diff --git a/com.connor.jd.plm/.classpath b/com.connor.jd.plm/.classpath index f420af9..0107178 100644 --- a/com.connor.jd.plm/.classpath +++ b/com.connor.jd.plm/.classpath @@ -3,11 +3,545 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -15,9 +549,5 @@ - - - - diff --git a/com.connor.jd.plm/.settings/org.eclipse.core.resources.prefs b/com.connor.jd.plm/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..2c04b7f --- /dev/null +++ b/com.connor.jd.plm/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//src/com/connor/jd/plm/handlers/Wf001ScheduleHandler.java=UTF-8 diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF index 7c4fa97..13001bc 100644 --- a/com.connor.jd.plm/META-INF/MANIFEST.MF +++ b/com.connor.jd.plm/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: JDProject Bundle-SymbolicName: com.connor.jd.plm;singleton:=true Bundle-Version: 1.0.0.qualifier -Require-Bundle: org.eclipse.ui, +Require-Bundle: org.eclipse.ui;bundle-version="3.108.0", com.teamcenter.rac.common;bundle-version="12000.1.0", com.teamcenter.rac.tcapps;bundle-version="12000.1.0", com.teamcenter.rac.util;bundle-version="12000.1.0", @@ -15,27 +15,33 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.forms;bundle-version="3.7.0" Automatic-Module-Name: JDProject Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: com.connor.jd.operations, - com.connor.jd.plm.dialogs, +Export-Package: com.connor.jd.plm.action, + com.connor.jd.plm.dialog, com.connor.jd.plm.form, com.connor.jd.plm.handlers, com.connor.jd.plm.table, - com.connor.jd.plm.utils, + com.connor.jd.plm.util, com.teamcenter.rac.form -Bundle-ClassPath: lib/commons-codec-1.13.jar, +Import-Package: com.teamcenter.services, + com.teamcenter.services.rac, + com.teamcenter.services.rac.core, + com.teamcenter.services.rac.core._2008_06 +Bundle-ClassPath: ., + lib/fastjson-1.2.9.jar, + lib/hutool-all-5.0.7.jar, + lib/commons-codec-1.13.jar, lib/commons-collections4-4.4.jar, lib/commons-compress-1.19.jar, lib/commons-logging-1.2.jar, lib/commons-math3-3.6.1.jar, + lib/jaxb-api-2.3.1.jar, + lib/jaxb-core-2.3.0.1.jar, + lib/jaxb-impl-2.3.2.jar, + lib/jfxrt.jar, lib/poi-4.1.1.jar, lib/poi-examples-4.1.1.jar, lib/poi-excelant-4.1.1.jar, lib/poi-ooxml-4.1.1.jar, lib/poi-ooxml-schemas-4.1.1.jar, lib/poi-scratchpad-4.1.1.jar, - lib/xmlbeans-3.1.0.jar, - ., - lib/jfxrt.jar, - lib/jaxb-api-2.3.1.jar, - lib/jaxb-core-2.3.0.1.jar, - lib/jaxb-impl-2.3.2.jar + lib/xmlbeans-3.1.0.jar diff --git a/com.connor.jd.plm/build.properties b/com.connor.jd.plm/build.properties index 368a476..3aea07f 100644 --- a/com.connor.jd.plm/build.properties +++ b/com.connor.jd.plm/build.properties @@ -4,19 +4,21 @@ bin.includes = plugin.xml,\ META-INF/,\ .,\ icons/,\ + lib/fastjson-1.2.9.jar,\ + lib/hutool-all-5.0.7.jar,\ lib/commons-codec-1.13.jar,\ lib/commons-collections4-4.4.jar,\ lib/commons-compress-1.19.jar,\ lib/commons-logging-1.2.jar,\ lib/commons-math3-3.6.1.jar,\ + lib/jaxb-api-2.3.1.jar,\ + lib/jaxb-core-2.3.0.1.jar,\ + lib/jaxb-impl-2.3.2.jar,\ + lib/jfxrt.jar,\ lib/poi-4.1.1.jar,\ lib/poi-examples-4.1.1.jar,\ lib/poi-excelant-4.1.1.jar,\ lib/poi-ooxml-4.1.1.jar,\ lib/poi-ooxml-schemas-4.1.1.jar,\ lib/poi-scratchpad-4.1.1.jar,\ - lib/xmlbeans-3.1.0.jar,\ - lib/jfxrt.jar,\ - lib/jaxb-api-2.3.1.jar,\ - lib/jaxb-core-2.3.0.1.jar,\ - lib/jaxb-impl-2.3.2.jar + lib/xmlbeans-3.1.0.jar diff --git a/com.connor.jd.plm/plugin.xml b/com.connor.jd.plm/plugin.xml index 8aef2ae..8b0d856 100644 --- a/com.connor.jd.plm/plugin.xml +++ b/com.connor.jd.plm/plugin.xml @@ -14,6 +14,7 @@ + @@ -59,6 +60,7 @@ + @@ -96,12 +98,15 @@ - + + + + @@ -142,8 +147,10 @@ - - + + + + @@ -192,7 +199,7 @@ - + @@ -234,7 +241,7 @@ - + @@ -277,11 +284,20 @@ - + + - + + + + + + + + + @@ -305,6 +321,7 @@ + @@ -366,6 +383,7 @@ + @@ -427,6 +445,9 @@ + + + @@ -481,24 +502,29 @@ - - - - - - - - - - + + + true + + + true + + + + + + diff --git a/com.connor.jd.plm/src/com/connor/jd/operations/ExcelImportServiceImpl.java b/com.connor.jd.plm/src/com/connor/jd/operations/ExcelImportServiceImpl.java deleted file mode 100644 index 6aef325..0000000 --- a/com.connor.jd.plm/src/com/connor/jd/operations/ExcelImportServiceImpl.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.connor.jd.operations; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -public class ExcelImportServiceImpl { - - public String importExcel(InputStream inputStream, String fileName) throws Exception { - - String message = "Import success"; - - boolean isE2007 = false; - // 判断是否是excel2007格式 - if (fileName.endsWith("xlsx")) { - isE2007 = true; - } - - int rowIndex = 0; - try { - InputStream input = inputStream; // 建立输入流 - Workbook wb; - // 根据文件格式(2003或者2007)来初始化 - if (isE2007) { - wb = new XSSFWorkbook(input); - } else { - wb = new HSSFWorkbook(input); - } - Sheet sheet = wb.getSheetAt(0); // 获得第一个表单 - int rowCount = sheet.getLastRowNum() + 1; - - for (int i = 1; i < rowCount; i++) { - rowIndex = i; - Row row; - - for (int j = 0; j < 26; j++) { - if (isMergedRegion(sheet, i, j)) { - System.out.print(getMergedRegionValue(sheet, i, j) + "\t"); - } else { - row = sheet.getRow(i); - System.out.print(row.getCell(j) + "\t"); - } - } - System.out.print("\n"); - } - } catch (Exception ex) { - message = "Import failed, please check the data in " + rowIndex + " rows "; - } - return message; - } - - /** - * 获取单元格的值 - * - * @param cell - * @return - */ - public String getCellValue(Cell cell) { - if (cell == null) - return ""; - return cell.getStringCellValue(); - } - - /** - * 合并单元格处理,获取合并行 - * - * @param sheet - * @return List - */ - public List getCombineCell(Sheet sheet) { - List list = new ArrayList<>(); - // 获得一个 sheet 中合并单元格的数量 - int sheetmergerCount = sheet.getNumMergedRegions(); - // 遍历所有的合并单元格 - for (int i = 0; i < sheetmergerCount; i++) { - // 获得合并单元格保存进list中 - CellRangeAddress ca = sheet.getMergedRegion(i); - list.add(ca); - } - return list; - } - - private int getRowNum(List listCombineCell, Cell cell, Sheet sheet) { - int xr = 0; - int firstC = 0; - int lastC = 0; - int firstR = 0; - int lastR = 0; - for (CellRangeAddress ca : listCombineCell) { - // 获得合并单元格的起始行, 结束行, 起始列, 结束列 - firstC = ca.getFirstColumn(); - lastC = ca.getLastColumn(); - firstR = ca.getFirstRow(); - lastR = ca.getLastRow(); - if (cell.getRowIndex() >= firstR && cell.getRowIndex() <= lastR) { - if (cell.getColumnIndex() >= firstC && cell.getColumnIndex() <= lastC) { - xr = lastR; - } - } - - } - return xr; - - } - - /** - * 判断单元格是否为合并单元格,是的话则将单元格的值返回 - * - * @param listCombineCell 存放合并单元格的list - * @param cell 需要判断的单元格 - * @param sheet sheet - * @return - */ - public String isCombineCell(List listCombineCell, Cell cell, Sheet sheet) throws Exception { - int firstC = 0; - int lastC = 0; - int firstR = 0; - int lastR = 0; - String cellValue = null; - for (CellRangeAddress ca : listCombineCell) { - // 获得合并单元格的起始行, 结束行, 起始列, 结束列 - firstC = ca.getFirstColumn(); - lastC = ca.getLastColumn(); - firstR = ca.getFirstRow(); - lastR = ca.getLastRow(); - if (cell.getRowIndex() >= firstR && cell.getRowIndex() <= lastR) { - if (cell.getColumnIndex() >= firstC && cell.getColumnIndex() <= lastC) { - Row fRow = sheet.getRow(firstR); - Cell fCell = fRow.getCell(firstC); - cellValue = getCellValue(fCell); - break; - } - } else { - cellValue = ""; - } - } - return cellValue; - } - - /** - * 获取合并单元格的值 - * - * @param sheet - * @param row - * @param column - * @return - */ - public String getMergedRegionValue(Sheet sheet, int row, int column) { - int sheetMergeCount = sheet.getNumMergedRegions(); - - for (int i = 0; i < sheetMergeCount; i++) { - CellRangeAddress ca = sheet.getMergedRegion(i); - int firstColumn = ca.getFirstColumn(); - int lastColumn = ca.getLastColumn(); - int firstRow = ca.getFirstRow(); - int lastRow = ca.getLastRow(); - - if (row >= firstRow && row <= lastRow) { - if (column >= firstColumn && column <= lastColumn) { - Row fRow = sheet.getRow(firstRow); - Cell fCell = fRow.getCell(firstColumn); - return getCellValue(fCell); - } - } - } - - return null; - } - - /** - * 判断指定的单元格是否是合并单元格 - * - * @param sheet - * @param row 行下标 - * @param column 列下标 - * @return - */ - private boolean isMergedRegion(Sheet sheet, int row, int column) { - int sheetMergeCount = sheet.getNumMergedRegions(); - for (int i = 0; i < sheetMergeCount; i++) { - CellRangeAddress range = sheet.getMergedRegion(i); - int firstColumn = range.getFirstColumn(); - int lastColumn = range.getLastColumn(); - int firstRow = range.getFirstRow(); - int lastRow = range.getLastRow(); - if (row >= firstRow && row <= lastRow) { - if (column >= firstColumn && column <= lastColumn) { - return true; - } - } - } - return false; - } - -} diff --git a/com.connor.jd.plm/src/com/connor/jd/operations/ExcelOperation.java b/com.connor.jd.plm/src/com/connor/jd/operations/ExcelOperation.java deleted file mode 100644 index 3b25807..0000000 --- a/com.connor.jd.plm/src/com/connor/jd/operations/ExcelOperation.java +++ /dev/null @@ -1,264 +0,0 @@ -package com.connor.jd.operations; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -import com.teamcenter.rac.kernel.TCComponent; - -public class ExcelOperation { - private static final String XLS = "xls"; - private static final String XLSX = "xlsx"; - - public static void writeExcel(File file, String outpath, Map> jfw) { - if (jfw.size() == 1) { - writeoneExcel(file, outpath, jfw); - } else { - writeallExcel(file, outpath, jfw); - } - } - - public static void writeallExcel(File file, String outpath, Map> jfw) { - Workbook workbook; - try { - workbook = getworkbook(file); - System.out.println("已有文件"); - Workbook newwb = getWorkbook(outpath); - Sheet newsheet = newwb.createSheet(); - Sheet sheet = workbook.getSheetAt(0); - CellStyle style = workbook.createCellStyle(); - Row row = sheet.getRow(0); - row.setRowStyle(style); - Row newrow0 = newsheet.createRow(0); - for (int i = 0; i < row.getLastCellNum(); i++) { - Cell newCell = newrow0.createCell(i); - newCell.setCellValue(row.getCell(i).getStringCellValue()); - } - List cellRangeList = getCombineCell(sheet); - for (Entry> ever : jfw.entrySet()) { - List itemList = ever.getValue(); - String sfname = ever.getKey(); - System.out.println("itemList长度" + itemList.size()); - for (int i = 0; i < cellRangeList.size(); i++) { - CellRangeAddress ca = cellRangeList.get(i); - int firstColumn = 0; - int firstRow = ca.getFirstRow(); - int lastRow = ca.getLastRow(); - Row fRow = sheet.getRow(firstRow); - Cell fCell = fRow.getCell(firstColumn); - String cellVelue = fCell.getStringCellValue(); - System.out.println("合并单元格的内容" + cellVelue); - System.out.println("起始行" + firstRow + "最后行" + lastRow); - if (sfname.equals(cellVelue)) { - for (int z = firstRow; z <= lastRow; z++) { - Row newRow = sheet.getRow(z); - String value = newRow.getCell(1).getStringCellValue(); - System.out.println("表格内容" + value); - for (int p = 0; p < itemList.size(); p++) { - if (itemList.get(p).getTCProperty("object_type").getDisplayableValue().equals(value)) { - TCComponent[] revlist = itemList.get(p).getTCProperty("revision_list") - .getReferenceValueArray(); - TCComponent component = null; - for (int revlength = 0; revlength < revlist.length; revlength++) { - String status = revlist[revlength].getProperty("release_status_list"); - if (!status.equals("")) { - component = revlist[revlength]; - } - } - String[] info = new String[4]; - if (component != null) { - info[0] = component.getProperty("owning_group"); - info[1] = component.getProperty("owning_user"); - info[2] = component.getProperty("creation_date"); - info[3] = component.getProperty("item_id"); - } else { - info[0] = ""; - info[1] = ""; - info[2] = ""; - info[3] = ""; - } - for (int v = 0; v < info.length; v++) { - Cell cellvalue = newRow.createCell(v + 2); - cellvalue.setCellValue(info[v]); - System.out.println("内容是" + info[v]); - } - } - } - } - } - - } - } - FileOutputStream fos = new FileOutputStream(outpath); - workbook.write(fos); - workbook.close(); - fos.close(); - } catch (Exception e) { - } - } - - public static void writeoneExcel(File file, String outpath, Map> jfw) { - Workbook workbook; - try { - workbook = getworkbook(file); - System.out.println("已有文件"); - Workbook newwb = getWorkbook(outpath); - Sheet newsheet = newwb.createSheet(); - Sheet sheet = workbook.getSheetAt(0); - CellStyle style = newwb.createCellStyle(); - Row row = sheet.getRow(0); - Row newrow0 = newsheet.createRow(0); - for (int i = 0; i < row.getLastCellNum(); i++) { - Cell oldCell = row.getCell(i); - style.cloneStyleFrom(oldCell.getCellStyle()); - - Cell newCell = newrow0.createCell(i); - newCell.setCellStyle(style); - newCell.setCellValue(oldCell.getStringCellValue()); - - } - List cellRangeList = getCombineCell(sheet); - for (Entry> ever : jfw.entrySet()) { - List itemList = ever.getValue(); - String sfname = ever.getKey(); - System.out.println("itemList长度" + itemList.size()); - for (int i = 0; i < cellRangeList.size(); i++) { - CellRangeAddress ca = cellRangeList.get(i); - int firstColumn = 0; - int firstRow = ca.getFirstRow(); - int lastRow = ca.getLastRow(); - Row fRow = sheet.getRow(firstRow); - Cell fCell = fRow.getCell(firstColumn); - String cellVelue = fCell.getStringCellValue(); - System.out.println("合并单元格的内容" + cellVelue); - System.out.println("起始行" + firstRow + "最后行" + lastRow); - - if (sfname.equals(cellVelue)) { - List valueList = new ArrayList(); - for (int z = firstRow; z <= lastRow; z++) { - Row oldRow = sheet.getRow(z); - String value = oldRow.getCell(1).getStringCellValue(); - - valueList.add(value); - } - - for (int j = 1; j <= lastRow - firstRow + 1; j++) { - Row newRow = newsheet.createRow(j); - Cell cell = newRow.createCell(0); - cell.setCellValue(cellVelue); - Cell cell2 = newRow.createCell(1); - cell2.setCellValue(valueList.get(j - 1)); - System.out.println("特殊表格内容" + valueList.get(j - 1)); - for (int p = 0; p < itemList.size(); p++) { - if (itemList.get(p).getTCProperty("object_type").getDisplayableValue() - .equals(valueList.get(j - 1))) { - System.out.println( - "类型:" + itemList.get(p).getTCProperty("object_type").getDisplayableValue()); - TCComponent[] revlist = itemList.get(p).getTCProperty("revision_list") - .getReferenceValueArray(); - TCComponent component = null; - for (int revlength = 0; revlength < revlist.length; revlength++) { - String status = revlist[revlength].getProperty("release_status_list"); - if (!status.equals("")) { - component = revlist[revlength]; - } - } - String[] info = new String[4]; - if (component != null) { - info[0] = component.getProperty("owning_group"); - info[1] = component.getProperty("owning_user"); - info[2] = component.getProperty("creation_date"); - info[3] = component.getProperty("item_id"); - } else { - info[0] = ""; - info[1] = ""; - info[2] = ""; - info[3] = ""; - } - for (int v = 0; v < info.length; v++) { - System.out.println("开始创建内容"); - Cell cellvalue = newRow.createCell(v + 2); - cellvalue.setCellValue(info[v]); - System.out.println("内容是" + info[v]); - } - } - } - } - CellRangeAddress region = new CellRangeAddress(1, lastRow - firstRow + 1, 0, 0); - newsheet.addMergedRegion(region); - } - - } - } - FileOutputStream fos = new FileOutputStream(outpath); - newwb.write(fos); - newwb.close(); - fos.close(); - } catch (Exception e) { - } - } - - /** - * 合并单元格处理,获取合并行 - * - * @param sheet - * @return List - */ - public static List getCombineCell(Sheet sheet) { - List list = new ArrayList<>(); - // 获得一个 sheet 中合并单元格的数量 - int sheetmergerCount = sheet.getNumMergedRegions(); - // 遍历所有的合并单元格 - for (int i = 0; i < sheetmergerCount; i++) { - // 获得合并单元格保存进list中 - CellRangeAddress ca = sheet.getMergedRegion(i); - list.add(ca); - } - return list; - } - - public static Workbook getWorkbook(String file) throws IOException { - Workbook workbook = null; - // FileInputStream in = new FileInputStream(file); - if (file.endsWith(XLS)) { - System.out.println("xls"); - workbook = new HSSFWorkbook(); - } else if (file.endsWith(XLSX)) { - System.out.println("xlsx"); - workbook = new XSSFWorkbook(); - } else { - System.out.println("格式错误"); - } - return workbook; - } - - public static Workbook getworkbook(File file) throws IOException { - Workbook workbook = null; - FileInputStream in = new FileInputStream(file); - if (file.getName().endsWith(XLS)) { - System.out.println("xls"); - workbook = new HSSFWorkbook(in); - } else if (file.getName().endsWith(XLSX)) { - System.out.println("xlsx"); - workbook = new XSSFWorkbook(in); - } else { - System.out.println("格式错误"); - } - in.close(); - return workbook; - } -} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/action/EditClassificationAction.java b/com.connor.jd.plm/src/com/connor/jd/plm/action/EditClassificationAction.java new file mode 100644 index 0000000..2fd400e --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/action/EditClassificationAction.java @@ -0,0 +1,29 @@ +package com.connor.jd.plm.action; + +import com.connor.jd.plm.dialog.EditClassificationDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.kernel.TCException; + +public class EditClassificationAction extends AbstractAIFAction { + private final AbstractAIFApplication app; + + public EditClassificationAction(AbstractAIFApplication arg0, String arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + new EditClassificationDialog(app); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java b/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java new file mode 100644 index 0000000..ffcfac1 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java @@ -0,0 +1,136 @@ +package com.connor.jd.plm.action; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.alibaba.fastjson.JSONObject; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + +import cn.hutool.http.HttpUtil; + +public class WLTZReviseAction extends AbstractAIFAction { + private AbstractAIFApplication app; + private TCSession session; + + public WLTZReviseAction(AbstractAIFApplication arg0, String arg1) { + super(arg0, arg1); + this.app = arg0; + this.session = (TCSession) app.getSession(); + + } + + @Override + public void run() { + // TODO Auto-generated method stub + TCComponent target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + String[] allow = getPrefStrArray("jd2_wltz_Revise_allow"); + List list = Arrays.asList(allow); + for (String s : list) { + System.out.println(s); + } + if (target instanceof TCComponentItemRevision) { + try { + TCComponentItemRevision rev = (TCComponentItemRevision) target; + String type = rev.getType(); + System.out.println(type); + if (!list.contains(type)) { + MessageBox.post("当前对象类型不允许修订并发送分类!", "错误", MessageBox.ERROR); + return; + } + TCComponentItem item = rev.getItem(); + TCComponentItemRevision newRev = rev.saveAs(item.getNewRev()); + TCComponentICO ico = rev.getClassificationObjects()[0]; + ICSProperty[] oldICSProps = ico.getICSProperties(true); + int[] ids = new int[oldICSProps.length]; + String[] values = new String[oldICSProps.length]; + for (int i = 0; i < oldICSProps.length; i++) { + System.out.println(oldICSProps[i].getId() + "=====>" + oldICSProps[i].getValue()); + ids[i] = oldICSProps[i].getId(); + values[i] = oldICSProps[i].getValue(); + } + JSONObject json = new JSONObject(); + json.put("ids", ids); + json.put("values", values); + String prop = json.toString(); + prop = prop.replace("\"", "\\\""); + System.out.println("prop:" + prop); + String uid = newRev.getUid(); + System.out.println("uid:" + uid); + String cid = rev.getClassificationClass(); + System.out.println("cid:" + cid); + String server = getPrefStr("jd2_server_ip"); + if (server == null || "".equals(server)) { + MessageBox.post("未配置jd2_server_ip首选项", "错误", MessageBox.ERROR); + return; + } + String url = "http://" + server + ":8080/classification"; + Map paramMap = new HashMap(); + paramMap.put("uid", uid); + paramMap.put("cid", cid); + paramMap.put("prop", prop); + final String URL = url; + final Map PARAMMAP = paramMap; + new Thread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + HttpUtil.post(URL, PARAMMAP); + System.out.println("success"); + } + }).start(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + MessageBox.post("当前对象类型不允许修订并发送分类!", "错误", MessageBox.ERROR); + } + } + + /** + * 获取单值得首选项 + * + * @param prefName + * @return + */ + public String getPrefStr(String prefName) { + TCPreferenceService service = session.getPreferenceService(); + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /** + * 获取多值得首选项 + * + * @param prefName + * @return + */ + public String[] getPrefStrArray(String prefName) { + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + service.getStringValues(prefName); + service.getStringValue(prefName); + if (strs == null) { + strs = new String[] { "" }; + } + return strs; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/action/package-info.java b/com.connor.jd.plm/src/com/connor/jd/plm/action/package-info.java new file mode 100644 index 0000000..8e74581 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/action/package-info.java @@ -0,0 +1 @@ +package com.connor.jd.plm.action; \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java new file mode 100644 index 0000000..2c51b6d --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java @@ -0,0 +1,221 @@ +package com.connor.jd.plm.dialog; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.ScrollPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSApplicationObject; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +public class EditClassificationDialog extends AbstractAIFDialog { + + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private TCComponent target; + private Map propMap; + private TCClassificationService myService; + final EditClassificationDialog DIALOG = this; + + public EditClassificationDialog(AbstractAIFApplication app) throws TCException { + this.app = app; + this.session = (TCSession) app.getSession(); + this.myService = session.getClassificationService(); + this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + if (target instanceof TCComponentItemRevision) { + try { + initUI(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + MessageBox.post("请选择版本", "错误", MessageBox.ERROR); + } + } + + private void initUI() { + this.setTitle("修改分类属性"); + this.setAutoRequestFocus(true); + this.setResizable(true); + + JPanel rootPanel = new JPanel(new BorderLayout()); + rootPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1)); + GridBagConstraints gbs = new GridBagConstraints(); + GridBagLayout gbl = new GridBagLayout(); + JPanel editPanel = new JPanel(gbl); + gbs.anchor = GridBagConstraints.NORTHWEST; + gbs.fill = GridBagConstraints.BOTH; + gbs.insets = new Insets(10, 20, 5, 10); + gbs.weighty = 0.2; + gbs.gridheight = 1; + + Map attr = null; + propMap = new HashMap(); + TCComponentItemRevision rev = (TCComponentItemRevision) target; + try { + if (rev.getClassificationClass() != null || !"".equals(rev.getClassificationClass())) { + try { + attr = rev.getClassificationAttributes(); + + for (Entry entry : attr.entrySet()) { + System.out.println(entry.getKey() + "===>" + entry.getValue()); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else { + MessageBox.post("当前版本未被分类", "错误", MessageBox.ERROR); + return; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if (attr != null) { + int num = 0; + JLabel[] names = new JLabel[attr.size()]; + JTextField[] values = new JTextField[attr.size()]; + for (Entry entry : attr.entrySet()) { + gbs.gridwidth = 1; + gbs.weightx = 0.4; + names[num] = new JLabel(entry.getKey() + ":"); + gbl.setConstraints(names[num], gbs); + gbs.gridwidth = GridBagConstraints.REMAINDER; + gbs.weightx = 2; + values[num] = new JTextField(entry.getValue()); + propMap.put(entry.getKey(), values[num]); + gbl.setConstraints(values[num], gbs); + editPanel.add(names[num]); + editPanel.add(values[num]); + num++; + } + + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + JButton cancelBtn = new JButton("取消"); + cancelBtn.addActionListener(cancel()); + JButton okBtn = new JButton("确认"); + okBtn.addActionListener(ok()); + buttonPanel.add(okBtn); + buttonPanel.add(cancelBtn); + + ScrollPane scroll = new ScrollPane(); + scroll.add(editPanel); + scroll.setPreferredSize(new Dimension(300, 300)); + rootPanel.add(scroll, BorderLayout.CENTER); + rootPanel.add(buttonPanel, BorderLayout.SOUTH); + this.setLayout(new BorderLayout()); + this.add(rootPanel); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + } + + private ActionListener ok() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + TCComponentItemRevision rev = (TCComponentItemRevision) target; + saveClassification(rev); + try { + if (rev.getProperty("object_type").equals("JD2_GTBJRevision")) { + TCProperty property = rev.getTCProperty("TC_Is_Represented_By"); + TCComponent[] comp = property.getReferenceValueArray(); + if (comp.length > 0) { + TCComponentItemRevision tzrev = (TCComponentItemRevision) comp[0]; + saveClassification(tzrev); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + DIALOG.disposeDialog(); + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + DIALOG.disposeDialog(); + } + }; + } + + private boolean saveClassification(TCComponentItemRevision rev) { + + try { + ICSApplicationObject icsAppObj = myService.newICSApplicationObject("ICM"); + TCComponentICO[] icoS = rev.getClassificationObjects(); + String classID = rev.getClassificationClass(); + if (icoS == null || icoS.length == 0) { + return false; + } + for (int i = 0; i < icoS.length; i++) { + TCComponentICO ico = icoS[i]; + ICSPropertyDescription[] desc = ico.getICSPropertyDescriptors(); + ICSProperty[] oldICSProps = ico.getICSProperties(true); + ICSProperty[] newICSProps = new ICSProperty[oldICSProps.length]; + for (int j = 0; j < oldICSProps.length; j++) { + ICSProperty icsProp = oldICSProps[j]; + // icsProp.setValue("1111"); + newICSProps[j] = new ICSProperty(icsProp.getId(), "111111"); + } + for (int j = 0; j < oldICSProps.length; j++) { + newICSProps[j].setValue(propMap.get(desc[j].getName()).getText()); + } + ico.delete(); + icsAppObj.create(myService.getTCComponentId(rev), myService.getTCComponentUid(rev)); + icsAppObj.setView(classID); + + icsAppObj.setProperties(newICSProps); + icsAppObj.save(); + } + rev.refresh(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return true; + } +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/package-info.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/package-info.java new file mode 100644 index 0000000..803ca64 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/package-info.java @@ -0,0 +1 @@ +package com.connor.jd.plm.dialog; \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java index b768822..e693586 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java @@ -1,39 +1,5 @@ package com.connor.jd.plm.dialogs; -import javax.swing.JPanel; +public class CSXWHDialog { -import com.teamcenter.rac.aif.AbstractAIFApplication; -import com.teamcenter.rac.kernel.TCException; - -import javafx.application.Application; -import javafx.scene.Scene; -import javafx.scene.layout.Pane; -import javafx.stage.Stage; - -public class CSXWHDialog extends Application { - - private AbstractAIFApplication app; - - public CSXWHDialog() throws TCException { - - } - - private JPanel Panel; - private Object[] obj = new Object[] { "序号", "产品类型", "试验项目", "试验时间", "样品数量", "试验费用" };// 民用表 - private Object[] obj2 = new Object[] { "序号", "类别", "项目", "项目费用" };// 工业表 - - public void initUI() { - - } - - @Override - public void start(Stage arg0) throws Exception { - Stage primaryStage = new Stage(); - Pane root = new Pane(); - Scene scene = new Scene(root, 382, 178); - primaryStage.setScene(scene); - primaryStage.setTitle("测试项维护"); - primaryStage.show(); - - } } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/PhotoFrame.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/PhotoFrame.java index dba4a99..1777960 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/PhotoFrame.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/PhotoFrame.java @@ -3,7 +3,6 @@ package com.connor.jd.plm.form; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; -import java.awt.Image; import java.awt.Toolkit; import javax.swing.JFrame; @@ -21,11 +20,22 @@ public class PhotoFrame extends JFrame { public static PhotoFrame getInstance(String imgPath) { if (instance == null) { instance = new PhotoFrame(imgPath); + } else { + instance.zPanel.setImagePath(imgPath); + instance.setVisible(true); + instance.zPanel.setPreferredSize( + new Dimension(instance.zPanel.getImgWidth(), + instance.zPanel.getImgHeight())); } return instance; } private PhotoFrame(String imgPath) { + init(imgPath); + finalSetting(); + } + + private void init(String imgPath) { con = getContentPane(); zPanel = new ZPanel(); @@ -40,16 +50,10 @@ public class PhotoFrame extends JFrame { imgSp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); con.add(imgSp, BorderLayout.CENTER); - - finalSetting(); } private void finalSetting() { - setTitle("ZakiSoft ZFileRenamerV0.2"); - - Image image = Toolkit.getDefaultToolkit() - .getImage(this.getClass().getResource("/title.gif")); - setIconImage(image); + setTitle("预览"); Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); @@ -59,10 +63,17 @@ public class PhotoFrame extends JFrame { int frameW = getWidth(); setLocation((screenWidth - frameW) / 2 - 250, (screenHeight - frameH) / 2 - 250); - setSize(500, 350); + setSize(screenWidth / 2, screenHeight / 2); setVisible(true); - setResizable(false); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setResizable(true); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } + @Override + public void dispose() { + // TODO Auto-generated method stub + super.dispose(); + System.out.println("预览关闭"); + zPanel.clear(); + } } \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index 8c9d2ac..414e1de 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -39,6 +39,7 @@ import com.connor.jd.plm.table.CTable; import com.connor.jd.plm.table.JCheckPanel; import com.connor.jd.plm.table.JRadioPanel; import com.connor.jd.plm.table.MyCellEditor; +import com.connor.jd.plm.table.TCTableUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aifrcp.AIFUtility; @@ -58,18 +59,30 @@ public class SampleConfirmationForm extends AbstractRendering { private CardLayout cl = new CardLayout(); private JPanel center = null; private JPopupMenu menu = new JPopupMenu(); + private JPopupMenu menu2 = new JPopupMenu(); private JPanel confirmPanel = new JPanel(); private JPanel examinePanel = new JPanel(); private CTMap model; private CTMap model2; private CTable table; private CTable table2; - private int bottom; - private int top = 13; + private int top = 13;// 头部行数 + private int bottom;// 中间部分结束 + private int end = 14;// 尾部行数+1 + private int top2 = 4; + private int bottom2; + private int end2 = 16; + private Map prop; private Map general; private List disableEdit; - private Map prop; private Map pic; + private Map general2; + private List disableEdit2; + private JRadioPanel sysl; + private JCheckPanel mqjd; + String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", + "jd2_1", "jd2_2", "jd2_3", "jd2_4", "jd2_5", "jd2_6", "jd2_7", + "jd2_8", "jd2_9", "jd2_10", "jd2_min", "jd2_max", "jd2_jg" }; public SampleConfirmationForm(TCComponent arg0) throws Exception { super(arg0); @@ -105,7 +118,7 @@ public class SampleConfirmationForm extends AbstractRendering { // 设置属性 model = new CTMap(47, 20); - bottom = model.getRowCount() - 14; + bottom = model.getRowCount() - end; disableEdit = new ArrayList<>();// 不允许编辑 general = new HashMap();// 要填写的一般属性 pic = new HashMap();// 图片 @@ -122,17 +135,25 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt("滚筒研发", 2, 2); disableEdit.add("2,2"); general.put("jd2_bz", new int[] { 2, 14 }); + disableEdit.add("2,14"); general.put("jd2_sh", new int[] { 2, 16 }); + disableEdit.add("2,16"); general.put("jd2_pz", new int[] { 2, 18 }); + disableEdit.add("2,18"); model.setValueAt("创建日期", 4, 0); disableEdit.add("4,0"); general.put("creation_date", new int[] { 4, 2 }); + disableEdit.add("4,2"); model.setValueAt("创建人", 4, 5); disableEdit.add("4,5"); general.put("owning_user", new int[] { 4, 7 }); + disableEdit.add("4,7"); general.put("jd2_bzrq", new int[] { 4, 14 }); + disableEdit.add("4,14"); general.put("jd2_shrq", new int[] { 4, 16 }); + disableEdit.add("4,16"); general.put("jd2_pzrq", new int[] { 4, 18 }); + disableEdit.add("4,18"); model.setValueAt("零件名", 6, 0); disableEdit.add("6,0"); general.put("jd2_ljm", new int[] { 6, 2 }); @@ -148,8 +169,7 @@ public class SampleConfirmationForm extends AbstractRendering { general.put("jd2_wlbm", new int[] { 7, 2 }); model.setValueAt("送样数量", 7, 8); disableEdit.add("7,8"); - JRadioPanel sysl = new JRadioPanel( - new String[] { "3", "5", "10", "30" }); + sysl = new JRadioPanel(new String[] { "3", "5", "10", "30" }); model.setValueAt(sysl, 7, 10); model.setValueAt("状态", 7, 14); disableEdit.add("7,14"); @@ -175,7 +195,7 @@ public class SampleConfirmationForm extends AbstractRendering { general.put("jd2_syyy", new int[] { 9, 10 }); model.setValueAt("目前阶段", 12, 0); disableEdit.add("12,0"); - JCheckPanel mqjd = new JCheckPanel( + mqjd = new JCheckPanel( new String[] { "DV", "PV", "PR", "SR", "现场测试", "MP" }); model.setValueAt(mqjd, 12, 2); @@ -201,7 +221,7 @@ public class SampleConfirmationForm extends AbstractRendering { disableEdit.add(top + 1 + ",18"); for (int i = top + 2; i <= bottom; i++) { - model.setValueAt(i - 1, i, 0); + model.setValueAt(i - 1 - top, i, 0); disableEdit.add(i + ",0"); model.combine(new int[] { i }, new int[] { 2, 3, 4 }); } @@ -407,7 +427,7 @@ public class SampleConfirmationForm extends AbstractRendering { table.getColumnModel().getColumn(5).setPreferredWidth(60); table.getColumnModel().getColumn(6).setPreferredWidth(60); for (int i = 7; i < model.getColumnCount() - 1; i++) { - table.getColumnModel().getColumn(i).setPreferredWidth(40); + table.getColumnModel().getColumn(i).setPreferredWidth(45); } table.getColumnModel().getColumn(model.getColumnCount() - 1) .setPreferredWidth(80); @@ -479,6 +499,7 @@ public class SampleConfirmationForm extends AbstractRendering { mqjd.setSelected(prop.get("jd2_mqjd")); } pic.put("user_data_1", new int[] { bottom + 3, 0 }); + pic.put("user_data_2", new int[] { bottom + 3, 9 }); for (Entry entry : pic.entrySet()) { if (prop.containsKey(entry.getKey())) { TCComponent comp = null; @@ -501,7 +522,7 @@ public class SampleConfirmationForm extends AbstractRendering { int col = entry.getValue()[1]; int[] arr = model.getSpan(row, col); int width = 0; - for(int i=0;i bottom) { + int num = Integer.parseInt( + model.getValueAt(bottom, 0).toString()); + model.insertRow(bottom); + model.setValueAt(num + 1, bottom, 0); + model.combine(new int[] { bottom }, + new int[] { 2, 3, 4 }); + bottom = model.getRowCount() - end; + } + model.setValueAt(tableRows[i][ii], i + top + 2, + ii > 2 ? ii + 2 : ii); + } + } + } ScrollPane confirmScrollPanel = new ScrollPane(); confirmScrollPanel.add(confirmPanel); // 检查表 - JTextField text2 = new JTextField("examine"); - examinePanel.add(text2); + examinePanel.setBorder(BorderFactory.createLineBorder(Color.black, 1)); + examinePanel.setLayout(new BorderLayout()); + + model2 = new CTMap(49, 10); + bottom2 = model2.getRowCount() - end2; + model2.setValueAt("SPL No", 0, 0); + disableEdit2.add("0,0"); + model2.combine(new int[] { 0, 1, 2, 3 }, new int[] { 0 }); + model2.setValueAt("规格 SPEC", 0, 1); + disableEdit2.add("0,1"); + model2.combine(new int[] { 0, 1 }, new int[] { 1 }); + for (int i = 0; i < 8; i++) { + model2.setValueAt("CTQ<" + i + 1 + ">", 0, i + 2); + disableEdit2.add("0," + (i + 2)); + } + model2.setValueAt("LOW", 2, 1); + disableEdit2.add("2,1"); + model2.setValueAt("UP", 3, 1); + disableEdit2.add("3,1"); + + for (int i = top2; i <= model2.getRowCount(); i++) { + model2.setValueAt(i - top2, i, 0); + disableEdit2.add(i + ",0"); + model2.combine(new int[] { i }, new int[] { 0, 1 }); + } + model2.setValueAt("MIN", bottom + 1, 0); + model2.setValueAt("MAX", bottom + 2, 0); + model2.setValueAt("R", bottom + 3, 0); + model2.setValueAt("标准偏差", bottom + 4, 0); + model2.setValueAt("平均", bottom + 5, 0); + model2.setValueAt("X,BAR-3S", bottom + 6, 0); + model2.setValueAt("X,BAR+3S", bottom + 7, 0); + model2.setValueAt("CP", bottom + 8, 0); + model2.setValueAt("Cpu", bottom + 9, 0); + model2.setValueAt("Cpl", bottom + 10, 0); + model2.setValueAt("CPK", bottom + 11, 0); + model2.setValueAt("SU 预测不良", bottom + 12, 0); + model2.setValueAt("SL 预测不良", bottom + 13, 0); + model2.setValueAt("预测不良(PPM)", bottom + 14, 0); + model2.setValueAt("工程能力意义", bottom + 15, 0); + + table2 = new CTable(model2) { + @Override + public boolean isCellEditable(int row, int col) { + if (isEditorDisable(disableEdit2, row, col)) { + return false; + } + return true; + } + }; + table2.setRowHeight(25); + table2.setBorder(BorderFactory.createLineBorder(Color.black)); + for (int i = 0; i < model.getColumnCount(); i++) { + table2.getColumnModel().getColumn(i).setPreferredWidth(80); + } + DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() { + // 重写方法 + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, boolean isSelected, boolean hasFocus, int row, + int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), + 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + setBackground(Color.white); +// if(points1.contains(new Point(row,column))) +// setForeground(new Color(0,0,255)); +// else + setForeground(Color.black); + if (isSelected) { + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙 + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + }; + tcr2.setHorizontalAlignment(SwingConstants.CENTER); + table2.setDefaultRenderer(Object.class, tcr2); + table2.addMouseListener(rightClick2()); + examinePanel.add(table2, BorderLayout.CENTER); - // 右键菜单 + ScrollPane examineScrollPanel = new ScrollPane(); + examineScrollPanel.add(examinePanel); + + // 确认单右键菜单 menu.setVisible(false); JMenuItem addP; addP = new JMenuItem("添加图片"); @@ -549,8 +681,26 @@ public class SampleConfirmationForm extends AbstractRendering { menu.add(insertR); insertR.addActionListener(insertRow()); + // 检验单右键菜单 + menu2.setVisible(false); + JMenuItem addR2; + addR2 = new JMenuItem("添加行"); + menu2.add(addR2); + addR2.addActionListener(addRow2()); + JMenuItem insertR2; + insertR2 = new JMenuItem("插入行"); + menu2.add(insertR2); + insertR2.addActionListener(insertRow2()); + center.add("confirm", confirmScrollPanel); - center.add("examine", examinePanel); + center.add("examine", examineScrollPanel); + root.add(buttons, BorderLayout.NORTH); + root.add(center, BorderLayout.CENTER); + this.add(menu); + this.add(root, BorderLayout.CENTER); + + center.add("confirm", confirmScrollPanel); + center.add("examine", examineScrollPanel); root.add(buttons, BorderLayout.NORTH); root.add(center, BorderLayout.CENTER); this.add(menu); @@ -561,7 +711,7 @@ public class SampleConfirmationForm extends AbstractRendering { @Override public void saveRendering() { - // TODO Auto-generated method stub + // 保存图片 JLabel label = null; for (Entry entry : pic.entrySet()) { if (prop.containsKey(entry.getKey())) { @@ -576,6 +726,58 @@ public class SampleConfirmationForm extends AbstractRendering { } } + // 保存选择 + try { + if (prop.containsKey("jd2_sysl")) { + form.setProperty("jd2_sysl", sysl.getSelected() == null ? "" + : sysl.getSelected().getText()); + } + if (prop.containsKey("jd2_mqjd")) { + form.setProperty("jd2_mqjd", mqjd.getSelectedText() == null ? "" + : mqjd.getSelectedText()); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // 保存普通数据 + for (Entry entry : general.entrySet()) { + try { + if (prop.containsKey(entry.getKey())) { + form.setProperty(entry.getKey(), + model.getValueAt(entry.getValue()[0], + entry.getValue()[1]).toString()); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + // 保存表格 + if (prop.containsKey("jd2_ypqrdtable")) { + List data = new ArrayList(); + int num = 0; + while (model.getValueAt(top + 2 + num, 1) != null + && !"".equals(model.getValueAt(top + 2 + num, 1))) { + String[] row = new String[18]; + for (int ii = 0; ii < 18; ii++) { + Object object = model.getValueAt(top + 2 + num, + ii > 2 ? ii + 2 : ii); + if (object == null) { + row[ii] = ""; + } else { + row[ii] = object.toString(); + } + System.out.println(row[ii]); + } + data.add(row); + num++; + } + String[][] dataArr = data.toArray(new String[data.size()][]); + System.out.println(Arrays.deepToString(dataArr)); + TCTableUtil.setTableRows(form, "jd2_ypqrdtable", colNames, dataArr); + } } @@ -584,7 +786,6 @@ public class SampleConfirmationForm extends AbstractRendering { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub System.out.println("confirm"); cl.show(center, "confirm"); } @@ -618,6 +819,19 @@ public class SampleConfirmationForm extends AbstractRendering { return mouseAdapter; } + private MouseAdapter rightClick2() { + MouseAdapter mouseAdapter = new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() + && table2.getSelectedRow() != -1) { + menu2.show(e.getComponent(), e.getX(), e.getY()); + } + } + }; + return mouseAdapter; + } + private ActionListener addPic() { ActionListener actionListener = new ActionListener() { @@ -654,7 +868,6 @@ public class SampleConfirmationForm extends AbstractRendering { try { datasetType = (TCComponentDatasetType) session .getTypeComponent("Dataset"); - TCComponentDataset dataset = datasetType .create(file.getName(), "", "Image"); dataset.setFiles(as1, as2); @@ -706,7 +919,29 @@ public class SampleConfirmationForm extends AbstractRendering { model.insertRow(bottom); model.setValueAt(num + 1, bottom, 0); model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); - bottom = model.getRowCount() - 14; + bottom = model.getRowCount() - end; + } else { + // 提示 + } + } + }; + return actionListener; + } + + private ActionListener addRow2() { + ActionListener actionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int row = table2.getSelectedRow(); + if (row >= top2 && row <= bottom2) { + int num = Integer + .parseInt(model2.getValueAt(bottom2, 0).toString()); + model2.insertRow(bottom2); + model2.setValueAt(num + 1, bottom2, 0); + model2.combine(new int[] { bottom2 }, new int[] { 0, 1 }); + bottom2 = model2.getRowCount() - end2; } else { // 提示 } @@ -730,7 +965,31 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt(num + i + 1 - row, row, 0); } model.combine(new int[] { row }, new int[] { 2, 3, 4 }); - bottom = model.getRowCount() - 14; + bottom = model.getRowCount() - end; + } else { + // 提示 + } + } + }; + return actionListener; + } + + private ActionListener insertRow2() { + ActionListener actionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int row = table2.getSelectedRow(); + if (row >= top2 && row <= bottom2) { + int num = Integer + .parseInt(model2.getValueAt(row, 0).toString()); + model2.insertRow(row); + for (int i = row; i < model2.getRowCount(); i++) { + model2.setValueAt(num + i + 1 - row, row, 0); + } + model2.combine(new int[] { row }, new int[] { 0, 1 }); + bottom2 = model2.getRowCount() - end2; } else { // 提示 } @@ -744,11 +1003,12 @@ public class SampleConfirmationForm extends AbstractRendering { } private MouseAdapter showImg(String path) { + final String imagePath = path; MouseAdapter adapter = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { - PhotoFrame.getInstance(path); + PhotoFrame.getInstance(imagePath); } } }; diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ZPanel.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ZPanel.java index 041251b..ed83ffe 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/ZPanel.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ZPanel.java @@ -14,6 +14,7 @@ public class ZPanel extends javax.swing.JPanel { private Image image; private int imgWidth; private int imgHeight; + private FileInputStream input; public int getImgWidth() { return imgWidth; @@ -39,7 +40,8 @@ public class ZPanel extends javax.swing.JPanel { // image = Toolkit.getDefaultToolkit().getImage(imgPath); try { // 该方法会将图像加载到内存,从而拿到图像的详细信息。 - image = ImageIO.read(new FileInputStream(imgPath)); + input = new FileInputStream(imgPath); + image = ImageIO.read(input); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { @@ -62,4 +64,16 @@ public class ZPanel extends javax.swing.JPanel { this); g = null; } + + public void clear() { + if (input != null) { + try { + image = null; + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } } \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java index 70994ff..6bc75e6 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java @@ -4,36 +4,10 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -import com.connor.jd.plm.dialogs.CSXWHDialog; -import com.teamcenter.rac.aif.AbstractAIFUIApplication; -import com.teamcenter.rac.aifrcp.AIFUtility; -import com.teamcenter.rac.kernel.TCSession; - -import javafx.application.Platform; -import javafx.embed.swing.JFXPanel; -import javafx.stage.Stage; - public class CSXWHHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); - TCSession session = (TCSession) app.getSession(); - new Thread(() -> { - new JFXPanel(); - Platform.setImplicitExit(false); - Platform.runLater(new Runnable() { - @Override - public void run() { - try { - CSXWHDialog csxwh = new CSXWHDialog(); - csxwh.start(new Stage()); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - }).start(); return null; } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CreateItemHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CreateItemHandler.java index 1432abc..43a878d 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CreateItemHandler.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CreateItemHandler.java @@ -38,8 +38,7 @@ import com.teamcenter.rac.util.UIUtilities; import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog; import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper; -public class CreateItemHandler extends AbstractHandler - implements IExecutableExtension { +public class CreateItemHandler extends AbstractHandler implements IExecutableExtension { private TCSession session; private String name; private AbstractAIFApplication app; @@ -58,8 +57,7 @@ public class CreateItemHandler extends AbstractHandler protected NewBOModel m_boModel; @Override - public Object execute(ExecutionEvent executionevent) - throws ExecutionException { + public Object execute(ExecutionEvent executionevent) throws ExecutionException { System.out.println("开始执行-----------"); app = AIFUtility.getCurrentApplication(); TCComponent comp = (TCComponent) app.getTargetComponent(); @@ -103,8 +101,7 @@ public class CreateItemHandler extends AbstractHandler throw new IllegalArgumentException("Event can't be null"); boolean flag = false; - if (executionevent.getParameters() != null - && executionevent.getParameters().containsKey("selection")) { + if (executionevent.getParameters() != null && executionevent.getParameters().containsKey("selection")) { Object obj = executionevent.getParameters().get("selection"); if (obj instanceof InterfaceAIFComponent[]) { selectedCmps = (InterfaceAIFComponent[]) obj; @@ -113,10 +110,8 @@ public class CreateItemHandler extends AbstractHandler } } if (!flag) { - m_currentSelection = HandlerUtil - .getCurrentSelection(executionevent); - selectedCmps = SelectionHelper - .getTargetComponents(m_currentSelection); + m_currentSelection = HandlerUtil.getCurrentSelection(executionevent); + selectedCmps = SelectionHelper.getTargetComponents(m_currentSelection); } m_boModel = getBOModel(); launchWizard(executionevent); @@ -128,13 +123,12 @@ public class CreateItemHandler extends AbstractHandler * * if (opType .equals("")) { TCComponentItemType itemType = * (TCComponentItemType) session.getTypeComponent(opType); // create参数: - * ID、版本、类型、名称、描述、单位 TCComponentItem item = - * itemType.create(itemType.getNewID(), itemType.getNewRev(null), opType, - * name + "表", "", null); + * ID、版本、类型、名称、描述、单位 TCComponentItem item = itemType.create(itemType.getNewID(), + * itemType.getNewRev(null), opType, name + "表", "", null); * * comp.add("contents", item); MessageBox.post(name + "表对象创建成功", "成功", - * MessageBox.INFORMATION); } } catch (TCException e) { // TODO - * Auto-generated catch block e.printStackTrace(); } } + * MessageBox.INFORMATION); } } catch (TCException e) { // TODO Auto-generated + * catch block e.printStackTrace(); } } */ private class CreateNewBOSWTDialog implements Runnable { @@ -215,16 +209,14 @@ public class CreateItemHandler extends AbstractHandler m_type = s; } - CreateNewBOSWTDialog(Shell shell, String s, - CreateNewBOSWTDialog createnewboswtdialog) { + CreateNewBOSWTDialog(Shell shell, String s, CreateNewBOSWTDialog createnewboswtdialog) { this(shell, s); } } @Override - public void setInitializationData( - IConfigurationElement iconfigurationelement, String s, Object obj) + public void setInitializationData(IConfigurationElement iconfigurationelement, String s, Object obj) throws CoreException { } @@ -263,12 +255,10 @@ public class CreateItemHandler extends AbstractHandler protected void initWizardModel(ExecutionEvent executionevent) { boolean flag = false; Object obj = null; - ISessionService isessionservice = (ISessionService) OSGIUtil.getService( - RACUICommandsActivator.getDefault(), + ISessionService isessionservice = (ISessionService) OSGIUtil.getService(RACUICommandsActivator.getDefault(), com.teamcenter.rac.services.ISessionService.class); try { - session = (TCSession) isessionservice.getSession( - com.teamcenter.rac.kernel.TCSession.class.getName()); + session = (TCSession) isessionservice.getSession(com.teamcenter.rac.kernel.TCSession.class.getName()); } catch (Exception _ex) { session = (TCSession) AIFUtility.getDefaultSession(); } @@ -277,11 +267,9 @@ public class CreateItemHandler extends AbstractHandler m_boModel.setFrame(AIFUtility.getActiveDesktop()); if (executionevent != null) { if (executionevent.getParameters().containsKey("revisionFlag")) - flag = ((Boolean) executionevent.getParameters() - .get("revisionFlag")).booleanValue(); + flag = ((Boolean) executionevent.getParameters().get("revisionFlag")).booleanValue(); if (executionevent.getParameters().containsKey("pasteRelation")) { - String s = (String) executionevent.getParameters() - .get("pasteRelation"); + String s = (String) executionevent.getParameters().get("pasteRelation"); if (s != null) { String as[] = null; as = s.split(","); @@ -289,8 +277,7 @@ public class CreateItemHandler extends AbstractHandler m_boModel.setPreAssignedRelType(as); } } - if (executionevent.getParameters() - .containsKey("parentComponents")) { + if (executionevent.getParameters().containsKey("parentComponents")) { InterfaceAIFComponent ainterfaceaifcomponent[] = (InterfaceAIFComponent[]) executionevent .getParameters().get("parentComponents"); m_boModel.setTargetArray(ainterfaceaifcomponent); @@ -307,8 +294,7 @@ public class CreateItemHandler extends AbstractHandler m_boModel.setCurrentSelection(m_currentSelection); } - protected void readDisplayParameters(NewBOWizard newbowizard, - WizardDialog wizarddialog) { + protected void readDisplayParameters(NewBOWizard newbowizard, WizardDialog wizarddialog) { newbowizard.retrievePersistedDialogSettings(wizarddialog); } @@ -317,8 +303,7 @@ public class CreateItemHandler extends AbstractHandler try { TCTypeService service = session.getTypeService(); - TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service - .getTypeComponent("BOMWindow"); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); window = winType.create(null); line = window.setWindowTopLine(rev.getItem(), rev, null, null); // window.close();//如果不关闭,会导致BOM被占用,乃至包含BOM的版本不能删除,除非重启TC diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/EditClassificationHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/EditClassificationHandler.java new file mode 100644 index 0000000..772372b --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/EditClassificationHandler.java @@ -0,0 +1,22 @@ +package com.connor.jd.plm.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.jd.plm.action.EditClassificationAction; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class EditClassificationHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + EditClassificationAction action = new EditClassificationAction(app, ""); + new Thread(action).start(); + return null; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/WLTZReviseHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/WLTZReviseHandler.java new file mode 100644 index 0000000..2b41687 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/WLTZReviseHandler.java @@ -0,0 +1,22 @@ +package com.connor.jd.plm.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.jd.plm.action.WLTZReviseAction; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class WLTZReviseHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + WLTZReviseAction action = new WLTZReviseAction(app, ""); + new Thread(action).start(); + return null; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/Wf001ScheduleHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/Wf001ScheduleHandler.java new file mode 100644 index 0000000..41c4f68 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/Wf001ScheduleHandler.java @@ -0,0 +1,105 @@ +package com.connor.jd.plm.handlers; + +import java.text.MessageFormat; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.schedule.commands.newschedule.NewScheduleHandler; +import com.teamcenter.rac.schedule.plugin.Activator; +import com.teamcenter.rac.schedule.project.sharedUtils.TimeZoneCalUtil; +import com.teamcenter.rac.schedule.wizardpages.SchedulePageModel; +import com.teamcenter.rac.ui.commands.handlers.NewBOHandler; +import com.teamcenter.rac.util.Registry; + +public class Wf001ScheduleHandler extends NewBOHandler { + + private TCSession session; + + public Wf001ScheduleHandler() { + } + + public static SchedulePageModel getScheduleModel() { + if (scheduleModel == null) + scheduleModel = new SchedulePageModel(); + return scheduleModel; + } + + @Override + public Object execute(ExecutionEvent executionevent) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp == null) { + return null; + } + if (targetComp instanceof TCComponentFolder) { + + scheduleModel = null; + wizardId = "com.teamcenter.rac.schedule.commands.newschedule.GenericScheduleWizard"; + TCSession tcsession = (TCSession) Activator.getDefault().getSessionService().getDefaultSession(); + TCPreferenceService tcpreferenceservice = tcsession.getPreferenceService(); + String s = tcpreferenceservice.getString(4, "SiteTimeZone", "null"); + IWorkbench iworkbench = PlatformUI.getWorkbench(); + IWorkbenchWindow iworkbenchwindow = iworkbench.getActiveWorkbenchWindow(); + Shell shell = iworkbenchwindow.getShell(); + if ("null".equals(s) || s == null) { + MessageDialog.openInformation(shell, textRegistry.getString("tzNotSet.TITLE"), + textRegistry.getString("tzNotSet.MSG")); + return Boolean.valueOf(false); + } + if (!TimeZoneCalUtil.testTimeZoneID(s)) { + String s1 = textRegistry.getString("tzInvalid.MSG"); + s1 = MessageFormat.format(s1, new Object[] { s }); + MessageDialog.openInformation(shell, textRegistry.getString("tzInvalid.TITLE"), s1); + return Boolean.valueOf(false); + } else { + return super.execute(executionevent); + } +// +// } else +// + +// if (targetComp.getType().equals("TC_Project")) { +// +// CreateScheduleOperation operation = new CreateScheduleOperation(targetComp,session); +// session.queueOperation(operation); +// +// return null; +// } else { +// MessageBox.post("脟毛脩隆脰脨脧卯脛驴脰麓脨脨麓麓陆篓!!", "麓铆脦贸", MessageBox.ERROR); +// return null; + } + return null; + } + + @Override + public String getWizardTitle() { + Registry registry = Registry.getRegistry(NewScheduleHandler.class); + return registry.getString("dialog.TITLE"); + } + + private static SchedulePageModel scheduleModel = null; + private final Registry textRegistry = Registry.getRegistry("com.teamcenter.rac.schedule.schedule"); + +} + +/* + * DECOMPILATION REPORT + * + * Decompiled from: + * D:\Teamcenter_4Sh\OTW11\rac\plugins\com.teamcenter.rac.schedule_11000.2.0.jar + * Total time: 1083 ms Jad reported messages/errors: Exit status: 0 Caught + * exceptions: + */ \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java index 6b62352..946e475 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java @@ -36,13 +36,29 @@ public class JCheckPanel extends JPanel { return list; } + public String getSelectedText() { + List list = getSelected(); + if (list.size() == 0) { + return null; + } + String str = ""; + for (JCheckBox jcb : list) { + str += jcb.getText(); + str += ","; + } + return str.substring(0, str.length() - 1); + } + public void setSelected(int index) { buttons[index].setSelected(true); } public void setSelected(String value) { - for (int i = 0; i < buttons.length; i++) { - buttons[i].setSelected(buttons[i].getText().equals(value)); + String[] arr = value.split(","); + for (int i = 0; i < arr.length; i++) { + for (int ii = 0; ii < buttons.length; ii++) { + buttons[ii].setSelected(buttons[ii].getText().equals(arr[i])); + } } } } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java index a343b2c..9ad868a 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java @@ -26,8 +26,11 @@ public class JRadioPanel extends JPanel { } public JRadioButton getSelected() { - return (JRadioButton) buttonGroup.getSelection() - .getSelectedObjects()[0]; + if (buttonGroup.getSelection() != null) { + return (JRadioButton) buttonGroup.getSelection() + .getSelectedObjects()[0]; + } + return null; } public void setSelected(int index) { diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java new file mode 100644 index 0000000..455d04d --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java @@ -0,0 +1,80 @@ +package com.connor.jd.plm.table; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; + +public class TCTableUtil { + public static String[][] getTableRows(TCComponentForm form, String prop, + String[] colNames) { + try { + TCProperty tcProperty = form.getTCProperty(prop); + TCComponent[] components = tcProperty.getReferenceValueArray(); + String[][] res = new String[components.length][colNames.length]; + for (int i = 0; i < components.length; i++) { + for (int ii = 0; ii < colNames.length; ii++) { + res[i][ii] = components[i] + .getPropertyDisplayableValue(colNames[ii]); + } + } + return res; + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + public static boolean setTableRows(TCComponentForm form, String prop, + String[] colNames, String[][] rows) { + List list = new ArrayList(); + DataManagementService service = DataManagementService.getService( + (TCSession) AIFUtility.getCurrentApplication().getSession()); + CreateIn ci = new CreateIn(); + ci.data.boName = "JD2_table"; + Map map = new HashMap(); + for (int i = 0; i < rows.length; i++) { + for (int ii = 0; ii < colNames.length; ii++) { + map.put(colNames[ii], rows[i][ii]); + } + System.out.println(map.size()); + ci.data.stringProps = map; + try { + CreateResponse response = service + .createObjects(new CreateIn[] { ci }); + System.out.println("CreateResponse size:" + + response.serviceData.sizeOfCreatedObjects()); + if (response.serviceData.sizeOfCreatedObjects() > 0) { + list.add(response.output[0].objects[0]); + } + } catch (ServiceException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + try { + form.getTCProperty(prop).setReferenceValueArray( + list.toArray(new TCComponent[list.size()])); + System.out.println("保存table成功"); + return true; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/util/package-info.java b/com.connor.jd.plm/src/com/connor/jd/plm/util/package-info.java new file mode 100644 index 0000000..0486a92 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/util/package-info.java @@ -0,0 +1 @@ +package com.connor.jd.plm.util; \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/utils/JDMethodUtil.java b/com.connor.jd.plm/src/com/connor/jd/plm/utils/JDMethodUtil.java deleted file mode 100644 index 892bbd2..0000000 --- a/com.connor.jd.plm/src/com/connor/jd/plm/utils/JDMethodUtil.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.connor.jd.plm.utils; - -import com.teamcenter.rac.kernel.TCPreferenceService; -import com.teamcenter.rac.kernel.TCSession; -import com.teamcenter.rac.kernel.TCUserService; - -public class JDMethodUtil { - - public static TCPreferenceService service; - public static TCUserService userservice; - - /** - * 获取单值得首选项 - * - * @param prefName - * @return - */ - public static String getPrefStr(String prefName, TCSession session) { - if (service == null) { - service = session.getPreferenceService(); - } - String str = service.getString(TCPreferenceService.TC_preference_site, prefName); - if (str == null) { - str = new String(""); - } - return str; - } - - /** - * 获取多值得首选项 - * - * @param prefName - * @return - */ - public static String[] getPrefStrArray(String prefName, TCSession session) { - if (service == null) { - service = session.getPreferenceService(); - } - String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); - service.getStringValues(prefName); - service.getStringValue(prefName); - if (strs == null) { - strs = new String[] { "" }; - } - return strs; - } -} diff --git a/com.connor.jd.plm/src/com/teamcenter/rac/form/form_user.properties b/com.connor.jd.plm/src/com/teamcenter/rac/form/form_user.properties index 772b059..6fb45b8 100644 --- a/com.connor.jd.plm/src/com/teamcenter/rac/form/form_user.properties +++ b/com.connor.jd.plm/src/com/teamcenter/rac/form/form_user.properties @@ -1 +1 @@ -JD2ConfirmFormRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.SampleConfirmationForm \ No newline at end of file +JD2_GTYPQRDRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.SampleConfirmationForm \ No newline at end of file