diff --git a/com.connor.jd.plm/.classpath b/com.connor.jd.plm/.classpath
index bf69a48..f420af9 100644
--- a/com.connor.jd.plm/.classpath
+++ b/com.connor.jd.plm/.classpath
@@ -3,556 +3,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF
index 4b7e1b0..7c4fa97 100644
--- a/com.connor.jd.plm/META-INF/MANIFEST.MF
+++ b/com.connor.jd.plm/META-INF/MANIFEST.MF
@@ -4,51 +4,38 @@ Bundle-Name: JDProject
Bundle-SymbolicName: com.connor.jd.plm;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.ui,
- com.teamcenter.rac.common;bundle-version="11000.2.0",
- com.teamcenter.rac.tcapps;bundle-version="11000.2.0",
- com.teamcenter.rac.util;bundle-version="11000.2.0",
- com.teamcenter.rac.aifrcp;bundle-version="11000.2.0",
- com.teamcenter.rac.ui.commands;bundle-version="11000.2.0",
- com.teamcenter.rac.kernel;bundle-version="11000.2.0",
- com.teamcenter.rac.ui.views;bundle-version="11000.2.0",
- org.eclipse.core.runtime;bundle-version="3.8.0",
- org.eclipse.ui.forms;bundle-version="3.5.200"
+ 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",
+ com.teamcenter.rac.aifrcp;bundle-version="12000.1.0",
+ com.teamcenter.rac.ui.commands;bundle-version="12000.1.0",
+ com.teamcenter.rac.kernel;bundle-version="12000.1.0",
+ com.teamcenter.rac.ui.views;bundle-version="12000.1.0",
+ org.eclipse.core.runtime;bundle-version="3.12.0",
+ org.eclipse.ui.forms;bundle-version="3.7.0"
Automatic-Module-Name: JDProject
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Export-Package: com.connor.jd.plm.form,
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Export-Package: com.connor.jd.operations,
+ com.connor.jd.plm.dialogs,
+ com.connor.jd.plm.form,
com.connor.jd.plm.handlers,
+ com.connor.jd.plm.table,
+ com.connor.jd.plm.utils,
com.teamcenter.rac.form
-Import-Package: javafx.animation,
- javafx.application,
- javafx.beans,
- javafx.beans.binding,
- javafx.beans.property,
- javafx.beans.property.adapter,
- javafx.beans.value,
- javafx.collections,
- javafx.collections.transformation,
- javafx.concurrent,
- javafx.css,
- javafx.embed.swing,
- javafx.event,
- javafx.fxml,
- javafx.geometry,
- javafx.print,
- javafx.scene,
- javafx.scene.canvas,
- javafx.scene.chart,
- javafx.scene.control,
- javafx.scene.control.cell,
- javafx.scene.effect,
- javafx.scene.image,
- javafx.scene.input,
- javafx.scene.layout,
- javafx.scene.media,
- javafx.scene.paint,
- javafx.scene.shape,
- javafx.scene.text,
- javafx.scene.transform,
- javafx.scene.web,
- javafx.stage,
- javafx.util,
- javafx.util.converter
+Bundle-ClassPath: 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/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
diff --git a/com.connor.jd.plm/build.properties b/com.connor.jd.plm/build.properties
index 4b8162a..368a476 100644
--- a/com.connor.jd.plm/build.properties
+++ b/com.connor.jd.plm/build.properties
@@ -3,4 +3,20 @@ output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
- icons/
+ icons/,\
+ 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/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
diff --git a/com.connor.jd.plm/plugin.xml b/com.connor.jd.plm/plugin.xml
index 1a0c133..8aef2ae 100644
--- a/com.connor.jd.plm/plugin.xml
+++ b/com.connor.jd.plm/plugin.xml
@@ -53,6 +53,7 @@
+
@@ -95,6 +96,7 @@
+
@@ -139,6 +141,9 @@
+
+
+
@@ -186,6 +191,7 @@
+
@@ -227,6 +233,7 @@
+
@@ -273,6 +280,8 @@
+
+
@@ -345,6 +354,7 @@
+
+
+
+
+ */
+ 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
new file mode 100644
index 0000000..3b25807
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/operations/ExcelOperation.java
@@ -0,0 +1,264 @@
+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/dialogs/CSXWHDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java
new file mode 100644
index 0000000..b768822
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java
@@ -0,0 +1,39 @@
+package com.connor.jd.plm.dialogs;
+
+import javax.swing.JPanel;
+
+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/dialogs/QTXJCDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/QTXJCDialog.java
new file mode 100644
index 0000000..1d14c00
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/QTXJCDialog.java
@@ -0,0 +1,285 @@
+package com.connor.jd.plm.dialogs;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+import com.connor.jd.operations.ExcelOperation;
+import com.connor.jd.plm.utils.JDMethodUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentDataset;
+import com.teamcenter.rac.kernel.TCComponentProjectSmartFolder;
+import com.teamcenter.rac.kernel.TCComponentTcFile;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.ButtonLayout;
+import com.teamcenter.rac.util.MessageBox;
+
+public class QTXJCDialog extends AbstractAIFDialog {
+
+ private AbstractAIFApplication app;
+ private TCSession session;
+ private JLabel road = new JLabel();
+ private JComboBox pjsName = new JComboBox();
+ private List sfList = new ArrayList();
+ private TCComponent[] com;
+ private String type;
+
+ public QTXJCDialog(AbstractAIFApplication app, List sfList, TCComponent[] com, TCSession session,
+ String type) throws TCException {
+ this.app = app;
+ this.sfList = sfList;
+ this.com = com;
+ this.session = session;
+ this.type = type;
+ initUI();
+ }
+
+ private void initUI() {
+ this.setAutoRequestFocus(true);
+ this.setPreferredSize(new Dimension(360, 150));
+ this.setResizable(false);
+
+ JLabel pjStage = new JLabel("Ŀ");
+ pjsName.addItem("");
+ for (int i = 0; i < sfList.size(); i++) {
+ pjsName.addItem(sfList.get(i));
+ }
+ JLabel roadLabel = new JLabel("·");
+
+ JButton open = new JButton("...");
+ open.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ openBtn();
+ }
+ });
+ JButton export = new JButton("");
+ export.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ exportBtn();
+ }
+ });
+ JButton out = new JButton("ȡ");
+ out.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ dispose();
+ }
+ });
+ JPanel flow1 = new JPanel();
+ Box b1 = Box.createHorizontalBox();
+ flow1.add(b1);
+ // b1.add(Box.createHorizontalStrut(20));
+ b1.add(pjStage);
+ b1.add(Box.createHorizontalStrut(50));
+ b1.add(pjsName);
+ JPanel flow2 = new JPanel();
+ Box b2 = Box.createHorizontalBox();
+ flow2.add(b2);
+ b2.add(Box.createHorizontalStrut(20));
+ b2.add(roadLabel);
+ b2.add(Box.createHorizontalStrut(20));
+ b2.add(road);
+ b2.add(Box.createHorizontalStrut(80));
+ b2.add(open);
+ JPanel btn = new JPanel(new ButtonLayout());
+ btn.add(export);
+ btn.add(out);
+ JPanel center = new JPanel(new BorderLayout());
+ center.add(flow1, BorderLayout.NORTH);
+ center.add(flow2, BorderLayout.CENTER);
+ center.add(btn, BorderLayout.SOUTH);
+ this.add(center, "Center");
+
+ this.pack();
+ this.centerToScreen();
+ this.showDialog();
+ }
+
+ String roadName = null;
+
+ private void openBtn() {
+ JFileChooser chooser = new JFileChooser();
+ // chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setDialogTitle("ѡҪļ");
+ // chooser.showDialog(new JLabel(), "ȷ");
+
+ FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel(*.xlsx)", "xlsx");
+ chooser.setFileFilter(filter);
+ chooser.showSaveDialog(null);
+ // File file = chooser.getSelectedFile();
+ try {
+ if (chooser.getSelectedFile().getAbsolutePath() != null) {
+ String filePath = chooser.getSelectedFile().getAbsolutePath() + ".xlsx";
+ roadName = filePath;
+ if (filePath.length() > 10) {
+ road.setText(filePath.substring(0, 10) + "...");
+ } else {
+ road.setText(filePath);
+ }
+ }
+
+ } catch (Exception e) {
+ }
+
+ }
+
+ private void exportBtn() {
+ String jdname = "JDJFW";
+ if (roadName.equals("")) {
+ MessageBox.post("ûѡ·", "", MessageBox.ERROR);
+ } else {
+ System.out.println(road.getText());
+ String outpath = roadName;
+
+ System.out.println(outpath);
+
+ File file = getExcle(jdname, type);
+ String sel = (String) pjsName.getSelectedItem();
+ Map> jfw = new HashMap>();
+ if (sel.equals("")) {
+ for (int i = 0; i < sfList.size(); i++) {
+ TCComponentProjectSmartFolder sf = (TCComponentProjectSmartFolder) com[i];
+ try {
+ TCComponent[] psf = sf.getTCProperty("project_data").getReferenceValueArray();
+
+ List jfList = new ArrayList();
+ for (int j = 0; j < psf.length; j++) {
+ // TCComponentItem jf = (TCComponentItem) psf[j];
+ jfList.add(psf[j]);
+ }
+ jfw.put(sf.getProperty("object_string"), jfList);
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ }
+ } else {
+ for (int i = 0; i < sfList.size(); i++) {
+ TCComponentProjectSmartFolder sf = (TCComponentProjectSmartFolder) com[i];
+ try {
+ if (sel.equals(sf.getProperty("object_string"))) {
+ TCComponent[] psf = sf.getTCProperty("project_data").getReferenceValueArray();
+ List jfList = new ArrayList();
+ for (int j = 0; j < psf.length; j++) {
+ // TCComponentItem jf = (TCComponentItem) psf[j];
+ jfList.add(psf[j]);
+ }
+ jfw.put(sel, jfList);
+ }
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ ExcelOperation.writeExcel(file, outpath, jfw);
+ System.out.println("ɹ");
+ MessageBox.post("ɹ", "Ϣ", MessageBox.INFORMATION);
+ dispose();
+ }
+ }
+
+ private File getExcle(String ssx, String type) {
+ File fmsFile = null;
+ String allpuid = JDMethodUtil.getPrefStr(ssx, session);
+ String[] relpuid = allpuid.split(";");
+ String puid = null;
+ switch (type) {
+ case "GT":
+ puid = relpuid[2];
+ break;
+ case "BL":
+ puid = relpuid[1];
+ break;
+ case "BX":
+ puid = relpuid[0];
+ break;
+ default:
+ break;
+ }
+ if (puid == null) {
+ MessageBox.post("ϵԱѡ", "", MessageBox.ERROR);
+ return null;
+ }
+ TCComponentDataset dateset = null;
+ try {
+ dateset = (TCComponentDataset) session.stringToComponent(puid);
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ if (dateset == null) {
+ MessageBox.post("δҵݼϵԱѡ", "", MessageBox.ERROR);
+ return null;
+ }
+ try {
+ TCComponentTcFile[] file = dateset.getTcFiles();
+ if (file.length == 0 || file.length != 1) {
+ MessageBox.post("ݼûõļļ࣬飡", "", MessageBox.WARNING);
+ return null;
+ } else {
+ fmsFile = file[0].getFmsFile();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return fmsFile;
+ }
+// @Override
+// public void start(Stage arg0) throws Exception {
+// Stage primaryStage = new Stage();
+// Pane root = new Pane();
+// Label pjStage = new Label("Ŀ");
+// pjStage.setLayoutX(37.0);
+// pjStage.setLayoutY(51.0);
+// ComboBox pjsName = new ComboBox();
+// pjsName.setLayoutX(94.0);
+// pjsName.setLayoutY(47.0);
+// pjsName.setValue("");
+// Label roadLabel = new Label("·");
+// roadLabel.setLayoutX(37.0);
+// roadLabel.setLayoutY(107.0);
+// Label road = new Label();
+// road.setLayoutX(94.0);
+// road.setLayoutY(107.0);
+// Button open = new Button("...");
+// open.setLayoutX(190.0);
+// open.setLayoutY(103.0);
+// Button export = new Button("");
+// export.setLayoutX(67.0);
+// export.setLayoutY(158.0);
+// Button out = new Button("ȡ");
+// out.setLayoutX(169.0);
+// out.setLayoutY(158.0);
+//
+// root.getChildren().add(pjStage);
+// root.getChildren().add(pjsName);
+// root.getChildren().add(roadLabel);
+// root.getChildren().add(road);
+// root.getChildren().add(open);
+// root.getChildren().add(export);
+// root.getChildren().add(out);
+//
+// Scene scene = new Scene(root, 290, 207);
+// primaryStage.setScene(scene);
+// primaryStage.setResizable(false);
+// primaryStage.show();
+// }
+
+}
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
new file mode 100644
index 0000000..70994ff
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java
@@ -0,0 +1,40 @@
+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.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/QTXJCHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/QTXJCHandler.java
new file mode 100644
index 0000000..4789dce
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/QTXJCHandler.java
@@ -0,0 +1,67 @@
+package com.connor.jd.plm.handlers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.jd.plm.dialogs.QTXJCDialog;
+import com.teamcenter.rac.aif.AbstractAIFUIApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentProject;
+import com.teamcenter.rac.kernel.TCComponentProjectSmartFolder;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class QTXJCHandler extends AbstractHandler {
+
+ private TCComponent[] com;
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ List sfList = new ArrayList();
+ String name = arg0.getCommand().getId();
+ String type = null;
+ switch (name) {
+ case "JDProject.menus.JD2_GTQTXJC":
+ type = "GT";
+ break;
+ case "JDProject.menus.JD2_BLQTXJC":
+ type = "BL";
+ break;
+ case "JDProject.menus.JD2_BXQTXJC":
+ type = "BX";
+ break;
+ default:
+ break;
+ }
+ try {
+ AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
+ if (app.getTargetComponent() != null && app.getTargetComponent() instanceof TCComponentProject) {
+ TCComponentProject project = (TCComponentProject) app.getTargetComponent();
+ com = project.getTCProperty("project_data").getReferenceValueArray();
+ for (int i = 0; i < com.length; i++) {
+ TCComponentProjectSmartFolder sf = (TCComponentProjectSmartFolder) com[i];
+ sfList.add(sf.getProperty("object_string"));
+ }
+ TCSession session = (TCSession) app.getSession();
+ try {
+ new Thread(new QTXJCDialog(app, sfList, com, session, type)).start();
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ } else {
+ MessageBox.post("ѡĿ", "ʾ", MessageBox.INFORMATION);
+ }
+ } catch (TCException e1) {
+ e1.printStackTrace();
+ }
+
+ return null;
+ }
+
+}
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
new file mode 100644
index 0000000..892bbd2
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/utils/JDMethodUtil.java
@@ -0,0 +1,47 @@
+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;
+ }
+}