commit a0680061118f1e8a38b75f14656b42f9c08770b7
Author: ChenZichaoczc <2974997276@qq.com>
Date: Thu May 15 15:39:04 2025 +0800
first commit
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..c649de2
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/.project b/.project
new file mode 100644
index 0000000..de96f55
--- /dev/null
+++ b/.project
@@ -0,0 +1,28 @@
+
+
+ com.connor.ahboxinwei.plm
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..a58ebdc
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,15 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..7103be7
--- /dev/null
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.text.custom_code_templates=
diff --git a/.settings/org.eclipse.ltk.core.refactoring.prefs b/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644
index 0000000..b196c64
--- /dev/null
+++ b/.settings/org.eclipse.ltk.core.refactoring.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..1687bdc
--- /dev/null
+++ b/META-INF/MANIFEST.MF
@@ -0,0 +1,103 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: boxinwei
+Bundle-SymbolicName: com.connor.ahboxinwei.plm;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Automatic-Module-Name: com.conor.ferrorTech.metal
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Import-Package: com.teamcenter.rac.aif,
+ com.teamcenter.rac.aif.kernel,
+ com.teamcenter.rac.aifrcp,
+ com.teamcenter.rac.classification.common.table,
+ com.teamcenter.rac.classification.icm,
+ com.teamcenter.rac.kernel,
+ com.teamcenter.rac.util,
+ com.teamcenter.services.rac.core,
+ com.teamcenter.services.rac.core._2006_03,
+ com.teamcenter.services.rac.core._2008_06,
+ com.teamcenter.services.rac.core._2013_05,
+ com.teamcenter.soa.exceptions,
+ org.apache.commons.lang,
+ org.eclipse.core.commands,
+ org.eclipse.core.databinding
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ com.teamcenter.rac.aifrcp,
+ com.teamcenter.rac.common,
+ com.teamcenter.rac.ui.commands,
+ com.teamcenter.rac.external,
+ com.teamcenter.rac.kernel,
+ com.teamcenter.rac.tcapps,
+ com.teamcenter.rac.util,
+ TcSoaCadRac,
+ TcSoaCommon,
+ TcSoaCoreRac,
+ TcSoaCoreTypes,
+ TcSoaCoreLoose,
+ com.teamcenter.rac.classification.icm,
+ com.teamcenter.rac.tcapps,
+ com.teamcenter.rac.workflow.processdesigner;bundle-version="14000.3.0",
+ TcSoaWorkflowRac;bundle-version="14000.3.0"
+Export-Package: .,
+ com.connor.ferrorTech.metal,
+ com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate,
+ com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel,
+ com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity,
+ com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate,
+ com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload,
+ com.connor.ferrorTech.metal.batchDownload,
+ com.connor.ferrorTech.metal.bomProcess,
+ com.connor.ferrorTech.metal.changeManagement.createECO,
+ com.connor.ferrorTech.metal.changeManagement.createECR,
+ com.connor.ferrorTech.metal.constant,
+ com.connor.ferrorTech.metal.createTechnicalDocuments,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.AinternalDrawing,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.BprocessControl,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.CredlineDrawing,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.FsetupSheet,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.HncFile,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.IprocessDrawing,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.JpreMillDrawing,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.LstandardInstruction,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments,
+ com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments,
+ com.connor.ferrorTech.metal.exception,
+ com.connor.ferrorTech.metal.importMaterial,
+ com.connor.ferrorTech.metal.material.finishedProducts,
+ com.connor.ferrorTech.metal.material.material,
+ com.connor.ferrorTech.metal.material.semiFinishedProducts,
+ com.connor.ferrorTech.metal.processManagement.classificationCraft,
+ com.connor.ferrorTech.metal.processManagement.classificationProcesses,
+ com.connor.ferrorTech.metal.processManagement.createCraft,
+ com.connor.ferrorTech.metal.processManagement.createProcesses,
+ com.connor.ferrorTech.metal.processManagement.entity,
+ com.connor.ferrorTech.metal.quotationManagement.createClientFile,
+ com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings,
+ com.connor.ferrorTech.metal.quotationManagement.createQuotationProject,
+ com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation,
+ com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate,
+ com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings,
+ com.connor.ferrorTech.metal.share,
+ com.connor.ferrorTech.metal.util
+Bundle-Vendor: boxinwei
+Bundle-ClassPath: .,
+ libs/commons-codec-1.15.jar,
+ libs/commons-collections4-4.4.jar,
+ libs/commons-compress-1.21.jar,
+ libs/commons-io-2.11.0.jar,
+ libs/commons-math3-3.6.1.jar,
+ libs/poi-5.2.1.jar,
+ libs/poi-ooxml-5.2.1.jar,
+ libs/poi-ooxml-lite-5.2.1.jar,
+ libs/swingx-core-1.6.2.jar,
+ libs/xml-apis-1.4.01.jar,
+ libs/xmlbeans-5.0.3.jar,
+ json-20151123.jar
+Bundle-ActivationPolicy: lazy
+
diff --git a/build.properties b/build.properties
new file mode 100644
index 0000000..40bd503
--- /dev/null
+++ b/build.properties
@@ -0,0 +1,21 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ build.properties,\
+ plugin.xml,\
+ libs/commons-codec-1.15.jar,\
+ libs/commons-collections4-4.4.jar,\
+ libs/commons-compress-1.21.jar,\
+ libs/commons-io-2.11.0.jar,\
+ libs/commons-math3-3.6.1.jar,\
+ libs/poi-5.2.1.jar,\
+ libs/poi-ooxml-5.2.1.jar,\
+ libs/poi-ooxml-lite-5.2.1.jar,\
+ libs/swingx-core-1.6.2.jar,\
+ libs/xml-apis-1.4.01.jar,\
+ libs/xmlbeans-5.0.3.jar,\
+ plugin_zh_CN.properties,\
+ plugin.properties,\
+ json-20151123.jar
+jars.compile.order = .
diff --git a/json-20151123.jar b/json-20151123.jar
new file mode 100644
index 0000000..472b253
Binary files /dev/null and b/json-20151123.jar differ
diff --git a/libs/commons-codec-1.15.jar b/libs/commons-codec-1.15.jar
new file mode 100644
index 0000000..f14985a
Binary files /dev/null and b/libs/commons-codec-1.15.jar differ
diff --git a/libs/commons-collections4-4.4.jar b/libs/commons-collections4-4.4.jar
new file mode 100644
index 0000000..da06c3e
Binary files /dev/null and b/libs/commons-collections4-4.4.jar differ
diff --git a/libs/commons-compress-1.21.jar b/libs/commons-compress-1.21.jar
new file mode 100644
index 0000000..4892334
Binary files /dev/null and b/libs/commons-compress-1.21.jar differ
diff --git a/libs/commons-io-2.11.0.jar b/libs/commons-io-2.11.0.jar
new file mode 100644
index 0000000..be507d9
Binary files /dev/null and b/libs/commons-io-2.11.0.jar differ
diff --git a/libs/commons-math3-3.6.1.jar b/libs/commons-math3-3.6.1.jar
new file mode 100644
index 0000000..0ff582c
Binary files /dev/null and b/libs/commons-math3-3.6.1.jar differ
diff --git a/libs/poi-5.2.1.jar b/libs/poi-5.2.1.jar
new file mode 100644
index 0000000..9e068d3
Binary files /dev/null and b/libs/poi-5.2.1.jar differ
diff --git a/libs/poi-ooxml-5.2.1.jar b/libs/poi-ooxml-5.2.1.jar
new file mode 100644
index 0000000..f6a9086
Binary files /dev/null and b/libs/poi-ooxml-5.2.1.jar differ
diff --git a/libs/poi-ooxml-lite-5.2.1.jar b/libs/poi-ooxml-lite-5.2.1.jar
new file mode 100644
index 0000000..848f47c
Binary files /dev/null and b/libs/poi-ooxml-lite-5.2.1.jar differ
diff --git a/libs/swingx-core-1.6.2.jar b/libs/swingx-core-1.6.2.jar
new file mode 100644
index 0000000..6ec2699
Binary files /dev/null and b/libs/swingx-core-1.6.2.jar differ
diff --git a/libs/xml-apis-1.4.01.jar b/libs/xml-apis-1.4.01.jar
new file mode 100644
index 0000000..4673346
Binary files /dev/null and b/libs/xml-apis-1.4.01.jar differ
diff --git a/libs/xmlbeans-5.0.3.jar b/libs/xmlbeans-5.0.3.jar
new file mode 100644
index 0000000..63b0ab8
Binary files /dev/null and b/libs/xmlbeans-5.0.3.jar differ
diff --git a/plugin.properties b/plugin.properties
new file mode 100644
index 0000000..cec15f8
--- /dev/null
+++ b/plugin.properties
@@ -0,0 +1,62 @@
+vf.1=Share File Auto Distribution
+vf.2=File Management
+vf.3=Import Bill Of Materials
+
+plugin.0=PLM Menu
+
+quo.0=Quote Management
+quo.1=Create customer profiles
+quo.2=Create quotation projects
+quo.3=Create quotation drawings
+quo.4=Upload quotation drawings
+quo.5=Create technical quotations
+quo.6=Create external quotations
+
+npi.0=NPI Project
+npi.1=Create NPI project
+npi.2=Create NPI No Quotation Project
+npi.3=Create customer drawings
+npi.4=Upload customer drawings
+
+mar.0=Create Material Master
+mar.1=Finished products
+mar.2=Semi-finished products
+mar.3=Raw Material
+
+gy.0=Process Management
+gy.1=Process Routing Library
+gy.2=Operation Library
+gy.3=Create Routing
+gy.4=Create Operation
+
+cg.0=Change Management
+cg.1=Create ECR
+cg.2=Create ECO
+
+tech.0=Create Engineering document
+tech.1=Create Internal Drawing
+tech.2=Create Process Control
+tech.3=Create Redline Drawing
+tech.4=Create RawMaterial Drawing
+tech.5=Create Sub-Parts Drawing
+tech.6=Create Setup Sheet
+tech.7=Create Rework Work Instruction
+tech.8=Create CNC file
+tech.9=Create Process Drawing
+tech.10=Create Pre-Mill Drawing
+tech.11=Create Jig & Fixture Drawing
+tech.12=Create Tooling List
+tech.13=Create Standard Work Instruction
+tech.14=Create In-Process Inspection Plan
+tech.15=Upload Documents
+tech.16=Batch Approval Of Tec-Documents
+
+BOMgy.0=BOM process batch approval
+
+batchDownload.0=Batch Download Files
+
+plugin.1=Design Management
+toBom.1=DBOM To EBOM
+
+
+
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..3c4b559
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,296 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugin_zh_CN.properties b/plugin_zh_CN.properties
new file mode 100644
index 0000000..d57df24
--- /dev/null
+++ b/plugin_zh_CN.properties
@@ -0,0 +1,66 @@
+vf.1=\u5171\u4eab\u6587\u4ef6\u81ea\u52a8\u5206\u53d1
+vf.2=\u6587\u4ef6\u7ba1\u7406
+vf.3=Import Bill Of Materials
+
+plugin.0=PLM Menu
+
+quo.0=\u62A5\u4EF7\u7BA1\u7406
+quo.1=\u521B\u5EFA\u5BA2\u6237\u6863\u6848
+quo.2=\u521B\u5EFA\u62A5\u4EF7\u9879\u76EE
+quo.3=\u521B\u5EFA\u62A5\u4EF7\u56FE\u7EB8
+quo.4=\u4E0A\u4F20\u62A5\u4EF7\u56FE\u7EB8
+quo.5=\u521B\u5EFA\u6280\u672F\u62A5\u4EF7\u5355
+quo.6=\u521B\u5EFA\u5BF9\u5916\u62A5\u4EF7\u5355
+
+npi.0=NPI\u9879\u76EE
+npi.1=\u521B\u5EFANPI
+npi.2=\u9009\u4E2D\u6587\u4EF6\u5939\u521B\u5EFANPI
+npi.3=\u521B\u5EFA\u5BA2\u6237\u56FE\u7EB8
+npi.4=\u4E0A\u4F20\u5BA2\u6237\u56FE\u7EB8
+
+mar.0=\u521B\u5EFA\u7269\u6599
+mar.1=\u4EA7\u6210\u54C1
+mar.2=\u534A\u6210\u54C1
+mar.3=\u6750\u6599
+
+gy.0=\u5DE5\u827A\u7BA1\u7406
+gy.1=Process Routing Library
+gy.2=Operation Library
+gy.3=Create Routing
+gy.4=Create Operation
+
+cg.0=\u53D8\u66F4\u7BA1\u7406
+cg.1=Create ECR
+cg.2=Create ECO
+
+tech.0=\u521B\u5EFA\u6280\u672F\u6587\u4EF6
+tech.1=Create Internal Drawing
+tech.2=Create Process Control
+tech.3=Create Redline Drawing
+tech.4=Create RawMaterial Drawing
+tech.5=Create Sub-Parts Drawing
+tech.6=Create Setup Sheet
+tech.7=Create Rework Work Instruction
+tech.8=Create CNC file
+tech.9=Create Process Drawing
+tech.10=Create Pre-Mill Drawing
+tech.11=Create Jig & Fixture Drawing
+tech.12=Create Tooling List
+tech.13=Create Standard Work Instruction
+tech.14=Create In-Process Inspection Plan
+tech.15=Upload Documents
+tech.16=Batch Approval Of Tec-Documents
+
+
+BOMgy.0=BOM\u5DE5\u827A\u6279\u91CF\u5BA1\u6279
+
+batchDownload.0=Batch Download Files
+
+plugin.1=\u8BBE\u8BA1\u7BA1\u7406
+toBom.1=DBOM\u8F6CEBOM
+
+
+
+
+
+
diff --git a/plugin备份.xml b/plugin备份.xml
new file mode 100644
index 0000000..b374fde
--- /dev/null
+++ b/plugin备份.xml
@@ -0,0 +1,271 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectAction.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectAction.java
new file mode 100644
index 0000000..9d8cb12
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectAction.java
@@ -0,0 +1,90 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate;
+
+import java.awt.Frame;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.jdesktop.swingx.JXDatePicker;
+
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCPreferenceService;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateNPIprojectAction extends AbstractAIFAction {
+
+ private AbstractAIFApplication application;
+ private JLabel[] inputLabels;
+ private JComponent[] inputFields;
+
+ private String[] columnNames;
+ private Object[][] data;
+
+ public CreateNPIprojectAction(AbstractAIFApplication application, Frame frame, String param) {
+ super(application, frame, param);
+ this.application = application;
+ }
+
+ @Override
+ public void run() {
+ boolean flag = false;
+
+ InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
+ if (selectComponent != null && selectComponent instanceof TCComponentFolder) {
+ TCComponentFolder targetRev = (TCComponentFolder) selectComponent;
+ System.out.println("ѡж汾Ϊ " + targetRev.getType());
+ if (targetRev.getType().equals("Folder")) {
+ flag = true;
+ } else {
+ MessageBox.post("Please select the Folder", "Error", MessageBox.ERROR);
+ return;
+ }
+ }
+ else {
+ MessageBox.post("Please select Item Revision", "Error", MessageBox.ERROR);
+ return;
+ }
+
+ if(flag) {
+ inputLabels = new JLabel[]{
+ new JLabel("NPI Project Name"), new JLabel("Order date"), new JLabel("Special requirements")};
+
+
+ inputFields = new JComponent[]{
+ new JTextField(14), createDatePicker(), new JTextField(14)
+ };
+
+ // б
+ columnNames = new String[]{"Serial", "Customer PN", "Product Name", "Rev", "Date of Issuance", "Num", "BOM Deadline", "Drawings Deadline", "Tec BOM Deadline", "Tec Drawings Deadline","Remarks"};
+
+ //
+ data = new Object[][]{};
+ CreateNPIprojectDialog dialog;
+ dialog = new CreateNPIprojectDialog(this.application,inputLabels,inputFields,null,columnNames,data,false);
+ new Thread(dialog).start();
+ }
+ }
+
+ private JXDatePicker createDatePicker() {
+ // JXDatePicker
+ JXDatePicker datePicker = new JXDatePicker();
+ // ڸʽ
+ datePicker.setFormats(new java.text.SimpleDateFormat("yyyy-MM-dd"));
+ return datePicker;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectDialog.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectDialog.java
new file mode 100644
index 0000000..d926da5
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectDialog.java
@@ -0,0 +1,691 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.border.EmptyBorder;
+import javax.swing.filechooser.FileNameExtensionFilter;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumnModel;
+
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jdesktop.swingx.JXDatePicker;
+
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel.ExcelRowData;
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel.ReadExcelData;
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.DatePickerEditor;
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.FormData;
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.RowData;
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentDataset;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateNPIprojectDialog extends JFrame implements Runnable {
+ private final String TABLE_TITLE = "Drawing Task Book Table";
+ private final String JFRAME_TITLE = "Create NPI Project";
+
+ private final String PREFERENCE_EXCEL_GETUID = "VF5CTRWS";
+ private final String TARGET_REV_XJXXD_GX = "VF5xjxxdgx";
+
+ private JFrame frame;
+ private JTable table;
+ private JLabel[] inputLalels;
+ private JComponent[] inputFields;
+
+ private Map> lovMap;
+
+ private JButton okButton;
+ private JButton celButton;
+ private JButton importButton;
+ private JButton exportButton;
+ private JButton addButton;
+ private JButton deleteButton;
+ private JButton moveUpButton;
+ private JButton moveDownButton;
+
+ private String[] columnNames;
+ private Object[][] data;
+ private boolean isFolder;
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+ private TCComponentFolder targetFolder;
+
+ public CreateNPIprojectDialog(AbstractAIFApplication application, Object... params) {
+ this.application = application;
+ this.inputLalels = (JLabel[]) params[0];
+ this.inputFields = (JComponent[]) params[1];
+ this.lovMap = (Map>) params[2];
+ this.columnNames = (String[]) params[3];
+ this.data = (Object[][]) params[4];
+ this.isFolder = (boolean) params[5];
+
+ this.tcSession = (TCSession) application.getSession();
+ }
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
+ if (selectComponent != null && selectComponent instanceof TCComponentFolder) {
+ targetFolder = (TCComponentFolder) selectComponent;
+ }
+ initUI();
+ }
+
+ private void initUI() {
+ try {
+ frame = new JFrame(JFRAME_TITLE);
+
+ frame.setSize(850, 550);
+ // ʼϢ
+ setPanelProperties();
+ // ݵJFrame λ
+ JScrollPane centerPanel = getTopPanel();
+ JPanel bottomPanel = getButtomPanel();
+
+ //
+ JPanel tableScrollPane = createTable();
+ tableScrollPane.setPreferredSize(new Dimension(700, 200)); // ùĴС
+
+ frame.getContentPane().add(centerPanel, BorderLayout.NORTH);
+ frame.getContentPane().add(tableScrollPane, BorderLayout.CENTER);
+ frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ // ôھ
+ frame.setLocationRelativeTo(null);
+// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ // ÿɼ
+ frame.setVisible(true);
+
+ } catch (TCException e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * ѡ̬ЧʼһЩϢԼʼһЩť
+ *
+ * @throws TCException
+ */
+ private void setPanelProperties() throws TCException {
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ importButton = new JButton(ConstantPool.EN_BUTTON_IMPORT);
+ exportButton = new JButton(ConstantPool.EN_BUTTON_EXPORT);
+ addButton = new JButton(ConstantPool.EN_BUTTON_ADD);
+ deleteButton = new JButton(ConstantPool.EN_BUTTON_DELETE);
+ moveUpButton = new JButton(ConstantPool.EN_BUTTON_MOVE_UP);
+ moveDownButton = new JButton(ConstantPool.EN_BUTTON_MOVE_DOWN);
+ }
+
+ private JScrollPane getTopPanel() {
+ // һʹ GridBagLayout ֹ JPanel
+ JPanel centerPanel = new JPanel(new GridBagLayout());
+
+ // һ GridBagConstraints IJԼ
+ GridBagConstraints c = new GridBagConstraints();
+
+ if (inputLalels.length != inputFields.length) {
+ throw new IllegalArgumentException("inputLalels and inputFields must have the same length");
+ }
+ Font defaultFont = new Font("ź", Font.BOLD, 13);
+ for (int i = 0; i < inputLalels.length; i++) {
+ int count = (i % 2 == 0) ? 0 : 2;
+ if (i == inputLalels.length - 1) {
+ c.insets = new Insets(5, 15, 15, 5);
+ } else {
+ c.insets = new Insets(10, 15, 5, 5);
+ }
+ c.gridx = count;
+ c.weightx = 0;
+ c.anchor = GridBagConstraints.LINE_START;
+ inputLalels[i].setFont(defaultFont);
+ centerPanel.add(inputLalels[i], c);
+
+ if (i == inputLalels.length - 1) {
+ c.gridx = 1;
+ c.gridwidth = 3;
+ c.weightx = 1;
+ } else {
+ c.weightx = 1;
+ c.gridwidth = 1;
+ c.gridx = count + 1;
+ }
+ c.fill = GridBagConstraints.HORIZONTAL;
+ inputFields[i].setFont(defaultFont);
+
+ if (inputFields[i] instanceof JTextField) {
+ ((JTextField) inputFields[i]).setPreferredSize(new Dimension(200, 27));
+ }
+ centerPanel.add(inputFields[i], c);
+ }
+ return new JScrollPane(centerPanel);
+ }
+
+ public JPanel getButtomPanel() {
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ // Ӽ
+ okButton.addActionListener(e -> {
+ String[] valueList = getFormData();
+ int length = 0;
+ FormData formData = new FormData(valueList[length++], valueList[length++], valueList[length++]);
+
+ List tableData = getTableData();
+ CreateNPIprojectOperation createNPIprojectOperation = new CreateNPIprojectOperation(application,
+ targetFolder, formData, tableData);
+ this.application.getSession().queueExcludedOperation(createNPIprojectOperation);
+ frame.dispose();
+ });
+ celButton.addActionListener(e -> {
+ frame.dispose();
+ });
+
+ bottomPanel.add(okButton);
+ bottomPanel.add(celButton);
+ return bottomPanel;
+ }
+
+ public JPanel createTable() {
+ JPanel panel = new JPanel(new BorderLayout(10, 10));
+ panel.setBorder(new EmptyBorder(10, 10, 10, 10));
+
+ JLabel titleLabel = new JLabel(TABLE_TITLE);
+ titleLabel.setFont(new Font("Serif", Font.BOLD, 13));
+ panel.add(titleLabel, BorderLayout.NORTH);
+
+ DefaultTableModel model = new DefaultTableModel(data, columnNames);
+ table = new JTable(model);
+
+ table.setRowHeight(30);
+ table.getTableHeader().setReorderingAllowed(false);
+ table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+// table.setFillsViewportHeight(true);
+
+ TableColumnModel columnModel = table.getColumnModel();
+ columnModel.getColumn(0).setPreferredWidth(50);
+ for (int i = 1; i < columnModel.getColumnCount(); i++) {
+ columnModel.getColumn(i).setPreferredWidth(120);
+ }
+
+ DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer() {
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
+ boolean hasFocus, int row, int column) {
+ Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ ((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER);
+ return c;
+ }
+ };
+
+ for (int i = 0; i < columnModel.getColumnCount(); i++) {
+ columnModel.getColumn(i).setCellRenderer(centerRenderer);
+ }
+
+ TableCellRenderer dateRenderer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
+ int column) -> {
+ JXDatePicker datePicker = new JXDatePicker();
+ if (value instanceof Date) {
+ datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd"));
+ datePicker.setDate((Date) value);
+ }
+ return datePicker;
+ };
+ TableCellEditor dateEditor = new DatePickerEditor();
+
+ int[] dateIndex = new int[] { 4, 6, 7, 8, 9 };
+ for (int index : dateIndex) {
+ table.getColumnModel().getColumn(index).setCellRenderer(dateRenderer);
+ table.getColumnModel().getColumn(index).setCellEditor(dateEditor);
+ }
+
+ JPanel buttonPanel = createTableButton();
+
+ JScrollPane scrollPane = new JScrollPane(table);
+// scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+
+ panel.add(scrollPane, BorderLayout.CENTER);
+ panel.add(buttonPanel, BorderLayout.SOUTH);
+ return panel;
+ }
+
+ public JPanel createTableButton() {
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
+ buttonPanel.add(importButton);
+ buttonPanel.add(exportButton);
+ buttonPanel.add(addButton);
+ buttonPanel.add(deleteButton);
+ buttonPanel.add(moveUpButton);
+ buttonPanel.add(moveDownButton);
+
+ importButton.addActionListener(e -> {
+ createDialog(ConstantPool.EN_TITLE_IMPORT_PATH, ConstantPool.EN_LABEL_UPLOAD_PATH, "import");
+ System.out.println("ص밴ť");
+ });
+
+ exportButton.addActionListener(e -> {
+ createDialog(ConstantPool.EN_TITLE_EXPORT_PATH, ConstantPool.EN_LABEL_UPLOAD_PATH, "export");
+ System.out.println("صť");
+ });
+
+ addButton.addActionListener(e -> {
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+
+ Object[] newRow = new Object[model.getColumnCount()];
+ for (int i = 0; i < newRow.length; i++) {
+ newRow[i] = "";
+ }
+
+ newRow[0] = model.getRowCount() + 1;
+
+ model.addRow(newRow);
+
+ table.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1);
+
+ System.out.println("аť");
+ });
+
+ deleteButton.addActionListener(e -> {
+ int[] selectedRows = table.getSelectedRows();
+ if (selectedRows.length > 0) {
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+
+ for (int i = selectedRows.length - 1; i >= 0; i--) {
+ model.removeRow(selectedRows[i]);
+ }
+
+ for (int i = 0; i < model.getRowCount(); i++) {
+ model.setValueAt(i + 1, i, 0);
+ }
+
+ if (model.getRowCount() > 0) {
+ int newSelectedRow = Math.min(selectedRows[0], model.getRowCount() - 1);
+ table.setRowSelectionInterval(newSelectedRow, newSelectedRow);
+ } else {
+ table.clearSelection();
+ }
+ } else {
+ JOptionPane.showMessageDialog(table, ConstantPool.EN_MESSAGE_DELETE);
+ }
+ System.out.println("ɾаť");
+ });
+
+ moveUpButton.addActionListener(e -> {
+ int selectedRow = table.getSelectedRow();
+ if (selectedRow > 0) {
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+ Object[] row = new Object[model.getColumnCount()];
+ for (int i = 0; i < model.getColumnCount(); i++) {
+ row[i] = model.getValueAt(selectedRow, i);
+ }
+
+ int tempIndex = Integer.parseInt(row[0].toString());
+ row[0] = model.getValueAt(selectedRow - 1, 0);
+ model.setValueAt(tempIndex, selectedRow - 1, 0);
+
+ model.removeRow(selectedRow);
+ model.insertRow(selectedRow - 1, row);
+ table.setRowSelectionInterval(selectedRow - 1, selectedRow - 1);
+ } else {
+ JOptionPane.showMessageDialog(table, ConstantPool.EN_MESSAGE_MOVE_UP);
+ }
+ System.out.println("ưť");
+ });
+
+ moveDownButton.addActionListener(e -> {
+ int selectedRow = table.getSelectedRow();
+ if (selectedRow >= 0 && selectedRow < table.getRowCount() - 1) {
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+ Object[] row = new Object[model.getColumnCount()];
+ for (int i = 0; i < model.getColumnCount(); i++) {
+ row[i] = model.getValueAt(selectedRow, i);
+ }
+ int tempIndex = Integer.parseInt(row[0].toString());
+ row[0] = model.getValueAt(selectedRow + 1, 0);
+ model.setValueAt(tempIndex, selectedRow + 1, 0);
+
+ model.removeRow(selectedRow);
+ model.insertRow(selectedRow + 1, row);
+ table.setRowSelectionInterval(selectedRow + 1, selectedRow + 1);
+ } else {
+ JOptionPane.showMessageDialog(table, ConstantPool.EN_MESSAGE_MOVE_DOWN);
+ }
+ System.out.println("ưť");
+
+ });
+ return buttonPanel;
+ }
+
+ public void createDialog(String title, String labelName, String method) {
+ JDialog dialog = new JDialog((JFrame) SwingUtilities.getWindowAncestor(importButton), title, true);
+ dialog.setLayout(null);
+
+ JLabel label = new JLabel(labelName);
+ label.setBounds(30, 40, 80, 25);
+ dialog.add(label);
+
+ JTextField pathField = new JTextField(15);
+ pathField.setBounds(110, 40, 150, 25);
+ dialog.add(pathField);
+
+ JButton selectButton = new JButton(ConstantPool.EN_BUTTON_CHOOSE);
+ selectButton.setBounds(280, 40, 90, 25);
+
+ selectButton.addActionListener(e -> {
+ JFileChooser fileChooser = new JFileChooser();
+ FileNameExtensionFilter filter = null;
+ if (method.equals("import")) {
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ filter = new FileNameExtensionFilter("Excel Files", "xlsx", "xls");
+ } else if (method.equals("export")) {
+ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ filter = new FileNameExtensionFilter("CSV Files", "csv");
+ } else {
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+ filter = new FileNameExtensionFilter("CSV Files", "csv");
+ }
+ fileChooser.setMultiSelectionEnabled(false);
+ fileChooser.setFileFilter(filter);
+
+ int result = fileChooser.showOpenDialog(dialog);
+ if (result == JFileChooser.APPROVE_OPTION) {
+ pathField.setText(fileChooser.getSelectedFile().getAbsolutePath());
+ }
+ });
+ dialog.add(selectButton, BorderLayout.EAST);
+
+ JButton localOkButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+// localOkButton.setBounds(80, 70, 100, 25);
+ localOkButton.setBounds(80, 90, 100, 25);
+ JButton localCancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+// localCancelButton.setBounds(200, 70, 100, 25);
+ localCancelButton.setBounds(200, 90, 100, 25);
+
+ localOkButton.addActionListener(e -> {
+ String path = pathField.getText();
+ if (path.isEmpty()) {
+ JOptionPane.showMessageDialog(dialog, ConstantPool.EN_MESSAGE_IMPORT);
+ } else if (method.equals("import")) {
+ System.out.println(labelName + ":" + path);
+ // ļչǷΪ .xlsx .xls
+ if (!path.toLowerCase().endsWith(".xlsx") && !path.toLowerCase().endsWith(".xls")) {
+ JOptionPane.showMessageDialog(dialog, ConstantPool.EN_MESSAGE_EXCEL_ERROR);
+ } else {
+ System.out.println(labelName + ":" + path);
+ importData(path);
+ dialog.dispose();
+ }
+ } else if (method.equals("export")) {
+ // ļǷΪĿ¼
+ File file = new File(path);
+ if (!file.isDirectory()) {
+ JOptionPane.showMessageDialog(dialog, ConstantPool.EN_MESSAGE_FILE_ERROR);
+ } else {
+ //
+ System.out.println(labelName + ":" + path);
+ exportData(path);
+ dialog.dispose();
+ }
+ }
+ });
+
+ localCancelButton.addActionListener(e -> {
+ dialog.dispose();
+ });
+
+ dialog.add(localOkButton);
+ dialog.add(localCancelButton);
+
+ // öԻСλ
+ dialog.pack();
+ dialog.setSize(410, 190);
+ dialog.setLocationRelativeTo((JFrame) SwingUtilities.getWindowAncestor(importButton));
+ dialog.setVisible(true);
+ }
+
+ public void importData(String path) {
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+
+ List excelRowData = ReadExcelData.readExcelFile(path);
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
+ excelRowData.forEach(rowData -> {
+ try {
+ Object[] newRow = new Object[model.getColumnCount()];
+ int colSno = 0;
+ newRow[colSno++] = model.getRowCount() + 1;
+ newRow[colSno++] = rowData.getCustomerPN();
+ newRow[colSno++] = rowData.getDescription();
+ newRow[colSno++] = rowData.getRev();
+ newRow[colSno++] = rowData.getDateOfIssuance().isEmpty() ? ""
+ : formatter.parse(rowData.getDateOfIssuance());
+ newRow[colSno++] = rowData.getProductionPIC();
+ newRow[colSno++] = rowData.getBomDeadline().isEmpty() ? "" : formatter.parse(rowData.getBomDeadline());
+ newRow[colSno++] = rowData.getDrawingsDeadline().isEmpty() ? ""
+ : formatter.parse(rowData.getDrawingsDeadline());
+ newRow[colSno++] = rowData.getTechBomDeadline().isEmpty() ? ""
+ : formatter.parse(rowData.getTechBomDeadline());
+ newRow[colSno++] = rowData.getTechDrawingsDeadline().isEmpty() ? ""
+ : formatter.parse(rowData.getTechDrawingsDeadline());
+ newRow[colSno] = rowData.getRemarks();
+ model.addRow(newRow);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ table.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1);
+ }
+
+ public void exportData(String exportPath) {
+// exportPath = "C:\Users\Administrator\Desktop";
+ String excelUid = tcSession.getPreferenceService().getStringValue(PREFERENCE_EXCEL_GETUID);
+ String templateFilePath = "";
+ try {
+ TCComponent comp = tcSession.stringToComponent(excelUid);
+ if (comp instanceof TCComponentDataset) {
+ TCComponentDataset dataset = (TCComponentDataset) comp;
+ String refs = comp.getProperty("ref_names");
+ String[] ref = refs.split(",");
+ File file = dataset.getFiles(ref[0], System.getenv("temp"))[0];
+ templateFilePath = file.getAbsolutePath();
+ System.out.println("filePath: " + templateFilePath);
+
+ exportPath += templateFilePath.substring(templateFilePath.lastIndexOf("\\"));
+ System.out.println("exportPath: " + exportPath);
+ }
+ } catch (TCException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ List rowDataList = getTableData();
+ try (FileInputStream fis = new FileInputStream(templateFilePath); Workbook workbook = new XSSFWorkbook(fis)) {
+
+ CellStyle fillStyle = workbook.createCellStyle();
+ CellStyle centerStyle = workbook.createCellStyle();
+ org.apache.poi.ss.usermodel.Font font = workbook.createFont();
+ font.setFontName("Arial");
+ font.setFontHeightInPoints((short) 12);
+
+ fillStyle.setFont(font);
+ fillStyle.setAlignment(HorizontalAlignment.FILL);
+ fillStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+ fillStyle.setWrapText(false);
+ fillStyle.setBorderTop(BorderStyle.THIN);
+ fillStyle.setBorderBottom(BorderStyle.THIN);
+ fillStyle.setBorderLeft(BorderStyle.THIN);
+ fillStyle.setBorderRight(BorderStyle.THIN);
+
+ centerStyle.setFont(font);
+ centerStyle.setAlignment(HorizontalAlignment.CENTER);
+ centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+ centerStyle.setWrapText(false);
+ centerStyle.setBorderTop(BorderStyle.THIN);
+ centerStyle.setBorderBottom(BorderStyle.THIN);
+ centerStyle.setBorderLeft(BorderStyle.THIN);
+ centerStyle.setBorderRight(BorderStyle.THIN);
+
+ Sheet sheet = workbook.getSheetAt(0);
+ int startRow = 12;
+ int rowNum = startRow;
+
+ for (RowData rowData : rowDataList) {
+ int count = 0;
+ Row row = sheet.createRow(rowNum++);
+ row.createCell(count++).setCellValue(rowNum - startRow); //
+ row.createCell(count++).setCellValue(isNull(rowData.getDrawingNumber()));
+ row.createCell(count++).setCellValue(isNull(rowData.getVersion()));
+ row.createCell(count++).setCellValue(isNull(rowData.getProductName()));
+ row.createCell(count++).setCellValue("");
+ row.createCell(count++)
+ .setCellValue(transfer(rowData.getIssueDate() != null ? rowData.getIssueDate() : ""));
+ row.createCell(count++).setCellValue(
+ transfer(rowData.getMaterialDeliveryTime() != null ? rowData.getMaterialDeliveryTime() : ""));
+ row.createCell(count++).setCellValue(
+ transfer(rowData.getDrawingDeliveryTime() != null ? rowData.getDrawingDeliveryTime() : ""));
+ row.createCell(count++).setCellValue(
+ transfer(rowData.getMaterialReplyDate() != null ? rowData.getMaterialReplyDate() : ""));
+ row.createCell(count++).setCellValue(
+ transfer(rowData.getDrawingReplyDate() != null ? rowData.getDrawingReplyDate() : ""));
+ row.createCell(count++).setCellValue("");
+ row.createCell(count++).setCellValue("");
+ row.createCell(count++).setCellValue(isNull(rowData.getNumber()));
+ row.createCell(count).setCellValue(isNull(rowData.getNotes()));
+
+ for (int colIndex = 0; colIndex <= count; colIndex++) {
+ Cell cell = row.getCell(colIndex);
+ if (cell != null) {
+ if (colIndex == 3) {
+ cell.setCellStyle(fillStyle);
+ } else {
+ cell.setCellStyle(centerStyle);
+ }
+ }
+ }
+ }
+
+ try (FileOutputStream fileOut = new FileOutputStream(exportPath)) {
+ workbook.write(fileOut);
+ }
+
+ } catch (IOException e) {
+ System.err.println("Failed to export data:(Template is not exist) " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ public String isNull(String str) {
+ return str == null || str.isEmpty() ? "" : str;
+ }
+
+ public String transfer(String str) {
+ if (str == null || str.isEmpty()) {
+ return "";
+ }
+
+ String[] parts = str.split("[/-]");
+
+ String year = parts[0];
+ String month = parts[1].replaceFirst("^0+", "");
+ String day = parts[2].replaceFirst("^0+", "");
+
+ return year + "/" + month + "/" + day;
+ }
+
+ public String[] getFormData() {
+ String[] valueList = new String[inputFields.length];
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ for (int i = 0; i < inputFields.length; i++) {
+ if (inputFields[i] instanceof JComboBox) {
+ valueList[i] = (String) ((JComboBox) inputFields[i]).getSelectedItem();
+ } else if (inputFields[i] instanceof JXDatePicker) {
+ Date date = ((JXDatePicker) inputFields[i]).getDate();
+ if (date != null) {
+ valueList[i] = simpleDateFormat.format(date);
+ } else {
+ valueList[i] = "";
+ }
+ } else {
+ valueList[i] = ((JTextField) inputFields[i]).getText();
+ }
+ }
+ return valueList;
+ }
+
+ public List getTableData() {
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+ int rowCount = model.getRowCount();
+ int columnCount = model.getColumnCount();
+
+ List data = new ArrayList();
+
+ for (int row = 0; row < rowCount; row++) {
+ String[] tempRowData = new String[columnCount];
+ for (int i = 0; i < columnCount; i++) {
+ Object obj = model.getValueAt(row, i);
+ if (obj instanceof Integer) {
+ tempRowData[i] = (Integer) obj + "";
+ } else if (obj instanceof Date) {
+ tempRowData[i] = new SimpleDateFormat("yyyy-MM-dd").format(obj);
+ } else {
+ tempRowData[i] = (String) obj;
+ }
+ }
+ int count = 1;
+ RowData drawingTaskBook = new RowData(tempRowData[count++], tempRowData[count++], tempRowData[count++],
+ tempRowData[count++], tempRowData[count++], tempRowData[count++], tempRowData[count++],
+ tempRowData[count++], tempRowData[count++], tempRowData[count++]);
+ data.add(drawingTaskBook);
+ }
+ return data;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectHandler.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectHandler.java
new file mode 100644
index 0000000..72049a2
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateNPIprojectHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateNPIprojectAction action = new CreateNPIprojectAction(application, null, null);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectOperation.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectOperation.java
new file mode 100644
index 0000000..78595f2
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/CreateNPIprojectOperation.java
@@ -0,0 +1,326 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.CountFolder;
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.FormData;
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.RowData;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFOperation;
+import com.teamcenter.rac.common.create.BOCreateDefinitionFactory;
+import com.teamcenter.rac.common.create.CreateInstanceInput;
+import com.teamcenter.rac.common.create.IBOCreateDefinition;
+import com.teamcenter.rac.common.create.SOAGenericCreateHelper;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentFolderType;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCPreferenceService;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+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 CreateNPIprojectOperation extends AbstractAIFOperation {
+ private final String PREFERENCES_FILE_FOLDER = "VF5NPI";
+ private final String PREFERENCES_FILE_FOLDER_CHILD = "VF5NPIChildFolder";
+ private final String FOLDER_TYPE_NORMAL = "Folder";
+ private final String FOLDER_TYPE_NPI = "VF5NPI";
+ private final String ITEM_TYPE_TASK_BOOK = "VF5ctrws";
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ public FormData formData;
+ public List tableData;
+
+ private TCComponentFolderType folderType;
+ private TCComponentFolderType npiType;
+ private TCComponentItemType taskType;
+
+ private TCComponentFolder originFolder;
+
+ private TCComponentFolder tagFolder;
+
+ public CreateNPIprojectOperation(AbstractAIFApplication application, TCComponentFolder targetFolder, FormData lists,
+ List tableData) {
+ this.application = application;
+ this.formData = lists;
+ this.tableData = tableData;
+ this.tcSession = (TCSession) application.getSession();
+ this.tagFolder = targetFolder;
+
+ try {
+ folderType = (TCComponentFolderType) tcSession.getTypeComponent(FOLDER_TYPE_NORMAL);
+ npiType = (TCComponentFolderType) tcSession.getTypeComponent(FOLDER_TYPE_NPI);
+// tableRowType = (TCComponentItemType) this.tcSession.getTypeComponent("VF5ctrwsrow");
+ taskType = (TCComponentItemType) this.tcSession.getTypeComponent(ITEM_TYPE_TASK_BOOK);
+
+ TCPreferenceService getFolderUID = tcSession.getPreferenceService();
+ String value = getFolderUID.getStringValue(PREFERENCES_FILE_FOLDER);
+ if(value == null || value.isEmpty()) {
+ MessageBox.post("Preferred VF5NPI not configured", "Error", MessageBox.ERROR);
+ }
+ System.out.println("ļUID: " + value);
+ originFolder = (TCComponentFolder) tcSession.stringToComponent(value);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void executeOperation() throws Exception {
+
+ System.out.println(formData.toString());
+
+// tableData.stream().forEach(e -> {
+// System.out.println(e.toString());
+// });
+
+ String[] filePath = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDateTime.now()).split("-");
+ CountFolder existFolder = isExistFolder(originFolder, filePath, 0);
+ TCComponentFolder targetFolder = createFolder(existFolder.getFolder(), filePath, existFolder.getCount());
+
+ boolean existNpiFolder = isExistNpiFolder(targetFolder, formData.getProjectName());
+ if (!existNpiFolder) {
+ MessageBox.post("NPI Already Exists", "Error", MessageBox.ERROR);
+ return;
+ }
+ TCComponentFolder npiFolder = creatNpiChildFolder(targetFolder);
+ tagFolder.add("contents", npiFolder);
+ TCComponentItemRevision taskBookRev = setNpiFolderProp(npiFolder);
+ if (taskBookRev == null) {
+ System.out.println("NPI Folder is empty!");
+ } else {
+ System.out.println("succeed to set property!");
+ }
+
+ TCComponent taskBookMaster = taskBookRev.getRelatedComponent("IMAN_master_form_rev");
+
+ String[] propName = { "vf5khth", "vf5cpmc", "vf5khtzbb", "vf5qfrq", "vf5sl", "vf5clqdnq", "vf5ctnq",
+ "vf5clqdnq2", "vf5ctnq2", "vf5beizhu" };
+ String rowType = "VF5ctrwsrow";
+ String tableType = "vf5cpxxTable";
+ System.out.println("begin set table value");
+ assignmentTable(tableData, taskBookMaster, propName, rowType, tableType);
+ System.out.println("after set table value");
+ }
+
+ private boolean isExistNpiFolder(TCComponentFolder targetFolder, String checkName) throws TCException {
+ // TODO Auto-generated method stub
+ TCComponent[] childFolder = targetFolder.getTCProperty("contents").getReferenceValueArray();
+ if (childFolder != null && childFolder.length > 0) {
+ for (int i = 0; i < childFolder.length; i++) {
+ if (childFolder[i].getStringProperty("object_name").equals(checkName)) {
+ return false;
+ }
+ }
+ } else {
+ return true;
+ }
+ return true;
+ }
+
+ public void assignmentTable(List data, TCComponent item, String[] propNames, String boName, String prop) {
+ try {
+ List c = new ArrayList();
+ DataManagementService service = DataManagementService.getService(tcSession);
+ CreateIn[] newIn = new CreateIn[data.size()];
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ for (int i = 0; i < data.size(); ++i) {
+ RowData rowData = data.get(i);
+ CreateIn in = new CreateIn();
+ Map dataPropMap = new HashMap<>();
+ Map stringPropMap = new HashMap<>();
+ int count = 0;
+ stringPropMap.put(propNames[count++], rowData.getDrawingNumber());
+ stringPropMap.put(propNames[count++], rowData.getProductName());
+ stringPropMap.put(propNames[count++], rowData.getVersion());
+ transferCalendar(simpleDateFormat, rowData.getIssueDate(), dataPropMap, propNames, count);
+ count++;
+ stringPropMap.put(propNames[count++], rowData.getNumber());
+ transferCalendar(simpleDateFormat, rowData.getMaterialDeliveryTime(), dataPropMap, propNames, count);
+ count++;
+ transferCalendar(simpleDateFormat, rowData.getDrawingDeliveryTime(), dataPropMap, propNames, count);
+ count++;
+ transferCalendar(simpleDateFormat, rowData.getMaterialReplyDate(), dataPropMap, propNames, count);
+ count++;
+ transferCalendar(simpleDateFormat, rowData.getDrawingReplyDate(), dataPropMap, propNames, count);
+ count++;
+ stringPropMap.put(propNames[count++], rowData.getNotes());
+
+ in.data.boName = boName;
+ in.data.dateProps = dataPropMap;
+ in.data.stringProps = stringPropMap;
+ newIn[i] = in;
+ }
+ System.out.println("Ҫ" + newIn.length);
+ CreateResponse response = service.createObjects(newIn);
+ System.out.println("" + response.serviceData.sizeOfCreatedObjects());
+ System.out.println("" + response.serviceData.sizeOfPartialErrors());
+ for (int i = 0; i < response.serviceData.sizeOfPartialErrors(); i++) {
+ for (int j = 0; j < response.serviceData.getPartialError(i).getErrorValues().length; j++) {
+ System.out
+ .println("" + response.serviceData.getPartialError(i).getErrorValues()[j].getMessage());
+ }
+ }
+ if (response.serviceData.sizeOfCreatedObjects() > 0) {
+ int length = response.serviceData.sizeOfCreatedObjects();
+ for (int i = 0; i < length; ++i) {
+ c.add(response.output[i].objects[0]);
+ }
+ }
+ item.getTCProperty(prop).setReferenceValueArray((TCComponent[]) c.toArray(new TCComponent[c.size()]));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void transferCalendar(SimpleDateFormat simpleDateFormat, String time, Map dataPropMap,
+ String[] propNames, int count) {
+ try {
+ if (time != null && time.isEmpty()) {
+ return;
+ }
+ Date date = simpleDateFormat.parse(time);
+
+ Calendar calendar = Calendar.getInstance();
+
+ calendar.setTime(date);
+
+ dataPropMap.put(propNames[count], calendar);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public CountFolder isExistFolder(TCComponentFolder parentFolder, String[] filePath, int targetFileCount)
+ throws TCException {
+ TCComponent[] folderArrays = parentFolder.getTCProperty("contents").getReferenceValueArray();
+ for (TCComponent tcComponent : folderArrays) {
+ if (tcComponent.getType().equals("Folder")
+ && tcComponent.getStringProperty("object_name").equals(filePath[targetFileCount])) {
+ parentFolder = (TCComponentFolder) tcComponent;
+ return isExistFolder(parentFolder, filePath, targetFileCount + 1);
+ }
+ }
+ return new CountFolder(parentFolder, targetFileCount);
+ }
+
+ public TCComponentFolder createFolder(TCComponentFolder parentFolder, String[] filePath, int targetFileCount)
+ throws TCException {
+ System.out.println("targetFolder: " + parentFolder.getStringProperty("object_name"));
+ for (int i = targetFileCount; i < filePath.length; i++) {
+ TCComponentFolder folder = folderType.create(filePath[i], "", "Folder");
+ parentFolder.add("contents", folder);
+ parentFolder = folder;
+ }
+ return parentFolder;
+ }
+
+ public TCComponentFolder creatNpiChildFolder(TCComponentFolder targetFolder) {
+ if (targetFolder != null) {
+ TCPreferenceService folderStyle = tcSession.getPreferenceService();
+ try {
+ System.out.println("NPIļ֮ǰ");
+ TCComponentFolder npiFolder = soaCreateFolder(formData.getProjectName(), FOLDER_TYPE_NPI);
+ System.out.println("npiFolder = " + npiFolder.toString());
+ targetFolder.add("contents", npiFolder);
+ targetFolder = npiFolder;
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("create npiFolder error !");
+ e.printStackTrace();
+ }
+
+ String[] npiChildPath = folderStyle.getStringValues(PREFERENCES_FILE_FOLDER_CHILD);
+ for (String childPath : npiChildPath) {
+ TCComponentFolder tempFolder = targetFolder;
+ String[] folderName = childPath.split("/");
+ for (String childFolderName : folderName) {
+ try {
+ TCComponentFolder childFolder = folderType.create(childFolderName, "", FOLDER_TYPE_NORMAL);
+ tempFolder.add("contents", childFolder);
+ tempFolder = childFolder;
+ } catch (TCException e) {
+ System.out.println("create inner folder error !");
+ e.printStackTrace();
+ }
+ }
+ }
+ return targetFolder;
+ } else {
+ System.out.println("creatNpiChildFolder method() : targetFolder is null");
+ return null;
+ }
+ }
+
+ public TCComponentItemRevision setNpiFolderProp(TCComponentFolder npiFolder) {
+ if (npiFolder != null) {
+ try {
+ System.out.println("óͼ");
+ String orderDate = formData.getOrderDate();
+ if (orderDate != null && orderDate.length() > 2) {
+ npiFolder.setDateProperty("vf5ddrq", new SimpleDateFormat("yyyy-MM-dd").parse(orderDate));
+ }
+ npiFolder.setStringProperty("vf5tsyq", checkNull(formData.getSpecialRequirements()));
+
+ TCComponentItem taskBookItem = taskType.create(taskType.getNewID(), null, ITEM_TYPE_TASK_BOOK,
+ formData.getProjectName(), "", null);
+ TCComponentItemRevision taskBookRev = taskBookItem.getLatestItemRevision();
+ npiFolder.add("contents", taskBookItem);
+ return taskBookRev;
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("fail to add tagRev !");
+ e.printStackTrace();
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else {
+ System.out.println("method setNpiFolderProp() npiFoder is null");
+ }
+ return null;
+ }
+
+ public String checkNull(String propValue) {
+ return propValue != null ? propValue : "";
+ }
+
+ public TCComponentFolder soaCreateFolder(String name, String type) {
+ System.out.println("ļ" + name);
+ TCComponentFolder folder = null;
+ try {
+ IBOCreateDefinition ibocreatedefinition = BOCreateDefinitionFactory.getInstance()
+ .getCreateDefinition(tcSession, type);
+ CreateInstanceInput cii = new CreateInstanceInput(ibocreatedefinition);
+ List list = new ArrayList();
+ list.add(cii);
+ List list1 = SOAGenericCreateHelper.create(tcSession, ibocreatedefinition, list);
+ if (list1 != null && list1.size() > 0) {
+ TCComponent tccomponent = (TCComponent) list1.get(0);
+ folder = (TCComponentFolder) tccomponent;
+ folder.setProperty("object_name", name);
+ }
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ return folder;
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/daheReadExcel/ExcelRowData.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/daheReadExcel/ExcelRowData.java
new file mode 100644
index 0000000..88d3c04
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/daheReadExcel/ExcelRowData.java
@@ -0,0 +1,159 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel;
+
+public class ExcelRowData {
+
+ private String customerPN;
+ private String rev;
+ private String description;
+ private String customer;
+ private String dateOfIssuance;
+ private String bomDeadline;
+ private String drawingsDeadline;
+ private String techBomDeadline;
+ private String techDrawingsDeadline;
+ private String finalBomDeadline;
+ private String finalDrawingsDeadline;
+ private String productionPIC;
+ private String remarks;
+
+ public ExcelRowData(String... params) {
+ int count =0;
+ this.customerPN = params[count++];
+ this.rev = params[count++];
+ this.description = params[count++];
+ this.customer = params[count++];
+ this.dateOfIssuance = params[count++];
+ this.bomDeadline = params[count++];
+ this.drawingsDeadline = params[count++];
+ this.techBomDeadline = params[count++];
+ this.techDrawingsDeadline = params[count++];
+ this.finalBomDeadline = params[count++];
+ this.finalDrawingsDeadline = params[count++];
+ this.productionPIC = params[count++];
+ this.remarks = params[count];
+ }
+
+
+ public String getCustomerPN() {
+ return customerPN;
+ }
+
+ public void setCustomerPN(String customerPN) {
+ this.customerPN = customerPN;
+ }
+
+ public String getRev() {
+ return rev;
+ }
+
+ public void setRev(String rev) {
+ this.rev = rev;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(String customer) {
+ this.customer = customer;
+ }
+
+ public String getDateOfIssuance() {
+ return dateOfIssuance;
+ }
+
+ public void setDateOfIssuance(String dateOfIssuance) {
+ this.dateOfIssuance = dateOfIssuance;
+ }
+
+ public String getBomDeadline() {
+ return bomDeadline;
+ }
+
+ public void setBomDeadline(String bomDeadline) {
+ this.bomDeadline = bomDeadline;
+ }
+
+ public String getDrawingsDeadline() {
+ return drawingsDeadline;
+ }
+
+ public void setDrawingsDeadline(String drawingsDeadline) {
+ this.drawingsDeadline = drawingsDeadline;
+ }
+
+ public String getTechBomDeadline() {
+ return techBomDeadline;
+ }
+
+ public void setTechBomDeadline(String techBomDeadline) {
+ this.techBomDeadline = techBomDeadline;
+ }
+
+ public String getTechDrawingsDeadline() {
+ return techDrawingsDeadline;
+ }
+
+ public void setTechDrawingsDeadline(String techDrawingsDeadline) {
+ this.techDrawingsDeadline = techDrawingsDeadline;
+ }
+
+ public String getFinalBomDeadline() {
+ return finalBomDeadline;
+ }
+
+ public void setFinalBomDeadline(String finalBomDeadline) {
+ this.finalBomDeadline = finalBomDeadline;
+ }
+
+ public String getFinalDrawingsDeadline() {
+ return finalDrawingsDeadline;
+ }
+
+ public void setFinalDrawingsDeadline(String finalDrawingsDeadline) {
+ this.finalDrawingsDeadline = finalDrawingsDeadline;
+ }
+
+ public String getProductionPIC() {
+ return productionPIC;
+ }
+
+ public void setProductionPIC(String productionPIC) {
+ this.productionPIC = productionPIC;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ @Override
+ public String toString() {
+ return "DataObject{" +
+ "customerPN='" + customerPN + '\'' +
+ ", rev='" + rev + '\'' +
+ ", description='" + description + '\'' +
+ ", customer='" + customer + '\'' +
+ ", dateOfIssuance='" + dateOfIssuance + '\'' +
+ ", bomDeadline='" + bomDeadline + '\'' +
+ ", drawingsDeadline='" + drawingsDeadline + '\'' +
+ ", techBomDeadline='" + techBomDeadline + '\'' +
+ ", techDrawingsDeadline='" + techDrawingsDeadline + '\'' +
+ ", finalBomDeadline='" + finalBomDeadline + '\'' +
+ ", finalDrawingsDeadline='" + finalDrawingsDeadline + '\'' +
+ ", productionPIC='" + productionPIC + '\'' +
+ ", remarks='" + remarks + '\'' +
+ '}';
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/daheReadExcel/ReadExcelData.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/daheReadExcel/ReadExcelData.java
new file mode 100644
index 0000000..1355220
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/daheReadExcel/ReadExcelData.java
@@ -0,0 +1,76 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel;
+
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import com.teamcenter.rac.util.MessageBox;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class ReadExcelData {
+
+ public static List readExcelFile(String filePath) {
+ List excelData = new ArrayList<>();
+ try (FileInputStream fis = new FileInputStream(new File(filePath));
+ Workbook workbook = new XSSFWorkbook(fis)) {
+
+ // ȡһ sheet
+ Sheet sheet = workbook.getSheetAt(0);
+
+ // ÿһУӵ13пʼ0ʼ
+ for (int rowNum = 12; rowNum <= sheet.getLastRowNum(); rowNum++) {
+ Row row = sheet.getRow(rowNum);
+ if (row != null && !getCellValue(row.getCell(0)).isEmpty()) { // Ƿ
+ String[] colValues = new String[row.getLastCellNum()];
+ for (int colNum = 1; colNum < row.getLastCellNum(); colNum++) {
+ Cell cell = row.getCell(colNum);
+ if (cell != null) {
+ colValues[colNum-1]=(getCellValue(cell));
+ } else {
+ colValues[colNum-1]=(""); // ԪΪգӿַ
+ }
+ }
+// System.out.println(Arrays.toString(colValues));
+ // ݷװ DataObject
+ ExcelRowData excelRowData = new ExcelRowData(colValues);
+ excelData.add(excelRowData);
+ }
+ }
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return excelData;
+ }
+
+ private static String getCellValue(Cell cell) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
+ DataFormatter dataFormatter = new DataFormatter();
+
+ switch (cell.getCellType()) {
+ case STRING:
+ return cell.getStringCellValue();
+ case NUMERIC:
+ if (DateUtil.isCellDateFormatted(cell)) {
+ Date date = cell.getDateCellValue();
+ return dateFormat.format(date);
+ } else {
+ // ʹ DataFormatter Ԫʾʽȡֵ
+ return dataFormatter.formatCellValue(cell);
+ }
+ case BOOLEAN:
+ return String.valueOf(cell.getBooleanCellValue());
+ case FORMULA:
+ return cell.getCellFormula();
+ default:
+ return "";
+ }
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/CountFolder.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/CountFolder.java
new file mode 100644
index 0000000..99481d1
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/CountFolder.java
@@ -0,0 +1,37 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity;
+
+import com.teamcenter.rac.kernel.TCComponentFolder;
+
+public class CountFolder {
+
+ private TCComponentFolder folder;
+ private int count;
+
+ public CountFolder(TCComponentFolder folder, int count) {
+ super();
+ this.folder = folder;
+ this.count = count;
+ }
+
+ public TCComponentFolder getFolder() {
+ return folder;
+ }
+
+ public void setFolder(TCComponentFolder folder) {
+ this.folder = folder;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ @Override
+ public String toString() {
+ return "CountFolder [folder=" + folder + ", count=" + count + "]";
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/DatePickerEditor.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/DatePickerEditor.java
new file mode 100644
index 0000000..4eb3111
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/DatePickerEditor.java
@@ -0,0 +1,49 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.EventObject;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JTable;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+
+import org.jdesktop.swingx.JXDatePicker;
+
+public class DatePickerEditor extends AbstractCellEditor implements TableCellEditor{
+
+ private JXDatePicker datePicker;
+
+ public DatePickerEditor() {
+ datePicker = new JXDatePicker();
+ // ڸʽ
+ datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd"));
+ datePicker.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ fireEditingStopped();
+ }
+ });
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof Date) {
+ System.out.println("value : "+value);
+ datePicker.setDate((Date) value);
+ } else {
+ datePicker.setDate(null);
+ }
+ return datePicker;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return datePicker.getDate();
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/FormData.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/FormData.java
new file mode 100644
index 0000000..2416d5e
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/FormData.java
@@ -0,0 +1,46 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity;
+
+public class FormData {
+
+ private String projectName;
+ private String orderDate;
+ private String specialRequirements;
+
+ public FormData(String... params) {
+ int count = 0;
+ this.projectName = params[count++];
+ this.orderDate = params[count++];
+ this.specialRequirements = params[count++];
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public String getOrderDate() {
+ return orderDate;
+ }
+
+ public void setOrderDate(String orderDate) {
+ this.orderDate = orderDate;
+ }
+
+ public String getSpecialRequirements() {
+ return specialRequirements;
+ }
+
+ public void setSpecialRequirements(String specialRequirements) {
+ this.specialRequirements = specialRequirements;
+ }
+
+ @Override
+ public String toString() {
+ return "FormData [projectName=" + projectName + ", orderDate=" + orderDate + ", specialRequirements="
+ + specialRequirements + "]";
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/RowData.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/RowData.java
new file mode 100644
index 0000000..f69b41c
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/entity/RowData.java
@@ -0,0 +1,102 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity;
+
+public class RowData {
+
+ private String DrawingNumber;
+ private String ProductName;
+ private String Version;
+ private String IssueDate;
+ private String Number;
+ private String MaterialDeliveryTime;
+ private String DrawingDeliveryTime;
+ private String MaterialReplyDate;
+ private String DrawingReplyDate;
+ private String Notes;
+
+ public RowData(String... params) {
+ int count = 0 ;
+ DrawingNumber = params[count++];
+ ProductName = params[count++];
+ Version = params[count++];
+ IssueDate = params[count++];
+ Number = params[count++];
+ MaterialDeliveryTime = params[count++];
+ DrawingDeliveryTime = params[count++];
+ MaterialReplyDate = params[count++];
+ DrawingReplyDate = params[count++];
+ Notes = params[count++];
+ }
+
+
+ public String getDrawingNumber() {
+ return DrawingNumber;
+ }
+ public void setDrawingNumber(String drawingNumber) {
+ DrawingNumber = drawingNumber;
+ }
+ public String getProductName() {
+ return ProductName;
+ }
+ public void setProductName(String productName) {
+ ProductName = productName;
+ }
+ public String getVersion() {
+ return Version;
+ }
+ public void setVersion(String version) {
+ Version = version;
+ }
+ public String getIssueDate() {
+ return IssueDate;
+ }
+ public void setIssueDate(String issueDate) {
+ IssueDate = issueDate;
+ }
+ public String getNumber() {
+ return Number;
+ }
+ public void setNumber(String number) {
+ Number = number;
+ }
+ public String getMaterialDeliveryTime() {
+ return MaterialDeliveryTime;
+ }
+ public void setMaterialDeliveryTime(String materialDeliveryTime) {
+ MaterialDeliveryTime = materialDeliveryTime;
+ }
+ public String getDrawingDeliveryTime() {
+ return DrawingDeliveryTime;
+ }
+ public void setDrawingDeliveryTime(String drawingDeliveryTime) {
+ DrawingDeliveryTime = drawingDeliveryTime;
+ }
+ public String getMaterialReplyDate() {
+ return MaterialReplyDate;
+ }
+ public void setMaterialReplyDate(String materialReplyDate) {
+ MaterialReplyDate = materialReplyDate;
+ }
+ public String getDrawingReplyDate() {
+ return DrawingReplyDate;
+ }
+ public void setDrawingReplyDate(String drawingReplyDate) {
+ DrawingReplyDate = drawingReplyDate;
+ }
+ public String getNotes() {
+ return Notes;
+ }
+ public void setNotes(String notes) {
+ Notes = notes;
+ }
+
+
+ @Override
+ public String toString() {
+ return "DrawingTaskBook [DrawingNumber=" + DrawingNumber + ", ProductName=" + ProductName + ", Version="
+ + Version + ", IssueDate=" + IssueDate + ", Number=" + Number + ", MaterialDeliveryTime="
+ + MaterialDeliveryTime + ", DrawingDeliveryTime=" + DrawingDeliveryTime + ", MaterialReplyDate="
+ + MaterialReplyDate + ", DrawingReplyDate=" + DrawingReplyDate + ", Notes=" + Notes + "]";
+ }
+
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/npiProject_locale.properties b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/npiProject_locale.properties
new file mode 100644
index 0000000..1115f24
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreate/npiProject_locale.properties
@@ -0,0 +1,22 @@
+npiProjectDialog.0=Create Npi Projects
+npiProjectDialog.1=NPI Project Name
+npiProjectDialog.2=Whether test product
+npiProjectDialog.3=Inquiry number
+npiProjectDialog.4=Emergency status
+npiProjectDialog.5=Customer name
+npiProjectDialog.6=PLM customer name
+npiProjectDialog.7=Order date
+npiProjectDialog.8=Sales person in charge
+npiProjectDialog.9=Special requirements
+
+npiProjectDialog.10=Serial
+npiProjectDialog.11=Customer PN
+npiProjectDialog.12=Product Name
+npiProjectDialog.13=Rev
+npiProjectDialog.14=Date of Issuance
+npiProjectDialog.15=Num
+npiProjectDialog.16=BOM Deadline
+npiProjectDialog.17=Drawings Deadline
+npiProjectDialog.18=Tec BOM Deadline
+npiProjectDialog.19=Tec Drawings Deadline
+npiProjectDialog.20=Remarks
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationAction.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationAction.java
new file mode 100644
index 0000000..74483b3
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationAction.java
@@ -0,0 +1,138 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreateOnQuotation;
+
+import java.awt.Frame;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.jdesktop.swingx.JXDatePicker;
+
+import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.CreateNPIprojectDialog;
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCPreferenceService;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateNPIprojectOnQuotationAction extends AbstractAIFAction {
+
+ private AbstractAIFApplication application;
+ private JLabel[] inputLabels;
+ private JComponent[] inputFields;
+ private String[] lovArrays;
+ private Map> lovMap;
+
+ private String[] columnNames;
+ private Object[][] data;
+
+ private TCSession tcSession;
+ private final String PREFERENCES = "Salespeoples";
+
+ public CreateNPIprojectOnQuotationAction(AbstractAIFApplication application, Frame frame, String param) {
+ super(application, frame, param);
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ }
+
+ @Override
+ public void run() {
+ boolean flag = false;
+
+ InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
+ if (selectComponent != null && selectComponent instanceof TCComponentFolder) {
+ TCComponentFolder targetRev = (TCComponentFolder) selectComponent;
+ System.out.println("ѡļΪ " + targetRev.getType());
+ if (targetRev.getType().equals("Folder") || targetRev.getType().equals("Fnd0HomeFolder")) {
+ flag = true;
+ } else {
+ MessageBox.post("Please select the correct Folder Type", "error", MessageBox.ERROR);
+ }
+ } else {
+ MessageBox.post("Please select Folder", "error", MessageBox.ERROR);
+ }
+
+ if (flag) {
+ lovMap = new HashMap();
+ lovArrays = new String[] { "VF5sflov", "VF5jjztlov" };
+
+ inputLabels = new JLabel[] { new JLabel("NPI Project Name"), new JLabel("Whether test product"),
+ new JLabel("Inquiry number"), new JLabel("Emergency status"), new JLabel("Customer name"),
+ new JLabel("PLM customer name"), new JLabel("Order date"), new JLabel("Sales person in charge"),
+ new JLabel("Special requirements") };
+
+ JComboBox jComboBox0 = new JComboBox<>(SwingUtil.getKeyValue(lovArrays[0], lovMap));
+ JComboBox jComboBox1 = new JComboBox<>(SwingUtil.getKeyValue(lovArrays[1], lovMap));
+ String[] customerName = getCustomerName();
+ inputFields = new JComponent[] { new JTextField(14), jComboBox0, new JTextField(14), jComboBox1,
+ new JComboBox<>(customerName), new JTextField(14), createDatePicker(),
+ new JComboBox<>(getSaleName()), new JTextField(14) };
+
+ // б
+ columnNames = new String[] { "Serial", "Customer PN", "Product Name", "Rev", "Date of Issuance", "Num",
+ "BOM Deadline", "Drawings Deadline", "Tec BOM Deadline", "Tec Drawings Deadline", "Remarks" };
+
+ //
+ data = new Object[][] {};
+ CreateNPIprojectDialog dialog;
+ dialog = new CreateNPIprojectDialog(this.application, inputLabels, inputFields, lovMap, columnNames, data,
+ true);
+ new Thread(dialog).start();
+ }
+ }
+
+ private JXDatePicker createDatePicker() {
+ // JXDatePicker
+ JXDatePicker datePicker = new JXDatePicker();
+ // ڸʽ
+ datePicker.setFormats(new java.text.SimpleDateFormat("yyyy-MM-dd"));
+ return datePicker;
+ }
+
+ // ѯȡȥ ͻ
+ public String[] getCustomerName() {
+ LinkedHashSet customerNameLov = new LinkedHashSet();
+ Map tempLovMap = new HashMap<>();
+ try {
+ List entryNames = new ArrayList();
+ List entryValues = new ArrayList();
+ entryNames.add("vf5khjc");
+ entryValues.add("*");
+ // 1ѯƣ2ѯĿ3ѯĿӦҪѯֵ
+ InterfaceAIFComponent[] resultComponents = tcSession.search("MU_FindCustomerList",
+ entryNames.toArray(new String[entryNames.size()]),
+ entryValues.toArray(new String[entryNames.size()]));
+ for (int i = 0; i < resultComponents.length; i++) {
+ TCComponentItemRevision tcRevision = (TCComponentItemRevision) resultComponents[i];
+ TCComponent[] tcMaster = tcRevision.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
+ String khmc = tcRevision.getProperty("object_name");
+ String khjc = tcMaster[0].getProperty("vf5khjc");
+ System.out.println("kh : " + khmc + " | " + khjc);
+ customerNameLov.add(khmc);
+ tempLovMap.put(khmc, khjc);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ System.out.println("ѯͻƴ");
+ e.printStackTrace();
+ }
+ lovMap.put("customerName", tempLovMap);
+ return customerNameLov.toArray(new String[0]);
+ }
+
+ public String[] getSaleName() {
+ TCPreferenceService preferenceService = tcSession.getPreferenceService();
+ return preferenceService.getStringValues(PREFERENCES);
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationHandler.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationHandler.java
new file mode 100644
index 0000000..ae6ae5d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreateOnQuotation;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateNPIprojectOnQuotationHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateNPIprojectOnQuotationAction action = new CreateNPIprojectOnQuotationAction(application, null, null);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsCreate/CreateClientDrawingAction.java b/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsCreate/CreateClientDrawingAction.java
new file mode 100644
index 0000000..d03f20d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsCreate/CreateClientDrawingAction.java
@@ -0,0 +1,206 @@
+package com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate;
+
+import java.awt.Frame;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.common.create.BOCreateDefinitionFactory;
+import com.teamcenter.rac.common.create.CreateInstanceInput;
+import com.teamcenter.rac.common.create.IBOCreateDefinition;
+import com.teamcenter.rac.common.create.SOAGenericCreateHelper;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentContextList;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentFolderType;
+import com.teamcenter.rac.kernel.TCComponentForm;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCPreferenceService;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateClientDrawingAction implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private TCComponentFolderType folderType;
+ private TCComponentFolderType productType;
+ private TCComponentItemType itemType;
+
+ public CreateClientDrawingAction(AbstractAIFApplication application) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ try {
+ this.folderType = (TCComponentFolderType) tcSession.getTypeComponent("Folder");
+ this.productType = (TCComponentFolderType) tcSession.getTypeComponent("VF5xmwjj");
+ this.itemType = (TCComponentItemType) tcSession.getTypeComponent("VF5khtz");
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void run() {
+ // TODO ѡNPIĿļ
+ InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
+ TCComponentForm formItem = null; //
+ try {
+ // ȡµı
+ formItem = getFormItem(selectComponent);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String[] preferenceValues = getPreference("VF5PROJECTCHILDFOLDER");
+ if (formItem != null) {
+ if (preferenceValues != null) {
+ TCComponentFolder npiFolder = (TCComponentFolder) selectComponent;
+ try {
+ TCComponent[] rowData = (TCComponent[]) formItem.getTCProperty("vf5cpxxTable")
+ .getReferenceValueArray();
+ createProductFolder(npiFolder, rowData, preferenceValues);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else {
+ MessageBox.post("Fail To Get Preference VF5PROJECTCHILDFOLDER", "Error", MessageBox.ERROR);
+ }
+
+ }
+ System.out.println("Fail To Get Form Item !");
+ }
+
+ public TCComponentFolder createProductChildFolder(TCComponentFolder parentFolder, String filePath) {
+ // TODO Auto-generated method stub
+ if (parentFolder != null) {
+ String[] fileName = filePath.split("/");
+ for (int i = 0; i < fileName.length; i++) {
+ try {
+ TCComponentFolder newChildFolder = folderType.create(fileName[i], "", "Folder");
+ parentFolder.add("contents", newChildFolder);
+ parentFolder = newChildFolder;
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ MessageBox.post("create Folder " + fileName[i] + " error!", "error", MessageBox.ERROR);
+ e.printStackTrace();
+ }
+ }
+ return parentFolder;
+ } else {
+ throw new CustomException("productFolder is not exist");
+ }
+ }
+
+ public void createProductFolder(TCComponentFolder npiFolder, TCComponent[] itemRows, String[] filePaths)
+ throws TCException {
+ // TODO Auto-generated method stub
+ if (filePaths != null && filePaths.length > 0 && npiFolder != null) {
+
+ TCComponentFolder customerFolder = null;
+ TCComponent[] components = npiFolder.getRelatedComponents("contents");
+ System.out.println("\u5BA2\u6237\u56FE\u7EB8");
+ System.out.println("ͻͼֽ");
+ for (int i = 0; i < components.length; i++) {
+ String customerFolderName = components[i].getProperty("object_name");
+ if (customerFolderName.equals("\u5BA2\u6237\u56FE\u7EB8") || customerFolderName.equals("ͻͼֽ")) {
+ customerFolder = (TCComponentFolder) components[i];
+ }
+ }
+
+ if (customerFolder != null) {
+ String rowName = "";
+ String rowRev = "";
+ String rowNo = "";
+ for (TCComponent rowItem : itemRows) {
+ rowName = rowItem.getStringProperty("vf5cpmc");
+ rowRev = rowItem.getStringProperty("vf5khtzbb");
+ rowNo = rowItem.getStringProperty("vf5khth");
+ TCComponentFolder project = soaCreateFolder(rowNo, "VF5xmwjj");
+ for (String path : filePaths) {
+ createProductChildFolder(project, path);
+ }
+ System.out.println("rowName = " + rowName + " | rowRev = " + rowRev
+ + " | rowNo = " + rowNo);
+ TCComponentItem khtz = (TCComponentItem) TcUtil.createComponent(application,
+ new String[] { itemType.getNewID(), rowRev, rowName }, "VF5khtz", "Item");
+ khtz.getLatestItemRevision().setStringProperty("vf5khth", rowNo);
+
+ customerFolder.add("contents", khtz);
+ project.add("contents", khtz);
+ npiFolder.add("contents", project);
+ }
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+ } else {
+ throw new CustomException("xjxxdRevForm or customerFolder is null");
+ }
+
+ } else {
+ throw new CustomException("npiFolder is not exist or Preference error !");
+ }
+
+ }
+
+ public TCComponentForm getFormItem(InterfaceAIFComponent selectComponent) throws Exception {
+ if (selectComponent != null) {
+ System.out.println("type: " + selectComponent.getType());
+ if (selectComponent.getType().equals("VF5NPI")) {
+ TCComponentFolder tarFolder = (TCComponentFolder) selectComponent;
+ TCComponent[] valueArray = tarFolder.getTCProperty("contents").getReferenceValueArray();
+ for (TCComponent tcComponent : valueArray) {
+ if (tcComponent.getStringProperty("object_type").equals("VF5ctrws")) {
+ TCComponentItem tempItem = (TCComponentItem) tcComponent;
+ return (TCComponentForm) tempItem.getLatestItemRevision()
+ .getRelatedComponent("IMAN_master_form_rev");
+ }
+ }
+ } else {
+ MessageBox.post(ConstantPool.EN_MESSAGE_Folder_TYPE_ERROR, "Error", MessageBox.ERROR);
+ }
+ } else {
+ MessageBox.post(ConstantPool.EN_MESSAGE_Folder_ERROR, "Error", MessageBox.ERROR);
+ }
+ return null;
+ }
+
+ public TCComponentFolder soaCreateFolder(String name, String type) {
+ System.out.println("ļ : " + name);
+ TCComponentFolder folder = null;
+ try {
+ IBOCreateDefinition ibocreatedefinition = BOCreateDefinitionFactory.getInstance()
+ .getCreateDefinition(tcSession, type);
+ CreateInstanceInput cii = new CreateInstanceInput(ibocreatedefinition);
+ List list = new ArrayList();
+ list.add(cii);
+ List list1 = SOAGenericCreateHelper.create(tcSession, ibocreatedefinition, list);
+ if (list1 != null && list1.size() > 0) {
+ TCComponent tccomponent = (TCComponent) list1.get(0);
+ folder = (TCComponentFolder) tccomponent;
+ folder.setProperty("object_name", name);
+ }
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ return folder;
+ }
+
+ public String[] getPreference(String prefenenceName) {
+ TCPreferenceService preferenceService = this.tcSession.getPreferenceService();
+ String[] stringValues = preferenceService.getStringValues(prefenenceName);
+ return stringValues;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsCreate/CreateClientDrawingHandler.java b/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsCreate/CreateClientDrawingHandler.java
new file mode 100644
index 0000000..3d3213b
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsCreate/CreateClientDrawingHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateClientDrawingHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateClientDrawingAction action = new CreateClientDrawingAction(application);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsUpload/UploadClientDrawingDialog.java b/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsUpload/UploadClientDrawingDialog.java
new file mode 100644
index 0000000..652ee7b
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsUpload/UploadClientDrawingDialog.java
@@ -0,0 +1,450 @@
+package com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload;
+
+import java.awt.BorderLayout;
+import java.awt.Dialog;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentDataset;
+import com.teamcenter.rac.kernel.TCComponentDatasetType;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentFolderType;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class UploadClientDrawingDialog extends AbstractAIFDialog implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private JLabel selectUploadLabel;
+ private JComponent uploadInput;
+
+ private JButton importButton;
+ private JButton okButton;
+ private JButton celButton;
+
+ private TCComponentFolderType folderType;
+ private TCComponentItemRevision targetRev;
+
+ private TCComponentDatasetType dwgType;
+ private TCComponentDatasetType pdfType;
+ private TCComponentDatasetType dxfType;
+ private TCComponentDatasetType jtType;
+ private TCComponentDatasetType stpType;
+
+ private TCComponentDatasetType docType;
+ private TCComponentDatasetType xlsType;
+ private TCComponentDatasetType pptType;
+
+ private TCComponentDatasetType wordType;
+ private TCComponentDatasetType excelType;
+ private TCComponentDatasetType pptxType;
+
+ private TCComponentDatasetType swprtType;
+ private TCComponentDatasetType swdrwType;
+ private TCComponentDatasetType swasmType;
+
+
+ private TCComponentDatasetType defaultType;
+
+ public UploadClientDrawingDialog(AbstractAIFApplication application) {
+ super();
+ this.application = application;
+ this.tcSession = (TCSession) this.application.getSession();
+ }
+
+ public void initializationComponent() {
+ selectUploadLabel = new JLabel(ConstantPool.EN_LABEL_UPLOAD_PATH);
+ uploadInput = new JTextField(14);
+
+ importButton = new JButton(ConstantPool.EN_BUTTON_SELECT);
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+
+ SwingUtilities.getWindowAncestor(importButton);
+ }
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
+ try {
+ String type = ((TCComponentItemRevision) selectComponent).getStringProperty("object_type");
+ System.out.println("type : " + type);
+ if (selectComponent != null && selectComponent instanceof TCComponentItemRevision
+ && type.equals("VF5khtzRevision")) {
+ targetRev = (TCComponentItemRevision) selectComponent;
+ initUI();
+ } else {
+ MessageBox.post(ConstantPool.EN_MESSAGE_REV_ERROR, "error", MessageBox.ERROR);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ }
+
+ public void initUI() {
+ initializationComponent();
+ // һԶԻ
+ this.setTitle(ConstantPool.EN_TITLE_UPLOAD_PATH);
+
+ this.setLayout(null);
+
+ // ǩ
+ selectUploadLabel.setBounds(30, 40, 80, 25);
+ this.add(selectUploadLabel);
+
+ //
+ uploadInput.setBounds(110, 40, 150, 25);
+ this.add(uploadInput);
+
+ // ѡť
+ importButton.setBounds(280, 40, 90, 25);
+
+ importButton.addActionListener(e -> {
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+ fileChooser.setMultiSelectionEnabled(false);
+
+ int result = fileChooser.showOpenDialog(this);
+ if (result == JFileChooser.APPROVE_OPTION) {
+ ((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath());
+ }
+ });
+ this.add(importButton, BorderLayout.EAST);
+
+ // ȷȡť
+ okButton.setBounds(80, 90, 100, 25);
+ celButton.setBounds(200, 90, 100, 25);
+
+ okButton.addActionListener(e -> {
+ String path = ((JTextField) uploadInput).getText();
+ if (path.isEmpty()) {
+ JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_UPLOAD_ERROR);
+ } else {
+ // ļǷΪĿ¼
+ File file = new File(path);
+ if (!file.isDirectory()) {
+ JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_FILE_ERROR);
+ } else {
+ // ð汾µݼ
+// getDrawingsDataSet();
+ try {
+ folderType = (TCComponentFolderType) tcSession.getTypeComponent("Folder");
+
+ dwgType =(TCComponentDatasetType)tcSession.getTypeComponent("VF5CAD");
+ pdfType =(TCComponentDatasetType)tcSession.getTypeComponent("PDF");
+ dxfType =(TCComponentDatasetType)tcSession.getTypeComponent("DXF");
+ jtType =(TCComponentDatasetType)tcSession.getTypeComponent("DirectModel") ;
+ stpType =(TCComponentDatasetType)tcSession.getTypeComponent("UGPART");
+
+ docType =(TCComponentDatasetType)tcSession.getTypeComponent("MSWord");
+ xlsType =(TCComponentDatasetType)tcSession.getTypeComponent("MSExcel");
+ pptType =(TCComponentDatasetType)tcSession.getTypeComponent("MSPowerPoint");
+
+ wordType =(TCComponentDatasetType)tcSession.getTypeComponent("MSWordX");
+ excelType =(TCComponentDatasetType)tcSession.getTypeComponent("MSExcelX");
+ pptxType =(TCComponentDatasetType)tcSession.getTypeComponent("MSPowerPointX");
+
+ swprtType =(TCComponentDatasetType)tcSession.getTypeComponent("SWPrt");
+ swdrwType =(TCComponentDatasetType)tcSession.getTypeComponent("SWDrw");
+ swasmType =(TCComponentDatasetType)tcSession.getTypeComponent("SWAsm");
+
+ defaultType =(TCComponentDatasetType)tcSession.getTypeComponent("Zip");
+ } catch (TCException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ this.dispose();
+ //
+ try {
+ uploadDrawings(targetRev, file, false);
+ MessageBox.post("upload successfully !", "Info", MessageBox.INFORMATION);
+ } catch (TCException e1) {
+ // TODO Auto-generated catch block
+ MessageBox.post("fail to upload !\n"+e1.getMessage(), "Error", MessageBox.ERROR);
+ e1.printStackTrace();
+ }
+ }
+ }
+ });
+
+ celButton.addActionListener(e -> {
+ // ر
+ this.setVisible(false);
+ // ͷ
+ this.disposeDialog();
+ });
+ this.add(okButton);
+ this.add(celButton);
+
+ // öԻСλ
+ this.pack();
+ this.setSize(410, 190);
+ this.setLocationRelativeTo((Dialog) SwingUtilities.getWindowAncestor(importButton));
+ this.setVisible(true);
+ }
+
+ public void uploadDrawings(TCComponent item, File file, boolean flag) throws TCException {
+
+// Map fileMap = getFileMap(item);
+// String fileName = file.getName();
+// if (file.isFile()){
+// TCComponentDataset existData = isExistData(fileMap, fileName);
+// if(existData!=null && removeData(item,existData)) {
+// System.out.println("ɾɹʼݼ: "+fileName);
+// }
+// TCComponentDataset date = addData(item, file.getAbsolutePath());
+// if(date == null) {
+// StringBuffer str = new StringBuffer();
+// str.append("Under the file path: ");
+// str.append(file.getAbsolutePath());
+// str.append("\nfileName: ");
+// str.append(fileName);
+// str.append(" add failed");
+// JOptionPane.showMessageDialog(this,str.toString());
+// }
+// } else if (file.isDirectory()) {
+// if(flag) {
+// // ļ
+// for (File childFile : file.listFiles()){
+// uploadDrawings(item,childFile,false);
+// }
+// }else {
+// TCComponentFolder existFolder = isExistFolder(item,fileName);
+// if(existFolder==null) {
+// existFolder = addFolder(item, file.getName());
+// }
+//
+// // ļ
+// for (File childFile : file.listFiles()){
+// uploadDrawings(existFolder,childFile,false);
+// }
+// }
+// }
+
+ File[] files = file.listFiles();
+ String folderName = file.getName();
+ TCComponent existFolder = item;
+ if (flag) {
+ existFolder = isExistFolder(item, folderName);
+ if (existFolder == null) {
+ existFolder = addFolder(item, folderName);
+ }
+ }
+ Map fileMap = getFileMap(existFolder);
+ if (files != null && files.length > 0) {
+ for (int i = 0; i < files.length; i++) {
+ String fileName = files[i].getName();
+ if (files[i].isDirectory()) {
+ uploadDrawings(existFolder, files[i], true);
+ } else {
+ TCComponentDataset existData = isExistData(fileMap, fileName);
+ if (existData != null && removeData(existFolder, existData)) {
+ System.out.println("Delete successfully, start to add data set: " + fileName);
+ }
+ TCComponentDataset date = addData(existFolder, files[i].getAbsolutePath());
+ if (date == null) {
+ StringBuffer str = new StringBuffer();
+ str.append("Under the file path: ");
+ str.append(files[i].getAbsolutePath());
+ str.append("\nfileName: ");
+ str.append(fileName);
+ str.append(" add failed");
+ JOptionPane.showMessageDialog(this, str.toString());
+ }
+ }
+ }
+ }
+ }
+
+ public Map getFileMap(TCComponent item) throws TCException {
+ Map map = new HashMap();
+ TCComponent[] referenceValueArray = null;
+ if (item instanceof TCComponentItemRevision) {
+ TCComponentItemRevision tempItemRev = (TCComponentItemRevision) item;
+ referenceValueArray = tempItemRev.getTCProperty("IMAN_specification").getReferenceValueArray();
+ } else if (item instanceof TCComponentFolder) {
+ referenceValueArray = item.getTCProperty("contents").getReferenceValueArray();
+ }
+ if (referenceValueArray.length > 0) {
+ for (TCComponent tcDataset : referenceValueArray) {
+ map.put(tcDataset.getStringProperty("object_name"), (TCComponentDataset) tcDataset);
+ }
+ }
+ return map;
+ }
+
+ public TCComponentDataset isExistData(Map tcMap, String fileName) {
+ if (tcMap != null && tcMap.containsKey(fileName)) {
+ return tcMap.get(fileName);
+ }
+ return null;
+ }
+
+ public TCComponentFolder isExistFolder(TCComponent item, String fileName) throws TCException {
+ System.out.println("Determine whether this folder is contained in tc:(fileName) " + fileName);
+ if (item instanceof TCComponentItemRevision) {
+ TCComponentItemRevision tempItemRev = (TCComponentItemRevision) item;
+ // õtcļж
+ TCComponent[] referenceValueArray = tempItemRev.getTCProperty("IMAN_reference").getReferenceValueArray();
+ for (TCComponent tcFolder : referenceValueArray) {
+ System.out.println("ǰļУ" + tcFolder.getStringProperty("object_name"));
+ if (tcFolder.getType().equals("Folder") && tcFolder.getStringProperty("object_name").equals(fileName)) {
+ System.out.println("The Folder Exists");
+ return (TCComponentFolder) tcFolder;
+ }
+ }
+ } else if (item instanceof TCComponentFolder) {
+ TCComponent[] referenceValueArray = item.getTCProperty("contents").getReferenceValueArray();
+ for (TCComponent tcFolder : referenceValueArray) {
+ if (tcFolder.getType().equals("Folder") && tcFolder.getStringProperty("object_name").equals(fileName)) {
+ return (TCComponentFolder) tcFolder;
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean removeData(TCComponent obj, TCComponentDataset dataSet) throws TCException {
+ if (obj instanceof TCComponentItemRevision) {
+ TCComponentItemRevision temp = (TCComponentItemRevision) obj;
+ temp.remove("IMAN_specification", dataSet);
+ return true;
+ } else if (obj instanceof TCComponentFolder) {
+ TCComponentFolder temp = (TCComponentFolder) obj;
+ temp.remove("contents", dataSet);
+ return true;
+ }
+ return false;
+ }
+
+ public TCComponentDataset addData(TCComponent obj, String filePath) throws TCException {
+ System.out.println("Add Data Set..." + filePath);
+ TCComponentDataset tempData = null;
+ String fileName = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
+ String lastName = fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase();
+ switch (lastName) {
+ case "dwg":{
+ tempData = dwgType.create(fileName, "", "VF5CAD");
+ tempData.setFiles(new String[] {filePath},new String[] {"VF5dwg"});
+ break;
+ }
+ case "pdf":{
+ tempData = pdfType.create(fileName, "", "PDF");
+ tempData.setFiles(new String[] {filePath},new String[] {"PDF_Reference"});
+ break;
+ }
+ case "dxf":{
+ tempData = dxfType.create(fileName, "", "DXF");
+ tempData.setFiles(new String[] {filePath},new String[] {"DXF"});
+ break;
+ }
+ case "jt":{
+ tempData = jtType.create(fileName, "", "DirectModel");
+ tempData.setFiles(new String[] {filePath},new String[] {"JTPART"});
+ break;
+ }
+ case "stp":{
+ tempData = stpType.create(fileName, "", "UGPART");
+ tempData.setFiles(new String[] {filePath},new String[] {"STEP-files"});
+ break;
+ }
+ case "doc":{
+ tempData = wordType.create(fileName, "", "MSWord");
+ tempData.setFiles(new String[] {filePath},new String[] {"word"});
+ break;
+ }
+ case "xls":{
+ tempData = excelType.create(fileName, "", "MSExcel");
+ tempData.setFiles(new String[] {filePath},new String[] {"excel"});
+ break;
+ }
+ case "ppt":{
+ tempData = docType.create(fileName, "", "MSPowerPoint");
+ tempData.setFiles(new String[] {filePath},new String[] {"powerpoint"});
+ break;
+ }
+ case "docx":{
+ tempData = xlsType.create(fileName, "", "MSWordX");
+ tempData.setFiles(new String[] {filePath},new String[] {"word"});
+ break;
+ }
+ case "xlsx":{
+ tempData = pptType.create(fileName, "", "MSExcelX");
+ tempData.setFiles(new String[] {filePath},new String[] {"excel"});
+ break;
+ }
+ case "pptx":{
+ tempData = pptxType.create(fileName, "", "MSPowerPointX");
+ tempData.setFiles(new String[] {filePath},new String[] {"powerpoint"});
+ break;
+ }
+ case "sldprt":{
+ tempData = pptxType.create(fileName, "", "SWPrt");
+ tempData.setFiles(new String[] {filePath},new String[] {"powerpoint"});
+ break;
+ }
+ case "slddrw":{
+ tempData = pptxType.create(fileName, "", "SWDrw");
+ tempData.setFiles(new String[] {filePath},new String[] {"PrtFile"});
+ break;
+ }
+ case "sldasm":{
+ tempData = pptxType.create(fileName, "", "SWAsm");
+ tempData.setFiles(new String[] {filePath},new String[] {"DrwFile"});
+ break;
+ }
+ default :{
+ tempData = defaultType.create(fileName, "", "Zip");
+ tempData.setFiles(new String[] {filePath},new String[] {"AsmFile"});
+ break;
+ }
+ }
+
+ if (tempData != null && obj instanceof TCComponentItemRevision) {
+ TCComponentItemRevision temp = (TCComponentItemRevision) obj;
+ temp.add("IMAN_specification", tempData);
+ return tempData;
+ } else if (tempData != null && obj instanceof TCComponentFolder) {
+ TCComponentFolder temp = (TCComponentFolder) obj;
+ temp.add("contents", tempData);
+ return tempData;
+ }
+ return null;
+ }
+
+ public TCComponentFolder addFolder(TCComponent item, String fileName) throws TCException {
+ System.out.println("Add Folders... " + fileName);
+ TCComponentFolder newFolder = folderType.create(fileName, "", "Folder");
+ if (item instanceof TCComponentItemRevision) {
+ TCComponentItemRevision temp = (TCComponentItemRevision) item;
+ temp.add("IMAN_reference", newFolder);
+ return newFolder;
+ } else if (item instanceof TCComponentFolder) {
+ TCComponentFolder temp = (TCComponentFolder) item;
+ temp.add("contents", newFolder);
+ return newFolder;
+ }
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsUpload/UploadClientDrawingHandler.java b/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsUpload/UploadClientDrawingHandler.java
new file mode 100644
index 0000000..b01c36d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/NPIproject/customerDrawingsUpload/UploadClientDrawingHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class UploadClientDrawingHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ UploadClientDrawingDialog action = new UploadClientDrawingDialog(application);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/Test.java b/src/com/connor/ferrorTech/metal/Test.java
new file mode 100644
index 0000000..308d0e1
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/Test.java
@@ -0,0 +1,13 @@
+package com.connor.ferrorTech.metal;
+
+import com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadDialog;
+
+public class Test {
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ UploadDialog uploadDialog = new UploadDialog(null);
+ uploadDialog.initUi();
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadDialog.java b/src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadDialog.java
new file mode 100644
index 0000000..4e64e1c
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadDialog.java
@@ -0,0 +1,406 @@
+package com.connor.ferrorTech.metal.batchDownload;
+
+import java.awt.BorderLayout;
+import java.awt.Dialog;
+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.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentDataset;
+import com.teamcenter.rac.kernel.TCComponentDatasetType;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentFolderType;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class BatchDownloadDialog extends AbstractAIFDialog {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private JLabel selectUploadLabel;
+ private JComponent uploadInput;
+
+ private JButton importButton;
+ private JButton okButton;
+ private JButton celButton;
+
+ private Map ccpGx;
+ private Map bcpGx;
+ private Map clGx;
+ private Map gxGx;
+
+ private TCComponentBOMWindow view;
+
+ public BatchDownloadDialog(AbstractAIFApplication application) {
+ super(true);
+ this.application = application;
+ this.tcSession = (TCSession) this.application.getSession();
+ }
+
+ public void initializationComponent() {
+ selectUploadLabel = new JLabel(ConstantPool.EN_LABEL_UPLOAD_PATH);
+ uploadInput = new JTextField(14);
+
+ importButton = new JButton(ConstantPool.EN_BUTTON_SELECT);
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+
+ SwingUtilities.getWindowAncestor(importButton);
+ }
+
+ @Override
+ public void run() {
+ initUi();
+ }
+
+ /**
+ * ʼ
+ */
+ public void initUi() {
+ initializationComponent();
+ this.setTitle(ConstantPool.EN_TITLE_DOWNLOAD_PATH);
+
+ this.setLayout(null);
+
+ selectUploadLabel.setBounds(30, 40, 80, 25);
+ this.add(selectUploadLabel);
+
+ uploadInput.setBounds(110, 40, 150, 25);
+ this.add(uploadInput);
+
+ importButton.setBounds(280, 40, 90, 25);
+
+ importButton.addActionListener(e -> {
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ fileChooser.setMultiSelectionEnabled(false);
+ FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV Files", "csv");
+ fileChooser.setFileFilter(filter);
+
+ int result = fileChooser.showOpenDialog(this);
+ if (result == JFileChooser.APPROVE_OPTION) {
+ ((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath());
+ }
+ });
+ this.add(importButton, BorderLayout.EAST);
+
+ okButton.setBounds(80, 90, 100, 25);
+ celButton.setBounds(200, 90, 100, 25);
+
+ okButton.addActionListener(e -> {
+ String path = ((JTextField) uploadInput).getText();
+ if (path.isEmpty()) {
+ JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_UPLOAD_ERROR);
+ } else {
+ File file = new File(path);
+ if (!file.exists() || !file.isDirectory()) {
+ JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_FILE_ERROR);
+ } else {
+ downloadFiles(file);
+ this.dispose();
+ }
+ }
+ });
+
+ celButton.addActionListener(e -> {
+ this.setVisible(false);
+ this.disposeDialog();
+ });
+ this.add(okButton);
+ this.add(celButton);
+ this.pack();
+ this.setSize(410, 190);
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ this.setLocationRelativeTo((Dialog) SwingUtilities.getWindowAncestor(importButton));
+ this.setVisible(true);
+ }
+
+ public void downloadFiles(File file) {
+ ccpGx = new HashMap<>();
+ ccpGx.put("VF5idgx", "VF5nbtz");
+ ccpGx.put("VF5pcgx", "VF5procctrl");
+ ccpGx.put("VF5rdgx", "VF5jctz");
+ ccpGx.put("VF5ssgx", "VF5setupsheet");
+ ccpGx.put("VF5rwigx", "VF5rwi");
+ ccpGx.put("VF5gygx", "VF5gy");
+
+ bcpGx = new HashMap<>();
+ bcpGx.put("VF5spgx", "VF5bcptz");
+
+ clGx = new HashMap<>();
+ clGx.put("VF5rmgx", "VF5ycltz");
+
+ gxGx = new HashMap<>();
+ gxGx.put("VF5ncgx", "VF5ncfile");
+ gxGx.put("VF5pdgx", "VF5gytz");
+ gxGx.put("VF5pmgx", "VF5yjgtz");
+ gxGx.put("VF5tlgx", "VF5tl");
+ gxGx.put("VF5swigx", "VF5swi");
+ gxGx.put("VF5rwigx", "VF5rwi");
+ gxGx.put("VF5ipgx", "VF5ip");
+
+ TCSession session = (TCSession) application.getSession();
+
+ TCComponentFolder tcFolder = (TCComponentFolder) application.getTargetComponent();
+ try {
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
+ view = winType.create(null);
+ String tarType = tcFolder.getStringProperty("object_type");
+
+ if (tarType.equals("Folder") || tarType.equals("VF5xmwjj")) {
+ mainProcess(tcFolder, file.getAbsolutePath());
+ } else if (tarType.equals("VF5NPI")) {
+ TCComponent[] childFolders = tcFolder.getRelatedComponents("contents");
+ for (TCComponent childFolder : childFolders) {
+ String childItemType = childFolder.getStringProperty("object_type");
+ System.out.println("childFolder type is " + childItemType);
+ System.out.println("childFolder name is " + childFolder.getStringProperty("object_name"));
+ if (childItemType.equals("Folder") || childItemType.equals("VF5xmwjj")) {
+ File createNewFolder = createNewFolder(file, childFolder.getStringProperty("object_name"));
+ mainProcess((TCComponentFolder) childFolder, createNewFolder.getAbsolutePath());
+ }
+ }
+ }
+ MessageBox.post("DownLoad Successfully !", "Info", MessageBox.INFORMATION);
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ MessageBox.post(e.getMessage(), "Info", MessageBox.INFORMATION);
+ }
+ }
+
+ public File createNewFolder(File file, String folderName) {
+ String absolutePath = file.getAbsolutePath();
+ File childFolder = new File(absolutePath + "\\" + folderName);
+ if (!childFolder.exists()) {
+ boolean mkdir = childFolder.mkdir();
+ if (mkdir == false) {
+ System.out.println("createNewFolder error !");
+ }
+ System.out.println("create successful ! " + folderName);
+ } else {
+ System.out.println("is exist !");
+ }
+ return childFolder;
+ }
+
+ public void mainProcess(TCComponentFolder tcFolder, String filePath) {
+ try {
+ Map targetsMap = new HashMap();
+ getTargets(tcFolder, targetsMap);
+ List tcList = new ArrayList<>();
+ Set keySet = targetsMap.keySet();
+ for (String key : keySet) {
+ tcList.add(targetsMap.get(key));
+ }
+ List dataSet = getDataSet(tcList);
+ for (TCComponentDataset tcComponentDataset : dataSet) {
+ getToLocal(tcComponentDataset, filePath);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ }
+
+ public void getToLocal(TCComponentDataset data, String filePath) {
+ // ȡļ
+ String templateFilePath = "";
+ try {
+ String fileName = data.getStringProperty("object_name");
+ System.out.println("begin add file: " + fileName);
+ if (!fileName.contains(".")) {
+ return;
+ }
+ String refs = data.getProperty("ref_names");
+ String[] ref = refs.split(",");
+ File file = data.getFiles(ref[0], filePath)[0];
+ templateFilePath = file.getAbsolutePath();
+ // ȡļľ·templateFilePath
+ System.out.println("after add file: " + templateFilePath);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ // ȡݼ
+ public List getDataSet(List tcList) throws TCException {
+ // TODO Auto-generated method stub
+ List dataSets = new ArrayList();
+ for (TCComponentItemRevision rev : tcList) {
+ String revType = rev.getStringProperty("object_type");
+ if (revType.equals("VF5bjtzRevision") || revType.equals("VF5khtzRevision")) {
+ TCComponentFolder[] folders = (TCComponentFolder[]) rev.getRelatedComponents("IMAN_reference");
+ for (TCComponentFolder folder : folders) {
+ TCComponent[] relatedComponents = folder.getRelatedComponents("contents");
+ for (TCComponent dataSet : relatedComponents) {
+ if (dataSet != null && dataSet instanceof TCComponentDataset) {
+ dataSets.add((TCComponentDataset) dataSet);
+ }
+ }
+ }
+ }
+ TCComponent[] dataList = rev.getRelatedComponents("IMAN_specification");
+ for (TCComponent dataSet : dataList) {
+ if (dataSet != null && dataSet instanceof TCComponentDataset) {
+ dataSets.add((TCComponentDataset) dataSet);
+ }
+ }
+ }
+ return dataSets;
+ }
+
+ // ȡļƥ¶
+ public boolean getTargets(TCComponentFolder tarFolder, Map targetsMap)
+ throws TCException {
+ TCComponent[] components = tarFolder.getRelatedComponents("contents");
+
+ for (TCComponent childComponent : components) {
+ getItemRev(childComponent, targetsMap);
+ }
+ return false;
+ }
+
+ public void getItemRev(TCComponent childComponent, Map targetsMap)
+ throws TCException {
+ if (childComponent instanceof TCComponentFolder) {
+ getTargets((TCComponentFolder) childComponent, targetsMap);
+ } else if (childComponent instanceof TCComponentItem) {
+ TCComponentItem childItem = (TCComponentItem) childComponent;
+ TCComponentItemRevision childRev = childItem.getLatestItemRevision();
+ String itemType = childItem.getStringProperty("object_type");
+ System.out.println("type ==> " + itemType + " || " + childRev.toString());
+ switch (itemType) {
+ case "VF5ccp": {
+ getGxTatgets(childRev, ccpGx, targetsMap);
+
+ TCComponentBOMLine ccpBomLine = view.setWindowTopLine(childItem, childRev, null, null);
+ getBomRuleChild(ccpBomLine, new String[] { "VF5bcpRevision", "VF5clRevision" }, targetsMap);
+ break;
+ }
+ case "VF5bcp": {
+ getGxTatgets(childRev, bcpGx, targetsMap);
+
+ TCComponentBOMLine bcpBomLine = view.setWindowTopLine(childItem, childRev, null, null);
+ getBomRuleChild(bcpBomLine, new String[] { "VF5clRevision" }, targetsMap);
+ break;
+ }
+ case "VF5cl": {
+ getGxTatgets(childRev, clGx, targetsMap);
+ break;
+ }
+ case "VF5gy": {
+ TCComponentBOMLine gyBomLine = view.setWindowTopLine(childItem, childRev, null, null);
+ getBomRuleChild(gyBomLine, new String[] { "VF5gxRevision" }, targetsMap);
+ break;
+ }
+ case "VF5gx": {
+ getGxTatgets(childRev, gxGx, targetsMap);
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ }
+ }
+
+ public void getGxTatgets(TCComponentItemRevision tarItem, Map gxMap,
+ Map targetsMap) throws TCException {
+ Set gxSet = gxMap.keySet();
+ System.out.println("===> 汾µĹϵ " + tarItem.toString());
+ // 汾йϵ ȡùϵ·͵İ汾
+ for (String gxValue : gxSet) {
+ System.out.println("##ϵ" + gxValue);
+ TCComponent[] relatedComponents = tarItem.getRelatedComponents(gxValue);
+ String targetType = gxMap.get(gxValue);
+ if (relatedComponents == null) {
+ continue;
+ }
+ for (TCComponent gxChildItem : relatedComponents) {
+ TCComponentItemRevision targetRev = null;
+ TCComponentItem targetItem = null;
+ if (gxChildItem instanceof TCComponentItem) {
+ targetItem = (TCComponentItem) gxChildItem;
+ targetRev = targetItem.getLatestItemRevision();
+ } else if (gxChildItem instanceof TCComponentItemRevision) {
+ targetRev = (TCComponentItemRevision) gxChildItem;
+ targetItem = targetRev.getItem();
+ }
+ String itemType = targetItem.getStringProperty("object_type");
+ System.out.println(itemType + " || " + targetRev.toString());
+ if (gxValue.equals("VF5gygx")) {
+ System.out.println("***ϹϵУ" + targetRev.toString());
+ getItemRev(targetItem, targetsMap);
+ } else if (targetRev != null && targetItem != null && itemType.equals(targetType)) {
+ System.out.println("***ϹϵУ" + targetRev.toString());
+ targetsMap.put(targetRev.getUid(), targetRev);
+ }
+ }
+ }
+ }
+
+ public void getBomRuleChild(TCComponentBOMLine gyBomLine, String[] ruleType,
+ Map targetsMap) throws TCException {
+ boolean hasChildren = gyBomLine.hasChildren();
+ if (hasChildren) {
+ AIFComponentContext[] childrena = gyBomLine.getChildren();
+ for (AIFComponentContext children : childrena) {
+ TCComponentBOMLine component = (TCComponentBOMLine) children.getComponent();
+ TCComponentItemRevision childRev = component.getItemRevision();
+ String revType = childRev.getStringProperty("object_type");
+ if (ruleType.length == 1 && revType.equals(ruleType[0])) {
+ switch (revType) {
+ case "VF5gxRevision": {
+ getGxTatgets(childRev, gxGx, targetsMap);
+ break;
+ }
+ case "VF5clRevision": {
+ getGxTatgets(childRev, clGx, targetsMap);
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ } else if (ruleType.length == 2 && revType.equals(ruleType[0])) {
+ // طbug
+ getGxTatgets(childRev, bcpGx, targetsMap);
+ } else if (ruleType.length == 2 && revType.equals(ruleType[1])) {
+ getGxTatgets(childRev, clGx, targetsMap);
+ }
+ }
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadHandler.java b/src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadHandler.java
new file mode 100644
index 0000000..bc72102
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadHandler.java
@@ -0,0 +1,26 @@
+package com.connor.ferrorTech.metal.batchDownload;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadDialog;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class BatchDownloadHandler extends AbstractHandler {
+
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"VF5NPI","VF5xmwjj","Folder"}, "Folder");
+ if(judgeSingleSelectComponent) {
+ BatchDownloadDialog dialog = new BatchDownloadDialog(application);
+ new Thread(dialog).start();
+ }
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/bomProcess/ApprovalOfBomProcessHandler.java b/src/com/connor/ferrorTech/metal/bomProcess/ApprovalOfBomProcessHandler.java
new file mode 100644
index 0000000..315a7ed
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/bomProcess/ApprovalOfBomProcessHandler.java
@@ -0,0 +1,172 @@
+package com.connor.ferrorTech.metal.bomProcess;
+
+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.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentProcessType;
+import com.teamcenter.rac.kernel.TCComponentTaskTemplate;
+import com.teamcenter.rac.kernel.TCComponentTaskTemplateType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand;
+
+public class ApprovalOfBomProcessHandler extends AbstractHandler {
+
+ private TCComponentFolder[] targetFolders;
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ TCSession tcSession = (TCSession) application.getSession();
+ String errorName = "";
+ try {
+ errorName = judgeFolder(application);
+
+ if (errorName != null && !errorName.isEmpty()) {
+ MessageBox.post(errorName + " Is Not Target Folder !", "error", MessageBox.ERROR);
+ } else {
+ List list = getFilesWithCcp(targetFolders);
+ TCComponent[] publicItems = filterTComponent(list);
+
+// String preferenceValue = TcUtil.getPreferenceValue(tcSession, "VF5BOM_PROCESS_RELEASE");
+// if (preferenceValue != null && !preferenceValue.isEmpty() && publicItems != null
+// && publicItems.length > 0) {
+
+ if (publicItems != null && publicItems.length > 0) {
+// CreateProcess(tcSession, publicItems, preferenceValue);
+// MessageBox.post("Public Successful !", "Info", MessageBox.INFORMATION);
+
+// new NewProcessCommand(AIFUtility.getActiveDesktop(), application, publicItems);
+ NewProcessCommand cmd = new NewProcessCommand(AIFUtility.getActiveDesktop(), application,
+ publicItems);
+ cmd.executeModeless();
+ } else {
+ MessageBox.post("Preference configuration error or failure to find VF5ccp, VF5gy objects", "error",
+ MessageBox.ERROR);
+ }
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public TCComponent[] filterTComponent(List list) {
+ List newList = new ArrayList<>();
+ if (list != null && list.size() > 0) {
+ try {
+ for (int i = 0; i < list.size(); i++) {
+ TCComponentItem item = (TCComponentItem) list.get(i);
+ TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
+ TCComponent[] releaseList = latestItemRevision.getRelatedComponents("release_status_list");
+ if (releaseList != null && releaseList.length > 0) {
+ continue;
+ } else {
+ newList.add(latestItemRevision);
+ }
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ }
+ return newList.toArray(new TCComponent[newList.size()]);
+ }
+
+ public void CreateProcess(TCSession session, TCComponent[] targets, String processName) throws TCException {
+ try {
+ System.out.println("number : " + targets.length);
+
+ TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");
+ TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session
+ .getTypeComponent("EPMTaskTemplate");
+ TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0);
+ int[] number = new int[targets.length];
+ for (int i = 0; i < targets.length; i++) {
+ number[i] = 1;
+ }
+ if (taskTemplate != null) {
+ String name = targets[0].getProperty("object_string");
+ processType.create(processName + ":" + name, "", taskTemplate, targets, number);
+ }
+ } catch (TCException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ public String judgeFolder(AbstractAIFApplication application) throws TCException {
+ InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
+
+ if (targetComponents != null && targetComponents.length > 0) {
+ targetFolders = new TCComponentFolder[targetComponents.length];
+ for (int i = 0; i < targetComponents.length; i++) {
+ if (!targetComponents[i].getType().equals("VF5xmwjj")) {
+ return ((TCComponentFolder) targetComponents[i]).getStringProperty("object_name");
+ } else {
+ targetFolders[i] = (TCComponentFolder) targetComponents[i];
+ }
+ }
+ } else {
+ MessageBox.post("Please Select Folder !", "Error", MessageBox.ERROR);
+ }
+ return null;
+ }
+
+ public List getFilesWithCcp(TCComponentFolder[] targetFolders) {
+ List result = new ArrayList<>();
+ try {
+ for (TCComponentFolder targetFolder : targetFolders) {
+ traverseDirectory(targetFolder, result);
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ /**
+ * ݹĿ¼Ŀ¼
+ *
+ * @param directory Ŀ¼ļ
+ * @param result 洢ļб
+ * @throws TCException
+ */
+ private void traverseDirectory(TCComponentFolder targetFolder, List result) throws TCException {
+ TCComponent[] childItems = targetFolder.getTCProperty("contents").getReferenceValueArray();
+
+ if (childItems != null && childItems.length > 0) {
+ for (TCComponent childItem : childItems) {
+ if (childItem.getType().equals("Folder")) {
+ traverseDirectory((TCComponentFolder) childItem, result);
+ } else if (childItem.getType().equals("VF5ccp")) {
+ result.add(childItem);
+ // ܻ⣬û⣬
+ TCComponent[] gyGx = childItem.getRelatedComponents("VF5gygx");
+ for (TCComponent tcComponent : childItems) {
+ if (tcComponent.getStringProperty("object_type").equals("VF5gy")) {
+ result.add(tcComponent);
+ }
+ }
+ } else if (childItem.getType().equals("VF5gy")) {
+ result.add(childItem);
+ }
+ }
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateDialog.java b/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateDialog.java
new file mode 100644
index 0000000..21b9496
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateDialog.java
@@ -0,0 +1,448 @@
+package com.connor.ferrorTech.metal.changeManagement.createECO;
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableModel;
+
+import com.connor.ferrorTech.metal.changeManagement.createECR.CustomTableCellRenderer;
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+import java.awt.*;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+
+public class ChangeNoticeFormCreateDialog extends JFrame implements Runnable {
+
+ private final String title;
+ private AbstractAIFApplication application;
+ private InterfaceAIFComponent targetComponent;
+
+ private final JLabel[] jLabels;
+ private final JComponent[] jComponents;
+ private JButton confirmButton;
+ private JButton cancelButton;
+ private JButton addButton;
+ private JButton removeButton;
+
+ private JTable leftTable;
+ private JTable rightTable;
+ private String[][] leftData;
+ private String[][] rightData;
+
+ public ChangeNoticeFormCreateDialog(AbstractAIFApplication application, String title, Object... args) {
+ int count = 0;
+ this.title = title;
+ this.application = application;
+ jLabels = (JLabel[]) args[count++];
+ jComponents = (JComponent[]) args[count++];
+ leftData = (String[][]) args[count];
+ }
+
+ @Override
+ public void run() {
+ targetComponent = application.getTargetComponent();
+ initUI();
+ }
+
+ public void initUI() {
+ this.setTitle(title);
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ this.setSize(780, 450); // ôڴС
+ this.setLayout(new BorderLayout()); // ò
+
+ initializationButton();
+
+ try {
+ JPanel topPanel = createTopPanel();
+ JPanel centerPanel = createCenterPanel();
+
+ JPanel southPanel = createSouthPanel();
+ this.add(topPanel, BorderLayout.NORTH);
+ this.add(centerPanel, BorderLayout.CENTER);
+ this.add(southPanel, BorderLayout.SOUTH);
+
+ this.setLocationRelativeTo(null);
+ this.setVisible(true);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void initializationButton() {
+ confirmButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ confirmButton.setPreferredSize(new Dimension(95, 25));
+ confirmButton.addActionListener(e -> {
+ String name = ((JTextField) jComponents[0]).getText();
+ String reason = ((JTextField) jComponents[1]).getText();
+ if (name.length() >= 40) {
+ JOptionPane.showMessageDialog(null, "The length of the name cannot exceed 40 characters", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ } else {
+ this.dispose();
+ if (name != null && name.isEmpty()) {
+ name = "MECO";
+ }
+ doTask(name, reason);
+ }
+ });
+
+ cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ cancelButton.setPreferredSize(new Dimension(95, 25));
+ cancelButton.addActionListener(e -> {
+ this.dispose();
+ });
+
+ addButton = new JButton("Add>>");
+ addButton.setPreferredSize(new Dimension(110, 25));
+ addButton.addActionListener(e -> {
+ moveRight();
+ });
+
+ removeButton = new JButton("< {
+ moveLeft();
+ });
+ }
+
+ public JPanel createTopPanel() throws Exception {
+ JPanel topPanel = new JPanel(new GridBagLayout());
+ topPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));
+ Font serif = new Font("Serif", Font.BOLD, 13);
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridy = 0;
+ gbc.insets = new Insets(5, 20, 5, 20);
+ int count = 0;
+ for (int i = 0; i < jLabels.length; i++) {
+ gbc.gridx = count++;
+ jLabels[i].setFont(serif);
+ topPanel.add(jLabels[i], gbc);
+ gbc.gridx = count++;
+ jComponents[i].setFont(serif);
+ if (targetComponent.getProperty("object_type").equals("VF5bgpsd") && i == 1) {
+ TCComponentItem tcItem = (TCComponentItem) targetComponent;
+ String reason = tcItem.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev")
+ .getProperty("vf5bgyy");
+ ((JTextField) jComponents[i]).setText(reason);
+ }
+ topPanel.add(jComponents[i], gbc);
+ }
+ return topPanel;
+ }
+
+ private JPanel createSouthPanel() {
+ JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
+ southPanel.setBorder(BorderFactory.createEmptyBorder(-10, 5, 10, 80));
+ southPanel.add(confirmButton);
+ southPanel.add(cancelButton);
+ return southPanel;
+ }
+
+ public JPanel createCenterPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout());
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ centerPanel.add(createLeftPanel(), BorderLayout.WEST);
+ centerPanel.add(createCenterButton(), BorderLayout.CENTER);
+ centerPanel.add(createRightPanel(), BorderLayout.EAST);
+ return centerPanel;
+ }
+
+ public JPanel createLeftPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout());
+ centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 5));
+
+ DefaultTableModel tableModel = new DefaultTableModel(leftData, new Object[] { "Column" }) {
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ return false;
+ }
+
+ @Override
+ public int getRowCount() {
+ return leftData.length;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 1;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ return leftData[rowIndex][1];
+ }
+
+ };
+
+ leftTable = new JTable(tableModel);
+
+ leftTable.setTableHeader(null);
+ leftTable.setShowGrid(false);
+ leftTable.setRowHeight(22);
+ leftTable.setIntercellSpacing(new Dimension(0, 0));
+
+ leftTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
+
+ centerPanel.add(new JScrollPane(leftTable), BorderLayout.CENTER);
+ return centerPanel;
+ }
+
+ public JPanel createCenterButton() {
+ JPanel jPanel = new JPanel(new GridBagLayout());
+ jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.anchor = GridBagConstraints.LINE_START;
+ gbc.insets = new Insets(-30, 5, 30, 5);// ߾
+ jPanel.add(addButton, gbc);
+ gbc.insets = new Insets(0, 5, 10, 5);// ߾
+ gbc.gridy = 1;
+ jPanel.add(removeButton, gbc);
+ return jPanel;
+ }
+
+ public JPanel createRightPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout());
+ centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 10));
+
+ rightData = new String[][] {};
+
+ DefaultTableModel tableModel = new DefaultTableModel(rightData, new Object[] { "Column" }) {
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ return false;
+ }
+
+ @Override
+ public int getRowCount() {
+ return rightData.length;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 1;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+
+ return rightData[rowIndex][1];
+ }
+
+ };
+
+ rightTable = new JTable(tableModel);
+ rightTable.setTableHeader(null);
+ rightTable.setShowGrid(false);
+ rightTable.setRowHeight(22);
+ rightTable.setIntercellSpacing(new Dimension(0, 0));
+
+ rightTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
+
+ centerPanel.add(new JScrollPane(rightTable), BorderLayout.CENTER);
+ return centerPanel;
+ }
+
+ public void moveRight() {
+ int[] selectedRows = leftTable.getSelectedRows();
+ if (selectedRows.length == 0) {
+ JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection",
+ JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+
+ String[][] newRightData = new String[rightData.length + selectedRows.length][];
+ System.arraycopy(rightData, 0, newRightData, 0, rightData.length);
+
+ for (int i = 0; i < selectedRows.length; i++) {
+ newRightData[rightData.length + i] = leftData[selectedRows[i]];
+ }
+
+ DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
+ rightTableModel.setDataVector(newRightData, new Object[] { "Column" });
+ rightData = newRightData;
+
+ String[][] newLeftData = new String[leftData.length - selectedRows.length][];
+ int newIndex = 0;
+ for (int i = 0; i < leftData.length; i++) {
+ boolean isSelected = false;
+ for (int selectedRow : selectedRows) {
+ if (i == selectedRow) {
+ isSelected = true;
+ break;
+ }
+ }
+ if (!isSelected) {
+ newLeftData[newIndex++] = leftData[i];
+ }
+ }
+
+ DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
+ leftTableModel.setDataVector(newLeftData, new Object[] { "Column" });
+ leftData = newLeftData;
+ }
+
+ public void moveLeft() {
+ int[] selectedRows = rightTable.getSelectedRows();
+ if (selectedRows.length == 0) {
+ JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection",
+ JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+
+ String[][] newLeftData = new String[leftData.length + selectedRows.length][];
+ System.arraycopy(leftData, 0, newLeftData, 0, leftData.length);
+
+ for (int i = 0; i < selectedRows.length; i++) {
+ newLeftData[leftData.length + i] = rightData[selectedRows[i]];
+ }
+
+ DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
+ leftTableModel.setDataVector(newLeftData, new Object[] { "Column" });
+ leftData = newLeftData;
+
+ String[][] newRightData = new String[rightData.length - selectedRows.length][];
+ int newIndex = 0;
+ for (int i = 0; i < rightData.length; i++) {
+ boolean isSelected = false;
+ for (int selectedRow : selectedRows) {
+ if (i == selectedRow) {
+ isSelected = true;
+ break;
+ }
+ }
+ if (!isSelected) {
+ newRightData[newIndex++] = rightData[i];
+ }
+ }
+
+ DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
+ rightTableModel.setDataVector(newRightData, new Object[] { "Column" });
+ rightData = newRightData;
+ }
+
+ public void doTask(String name, String reason) {
+ TCSession session = (TCSession) application.getSession();
+
+ int selectedRow = rightTable.getRowCount();
+ String[] uid = null;
+ if (selectedRow > 0) {
+ String[][] selectItems = new String[selectedRow][];
+ uid = new String[selectItems.length];
+ for (int i = 0; i < selectedRow; i++) {
+ String[] selectedItem = rightData[i];
+ selectItems[i] = selectedItem;
+ System.out.println("Selected Item: " + Arrays.toString(selectedItem));
+ }
+
+ for (int i = 0; i < selectItems.length; i++) {
+ uid[i] = selectItems[i][0];
+ }
+ }
+
+ TCComponentFolder xmwjj = null;
+ boolean isECR = false;
+ if (targetComponent instanceof TCComponentFolder) {
+ xmwjj = (TCComponentFolder) targetComponent;
+ } else if (targetComponent instanceof TCComponentItem) {
+ TCComponent changeFolder = ChangeNoticeFormCreateHandler.getLast((TCComponent) targetComponent, "Folder",
+ "CHANGE DATA");
+ if (changeFolder == null) {
+ System.out.println("out Folder is null");
+ }
+ xmwjj = (TCComponentFolder) TcUtil.getLastReferenced(changeFolder, "VF5xmwjj", "Folder");
+ isECR = true;
+ }
+ try {
+ if (xmwjj == null) {
+ throw new CustomException("xmwjj is null !");
+ }
+ setByFolder(xmwjj, uid, session, name, reason, isECR);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void setByFolder(TCComponentFolder xmwjj, String[] uid, TCSession session, String name, String reason,
+ boolean isECR) throws Exception {
+ TCComponent[] components = xmwjj.getRelatedComponents("contents");
+ TCComponentFolder changeFolder = null;
+ for (TCComponent tcComponent : components) {
+ if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
+ && tcComponent.getStringProperty("object_name").equals("CHANGE DATA")) {
+ changeFolder = (TCComponentFolder) tcComponent;
+ break;
+ }
+ }
+
+ TCComponentItemRevision revision = null;
+ if (changeFolder != null) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMM");
+ String localTime = formatter.format(LocalDateTime.now());
+ System.out.println("ǰʱ䣺" + localTime);
+ int maxNumber = 0;
+ InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find ItemRevision",
+ new String[] { "ID" }, new String[] { "MECO-" + localTime + "-*" });
+ if(queryList !=null) {
+ for (InterfaceAIFComponent result : queryList) {
+ String[] id = result.getProperty("item_id").split("-");
+ if (id != null && id.length == 3) {
+ int localNo = Integer.parseInt(id[id.length - 1]);
+ if (localNo > maxNumber) {
+ maxNumber = localNo;
+ }
+ }
+ }
+ }
+ String itemId = (maxNumber + 1) + "";
+ int count = 2 - itemId.length();
+ for (int i = 0; i < count; i++) {
+ itemId = "0" + itemId;
+ }
+ System.out.println("itemId : "+itemId);
+
+ TCComponentItem newItem = (TCComponentItem) TcUtil.createComponent(application,
+ new String[] { "MECO-" + localTime + "-" + itemId, "", name }, "VF5bgtzd", "Item");
+ revision = newItem.getLatestItemRevision();
+ TCComponent form = revision.getRelatedComponent("IMAN_master_form_rev");
+ form.setStringProperty("vf5bgyy", reason);
+ changeFolder.add("contents", newItem);
+
+ if (isECR) {
+ revision.add("VF5bgpsdgx", (TCComponent) targetComponent);
+ }
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+
+ } else {
+ throw new CustomException("changeFolder is null !");
+ }
+
+ if (revision != null && uid != null & uid.length > 0) {
+ TCComponent[] revList = session.stringToComponent(uid);
+ revision.add("VF5ggqdxgx", revList);
+ } else {
+ throw new CustomException("revision is null !");
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateHandler.java b/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateHandler.java
new file mode 100644
index 0000000..662a524
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateHandler.java
@@ -0,0 +1,218 @@
+package com.connor.ferrorTech.metal.changeManagement.createECO;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class ChangeNoticeFormCreateHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ TCComponent targetItem = judgeAndGetSingleSelectComponent(application);
+
+ try {
+ if (targetItem != null) {
+ JLabel[] jLabels = new JLabel[] { new JLabel("Name"), new JLabel("Reason for Change") };
+ JComponent[] jComponents = new JComponent[] { new JTextField(20), new JTextField(20) };
+
+ TCComponentFolder xmwjj = null;
+ if (targetItem instanceof TCComponentFolder) {
+ xmwjj = (TCComponentFolder) targetItem;
+ } else if (targetItem instanceof TCComponentItem) {
+ TCComponent changeFolder = ChangeNoticeFormCreateHandler.getLast(targetItem, "Folder",
+ "CHANGE DATA");
+
+ if (changeFolder == null) {
+ throw new CustomException("changeFolder is null !");
+ }
+ xmwjj = (TCComponentFolder) TcUtil.getLastReferenced(changeFolder, "VF5xmwjj", "Folder");
+ }
+
+ if (xmwjj == null) {
+ throw new CustomException("xmwjj is null !");
+ }
+ List revisionList = null;
+ revisionList = getCcpItemRevision(application, xmwjj);
+ if (revisionList == null) {
+ throw new CustomException("revisionList is null !");
+ }
+ String[][] data = getData(revisionList);
+ ChangeNoticeFormCreateDialog searchTemplate = new ChangeNoticeFormCreateDialog(application,
+ "Create ECO", jLabels, jComponents, data);
+ new Thread(searchTemplate).start();
+
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
+ }
+ return null;
+ }
+
+ public static TCComponent getLast(TCComponent targetComponent, String type, String name) {
+ if (targetComponent != null) {
+ try {
+ AIFComponentContext[] parent = targetComponent.whereReferenced();
+ for (int i = 0; i < parent.length; i++) {
+ InterfaceAIFComponent component = (TCComponent) parent[i].getComponent();
+ if (component.getType().equals(type) && component.getProperty("object_name").equals(name)) {
+ return (TCComponent) parent[i].getComponent();
+ }
+ }
+ System.out.println("Type is not exist !\n" + type);
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ } else {
+ System.out.println("TargetComponent Is Null !");
+ }
+ return null;
+ }
+
+ public static TCComponent judgeAndGetSingleSelectComponent(AbstractAIFApplication application) {
+ InterfaceAIFComponent targetComponent = application.getTargetComponent();
+ try {
+ if (targetComponent instanceof TCComponentItem
+ && ((TCComponentItem)targetComponent).getStringProperty("object_type").equals("VF5bgpsd")) {
+ return (TCComponent) targetComponent;
+ } else if (targetComponent instanceof TCComponentFolder
+ && ((TCComponentFolder)targetComponent).getStringProperty("object_type").equals("VF5xmwjj")) {
+ return (TCComponent) targetComponent;
+ }
+ MessageBox.post("The Following Is Not A Specify Type !\n" + targetComponent.getUid(), "Error",
+ MessageBox.ERROR);
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private String[][] getData(List revisionList) throws TCException {
+ // TODO Auto-generated method stub
+ String[][] data = new String[revisionList.size()][];
+ if (revisionList != null && revisionList.size() > 0) {
+ int count = 0;
+ String name = "";
+ for (TCComponentItemRevision itemRevison : revisionList) {
+ String type = itemRevison.getStringProperty("object_type");
+ String[] rowData = new String[2];
+ String uid = itemRevison.getUid();
+ if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
+ String wlbm = itemRevison.getRelatedComponent("IMAN_master_form_rev").getStringProperty("vf5wlbm");
+ name = wlbm + "-" + itemRevison.getStringProperty("object_name") + ";"
+ + itemRevison.getStringProperty("item_revision_id");
+ } else if (type.equals("VF5gyRevision")) {
+ name = itemRevison.getStringProperty("item_id") + "-" + itemRevison.getStringProperty("object_name")
+ + ";" + itemRevison.getStringProperty("item_revision_id");
+ }
+ rowData[0] = uid;
+ rowData[1] = name;
+ data[count++] = rowData;
+ }
+ return data;
+ } else {
+ return new String[][] {};
+ }
+ }
+
+ public List getCcpItemRevision(AbstractAIFApplication application, TCComponentFolder xmwjj)
+ throws TCException {
+ // TODO Auto-generated method stub
+ TCSession session = (TCSession) application.getSession();
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
+ // ͼ
+ TCComponentBOMWindow view = winType.create(null);
+ // BOM args:item 汾 ...
+
+ List revList = new ArrayList<>();
+
+ TCComponent[] components = xmwjj.getRelatedComponents("contents");
+ TCComponentFolder materialFolder = null;
+ TCComponentFolder porFolder = null;
+ for (TCComponent tcComponent : components) {
+ if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
+ && tcComponent.getStringProperty("object_name").equals("MATERIAL AND BOM")) {
+ materialFolder = (TCComponentFolder) tcComponent;
+ } else if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
+ && tcComponent.getStringProperty("object_name").equals("POR")) {
+ porFolder = (TCComponentFolder) tcComponent;
+ }
+ }
+
+ if (materialFolder != null) {
+ TCComponent[] materialChildren = materialFolder.getRelatedComponents("contents");
+ for (TCComponent tcItem : materialChildren) {
+ if (tcItem.getStringProperty("object_type").equals("VF5ccp")) {
+ TCComponentItem ccpItem = (TCComponentItem) tcItem;
+ TCComponentItemRevision ccpItemRev = ccpItem.getLatestItemRevision();
+
+ revList.add(ccpItemRev);
+ getBcpRevision(revList, view, ccpItem, ccpItemRev);
+ }
+ }
+ } else {
+ throw new CustomException("materialFolder is null ! ");
+ }
+
+ if (porFolder != null) {
+ TCComponent[] porChildren = porFolder.getRelatedComponents("contents");
+ for (TCComponent tcItem : porChildren) {
+ if (tcItem.getStringProperty("object_type").equals("VF5gy")) {
+ TCComponentItem gyItem = (TCComponentItem) tcItem;
+ TCComponentItemRevision gyItemRev = gyItem.getLatestItemRevision();
+ revList.add(gyItemRev);
+ }
+ }
+ } else {
+ throw new CustomException("porFolder is null ! ");
+ }
+ return revList;
+ }
+
+ public void getBcpRevision(List revList, TCComponentBOMWindow view,
+ TCComponentItem ccpItem, TCComponentItemRevision ccpItemRev) throws TCException {
+ TCComponentBOMLine bomLine = view.setWindowTopLine(ccpItem, ccpItemRev, null, null);
+
+ boolean hasChildren = bomLine.hasChildren();
+ if (hasChildren) {
+ AIFComponentContext[] childrena = bomLine.getChildren();
+ for (AIFComponentContext children : childrena) {
+ // ǿתΪTCComponentBOMLine
+ TCComponentItemRevision bcpItemRev = ((TCComponentBOMLine) children.getComponent()).getItemRevision();
+ if (bcpItemRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
+ revList.add(bcpItemRev);
+ }
+ }
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateDialog.java b/src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateDialog.java
new file mode 100644
index 0000000..6d49f25
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateDialog.java
@@ -0,0 +1,406 @@
+package com.connor.ferrorTech.metal.changeManagement.createECR;
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableModel;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+import java.awt.*;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+
+public class ChangeApplyFormCreateDialog extends JFrame implements Runnable {
+
+ private final String title;
+ private AbstractAIFApplication application;
+
+ private final JLabel[] jLabels;
+ private final JComponent[] jComponents;
+ private JButton confirmButton;
+ private JButton cancelButton;
+ private JButton addButton;
+ private JButton removeButton;
+
+ private JTable leftTable;
+ private JTable rightTable;
+ private String[][] leftData;
+ private String[][] rightData;
+
+ public ChangeApplyFormCreateDialog(AbstractAIFApplication application,String title, Object... args) {
+ int count = 0;
+ this.title = title;
+ this.application =application;
+ jLabels = (JLabel[]) args[count++];
+ jComponents = (JComponent[]) args[count++];
+ leftData = (String[][]) args[count];
+ }
+
+ @Override
+ public void run() {
+ initUI();
+ }
+
+ public void initUI() {
+ this.setTitle(title);
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ this.setSize(780, 450); // ôڴС
+ this.setLayout(new BorderLayout()); // ò
+
+ initializationButton();
+
+ JPanel topPanel = createTopPanel();
+
+ JPanel centerPanel = createCenterPanel();
+
+ JPanel southPanel = createSouthPanel();
+ this.add(topPanel, BorderLayout.NORTH);
+ this.add(centerPanel, BorderLayout.CENTER);
+ this.add(southPanel, BorderLayout.SOUTH);
+
+ this.setLocationRelativeTo(null);
+ this.setVisible(true);
+ }
+
+ public void initializationButton() {
+ confirmButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ confirmButton.setPreferredSize(new Dimension(95, 25));
+ confirmButton.addActionListener(e -> {
+ String name = ((JTextField) jComponents[0]).getText();
+ String reason = ((JTextField) jComponents[1]).getText();
+ if(name.length()>=40){
+ JOptionPane.showMessageDialog(null, "The length of the name cannot exceed 40 characters", "Error", JOptionPane.ERROR_MESSAGE);
+ }else{
+ this.dispose();
+ try {
+ if(name !=null && name.isEmpty()) {
+ name = "MECR";
+ }
+ doTask(name,reason);
+ } catch (TCException e1) {
+ // TODO Auto-generated catch block
+ MessageBox.post(e1.getMessage(), "Error", MessageBox.ERROR);
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ });
+
+ cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ cancelButton.setPreferredSize(new Dimension(95, 25));
+ cancelButton.addActionListener(e -> {
+ this.dispose();
+ });
+
+ addButton = new JButton("Add>>");
+ addButton.setPreferredSize(new Dimension(110, 25));
+ addButton.addActionListener(e -> {
+ moveRight();
+ });
+
+ removeButton = new JButton("< {
+ moveLeft();
+ });
+ }
+
+ public JPanel createTopPanel() {
+ JPanel topPanel = new JPanel(new GridBagLayout());
+ topPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));
+ Font serif = new Font("Serif", Font.BOLD, 13);
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridy = 0;
+ gbc.insets = new Insets(5, 20, 5, 20);
+ int count = 0;
+ for (int i = 0; i < jLabels.length; i++) {
+ gbc.gridx = count++;
+ jLabels[i].setFont(serif);
+ topPanel.add(jLabels[i], gbc);
+ gbc.gridx = count++;
+ jComponents[i].setFont(serif);
+ topPanel.add(jComponents[i], gbc);
+ }
+ return topPanel;
+ }
+
+ private JPanel createSouthPanel() {
+ JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
+ southPanel.setBorder(BorderFactory.createEmptyBorder(-10, 5, 10, 80));
+ southPanel.add(confirmButton);
+ southPanel.add(cancelButton);
+ return southPanel;
+ }
+
+ public JPanel createCenterPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout());
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ centerPanel.add(createLeftPanel(), BorderLayout.WEST);
+ centerPanel.add(createCenterButton(), BorderLayout.CENTER);
+ centerPanel.add(createRightPanel(), BorderLayout.EAST);
+ return centerPanel;
+ }
+
+ public JPanel createLeftPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout());
+ centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 5));
+
+ DefaultTableModel tableModel = new DefaultTableModel(leftData, new Object[]{"Column"}) {
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ return false;
+ }
+
+ @Override
+ public int getRowCount() {
+ return leftData.length;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 1;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ return leftData[rowIndex][1];
+ }
+
+ };
+
+ leftTable = new JTable(tableModel);
+
+ leftTable.setTableHeader(null);
+ leftTable.setShowGrid(false);
+ leftTable.setRowHeight(22);
+ leftTable.setIntercellSpacing(new Dimension(0, 0));
+
+ leftTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
+
+ centerPanel.add(new JScrollPane(leftTable), BorderLayout.CENTER);
+ return centerPanel;
+ }
+
+ public JPanel createCenterButton() {
+ JPanel jPanel = new JPanel(new GridBagLayout());
+ jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.anchor = GridBagConstraints.LINE_START;
+ gbc.insets = new Insets(-30, 5, 30, 5);// ߾
+ jPanel.add(addButton, gbc);
+ gbc.insets = new Insets(0, 5, 10, 5);// ߾
+ gbc.gridy = 1;
+ jPanel.add(removeButton, gbc);
+ return jPanel;
+ }
+
+ public JPanel createRightPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout());
+ centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 10));
+
+ rightData = new String[][]{};
+
+ DefaultTableModel tableModel = new DefaultTableModel(rightData, new Object[]{"Column"}) {
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ return false;
+ }
+
+ @Override
+ public int getRowCount() {
+ return rightData.length;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 1;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+
+ return rightData[rowIndex][1];
+ }
+
+ };
+
+ rightTable = new JTable(tableModel);
+ rightTable.setTableHeader(null);
+ rightTable.setShowGrid(false);
+ rightTable.setRowHeight(22);
+ rightTable.setIntercellSpacing(new Dimension(0, 0));
+
+ rightTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
+
+ centerPanel.add(new JScrollPane(rightTable), BorderLayout.CENTER);
+ return centerPanel;
+ }
+
+ public void moveRight() {
+ int[] selectedRows = leftTable.getSelectedRows();
+ if (selectedRows.length == 0) {
+ JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection", JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+
+ String[][] newRightData = new String[rightData.length + selectedRows.length][];
+ System.arraycopy(rightData, 0, newRightData, 0, rightData.length);
+
+ for (int i = 0; i < selectedRows.length; i++) {
+ newRightData[rightData.length + i] = leftData[selectedRows[i]];
+ }
+
+ DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
+ rightTableModel.setDataVector(newRightData, new Object[]{"Column"});
+ rightData = newRightData;
+
+ String[][] newLeftData = new String[leftData.length - selectedRows.length][];
+ int newIndex = 0;
+ for (int i = 0; i < leftData.length; i++) {
+ boolean isSelected = false;
+ for (int selectedRow : selectedRows) {
+ if (i == selectedRow) {
+ isSelected = true;
+ break;
+ }
+ }
+ if (!isSelected) {
+ newLeftData[newIndex++] = leftData[i];
+ }
+ }
+
+ DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
+ leftTableModel.setDataVector(newLeftData, new Object[]{"Column"});
+ leftData = newLeftData;
+ }
+
+ public void moveLeft() {
+ int[] selectedRows = rightTable.getSelectedRows();
+ if (selectedRows.length == 0) {
+ JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection", JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+
+ String[][] newLeftData = new String[leftData.length + selectedRows.length][];
+ System.arraycopy(leftData, 0, newLeftData, 0, leftData.length);
+
+ for (int i = 0; i < selectedRows.length; i++) {
+ newLeftData[leftData.length + i] = rightData[selectedRows[i]];
+ }
+
+ DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
+ leftTableModel.setDataVector(newLeftData, new Object[]{"Column"});
+ leftData = newLeftData;
+
+ String[][] newRightData = new String[rightData.length - selectedRows.length][];
+ int newIndex = 0;
+ for (int i = 0; i < rightData.length; i++) {
+ boolean isSelected = false;
+ for (int selectedRow : selectedRows) {
+ if (i == selectedRow) {
+ isSelected = true;
+ break;
+ }
+ }
+ if (!isSelected) {
+ newRightData[newIndex++] = rightData[i];
+ }
+ }
+
+ DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
+ rightTableModel.setDataVector(newRightData, new Object[]{"Column"});
+ rightData = newRightData;
+ }
+
+
+ public void doTask(String name,String reason) throws Exception {
+ TCSession session = (TCSession) application.getSession();
+
+ int selectedRow = rightTable.getRowCount();
+ String[] uid = null;
+ if (selectedRow > 0) {
+ String[][] selectItems = new String[selectedRow][];
+ uid = new String[selectItems.length];
+ for (int i = 0; i < selectedRow; i++) {
+ String[] selectedItem = rightData[i];
+ selectItems[i] = selectedItem;
+ System.out.println("Selected Item: " + Arrays.toString(selectedItem));
+ }
+ for (int i = 0; i < selectItems.length; i++) {
+ uid[i] = selectItems[i][0];
+ }
+ }
+
+ TCComponentFolder xmwjj = (TCComponentFolder) TcUtil.judgeAndGetSingleSelectComponent(application,
+ new String[] { "VF5xmwjj" }, "Folder");
+
+ TCComponent[] components = xmwjj.getRelatedComponents("contents");
+ TCComponentFolder changeFolder = null;
+ for (TCComponent tcComponent : components) {
+ if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
+ && tcComponent.getStringProperty("object_name").equals("CHANGE DATA")) {
+ changeFolder = (TCComponentFolder) tcComponent;
+ break;
+ }
+ }
+
+ TCComponentItemRevision revision = null;
+ if(changeFolder!=null) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMM");
+ String localTime = formatter.format(LocalDateTime.now());
+ System.out.println("ǰʱ䣺" + localTime);
+ int maxNumber = 0;
+ InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find ItemRevision", new String[] {"ID"}, new String[] {"MECR-"+localTime+"-*"});
+ for (InterfaceAIFComponent result : queryList) {
+ String[] id = result.getProperty("item_id").split("-");
+ if(id !=null && id.length==3){
+ int localNo = Integer.parseInt(id[id.length-1]);
+ if(localNo>maxNumber) {
+ maxNumber = localNo;
+ }
+ }
+ }
+ String itemId = (maxNumber+1) + "";
+ int count = 2 - itemId.length();
+ for (int i = 0; i < count; i++) {
+ itemId = "0"+itemId;
+ }
+
+ TCComponentItem newItem = (TCComponentItem)TcUtil.createComponent(application
+ , new String[] {"MECR-"+localTime+"-"+itemId,"",name}, "VF5bgpsd", "Item");
+ revision = newItem.getLatestItemRevision();
+ TCComponent form = revision.getRelatedComponent("IMAN_master_form_rev");
+ form.setStringProperty("vf5bgyy", reason);
+ changeFolder.add("contents", newItem);
+
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+ }else {
+ throw new CustomException("changeFolder is null !");
+ }
+
+ if(revision!=null && uid!=null & uid.length>0) {
+ TCComponent[] revList = session.stringToComponent(uid);
+ revision.add("VF5ggqdxgx", revList);
+ }else {
+ throw new CustomException("revision is null !");
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateHandler.java b/src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateHandler.java
new file mode 100644
index 0000000..d8355ab
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateHandler.java
@@ -0,0 +1,156 @@
+package com.connor.ferrorTech.metal.changeManagement.createECR;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class ChangeApplyFormCreateHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ TCComponentFolder xmwjj = (TCComponentFolder) TcUtil.judgeAndGetSingleSelectComponent(application,
+ new String[] { "VF5xmwjj" }, "Folder");
+
+ try {
+ if (xmwjj != null) {
+ JLabel[] jLabels = new JLabel[] { new JLabel("Name"), new JLabel("Reason for Change") };
+ JComponent[] jComponents = new JComponent[] { new JTextField(20), new JTextField(20) };
+
+ List revisionList = getCcpItemRevision(application, xmwjj);
+
+ String[][] data = getData(revisionList);
+
+ ChangeApplyFormCreateDialog searchTemplate = new ChangeApplyFormCreateDialog(application,"Create ECR", jLabels,
+ jComponents,data);
+ new Thread(searchTemplate).start();
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
+ }
+ return null;
+ }
+
+ private String[][] getData(List revisionList) throws TCException {
+ // TODO Auto-generated method stub
+ String[][] data = new String[revisionList.size()][];
+ if(revisionList!=null && revisionList.size()>0) {
+ int count = 0 ;
+ String name = "";
+ for (TCComponentItemRevision itemRevison : revisionList) {
+ String type = itemRevison.getStringProperty("object_type");
+ String[] rowData = new String[2];
+ String uid = itemRevison.getUid();
+ if(type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
+ String wlbm = itemRevison.getRelatedComponent("IMAN_master_form_rev").getStringProperty("vf5wlbm");
+ name = wlbm +"-"+itemRevison.getStringProperty("object_name")+";"+itemRevison.getStringProperty("item_revision_id");
+ }else if(type.equals("VF5gyRevision")) {
+ name = itemRevison.getStringProperty("item_id") +"-"+itemRevison.getStringProperty("object_name")+";"+itemRevison.getStringProperty("item_revision_id");
+ }
+ rowData[0] = uid;
+ rowData[1] = name;
+ data[count++] = rowData;
+ }
+ return data;
+ }else {
+ return new String[][] {};
+ }
+ }
+
+ public List getCcpItemRevision(AbstractAIFApplication application, TCComponentFolder xmwjj) throws TCException {
+ // TODO Auto-generated method stub
+ TCSession session = (TCSession) application.getSession();
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
+ // ͼ
+ TCComponentBOMWindow view = winType.create(null);
+ // BOM args:item 汾 ...
+
+ List revList = new ArrayList<>();
+
+ TCComponent[] components = xmwjj.getRelatedComponents("contents");
+ TCComponentFolder materialFolder = null;
+ TCComponentFolder porFolder = null;
+ for (TCComponent tcComponent : components) {
+ if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
+ && tcComponent.getStringProperty("object_name").equals("MATERIAL AND BOM")) {
+ materialFolder = (TCComponentFolder) tcComponent;
+ } else if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
+ && tcComponent.getStringProperty("object_name").equals("POR")) {
+ porFolder = (TCComponentFolder) tcComponent;
+ }
+ }
+
+ if (materialFolder != null) {
+ TCComponent[] materialChildren = materialFolder.getRelatedComponents("contents");
+ for (TCComponent tcItem : materialChildren) {
+ if (tcItem.getStringProperty("object_type").equals("VF5ccp")) {
+ TCComponentItem ccpItem = (TCComponentItem) tcItem;
+ TCComponentItemRevision ccpItemRev = ccpItem.getLatestItemRevision();
+
+ revList.add(ccpItemRev);
+ getBcpRevision(revList, view, ccpItem, ccpItemRev);
+ }
+ }
+ } else {
+ throw new CustomException("materialFolder is null ! ");
+ }
+
+ if (porFolder != null) {
+ TCComponent[] porChildren = porFolder.getRelatedComponents("contents");
+ for (TCComponent tcItem : porChildren) {
+ if (tcItem.getStringProperty("object_type").equals("VF5gy")) {
+ TCComponentItem gyItem = (TCComponentItem) tcItem;
+ TCComponentItemRevision gyItemRev = gyItem.getLatestItemRevision();
+ revList.add(gyItemRev);
+ }
+ }
+ } else {
+ throw new CustomException("porFolder is null ! ");
+ }
+ return revList;
+ }
+
+ public void getBcpRevision(List revList, TCComponentBOMWindow view,
+ TCComponentItem ccpItem, TCComponentItemRevision ccpItemRev) throws TCException {
+ TCComponentBOMLine bomLine = view.setWindowTopLine(ccpItem, ccpItemRev, null, null);
+
+ boolean hasChildren = bomLine.hasChildren();
+ if (hasChildren) {
+ AIFComponentContext[] childrena = bomLine.getChildren();
+ for (AIFComponentContext children : childrena) {
+ // ǿתΪTCComponentBOMLine
+ TCComponentItemRevision bcpItemRev = ((TCComponentBOMLine) children.getComponent()).getItemRevision();
+ if (bcpItemRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
+ revList.add(bcpItemRev);
+ }
+ }
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/changeManagement/createECR/CustomTableCellRenderer.java b/src/com/connor/ferrorTech/metal/changeManagement/createECR/CustomTableCellRenderer.java
new file mode 100644
index 0000000..6db4b3d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/changeManagement/createECR/CustomTableCellRenderer.java
@@ -0,0 +1,24 @@
+package com.connor.ferrorTech.metal.changeManagement.createECR;
+
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.LineBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.*;
+
+public class CustomTableCellRenderer extends DefaultTableCellRenderer {
+ private final Border noFocusBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
+ private final Border focusBorder = new LineBorder(Color.YELLOW, 1);
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ JComponent c = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if (isSelected) {
+ c.setBorder(focusBorder);
+ } else {
+ c.setBorder(noFocusBorder);
+ }
+ return c;
+ }
+}
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/constant/ConstantPool.java b/src/com/connor/ferrorTech/metal/constant/ConstantPool.java
new file mode 100644
index 0000000..d80726f
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/constant/ConstantPool.java
@@ -0,0 +1,68 @@
+package com.connor.ferrorTech.metal.constant;
+
+public class ConstantPool {
+
+ public static final String EN_LABEL_UPLOAD_PATH = "Local path";
+
+ public static final String EN_TITLE_UPLOAD_PATH = "Please select the upload path";
+ public static final String EN_TITLE_IMPORT_PATH = "Please select the import path";
+ public static final String EN_TITLE_EXPORT_PATH = "Please select the export path";
+ public static final String EN_TITLE_DOWNLOAD_PATH = "Please select the download path";
+
+ public static final String EN_BUTTON_CONFIRM = "Confirm";
+ public static final String EN_BUTTON_CANCEL = "Cancel";
+ public static final String EN_BUTTON_SEARCH = "Search";
+ public static final String EN_BUTTON_SELECT = "Select";
+ public static final String EN_BUTTON_IMPORT = "Local Import";//ص
+ public static final String EN_BUTTON_EXPORT = "Local Export";
+ public static final String EN_BUTTON_CHOOSE = "CHOOSE";
+ public static final String EN_BUTTON_ADD = "Add Rows";
+ public static final String EN_BUTTON_DELETE = "Delete Row";
+ public static final String EN_BUTTON_MOVE_UP = "Move Up";
+ public static final String EN_BUTTON_MOVE_DOWN = "Move Down";
+
+ public static final String EN_MESSAGE_UPLOAD_ERROR = "Please enter or select the file path";
+ public static final String EN_MESSAGE_FILE_ERROR = "Invalid file path, not a directory !";
+ public static final String EN_MESSAGE_EXCEL_ERROR = "Invalid file path, not a directory !";
+ public static final String EN_MESSAGE_MOVE_UP = "Cannot move up, it is already the first line";
+ public static final String EN_MESSAGE_MOVE_DOWN = "Cannot move down, it is already the last line";
+ public static final String EN_MESSAGE_IMPORT = "Please enter or select the file path";
+ public static final String EN_MESSAGE_DELETE = "Please select the row to delete";
+ public static final String EN_MESSAGE_REV_ERROR = "Please select a Revision Item";
+ public static final String EN_MESSAGE_REV_TYPE_ERROR = "Please select the correct version";
+ public static final String EN_MESSAGE_Folder_ERROR = "Please select a file";
+ public static final String EN_MESSAGE_Folder_TYPE_ERROR = "Please select the correct file type";
+
+
+
+ public static final String CH_LABEL_UPLOAD_PATH = "ϴ·";
+
+ public static final String CH_TITLE_UPLOAD_PATH = "ѡϴ·";
+ public static final String CH_TITLE_IMPORT_PATH = "ѡ·";
+ public static final String CH_TITLE_EXPORT_PATH = "ѡ·";
+ public static final String CH_TITLE_DOWNLOAD_PATH = "ѡ·";
+
+ public static final String CH_BUTTON_CONFIRM = "ȷ";
+ public static final String CH_BUTTON_CANCEL = "ȡ";
+ public static final String CH_BUTTON_SEARCH = "";
+ public static final String CH_BUTTON_SELECT = "ѡ";
+ public static final String CH_BUTTON_IMPORT = "ص";
+ public static final String CH_BUTTON_EXPORT = "ص";
+ public static final String CH_BUTTON_CHOOSE = "ѡ";
+ public static final String CH_BUTTON_ADD = "";
+ public static final String CH_BUTTON_DELETE = "ɾ";
+ public static final String CH_BUTTON_MOVE_UP = "";
+ public static final String CH_BUTTON_MOVE_DOWN = "";
+
+ public static final String CH_MESSAGE_UPLOAD_ERROR = "ѡļϴ·";
+ public static final String CH_MESSAGE_FILE_ERROR = "ļ·ѡһĿ¼";
+ public static final String CH_MESSAGE_EXCEL_ERROR = "ļ·ЧĿ¼";
+ public static final String CH_MESSAGE_MOVE_UP = "ƶѾǵһ";
+ public static final String CH_MESSAGE_MOVE_DOWN = "ƶѾһ";
+ public static final String CH_MESSAGE_IMPORT = "ѡļ·";
+ public static final String CH_MESSAGE_DELETE = "ѡҪɾ";
+ public static final String CH_MESSAGE_REV_ERROR = "ѡ汾";
+ public static final String CH_MESSAGE_REV_TYPE_ERROR = "ѡȷİ汾";
+ public static final String CH_MESSAGE_Folder_ERROR = "ѡļ";
+ public static final String CH_MESSAGE_Folder_TYPE_ERROR = "ѡȷļ";
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/AinternalDrawing/CreateInternalDrawingHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/AinternalDrawing/CreateInternalDrawingHandler.java
new file mode 100644
index 0000000..4debc5d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/AinternalDrawing/CreateInternalDrawingHandler.java
@@ -0,0 +1,19 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.AinternalDrawing;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+
+public class CreateInternalDrawingHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0){
+ AbstractAIFApplication application =AIFUtility.getCurrentApplication();
+ CommonAction commonAction = new CommonAction(application,"VF5idgx","VF5nbtz","Internal Drawing","-ID");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/BprocessControl/CreateProcessControlHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/BprocessControl/CreateProcessControlHandler.java
new file mode 100644
index 0000000..2506bc8
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/BprocessControl/CreateProcessControlHandler.java
@@ -0,0 +1,18 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.BprocessControl;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateProcessControlHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CommonAction commonAction = new CommonAction(application, "VF5pcgx", "VF5procctrl","Process Control","-PC");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/CommonAction.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/CommonAction.java
new file mode 100644
index 0000000..cae7fd5
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/CommonAction.java
@@ -0,0 +1,194 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CommonAction implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private TCComponentItemRevision[] tarRevs;
+
+ private String revReference;
+ private String itemType;
+ private String itemName;
+ private String ruleName;
+
+ public CommonAction(AbstractAIFApplication application, String revReference, String type, String name,
+ String ruleName) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.revReference = revReference;
+ this.itemType = type;
+ this.ruleName = ruleName;
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void run() {
+ boolean revFlag = false;
+ try {
+ revFlag = isCcpRevision();
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (!revFlag) {
+ MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
+ } else if (tarRevs == null && tarRevs.length == 0) {
+ MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
+ } else {
+ Map nullMap = isExistNull();
+ if (nullMap.isEmpty()) {
+ System.out.println("enter createNbtzItem()");
+ createNbtzItem();
+ } else {
+ StringBuffer str = new StringBuffer("");
+ Set keySet = nullMap.keySet();
+ for (String key : keySet) {
+ int count = 0;
+ if (count == 0) {
+ str.append("\n" + key + " | " + nullMap.get(key));
+ } else if (count == keySet.size() - 1) {
+ str.append(key + " | " + nullMap.get(key) + "\n");
+ } else {
+ str.append(key + " | " + nullMap.get(key));
+ }
+ }
+ MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
+ }
+ }
+ }
+
+ public boolean isCcpRevision() throws TCException {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
+ System.out.println("length: " + targetComponents.length);
+ List tempComponents = new ArrayList<>();
+ for (InterfaceAIFComponent targetComponent : targetComponents) {
+ System.out.println("enter judge");
+ if (targetComponent instanceof TCComponentItemRevision) {
+ TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
+ if (!tempComponentRev.getStringProperty("object_type").equals("VF5ccpRevision")) {
+ System.out.println("false");
+ return false;
+ } else {
+ System.out.println("true");
+ tempComponents.add(tempComponentRev);
+ }
+ } else if (targetComponent instanceof TCComponentBOMLine) {
+ try {
+ TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ if (!tempComponentRev.getStringProperty("object_type").equals("VF5ccpRevision")) {
+ return false;
+ } else {
+ tempComponents.add(tempComponentRev);
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ System.out.println("tempComponents.size: " + tempComponents.size());
+ tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
+ return true;
+ }
+
+ public Map isExistNull() {
+ Map errorMap = new HashMap<>();
+ for (InterfaceAIFComponent targetComponent : tarRevs) {
+ TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
+ try {
+ TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ String property = referenceValueArray[0].getStringProperty("vf5wlbm");
+ if (property.isEmpty()) {
+ errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("isExistNull is error !");
+ e.printStackTrace();
+ }
+ }
+ return errorMap;
+ }
+
+ public void createNbtzItem() {
+ try {
+ System.out.println("tarRevs: "+tarRevs.length);
+ if (tarRevs != null && tarRevs.length > 0) {
+ boolean flag = true;
+ for (TCComponentItemRevision targetRev : tarRevs) {
+ if (judgeIsExist(targetRev)) {
+ TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ String property = targetRevForm[0].getStringProperty("vf5khth");
+ String pn = targetRevForm[0].getStringProperty("vf5wlbm");
+
+ TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
+ TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
+ if (tzItem != null) {
+ TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
+ TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ newTcItemRevForm[0].setStringProperty("vf5khth", property);
+ newTcItemRevForm[0].setStringProperty("vf5pn", pn);
+
+ targetRev.add(revReference, tzItem);
+ } else {
+ flag = false;
+ }
+ }
+
+ }
+ if(flag) {
+ MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
+ }else {
+ MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
+ }
+ } else {
+ MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ }
+
+ public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
+ if(targetRev!=null) {
+ TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
+ System.out.println("item: " + targetRev.getStringProperty("object_name"));
+ if (tzReferences != null && tzReferences.length > 0) {
+ for (int i = 0; i < tzReferences.length; i++) {
+ if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
+ System.out.println("it's exist!");
+ return false;
+ }
+ }
+ }
+ }else {
+ throw new CustomException("targetRev is null");
+ }
+ return true;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/CredlineDrawing/CreateRedlineDrawingHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/CredlineDrawing/CreateRedlineDrawingHandler.java
new file mode 100644
index 0000000..6cd1f5d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/CredlineDrawing/CreateRedlineDrawingHandler.java
@@ -0,0 +1,20 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.CredlineDrawing;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateRedlineDrawingHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CommonAction commonAction = new CommonAction(application, "VF5rdgx", "VF5jctz","Redline Drawing","-RD");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingAction.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingAction.java
new file mode 100644
index 0000000..860dde1
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingAction.java
@@ -0,0 +1,194 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateRawMaterialDrawingAction implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private TCComponentItemRevision[] tarRevs;
+
+ private String revReference;
+ private String itemType;
+ private String itemName;
+ private String ruleName;
+
+ public CreateRawMaterialDrawingAction(AbstractAIFApplication application, String revReference, String type, String name,
+ String ruleName) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.revReference = revReference;
+ this.itemType = type;
+ this.ruleName = ruleName;
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void run() {
+ boolean revFlag = false;
+ try {
+ revFlag = isCcpRevision();
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (!revFlag) {
+ MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
+ } else if (tarRevs == null && tarRevs.length == 0) {
+ MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
+ } else {
+ Map nullMap = isExistNull();
+ if (nullMap.isEmpty()) {
+ System.out.println("enter createNbtzItem()");
+ createNbtzItem();
+ } else {
+ StringBuffer str = new StringBuffer("");
+ Set keySet = nullMap.keySet();
+ for (String key : keySet) {
+ int count = 0;
+ if (count == 0) {
+ str.append("\n" + key + " | " + nullMap.get(key));
+ } else if (count == keySet.size() - 1) {
+ str.append(key + " | " + nullMap.get(key) + "\n");
+ } else {
+ str.append(key + " | " + nullMap.get(key));
+ }
+ }
+ MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
+ }
+ }
+ }
+
+ public boolean isCcpRevision() throws TCException {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
+ System.out.println("length: " + targetComponents.length);
+ List tempComponents = new ArrayList<>();
+ for (InterfaceAIFComponent targetComponent : targetComponents) {
+ System.out.println("enter judge");
+ if (targetComponent instanceof TCComponentItemRevision) {
+ TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
+ if (!tempComponentRev.getStringProperty("object_type").equals("VF5clRevision")) {
+ System.out.println("false");
+ return false;
+ } else {
+ System.out.println("true");
+ tempComponents.add(tempComponentRev);
+ }
+ } else if (targetComponent instanceof TCComponentBOMLine) {
+ try {
+ TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ if (!tempComponentRev.getStringProperty("object_type").equals("VF5clRevision")) {
+ return false;
+ } else {
+ tempComponents.add(tempComponentRev);
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ System.out.println("tempComponents.size: " + tempComponents.size());
+ tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
+ return true;
+ }
+
+ public Map isExistNull() {
+ Map errorMap = new HashMap<>();
+ for (InterfaceAIFComponent targetComponent : tarRevs) {
+ TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
+ try {
+ TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ String property = referenceValueArray[0].getStringProperty("vf5wlbm");
+ if (property.isEmpty()) {
+ errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("isExistNull is error !");
+ e.printStackTrace();
+ }
+ }
+ return errorMap;
+ }
+
+ public void createNbtzItem() {
+ try {
+ System.out.println("tarRevs: "+tarRevs.length);
+ if (tarRevs != null && tarRevs.length > 0) {
+ boolean flag = true;
+ for (TCComponentItemRevision targetRev : tarRevs) {
+ if (judgeIsExist(targetRev)) {
+ TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ String property = targetRevForm[0].getStringProperty("vf5khth");
+ String pn = targetRevForm[0].getStringProperty("vf5wlbm");
+
+ TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
+ TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
+ if (tzItem != null) {
+ TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
+ TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ newTcItemRevForm[0].setStringProperty("vf5khth", property);
+ newTcItemRevForm[0].setStringProperty("vf5pn", pn);
+
+ targetRev.add(revReference, tzItem);
+ } else {
+ flag = false;
+ }
+ }
+
+ }
+ if(flag) {
+ MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
+ }else {
+ MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
+ }
+ } else {
+ MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ }
+
+ public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
+ if(targetRev!=null) {
+ TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
+ System.out.println("item: " + targetRev.getStringProperty("object_name"));
+ if (tzReferences != null && tzReferences.length > 0) {
+ for (int i = 0; i < tzReferences.length; i++) {
+ if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
+ System.out.println("it's exist!");
+ return false;
+ }
+ }
+ }
+ }else {
+ throw new CustomException("targetRev is null");
+ }
+ return true;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingHandler.java
new file mode 100644
index 0000000..d487df0
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingHandler.java
@@ -0,0 +1,21 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateRawMaterialDrawingHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateRawMaterialDrawingAction commonAction = new CreateRawMaterialDrawingAction(application, "VF5rmgx", "VF5ycltz","Raw Material Drawing","-RM");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingAction.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingAction.java
new file mode 100644
index 0000000..8611205
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingAction.java
@@ -0,0 +1,194 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateSubPartsDrawingAction implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private TCComponentItemRevision[] tarRevs;
+
+ private String revReference;
+ private String itemType;
+ private String itemName;
+ private String ruleName;
+
+ public CreateSubPartsDrawingAction(AbstractAIFApplication application, String revReference, String type, String name,
+ String ruleName) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.revReference = revReference;
+ this.itemType = type;
+ this.ruleName = ruleName;
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void run() {
+ boolean revFlag = false;
+ try {
+ revFlag = isCcpRevision();
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (!revFlag) {
+ MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
+ } else if (tarRevs == null && tarRevs.length == 0) {
+ MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
+ } else {
+ Map nullMap = isExistNull();
+ if (nullMap.isEmpty()) {
+ System.out.println("enter createNbtzItem()");
+ createNbtzItem();
+ } else {
+ StringBuffer str = new StringBuffer("");
+ Set keySet = nullMap.keySet();
+ for (String key : keySet) {
+ int count = 0;
+ if (count == 0) {
+ str.append("\n" + key + " | " + nullMap.get(key));
+ } else if (count == keySet.size() - 1) {
+ str.append(key + " | " + nullMap.get(key) + "\n");
+ } else {
+ str.append(key + " | " + nullMap.get(key));
+ }
+ }
+ MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
+ }
+ }
+ }
+
+ public boolean isCcpRevision() throws TCException {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
+ System.out.println("length: " + targetComponents.length);
+ List tempComponents = new ArrayList<>();
+ for (InterfaceAIFComponent targetComponent : targetComponents) {
+ System.out.println("enter judge");
+ if (targetComponent instanceof TCComponentItemRevision) {
+ TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
+ if (!tempComponentRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
+ System.out.println("false");
+ return false;
+ } else {
+ System.out.println("true");
+ tempComponents.add(tempComponentRev);
+ }
+ } else if (targetComponent instanceof TCComponentBOMLine) {
+ try {
+ TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ if (!tempComponentRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
+ return false;
+ } else {
+ tempComponents.add(tempComponentRev);
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ System.out.println("tempComponents.size: " + tempComponents.size());
+ tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
+ return true;
+ }
+
+ public Map isExistNull() {
+ Map errorMap = new HashMap<>();
+ for (InterfaceAIFComponent targetComponent : tarRevs) {
+ TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
+ try {
+ TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ String property = referenceValueArray[0].getStringProperty("vf5wlbm");
+ if (property.isEmpty()) {
+ errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("isExistNull is error !");
+ e.printStackTrace();
+ }
+ }
+ return errorMap;
+ }
+
+ public void createNbtzItem() {
+ try {
+ System.out.println("tarRevs: "+tarRevs.length);
+ if (tarRevs != null && tarRevs.length > 0) {
+ boolean flag = true;
+ for (TCComponentItemRevision targetRev : tarRevs) {
+ if (judgeIsExist(targetRev)) {
+ TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ String property = targetRevForm[0].getStringProperty("vf5khth");
+ String pn = targetRevForm[0].getStringProperty("vf5wlbm");
+
+ TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
+ TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
+ if (tzItem != null) {
+ TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
+ TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ newTcItemRevForm[0].setStringProperty("vf5khth", property);
+ newTcItemRevForm[0].setStringProperty("vf5pn", pn);
+
+ targetRev.add(revReference, tzItem);
+ } else {
+ flag = false;
+ }
+ }
+
+ }
+ if(flag) {
+ MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
+ }else {
+ MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
+ }
+ } else {
+ MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ }
+
+ public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
+ if(targetRev!=null) {
+ TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
+ System.out.println("item: " + targetRev.getStringProperty("object_name"));
+ if (tzReferences != null && tzReferences.length > 0) {
+ for (int i = 0; i < tzReferences.length; i++) {
+ if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
+ System.out.println("it's exist!");
+ return false;
+ }
+ }
+ }
+ }else {
+ throw new CustomException("targetRev is null");
+ }
+ return true;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingHandler.java
new file mode 100644
index 0000000..cc20c3f
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingHandler.java
@@ -0,0 +1,20 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateSubPartsDrawingHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateSubPartsDrawingAction commonAction = new CreateSubPartsDrawingAction(application, "VF5spgx", "VF5bcptz","Sub-Parts Drawing","-SP");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/FsetupSheet/CreateSetupSheetHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/FsetupSheet/CreateSetupSheetHandler.java
new file mode 100644
index 0000000..2ca2906
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/FsetupSheet/CreateSetupSheetHandler.java
@@ -0,0 +1,20 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.FsetupSheet;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateSetupSheetHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CommonAction commonAction = new CommonAction(application, "VF5ssgx", "VF5setupsheet","Setup Sheet","-SS");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionAction.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionAction.java
new file mode 100644
index 0000000..85fa9a0
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionAction.java
@@ -0,0 +1,255 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentForm;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateReworkInstructionAction implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private TCComponentItemRevision[] tarRevs;
+
+ private String revReference;
+ private String itemType;
+ private String itemName;
+ private String ruleName;
+
+ private String[][] idList;
+
+ public CreateReworkInstructionAction(AbstractAIFApplication application, String revReference, String type,
+ String name, String ruleName) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.revReference = revReference;
+ this.itemType = type;
+ this.itemName = name;
+ this.ruleName = ruleName;
+ }
+
+ @Override
+ public void run() {
+ String errorName = null;
+ try {
+ errorName = isCcpOrGxRevision();
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (errorName == null) {
+ MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
+ } else if (!errorName.isEmpty()) {
+ MessageBox.post("Please select the finished product or process version !\n" + errorName, "error",
+ MessageBox.ERROR);
+ } else {
+ Map nullMap = null;
+ try {
+ nullMap = isExistNull();
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (nullMap != null && nullMap.isEmpty()) {
+ createNbtzItem();
+ } else {
+ StringBuffer str = new StringBuffer("");
+ Set keySet = nullMap.keySet();
+ for (String key : keySet) {
+ int count = 0;
+ if (count == 0) {
+ str.append("\n" + key + " | " + nullMap.get(key));
+ } else if (count == keySet.size() - 1) {
+ str.append(key + " | " + nullMap.get(key) + "\n");
+ } else {
+ str.append(key + " | " + nullMap.get(key));
+ }
+ }
+ MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
+ }
+ }
+ }
+
+ public String isCcpOrGxRevision() throws TCException {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
+ List tempComponents = new ArrayList<>();
+ String type = "";
+ for (InterfaceAIFComponent targetComponent : targetComponents) {
+ TCComponentItemRevision tempComponentRev = null;
+ if (targetComponent instanceof TCComponentItemRevision) {
+ tempComponentRev = (TCComponentItemRevision) targetComponent;
+ } else if (targetComponent instanceof TCComponentBOMLine) {
+ tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ }
+ type = tempComponentRev.getStringProperty("object_type");
+ if (!(type.equals("VF5ccpRevision") || type.equals("VF5gxRevision"))) {
+ return tempComponentRev.getStringProperty("object_name");
+ }else {
+ tempComponents.add(tempComponentRev);
+ }
+ }
+ tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
+ return "";
+ }
+
+ public Map isExistNull() throws TCException {
+ Map errorMap = new HashMap<>();
+ Map> lovMap = new HashMap>();
+ SwingUtil.getKeyValue("VF5gxlxlov", lovMap);
+ idList = new String[tarRevs.length][3];
+ for (InterfaceAIFComponent targetComponent : tarRevs) {
+ int count = 0;
+ TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
+ TCComponentForm formItem = null;
+ String pnValue = "";
+ String processValue = "";
+ String sequenceValue = "";
+ String tarType = targetRev.getStringProperty("object_type");
+ if (tarType.equals("VF5ccpRevision")) {
+ TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ formItem = (TCComponentForm) referenceValueArray[0];
+ pnValue = formItem.getStringProperty("vf5wlbm");
+ processValue = "N";
+ sequenceValue = "0";
+ } else if (tarType.equals("VF5gxRevision")) {
+ sequenceValue = getBomLineRowNumber((TCComponentItemRevision) targetRev);
+ TCComponentItemRevision gyRev = null;
+ TCComponent[] whereUsed = targetRev.whereUsed((short) 0);
+ if (whereUsed != null && whereUsed.length > 0) {
+ for (TCComponent tcItem : whereUsed) {
+ if (tcItem.getStringProperty("object_type").equals("VF5gyRevision")) {
+ gyRev = (TCComponentItemRevision) tcItem;
+ break;
+ }
+ }
+ } else {
+ MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
+ }
+ if (gyRev != null) {
+ String innerType = "";
+ TCComponent[] ccpItems = gyRev.getTCProperty("IMAN_METarget").getReferenceValueArray();
+ for (TCComponent ccpItem : ccpItems) {
+ innerType = ccpItem.getStringProperty("object_type");
+ if (innerType.equals("VF5ccpRevision") || innerType.equals("VF5bcpRevision")) {
+ TCComponentForm gxForm = (TCComponentForm)targetRev.getRelatedComponent("IMAN_master_form_rev");
+ formItem = (TCComponentForm)ccpItem.getRelatedComponent("IMAN_master_form_rev");
+// processValue = lovMap.get("VF5gxlxlov").get(formItem.getStringProperty("vf5gxlx"));
+ String vf5gxlx = gxForm.getStringProperty("vf5gxlx");
+ System.out.println("vf5gxlx : "+vf5gxlx);
+ processValue = vf5gxlx;
+ pnValue = formItem.getStringProperty("vf5wlbm");
+ break;
+ }
+ }
+ } else {
+ throw new CustomException(
+ targetRev.getStringProperty("object_name") + " : parent's item is not exist !");
+ }
+ }
+
+ System.out.println(
+ "pnValue:" + pnValue + " | processValue:" + processValue + " | sequenceValue:" + sequenceValue);
+ idList[count][0] = pnValue;
+ idList[count][1] = processValue;
+ idList[count++][2] = sequenceValue;
+
+ if (formItem != null) {
+ String property = formItem.getStringProperty("vf5wlbm");
+ if (property.isEmpty()) {
+ errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
+ }
+ } else {
+ System.out.println("cannot get form item !");
+ }
+ }
+ return errorMap;
+ }
+
+ public String getBomLineRowNumber(TCComponentItemRevision itemRev) throws TCException {
+ TCComponent[] whereUsed = itemRev.whereUsed((short) 0);
+ String localId = itemRev.getStringProperty("item_id");
+ TCComponentBOMLine bomLine = null;
+ TCComponentBOMWindow view = null;
+ if (whereUsed != null && whereUsed.length > 0) {
+ TCComponentItemRevision itemType = (TCComponentItemRevision) whereUsed[0];
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
+ view = winType.create(null);
+
+ bomLine = view.setWindowTopLine(itemType.getItem(), itemType, null, null);
+ } else {
+ MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
+ }
+
+ if (bomLine != null && bomLine.hasChildren()) {
+ // ȡӼ
+ AIFComponentContext[] childrena = bomLine.getChildren();
+ for (int i = 0; i < childrena.length; i++) {
+ // ǿתΪTCComponentBOMLine
+ TCComponentBOMLine childBomLine = (TCComponentBOMLine) childrena[i].getComponent();
+ if (childBomLine.getItemRevision().getStringProperty("item_id").equals(localId)) {
+ return i + 1 + "";
+ }
+ }
+ }
+ return "";
+ }
+
+ public void createNbtzItem() {
+ try {
+ boolean createFlag = true;
+ for (InterfaceAIFComponent targetComponent : tarRevs) {
+ int count = 0;
+ TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
+ TCComponent[] tzReferences = targetRev.getTCProperty(revReference).getReferenceValueArray();
+ boolean flag = true;
+ if (tzReferences != null && tzReferences.length > 0) {
+ for (int i = 0; i < tzReferences.length; i++) {
+ if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
+ flag = false;
+ }
+ }
+ }
+ if (flag) {
+ TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
+ TCComponentItem tzItem = tzType.create(
+ idList[count][0] + ruleName + idList[count][1] + idList[count++][2], "", itemType, itemName,
+ "", null);
+ if (tzItem != null) {
+ targetRev.add(revReference, tzItem);
+ } else {
+ createFlag = false;
+ }
+ }
+ }
+ if(createFlag) {
+ MessageBox.post("Creation Item Successful !", "Info", MessageBox.INFORMATION);
+ }else {
+ MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionHandler.java
new file mode 100644
index 0000000..18e06db
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionHandler.java
@@ -0,0 +1,19 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateReworkInstructionHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateReworkInstructionAction commonAction = new CreateReworkInstructionAction(application, "VF5rwigx", "VF5rwi","Rework Work Instruction","-RWI-");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GxTemplateAction.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GxTemplateAction.java
new file mode 100644
index 0000000..fa42dc0
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GxTemplateAction.java
@@ -0,0 +1,225 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentForm;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+/**
+ * used: HncFile || IprocessDrawing || JpreMillDrawing
+ *
+ * @author Administrator
+ *
+ */
+public class GxTemplateAction implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private TCComponentItemRevision[] gyRevs;
+ private TCComponentItemRevision[] gxRevs;
+
+ private String revReference;
+ private String itemType;
+ private String itemName;
+ private String ruleName;
+
+ public GxTemplateAction(AbstractAIFApplication application, String revReference, String type, String name,
+ String ruleName) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.revReference = revReference;
+ this.itemType = type;
+ this.itemName = name;
+ this.ruleName = ruleName;
+ }
+
+ @Override
+ public void run() {
+ try {
+ gyRevs = judgeSelectRevision(application);
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ MessageBox.post(e1.getMessage(), "Error", MessageBox.ERROR);
+ }
+ if (gyRevs != null) {
+ Map nullMap = null;
+ String[] pnValue = null;
+ try {
+ pnValue = new String[gyRevs.length];
+ nullMap = isExistNull(pnValue);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (nullMap != null && nullMap.isEmpty()) {
+ createNbtzItem(pnValue);
+ } else {
+ StringBuffer str = new StringBuffer("");
+ Set keySet = nullMap.keySet();
+ for (String key : keySet) {
+ int count = 0;
+ if (count == 0) {
+ str.append("\n" + key + " | " + nullMap.get(key));
+ } else if (count == keySet.size() - 1) {
+ str.append(key + " | " + nullMap.get(key) + "\n");
+ } else {
+ str.append(key + " | " + nullMap.get(key));
+ }
+ }
+ MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
+ }
+ }
+ }
+
+ public TCComponentItemRevision[] judgeSelectRevision(AbstractAIFApplication application) throws Exception {
+ InterfaceAIFComponent[] selectComponents = application.getTargetComponents();
+ List gyRevList = new ArrayList<>();
+ List gxRevList = new ArrayList<>();
+ try {
+ for (InterfaceAIFComponent targetComponent : selectComponents) {
+ TCComponentItemRevision tempComponentRev = null;
+ if (targetComponent instanceof TCComponentItemRevision) {
+ tempComponentRev = (TCComponentItemRevision) targetComponent;
+ } else if (targetComponent instanceof TCComponentBOMLine) {
+ tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ } else {
+ MessageBox.post(
+ "Please Select Rule Version Object !\n" + targetComponent.getProperty("object_name"),
+ "Error", MessageBox.ERROR);
+ return null;
+ }
+ gxRevList.add(tempComponentRev);
+ TCComponent[] whereUsed = tempComponentRev.whereUsed((short) 0);
+ TCComponentItemRevision gyRev = null;
+ if (whereUsed != null && whereUsed.length > 0) {
+ for (TCComponent tcItem : whereUsed) {
+ System.out.println("tcItem : " + tcItem.getStringProperty("object_name"));
+ System.out.println("tcItem : " + tcItem.getStringProperty("object_type"));
+ if (tcItem.getStringProperty("object_type").equals("VF5gyRevision")) {
+ gyRev = (TCComponentItemRevision) tcItem;
+ gyRevList.add(gyRev);
+ break;
+ }
+ }
+ if (gyRev == null) {
+ throw new CustomException(
+ tempComponentRev.getStringProperty("object_name") + " : parent's item is not exist !");
+ }
+ }else {
+ throw new CustomException(
+ tempComponentRev.getStringProperty("object_name") + " : parent's item is not exist !");
+ }
+ }
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ gxRevs = gxRevList.toArray(new TCComponentItemRevision[gxRevList.size()]);
+ return gyRevList.toArray(new TCComponentItemRevision[gyRevList.size()]);
+ }
+
+ public Map isExistNull(String pnValue[]) throws TCException {
+ Map errorMap = new HashMap<>();
+ for (TCComponentItemRevision gyItemRev : gyRevs) {
+ int count = 0;
+ TCComponentForm formItem = null;
+ TCComponent[] ccpItems = gyItemRev.getTCProperty("IMAN_METarget").getReferenceValueArray();
+ for (TCComponent ccpItem : ccpItems) {
+ String type = ccpItem.getStringProperty("object_type");
+ if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision") ) {
+ TCComponent[] referenceValueArray = ccpItem.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ formItem = (TCComponentForm) referenceValueArray[0];
+ break;
+ }
+ }
+
+ if (formItem != null) {
+ String wlbm = formItem.getStringProperty("vf5wlbm");
+ pnValue[count++] = wlbm;
+ if (wlbm !=null && (wlbm.isEmpty() || wlbm.equals("null"))) {
+ errorMap.put(gyItemRev.getStringProperty("item_id"), gyItemRev.getStringProperty("object_name"));
+ }
+ } else {
+ System.out.println("cannot get form item !");
+ }
+ }
+ return errorMap;
+ }
+
+ public String getBomLineRowNumber(TCComponentItemRevision itemRev) throws TCException {
+ TCComponent[] whereUsed = itemRev.whereUsed((short) 0);
+ String localId = itemRev.getStringProperty("item_id");
+ TCComponentBOMLine bomLine = null;
+ TCComponentBOMWindow view = null;
+ if (whereUsed != null && whereUsed.length > 0) {
+ TCComponentItemRevision itemType = (TCComponentItemRevision) whereUsed[0];
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
+ view = winType.create(null);
+
+ bomLine = view.setWindowTopLine(itemType.getItem(), itemType, null, null);
+ } else {
+ MessageBox.post("The current object is not referenced !", "error", MessageBox.ERROR);
+ }
+
+ if (bomLine != null && bomLine.hasChildren()) {
+ AIFComponentContext[] childrena = bomLine.getChildren();
+ for (int i = 0; i < childrena.length; i++) {
+ TCComponentBOMLine childBomLine = (TCComponentBOMLine) childrena[i].getComponent();
+ if (childBomLine.getItemRevision().getStringProperty("item_id").equals(localId)) {
+ return i + 1 + "";
+ }
+ }
+ }
+ return "";
+ }
+
+ public void createNbtzItem(String[] pnValue) {
+ for (TCComponentItemRevision targetRev : gxRevs) {
+ int count = 0;
+ try {
+ TCComponent[] tzReferences = targetRev.getTCProperty(revReference).getReferenceValueArray();
+ boolean flag = true;
+ if (tzReferences != null && tzReferences.length > 0) {
+ for (int i = 0; i < tzReferences.length; i++) {
+ if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
+ flag = false;
+ }
+ }
+ }
+ if (flag) {
+ TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
+ TCComponentItem tzItem = tzType.create(pnValue[count++] + ruleName, "", itemType, itemName, "",
+ null);
+ if (tzItem != null) {
+ targetRev.add(revReference, tzItem);
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+ } else {
+ MessageBox.post("Creation Failed !", "Error", MessageBox.ERROR);
+ }
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/HncFile/CreateNcFileHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/HncFile/CreateNcFileHandler.java
new file mode 100644
index 0000000..d4e756e
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/HncFile/CreateNcFileHandler.java
@@ -0,0 +1,20 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.HncFile;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateNcFileHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ GxTemplateAction commonAction = new GxTemplateAction(application, "VF5ncgx", "VF5ncfile","NC File","-NC");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/IprocessDrawing/CreateProcessDrawingHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/IprocessDrawing/CreateProcessDrawingHandler.java
new file mode 100644
index 0000000..c0a2f66
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/IprocessDrawing/CreateProcessDrawingHandler.java
@@ -0,0 +1,20 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.IprocessDrawing;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateProcessDrawingHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ GxTemplateAction commonAction = new GxTemplateAction(application, "VF5pdgx", "VF5gytz","Process Drawing","-PD");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JpreMillDrawing/CreatePreMillDrawingHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JpreMillDrawing/CreatePreMillDrawingHandler.java
new file mode 100644
index 0000000..9ec55ca
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JpreMillDrawing/CreatePreMillDrawingHandler.java
@@ -0,0 +1,21 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.JpreMillDrawing;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreatePreMillDrawingHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ GxTemplateAction commonAction = new GxTemplateAction(application, "VF5pmgx", "VF5yjgtz","Pre-Mill Drawing","-PM");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureDialog.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureDialog.java
new file mode 100644
index 0000000..589530d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureDialog.java
@@ -0,0 +1,174 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing;
+
+import javax.swing.*;
+
+import org.apache.commons.compress.harmony.unpack200.bytecode.forms.LocalForm;
+
+import java.awt.*;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCComponentType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateJitFixtureDialog extends AbstractAIFDialog {
+ private AbstractAIFApplication application;
+
+ private String title;
+ private int[] sizes;
+ private JLabel[] jLabels;
+ private JComponent[] jComponents;
+
+ private JButton okButton;
+ private JButton celButton;
+
+ private Map> lovMap;
+
+ public CreateJitFixtureDialog(AbstractAIFApplication application, String title, Object... args) {
+ super(true);
+ int count = 0;
+ this.title = title;
+ this.application = application;
+ this.sizes = (int[]) args[count++];
+ this.jLabels = (JLabel[]) args[count++];
+ this.jComponents = (JComponent[]) args[count++];
+ this.lovMap = (Map>) args[count];
+ }
+
+ @Override
+ public void run() {
+ initUI();
+ }
+
+ public void initUI() {
+ this.setTitle(title);
+ this.setSize(sizes[0], sizes[1]);
+ initializationComponent();
+ JScrollPane centerPanel = getCenterPanel();
+ JPanel bottomPanel = getBottomPanel();
+
+ this.getContentPane().add(centerPanel, BorderLayout.CENTER);
+ this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ this.setLocationRelativeTo(null);
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ this.setVisible(true);
+ }
+
+ private void initializationComponent() {
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ }
+
+ private JScrollPane getCenterPanel() {
+ JPanel centerPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints customLayout = new GridBagConstraints();
+ for (int i = 0; i < jLabels.length; i++) {
+ customLayout.insets = new Insets(5, 30, 5, 20);
+ customLayout.gridx = 0;
+ customLayout.weightx = 0;
+ customLayout.anchor = GridBagConstraints.LINE_START;
+ jLabels[i].setFont(new Font("ź", Font.BOLD, 13));
+ centerPanel.add(jLabels[i], customLayout);
+
+ customLayout.insets = new Insets(5, 3, 5, 30);
+ customLayout.gridx = 1;
+ customLayout.weightx = 0;
+ customLayout.fill = GridBagConstraints.HORIZONTAL;
+ JComponent jComponent = jComponents[i];
+ jComponent.setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(jComponent, customLayout);
+ }
+ return new JScrollPane(centerPanel);
+ }
+
+ private JPanel getBottomPanel() {
+ // TODO Auto-generated method stub
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10));
+ bottomPanel.setBorder(BorderFactory.createEmptyBorder(sizes[2], 0, sizes[3], 0));
+ bottomPanel.add(this.okButton);
+ bottomPanel.add(this.celButton);
+ okButton.addActionListener(e -> {
+ boolean confirmed = confirmFunction();
+ if (confirmed) {
+ this.dispose();
+ }
+ });
+ celButton.addActionListener(e -> {
+ this.dispose();
+ });
+ return bottomPanel;
+ }
+
+ public boolean confirmFunction() {
+ String[] inputValue = new String[jComponents.length];
+ for (int i = 0; i < jComponents.length; i++) {
+ if (jComponents[i] instanceof JTextField) {
+ inputValue[i] = ((JTextField) jComponents[i]).getText();
+ } else if (jComponents[i] instanceof JComboBox) {
+ JComboBox comboBox = (JComboBox) jComponents[i];
+ Object selectedItem = comboBox.getSelectedItem();
+ inputValue[i] = (selectedItem != null) ? selectedItem.toString() : "";
+ }
+ }
+ try {
+ createItem(inputValue);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ private void createItem(String[] inputValue) throws Exception {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find Jit_Fixture Flow",
+ new String[] { "ID" }, new String[] { "MJF*" });
+ int maxFlowNo = 0;
+ for (InterfaceAIFComponent tcItem : queryList) {
+ String itemId = tcItem.getProperty("item_id");
+ String[] split = itemId.split("-");
+ if (split != null && split.length > 2) {
+ int localFlowNo = Integer.parseInt(split[2]);
+ if (localFlowNo >= maxFlowNo) {
+ maxFlowNo = localFlowNo;
+ }
+ }
+ }
+ String strMaxFlowNo = (maxFlowNo + 1) + "";
+ int addZero = 5 - strMaxFlowNo.length();
+ for (int i = 0; i < addZero; i++) {
+ strMaxFlowNo = "0" + strMaxFlowNo;
+ }
+
+ String realProcess = lovMap.get("VF5gxlxlov").get(inputValue[0]);
+ String name = inputValue[inputValue.length - 1].isEmpty() ? "Jit-Fixture Drawing"
+ : inputValue[inputValue.length - 1];
+ String itemId = "MJF-" + realProcess + inputValue[1] + "-" + strMaxFlowNo + "-"
+ + inputValue[inputValue.length - 2];
+
+ System.out.println("itemId : "+itemId);
+
+ TCComponentItem newComponent = (TCComponentItem) TcUtil.createComponent(application,
+ new String[] { itemId, "", name }, "VF5gzjtz", "Item");
+ if (newComponent != null) {
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+ } else {
+ MessageBox.post("Created Failed !", "Error", MessageBox.ERROR);
+ }
+ ((TCComponentFolder) application.getTargetComponent()).add("contents", newComponent);
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureHandler.java
new file mode 100644
index 0000000..ae94fdc
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureHandler.java
@@ -0,0 +1,51 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCSession;
+
+import javax.swing.*;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CreateJitFixtureHandler extends AbstractHandler {
+
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"Folder","VF5xmwjj"}, "Folder");
+ if(judgeSingleSelectComponent) {
+ String[] enLabelName = new String[]{
+ "Process", "Process Sequence", "Property","Name"
+ };
+ JLabel[] jLabels = new JLabel[enLabelName.length];
+ JComponent[] jComponents = new JComponent[enLabelName.length];
+ Map map = new HashMap<>();
+
+ Map> lovMap = new HashMap>();
+ map.put(0, SwingUtil.getKeyValue("VF5gxlxlov", lovMap));
+ map.put(1, TcUtil.getPreferenceValues((TCSession)application.getSession(), "VF5ProcessSequence"));
+
+ for (int i = 0; i < enLabelName.length; i++) {
+ if (map.containsKey(i)) {
+ jComponents[i] = new JComboBox<>(map.get(i));
+ } else {
+ jComponents[i] = new JTextField(14);
+ }
+ jLabels[i] = new JLabel(enLabelName[i]);
+ }
+
+ CreateJitFixtureDialog dialog = new CreateJitFixtureDialog(application,"create Jit-Fixture Drawing", new int[]{430, 400,5,5},jLabels, jComponents,lovMap);
+ new Thread(dialog).start();
+ }
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListAction.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListAction.java
new file mode 100644
index 0000000..7876d98
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListAction.java
@@ -0,0 +1,237 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentForm;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateToolingListAction implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private InterfaceAIFComponent[] targetComponents;
+
+ private String revReference;
+ private String itemType;
+ private String itemName;
+ private String ruleName;
+
+ private String[][] idList;
+
+ public CreateToolingListAction(AbstractAIFApplication application, String revReference, String type, String name,
+ String ruleName) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.revReference = revReference;
+ this.itemType = type;
+ this.itemName = name;
+ this.ruleName = ruleName;
+ }
+
+ @Override
+ public void run() {
+ try {
+ targetComponents = judgeSelectRevision(application);
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ if (targetComponents != null) {
+ Map nullMap = null;
+ try {
+ nullMap = isExistNull();
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (nullMap != null && nullMap.isEmpty()) {
+ createNbtzItem();
+ } else {
+ StringBuffer str = new StringBuffer("");
+ Set keySet = nullMap.keySet();
+ for (String key : keySet) {
+ int count = 0;
+ if (count == 0) {
+ str.append("\n" + key + " | " + nullMap.get(key));
+ } else if (count == keySet.size() - 1) {
+ str.append(key + " | " + nullMap.get(key) + "\n");
+ } else {
+ str.append(key + " | " + nullMap.get(key));
+ }
+ }
+ MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
+ }
+ }
+ }
+
+ public TCComponentItemRevision[] judgeSelectRevision(AbstractAIFApplication application) throws Exception {
+ InterfaceAIFComponent[] selectComponents = application.getTargetComponents();
+ List gxRevList = new ArrayList<>();
+ try {
+ for (InterfaceAIFComponent targetComponent : selectComponents) {
+ TCComponentItemRevision tempComponentRev = null;
+ if (targetComponent instanceof TCComponentItemRevision) {
+ tempComponentRev = (TCComponentItemRevision) targetComponent;
+ } else if (targetComponent instanceof TCComponentBOMLine) {
+ tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ }
+
+ if (tempComponentRev != null
+ && tempComponentRev.getStringProperty("object_type").equals("VF5gxRevision")) {
+ gxRevList.add(tempComponentRev);
+ } else {
+ MessageBox.post(
+ "Please Select Rule Version Object !\n" + targetComponent.getProperty("object_name"),
+ "Error", MessageBox.ERROR);
+ return null;
+ }
+ }
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ return gxRevList.toArray(new TCComponentItemRevision[gxRevList.size()]);
+ }
+
+ public Map isExistNull() throws TCException {
+ Map errorMap = new HashMap<>();
+ Map> lovMap = new HashMap>();
+ SwingUtil.getKeyValue("VF5gxlxlov", lovMap);
+ idList = new String[targetComponents.length][3];
+ for (InterfaceAIFComponent targetComponent : targetComponents) {
+ int count = 0;
+ TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
+ TCComponent ccpForm = null;
+ String pnValue = "";
+ String processValue = "";
+ String sequenceValue = getBomLineRowNumber((TCComponentItemRevision) targetRev);
+ TCComponentItemRevision gyRev = null;
+ TCComponent[] whereUsed = targetRev.whereUsed((short) 0);
+ if (whereUsed != null && whereUsed.length > 0) {
+ for (TCComponent tcItem : whereUsed) {
+ if (tcItem.getStringProperty("object_type").equals("VF5gyRevision")) {
+ gyRev = (TCComponentItemRevision) tcItem;
+ break;
+ }
+ }
+ } else {
+ MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
+ }
+ if (gyRev != null) {
+ TCComponent[] ccpItems = gyRev.getTCProperty("IMAN_METarget").getReferenceValueArray();
+ String type ="";
+ for (TCComponent ccpItem : ccpItems) {
+ type = ccpItem.getStringProperty("object_type");
+ if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
+ ccpForm = ccpItem.getRelatedComponent("IMAN_master_form_rev");
+ pnValue = ccpForm.getStringProperty("vf5wlbm");
+
+ TCComponent gxForm = targetRev.getRelatedComponent("IMAN_master_form_rev");
+ String gxlx = gxForm.getStringProperty("vf5gxlx");
+ System.out.println("gxForm(vf5gxlx) : " + gxlx);
+ processValue = gxlx;
+ break;
+ }
+ }
+ } else {
+ throw new CustomException(
+ targetRev.getStringProperty("object_name") + " : parent's item is not exist !");
+ }
+
+ System.out.println(
+ "pnValue:" + pnValue + " | processValue:" + processValue + " | sequenceValue:" + sequenceValue);
+ idList[count][0] = pnValue;
+ idList[count][1] = processValue;
+ idList[count++][2] = sequenceValue;
+
+ if (ccpForm != null) {
+ String property = ccpForm.getStringProperty("vf5wlbm");
+ if (property.isEmpty()) {
+ errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
+ }
+ } else {
+ System.out.println("cannot get form item !");
+ }
+ }
+ return errorMap;
+ }
+
+ public String getBomLineRowNumber(TCComponentItemRevision itemRev) throws TCException {
+ TCComponent[] whereUsed = itemRev.whereUsed((short) 0);
+ String localId = itemRev.getStringProperty("item_id");
+ TCComponentBOMLine bomLine = null;
+ TCComponentBOMWindow view = null;
+ if (whereUsed != null && whereUsed.length > 0) {
+ TCComponentItemRevision tempItemRev = (TCComponentItemRevision) whereUsed[0];
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
+ view = winType.create(null);
+
+ bomLine = view.setWindowTopLine(tempItemRev.getItem(), tempItemRev, null, null);
+ } else {
+ MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
+ }
+
+ if (bomLine != null && bomLine.hasChildren()) {
+ AIFComponentContext[] childrena = bomLine.getChildren();
+ for (int i = 0; i < childrena.length; i++) {
+ TCComponentBOMLine childBomLine = (TCComponentBOMLine) childrena[i].getComponent();
+ if (childBomLine.getItemRevision().getStringProperty("item_id").equals(localId)) {
+ return i + 1 + "";
+ }
+ }
+ }
+ return "";
+ }
+
+ public void createNbtzItem() {
+ for (InterfaceAIFComponent targetComponent : targetComponents) {
+ int count = 0;
+ TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
+ try {
+ TCComponent[] tzReferences = targetRev.getTCProperty(revReference).getReferenceValueArray();
+ boolean flag = true;
+ if (tzReferences != null && tzReferences.length > 0) {
+ for (int i = 0; i < tzReferences.length; i++) {
+ if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
+ flag = false;
+ }
+ }
+ }
+ if (flag) {
+ TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
+ TCComponentItem tzItem = tzType.create(
+ idList[count][0] + ruleName + idList[count][1] + idList[count++][2], "", itemType, itemName,
+ "", null);
+ if (tzItem != null) {
+ targetRev.add(revReference, tzItem);
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+ } else {
+ MessageBox.post("Creation Failed !", "Error", MessageBox.ERROR);
+ }
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListHandler.java
new file mode 100644
index 0000000..2d3a833
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListHandler.java
@@ -0,0 +1,21 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateToolingListHandler extends AbstractHandler {
+
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateToolingListAction commonAction = new CreateToolingListAction(application, "VF5tlgx", "VF5tl","ToolList","-TL-");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/LTinspectionPlan/InspectionPlanHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/LTinspectionPlan/InspectionPlanHandler.java
new file mode 100644
index 0000000..a31692a
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/LTinspectionPlan/InspectionPlanHandler.java
@@ -0,0 +1,21 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.LTinspectionPlan;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
+import com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList.CreateToolingListAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class InspectionPlanHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ GxTemplateAction commonAction = new GxTemplateAction(application, "VF5ipgx", "VF5ip","In-Process Inspection Plan","-IP");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/LstandardInstruction/CreateStandardInstructionHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/LstandardInstruction/CreateStandardInstructionHandler.java
new file mode 100644
index 0000000..9d63289
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/LstandardInstruction/CreateStandardInstructionHandler.java
@@ -0,0 +1,20 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.LstandardInstruction;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList.CreateToolingListAction;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateStandardInstructionHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateToolingListAction commonAction = new CreateToolingListAction(
+ application, "VF5swigx", "VF5swi","Standard Work Instruction","-SWI-");
+ new Thread(commonAction).start();
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsDialog.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsDialog.java
new file mode 100644
index 0000000..af1a050
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsDialog.java
@@ -0,0 +1,326 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments;
+
+import java.awt.BorderLayout;
+import java.awt.Dialog;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponentDataset;
+import com.teamcenter.rac.kernel.TCComponentDatasetType;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+@SuppressWarnings("serial")
+public class UploadDocumentsDialog extends AbstractAIFDialog {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private JLabel selectUploadLabel;
+ private JComponent uploadInput;
+
+ private JButton importButton;
+ private JButton okButton;
+ private JButton celButton;
+
+ private TCComponentDatasetType pdfType;
+ private TCComponentDatasetType dwgType;
+ private TCComponentDatasetType docType;
+ private TCComponentDatasetType docxType;
+ private TCComponentDatasetType xlsType;
+ private TCComponentDatasetType xlsxType;
+ private TCComponentDatasetType defaultType;
+
+ public UploadDocumentsDialog(AbstractAIFApplication application) {
+ super(true);
+ this.application = application;
+ this.tcSession = (TCSession) this.application.getSession();
+ }
+
+ public void initializationComponent() {
+ selectUploadLabel = new JLabel(ConstantPool.EN_LABEL_UPLOAD_PATH);
+ uploadInput = new JTextField(14);
+
+ importButton = new JButton(ConstantPool.EN_BUTTON_SELECT);
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+
+ SwingUtilities.getWindowAncestor(importButton);
+ }
+
+ @Override
+ public void run() {
+ try {
+ pdfType = (TCComponentDatasetType) tcSession.getTypeComponent("PDF");
+ dwgType = (TCComponentDatasetType) tcSession.getTypeComponent("VF5CAD");
+ docType = (TCComponentDatasetType) tcSession.getTypeComponent("MSWord");
+ docxType = (TCComponentDatasetType) tcSession.getTypeComponent("MSWordX");
+ xlsType = (TCComponentDatasetType) tcSession.getTypeComponent("MSExcel");
+ xlsxType = (TCComponentDatasetType) tcSession.getTypeComponent("MSExcelX");
+ defaultType = (TCComponentDatasetType) tcSession.getTypeComponent("Dataset");
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ initUi();
+ }
+
+ /**
+ * ʼ
+ */
+ public void initUi() {
+ initializationComponent();
+ this.setTitle(ConstantPool.EN_TITLE_UPLOAD_PATH);
+
+ this.setLayout(null);
+
+ selectUploadLabel.setBounds(30, 40, 80, 25);
+ this.add(selectUploadLabel);
+
+ uploadInput.setBounds(110, 40, 150, 25);
+ this.add(uploadInput);
+
+ importButton.setBounds(280, 40, 90, 25);
+
+ importButton.addActionListener(e -> {
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ fileChooser.setMultiSelectionEnabled(false);
+ FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV Files", "csv");
+ fileChooser.setFileFilter(filter);
+
+ int result = fileChooser.showOpenDialog(this);
+ if (result == JFileChooser.APPROVE_OPTION) {
+ ((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath());
+ }
+ });
+ this.add(importButton, BorderLayout.EAST);
+
+ okButton.setBounds(80, 90, 100, 25);
+ celButton.setBounds(200, 90, 100, 25);
+
+ okButton.addActionListener(e -> {
+ String path = ((JTextField) uploadInput).getText();
+ if (path.isEmpty()) {
+ JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_UPLOAD_ERROR);
+ } else {
+ File file = new File(path);
+ if (!file.exists() || !file.isDirectory()) {
+ JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_FILE_ERROR);
+ } else {
+ this.dispose();
+ uploadDrawings(file);
+ }
+ }
+ });
+
+ celButton.addActionListener(e -> {
+ this.setVisible(false);
+ this.disposeDialog();
+ });
+ this.add(okButton);
+ this.add(celButton);
+ this.pack();
+ this.setSize(410, 190);
+ this.setLocationRelativeTo((Dialog) SwingUtilities.getWindowAncestor(importButton));
+ this.setVisible(true);
+ }
+
+ private void uploadDrawings(File file) {
+ List localFiles = getFilesInDirectory(file.getAbsolutePath());
+
+// for (File localFile : localFiles) {
+// System.out.println("Found file: " + localFile.getAbsolutePath());
+// }
+ try {
+ addDataSet(localFiles);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("123");
+ e.printStackTrace();
+ }
+ }
+
+ public boolean createDataSet(TCComponentItemRevision rev, File localFile) throws TCException {
+ String fileName = localFile.getName();
+ String[] split = fileName.split("\\.");
+ System.out.println(": " + split[1]);
+ String type = "";
+ String tool = "";
+ TCComponentDatasetType tempType = null;
+ if (split != null && split.length == 2) {
+ switch (split[1].toLowerCase()) {
+ case "pdf": {
+ type = "PDF";
+ tool = "PDF_Reference";
+ tempType = pdfType;
+ break;
+ }
+ case "dwg": {
+ type = "VF5CAD";
+ tool = "VF5dwg";
+ tempType = dwgType;
+ break;
+ }
+ case "doc": {
+ type = "MSWord";
+ tool = "word";
+ tempType = docType;
+ break;
+ }
+ case "docx": {
+ type = "MSWordX";
+ tool = "word";
+ tempType = docxType;
+ break;
+ }
+ case "xls": {
+ type = "MSExcel";
+ tool = "excel";
+ tempType = xlsType;
+ break;
+ }
+ case "xlsx": {
+ type = "MSExcelX";
+ tool = "excel";
+ tempType = xlsxType;
+ break;
+ }
+ default: {
+ type = "CAEAnalysisDS";
+ tool = "CAEAnaysisData";
+ tempType = defaultType;
+ break;
+ }
+ }
+
+ TCComponentDataset tempData = tempType.create(fileName, "", type);
+ try {
+ tempData.setFiles(new String[] { localFile.getAbsolutePath() }, new String[] { tool });
+ } catch (Exception e) {
+ // TODO: handle exception
+ return false;
+ }
+ if (tempData != null) {
+ rev.add("IMAN_specification", tempData);
+ return true;
+ }
+
+ } else {
+ System.out.println("Folder Name Is Error !");
+ }
+ return false;
+ }
+
+ public void addDataSet(List localFiles) throws TCException {
+ // TODO Auto-generated method stub
+
+ int successfulCount = 0;
+ int failedCount = 0;
+ int notFoundCount = 0;
+
+// StringBuffer successfulData = new StringBuffer("");
+ StringBuffer failedData = new StringBuffer("");
+ StringBuffer notFoundData = new StringBuffer("");
+ for (File localFile : localFiles) {
+ String fileName = localFile.getName();
+ String queryValue = fileName.substring(0,
+ fileName.lastIndexOf(".") == -1 ? fileName.length() : fileName.lastIndexOf("."));
+ System.out.println("fileName : " + fileName);
+ System.out.println("queryValue : " + queryValue);
+ InterfaceAIFComponent[] resultComponents = queryItem(queryValue);
+ if (resultComponents != null && resultComponents.length > 0) {
+ TCComponentItemRevision queryRev = null;
+ if (resultComponents[0] instanceof TCComponentItem) {
+ queryRev = ((TCComponentItem) resultComponents[0]).getLatestItemRevision();
+ } else if (resultComponents[0] instanceof TCComponentItemRevision) {
+ queryRev = (TCComponentItemRevision) resultComponents[0];
+ }
+
+ if (resultComponents[0] != null) {
+ if (createDataSet(queryRev, localFile)) {
+// successfulData.append(fileName);
+// successfulData.append(" ");
+ successfulCount++;
+ } else {
+ failedData.append(fileName);
+ failedData.append(" ");
+ failedCount++;
+ }
+ }
+ } else {
+ notFoundData.append(fileName);
+ notFoundData.append(" ");
+ notFoundCount++;
+ }
+ }
+ StringBuffer resultData = new StringBuffer("");
+ resultData.append("Successful: ");
+ resultData.append(successfulCount);
+ resultData.append("\n");
+
+ resultData.append("Failed: ");
+ resultData.append(failedCount);
+ resultData.append(" ->");
+ resultData.append(failedData);
+ resultData.append("\n");
+
+ resultData.append("Not Found Rev: ");
+ resultData.append(notFoundCount);
+ resultData.append(" ->");
+ resultData.append(notFoundData);
+ resultData.append("\n");
+
+ MessageBox.post(resultData.toString(), "Info", MessageBox.INFORMATION);
+ }
+
+ public InterfaceAIFComponent[] queryItem(String itemId) {
+ try {
+ return tcSession.search("MU_Find ItemRevision", new String[] { "ID" }, new String[] { itemId });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public List getFilesInDirectory(String directoryPath) {
+ List filesList = new ArrayList<>();
+
+ File directory = new File(directoryPath);
+
+ if (!directory.exists() || !directory.isDirectory()) {
+ System.out.println("The specified path is not a valid directory: " + directoryPath);
+ return filesList;
+ }
+
+ File[] filesAndDirs = directory.listFiles();
+
+ if (filesAndDirs != null) {
+ for (File file : filesAndDirs) {
+ if (file.isFile()) {
+ filesList.add(file);
+ }
+ }
+ } else {
+ System.out.println("Failed to list files in the directory: " + directoryPath);
+ }
+
+ return filesList;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsHandler.java
new file mode 100644
index 0000000..79417c4
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsHandler.java
@@ -0,0 +1,26 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class UploadDocumentsHandler extends AbstractHandler {
+
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"VF5NPI"}, "Folder");
+ if(judgeSingleSelectComponent) {
+ UploadDocumentsDialog dialog = new UploadDocumentsDialog(application);
+
+ new Thread(dialog).start();
+ }
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsDialog.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsDialog.java
new file mode 100644
index 0000000..9642b38
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsDialog.java
@@ -0,0 +1,254 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments;
+
+import javax.swing.*;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumnModel;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class ApprovalofDocumentsDialog extends JFrame implements Runnable {
+
+ private final String title;
+
+ private JButton okButton;
+ private JButton cancelButton;
+ private JCheckBox allCheck;
+
+ private String[] columnNames;
+ private Object[][] data;
+ private JTable table;
+ private AbstractAIFApplication application;
+
+ public ApprovalofDocumentsDialog(AbstractAIFApplication application ,String title, Object... args) {
+ int count = 0;
+ this.title = title;
+ this.application = application;
+ columnNames = (String[]) args[count++];
+ data = (Object[][]) args[count];
+ }
+
+ @Override
+ public void run() {
+ initUI();
+ }
+
+ public void initializationButton() {
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ okButton.addActionListener(e -> {
+ try {
+ doTask();
+ } catch (TCException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ });
+ cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ cancelButton.addActionListener(e -> {
+ this.dispose();
+ });
+
+ }
+
+ public void initUI() {
+ // ôھ
+ this.setTitle(title);
+// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ this.setSize(600, 400); // ôڴС
+ this.setLayout(new BorderLayout()); // ò
+ this.setLocationRelativeTo(null);
+
+ initializationButton();
+
+ JPanel topPanel = createTopPanel();
+ JPanel centerPanel = createCenterPanel();
+ JPanel bottomPanel = createBottomPanel();
+
+ this.add(topPanel, BorderLayout.NORTH);
+ this.add(centerPanel, BorderLayout.CENTER);
+ this.add(bottomPanel, BorderLayout.SOUTH);
+
+ this.setVisible(true);
+ }
+
+ private JPanel createTopPanel() {
+ JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0));
+ topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ allCheck = new JCheckBox("AllSelect");
+ allCheck.addActionListener(e -> {
+ if (allCheck.isSelected()) {
+ for (int i = 0; i < table.getRowCount(); i++) {
+ table.setValueAt(true, i, columnNames.length - 2);
+ }
+ } else {
+ for (int i = 0; i < table.getRowCount(); i++) {
+ table.setValueAt(false, i, columnNames.length - 2);
+ }
+ }
+ });
+ topPanel.add(allCheck);
+
+ return topPanel;
+ }
+
+ public JPanel createCenterPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout(10, 10));
+// centerPanel.setBorder(BorderFactory.createTitledBorder(childTitle));
+ centerPanel.setPreferredSize(new Dimension(400, 200));
+
+ DefaultTableModel model = new DefaultTableModel(data, columnNames) {
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ return column != -1;
+ }
+
+ @Override
+ public Class> getColumnClass(int columnIndex) {
+ if (columnIndex == columnNames.length - 1) {
+ return Boolean.class;
+ }
+ return String.class;
+ }
+ };
+ table = new JTable(model);
+ table.setRowHeight(18);
+ table.getTableHeader().setReorderingAllowed(false);
+ table.setAutoCreateRowSorter(true);
+
+ TableColumnModel columnModel = table.getColumnModel();
+ table.setRowHeight(20);
+
+ table.removeColumn(columnModel.getColumn(columnModel.getColumnCount() - 2));
+
+ DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer() {
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
+ boolean hasFocus, int row, int column) {
+ Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ ((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER);
+ return c;
+ }
+ };
+
+ TableCellRenderer selectRenderer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
+ int column) -> {
+ JCheckBox checkBox = new JCheckBox();
+
+ if (value instanceof Boolean) {
+ checkBox.setSelected((Boolean) value);
+ } else if (value instanceof String) {
+ checkBox.setSelected(Boolean.parseBoolean((String) value));
+ } else {
+ checkBox.setSelected(false);
+ }
+
+ checkBox.setHorizontalAlignment(SwingConstants.CENTER);
+ return checkBox;
+ };
+
+ for (int i = 0; i < columnModel.getColumnCount(); i++) {
+ columnModel.getColumn(i).setCellRenderer(centerRenderer);
+ }
+ columnModel.getColumn(columnNames.length - 2).setCellRenderer(selectRenderer);
+
+ table.getModel().addTableModelListener(e -> {
+ if (e.getType() == TableModelEvent.UPDATE) {
+ int column = e.getColumn();
+ if (column == columnNames.length - 2) {
+ boolean allSelected = true;
+ for (int i = 0; i < table.getRowCount(); i++) {
+ boolean selected = (boolean) table.getValueAt(i, column);
+ if (!selected) {
+ allSelected = false;
+ break;
+ }
+ }
+ allCheck.setSelected(allSelected);
+ }
+ }
+ });
+
+ JScrollPane scrollPane = new JScrollPane(table);
+ scrollPane.setPreferredSize(new Dimension(400, 150));
+ centerPanel.add(scrollPane, BorderLayout.CENTER);
+ return centerPanel;
+ }
+
+ public JPanel createBottomPanel() {
+ // ײ壬ť
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 60, 10));
+ bottomPanel.add(okButton);
+ bottomPanel.add(cancelButton);
+ return bottomPanel;
+ }
+
+ public void doTask() throws TCException {
+ int rowCount = table.getRowCount();
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+
+ int selectedRowCount = 0;
+ for (int i = 0; i < rowCount; i++) {
+ Object value = model.getValueAt(table.convertRowIndexToModel(i), columnNames.length - 1);
+ boolean isSelected = false;
+ if (value instanceof Boolean) {
+ isSelected = (Boolean) value;
+ } else if (value instanceof String) {
+ isSelected = Boolean.parseBoolean((String) value);
+ }
+ if (isSelected) {
+ selectedRowCount++;
+ }
+ }
+
+ TCSession session = (TCSession) application.getSession();
+ String[][] selectedData = new String[selectedRowCount][model.getColumnCount()];
+ List list = new ArrayList<>();
+ int index = 0;
+ for (int i = 0; i < rowCount; i++) {
+ int modelIndex = table.convertRowIndexToModel(i);
+ boolean isSelected = (Boolean) model.getValueAt(modelIndex, columnNames.length - 1);
+ if (isSelected) {
+ String[] rowData = new String[model.getColumnCount()];
+ for (int j = 0; j < model.getColumnCount(); j++) {
+ Object value = model.getValueAt(modelIndex, j);
+ if (value instanceof String) {
+ rowData[j] = (String) value;
+ } else if (value instanceof Boolean) {
+ rowData[j] = value.toString();
+ } else {
+ rowData[j] = value == null ? "" : value.toString();
+ }
+ }
+ selectedData[index++] = rowData;
+ System.out.println("Selected Row Data: " + Arrays.toString(rowData));
+ list.add((TCComponent) session.stringToComponent(rowData[rowData.length - 2]));
+ }
+ }
+
+ TCComponent[] tcRev = list.toArray(new TCComponent[list.size()]);
+// TcUtil.CreateProcess(session, tcRev, TcUtil.getPreferenceValue(session, "VF5JSWJSPLC"));
+ if (selectedData.length == 0) {
+ System.out.println("No rows selected");
+ }
+ NewProcessCommand cmd = new NewProcessCommand(AIFUtility.getActiveDesktop(), application, tcRev);
+ cmd.executeModeless();
+ this.dispose();
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsHandler.java
new file mode 100644
index 0000000..7c173d2
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsHandler.java
@@ -0,0 +1,226 @@
+package com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadDialog;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class ApprovalofDocumentsHandler extends AbstractHandler {
+
+ private static final String TCSession = null;
+ /**
+ * 汾ϵ : --> ϵ,,Ƿ mapṹ--> 汾(VF5ccpRevision) :
+ * 汾ϵ({"vf5idgx","VF5nbtz","y"},{"vf5pcgx","VF5procctrl","y"})
+ */
+ private Map> preferenceMap;
+ private TCComponentBOMWindow gxView;
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ TCSession tcSession = (TCSession) application.getSession();
+ boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application,
+ new String[] { "VF5ccpRevision", "VF5bcpRevision", "VF5clRevision" }, "ItemRevision");
+ if (judgeSingleSelectComponent) {
+ String[] enColumnNames = new String[] { "PN Number", "Name", "Owner", "Creation Date", "", "Select" };
+
+ preferenceMap = getPreference(tcSession, "Material_target_Relation");
+ if (preferenceMap != null) {
+ Set keySet = preferenceMap.keySet();
+ for (String key : keySet) {
+ List list = preferenceMap.get(key);
+ System.out.println("rev: " + key);
+ for (String[] gx : list) {
+ System.out.println(Arrays.toString(gx));
+ }
+ }
+
+ TCComponentItemRevision targetRev = (TCComponentItemRevision) application.getTargetComponent();
+
+ List tcList = new ArrayList<>();
+ try {
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession
+ .getTypeComponent("BOMWindow");
+ TCComponentBOMWindow view = winType.create(null);
+
+ TCComponentBOMLine topBomLine = view.setWindowTopLine(targetRev.getItem(), targetRev, null, null);
+ gxView = winType.create(null);
+
+ getAllChildrenBomLine(topBomLine, tcList);
+
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String[] prop = new String[] { "item_id", "object_name", "owning_user", "creation_date", "", "Select" };
+ System.out.println("tcList.length: " + tcList.size());
+ Object[][] data = assignmentValue(prop, tcList);
+
+ ApprovalofDocumentsDialog dialog = new ApprovalofDocumentsDialog(application, "ɸѡ", enColumnNames,
+ data);
+ new Thread(dialog).start();
+ } else {
+ MessageBox.post("The Preference Configuration Is Null !", "error", MessageBox.ERROR);
+ }
+
+ }
+ return null;
+ }
+
+ private Object[][] assignmentValue(String[] prop, List tcList) {
+ try {
+ String[] pop = new String[] { "item_id", "object_name", "owning_user", "creation_date" };
+ Object[][] data = new Object[tcList.size()][];
+ // TODO Auto-generated method stub
+ for (int i = 0; i < tcList.size(); i++) {
+ int length = prop.length;
+ Object[] rowData = new Object[length];
+ TCComponentItemRevision tarRev = tcList.get(i);
+ System.out.println("type ====> " + tarRev.getStringProperty("object_type"));
+
+ String[] properties = tarRev.getProperties(pop);
+ for (int j = 0; j < properties.length; j++) {
+ rowData[j] = properties[j];
+ }
+ rowData[length - 2] = tarRev.getUid();
+ rowData[length - 1] = false;
+
+ System.out.println("properties || " + Arrays.toString(rowData));
+ data[i] = rowData;
+ }
+ return data;
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ return null;
+ }
+
+ public Map> getPreference(TCSession tcSession, String preferenceValue) {
+ String[] preferenceValues = TcUtil.getPreferenceValues(tcSession, preferenceValue);
+ if (preferenceValues != null && !preferenceValue.isEmpty()) {
+ Map> map = new HashMap<>();
+ for (String reference : preferenceValues) {
+ String rev = reference.substring(0, reference.indexOf("-"));
+ String[] gx = reference.substring(reference.indexOf("-") + 1).split("-");
+ if (map.containsKey(rev)) {
+ List list = map.get(rev);
+ list.add(gx);
+ } else {
+ List list = new ArrayList<>();
+ list.add(gx);
+ map.put(rev, list);
+ }
+ }
+ return map;
+ } else {
+ return null;
+ }
+ }
+
+ public void getAllChildrenBomLine(TCComponentBOMLine bomLine, List tcList)
+ throws TCException {
+ System.out.println("ǰBOM1"+bomLine.getItemRevision().getStringProperty("object_name"));
+ System.out.println("hasChildren1 : "+bomLine.hasChildren());
+ if (bomLine.hasChildren()) {
+ System.out.println("ǰBOM2"+bomLine.getItemRevision().getStringProperty("object_name"));
+ System.out.println("hasChildren2 : "+bomLine.hasChildren());
+ AIFComponentContext[] children = bomLine.getChildren();
+ for (AIFComponentContext child : children) {
+ TCComponentBOMLine component = (TCComponentBOMLine) child.getComponent();
+ getAllChildrenBomLine(component, tcList);
+ }
+ }
+ addChildrenBomRev(bomLine, tcList);
+ }
+
+ /**
+ * ӵǰָϵµĶ
+ *
+ * @param bomLine
+ * @param tcList
+ * @throws TCException
+ */
+ public void addChildrenBomRev(TCComponentBOMLine bomLine, List tcList) throws TCException {
+ TCComponentItemRevision itemRevision = bomLine.getItemRevision();
+ String type = itemRevision.getStringProperty("object_type");
+ System.out.println("ǰ ==> " + type);
+ if (preferenceMap.containsKey(type)) {
+ List gxReference = preferenceMap.get(type);
+ for (String[] gxArray : gxReference) {
+ System.out.println("ǰĹϵ :" + gxArray[0] + " || "+ gxArray[1]);
+ if (gxArray != null && gxArray.length == 3 && !gxArray[0].equals("VF5gygx")) {
+ System.out.println("enter 1");
+ TCComponent[] gxComponents = itemRevision.getRelatedComponents(gxArray[0]);
+
+ for (TCComponent component : gxComponents) {
+ String gxType = "";
+ TCComponentItemRevision targetRev = null;
+ if (component instanceof TCComponentItem) {
+ gxType = component.getStringProperty("object_type");
+ targetRev = ((TCComponentItem) component).getLatestItemRevision();
+ } else if (component instanceof TCComponentItemRevision) {
+ targetRev = (TCComponentItemRevision) component;
+ gxType = targetRev.getItem().getStringProperty("object_type");
+ }
+
+ System.out.println("ǰϵеĶ : " + gxType);
+ if (gxType.equals(gxArray[1])) {
+ System.out.println("inner1");
+ TCComponent[] publishStatus = targetRev.getTCProperty("release_status_list")
+ .getReferenceValueArray();
+ if ((publishStatus == null || publishStatus.length == 0) && gxArray[2].equals("y")) {
+ System.out.println("add");
+ tcList.add(targetRev);
+ }
+ }
+ }
+ } else if (gxArray != null && gxArray.length == 3 && gxArray[0].equals("VF5gygx")) {
+ // &&
+ System.out.println("enter 2");
+ TCComponent[] gyItems = itemRevision.getRelatedComponents(gxArray[0]);
+ for (TCComponent gyItem : gyItems) {
+ TCComponentItemRevision gyRev = ((TCComponentItem) gyItem).getLatestItemRevision();
+ if (gxArray[2].equals("y")) {
+ tcList.add(gyRev);
+ System.out.println("ӹն");
+ }
+ TCComponentBOMLine gyBom = gxView.setWindowTopLine((TCComponentItem) gyItem, gyRev, null, null);
+ if (gyBom.hasChildren()) {
+ AIFComponentContext[] gyChildren = gyBom.getChildren();
+ for (AIFComponentContext gyChild : gyChildren) {
+ TCComponentBOMLine gyChildBom = (TCComponentBOMLine) gyChild.getComponent();
+ getAllChildrenBomLine(gyChildBom, tcList);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/exception/CustomException.java b/src/com/connor/ferrorTech/metal/exception/CustomException.java
new file mode 100644
index 0000000..5ae534b
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/exception/CustomException.java
@@ -0,0 +1,10 @@
+package com.connor.ferrorTech.metal.exception;
+
+@SuppressWarnings("serial")
+public class CustomException extends RuntimeException {
+
+ public CustomException(String message) {
+ super(message);
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/importMaterial/ImportMaterialDialog.java b/src/com/connor/ferrorTech/metal/importMaterial/ImportMaterialDialog.java
new file mode 100644
index 0000000..0904c8b
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/importMaterial/ImportMaterialDialog.java
@@ -0,0 +1,839 @@
+package com.connor.ferrorTech.metal.importMaterial;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Label;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+import javax.swing.border.EmptyBorder;
+
+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.xssf.usermodel.XSSFWorkbook;
+import org.json.JSONObject;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.aif.AbstractAIFUIApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.kernel.TCTypeService;
+import com.teamcenter.rac.util.MessageBox;
+import com.teamcenter.rac.util.Registry;
+
+public class ImportMaterialDialog extends AbstractAIFDialog {
+
+ Registry reg = Registry.getRegistry(this);
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private AbstractAIFUIApplication application;
+ private TCSession session;
+ private String url;
+ private String sapCheck;
+ private String errorInfo;
+
+ private JPanel contentPane;
+ private JTextField textField;
+ private File[] selectedFile;
+ private TCComponent target;
+
+ private Map wlbmMap = new HashMap<>();
+ private Map gxwlbmMap = new HashMap<>();
+ private Map newObjectMap = new HashMap<>();
+ private Map topMap = new HashMap<>();
+ private Map cjCodeMap = new HashMap<>();
+ private Map> excelData = new HashMap<>();
+
+ public ImportMaterialDialog(AbstractAIFApplication application, TCComponent target) {
+ super();
+ this.application = (AbstractAIFUIApplication) application;
+ this.session = (TCSession) application.getSession();
+ this.target = target;
+ }
+
+ @Override
+ public void run() {
+ initUI();
+
+ }
+
+ public void initUI() {
+ setTitle(reg.getString("ImportMaterialDialog.0")); //$NON-NLS-1$
+ setResizable(true);
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ setBounds(100, 100, 500, 120);
+ contentPane = new JPanel();
+ contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
+ setContentPane(contentPane);
+ contentPane.setLayout(null);
+
+ JLabel lblNewLabel = new JLabel(reg.getString("ImportMaterialDialog.1")); //$NON-NLS-1$
+ lblNewLabel.setBounds(10, 10, 150, 15);
+ contentPane.add(lblNewLabel);
+
+ textField = new JTextField();
+ textField.setBounds(160, 7, 180, 21);
+ contentPane.add(textField);
+ textField.setColumns(10);
+
+ JButton btnNewButton = new JButton(reg.getString("ImportMaterialDialog.2"));
+ btnNewButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ // ½һļѡ
+ JFileChooser jFileChooser = new JFileChooser();
+ jFileChooser.setMultiSelectionEnabled(true);
+ // ļѡ
+ int showOpenDialog = jFileChooser.showOpenDialog(null);
+ // ļѡ
+ if (showOpenDialog == jFileChooser.APPROVE_OPTION) {
+
+ selectedFile = jFileChooser.getSelectedFiles();
+ String fileName = "";
+ for (File file : selectedFile) {
+ fileName += file.getName() + ";";
+ }
+ textField.setText(fileName);
+ }
+ }
+ });
+ btnNewButton.setBounds(360, 6, 100, 23);
+ contentPane.add(btnNewButton);
+
+ JButton btnNewButton_1 = new JButton(reg.getString("ImportMaterialDialog.8")); //$NON-NLS-1$
+ btnNewButton_1.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ dispose();
+ }
+ });
+ btnNewButton_1.setBounds(250, 38, 100, 21);
+ contentPane.add(btnNewButton_1);
+
+ JButton btnNewButton_1_1 = new JButton(reg.getString("ImportMaterialDialog.3")); //$NON-NLS-1$
+ btnNewButton_1_1.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ dispose();
+ WaitingDialog dia = new WaitingDialog(application.getDesktop(), "INFOMATION",
+ reg.getString("ImportMaterialDialog.10")); //$NON-NLS-1$
+ dia.setVisible(true);
+ if (target != null) {
+ if (selectedFile.length > 0) {
+ // ȡѡSAP_urlֵ
+ String[] sapUrls = session.getPreferenceService().getStringValues("SAP_url");
+ if (sapUrls != null) {
+ // ȡsap·
+ url = sapUrls[0];
+ // ȡӿ֤
+ sapCheck = session.getPreferenceService().getStringValue("SAP_check");
+ if (sapCheck != null) {
+ boolean comfireFlag = comfire(selectedFile[0]);
+ dia.setVisible(false);
+ if (comfireFlag) {
+ MessageBox.post(reg.getString("ImportMaterialDialog.11"),
+ reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
+ } else {
+ MessageBox.post(reg.getString("ImportMaterialDialog.12"),
+ reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
+ }
+ } else {
+ dia.setVisible(false);
+ MessageBox.post(reg.getString("ImportMaterialDialog.5"),
+ reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
+ }
+ } else {
+ dia.setVisible(false);
+ MessageBox.post(reg.getString("ImportMaterialDialog.4"),
+ reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
+ }
+ }
+ } else {
+ dia.setVisible(false);
+ MessageBox.post(reg.getString("ImportMaterialDialog.4"), reg.getString("ImportMaterialHandler.0"),
+ MessageBox.INFORMATION);
+ }
+ }
+ });
+ btnNewButton_1_1.setBounds(100, 38, 100, 21);
+ contentPane.add(btnNewButton_1_1);
+
+ // д
+ setLocationRelativeTo(null);
+ setVisible(true);
+ }
+
+ private boolean comfire(File file) {
+ // ȡϴļ
+ excelData = readExcelData(file);
+ if (excelData != null && excelData.size() > 0) {
+ // ͨsapӿڻȡϢ
+ Map materialInfoBySap = materialInfoBySap(excelData);
+
+ Map> materialBOMMap = materialBOMNum(excelData);
+ if (materialInfoBySap != null && materialInfoBySap.size() > 0) {
+ try {
+ // ѯǷ
+ queryMaterial(excelData, materialInfoBySap);
+ System.out.println("BOM:" + materialBOMMap.size());
+ boolean flag = false;
+ // BOM
+ for (String str : materialBOMMap.keySet()) {
+ System.out.println("BOM㼶:" + str);
+ if (createMaterialBOM(materialBOMMap.get(str), excelData, str)) {
+ flag = true;
+ } else {
+ flag = false;
+ }
+ }
+ findFolder(target, excelData);
+ return flag;
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ } else {
+ int length = errorInfo.length();
+ if (length > 0) {
+ String str = errorInfo.substring(0, length - 1);
+ MessageBox.post(
+ reg.getString("ImportMaterialDialog.13") + str + reg.getString("ImportMaterialDialog.14"),
+ reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
+ errorInfo = "";
+ return false;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * ҪBOM
+ *
+ * @param excelData
+ */
+ private Map> materialBOMNum(Map> excelData) {
+ Map> bomMap = new HashMap<>();
+ Map bomChildrenMap = new HashMap<>();
+ for (String key : excelData.keySet()) {
+ // ȡ㼶
+ String cjh = excelData.get(key).get(0);
+ // ݶŷָ
+ String[] split = cjh.split("\\.");
+ if (split.length > 1) {
+ if (bomMap.containsKey(split[0])) {
+ Map map = bomMap.get(split[0]);
+ map.put(cjh, excelData.get(key).get(1));
+ }
+ } else {
+ bomChildrenMap.put(cjh, excelData.get(key).get(1));
+ if (split.length == 1) {
+ bomMap.put(cjh, bomChildrenMap);
+ }
+ }
+ }
+ return bomMap;
+ }
+
+ /**
+ * BOM
+ *
+ * @param excelData
+ * @throws TCException
+ */
+ private boolean createMaterialBOM(Map data, Map> excelData, String code)
+ throws TCException {
+ boolean flag = true;
+ TCTypeService service = session.getTypeService();
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
+ TCComponentBOMWindow win = winType.create(null);
+
+ System.out.println("bom:" + code);
+ String[] split = code.split("\\.");
+ if (!code.contains(".")) {
+ String materialCode = cjCodeMap.get(code);
+ System.out.println("ϱ:" + materialCode);
+ if (gxwlbmMap.containsKey(materialCode)) {
+ TCComponent component = gxwlbmMap.get(materialCode);
+ try {
+ TCComponentItemRevision itemRevision = (TCComponentItemRevision) component;
+ // BOMͼ
+ TCComponentBOMLine topLine = win.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null);
+ // ȡӲ
+ AIFComponentContext[] children = topLine.getChildren();
+ System.out.println("Ӳ:" + children.length);
+ if (children.length > 0) {
+ for (AIFComponentContext child : children) {
+ topLine.remove("", (TCComponent) child.getComponent());
+ }
+ }
+ // ٴδBOM
+ for (String code2 : data.keySet()) {
+ String[] split2 = code2.split("\\.");
+ System.out.println(":" + code);
+ System.out.println("Ӳ:" + code2);
+ String childrenStr = code + ".";
+ System.out.println("Ӳ:" + childrenStr);
+ if (code2.contains(childrenStr)) {
+ if (split2.length == (split.length + 1) && code2.startsWith(childrenStr)) {
+ flag = createMaterialBOMLine(data, excelData, topLine, code2);
+ }
+ }
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ }
+ } else if (newObjectMap.containsKey(materialCode)) {
+ TCComponentItem item = newObjectMap.get(materialCode);
+ try {
+ // BOMͼ
+ TCComponentBOMLine topLine = win.setWindowTopLine(item, item.getLatestItemRevision(), null, null);
+ // BOM
+ for (String code2 : data.keySet()) {
+ String[] split2 = code2.split("\\.");
+ String childrenStr = code + ".";
+ if (code2.contains(childrenStr)) {
+ if (split2.length == (split.length + 1) && code2.startsWith(childrenStr)) {
+ flag = createMaterialBOMLine(data, excelData, topLine, code2);
+ }
+ }
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ }
+ }
+ }
+ win.save();// ᴥ
+ win.refresh();
+ win.close();
+ return flag;
+ }
+
+ /**
+ * Ӳ
+ *
+ * @param data
+ * @param excelData
+ * @param topLine
+ * @param num
+ * @param str
+ * @throws TCException
+ */
+ private boolean createMaterialBOMLine(Map data, Map> excelData,
+ TCComponentBOMLine topLine, String str) throws TCException {
+ String code = str;
+ String[] split = code.split("\\.");
+ if (code.equals(str)) {
+ String materialCode = cjCodeMap.get(code);
+ String vf5jbyl = "";
+ String vf5sl = "";
+ for (String str2 : excelData.keySet()) {
+ String num2 = excelData.get(str2).get(0);
+ if (num2.equals(code)) {
+ vf5jbyl = excelData.get(str2).get(6);
+ vf5sl = excelData.get(str2).get(7);
+ }
+ }
+ TCComponentItem item = null;
+ if (gxwlbmMap.containsKey(materialCode)) {
+ TCComponent component = gxwlbmMap.get(materialCode);
+ item = ((TCComponentItemRevision) component).getItem();
+ } else if (newObjectMap.containsKey(materialCode)) {
+ item = newObjectMap.get(materialCode);
+ }
+ try {
+ if (topLine != null) {
+ System.out.println("Ӳitem:" + item.getStringProperty("object_name"));
+ TCComponentBOMLine wuLiaoChildLine = topLine.add(item, item.getLatestItemRevision(), null, false,
+ "");
+ // ȡӲ
+ AIFComponentContext[] children = wuLiaoChildLine.getChildren();
+ if (children.length > 0) {
+ for (AIFComponentContext child : children) {
+ topLine.remove("", (TCComponent) child.getComponent());
+ }
+ }
+ wuLiaoChildLine.setProperty("VF5jbsl", vf5jbyl);
+ wuLiaoChildLine.setProperty("VF5sl", vf5sl);
+ // BOM
+ for (String code2 : data.keySet()) {
+ String[] split2 = code2.split("\\.");
+ String childrenStr = code + ".";
+ if (code2.contains(childrenStr)) {
+ if (split2.length == (split.length + 1) && code2.startsWith(childrenStr)) {
+ createMaterialBOMLine(data, excelData, wuLiaoChildLine, code2);
+ }
+ }
+ }
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * ȡϴexcelļ
+ *
+ * @param file
+ * @return
+ */
+ private Map> readExcelData(File file) {
+ Map> tableDataMap = new HashMap>();
+ try (FileInputStream fileInputStream = new FileInputStream(selectedFile[0]);
+ Workbook workbook = new XSSFWorkbook(fileInputStream)) {
+
+ Sheet sheet = workbook.getSheetAt(0); // ȡһ
+
+ // ȡ
+ int lastRowNum = sheet.getLastRowNum();
+ int firstRowNum = sheet.getFirstRowNum();
+ int num = lastRowNum - firstRowNum;
+ System.out.println(":" + num);
+ int key = 0;
+ if (num >= 6) {
+ for (int i = 5; i <= num; i++) {
+ Row row = sheet.getRow(i);
+ // жǷΪ
+ if (!isRowEmpty(row)) {
+ List rowList = new ArrayList();
+ if (sheet.getRow(i) != null) {
+ // ȡԪ
+ int lastCellNum = sheet.getRow(i).getLastCellNum();
+ for (int j = 0; j < lastCellNum; j++) {
+ Cell cell = sheet.getRow(i).getCell(j);
+ String value = "";
+ if (cell != null) {
+ // ݲַͬͣʽ
+ switch (cell.getCellType()) {
+ case STRING:
+ value = cell.getStringCellValue() != null ? cell.getStringCellValue() : "";
+ break;
+ case NUMERIC:
+ value = String.valueOf(cell.getNumericCellValue()) != null
+ ? String.valueOf(cell.getNumericCellValue())
+ : "";
+ if (value.endsWith(".0")) {
+ value = value.substring(0, value.lastIndexOf("."));
+ }
+ break;
+ case BOOLEAN:
+ value = String.valueOf(cell.getBooleanCellValue()) != null
+ ? String.valueOf(cell.getBooleanCellValue())
+ : "";
+ break;
+ case FORMULA:
+ value = String.valueOf(cell.getCellFormula()) != null
+ ? String.valueOf(cell.getCellFormula())
+ : "";
+ break;
+ default:
+ break;
+ }
+ }
+ if (value != null || value != "") {
+ if (value.contains(",")) {
+ value = value.replace(",", ";");
+ }
+ }
+ rowList.add(value);
+ }
+ }
+ System.out.println(":" + rowList);
+ if (rowList.get(0) == null || rowList.get(0) == "" || rowList.get(1) == null
+ || rowList.get(1) == "") {
+ MessageBox.post(reg.getString("ImportMaterialDialog.7"),
+ reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
+ return null;
+ }
+ tableDataMap.put(String.valueOf(key), rowList);
+ key++;
+ }
+ }
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ return tableDataMap;
+ }
+
+ /**
+ * жǷΪ
+ *
+ * @param row
+ * @return
+ */
+ private boolean isRowEmpty(Row row) {
+ if (row == null) {
+ return true;
+ }
+ for (int c = 0; c < row.getLastCellNum(); c++) {
+ if (row.getCell(c) != null && row.getCell(c).toString().trim().length() > 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * ȡƷļв϶Ӧλ
+ *
+ * @param excelData
+ * @throws Exception
+ */
+ private void findFolder(TCComponent target, Map> excelData) throws Exception {
+ TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder();
+ // ȡѡļµļ
+ TCComponent[] relatedFolders = target.getRelatedComponents("contents");
+ if (relatedFolders.length > 0) {
+ Map folders = new HashMap<>();
+ for (int i = 0; i < relatedFolders.length; i++) {
+ String name = relatedFolders[i].getStringProperty("object_name");
+ System.out.println("name:" + name);
+ folders.put(name, relatedFolders[i]);
+ }
+ for (String key : topMap.keySet()) {
+ String name = topMap.get(key);
+ if (folders.containsKey(name)) {
+ TCComponent component = folders.get(name);
+ TCComponent[] relatedComponents = component.getRelatedComponents("contents");
+ TCComponent comp = gxwlbmMap.get(cjCodeMap.get(key));
+ for (TCComponent com : relatedComponents) {
+ String objectName = com.getStringProperty("object_name");
+ if (objectName.equals("MATERIAL AND BOM")) {
+ TCComponent[] relatedComponents2 = com.getRelatedComponents("contents");
+ List ids = new ArrayList();
+ for (TCComponent com2 : relatedComponents2) {
+ ids.add(com2.getStringProperty("item_id"));
+ }
+ if (newObjectMap.containsKey(cjCodeMap.get(key))) {
+ String id = newObjectMap.get(cjCodeMap.get(key)).getStringProperty("item_id");
+ if (!ids.contains(id)) {
+ com.add("contents", newObjectMap.get(cjCodeMap.get(key)));
+ }
+ } else if (gxwlbmMap.containsKey(cjCodeMap.get(key))) {
+ String id = (((TCComponentItemRevision) comp)).getStringProperty("item_id");
+ if (!ids.contains(id)) {
+ com.add("contents", ((TCComponentItemRevision) comp).getItem());
+ }
+ } else if (wlbmMap.containsKey(cjCodeMap.get(key))) {
+ String id = (((TCComponentItemRevision) comp).getStringProperty("item_id"));
+ if (!ids.contains(id)) {
+ com.add("contents", ((TCComponentItemRevision) comp).getItem());
+ }
+ }
+ }
+ }
+ } else {
+ TCComponent[] relatedComponents = newStuffFolder.getRelatedComponents("contents");
+ List ids = new ArrayList();
+ for (TCComponent com2 : relatedComponents) {
+ ids.add(com2.getStringProperty("item_id"));
+ }
+ if (newObjectMap.containsKey(cjCodeMap.get(key))) {
+ String id = newObjectMap.get(cjCodeMap.get(key)).getStringProperty("item_id");
+ if (!ids.contains(id)) {
+ newStuffFolder.add("contents", newObjectMap.get(cjCodeMap.get(key)));
+ }
+ } else if (gxwlbmMap.containsKey(cjCodeMap.get(key))) {
+ String id = gxwlbmMap.get(cjCodeMap.get(key)).getStringProperty("item_id");
+ if (!ids.contains(id)) {
+ newStuffFolder.add("contents",
+ ((TCComponentItemRevision) gxwlbmMap.get(cjCodeMap.get(key))).getItem());
+ }
+ } else if (wlbmMap.containsKey(cjCodeMap.get(key))) {
+ String id = gxwlbmMap.get(cjCodeMap.get(key)).getStringProperty("item_id");
+ if (!ids.contains(id)) {
+ newStuffFolder.add("contents",
+ ((TCComponentItemRevision) gxwlbmMap.get(cjCodeMap.get(key))).getItem());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * ͨSAPӿڻȡϢ
+ */
+ private Map materialInfoBySap(Map> excelData) {
+ Map resultMap = new HashMap<>();
+ // ȡPN
+ for (String key : excelData.keySet()) {
+ if (excelData.get(key).get(1) != null) {
+ MaterialPropertyBean materiaPorptry = new MaterialPropertyBean();
+ // ͨӿڻȡϢ
+ String value = sapConnect("Product", excelData.get(key).get(1));
+ System.out.println("Ϣjson:" + value);
+ if (value != null) {
+ JSONObject jsonObject = new JSONObject(value);
+ materiaPorptry.setVf5wlbm(jsonObject.getString("Product"));
+ if ("FERT".equals(jsonObject.getString("ProductType"))) {
+ materiaPorptry.setMaterialType("VF5ccp");
+ } else if ("HALB".equals(jsonObject.getString("ProductType"))) {
+ materiaPorptry.setMaterialType("VF5bcp");
+ } else if ("ROH".equals(jsonObject.getString("ProductType"))) {
+ materiaPorptry.setMaterialType("VF5cl");
+ }
+ String dw = jsonObject.getString("BaseUnit");
+ if("ST".equals(dw)) {
+ materiaPorptry.setVf5dw("PC");
+ }else {
+ materiaPorptry.setVf5dw(jsonObject.getString("BaseUnit"));
+ }
+ materiaPorptry.setVf5zl(String.valueOf(jsonObject.getDouble("GrossWeight")));
+ materiaPorptry.setVf5sjzl(String.valueOf(jsonObject.getDouble("NetWeight")));
+ }
+ // Ϣ
+ String value3 = sapConnect(
+ "ProductDescription(Product='" + excelData.get(key).get(1) + "',Language='EN')", "");
+ if (value3 != null) {
+ System.out.println("json:" + value3);
+ JSONObject jsonObject = new JSONObject(value3);
+ materiaPorptry.setObjectName(jsonObject.getString("ProductDescription"));
+ }
+ // ϲɹ
+ String value2 = sapConnect(
+ "ProductPlantSupplyPlanning(Product='" + excelData.get(key).get(1) + "',Plant='5410')", "");
+ if (value2 != null) {
+ System.out.println("ϲɹjson:" + value2);
+ JSONObject jsonObject = new JSONObject(value2);
+ materiaPorptry.setVf5jhmrsx(jsonObject.getString("ProcurementType"));
+// if ("E".equals(jsonObject.getString("ProcurementType"))) {
+// materiaPorptry.setVf5jhmrsx("In-House Production");
+// } else if ("F".equals(jsonObject.getString("ProcurementType"))) {
+// materiaPorptry.setVf5jhmrsx("External Procurement");
+// } else if ("X".equals(jsonObject.getString("ProcurementType"))) {
+// materiaPorptry.setVf5jhmrsx("Both Procurement Type");
+// }
+ materiaPorptry.setVf5jhmrsx(jsonObject.getString("ProcurementType"));
+ }
+ String materialType = materiaPorptry.getMaterialType();
+ if (materialType != null) {
+ resultMap.put(excelData.get(key).get(1), materiaPorptry);
+ } else {
+ if (errorInfo == null) {
+ errorInfo = excelData.get(key).get(1) + ",";
+ } else {
+ errorInfo = errorInfo + excelData.get(key).get(1) + ",";
+ }
+ }
+ }
+ }
+ System.out.println("resultMapĴС:" + resultMap.size());
+ return resultMap;
+ }
+
+ /**
+ * ϱѯ϶Ƿ
+ *
+ * @param excelData
+ * @throws Exception
+ */
+ private void queryMaterial(Map> excelData, Map materialInfoMap)
+ throws Exception {
+ List pnNum = new ArrayList();
+ Map khthMap = new HashMap<>();
+ // ȡPN
+ for (String key : excelData.keySet()) {
+ pnNum.add(excelData.get(key).get(1));
+ khthMap.put(excelData.get(key).get(1), excelData.get(key).get(2));
+ cjCodeMap.put(excelData.get(key).get(0), excelData.get(key).get(1));
+ if (!excelData.get(key).get(0).contains(".")) {
+ topMap.put(excelData.get(key).get(0), excelData.get(key).get(2));
+ }
+ }
+ System.out.println("pnNum:" + pnNum);
+ String str = String.join(";", pnNum);
+ // ݲѯѯ
+ TCComponent[] search = session.search("MU_Find Part", new String[] { "vf5wlbm" }, new String[] { str });
+ System.out.println("ѯ:" + search.length);
+ if (search.length > 0) {
+ for (TCComponent com : search) {
+ TCComponent wlbmForm = com.getRelatedComponents("IMAN_master_form_rev")[0];
+ for (int i = 0; i < pnNum.size(); i++) {
+ if ((wlbmForm.getStringProperty("vf5wlbm")).equals(pnNum.get(i))) {
+ pnNum.remove(i);
+ }
+ }
+ if (com.getRelatedComponents("release_status_list").length > 0) {
+ wlbmMap.put(wlbmForm.getStringProperty("vf5wlbm"), com);
+ } else {
+ gxwlbmMap.put(wlbmForm.getStringProperty("vf5wlbm"), com);
+ }
+ }
+ }
+ System.out.println("gxwlbmMap:" + gxwlbmMap.size());
+ if (gxwlbmMap.size() > 0) {
+ for (String key : gxwlbmMap.keySet()) {
+ if (materialInfoMap.containsKey(key)) {
+ // ȡѴڵĶ
+ TCComponent existObj = gxwlbmMap.get(key).getRelatedComponents("IMAN_master_form_rev")[0];
+ // ȡSAPӿڷصϢ
+ MaterialPropertyBean propertyBean = materialInfoMap.get(key);
+ // ȡֵ
+ existObj.setStringProperty("vf5khth", khthMap.get(key));
+ existObj.setStringProperty("vf5dw", propertyBean.getVf5dw());
+ existObj.setStringProperty("vf5zl", propertyBean.getVf5zl());
+ existObj.setStringProperty("vf5sjzl", propertyBean.getVf5sjzl());
+ existObj.setStringProperty("vf5wlbm", propertyBean.getVf5wlbm());
+ existObj.setStringProperty("vf5jhmrsx", propertyBean.getVf5jhmrsx());
+ }
+ }
+ }
+
+ if (pnNum.size() > 0) {
+ for (String code : pnNum) {
+ if (materialInfoMap.containsKey(code)) {
+ TCComponentItemType itemType = (TCComponentItemType) session
+ .getTypeComponent(materialInfoMap.get(code).getMaterialType());
+ String itemRev = itemType.getNewRev(null);// Ĭ
+ String itemID = itemType.getNewID();
+ // ȡSAPӿڷصϢ
+ MaterialPropertyBean propertyBean = materialInfoMap.get(code);
+ System.out.println("½:" + propertyBean.getMaterialType());
+ TCComponentItem item = itemType.create(itemID, itemRev, propertyBean.getMaterialType(),
+ propertyBean.getObjectName(), "", null);
+ System.out.println("½:" + item.getStringProperty("item_id"));
+ // ȡ汾
+ TCComponent component = item.getLatestItemRevision()
+ .getRelatedComponents("IMAN_master_form_rev")[0];
+ component.setStringProperty("vf5khth", khthMap.get(code));
+ component.setStringProperty("vf5dw", propertyBean.getVf5dw());
+ component.setStringProperty("vf5zl", propertyBean.getVf5zl());
+ component.setStringProperty("vf5sjzl", propertyBean.getVf5sjzl());
+ component.setStringProperty("vf5wlbm", propertyBean.getVf5wlbm());
+ component.setStringProperty("vf5jhmrsx", propertyBean.getVf5jhmrsx());
+ newObjectMap.put(code, item);
+ }
+ }
+ }
+ }
+
+ private String sapConnect(String param, String code) {
+ String result = null;
+ HttpsURLConnection connection = null;
+ try {
+ String[] split = sapCheck.split(":");
+ // ֤û
+ String basicAuth = "Basic "
+ + new String(Base64.getEncoder().encode((split[0] + ":" + split[1]).getBytes()));
+
+ // URL
+ URL urlObj = null;
+ if (code != null && code != "") {
+ urlObj = new URL(url + "/" + param + "/" + code);
+ } else {
+ urlObj = new URL(url + "/" + param);
+ }
+
+ //
+ connection = (HttpsURLConnection) urlObj.openConnection();
+ // ֤ͷ
+ connection.setRequestProperty("Authorization", basicAuth);
+
+ // ΪGET
+ connection.setRequestMethod("GET");
+
+ // Ӧ
+ int responseCode = connection.getResponseCode();
+ System.out.println("Response Code: " + responseCode);
+
+ // ȡӦ
+ BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ String inputLine;
+ StringBuilder response = new StringBuilder();
+
+ while ((inputLine = in.readLine()) != null) {
+ response.append(inputLine);
+ }
+ in.close();
+
+ result = response.toString();
+ // ӡ
+ System.out.println(response.toString());
+ } catch (Exception e) {
+ e.getStackTrace();
+ System.out.println(e.getStackTrace());
+ } finally {
+ // ر
+ connection.disconnect();
+ }
+ return result;
+
+ }
+}
+
+class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog {
+ private static final long serialVersionUID = 1L;
+ public JPanel panel;
+ JProgressBar progressBar = null;
+
+ public WaitingDialog(Frame arg0, String title, String message) {
+ super(arg0, title);
+ this.setModal(false);
+
+ panel = new JPanel(new BorderLayout());
+
+ /*
+ * JLabel label = new JLabel(message); System.out.println("message:"+message);
+ * System.out.println("label:"+label); panel.add(label);
+ */
+
+ progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
+ progressBar.setVisible(true);
+ progressBar.setIndeterminate(true);
+
+ panel.add(BorderLayout.CENTER, new Label(message));
+ panel.add(BorderLayout.SOUTH, progressBar);
+
+ panel.setPreferredSize(new Dimension(350, 60));
+
+ this.getContentPane().add(panel);
+
+ centerToScreen();
+
+ pack();
+
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/importMaterial/ImportMaterialHandler.java b/src/com/connor/ferrorTech/metal/importMaterial/ImportMaterialHandler.java
new file mode 100644
index 0000000..df53321
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/importMaterial/ImportMaterialHandler.java
@@ -0,0 +1,34 @@
+package com.connor.ferrorTech.metal.importMaterial;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.util.MessageBox;
+import com.teamcenter.rac.util.Registry;
+
+public class ImportMaterialHandler extends AbstractHandler{
+ Registry reg=Registry.getRegistry(this);
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ // TODO Auto-generated method stub
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ //ȡѡеĶ
+ TCComponent selectObject=(TCComponent) application.getTargetComponent();
+ System.out.println("ѡж:" + selectObject.getType());
+ if(!selectObject.getType().equals("VF5NPI")) {
+ MessageBox.post(reg.getString("ImportMaterialHandler.1"), reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
+ return null;
+ }
+ ImportMaterialDialog action = new ImportMaterialDialog(application,selectObject);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/importMaterial/MaterialPropertyBean.java b/src/com/connor/ferrorTech/metal/importMaterial/MaterialPropertyBean.java
new file mode 100644
index 0000000..173d3f3
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/importMaterial/MaterialPropertyBean.java
@@ -0,0 +1,85 @@
+package com.connor.ferrorTech.metal.importMaterial;
+
+public class MaterialPropertyBean {
+ private String vf5wlbm;
+ private String materialType;
+ private String itemRevisionId;
+ private String objectName;
+ private String vf5dw;
+ private String vf5sjzl;
+ private String vf5zl;
+ private String vf5jhmrsx;
+
+ public String getVf5wlbm() {
+ return vf5wlbm;
+ }
+
+ public void setVf5wlbm(String vf5wlbm) {
+ this.vf5wlbm = vf5wlbm;
+ }
+
+ public String getMaterialType() {
+ return materialType;
+ }
+
+ public void setMaterialType(String materialType) {
+ this.materialType = materialType;
+ }
+
+ public String getItemRevisionId() {
+ return itemRevisionId;
+ }
+
+ public void setItemRevisionId(String itemRevisionId) {
+ this.itemRevisionId = itemRevisionId;
+ }
+
+ public String getObjectName() {
+ return objectName;
+ }
+
+ public void setObjectName(String objectName) {
+ this.objectName = objectName;
+ }
+
+ public String getVf5dw() {
+ return vf5dw;
+ }
+
+ public void setVf5dw(String vf5dw) {
+ this.vf5dw = vf5dw;
+ }
+
+ public String getVf5sjzl() {
+ return vf5sjzl;
+ }
+
+ public void setVf5sjzl(String vf5sjzl) {
+ this.vf5sjzl = vf5sjzl;
+ }
+
+ public String getVf5zl() {
+ return vf5zl;
+ }
+
+ public void setVf5zl(String vf5zl) {
+ this.vf5zl = vf5zl;
+ }
+
+ public String getVf5jhmrsx() {
+ return vf5jhmrsx;
+ }
+
+ public void setVf5jhmrsx(String vf5jhmrsx) {
+ this.vf5jhmrsx = vf5jhmrsx;
+ }
+
+ @Override
+ public String toString() {
+ return "MaterialPropertyBean [vf5wlbm=" + vf5wlbm + ", materialType=" + materialType + ", itemRevisionId="
+ + itemRevisionId + ", objectName=" + objectName + ", vf5dw=" + vf5dw + ", vf5sjzl=" + vf5sjzl
+ + ", vf5zl=" + vf5zl + ", vf5jhmrsx=" + vf5jhmrsx + "]";
+ }
+
+
+}
diff --git a/src/com/connor/ferrorTech/metal/importMaterial/ProgressBar.java b/src/com/connor/ferrorTech/metal/importMaterial/ProgressBar.java
new file mode 100644
index 0000000..a4393dd
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/importMaterial/ProgressBar.java
@@ -0,0 +1,138 @@
+package com.connor.ferrorTech.metal.importMaterial;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.KeyStroke;
+
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+
+@SuppressWarnings("serial")
+public class ProgressBar extends AbstractAIFDialog {
+
+ private JLabel messageLabel;
+
+ private JProgressBar progressBar;
+
+ private boolean showBar = false;
+
+ public ProgressBar(Dimension dim) {
+ super(false);
+ initUI(dim);
+ }
+
+ public ProgressBar(AbstractAIFDialog pd, Dimension dimension) {
+ super(pd, false);
+ initUI(dimension);
+ }
+
+ public ProgressBar(Dimension dim,boolean showBar) {
+ super(false);
+ this.showBar=showBar;
+ initUI(dim);
+ }
+
+ public ProgressBar(AbstractAIFDialog pd, Dimension dimension,boolean showBar) {
+ super(pd, false);
+ this.showBar=showBar;
+ initUI(dimension);
+ }
+
+ public ProgressBar(JFrame pd, Dimension dimension,boolean showBar) {
+ super(pd, false);
+ this.showBar=showBar;
+ initUI(dimension);
+ }
+ private void initUI(Dimension dim) {
+ this.setLayout(new BorderLayout(0, 0));
+ this.setUndecorated(true);
+ JPanel main = new JPanel(new GridBagLayout());
+ GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0);
+ main.setBackground(new Color(53, 53, 53));
+ if (dim != null) {
+ this.setPreferredSize(dim);
+ } else {
+ this.setPreferredSize(new Dimension(200, 40));
+ }
+ messageLabel = new JLabel(" ");
+ messageLabel.setForeground(Color.white);
+ progressBar = new JProgressBar();
+ progressBar.setForeground(Color.black);
+ progressBar.setIndeterminate(true);
+ main.add(messageLabel, s);
+ s.gridy++;
+ s.insets = new Insets(0, 5, 2, 5);
+ if(showBar) {
+ main.add(progressBar, s);
+ }
+ this.add(BorderLayout.CENTER, main);
+ KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
+ this.getRootPane().registerKeyboardAction(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ disposeDialog();
+ }
+ }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
+ MouseAdapter ma = new MouseAdapter() {
+ private Point pressPoint = new Point();
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ pressPoint = e.getPoint();
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ pressPoint = new Point();
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ Rectangle r = ProgressBar.this.getBounds();
+ setLocation(r.x + (e.getX() - pressPoint.x), r.y + (e.getY() - pressPoint.y));
+ }
+ };
+ this.addMouseListener(ma);
+ this.addMouseMotionListener(ma);
+ }
+
+ public void setText(String message) {
+ messageLabel.setText(message);
+ }
+
+ public void setIndeterminate(boolean b) {
+ progressBar.setIndeterminate(b);
+ }
+
+ public void setText(String txt, int percent) {
+ setText(txt);
+ if (percent > progressBar.getMaximum()) {
+ percent = progressBar.getMaximum();
+ }
+ progressBar.setValue(percent);
+ }
+
+ public void cancel() {
+ disposeDialog();
+ }
+
+ public void startProgress() {
+ showDialog();
+ }
+}
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/importMaterial/importMaterial_locale.properties b/src/com/connor/ferrorTech/metal/importMaterial/importMaterial_locale.properties
new file mode 100644
index 0000000..598a25a
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/importMaterial/importMaterial_locale.properties
@@ -0,0 +1,17 @@
+ImportMaterialDialog.0=Please select the upload path
+ImportMaterialDialog.1=Local upload path:
+ImportMaterialDialog.2=Select
+ImportMaterialDialog.3=Confirm
+ImportMaterialDialog.8=Cancel
+ImportMaterialHandler.0=Info
+ImportMaterialHandler.1=The selected object type is incorrect!
+ImportMaterialDialog.4=Please select Upload file\uff01
+ImportMaterialDialog.5=Preference [SAP_check] is not configured\uff01
+ImportMaterialDialog.6=Preference [SAP_url] is not configured\uff01
+ImportMaterialDialog.7=The level or PN number in the uploaded file is empty, please check!
+ImportMaterialDialog.9=execute
+ImportMaterialDialog.10=In execution......
+ImportMaterialDialog.11=Executed successfully!
+ImportMaterialDialog.12=Execution failure!
+ImportMaterialDialog.13=Materiel\u3010
+ImportMaterialDialog.14=\u3011Failed to call SAP interface, material information could not be obtained!
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/importMaterial/importMaterial_locale_zh_CN.properties b/src/com/connor/ferrorTech/metal/importMaterial/importMaterial_locale_zh_CN.properties
new file mode 100644
index 0000000..7a03be5
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/importMaterial/importMaterial_locale_zh_CN.properties
@@ -0,0 +1,17 @@
+ImportMaterialDialog.0=\u8bf7\u9009\u62e9\u4e0a\u4f20\u8def\u5f84
+ImportMaterialDialog.1=\u672c\u5730\u4e0a\u4f20\u8def\u5f84\uff1a
+ImportMaterialDialog.2=\u9009\u62e9
+ImportMaterialDialog.3=\u786e\u5b9a
+ImportMaterialDialog.8=\u53d6\u6d88
+ImportMaterialHandler.0=\u63d0\u793a
+ImportMaterialHandler.1=\u9009\u4e2d\u7684\u5bf9\u8c61\u7c7b\u578b\u9519\u8bef\uff01
+ImportMaterialDialog.4=\u8bf7\u9009\u62e9\u4e0a\u4f20\u6587\u4ef6\uff01
+ImportMaterialDialog.5=\u9996\u9009\u9879\u3010SAP_check\u3011\u672a\u914d\u7f6e\uff01
+ImportMaterialDialog.6=\u9996\u9009\u9879\u3010SAP_url\u3011\u672a\u914d\u7f6e\uff01
+ImportMaterialDialog.7=\u4e0a\u4f20\u6587\u4ef6\u4e2d\u5c42\u7ea7\u6216\u8005PN\u53f7\u5217\u4e3a\u7a7a\uff0c\u8bf7\u68c0\u67e5\uff01
+ImportMaterialDialog.9=\u6267\u884c
+ImportMaterialDialog.10=\u6267\u884c\u4e2d......
+ImportMaterialDialog.11=\u6267\u884c\u6210\u529f!
+ImportMaterialDialog.12=\u6267\u884c\u5931\u8d25!
+ImportMaterialDialog.13=\u7269\u6599\u3010
+ImportMaterialDialog.14=\u3011\u8c03\u7528SAP\u63a5\u53e3\u5931\u8d25\uff0c\u65e0\u6cd5\u83b7\u53d6\u7269\u6599\u4fe1\u606f\uff01
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/material/finishedProducts/FinishedProductsCreateHandler.java b/src/com/connor/ferrorTech/metal/material/finishedProducts/FinishedProductsCreateHandler.java
new file mode 100644
index 0000000..3090199
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/material/finishedProducts/FinishedProductsCreateHandler.java
@@ -0,0 +1,88 @@
+package com.connor.ferrorTech.metal.material.finishedProducts;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.*;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class FinishedProductsCreateHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ @SuppressWarnings("unused")
+ String[] chLabelName = new String[] { "ϱ", "", "ͻͼ", "", "", "ߴ", "ϳߴ", "Ҫ", "иʽ",
+ "λ", "ƻĬ", "ע" };
+ String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
+ "Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
+ "Unit", "Plan default attributes", "Remarks" };
+
+ String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
+ "vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
+
+ JLabel[] jLabels = new JLabel[enLabelName.length];
+ JComponent[] jComponents = new JComponent[enLabelName.length];
+ Map> lovMap = new HashMap>();
+ Map map = new HashMap<>();
+ String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
+ String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
+ map.put(enLabelName.length - 3, inHouse);
+ map.put(enLabelName.length - 2, eas);
+
+ for (int i = 0; i < enLabelName.length; i++) {
+ if (map.containsKey(i)) {
+ jComponents[i] = new JComboBox<>(map.get(i));
+ } else {
+ jComponents[i] = new JTextField(14);
+ }
+ jLabels[i] = new JLabel(enLabelName[i]);
+ }
+ System.out.println("In house :" + inHouse);
+ for (String inhouse : inHouse) {
+ if (inhouse.equals("In-House Production")) {
+ ((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
+ }
+ }
+ for (String ea : eas) {
+ if (ea.equals("EA")) {
+ ((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
+ }
+ }
+
+ Set keySet = lovMap.keySet();
+ for (String key : keySet) {
+ StringBuffer str = new StringBuffer();
+ str.append(key);
+ str.append(" ==> ");
+ Map map2 = lovMap.get(key);
+ Set keySet2 = map2.keySet();
+ for (String key2 : keySet2) {
+ String value2 = map2.get(key2);
+ str.append("( ");
+ str.append(key2);
+ str.append(" || ");
+ str.append(value2);
+ str.append(" )");
+ }
+ System.out.println(str.toString());
+ }
+
+ ProductsCreateFrame action = new ProductsCreateFrame(application, "Create finished products",
+ "finishedProducts", jLabels, jComponents, prop, lovMap);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/material/finishedProducts/ProductsCreateFrame.java b/src/com/connor/ferrorTech/metal/material/finishedProducts/ProductsCreateFrame.java
new file mode 100644
index 0000000..75e5856
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/material/finishedProducts/ProductsCreateFrame.java
@@ -0,0 +1,435 @@
+package com.connor.ferrorTech.metal.material.finishedProducts;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.json.JSONObject;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.connor.ferrorTech.metal.importMaterial.MaterialPropertyBean;
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.commands.open.OpenCommand;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+import com.teamcenter.rac.util.Registry;
+
+
+@SuppressWarnings("serial")
+public class ProductsCreateFrame extends JFrame implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private String title;
+ private String objectName;
+ private JLabel[] jLabels;
+ private JComponent[] jComponents;
+ private String[] prop;
+ private Map> lovMap;
+
+ private JButton okButton;
+ private JButton celButton;
+ private JButton queryButton;
+
+ private String url;
+ private String sapCheck;
+ private String soaRetrunType;
+ private Map map;
+
+ private TCComponentFolder targetFolder;
+
+ public ProductsCreateFrame(AbstractAIFApplication application, String title, String objectName, Object... args) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.title = title;
+ this.objectName = objectName;
+ this.jLabels = (JLabel[]) args[0];
+ this.jComponents = (JComponent[]) args[1];
+ this.prop = (String[]) args[2];
+ this.lovMap = (Map>) args[3];
+
+ map = new HashMap();
+ map.put("finishedProducts","VF5ccp");
+ map.put("semiFinishedProducts","VF5bcp");
+ map.put("material","VF5cl");
+ }
+
+ public void initUI() {
+ this.setTitle(title);
+ this.setSize(600, 570);
+ // ʼ
+ initializationComponent();
+ // ݵJFrame λ
+ JScrollPane centerPanel = getCenterPanel();
+ JPanel bottomPanel = getBottomPanel();
+
+ this.getContentPane().add(centerPanel, BorderLayout.CENTER);
+ this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ // ôھ
+ this.setLocationRelativeTo(null);
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ // ÿɼ
+ this.setVisible(true);
+ }
+
+ /**
+ * ýĿ
+ */
+ public void initializationComponent() {
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ queryButton = new JButton("Query");
+ }
+
+ public JScrollPane getCenterPanel() {
+ JPanel centerPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints customLayout = new GridBagConstraints();
+
+ // ӵһJLabelJTextField
+ customLayout.insets = new Insets(5, 30, 5, 20); // ߾
+ customLayout.gridx = 0;
+ customLayout.weightx = 0;
+ customLayout.anchor = GridBagConstraints.LINE_START;
+ jLabels[0].setFont(new Font("ź", Font.BOLD, 13));
+ centerPanel.add(jLabels[0], customLayout);
+
+ customLayout.insets = new Insets(5, 3, 5, 20); // ߾
+ customLayout.gridx = 1;
+ customLayout.fill = GridBagConstraints.HORIZONTAL;
+ JComponent jComponent = jComponents[0];
+ jComponent.setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(jComponent, customLayout);
+
+ // queryButtonڵһұ
+ customLayout.insets = new Insets(5, 3, 5, 20); // ߾
+ customLayout.gridx = 2;
+ customLayout.fill = GridBagConstraints.HORIZONTAL;
+ queryButton.setFont(new Font("ź", Font.BOLD, 12));
+ centerPanel.add(queryButton, customLayout);
+
+ // ʣJLabelJTextField
+ for (int i = 1; i < jLabels.length; i++) {
+ customLayout.insets = new Insets(5, 30, 5, 20); // ߾
+ customLayout.gridx = 0;
+ customLayout.gridy = i; // ôֱλ
+ customLayout.weightx = 0;
+ customLayout.anchor = GridBagConstraints.LINE_START;
+ jLabels[i].setFont(new Font("ź", Font.BOLD, 13));
+ centerPanel.add(jLabels[i], customLayout);
+
+ customLayout.insets = new Insets(5, 3, 5, 20); // ߾
+ customLayout.gridx = 1;
+ customLayout.fill = GridBagConstraints.HORIZONTAL;
+ jComponent = jComponents[i];
+ jComponent.setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(jComponent, customLayout);
+ }
+
+ // йܵJPanel
+ return new JScrollPane(centerPanel);
+ }
+
+ public JPanel getBottomPanel() {
+ // TODO Auto-generated method stub
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10));
+ bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
+ bottomPanel.add(this.okButton);
+ bottomPanel.add(this.celButton);
+ // Ӽ
+ okButton.addActionListener(e -> {
+ this.dispose(); // رմ
+ confirmFunction();
+ });
+ celButton.addActionListener(e -> {
+ this.dispose(); // رմ
+ });
+ queryButton.addActionListener(e->{
+ try {
+ queryItem();
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ });
+ return bottomPanel;
+ }
+
+ public void queryItem() throws Exception {
+ // TODO УϱǷΪ
+ JTextField codeField = (JTextField)jComponents[0];
+ String codeName = codeField.getText();
+ if(codeName.isEmpty()) {
+ JOptionPane.showMessageDialog(this, "Please fill in the material code!", "Info", JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ InterfaceAIFComponent[] results = tcSession.search("MU_Find Part",new String[] {"vf5wlbm"}, new String[]{codeName});
+
+ // ʾѾڸϣѯϡ
+ if(results!=null && results.length>0) {
+ JOptionPane.showMessageDialog(this, "The material already exists!", "Info", JOptionPane.INFORMATION_MESSAGE);
+ this.dispose();
+ TCComponent target = (TCComponent) results[0];
+ com.teamcenter.rac.common.Activator.getDefault()
+ .openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective");
+ com.teamcenter.rac.common.Activator.getDefault().openComponents(
+ "com.teamcenter.rac.ui.perspectives.navigatorPerspective",
+ new InterfaceAIFComponent[]{target});
+ }
+ //SAPϽӿڻȡӦϢ
+ String[] sapUrls = tcSession.getPreferenceService().getStringValues("SAP_url");
+ if(sapUrls!=null && sapUrls.length>0) {
+ url = sapUrls[0];
+ }else {
+ JOptionPane.showMessageDialog(this, "SAP_url preference configuration error!", "Info", JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ sapCheck = tcSession.getPreferenceService().getStringValue("SAP_check");
+ if(sapCheck.isEmpty()) {
+ JOptionPane.showMessageDialog(this, "SAP_check preference configuration error!", "Info", JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ MaterialPropertyBean materialInfo = materialInfoBySap(codeName);
+ if(materialInfo == null) {
+ JOptionPane.showMessageDialog(this, "SAP does not exist for this material!", "Info", JOptionPane.INFORMATION_MESSAGE);
+ }else {
+ System.out.println("get info :"+materialInfo.toString());
+ String selectType = map.get(objectName);
+ soaRetrunType = materialInfo.getMaterialType();
+ if(!selectType.equals(soaRetrunType)) {
+ JOptionPane.showMessageDialog(this, "The material code entered is incorrect, please re-enter!", "Info", JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ JTextField nameField = (JTextField)jComponents[1];
+ nameField.setText(materialInfo.getObjectName());
+
+ JComboBox unitBox =(JComboBox) jComponents[jComponents.length-3];
+ unitBox.setSelectedItem(materialInfo.getVf5dw());
+
+ JComboBox planBox =(JComboBox) jComponents[jComponents.length-2];
+ planBox.setSelectedItem(materialInfo.getVf5jhmrsx());
+ }
+
+ }
+
+ public boolean confirmFunction() {
+ Map propMap = SwingUtil.getJComponentValue(prop, jComponents);
+ String selectType = map.get(objectName);
+ System.out.println("selectType : "+selectType);
+ if(soaRetrunType!=null && !soaRetrunType.isEmpty() && !selectType.equals(soaRetrunType)) {
+ JOptionPane.showMessageDialog(this, "The material code entered is incorrect, please re-enter!", "Info", JOptionPane.INFORMATION_MESSAGE);
+ return false;
+ }
+ createItem(selectType, propMap);
+ return true;
+ }
+
+ public void createItem(String itemType, Map propMap) {
+ // TODO Auto-generated method stub
+ try {
+ TCComponentItemType ccpType = (TCComponentItemType) this.tcSession.getTypeComponent(itemType);
+ TCComponentItem ccpItem = ccpType.create(ccpType.getNewID(), "", itemType, propMap.get("object_name"), "",
+ null);
+ TCComponent[] referenceValueArray = ccpItem.getLatestItemRevision().getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ TCComponent form = referenceValueArray[0];
+ Set keySet = propMap.keySet();
+ for (String key : keySet) {
+ if (key.equals("vf5jhmrsx")) {
+ form.setProperty(key,lovMap.get("VF5jhmrsx").get(propMap.get(key)));
+ } else {
+ form.setProperty(key, propMap.get(key));
+ }
+ }
+ targetFolder.add("contents", ccpItem);
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void run() {
+ InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
+ String itemType = targetComponent.getType();
+ if (targetComponent instanceof TCComponentFolder
+ && (itemType.equals("VF5NPI") || itemType.equals("VF5xmwjj") || itemType.equals("Folder"))) {
+ targetFolder = (TCComponentFolder) targetComponent;
+ initUI();
+ } else {
+ JOptionPane.showMessageDialog(null, "not Folder or type error", "Warning", JOptionPane.WARNING_MESSAGE);
+ }
+ }
+
+ /**
+ * ͨѯѯ
+ *
+ * @param materialCode
+ * @return
+ */
+ public boolean queryMaterial(String materialCode) {
+
+ try {
+ TCComponent[] materialObjects = tcSession.search("FTH_Find PartRevisionBywlbm", new String[] { "fth4wlbm" },
+ new String[] { materialCode });
+ if (materialObjects.length >= 1) {
+ TCComponent com = materialObjects[0];
+ //
+ Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open");
+ OpenCommand localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand",
+ new Object[] { AIFUtility.getActiveDesktop(), com });
+ localOpenCommand.executeModeless();
+ return false;
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ /**
+ * sapӿ
+ *
+ * @param param
+ * @param code
+ * @return
+ */
+ public String sapConnect(String param, String code) {
+ String result = null;
+ HttpsURLConnection connection = null;
+ try {
+ String[] split = sapCheck.split(":");
+ // ֤û
+ String basicAuth = "Basic "
+ + new String(Base64.getEncoder().encode((split[0] + ":" + split[1]).getBytes()));
+
+ // URL
+ URL urlObj = null;
+ if (code != null && code != "") {
+ urlObj = new URL(url + "/" + param + "/" + code);
+ } else {
+ urlObj = new URL(url + "/" + param);
+ }
+
+ //
+ connection = (HttpsURLConnection) urlObj.openConnection();
+ // ֤ͷ
+ connection.setRequestProperty("Authorization", basicAuth);
+
+ // ΪGET
+ connection.setRequestMethod("GET");
+
+ // Ӧ
+ int responseCode = connection.getResponseCode();
+ System.out.println("Response Code: " + responseCode);
+
+ // ȡӦ
+ BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ String inputLine;
+ StringBuilder response = new StringBuilder();
+
+ while ((inputLine = in.readLine()) != null) {
+ response.append(inputLine);
+ }
+ in.close();
+
+ result = response.toString();
+ // ӡ
+ System.out.println(response.toString());
+ } catch (Exception e) {
+ e.getStackTrace();
+ System.out.println(e.getStackTrace());
+ } finally {
+ // ر
+ connection.disconnect();
+ }
+ return result;
+ }
+
+ /**
+ * ͨSAPӿڻȡϢ
+ */
+ public MaterialPropertyBean materialInfoBySap(String materialCode) {
+ MaterialPropertyBean materiaPorptry = new MaterialPropertyBean();
+ // ͨӿڻȡϢ
+ String value = sapConnect("Product", materialCode);
+ System.out.println("Ϣjson:" + value);
+ if (value != null) {
+ JSONObject jsonObject = new JSONObject(value);
+ materiaPorptry.setVf5wlbm(jsonObject.getString("Product"));
+ System.out.println("ϱ:" + jsonObject.getString("Product"));
+ if ("FERT".equals(jsonObject.getString("ProductType"))) {
+ materiaPorptry.setMaterialType("VF5ccp");
+ } else if ("HALB".equals(jsonObject.getString("ProductType"))) {
+ materiaPorptry.setMaterialType("VF5bcp");
+ } else if ("ROH".equals(jsonObject.getString("ProductType"))) {
+ materiaPorptry.setMaterialType("VF5cl");
+ }
+ String dw = jsonObject.getString("BaseUnit");
+ if("ST".equals(dw)) {
+ materiaPorptry.setVf5dw("PC");
+ }else {
+ materiaPorptry.setVf5dw(dw);
+ }
+ } else {
+ return null;
+ }
+ // Ϣ
+ String value3 = sapConnect("ProductDescription(Product='" + materialCode + "',Language='EN')", "");
+ if (value3 != null) {
+ System.out.println("json:" + value3);
+ JSONObject jsonObject = new JSONObject(value3);
+ materiaPorptry.setObjectName(jsonObject.getString("ProductDescription"));
+ } else {
+ return null;
+ }
+ // ϲɹ
+ String value2 = sapConnect("ProductPlantSupplyPlanning(Product='" + materialCode + "',Plant='5410')", "");
+ if (value2 != null) {
+ System.out.println("ϲɹjson:" + value2);
+ JSONObject jsonObject = new JSONObject(value2);
+ if ("E".equals(jsonObject.getString("ProcurementType"))) {
+ materiaPorptry.setVf5jhmrsx("In-House Production");
+ } else if ("F".equals(jsonObject.getString("ProcurementType"))) {
+ materiaPorptry.setVf5jhmrsx("External Procurement");
+ } else if ("X".equals(jsonObject.getString("ProcurementType"))) {
+ materiaPorptry.setVf5jhmrsx("Both Procurement Type");
+ }
+ } else {
+ return null;
+ }
+ return materiaPorptry;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/material/finishedProducts_locale.properties b/src/com/connor/ferrorTech/metal/material/finishedProducts_locale.properties
new file mode 100644
index 0000000..08e336f
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/material/finishedProducts_locale.properties
@@ -0,0 +1,13 @@
+finishedProductsDialog.0=Create Finished Products
+finishedProductsDialog.1=Material code
+finishedProductsDialog.2=Material name
+finishedProductsDialog.3=Customer drawing number
+finishedProductsDialog.4=Material
+finishedProductsDialog.5=Specification
+finishedProductsDialog.6=Part size
+finishedProductsDialog.7=Material size
+finishedProductsDialog.8=Surface requirements
+finishedProductsDialog.9=Cutting method
+finishedProductsDialog.10=Unit
+finishedProductsDialog.11=Plan default attributes
+finishedProductsDialog.12=Remarks
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/material/material/MaterialCreateHandler.java b/src/com/connor/ferrorTech/metal/material/material/MaterialCreateHandler.java
new file mode 100644
index 0000000..b1c1c0d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/material/material/MaterialCreateHandler.java
@@ -0,0 +1,72 @@
+package com.connor.ferrorTech.metal.material.material;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.material.finishedProducts.ProductsCreateFrame;
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class MaterialCreateHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ @SuppressWarnings("unused")
+ String[] chLabelName = new String[] { "ϱ", "", "ͻͼ", "", "", "ߴ", "ϳߴ", "Ҫ", "иʽ",
+ "λ", "ƻĬ", "ע" };
+ String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
+ "Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
+ "Unit", "Plan default attributes", "Remarks" };
+
+ String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
+ "vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
+
+ JLabel[] jLabels = new JLabel[enLabelName.length];
+ JComponent[] jComponents = new JComponent[enLabelName.length];
+ Map> lovMap = new HashMap>();
+ Map map = new HashMap<>();
+ String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
+ String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
+ map.put(enLabelName.length - 3, inHouse);
+ map.put(enLabelName.length - 2, eas);
+
+ for (int i = 0; i < enLabelName.length; i++) {
+ if (map.containsKey(i)) {
+ jComponents[i] = new JComboBox<>(map.get(i));
+ } else {
+ jComponents[i] = new JTextField(14);
+ }
+ jLabels[i] = new JLabel(enLabelName[i]);
+ }
+ System.out.println("In house :" + inHouse);
+ for (String inhouse : inHouse) {
+ if (inhouse.equals("In-House Production")) {
+ ((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
+ }
+ }
+ for (String ea : eas) {
+ if (ea.equals("EA")) {
+ ((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
+ }
+ }
+ ProductsCreateFrame action = new ProductsCreateFrame(application, "Create materials", "material", jLabels,
+ jComponents, prop, lovMap);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/material/semiFinishedProducts/SemiFinishedProductsCreateHandler.java b/src/com/connor/ferrorTech/metal/material/semiFinishedProducts/SemiFinishedProductsCreateHandler.java
new file mode 100644
index 0000000..b21e3bb
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/material/semiFinishedProducts/SemiFinishedProductsCreateHandler.java
@@ -0,0 +1,73 @@
+package com.connor.ferrorTech.metal.material.semiFinishedProducts;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.material.finishedProducts.ProductsCreateFrame;
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class SemiFinishedProductsCreateHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ @SuppressWarnings("unused")
+ String[] chLabelName = new String[] { "ϱ", "", "ͻͼ", "", "", "ߴ", "ϳߴ", "Ҫ", "иʽ",
+ "λ", "ƻĬ", "ע" };
+ String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
+ "Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
+ "Unit", "Plan default attributes", "Remarks" };
+
+ String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
+ "vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
+
+ JLabel[] jLabels = new JLabel[enLabelName.length];
+ JComponent[] jComponents = new JComponent[enLabelName.length];
+ Map> lovMap = new HashMap>();
+ Map map = new HashMap<>();
+ String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
+ String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
+ map.put(enLabelName.length - 3, inHouse);
+ map.put(enLabelName.length - 2, eas);
+
+ for (int i = 0; i < enLabelName.length; i++) {
+ if (map.containsKey(i)) {
+ jComponents[i] = new JComboBox<>(map.get(i));
+ } else {
+ jComponents[i] = new JTextField(14);
+ }
+ jLabels[i] = new JLabel(enLabelName[i]);
+ }
+ System.out.println("In house :" + inHouse);
+ for (String inhouse : inHouse) {
+ if (inhouse.equals("In-House Production")) {
+ ((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
+ }
+ }
+ for (String ea : eas) {
+ if (ea.equals("EA")) {
+ ((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
+ }
+ }
+
+ ProductsCreateFrame action = new ProductsCreateFrame(application, "Create semi-finished products",
+ "semiFinishedProducts", jLabels, jComponents, prop, lovMap);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomCommand.java b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomCommand.java
new file mode 100644
index 0000000..dbbcfa3
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomCommand.java
@@ -0,0 +1,280 @@
+package com.connor.ferrorTech.metal.materialManage;
+
+import java.util.ArrayList;
+
+import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
+
+import com.teamcenter.rac.aif.AbstractAIFCommand;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentItem;
+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.util.MessageBox;
+
+public class DbomTransitionToEbomCommand extends AbstractAIFCommand {
+
+ private InterfaceAIFComponent comp;
+ private TCSession session;
+ private TCComponentBOMLine bomLine = null;
+ static ArrayList preList = new ArrayList();
+
+ public DbomTransitionToEbomCommand(InterfaceAIFComponent comp, TCSession session) {
+ // TODO Auto-generated constructor stub
+ this.comp = comp;
+ this.session = session;
+ }
+
+ @Override
+ public void executeModal() throws Exception {
+ // TODO Auto-generated method stub
+// TCComponentType compType = session.getTypeComponent("ML8_Washing");
+// String[] allProperties=compType.getPropertyNames();//ȡ
+ //TCProperty[] allProperties=compType.getPropertyNames();//ȡ
+
+ //ȡѡеĶ
+ if(!(comp instanceof TCComponentBOMLine))
+ {
+ MessageBox.post("ڽṹѡBOMLine", "", MessageBox.ERROR);
+ return;
+ }
+ //System.out.println("11111111111");
+ bomLine = (TCComponentBOMLine) comp;
+
+ //ж϶
+ TCComponentItem item = bomLine.getItem();
+ boolean isTypeof=false;
+ String[] prefValues = session.getPreferenceService().getStringValues("Connor_LY6_DBOM_Type"); //Connor_DBOM_Type
+ System.out.println("prefValuse"+prefValues.toString());
+ for(String pref : prefValues) {
+ if(pref.equals(item.getType())) {
+ isTypeof = true;
+ }
+ }
+
+ if(!isTypeof) {
+ MessageBox.post("ѡConnor_DBOM_TypeѡõĶ","ʾ",2);
+ return;
+ }
+ System.out.println(item.getType());
+// if(!item.getType().equals("ML8_Design"))
+// {
+// MessageBox.post("ѡƶ", "", MessageBox.ERROR);
+// return;
+// }
+ //final List> bomPropertyList = this.getBomPropertys(session, bomLine);
+
+
+ String[] prefValueParts = session.getPreferenceService().getStringValues("Connor_LY6_DBOM_PartType");
+ for (String string : prefValueParts) {
+ preList.add(string);
+ }
+
+ final DefaultMutableTreeTableNode node = this.getBomPropertyToNode(session, bomLine);
+
+
+ new Thread() {
+ @Override
+ public void run() {
+ DbomTransitionToEbomDialog dialog = new DbomTransitionToEbomDialog(
+ comp, session,node,preList);
+ }
+ }.start();
+ super.executeModal();
+ }
+
+ /**
+ * ȡBOM
+ * @throws TCException
+ */
+ public static DefaultMutableTreeTableNode getBomPropertyToNode(TCSession session, TCComponentBOMLine topBomLine) throws TCException {
+ // TODO Auto-generated method stub
+
+ NodeBean nodeBean = new NodeBean();
+
+ //String ss = subline.getStringProperty("bl_indented_title");
+ //ID
+ nodeBean.setDbom("");
+ nodeBean.setdId("");
+ nodeBean.setEbom("");
+ nodeBean.setEbomId("");
+ nodeBean.setNum("");
+ nodeBean.setLabel("");
+ nodeBean.setRefreshStatus("");
+ nodeBean.setParentString("");
+
+ DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean);
+ //ȡBOM
+ try {
+ //getRepresentationPropertysToNode(topBomLine, rootNode, "");
+ getBomPropertysToNode(topBomLine, rootNode, "");
+ return rootNode;
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ return null;
+ }
+ /***
+ * ȡʾµĶ
+ * @param bomLine
+ * @param rootNode
+ * @param parentID
+ * @throws TCException
+ */
+ public static void getRepresentationPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID,String quantity) throws TCException
+ {
+ TCComponentItemRevision itemRevision = bomLine.getItemRevision();
+ //ˢ±ʾϵ
+ //TCComponent referenceProperty = itemRevision.getReferenceProperty("representation_for");
+ //referenceProperty.refresh();
+ //ȡʾϵµĶ
+ itemRevision.refresh();
+ TCComponent[] tcComponents = itemRevision.getReferenceListProperty("representation_for");
+ for (TCComponent tcComponent : tcComponents) {
+
+ TCProperty refreshStatusProperty = tcComponent.getTCProperty("release_status_list");
+ TCComponent[] refreshStatus = refreshStatusProperty.getReferenceValueArray();
+ TCProperty processProperty = tcComponent.getTCProperty("process_stage_list");
+ TCComponent[] processStage = processProperty.getReferenceValueArray();
+
+ NodeBean nodeBean = new NodeBean();
+
+ nodeBean.setDbom("");
+ nodeBean.seteRevision((TCComponentItemRevision)tcComponent);
+ nodeBean.setEbom(tcComponent.getStringProperty("object_string"));
+ nodeBean.setEbomId(tcComponent.getStringProperty("item_id"));
+ nodeBean.setEbomDesc(tcComponent.getStringProperty("ld6_materialDesc"));
+ nodeBean.setNum(quantity);
+ nodeBean.setLabel("0");
+ if(refreshStatus.length > 0)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+ //ӷ״̬
+ for (int i = 0; i < refreshStatus.length; i++) {
+ stringBuffer.append(refreshStatus[i].toString());
+ if(i < refreshStatus.length - 1)
+ {
+ stringBuffer.append(",");
+ }
+ }
+ nodeBean.setRefreshStatus(stringBuffer.toString());
+ }
+ else if(processStage.length > 0)
+ {
+ nodeBean.setRefreshStatus("");
+ }
+ else
+ {
+ nodeBean.setRefreshStatus("");
+ }
+ nodeBean.setParentString(itemRevision.getStringProperty("object_string"));
+
+ DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean);
+ rootNode.add(node);
+
+ if(tcComponents.length == 1)
+ {
+ if(getTopRefresh(node))
+ {
+ nodeBean.setLabel("0");
+ }
+ else
+ {
+ nodeBean.setLabel("1");
+ }
+ }
+ }
+ }
+ /***
+ * жϼǷѡѷ
+ * @param node
+ * @return
+ */
+ private static boolean getTopRefresh(DefaultMutableTreeTableNode node)
+ {
+ boolean result = false;
+
+ //жϲǷѡѷĶ
+ DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
+ if(parentNode != null)
+ {
+ DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
+ if(rootNode != null)
+ {
+ for (int i = 0; i < rootNode.getChildCount(); i++) {
+ DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
+ NodeBean childBean = (NodeBean) childNode.getUserObject();
+ if(childBean.getLabel().equals("1") && childBean.getRefreshStatus().indexOf("") >= 0)
+ {
+ //MessageBox.post("ϲ["+childBean.getEbom()+"]ѹѡͲ㲻ѡ", "", MessageBox.ERROR);
+ return true;
+ }
+ else
+ {
+ return getTopRefresh(childNode);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+
+ /**
+ * ȡBOMϢ
+ * @param bomLine
+ * @param bomPropertyList
+ * @param parentID
+ */
+ public static void getBomPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID)
+ {
+ try {
+
+ NodeBean nodeBean = new NodeBean();
+ System.out.println(bomLine.getStringProperty("bl_item_object_type"));
+ if(bomLine.getStringProperty("bl_item_object_type").equals("LD6_3Ddesign")) {
+ return;
+ }
+ nodeBean.setdId(bomLine.getStringProperty("bl_item_item_id"));
+ nodeBean.setDbom(bomLine.getStringProperty("bl_item_object_string"));
+ nodeBean.setNum(bomLine.getStringProperty("bl_quantity"));
+ nodeBean.setEbom("");
+ nodeBean.setEbomId("");
+ if(preList.contains(bomLine.getStringProperty("bl_item_object_type"))) {
+ nodeBean.setLabel("0");
+ }else {
+ nodeBean.setLabel("");
+ }
+
+ nodeBean.setRefreshStatus("");
+ nodeBean.setParentString("");
+
+ DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean);
+ rootNode.add(node);
+
+
+ getRepresentationPropertysToNode(bomLine, node,bomLine.getStringProperty("bl_item_item_id"),bomLine.getStringProperty("bl_quantity"));
+
+ if(bomLine.getChildren().length > 0)
+ {
+ AIFComponentContext aif[] = bomLine.getChildren();
+ for (int i = 0; i < aif.length; i++)
+ {
+ TCComponentBOMLine subline = (TCComponentBOMLine) aif[i]
+ .getComponent();
+
+ getBomPropertysToNode(subline, node,bomLine.getStringProperty("bl_item_item_id"));
+ }
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomDialog.java b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomDialog.java
new file mode 100644
index 0000000..d1595ab
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomDialog.java
@@ -0,0 +1,818 @@
+package com.connor.ferrorTech.metal.materialManage;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.ListSelectionModel;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.tree.TreePath;
+
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
+
+import com.connor.ferrorTech.metal.util.Adapter;
+import com.connor.ferrorTech.metal.util.MethodUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCComponentQuery;
+import com.teamcenter.rac.kernel.TCComponentQueryType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.kernel.TCUserService;
+import com.teamcenter.rac.util.MessageBox;
+//import com.teamcenter.soa.exceptions.NotLoadedException;
+
+public class DbomTransitionToEbomDialog extends AbstractAIFDialog implements ActionListener, MouseListener {
+
+ private TCSession session;
+ private InterfaceAIFComponent comp;
+ // private InterfaceAIFComponent comp;//ȡѡеĶ
+
+ private List isNotEditableRow = new ArrayList();
+ // private TCComponentBOMLine bomLine;
+ private DefaultMutableTreeTableNode node;
+
+ private String[] header = new String[] { "DBOM", "EBOM", "ѡ", "EBOMID", "", "", "״̬", "Ӧڵ" };
+ private String[] needChangeUomTypeList = new String[] { "Part", "Design", "LY6_Product", "LY6_Component",
+ "LY6_Part", "LY6_EnStandardP", "LY6_StandardP", "LY6_SemiformedP", "LY6_CastingP", "LY6_Equipment",
+ "LY6_MeasureTool", "LY6_Mold" };
+
+ private JPanel titlePanel;
+ private JLabel titleLabel;
+ private JTreeTable table;
+ private JTreeTableModel map;
+
+ private JPanel rootPanel;
+ private JButton okButton;
+ private JButton celButton;
+ private JButton refreshButton;
+ private ArrayList preList;
+
+ public DbomTransitionToEbomDialog(InterfaceAIFComponent comp, TCSession session, DefaultMutableTreeTableNode node,
+ ArrayList preList) {
+ // TODO Auto-generated constructor stub
+ super(false);
+ this.session = session;
+ this.comp = comp;
+ this.node = node;
+ this.preList = preList;
+ init();
+ }
+
+ private void init() {
+ // TODO Auto-generated method stub
+ this.setTitle("DBOMתEBOM");
+ this.setPreferredSize(new Dimension(800, 600));
+ // ʼⲿֿؼ
+ this.titlePanel = new JPanel();
+ this.titleLabel = new JLabel("DBOMתEBOM");
+ this.titleLabel.setFont(new Font("", 1, 18));
+ this.titlePanel.add(titleLabel);
+
+ JPanel panel = new JPanel();
+ panel.add(this.titlePanel, BorderLayout.NORTH);
+
+ this.table = getJTreeTable(null, null, header, null);
+
+ this.table.addMouseListener(this);
+ Adapter adapter = new Adapter(table);
+
+ this.rootPanel = new JPanel(new FlowLayout());
+ this.okButton = new JButton("ȷ");
+ this.celButton = new JButton("ȡ");
+ this.refreshButton = new JButton("ˢ");
+
+ this.rootPanel.add(okButton);
+ this.rootPanel.add(celButton);
+ this.rootPanel.add(refreshButton);
+ // this.rootPanel.add(celValueButton);
+
+ //
+ this.createActionEvent();
+ this.setLayout(new BorderLayout());
+ // this.add(centerPanel, BorderLayout.NORTH);
+ this.add(panel, BorderLayout.NORTH);
+ this.add(new JScrollPane(this.table), BorderLayout.CENTER);
+ // dialog.add(tablePanel, BorderLayout.CENTER);
+ this.add(rootPanel, BorderLayout.SOUTH);
+ // this.setAlwaysOnTop(true);
+ this.pack();
+ this.setLocationRelativeTo(null);
+ this.show();
+ }
+
+ // Ӽ
+ public void createActionEvent() {
+ this.okButton.addActionListener(this);
+ this.celButton.addActionListener(this);
+ this.refreshButton.addActionListener(this);
+ // this.celValueButton.addActionListener(this);
+ }
+
+ // Jtableͨ÷
+ public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, Object[] titleNames,
+ Object[][] values) {
+ int simpleLen = 100;
+ int totleLen = 1500;
+ if (partsTable == null) {
+ this.map = new JTreeTableModel(this.node);
+ this.map.setIsNotEditableRow(this.isNotEditableRow);
+ // map.setColumnIdentifiers(titleNames);
+
+ partsTable = new JTreeTable(map);
+ partsTable.setIsNotEditableRow(this.isNotEditableRow);
+ partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ // partsTable.setRowHeight(1, 50);
+ // partsTable.setRowHeight(2, 100);
+ partsTable.setRowHeight(30);
+ partsTable.expandAll(); // չȫڵ
+ //
+// partsTable.HiddenCell(0);
+
+ partsTable.getColumnModel().getColumn(0).setPreferredWidth(188); // õһп
+ partsTable.getColumnModel().getColumn(1).setPreferredWidth(150); // õڶп
+ partsTable.getColumnModel().getColumn(2).setPreferredWidth(55); // õп
+
+ partsTable.setHighlighters(HighlighterFactory.createSimpleStriping());
+
+ if (simpleLen * titleNames.length >= totleLen) {
+ for (int i = 0; i < titleNames.length; i++) {
+ partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen);
+ }
+ partsTable.setAutoResizeMode(0);
+ } else {
+ partsTable.setAutoResizeMode(1);
+ }
+ }
+ return partsTable;
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ // TODO Auto-generated method stub
+ if (e.getClickCount() == 2) {
+ TreePath treePath = table.getPathForLocation(e.getX(), e.getY());
+ if (treePath != null) {
+ DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent();
+ NodeBean nodeBean = (NodeBean) node.getUserObject();
+ String itemId = nodeBean.getdId();
+ if (itemId != null && !itemId.isEmpty()) {
+ try {
+ // ȡ
+ TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item");
+ TCComponentItem[] item = itemType.findItems(itemId);
+
+ com.teamcenter.rac.common.Activator.getDefault()
+ .openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective");
+ com.teamcenter.rac.common.Activator.getDefault().openComponents(
+ "com.teamcenter.rac.ui.perspectives.navigatorPerspective",
+ new InterfaceAIFComponent[] { item[0] });
+ } catch (Exception e2) {
+ // TODO: handle exception
+ e2.printStackTrace();
+ }
+ }
+ }
+ } else if (e.getClickCount() > 0) {
+ // ѡ
+ int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint());
+
+ if (selectColumn != 2) {
+ return;
+ }
+
+ TreePath treePath = table.getPathForLocation(e.getX(), e.getY());
+ if (treePath != null) {
+ DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent();
+ NodeBean nodeBean = (NodeBean) node.getUserObject();
+
+ if (getTopRefresh(node)) {
+ MessageBox.post("ϲѹѡͲ㲻ѡ", "", MessageBox.ERROR);
+ return;
+ }
+
+ if (getTopProcessRefresh(node)) {
+ MessageBox.post("ϲѹѡеͲ㲻ѡ", "", MessageBox.ERROR);
+ return;
+ }
+
+ DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
+ if (parentNode != null) {
+ DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
+ NodeBean rootNodeBean = (NodeBean) rootNode.getUserObject();
+
+ if (!rootNodeBean.getDbom().equals("") && !getTop(node) && nodeBean.getLabel().equals("0")) {
+ MessageBox.post("ϲδѡ²㲻ѡ", "", MessageBox.ERROR);
+ return;
+ }
+ }
+
+ try {
+ TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
+
+ if (nodeBean.getLabel().equals("0")) {
+ // жͬһǷѹѡ
+ if (parentNode != null) {
+ for (int i = 0; i < parentNode.getChildCount(); i++) {
+ DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode
+ .getChildAt(i);
+ NodeBean childBean = (NodeBean) childNode.getUserObject();
+ if (childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty()
+ && !nodeBean.getEbom().isEmpty()) {
+ MessageBox.post("ͬһ㼶ֻѡһ", "", MessageBox.ERROR);
+ return;
+ }
+ }
+
+ }
+
+ nodeBean.setLabel("1");
+ // isHaveBom(node, nodeBean.getEbomId(), "1", itemType);
+ } else if (nodeBean.getLabel().equals("1")) {
+ nodeBean.setLabel("0");
+ // isHaveBom(node, nodeBean.getEbomId(), "0", itemType);
+ }
+ Robot robot = new Robot();
+ robot.keyPress(KeyEvent.VK_TAB);
+ robot.keyRelease(KeyEvent.VK_TAB);
+ } catch (Exception e2) {
+ // TODO: handle exception
+ e2.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /***
+ * жϼǷѡ
+ *
+ * @param node
+ * @return
+ * @throws TCException
+ */
+ private void isHaveBom(DefaultMutableTreeTableNode node, String parentID, String status,
+ TCComponentItemType itemType) throws TCException {
+ TCComponentItem[] item = itemType.findItems(parentID);
+ TCComponentItemRevision itemRevision = item[0].getLatestItemRevision();
+
+ TCComponent[] tcComponents = itemRevision.getReferenceListProperty("view");
+ if (tcComponents.length > 0) {
+ for (int ii = 0; ii < node.getParent().getChildCount(); ii++) {
+ DefaultMutableTreeTableNode tableNode = (DefaultMutableTreeTableNode) node.getParent().getChildAt(ii);
+
+ if (tableNode.getChildCount() > 0) {
+ for (int i = 0; i < tcComponents.length; i++) {
+ TCComponent childBomLine = tcComponents[i];
+ List haveItemID = new ArrayList();
+ for (int j = 0; j < tableNode.getChildCount(); j++) {
+ String childItemId = childBomLine.getStringProperty("item_id");
+ NodeBean childNodeBean = (NodeBean) tableNode.getChildAt(j).getUserObject();
+ if (childItemId.equals(childNodeBean.getEbomId())
+ && !haveItemID.contains(childNodeBean.getEbomId())) {
+ haveItemID.add(childNodeBean.getEbomId());
+ childNodeBean.setLabel(status);
+ isHaveBom((DefaultMutableTreeTableNode) (tableNode.getChildAt(j)),
+ childNodeBean.getEbomId(), status, itemType);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /***
+ * жϼǷѡ
+ *
+ * @param node
+ * @return
+ */
+ private boolean getTop(DefaultMutableTreeTableNode node) {
+ boolean result = false;
+
+ // жϲǷѡѷĶ
+ DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
+ if (parentNode != null) {
+ DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
+ if (rootNode != null) {
+ for (int i = 0; i < rootNode.getChildCount(); i++) {
+ DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
+ NodeBean childBean = (NodeBean) childNode.getUserObject();
+ if (childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty()) {
+ // MessageBox.post("ϲ["+childBean.getEbom()+"]ѹѡͲ㲻ѡ", "",
+ // MessageBox.ERROR);
+ return true;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /***
+ * жϼǷѡѷ
+ *
+ * @param node
+ * @return
+ */
+ private boolean getTopRefresh(DefaultMutableTreeTableNode node) {
+ boolean result = false;
+
+ // жϲǷѡѷĶ
+ DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
+ if (parentNode != null) {
+ DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
+ if (rootNode != null) {
+ for (int i = 0; i < rootNode.getChildCount(); i++) {
+ DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
+ NodeBean childBean = (NodeBean) childNode.getUserObject();
+ if (childBean.getLabel().equals("1") && !childBean.getRefreshStatus().equals("Է")
+ && !childBean.getRefreshStatus().isEmpty()) {
+ result = true;
+ break;
+ } else {
+ if (getTopRefresh(childNode)) {
+ result = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /***
+ * жϼǷѡж
+ *
+ * @param node
+ * @return
+ */
+ private boolean getTopProcessRefresh(DefaultMutableTreeTableNode node) {
+ boolean result = false;
+
+ // жϲǷѡѷĶ
+ DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
+ if (parentNode != null) {
+ DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
+ if (rootNode != null) {
+ for (int i = 0; i < rootNode.getChildCount(); i++) {
+ DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
+ NodeBean childBean = (NodeBean) childNode.getUserObject();
+ if (childBean.getLabel().equals("1") && childBean.getRefreshStatus().equals("")) {
+ result = true;
+ break;
+ } else {
+ if (getTopProcessRefresh(childNode)) {
+ result = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // TODO Auto-generated method stub
+ Object source = e.getSource();
+ if (source.equals(this.okButton)) {
+ // ȡѡеEBOM
+ try {
+ MethodUtil.openByPass(session);
+ TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
+ this.adaptiveVariants((DefaultMutableTreeTableNode) (this.node.getChildAt(0)), itemType, true);
+ MethodUtil.closeByPass(session);
+ MessageBox.post("תɹ", "ɹ", MessageBox.INFORMATION);
+ } catch (TCException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ } else if (source.equals(this.refreshButton)) {
+ this.dispose();
+ try {
+ DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(comp, session);
+ command.executeModal();
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ } else {
+ this.dispose();
+ }
+ }
+
+ public boolean isEmpty(String str) {
+ return str == null || "".equals(str.trim());
+ }
+
+ public String getText(TCSession session, String str) throws Exception {
+ if (isEmpty(str)) {
+ return str;
+ } else {
+ String res = session.getTextService().getTextValue(str);
+ return !isEmpty(res) ? res : str;
+ }
+ }
+
+ public TCComponentItem getItemById(String id) {
+
+ try {
+ System.out.println("ûĿ" + getText(session, "ItemID"));
+ // òѯ
+ String[] keys = new String[] { getText(session, "ItemID") };
+ // òѯidֵ
+ String[] values = new String[] { id };
+ List comps = queryObject("...", keys, values);
+ if (comps != null || comps.size() > 0) {
+ return (TCComponentItem) comps.get(0);
+ } else {
+ MessageBox.post("ѡûвѯ", "", MessageBox.ERROR);
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public List queryObject(String queryName, String[] keys, String[] values) {
+ TCComponent[] components = null;
+ try {
+ AbstractAIFApplication app = AIFUtility.getCurrentApplication();
+ TCSession session = (TCSession) app.getSession();
+ TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery");
+ TCComponentQuery query = (TCComponentQuery) queryType.find(queryName);
+ if (query == null) {
+ MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR);
+ return null;
+ }
+
+ components = query.execute(keys, values);
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ if (components != null && components.length > 0) {
+ List compList = Arrays.asList(components);
+ return compList;
+ } else {
+ MessageBox.post("ûвѯ", "", MessageBox.ERROR);
+ return null;
+ }
+ }
+
+ TCComponentBOMLine resultTopline = null;
+
+ /**
+ * ´BOM
+ *
+ * @param topItem
+ * @throws TCException
+ */
+ private void adaptiveVariants(DefaultMutableTreeTableNode tableNode, TCComponentItemType itemType, boolean ifCreate)
+ throws TCException {
+ TCComponentItem topItem = null;
+ // idͬʱ
+ LinkedHashMap countMap = new LinkedHashMap();
+ ArrayList itemList = new ArrayList();
+ Map itemNumMap = new HashMap();
+
+ System.out.println("adaptiveVariants called with ifCreate: " + ifCreate);
+
+ for (int i = 0; i < tableNode.getChildCount(); i++) {
+ DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i);
+ NodeBean childBean = (NodeBean) childNode.getUserObject();
+ System.out.println("Processing child node " + i + " with label: " + childBean.getLabel());
+
+ if (childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty()) {
+// topItem = itemType.findItems(childBean.getEbomId());
+ topItem = childBean.geteRevision().getItem();
+ System.out.println("Found topItem with EBOM ID: " + childBean.getEbomId());
+
+ for (int j = 0; j < tableNode.getChildCount(); j++) {
+ DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) tableNode.getChildAt(j);
+ if (ifCreate) {
+ NodeBean childBean2 = (NodeBean) node.getUserObject();
+ String dbom = childBean2.getDbom();
+ System.out.println("Processing sub-child node " + j + " with label: " + childBean2.getLabel()
+ + ", Dbom: " + dbom);
+ if (!dbom.isEmpty()) {
+ String id = childBean2.getdId();
+ System.out.println("id:" + id);
+ TCComponentItem[] createItem = itemType.findItems(id);
+ System.out
+ .println("Found createItem with ID: " + id + ", Type: " + createItem[0].getType());
+
+ if (childBean2.getLabel().equals("1") && preList.contains(createItem[0].getType())) {
+ System.out.println("child id material ===>" + id);
+ System.out.println("parent id EBOM ===>" + childBean.getEbomId());
+ String num = childBean2.getNum();
+ if (num == null || num.isEmpty() || num.equals("0")) {
+ num = "1";
+ }
+ System.out.println("Updating countMap for "
+ + createItem[0].getLatestItemRevision().getProperty("item_id") + " with num: "
+ + num);
+ if (countMap.containsKey(createItem[0].getLatestItemRevision())) {
+ Integer integer = countMap.get(createItem[0].getLatestItemRevision());
+ countMap.put(createItem[0].getLatestItemRevision(),
+ Integer.parseInt(num) + integer);
+ } else {
+ countMap.put(createItem[0].getLatestItemRevision(), Integer.parseInt(num));
+ }
+ }
+ }
+ }
+ for (int k = 0; k < node.getChildCount(); k++) {
+ DefaultMutableTreeTableNode childTableNode = (DefaultMutableTreeTableNode) node.getChildAt(k);
+ NodeBean childNodeBean = (NodeBean) childTableNode.getUserObject();
+ System.out.println(
+ "Processing grandchild node " + k + " with label: " + childNodeBean.getLabel());
+ if (childNodeBean.getLabel().equals("1")) {
+ TCComponentItem item = null;
+ if (childNodeBean.getEbomId() == null || childNodeBean.getEbomId().isEmpty()) {
+
+ String id = childNodeBean.getdId();
+ System.out.println("id:" + id);
+ item = itemType.findItems(id)[0];
+ System.out.println("Found item with ID: " + id);
+ } else {
+ item = childNodeBean.geteRevision().getItem();
+ System.out.println("Found item with EBOM ID: " + childNodeBean.getEbomId());
+ }
+ if (preList.contains(item.getType())) {
+ continue;
+ }
+ String num = childNodeBean.getNum();
+ if (num == null || num.isEmpty() || num.equals("0")) {
+ num = "1";
+ }
+ System.out.println("Updating countMap for "
+ + item.getLatestItemRevision().getProperty("item_id") + " with num: " + num);
+ if (countMap.containsKey(item.getLatestItemRevision())) {
+ Integer integer = countMap.get(item.getLatestItemRevision());
+ countMap.put(item.getLatestItemRevision(), Integer.parseInt(num) + integer);
+ } else {
+ countMap.put(item.getLatestItemRevision(), Integer.parseInt(num));
+ }
+ itemList.add(item.getLatestItemRevision());
+ System.out.println("Updating itemNumMap for " + item.getStringProperty("item_id")
+ + " with num: " + num);
+ if (itemNumMap.containsKey(item.getStringProperty("item_id"))) {
+ String integer = itemNumMap.get(item.getStringProperty("item_id"));
+ itemNumMap.put(item.getStringProperty("item_id"),
+ Integer.parseInt(num) + Integer.parseInt(integer) + "");
+ } else {
+ itemNumMap.put(item.getStringProperty("item_id"), Integer.parseInt(num) + "");
+ }
+ if (childNodeBean.getRefreshStatus().equals("Է")
+ || childNodeBean.getRefreshStatus().equals("")) {
+ System.out.println("Calling recursive adaptiveVariants for node " + k);
+ adaptiveVariants((DefaultMutableTreeTableNode) (childTableNode.getParent()), itemType,
+ true);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (topItem != null) {
+ System.out.println("Processing topItem with ID: " + topItem.getProperty("item_id"));
+ resultTopline = null;
+ TCComponentBOMWindow recreateBom = this.recreateBom(topItem.getLatestItemRevision(), itemList, true,
+ countMap);
+ if (resultTopline != null) {
+ resultTopline.lock();
+ System.out.println("Setting BOM line properties for topItem: " + topItem.getProperty("item_id"));
+ Map qMap = new HashMap();
+ for (int j = 0; j < resultTopline.getChildren().length; j++) {
+ TCComponentBOMLine bomLine = (TCComponentBOMLine) resultTopline.getChildren()[j].getComponent();
+ System.out.println("bomLine.getItem().getType():" + bomLine.getItem().getType());
+ if (Arrays.asList(needChangeUomTypeList).contains(bomLine.getItem().getType())) {
+ // ĵλ
+ System.out.println("ʼĵλ");
+ String uomName = "Each.";
+ try {
+ TCUserService userservice = session.getUserService();
+ userservice.call("connor_set_uom", new Object[] { bomLine.getItem(), uomName });
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("connor_set_uomķδעû");
+ }
+ System.out.println("ĵλ");
+ }
+ bomLine.lock();
+ if (countMap.containsKey(bomLine.getItemRevision())) {
+ bomLine.setStringProperty("bl_quantity",
+ String.valueOf(countMap.get(bomLine.getItemRevision())));
+ System.out.println("Set bl_quantity for item " + bomLine.getItem().getProperty("item_id")
+ + " to " + countMap.get(bomLine.getItemRevision()));
+ }
+ if (itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) {
+ String quantity = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"));
+ System.out.println("Found quantity for item " + bomLine.getItem().getProperty("item_id") + ": "
+ + quantity);
+ if (quantity == null || quantity.isEmpty() || quantity.equals("0")) {
+ String uom = "";
+ try {
+ uom = bomLine.getPropertyDisplayableValue("bl_uom");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println("Unit of measure for item " + bomLine.getItem().getProperty("item_id")
+ + ": " + uom);
+ if (!uom.equals("ÿ")) {
+ quantity = "1.00";
+ }
+ }
+ System.out.println("Setting bl_quantity for item " + bomLine.getItem().getProperty("item_id")
+ + " to " + quantity);
+ if (quantity.indexOf(".") > 0) {
+ Double bomNum = Double.parseDouble(quantity);
+ System.out.println("bomNum:" + bomNum);
+ System.out.println("ʼֵbl_quantityΪ" + bomNum);
+ bomLine.setStringProperty("bl_quantity", bomNum.toString());
+ qMap.put(bomLine.getItem().getStringProperty("item_id"), bomNum.toString());
+ } else {
+ Integer bomNum = Integer.parseInt(quantity);
+ System.out.println("bomNum:" + bomNum);
+ System.out.println("ʼֵbl_quantityΪ" + bomNum);
+ bomLine.setStringProperty("bl_quantity", bomNum.toString());
+ qMap.put(bomLine.getItem().getStringProperty("item_id"), bomNum.toString());
+ }
+ }
+ bomLine.save();
+ bomLine.unlock();
+ }
+ resultTopline.save();
+ resultTopline.unlock();
+ resultTopline.refresh();
+ if (resultTopline.getBOMView() != null) {
+ resultTopline.getBOMView().save();
+ resultTopline.getBOMView().unlock();
+ resultTopline.getBOMView().refresh();
+ System.out.println("Refreshed BOM view for topItem: " + topItem.getProperty("item_id"));
+ System.out.println("ݹֵ");
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
+ TCComponentBOMWindow view = winType.create(null);
+ TCComponentBOMLine line = view.setWindowTopLine(topItem, topItem.getLatestItemRevision(), null, null);
+
+ reviceQuantity(line, qMap);
+ view.close();
+ }
+ }
+ recreateBom.close();
+
+ }
+ }
+
+ private void reviceQuantity(TCComponentBOMLine topBomLine, Map qMap) throws TCException {
+ // TODO Auto-generated method stub
+ if (topBomLine.hasChildren()) {
+ AIFComponentContext[] childrens = topBomLine.getChildren();
+ for (AIFComponentContext aifComponentContext : childrens) {
+ TCComponentBOMLine bomLine = (TCComponentBOMLine) aifComponentContext.getComponent();
+ if(qMap.containsKey(bomLine.getItem().getStringProperty("item_id"))) {
+ bomLine.lock();
+ bomLine.setProperty("bl_quantity", qMap.get(bomLine.getItem().getStringProperty("item_id")));
+ bomLine.save();
+ bomLine.unlock();
+ }
+ reviceQuantity(bomLine,qMap);
+ }
+ }
+
+ }
+
+ /**
+ * ´BOM
+ *
+ * @param item
+ * @param itemlists
+ * @throws TCException
+ */
+ public TCComponentBOMWindow recreateBom(TCComponentItemRevision topItemRev,
+ ArrayList itemRevisionlists, boolean isDelete,
+ HashMap countMap) throws TCException {
+ TCComponentBOMWindow bomWindow = null;
+ try {
+ System.out.println("Starting to recreate BOM for topItemRev: " + topItemRev.getProperty("item_id"));
+
+ TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
+ bomWindow = bomWindowType.create(null);
+ System.out.println("Created BOM window.");
+
+ TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), topItemRev, null, null);
+ resultTopline = topline;
+ bomWindow.lock();
+ topline.lock();
+ System.out.println("Locked BOM window and top line.");
+
+ if (isDelete) {
+ System.out.println("Deleting existing children from top line.");
+ if (topline.hasChildren()) {
+ AIFComponentContext[] childrens = topline.getChildren();
+ for (AIFComponentContext children : childrens) {
+ ((TCComponentBOMLine) children.getComponent()).cut();
+ System.out.println(
+ "Deleted child with ID: " + children.getComponent().getProperty("bl_child_id"));
+ }
+ }
+ }
+
+ System.out.println("Adding items from countMap to top line.");
+ Set> entrySet = countMap.entrySet();
+ for (Entry entry : entrySet) {
+ topline.add(entry.getKey().getItem(), entry.getKey(), null, false, "");
+ System.out.println(
+ "Added item " + entry.getKey().getProperty("item_id") + " with quantity " + entry.getValue());
+ }
+
+ topline.save();
+ topline.unlock();
+ topline.refresh();
+ System.out.println("Saved, unlocked, and refreshed top line.");
+
+ if (topline.getBOMView() != null) {
+ topline.getBOMView().save();
+ topline.getBOMView().unlock();
+ topline.getBOMView().refresh();
+ System.out.println("Saved, unlocked, and refreshed BOM view.");
+ }
+
+ } catch (Exception e) {
+ System.out.println("Exception occurred while recreating BOM:");
+ e.printStackTrace();
+ } finally {
+ if (bomWindow != null) {
+ bomWindow.save();
+ bomWindow.unlock();
+ bomWindow.refresh();
+ System.out.println("Saved, unlocked, refreshed, and closed BOM window.");
+ }
+ }
+ return bomWindow;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomHandler.java b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomHandler.java
new file mode 100644
index 0000000..923c6c2
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomHandler.java
@@ -0,0 +1,30 @@
+package com.connor.ferrorTech.metal.materialManage;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCSession;
+
+
+public class DbomTransitionToEbomHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ // TODO Auto-generated method stub
+ AbstractAIFApplication app = AIFUtility.getCurrentApplication();
+ TCSession session = (TCSession) app.getSession();
+ try {
+ DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(app.getTargetComponent(),session);
+ command.executeModal();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
+}
diff --git a/src/com/connor/ferrorTech/metal/materialManage/JTreeTable.java b/src/com/connor/ferrorTech/metal/materialManage/JTreeTable.java
new file mode 100644
index 0000000..bb0cdec
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/materialManage/JTreeTable.java
@@ -0,0 +1,85 @@
+package com.connor.ferrorTech.metal.materialManage;
+
+import java.awt.event.MouseEvent;
+import java.util.List;
+
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+
+import org.jdesktop.swingx.JXTreeTable;
+
+public class JTreeTable extends JXTreeTable {
+
+
+ private List isNotEditableRow;
+ //CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this);
+ TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this);
+
+ public List getIsNotEditableRow() {
+ return isNotEditableRow;
+ }
+
+ public void setIsNotEditableRow(List isNotEditableRow) {
+ this.isNotEditableRow = isNotEditableRow;
+ }
+
+ public JTreeTable(JTreeTableModel testTreeTableModel) {
+ // TODO Auto-generated constructor stub
+ super(testTreeTableModel);
+ }
+
+ @Override
+ public boolean isCellEditable(int arg0, int arg1) {
+ // TODO Auto-generated method stub
+ return true;//super.isCellEditable(arg0, arg1);
+ }
+
+ @Override
+ public TableCellEditor getCellEditor(int row, int column) {
+ // TODO Auto-generated method stub
+ //if(isNotEditableRow.contains(row) && column == 2)
+
+
+ return cellEditor;
+ //return super.getCellEditor(row, column);
+ }
+
+ public String getToolTipText(MouseEvent e) {
+ int row = this.rowAtPoint(e.getPoint());
+ int col = this.columnAtPoint(e.getPoint());
+ String tiptextString = null;
+ if (row > -1 && col > -1) {
+ Object value = this.getValueAt(row, col);
+ if (null != value && !"".equals(value))
+ tiptextString = value.toString();// ʾԪ
+ }
+ return tiptextString;
+ }
+
+ @Override
+ public TableCellRenderer getCellRenderer(int row, int column) {
+ // TODO Auto-generated method stub
+ if(this.getValueAt(row, 2) != null && (this.getValueAt(row, 2).toString().equals("0") || this.getValueAt(row, 2).toString().equals("1")) && column == 2)
+ {
+ return checkboxRenderer;
+ }
+ else
+ {
+ return super.getCellRenderer(row, column);
+ }
+ }
+
+ //
+ public void HiddenCell(int column) {
+ TableColumn tc = this.getTableHeader().getColumnModel()
+ .getColumn(column);
+ tc.setMaxWidth(0);
+ tc.setPreferredWidth(0);
+ tc.setWidth(0);
+ tc.setMinWidth(0);
+ this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0);
+ this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0);
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/materialManage/JTreeTableModel.java b/src/com/connor/ferrorTech/metal/materialManage/JTreeTableModel.java
new file mode 100644
index 0000000..e7ec010
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/materialManage/JTreeTableModel.java
@@ -0,0 +1,117 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.connor.ferrorTech.metal.materialManage;
+
+import java.util.List;
+
+import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
+import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
+import org.jdesktop.swingx.treetable.TreeTableNode;
+
+/**
+ *
+ * @author vearn
+ */
+public class JTreeTableModel extends DefaultTreeTableModel {
+
+ private String[] _names = { "DBOM", "EBOM","ѡ", "EBOMID", "","","״̬","Ӧڵ"};
+
+
+ private List isNotEditableRow;
+
+
+
+ public JTreeTableModel(TreeTableNode node) {
+ super(node);
+ }
+
+
+ public List getIsNotEditableRow() {
+ return isNotEditableRow;
+ }
+
+ public void setIsNotEditableRow(List isNotEditableRow) {
+ this.isNotEditableRow = isNotEditableRow;
+ }
+
+ /**
+ * е
+ */
+ @Override
+ public int getColumnCount() {
+ return _names.length;
+ }
+
+ /**
+ * ͷʾ
+ */
+ @Override
+ public String getColumnName(int column) {
+ return _names[column];
+ }
+
+ /**
+ * ڵԪʾObject
+ */
+ @Override
+ public Object getValueAt(Object node, int column) {
+ Object value = null;
+ if (node instanceof DefaultMutableTreeTableNode) {
+ DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node;
+ Object o = mutableNode.getUserObject();
+ if (o != null && o instanceof NodeBean) {
+ NodeBean bean = (NodeBean) o;
+ switch (column) {
+ case 0:
+ value = bean.getDbom();
+ break;
+ case 1:
+ value = bean.getEbom();
+ break;
+ case 2:
+ value = bean.getLabel();
+ break;
+ case 3:
+ value = bean.getEbomId();
+ break;
+ case 4:
+ value = bean.getEbomDesc();
+ break;
+ case 5:
+ value = bean.getNum();
+ break;
+ case 6:
+ value = bean.getRefreshStatus();
+ break;
+ case 7:
+ value = bean.getParentString();
+ break;
+ }
+ }
+ }
+ return value;
+ }
+
+ /**
+ * еԪܱ༭
+ *
+ * @param the node (i.e. row) for which editing is to be determined
+ * @param the column for which editing is to be determined
+ * @return false
+ */
+ @Override
+ public boolean isCellEditable(Object node, int column) {
+ //if(column == 5)
+ //{
+ return true;
+ //}
+ //else
+ //{
+ // return false;
+ //}
+ }
+
+
+}
diff --git a/src/com/connor/ferrorTech/metal/materialManage/NodeBean.java b/src/com/connor/ferrorTech/metal/materialManage/NodeBean.java
new file mode 100644
index 0000000..829f722
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/materialManage/NodeBean.java
@@ -0,0 +1,87 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.connor.ferrorTech.metal.materialManage;
+
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+
+/**
+ *
+ * @author vearn
+ */
+public class NodeBean {
+
+ private String dbom;//ID
+ private String dId; //dBOMID
+ private String ebom;//
+ private TCComponentItemRevision eRevision;//eBOm汾
+ private String ebomId;//
+ private String ebomDesc;//
+ private String num;//
+ private String label;//
+ private String refreshStatus;//״̬
+ private String parentString;//Ӧڵ
+
+ public TCComponentItemRevision geteRevision() {
+ return eRevision;
+ }
+ public void seteRevision(TCComponentItemRevision eRevision) {
+ this.eRevision = eRevision;
+ }
+ public String getdId() {
+ return dId;
+ }
+ public void setdId(String dId) {
+ this.dId = dId;
+ }
+ public String getDbom() {
+ return dbom;
+ }
+ public void setDbom(String dbom) {
+ this.dbom = dbom;
+ }
+ public String getEbom() {
+ return ebom;
+ }
+ public void setEbom(String ebom) {
+ this.ebom = ebom;
+ }
+ public String getEbomId() {
+ return ebomId;
+ }
+ public void setEbomId(String ebomId) {
+ this.ebomId = ebomId;
+ }
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+ public String getRefreshStatus() {
+ return refreshStatus;
+ }
+ public void setRefreshStatus(String refreshStatus) {
+ this.refreshStatus = refreshStatus;
+ }
+ public String getParentString() {
+ return parentString;
+ }
+ public void setParentString(String parentString) {
+ this.parentString = parentString;
+ }
+ public String getNum() {
+ return num;
+ }
+ public void setNum(String num) {
+ this.num = num;
+ }
+ public String getEbomDesc() {
+ return ebomDesc;
+ }
+ public void setEbomDesc(String ebomDesc) {
+ this.ebomDesc = ebomDesc;
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/materialManage/TableCellCheckboxRenderer.java b/src/com/connor/ferrorTech/metal/materialManage/TableCellCheckboxRenderer.java
new file mode 100644
index 0000000..23c0445
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/materialManage/TableCellCheckboxRenderer.java
@@ -0,0 +1,71 @@
+package com.connor.ferrorTech.metal.materialManage;
+
+import java.awt.Component;
+import java.util.List;
+
+import javax.swing.JCheckBox;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.EventListenerList;
+import javax.swing.table.TableCellRenderer;
+
+
+public class TableCellCheckboxRenderer extends JCheckBox implements
+ TableCellRenderer {
+ private List processRows;
+ protected EventListenerList listenerList = new EventListenerList();
+ protected ChangeEvent changeEvent = new ChangeEvent(this);
+ //private TestTreeTableModel tableModel;
+
+ public List getProcessRows() {
+ return processRows;
+ }
+
+ public void setProcessRows(List processRows) {
+ this.processRows = processRows;
+
+ }
+
+ public TableCellCheckboxRenderer(final JTreeTable table) {
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus, int row, int column) {
+ // TODO Auto-generated method stub
+ this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ
+ this.setBorderPainted(true);
+
+ if(value != null)
+ {
+// if(value.toString().equals("1"))
+// {
+// if(table.getColumnName(column).equals("") && hasFocus)
+// {
+// if(table.getValueAt(row, column + 1).toString().equals("1"))
+// {
+// table.setValueAt(0, row, column + 1);
+// }
+// }
+// else if(table.getColumnName(column).equals("ɾ") && hasFocus)
+// {
+// if(table.getValueAt(row, column - 1).toString().equals("1"))
+// {
+// table.setValueAt(0, row, column - 1);
+// }
+// }
+// }
+// if(value.toString().equals("1"))
+// {
+// System.out.println(value.toString().equals("1") + "====");
+// }
+ this.setSelected(value.toString().equals("1"));
+ }
+ else
+ {
+ this.setSelected(false);
+ }
+ return this;
+ }
+}
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftDialog.java b/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftDialog.java
new file mode 100644
index 0000000..e88705a
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftDialog.java
@@ -0,0 +1,222 @@
+package com.connor.ferrorTech.metal.processManagement.classificationCraft;
+
+import javax.swing.*;
+import javax.swing.table.AbstractTableModel;
+
+import java.awt.*;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.connor.ferrorTech.metal.processManagement.entity.CustomTableCellRenderer;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCClassificationService;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.kernel.ics.ICSAdminClass;
+import com.teamcenter.rac.kernel.ics.ICSSearchResult;
+import java.util.Arrays;
+
+public class ClassificationCraftDialog extends JFrame implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+
+ private final String title;
+
+ private final JLabel[] jLabels;
+ private final JComponent[] jComponents;
+ private JButton searchButton;
+ private JButton confirmButton;
+ private JButton cancelButton;
+
+ private JTable table;
+ private String[][] data;
+ private String[][] filteredData;
+
+ public ClassificationCraftDialog(AbstractAIFApplication application, String title, Object... args) {
+ this.application = application;
+ this.tcSession = (TCSession) this.application.getSession();
+ int count = 0;
+ this.title = title;
+ this.jLabels = (JLabel[]) args[count++];
+ this.jComponents = (JComponent[]) args[count++];
+ this.data = (String[][]) args[count];
+ this.filteredData = data;
+ }
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
+ String itemType = targetComponent.getType();
+ if (itemType.equals("VF5ccpRevision") || itemType.equals("VF5bcpRevision")) {
+ initUI();
+ } else {
+ JOptionPane.showMessageDialog(null, "Incorrect version!", "Error", JOptionPane.WARNING_MESSAGE);
+ }
+ }
+
+ public void initUI() {
+ // ôھ
+ this.setTitle(title);
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ this.setSize(780, 450); // ôڴС
+ this.setLayout(new BorderLayout()); // ò
+
+ initializationButton();
+
+ // 壬IDƵ
+ JPanel topPanel = createTopPanel();
+
+ // м壬б
+ JPanel centerPanel = createCenterPanel();
+
+ // ӵ
+ this.add(topPanel, BorderLayout.NORTH);
+ this.add(centerPanel, BorderLayout.CENTER);
+
+ this.setLocationRelativeTo(null);
+ this.setVisible(true);
+ }
+
+ public void initializationButton() {
+ searchButton = new JButton(ConstantPool.EN_BUTTON_SEARCH);
+ searchButton.setPreferredSize(new Dimension(87, 25));
+ searchButton.addActionListener(e -> {
+ searchList();
+ });
+ confirmButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ confirmButton.setPreferredSize(new Dimension(87, 25)); // ȷťijΪ100x30
+ confirmButton.addActionListener(e -> {
+ // ִȷرմڵ
+ this.dispose();
+ doTask();
+ });
+
+ cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ cancelButton.setPreferredSize(new Dimension(87, 25)); // ȡťijΪ100x30
+ cancelButton.addActionListener(e -> {
+ // ִȡرմڵ
+ this.dispose();
+ });
+ }
+
+ public JPanel createTopPanel() {
+ JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
+ topPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 10));
+ Font serif = new Font("Serif", Font.BOLD, 13);
+
+ for (int i = 0; i < jLabels.length; i++) {
+ jLabels[i].setFont(serif);
+ topPanel.add(jLabels[i]);
+ jComponents[i].setFont(serif);
+ topPanel.add(jComponents[i]);
+ }
+
+ topPanel.add(searchButton);
+ topPanel.add(confirmButton);
+ topPanel.add(cancelButton);
+ return topPanel;
+ }
+
+ public JPanel createCenterPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout());
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ // Զ TableModel
+ AbstractTableModel tableModel = new AbstractTableModel() {
+ @Override
+ public int getRowCount() {
+ return data.length;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 1; // ֻһ
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ // ÿһеĵһ
+ return data[rowIndex][1];
+ }
+ };
+
+ // JTable ģ
+ table = new JTable(tableModel);
+ table.setTableHeader(null); // ȥͷ
+ table.setShowGrid(false); // ȥ
+ table.setRowHeight(22); // иΪ30
+ table.setIntercellSpacing(new Dimension(0, 0)); // ȥԪ֮ļ
+
+ table.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
+
+ centerPanel.add(new JScrollPane(table), BorderLayout.CENTER);
+ return centerPanel;
+ }
+
+ public void searchList() {
+ String id = ((JTextField) jComponents[0]).getText();
+ String name = ((JTextField) jComponents[1]).getText();
+
+ //
+ filteredData = new String[data.length][data[0].length];
+ int row = 0;
+ for (String[] item : data) {
+ String[] splitItem = item[1].split(":");
+ boolean matchId = id.isEmpty() || splitItem[0].contains(id);
+ boolean matchName = name.isEmpty() || splitItem[1].contains(name);
+ if (matchId && matchName) {
+ filteredData[row++] = item;
+ }
+ }
+
+ AbstractTableModel tableModel = new AbstractTableModel() {
+ @Override
+ public int getRowCount() {
+ return filteredData.length;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 1; // ֻһ
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ return filteredData[rowIndex][1];
+ }
+ };
+
+ table.setModel(tableModel);
+ }
+
+ public void doTask() {
+ // ȡѡе
+ int[] selectedRow = table.getSelectedRows();
+
+ if (selectedRow.length > 0) {
+ String[][] selectItems = new String[selectedRow.length][];
+ for (int i = 0; i < selectedRow.length; i++) {
+ String[] selectedItem = filteredData[selectedRow[i]];
+ selectItems[i] = selectedItem;
+ System.out.println("Selected Item: " + Arrays.toString(selectedItem));
+ }
+ String[] uid = new String[selectItems.length];
+ for (int i = 0; i < selectItems.length; i++) {
+ uid[i] = selectItems[i][0];
+ }
+ ClassificationCraftOperation classificationCraftOperation = new ClassificationCraftOperation(application,
+ uid);
+
+ // رմ
+ this.dispose();
+ this.tcSession.queueExcludedOperation(classificationCraftOperation);
+ } else {
+ // ûѡκУԵʾϢ
+ JOptionPane.showMessageDialog(this, "Please select a row.", "No Selection", JOptionPane.WARNING_MESSAGE);
+ }
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftHandler.java b/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftHandler.java
new file mode 100644
index 0000000..5437614
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftHandler.java
@@ -0,0 +1,66 @@
+package com.connor.ferrorTech.metal.processManagement.classificationCraft;
+
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCClassificationService;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.kernel.ics.ICSAdminClass;
+import com.teamcenter.rac.kernel.ics.ICSSearchResult;
+
+
+
+public class ClassificationCraftHandler extends AbstractHandler {
+
+ private static final String PREFERNCER = "VF5TYPICAL_GY_LIB";
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ JLabel[] jLabels = new JLabel[]{new JLabel("Technical ID"), new JLabel("Technical Name")};
+ JComponent[] jComponents = new JComponent[]{new JTextField(10),new JTextField(10)};
+ String[][] data = null;
+ try {
+ data = getClassificationData(application);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ ClassificationCraftDialog dialog = new ClassificationCraftDialog(application,"Process Routing Library", jLabels, jComponents,data);
+ new Thread(dialog).start();
+
+ return null;
+ }
+
+ public String[][] getClassificationData(AbstractAIFApplication application) throws TCException {
+ TCSession tcSession = (TCSession)application.getSession();
+ String classifyId = tcSession.getPreferenceService().getStringValue(PREFERNCER);
+ System.out.println("classifyId = " + classifyId);
+
+ TCClassificationService classificationService = tcSession.getClassificationService();
+
+ ICSAdminClass c = classificationService.newICSAdminClass();
+ c.load(classifyId);
+ ICSSearchResult[] results = classificationService.searchICOs(classifyId, null, 0);
+
+ String[][] data = new String[results.length][2];
+ for (int i = 0; i < results.length; i++) {
+ String uid = results[i].getWsoUid();
+ data[i][0] = uid;
+ data[i][1] = results[i].getIcoId() +":" +tcSession.stringToComponent(uid).getStringProperty("object_name");
+ }
+ return data;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftOperation.java b/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftOperation.java
new file mode 100644
index 0000000..872b9d5
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/classificationCraft/ClassificationCraftOperation.java
@@ -0,0 +1,165 @@
+package com.connor.ferrorTech.metal.processManagement.classificationCraft;
+
+import java.awt.Frame;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFOperation;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.DeepCopyInfo;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class ClassificationCraftOperation extends AbstractAIFOperation {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+ private String[] uid;
+
+ private TCComponentItemRevision targetRev;
+
+ public ClassificationCraftOperation(AbstractAIFApplication application, String[] itemUid) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.uid = itemUid;
+ }
+
+ @Override
+ public void executeOperation() throws Exception {
+ TCComponentFolder targetFolder = getTargetFolder();
+ if (targetFolder != null) {
+ TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ String name = referenceValueArray[0].getStringProperty("object_name");
+ TCComponentItemType component = (TCComponentItemType) tcSession.getTypeComponent("VF5gy");
+ TCComponentItem item = component.create(component.getNewID(), "", "VF5gy", name, "", null);
+ TCComponentItemRevision gyItemRev = item.getLatestItemRevision();
+ targetFolder.add("contents", item);
+
+ TCComponentItemRevision targetComponent = (TCComponentItemRevision)application.getTargetComponent();
+ targetComponent.add("VF5gygx", item);
+ gyItemRev.add("IMAN_METarget", targetComponent);
+ setReference(gyItemRev, uid);
+ } else {
+ MessageBox.post("Currently, no folder named POR was found !", "error", MessageBox.ERROR);
+ }
+ }
+
+ public TCComponentFolder getTargetFolder() throws TCException {
+ System.out.println("ʼȡtargetļ");
+ InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
+ String type = targetComponent.getType();
+ targetRev = (TCComponentItemRevision) targetComponent;
+
+ TCComponentFolder targetFolder = (TCComponentFolder) TcUtil.getLastReferenced(targetRev.getItem(), "Folder","Item");
+ if(targetFolder!=null) {
+ targetFolder = (TCComponentFolder) TcUtil.getLastReferenced(targetFolder, "VF5xmwjj","Folder");
+ }else {
+ MessageBox.post("The current parent Folder is not referenced !", "error", MessageBox.ERROR);
+ }
+
+ if (targetFolder != null) {
+ TCComponent[] valueArray = targetFolder.getTCProperty("contents").getReferenceValueArray();
+ for (TCComponent tcComponent : valueArray) {
+ if (tcComponent instanceof TCComponentFolder
+ && tcComponent.getStringProperty("object_name").equals("POR")) {
+ return (TCComponentFolder) tcComponent;
+ }
+ }
+ } else {
+ System.out.println("targetFolder is null");
+ }
+ return null;
+ }
+
+ public void setReference(TCComponentItemRevision gyItemRev, String[] itemUid) throws TCException {
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
+ TCComponentBOMWindow view = winType.create(null);
+ TCComponentBOMWindow newView = winType.create(null);
+ newView.lock();
+
+ String[] formProp = new String[] {
+ "vf5zbsj","vf5zbsjdw","vf5jqsj","vf5jqsjdw","vf5rgsj","vf5rgsjdw","vf5fjfy","vf5fjfydw"
+ };
+ String[] bomProp = new String[] {
+ "VF5zbsj","VF5zbsjdw","VF5jqsj","VF5jqsjdw","VF5rgsj","VF5rgsjdw","VF5fjfy","VF5fjfydw"
+ };
+ // µĹնBom
+ TCComponentBOMLine newTopBomLine = newView.setWindowTopLine(gyItemRev.getItem(),gyItemRev, null, null);
+ if (itemUid != null) {
+ TCComponent[] tcComponents = tcSession.stringToComponent(itemUid);
+ for (TCComponent tcComponent : tcComponents) {
+ TCComponentItem gyItem = null;
+ TCComponentItemRevision gyRev = null;
+
+ System.out.println("ǰitem: "+tcComponent.getStringProperty("object_name"));
+ if(tcComponent instanceof TCComponentItem) {
+ System.out.println("is TCComponentItem");
+ gyItem = (TCComponentItem) tcComponent;
+ gyRev = gyItem.getLatestItemRevision();
+ }else if(tcComponent instanceof TCComponentItemRevision) {
+ System.out.println("is TCComponentItemRevision");
+ gyRev = (TCComponentItemRevision)tcComponent;
+ gyItem = gyRev.getItem();
+ }
+
+ TCComponentBOMLine bomLine = null;
+ if(gyItem != null && gyRev != null) {
+ bomLine = view.setWindowTopLine(gyItem,gyRev, null, null);
+ }else {
+ throw new CustomException("tcItem or tcItemRev is null");
+ }
+
+ boolean hasChildren = bomLine.hasChildren();
+ if (hasChildren) {
+ AIFComponentContext[] childrenBomLines = bomLine.getChildren();
+
+ System.out.println("begin copy bom !");
+ // ѡеgx Bom
+ for (AIFComponentContext children : childrenBomLines) {
+ // ǿתΪTCComponentBOMLine
+ TCComponentBOMLine component = (TCComponentBOMLine) children.getComponent();
+ TCComponentItemRevision oldGxRev = component.getItemRevision();
+
+ String name = oldGxRev.getStringProperty("object_name");
+ TCComponentItemType gxType = (TCComponentItemType) this.tcSession
+ .getTypeComponent(oldGxRev.getItem().getStringProperty("object_type"));
+ TCComponentItem newGxItem = oldGxRev.saveAsItem(gxType.getNewID(), "", name, "", true,
+ (DeepCopyInfo[]) null);
+
+ TCComponentBOMLine newBomLine = newTopBomLine.add(newGxItem,newGxItem.getLatestItemRevision(),null,false,"");
+
+ TCComponent oldGxRevForm = oldGxRev.getRelatedComponent("IMAN_master_form_rev");
+ for (int j = 0; j < formProp.length; j++) {
+ String prop = oldGxRevForm.getStringProperty(formProp[j]);
+ System.out.println(bomProp[j] + " : "+prop);
+ newBomLine.setProperty(bomProp[j], prop);
+ }
+
+ }
+ }else {
+ System.out.println("Currently, BomLine has no children");
+ }
+ }
+ newView.save();
+ newView.unlock();
+ newView.close();
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+ } else {
+ MessageBox.post("Currently no process object selected !", "Info", MessageBox.INFORMATION);
+ }
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesDialog.java b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesDialog.java
new file mode 100644
index 0000000..3f1fc69
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesDialog.java
@@ -0,0 +1,250 @@
+package com.connor.ferrorTech.metal.processManagement.classificationProcesses;
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableColumnModel;
+
+import java.awt.*;
+import java.util.Arrays;
+import java.util.Objects;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+
+public class ClassificationProcessesDialog extends JFrame implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private final String title;
+ private final String subtitle;
+
+ private JLabel[] jLabels;
+ private JComponent[] jComponents;
+
+ private JButton searchButton;
+ private JButton okButton;
+ private JButton cancelButton;
+
+ private String[] columnNames;
+ private String[][] data;
+ private JTable table;
+
+ public ClassificationProcessesDialog(AbstractAIFApplication application, String title, Object... args) {
+ this.application = application;
+ this.tcSession = (TCSession) this.application.getSession();
+
+ this.subtitle = "Process List";
+ int count = 0;
+ this.title = title;
+ this.jLabels = (JLabel[]) args[count++];
+ this.jComponents = (JComponent[]) args[count++];
+ this.columnNames = (String[]) args[count++];
+ this.data = (String[][]) args[count];
+ }
+
+ @Override
+ public void run() {
+ try {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
+ TCComponentItemRevision tempComponentRev = null;
+ if (targetComponent instanceof TCComponentBOMLine) {
+ tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ } else if (targetComponent instanceof TCComponentItemRevision) {
+ tempComponentRev = (TCComponentItemRevision) targetComponent;
+ } else {
+ throw new CustomException("Please Select The Correct Version !");
+ }
+
+ if (tempComponentRev.getStringProperty("object_type").equals("VF5gyRevision")) {
+ initUI();
+ } else {
+ JOptionPane.showMessageDialog(null, "Incorrect version!", "Error", JOptionPane.WARNING_MESSAGE);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
+ }
+ }
+
+ public TCComponentBOMLine judgeSingleSelectRevision(AbstractAIFApplication application, String[] revType) {
+ InterfaceAIFComponent targetComponent = application.getTargetComponent();
+ try {
+ TCComponentItemRevision tempComponentRev = null;
+ if (targetComponent instanceof TCComponentBOMLine) {
+ tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ } else if (targetComponent instanceof TCComponentItemRevision) {
+ tempComponentRev = (TCComponentItemRevision) targetComponent;
+ } else {
+ throw new CustomException("Please Select The Correct Version !");
+ }
+
+ if (tempComponentRev != null && revType != null && revType.length > 0) {
+ for (int i = 0; i < revType.length; i++) {
+ if (tempComponentRev.getType().equals(revType[i])) {
+ return (TCComponentBOMLine) targetComponent;
+ }
+ }
+ } else {
+ System.out.println("tempComponentRev or revType is null !");
+ }
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public void initializationButton() {
+ searchButton = new JButton(ConstantPool.EN_BUTTON_SEARCH);
+ searchButton.setPreferredSize(new Dimension(80, 23));
+ searchButton.addActionListener(e -> {
+ searchList();
+ });
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ okButton.addActionListener(e -> {
+ this.dispose();
+ doTask();
+ });
+ cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ cancelButton.addActionListener(e -> {
+ this.dispose();
+ });
+ }
+
+ public void initUI() {
+ // ôھ
+ this.setTitle(title);
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ this.setSize(700, 500); // ôڴС
+ this.setLayout(new BorderLayout()); // ò
+
+ initializationButton();
+
+ JPanel topPanel = createTopPanel();
+
+ JPanel centerPanel = createCenterPanel();
+
+ JPanel bottomPanel = createBottomPanel();
+
+ this.add(topPanel, BorderLayout.NORTH);
+ this.add(centerPanel, BorderLayout.CENTER);
+ this.add(bottomPanel, BorderLayout.SOUTH);
+
+ this.setLocationRelativeTo(null);
+ this.setVisible(true);
+ }
+
+ public JPanel createTopPanel() {
+ JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
+
+ topPanel.add(jLabels[0]);
+ topPanel.add(jComponents[0]);
+
+ topPanel.add(jLabels[1]);
+ topPanel.add(jComponents[1]);
+ topPanel.add(searchButton);
+ return topPanel;
+ }
+
+ public JPanel createCenterPanel() {
+ JPanel centerPanel = new JPanel(new BorderLayout(10, 10));
+ centerPanel.setBorder(BorderFactory.createTitledBorder(subtitle));
+ centerPanel.setPreferredSize(new Dimension(400, 200));
+
+ table = new JTable(new DefaultTableModel(data, columnNames));
+ table.setRowHeight(18);
+ table.getTableHeader().setReorderingAllowed(false);
+ table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+
+ TableColumnModel columnModel = table.getColumnModel();
+ for (int i = 0; i < columnModel.getColumnCount(); i++) {
+ columnModel.getColumn(i).setPreferredWidth(100); // ÿеĿΪ120
+ }
+
+ table.removeColumn(columnModel.getColumn(columnModel.getColumnCount() - 1));
+
+ DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer() {
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
+ boolean hasFocus, int row, int column) {
+ Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ ((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER); // ıж
+ return c;
+ }
+ };
+
+ for (int i = 0; i < columnModel.getColumnCount(); i++) {
+ columnModel.getColumn(i).setCellRenderer(centerRenderer);
+ }
+
+ JScrollPane scrollPane = new JScrollPane(table);
+ scrollPane.setPreferredSize(new Dimension(400, 150));
+ centerPanel.add(scrollPane, BorderLayout.CENTER);
+ return centerPanel;
+ }
+
+ public JPanel createBottomPanel() {
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 60, 10));
+ bottomPanel.add(okButton);
+ bottomPanel.add(cancelButton);
+ return bottomPanel;
+ }
+
+ public void searchList() {
+ if (jComponents.length < 2) {
+ throw new IllegalArgumentException("jComponents 鳤Ȳ");
+ }
+
+ String processCode = ((JTextField) jComponents[0]).getText().trim();
+ String technicalName = ((JTextField) jComponents[1]).getText().trim();
+
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+ model.setRowCount(0); //
+
+ if (data == null || data.length == 0) {
+ return;
+ }
+
+ for (String[] rowData : data) {
+ String code = Objects.toString(rowData[0], "");
+ String name = Objects.toString(rowData[1], "");
+ if (code.contains(processCode) && name.contains(technicalName)) {
+ model.addRow(rowData);
+ }
+ }
+ }
+
+ public void doTask() {
+ int[] selectedRows = table.getSelectedRows();
+
+ String[][] selectedData = new String[selectedRows.length][];
+ if (selectedRows.length > 0) {
+ DefaultTableModel model = (DefaultTableModel) table.getModel();
+ for (int i = 0; i < selectedRows.length; i++) {
+ String[] rowData = new String[model.getColumnCount()];
+ for (int j = 0; j < model.getColumnCount(); j++) {
+ rowData[j] = (String) model.getValueAt(selectedRows[i], j);
+ }
+ selectedData[i] = rowData;
+ System.out.println("Selected Row Data: " + Arrays.toString(rowData));
+ }
+
+ ClassificationProcessesOperation classificationProcessesOperation = new ClassificationProcessesOperation(
+ application, selectedData);
+ this.tcSession.queueExcludedOperation(classificationProcessesOperation);
+ } else {
+ System.out.println("No rows selected");
+ }
+
+ this.dispose();
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesHandler.java b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesHandler.java
new file mode 100644
index 0000000..78ccc68
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesHandler.java
@@ -0,0 +1,105 @@
+package com.connor.ferrorTech.metal.processManagement.classificationProcesses;
+
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCClassificationService;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentForm;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.kernel.ics.ICSAdminClass;
+import com.teamcenter.rac.kernel.ics.ICSSearchResult;
+
+
+/**
+ * ù
+ * @author Administrator
+ *
+ */
+public class ClassificationProcessesHandler extends AbstractHandler {
+
+ private static final String PREFERNCER = "VF5TYPICAL_GX_LIB";
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ JLabel[] labels = new JLabel[]{new JLabel("ID"), new JLabel("Name")};
+ JComponent[] components = {new JTextField(14), new JTextField(14)};
+
+ @SuppressWarnings("unused")
+ String[] chColumnNames = new String[]{
+ "ID", "","", "ʱ", "ʱ䵥λ",
+ "ı","ʱ","ʱ䵥λ", "˹ʱ", "˹ʱ䵥λ",
+ "ӷ","ӷõλ",""
+ };
+ String[] enColumnNames = new String[]{
+ "ID", "Name", "Operate type", "WorkCenterInternalI","Setup",
+ "Setup Unit","Machine","Machine Unit", "Labor", "Labor Unit",
+ "Production Overhead","Production Overhead Unit",""
+ };
+ String[][] data = null;
+ try {
+ String[] rowProp = {
+ "item_id","object_name","vf5gxlx","vf5gzzxsj","vf5zbsj",
+ "vf5zbsjdw","vf5jqsj","vf5jqsjdw","vf5rgsj","vf5rgsjdw",
+ "vf5fjfy","vf5fjfydw"
+ };
+ data = getPreference(application,rowProp);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ClassificationProcessesDialog dialog = new ClassificationProcessesDialog(
+ application,"Operation Library",labels,components,enColumnNames,data);
+ new Thread(dialog).start();
+
+ return null;
+ }
+
+ public String[][] getPreference(AbstractAIFApplication application,String[] rowProp) throws TCException {
+ TCSession tcSession = (TCSession)application.getSession();
+ String classifyId = tcSession.getPreferenceService().getStringValue(PREFERNCER);
+ System.out.println("classifyId = " + classifyId);
+
+ TCClassificationService classificationService = tcSession.getClassificationService();
+
+ ICSAdminClass c = classificationService.newICSAdminClass();
+ c.load(classifyId);
+ ICSSearchResult[] results = classificationService.searchICOs(classifyId, null, 0);
+
+ String[][] tableData = new String[results.length][];
+ int rowIndex = 0;
+ for (ICSSearchResult result : results) {
+ String[] rowData = new String[rowProp.length+1];
+ String wsoUid = result.getWsoUid();
+
+ InterfaceAIFComponent targetInstance = tcSession.stringToComponent(wsoUid);
+ if(targetInstance instanceof TCComponentItemRevision) {
+ TCComponentItemRevision tempRev = (TCComponentItemRevision)targetInstance;
+ TCComponent[] referenceValueArray = tempRev.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
+ TCComponentForm itemForm = (TCComponentForm)referenceValueArray[0];
+ rowData[0] = tempRev.getStringProperty(rowProp[0]);
+ rowData[1] = tempRev.getStringProperty(rowProp[1]);
+ for (int i = 2; i < rowProp.length; i++) {
+ rowData[i] = itemForm.getStringProperty(rowProp[i]);
+ }
+ rowData[rowProp.length] = wsoUid;
+ tableData[rowIndex++] = rowData;
+ }
+ }
+ return tableData;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesOperation.java b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesOperation.java
new file mode 100644
index 0000000..4489810
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesOperation.java
@@ -0,0 +1,115 @@
+package com.connor.ferrorTech.metal.processManagement.classificationProcesses;
+
+import java.awt.Frame;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFOperation;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.DeepCopyInfo;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCComponentType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class ClassificationProcessesOperation extends AbstractAIFOperation {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+ private String[][] tableData;
+
+ public ClassificationProcessesOperation(AbstractAIFApplication application,String[][] tableData) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.tableData = tableData;
+ }
+
+ @Override
+ public void executeOperation() throws Exception {
+ TCComponentBOMLine targetBomLine = judgeSingleSelectRevision(application, new String[]{"VF5gyRevision"});
+ if(targetBomLine!=null) {
+ copyItem(targetBomLine,tableData);
+ }else {
+ MessageBox.post("Fail Get TargetBomLine !", "Error", MessageBox.ERROR);
+ }
+ }
+
+ public void copyItem(TCComponentBOMLine targetBomLine,String[][] data) throws TCException {
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
+ TCComponentBOMWindow view = winType.create(null);
+
+ String[] formProp = new String[] {
+ "vf5zbsj","vf5zbsjdw","vf5jqsj","vf5jqsjdw","vf5rgsj","vf5rgsjdw","vf5fjfy","vf5fjfydw"
+ };
+ String[] bomProp = new String[] {
+ "VF5zbsj","VF5zbsjdw","VF5jqsj","VF5jqsjdw","VF5rgsj","VF5rgsjdw","VF5fjfy","VF5fjfydw"
+ };
+ view.lock();
+ boolean flag = false;
+ for (int i = 0; i < data.length; i++) {
+ String[] rowData = data[i];
+ String uid = rowData[rowData.length-1];
+ TCComponent gxComponent = this.tcSession.stringToComponent(uid);
+ if(gxComponent instanceof TCComponentItemRevision) {
+ TCComponentItemRevision gxItemRev = (TCComponentItemRevision)gxComponent;
+ String name = gxItemRev.getStringProperty("object_name");
+ TCComponentItemType typeComponent = (TCComponentItemType) this.tcSession
+ .getTypeComponent(gxItemRev.getItem().getStringProperty("object_type"));
+ TCComponentItem newItem = gxItemRev.saveAsItem(typeComponent.getNewID(), "", name, "", true,(DeepCopyInfo[]) null);
+
+ TCComponentBOMLine newBomLine = targetBomLine.add(newItem,newItem.getLatestItemRevision(),null,false,"");
+
+ TCComponent gxRevForm = gxItemRev.getRelatedComponent("IMAN_master_form_rev");
+ for (int j = 0; j < bomProp.length; j++) {
+ String prop = gxRevForm.getStringProperty(formProp[j]);
+ System.out.println(bomProp[j] + " : " + prop);
+ newBomLine.setProperty(bomProp[j], prop);
+ }
+ flag =true;
+ }
+ }
+ if(flag) {
+ MessageBox.post("Add Successfully !", "Info", MessageBox.INFORMATION);
+ }else {
+ MessageBox.post("Add Failed !", "Rrror", MessageBox.ERROR);
+ }
+ view.save();
+ view.unlock();
+ }
+
+ public TCComponentBOMLine judgeSingleSelectRevision(AbstractAIFApplication application,
+ String[] revType) {
+ InterfaceAIFComponent targetComponent = application.getTargetComponent();
+ try {
+ TCComponentItemRevision tempComponentRev = null;
+ if (targetComponent instanceof TCComponentBOMLine) {
+ tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
+ }else if(targetComponent instanceof TCComponentItemRevision) {
+ tempComponentRev = (TCComponentItemRevision) targetComponent;
+ }else {
+ throw new CustomException("Please Select The Correct Version !");
+ }
+
+ if (tempComponentRev != null && revType != null && revType.length > 0) {
+ for (int i = 0; i < revType.length; i++) {
+ if (tempComponentRev.getType().equals(revType[i])) {
+ return (TCComponentBOMLine)targetComponent;
+ }
+ }
+ } else {
+ System.out.println("tempComponentRev or revType is null !");
+ }
+ } catch (TCException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/workCenter_locale.properties b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/workCenter_locale.properties
new file mode 100644
index 0000000..cbaf113
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/workCenter_locale.properties
@@ -0,0 +1,12 @@
+workCenterDialog.0=Work Center Library
+workCenterDialog.1=WorkCenterInternalI
+workCenterDialog.2=Name
+workCenterDialog.3=Operate type
+workCenterDialog.4=Setup
+workCenterDialog.5=Setup Unit
+workCenterDialog.6=Machine
+workCenterDialog.7=Machine Unit
+workCenterDialog.8=Labor
+workCenterDialog.9=Labor Unit
+workCenterDialog.10=Production Overhead
+workCenterDialog.11=Production Overhead Unit
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftHandler.java b/src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftHandler.java
new file mode 100644
index 0000000..83fcb7e
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftHandler.java
@@ -0,0 +1,134 @@
+package com.connor.ferrorTech.metal.processManagement.createCraft;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.exception.CustomException;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateCraftHandler extends AbstractHandler {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private TCComponentItemRevision targetRev;
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ this.application = AIFUtility.getCurrentApplication();
+ this.tcSession = (TCSession) application.getSession();
+
+ boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application,
+ new String[] { "VF5ccpRevision", "VF5bcpRevision" }, "ItemRevision");
+ if (judgeSingleSelectComponent) {
+ TCComponentFolder targetFolder = null;
+ try {
+ targetFolder = getTargetFolder();
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CustomException e1) {
+ e1.printStackTrace();
+ } catch (Exception e2) {
+ e2.printStackTrace();
+ }
+ if (targetFolder != null) {
+ try {
+ String name = targetRev.getStringProperty("object_name");
+ System.out.println("target Folder is :" + targetFolder.getStringProperty("object_name"));
+ TCComponentItemRevision gyItemRev = createItem(tcSession, "VF5gy", name);
+ if(gyItemRev!=null) {
+ System.out.println("new item : "+gyItemRev.getStringProperty("object_name"));
+ }
+ gyItemRev.add("IMAN_METarget", targetRev);
+ targetRev.add("VF5gygx", gyItemRev.getItem());
+ targetFolder.add("contents", gyItemRev.getItem());
+ MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
+
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ } else {
+ MessageBox.post("Currently, no folder named POR was found !", "error", MessageBox.ERROR);
+ }
+ }
+ return null;
+ }
+
+ public TCComponentFolder getTargetFolder() throws Exception {
+ System.out.println("ʼȡtargetļ");
+ InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
+ targetRev = (TCComponentItemRevision) targetComponent;
+
+ TCComponentItemRevision ccpRev = null;
+ if(targetRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
+ ccpRev = TcUtil.getLastUsed(targetRev, "VF5ccpRevision");
+ }else {
+ ccpRev = targetRev;
+ }
+
+ if(ccpRev == null) {
+ throw new CustomException(targetRev.getStringProperty("object_name") + " : ccpRev is not exist !");
+ }
+ TCComponentFolder targetFolder = null;
+ AIFComponentContext[] ccpParent = ccpRev.getItem().whereReferenced();
+ for (int i = 0; i < ccpParent.length; i++) {
+ InterfaceAIFComponent component = (TCComponent) ccpParent[i].getComponent();
+ if (component.getProperty("object_type").equals("Folder")) {
+ targetFolder = (TCComponentFolder) ccpParent[i].getComponent();
+ }
+ }
+
+
+ if (targetFolder == null) {
+ throw new CustomException(ccpRev.getStringProperty("object_name") + " : parent's Folder is not exist !");
+ }
+ TCComponentFolder topFolder = null;
+ AIFComponentContext[] topFolders = targetFolder.whereReferenced();
+ for (int j = 0; j < topFolders.length; j++) {
+ InterfaceAIFComponent component = (TCComponent) topFolders[j].getComponent();
+ if (component.getType().equals("VF5xmwjj")) {
+ topFolder = (TCComponentFolder) topFolders[j].getComponent();
+ targetFolder = topFolder;
+ }
+ }
+
+ if (topFolder == null) {
+ throw new CustomException(targetFolder.getStringProperty("object_name") + " : parent's Folder is not exist !");
+ }
+ if (targetFolder != null) {
+ TCComponent[] valueArray = targetFolder.getTCProperty("contents").getReferenceValueArray();
+ for (TCComponent tcComponent : valueArray) {
+ if (tcComponent instanceof TCComponentFolder
+ && tcComponent.getStringProperty("object_name").equals("POR")) {
+ return (TCComponentFolder) tcComponent;
+ }
+ }
+ } else {
+ System.out.println("targetFolder is null");
+ }
+ return null;
+ }
+
+ public TCComponentItemRevision createItem(TCSession session, String type,
+ String name) throws TCException {
+ TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
+ TCComponentItem item = itemType.create(itemType.getNewID(), "", type, name, "", null);
+ return item.getLatestItemRevision();
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesDialog.java b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesDialog.java
new file mode 100644
index 0000000..f93fd7d
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesDialog.java
@@ -0,0 +1,158 @@
+package com.connor.ferrorTech.metal.processManagement.createProcesses;
+
+import java.awt.Frame;
+
+import javax.swing.JFrame;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
+import com.teamcenter.rac.aif.kernel.AIFComponentContext;
+import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentType;
+import com.teamcenter.rac.kernel.TCProperty;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+import javax.swing.*;
+import java.awt.*;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class CreateProcessesDialog extends JFrame implements Runnable {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private String title;
+ private JLabel[] jLabels;
+ private JComponent[] jComponents;
+
+ private String[] lovArrays;
+
+ private JButton okButton;
+ private JButton celButton;
+
+ private Map> lovMap;
+
+ public CreateProcessesDialog(AbstractAIFApplication application, Object... args) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ int count = 0;
+ this.title = (String) args[count++];
+ this.jLabels = (JLabel[]) args[count++];
+ this.jComponents = (JComponent[]) args[count++];
+ this.lovMap = (Map>) args[count];
+ }
+
+ @Override
+ public void run() {
+ initUI();
+ }
+
+ public void initUI() {
+ this.setTitle(title);
+ this.setSize(460, 570);
+ // ʼ
+ initializationComponent();
+ // ݵJFrame λ
+ JScrollPane centerPanel = getCenterPanel();
+ JPanel bottomPanel = getBottomPanel();
+
+ this.getContentPane().add(centerPanel, BorderLayout.CENTER);
+ this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ // ôھ
+ this.setLocationRelativeTo(null);
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ // ÿɼ
+ this.setVisible(true);
+ }
+
+ /**
+ * ýĿ
+ */
+ private void initializationComponent() {
+ okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
+ celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
+ }
+
+ private JScrollPane getCenterPanel() {
+ // TODO Auto-generated method stub
+ JPanel centerPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints customLayout = new GridBagConstraints();
+ // ÿJLabelJTextFieldӵformPanel
+ for (int i = 0; i < jLabels.length; i++) {
+ customLayout.insets = new Insets(5, 30, 5, 20);// ߾
+ customLayout.gridx = 0;
+ customLayout.weightx = 0;
+ customLayout.anchor = GridBagConstraints.LINE_START;
+ jLabels[i].setFont(new Font("ź", Font.BOLD, 13));
+ centerPanel.add(jLabels[i], customLayout);
+
+ customLayout.insets = new Insets(5, 3, 5, 30);// ߾
+ customLayout.gridx = 1;
+ customLayout.weightx = 0;
+ customLayout.fill = GridBagConstraints.HORIZONTAL;
+ JComponent jComponent = jComponents[i];
+ jComponent.setFont(new Font("ź", Font.BOLD, 15));
+
+ if (i > 3 && jComponent instanceof JComboBox) {
+ ((JComboBox) jComponent).setSelectedItem("MIN");
+ }
+ centerPanel.add(jComponent, customLayout);
+ }
+ // йܵJPanel
+ return new JScrollPane(centerPanel);
+ }
+
+ private JPanel getBottomPanel() {
+ // TODO Auto-generated method stub
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10));
+ bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
+ bottomPanel.add(this.okButton);
+ bottomPanel.add(this.celButton);
+ // Ӽ
+ okButton.addActionListener(e -> {
+ this.dispose(); // رմ
+ boolean confirmed = confirmFunction();
+ });
+ celButton.addActionListener(e -> {
+ this.dispose(); // رմ
+ });
+ return bottomPanel;
+ }
+
+ public boolean confirmFunction() {
+ Map propMap = new LinkedHashMap<>();
+ String[] prop = new String[] { "object_name", "vf5gxlx", "vf5gzzxsj", "vf5zbsj", "vf5zbsjdw", "vf5jqsj",
+ "vf5jqsjdw", "vf5rgsj", "vf5rgsjdw", "vf5fjfy", "vf5fjfydw" };
+ for (int i = 0; i < jComponents.length; i++) {
+ if (jComponents[i] instanceof JTextField) {
+ propMap.put(prop[i], ((JTextField) jComponents[i]).getText());
+ } else if (jComponents[i] instanceof JComboBox) {
+ JComboBox comboBox = (JComboBox) jComponents[i];
+ Object selectedItem = comboBox.getSelectedItem();
+ String displayValue = selectedItem != null ? selectedItem.toString() : "";
+
+ if (i == 1) {
+ Map map = lovMap.get("vf5gxlxlov");
+ propMap.put(prop[i], map.get(displayValue));
+ } else if (i == 4 || i == 6 || i == 8 || i == 10) {
+ Map map = lovMap.get("VF5dwlov");
+ propMap.put(prop[i], map.get(displayValue));
+ } else {
+ propMap.put(prop[i], displayValue);
+ }
+ }
+ }
+ System.out.println(propMap);
+ CreateProcessesOperation createProcessesOperation = new CreateProcessesOperation(application, propMap);
+ this.tcSession.queueExcludedOperation(createProcessesOperation);
+ return true;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesHandler.java b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesHandler.java
new file mode 100644
index 0000000..8d74694
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesHandler.java
@@ -0,0 +1,106 @@
+package com.connor.ferrorTech.metal.processManagement.createProcesses;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTextField;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.connor.ferrorTech.metal.util.SwingUtil;
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+/**
+ *
+ * @author Administrator
+ *
+ */
+public class CreateProcessesHandler extends AbstractHandler {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ this.application = AIFUtility.getCurrentApplication();
+ this.tcSession = (TCSession)application.getSession();
+
+ boolean flag = false;
+ try {
+ flag = isCorrectType();
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if(flag) {
+ String[] chLabelName = new String[]{
+ "", "", "ı", "ʱ", "ʱ䵥λ",
+ "ʱ", "ʱ䵥λ", "˹ʱ", "˹ʱ䵥λ", "ӷ",
+ "ӷõλ"
+ };
+ String[] enLabelName = new String[]{
+ "Operate Name", "Operate type", "WorkCenterInternalI", "Setup", "Setup Unit",
+ "Machine Time", "Machine Unit", "Labor", "Labor Unit", "Production Overhead",
+ "Production Overhead Unit"
+ };
+ JLabel[] jLabels = new JLabel[enLabelName.length];
+ JComponent[] jComponents = new JComponent[enLabelName.length];
+ Map map = new HashMap<>();
+ map.put(1, "vf5gxlxlov");
+ map.put(2, "VF5gzzxlov2");
+ map.put(4, "VF5dwlov");
+ map.put(6, "VF5dwlov");
+ map.put(8, "VF5dwlov");
+ map.put(10, "VF5dwlov");
+ Map> lovMap = new HashMap>();
+ Map> dynamicLovMap = new HashMap>();
+
+ for (int i = 0; i < enLabelName.length; i++) {
+ if(i ==2) {
+ jComponents[i] = new JComboBox<>(TcUtil.getDynamicLOV(tcSession, map.get(i), dynamicLovMap));
+ }else if(map.containsKey(i)){
+ jComponents[i] = new JComboBox<>(SwingUtil.getKeyValue(map.get(i), lovMap));
+ }else{
+ jComponents[i] = new JTextField(14);
+ }
+ jLabels[i] = new JLabel(enLabelName[i]);
+ }
+
+ CreateProcessesDialog action = new CreateProcessesDialog(application,"Create Operation",jLabels,jComponents,lovMap);
+ new Thread(action).start();
+ }
+
+ return null;
+ }
+
+ private boolean isCorrectType() throws TCException {
+ // TODO Auto-generated method stub
+ InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
+ if(targetComponent instanceof TCComponentBOMLine) {
+ String itemType = ((TCComponentBOMLine)targetComponent).getItemRevision().getStringProperty("object_type");
+ if (itemType.equals("VF5gyRevision")) {
+ return true;
+ } else {
+ JOptionPane.showMessageDialog(null, "Incorrect version!", "Error", JOptionPane.WARNING_MESSAGE);
+ return false;
+ }
+ }else {
+ MessageBox.post("Please select the Bom Item !", "error", MessageBox.ERROR);
+ return false;
+ }
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesOperation.java b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesOperation.java
new file mode 100644
index 0000000..c37131a
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesOperation.java
@@ -0,0 +1,68 @@
+package com.connor.ferrorTech.metal.processManagement.createProcesses;
+
+import java.awt.Frame;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFOperation;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentBOMLine;
+import com.teamcenter.rac.kernel.TCComponentBOMWindow;
+import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
+import com.teamcenter.rac.kernel.TCComponentForm;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCComponentType;
+import com.teamcenter.rac.kernel.TCSession;
+
+public class CreateProcessesOperation extends AbstractAIFOperation {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+
+ private Map propMap;
+
+ public CreateProcessesOperation(AbstractAIFApplication application, Map propMap) {
+ this.application = application;
+ this.tcSession = (TCSession) application.getSession();
+ this.propMap = propMap;
+ }
+
+ @Override
+ public void executeOperation() throws Exception {
+ TCComponentItemType typeComponent = (TCComponentItemType) tcSession.getTypeComponent("VF5gx");
+ TCComponentItem item = typeComponent.create(typeComponent.getNewID(), "", "VF5gx", propMap.get("object_name"),
+ "", null);
+ TCComponentItemRevision itemRevision = item.getLatestItemRevision();
+ TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev");
+ System.out.println("item uid : " + item.getUid());
+
+ TCComponentBOMLine targetBomLine = (TCComponentBOMLine) this.application.getTargetComponent();
+ TCComponentBOMLine bomLine = targetBomLine.add(item, itemRevision, null, false, "");
+
+ Set keySet = propMap.keySet();
+ for (String key : keySet) {
+ System.out.println("ǰֵ=> key:"+key + " || value: "+propMap.get(key));
+ if (key.equals("object_name")) {
+ continue;
+ }
+ form.setStringProperty(key, propMap.get(key));
+
+ if (key.equals("vf5gxlx") || key.equals("vf5gzzxsj")) {
+ continue;
+ }
+ bomLine.setProperty(capitalizeFirstTwo(key), propMap.get(key));
+ }
+ targetBomLine.save();
+ }
+
+ public String capitalizeFirstTwo(String input) {
+ if (input == null || input.length() < 2) {
+ return input == null ? "" : input.toUpperCase();
+ }
+ return input.substring(0, 2).toUpperCase() + input.substring(2);
+ }
+}
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/processManagement/createProcesses/createWorkCenter_locale.properties b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/createWorkCenter_locale.properties
new file mode 100644
index 0000000..3a80d2a
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/createWorkCenter_locale.properties
@@ -0,0 +1,12 @@
+createWorkCenterDialog.1=Create Work Center
+createWorkCenterDialog.1=Operate Name
+createWorkCenterDialog.2=Operate type
+createWorkCenterDialog.3=WorkCenterInternalI
+createWorkCenterDialog.4=Setup
+createWorkCenterDialog.5=Setup Unit
+createWorkCenterDialog.6=Machine Time
+createWorkCenterDialog.7=Machine Unit
+createWorkCenterDialog.8=Labor
+createWorkCenterDialog.9=Labor Unit
+createWorkCenterDialog.10=Production Overhead
+createWorkCenterDialog.11=Production Overhead Unit
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/processManagement/entity/CustomTableCellRenderer.java b/src/com/connor/ferrorTech/metal/processManagement/entity/CustomTableCellRenderer.java
new file mode 100644
index 0000000..ce6dd1f
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/processManagement/entity/CustomTableCellRenderer.java
@@ -0,0 +1,29 @@
+package com.connor.ferrorTech.metal.processManagement.entity;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.LineBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.*;
+
+/**
+ * @ClassName CustomTableCellRenderer
+ * @Description Զ嵥ԪȾ
+ * @Author chenzc
+ * @Date 2024/12/3 11:54
+ **/
+public class CustomTableCellRenderer extends DefaultTableCellRenderer {
+ private final Border noFocusBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
+ private final Border focusBorder = new LineBorder(Color.YELLOW, 1);
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ JComponent c = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if (isSelected) {
+ c.setBorder(focusBorder);
+ } else {
+ c.setBorder(noFocusBorder);
+ }
+ return c;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileAction.java b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileAction.java
new file mode 100644
index 0000000..adb67b8
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileAction.java
@@ -0,0 +1,21 @@
+package com.connor.ferrorTech.metal.quotationManagement.createClientFile;
+
+import java.awt.Frame;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
+
+public class CreateClientFileAction extends AbstractAIFAction {
+
+ private AbstractAIFApplication application;
+ public CreateClientFileAction(AbstractAIFApplication application, Frame frame, String param) {
+ super(application, frame, param);
+ this.application = application;
+ }
+
+ @Override
+ public void run() {
+ CreateClientFileDialog dialog = new CreateClientFileDialog(this.application);
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileDialog.java b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileDialog.java
new file mode 100644
index 0000000..5f53069
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileDialog.java
@@ -0,0 +1,328 @@
+package com.connor.ferrorTech.metal.quotationManagement.createClientFile;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.ListOfValuesInfo;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentDatasetType;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCComponentListOfValues;
+import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCProperty;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateClientFileDialog {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+ private JFrame frame;
+
+ private JLabel[] inputLalels;
+ private JTextField[] inputFields;
+ private JLabel[] selectLabels;
+ private JComboBox[] selectFields;
+
+ private String[] fieldName;
+ private String[] lovArrays;
+
+ private JButton okButton;
+ private JButton celButton;
+
+ private Map> lovMap;
+
+ private final String Type = "VF5khda";
+ private TCComponentItemType itemType;
+ private TCComponentFolder targetFolder;
+
+ public CreateClientFileDialog(AbstractAIFApplication application) {
+ this.application = application;
+ this.tcSession = (TCSession) this.application.getSession();
+ run();
+ }
+
+ /**
+ * ʼ
+ */
+ private void initUi() {
+ try {
+ frame = new JFrame("Create Customer Profiles");
+
+ frame.setSize(520, 520);
+ // ʼϢ
+ setPanelProperties();
+ // ݵJFrame λ
+ JScrollPane centerPanel = getTopPanel();
+ JPanel bottomPanel = getButtomPanel();
+
+ frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
+ frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ // ôھ
+ frame.setLocationRelativeTo(null);
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ // ÿɼ
+ frame.setVisible(true);
+
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ MessageBox.post("InitUi Error!!", "error", MessageBox.ERROR);
+ }
+ }
+
+
+ /**
+ * ýĿ
+ */
+ private void setPanelProperties() {
+ fieldName = new String[]{"vf5khjc","vf5lxr","vf5lxdh","vf5khhy","vf5gs","vf5khjl","vf5lx","vf5zt"};
+ lovArrays = new String[] {"VF5khhylov","VF5gslov","VF5lxlov","VF5ztlov"};
+ lovMap = new HashMap>();
+
+ inputLalels =new JLabel[]{
+ new JLabel("Customer name"), new JLabel("Customer abbreviation"), new JLabel("Contact person"),
+ new JLabel("Telephone number"),new JLabel("Account manager")};
+ selectLabels = new JLabel[]{new JLabel("Customer industry"),new JLabel("Business unit/company"),new JLabel("Type"),new JLabel("Status")};
+
+ try {
+
+ inputFields = new JTextField[] {new JTextField(14),new JTextField(14),new JTextField(14),new JTextField(14),new JTextField(14)};
+
+ selectFields = new JComboBox[lovArrays.length];
+ for (int i = 0; i < lovArrays.length; i++) {
+ selectFields[i]= new JComboBox(getRealLoveName(lovArrays[i]));
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ MessageBox.post("get LOV error", "error", MessageBox.ERROR);
+ }
+ okButton = new JButton("Confirm");
+ celButton = new JButton("Cancel");
+ }
+
+ private JScrollPane getTopPanel() {
+ // TODO Auto-generated method stub
+ JPanel centerPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+
+ // ÿJLabelJTextFieldӵformPanel
+ for (int i = 0; i < inputLalels.length; i++) {
+ c.insets = new Insets(5, 30, 5, 5);// ߾
+ c.gridx = 0;
+ c.weightx = 0;
+ c.anchor = GridBagConstraints.LINE_START;
+ inputLalels[i].setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(inputLalels[i], c);
+
+ c.insets = new Insets(5, 3, 5, 30);// ߾
+ c.gridx = 1;
+ c.weightx = 0;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ JTextField jTextField = inputFields[i];
+ jTextField.setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(jTextField, c);
+ }
+
+ // ÿJLabelJTextFieldӵformPanel
+ for (int i = 0; i < selectLabels.length; i++) {
+ c.insets = new Insets(5, 30, 5, 5);// ߾
+ c.gridx = 0;
+ c.weightx = 0;
+ c.anchor = GridBagConstraints.LINE_START;
+ selectLabels[i].setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(selectLabels[i], c);
+
+ c.insets = new Insets(5, 3, 5, 30);// ߾
+ c.gridx = 1;
+ c.weightx = 1;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ JComboBox jComboBox = selectFields[i];
+ jComboBox.setFont(new Font("ź", Font.BOLD, 15));
+ jComboBox.setSelectedIndex(-1);
+ centerPanel.add(jComboBox, c);
+ }
+ // йܵJPanel
+ return new JScrollPane(centerPanel);
+ }
+
+ private JPanel getButtomPanel() {
+ // TODO Auto-generated method stub
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ bottomPanel.add(this.okButton);
+ bottomPanel.add(this.celButton);
+ //Ӽ
+ okButton.addActionListener(e->{
+ frame.dispose(); // رմ
+ createUser();
+ });
+ celButton.addActionListener(e->{
+ frame.dispose(); // رմ
+ });
+ return bottomPanel;
+ }
+
+ public void run() {
+ InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
+ if (selectComponent !=null && selectComponent instanceof TCComponentFolder) {
+ targetFolder = (TCComponentFolder) selectComponent;
+ initUi();
+ } else {
+ MessageBox.post("Please select a folder", "error", MessageBox.ERROR);
+ }
+
+ }
+
+ // ȡlovֵ
+ public String[] getRealLoveName(String lovName) throws TCException {
+ String[] myLovArray =null;
+ Map tempLovMap = new HashMap<>();
+ TCComponentListOfValues lobList = TCComponentListOfValuesType
+ .findLOVByName(lovName);
+ System.out.println("lovName:"+lovName);
+ try {
+ if (lobList != null) {
+ ListOfValuesInfo info = lobList.getListOfValues();
+ String[] valuesList = info.getStringListOfValues();
+ myLovArray = new String[valuesList.length];
+ for (int w = 0; w < valuesList.length; w++) {
+ String disValue = info.getDisplayableValue(valuesList[w]);
+ myLovArray[w]=disValue;
+ tempLovMap.put(disValue,(String)valuesList[w]);
+ System.out.println("Lov dis = "+valuesList[w]+" | "+disValue);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("get Lov is error!");
+ }
+
+ lovMap.put(lovName, tempLovMap);
+ return myLovArray;
+ }
+
+ /**
+ *
+ userNameInput;
+ userSmallNameInput;
+ contactsInput;
+ contactNumberInput;
+ industryBox;
+ ascriptionBox;
+ managerInput;
+ saleBox;
+ typeBox;
+ stateBox
+ */
+ @SuppressWarnings("unused")
+ private Boolean createUser(){
+ String userName = inputFields[0].getText();
+ String userSmallName = inputFields[1].getText();
+ String contacts = inputFields[2].getText();
+ String contactNumber = inputFields[3].getText();
+ String manager = inputFields[4].getText();
+ String industry = (String)selectFields[0].getSelectedItem();
+ String ascription = (String)selectFields[1].getSelectedItem();
+// String sale = (String)this.saleBox.getSelectedItem();
+ String type = (String)selectFields[2].getSelectedItem();
+ String state = (String)selectFields[3].getSelectedItem();
+
+// StringBuffer info = new StringBuffer("");
+// info.append("userName = "+userName);
+// info.append("\nuserSmallName = "+userSmallName);
+// info.append("\ncontacts = "+contacts);
+// info.append("\ncontactNumber = "+contactNumber);
+// info.append("\nindustry = "+industry);
+// info.append("\nascription = "+ascription);
+// info.append("\nmanager = "+manager);
+// info.append("\nsale = "+sale);
+// info.append("\ntype = "+type);
+// info.append("\nstate = "+state);
+
+ String[] contentField = new String[] {userSmallName,contacts,contactNumber,industry
+ ,ascription,manager,type,state};
+
+// MessageBox.post(info.toString(),"info",MessageBox.INFORMATION);
+
+ if(userName == null) {
+ MessageBox.post("Customer name cannot be empty","create error",MessageBox.ERROR);
+ return false;
+ }
+
+ try {
+ System.out.println("Type = "+ Type);
+ itemType = (TCComponentItemType) this.tcSession.getTypeComponent(Type);
+ String itemID = itemType.getNewID();
+ TCComponentItem item = itemType.create(itemID,null,Type,userName, "", null);
+
+ TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
+ TCComponent[] referenceValueArray = latestItemRevision.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
+ if(referenceValueArray.length>0) {
+ for (int i = 0; i < contentField.length; i++) {
+ String trueValue = "";
+ Map tempMap = null;
+ switch(fieldName[i]){
+ case "vf5khhy":{
+ tempMap = lovMap.get("VF5khhylov");
+ break;
+ }case "vf5gs":{
+ tempMap = lovMap.get("VF5gslov");
+ break;
+ }case "vf5lx":{
+ tempMap = lovMap.get("VF5lxlov");
+ break;
+ }case "vf5zt":{
+ tempMap = lovMap.get("VF5ztlov");
+ break;
+ }default:{
+ break;
+ }}
+ if(tempMap!=null) {
+ System.out.println(fieldName[i] + "lov => " + tempMap.toString());
+ trueValue = tempMap.get(contentField[i]);
+ }else {
+ trueValue = contentField[i];
+ }
+ System.out.println(" => :" + fieldName[i]+ " = "+trueValue);
+ referenceValueArray[0].setProperty(fieldName[i],trueValue);
+ }
+ }else {
+ // form
+ }
+ if(item!=null) {
+ targetFolder.add("contents", item);
+ targetFolder.refresh();
+ MessageBox.post("Successfully created customer profile!","Tip",MessageBox.INFORMATION);
+ }else {
+ MessageBox.post("Failed to create customer profile!","Tip",MessageBox.ERROR);
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return true;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileHandler.java b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileHandler.java
new file mode 100644
index 0000000..d9e32d2
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.quotationManagement.createClientFile;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateClientFileHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateClientFileAction action = new CreateClientFileAction(application, null, null);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/customerProfiles_locale.properties b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/customerProfiles_locale.properties
new file mode 100644
index 0000000..2f48033
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/customerProfiles_locale.properties
@@ -0,0 +1,10 @@
+customerProfilesDialog.0=Create Customer Profiles
+customerProfilesDialog.1=Customer name
+customerProfilesDialog.2=Customer abbreviation
+customerProfilesDialog.3=Contact person
+customerProfilesDialog.4=Telephone number
+customerProfilesDialog.5=Account manager
+customerProfilesDialog.6=Customer industry
+customerProfilesDialog.7=Business unit/company
+customerProfilesDialog.8=Type
+customerProfilesDialog.9=Status
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsAction.java b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsAction.java
new file mode 100644
index 0000000..0980dd4
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsAction.java
@@ -0,0 +1,97 @@
+package com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings;
+
+import java.awt.Frame;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCComponentType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateQuotationDrawingsAction extends AbstractAIFAction {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+ private TCComponentItemRevision targetRev;
+
+ private TCComponentItemType drawType ;
+ private final static String DRAW_TYPE = "VF5bjtz";
+
+ public CreateQuotationDrawingsAction(AbstractAIFApplication application, Frame frame, String param) {
+ super(application, frame, param);
+ this.application = application;
+ this.tcSession = (TCSession)application.getSession();
+ }
+
+ @Override
+ public void run() {
+ InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
+ if (selectComponent !=null && selectComponent instanceof TCComponentItemRevision) {
+ targetRev = (TCComponentItemRevision) selectComponent;
+ System.out.println("ѡж汾Ϊ "+ targetRev.getType());
+ if(targetRev.getType().equals("VF5bjxmRevision")) {
+ try {
+ boolean judgeReference = judgeReference(targetRev);
+ if(judgeReference) {
+ drawType =(TCComponentItemType)tcSession.getTypeComponent(DRAW_TYPE);
+ TCComponentItem targetItem = targetRev.getItem();
+ // ȡĿVF5xjxxdgxϵѯϢ
+ TCComponent[] targetRevItem = targetRev.getTCProperty("VF5xjxxdgx").getReferenceValueArray();
+ if(targetRevItem.length<1) {
+ throw new IndexOutOfBoundsException("VF5xjxxdgx ϵûж");
+ }
+ TCComponentItemRevision xjxxdItemRev = ((TCComponentItem) targetRevItem[0]).getLatestItemRevision();
+
+ String newID = drawType.getNewID();
+ TCComponentItem drawItem = drawType.create(newID, null, DRAW_TYPE, targetItem.getStringProperty("object_name"), "", null);
+
+
+ TCComponentItemRevision drawItemRevision = drawItem.getLatestItemRevision();
+ TCComponent[] drawItemRevisionMaster = drawItemRevision.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
+ drawItemRevisionMaster[0].setProperty("vf5khmc", xjxxdItemRev.getRelatedComponent("IMAN_master_form_rev").getStringProperty("vf5khmc"));
+
+ // ڱĿ汾ıͼֽϵvf5bjtzgxϵ
+ targetRev.add("VF5tzgx", drawItem);
+
+ MessageBox.post("Successfully created quotation drawing !", "Success", MessageBox.INFORMATION);
+ }else {
+ MessageBox.post("The Quotation Drawing Object Already Exists. !", "Success", MessageBox.WARNING);
+ }
+
+
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("Failed to create object type !");
+ e.printStackTrace();
+ } catch (IndexOutOfBoundsException e) {
+ MessageBox.post("There are no objects in the current version relationship", "Warning", MessageBox.WARNING);
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }else {
+ MessageBox.post("Please Select A Collect Revision !", "error", MessageBox.ERROR);
+ }
+ } else {
+ MessageBox.post("Please Select A Revision Item !", "error", MessageBox.ERROR);
+ }
+ }
+
+ public boolean judgeReference(TCComponentItemRevision targetRev) throws TCException {
+ TCComponent[] relatedComponents = targetRev.getRelatedComponents("VF5tzgx");
+ for (TCComponent tcComponent : relatedComponents) {
+ if(tcComponent.getType().equals(DRAW_TYPE)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsHandler.java b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsHandler.java
new file mode 100644
index 0000000..9672f74
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateQuotationDrawingsHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateQuotationDrawingsAction action = new CreateQuotationDrawingsAction(application, null, null);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectAction.java b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectAction.java
new file mode 100644
index 0000000..8178d40
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectAction.java
@@ -0,0 +1,21 @@
+package com.connor.ferrorTech.metal.quotationManagement.createQuotationProject;
+
+import java.awt.Frame;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
+
+public class CreateQuotationProjectAction extends AbstractAIFAction {
+
+ private AbstractAIFApplication application;
+ public CreateQuotationProjectAction(AbstractAIFApplication application, Frame frame, String param) {
+ super(application, frame, param);
+ this.application = application;
+ }
+
+ @Override
+ public void run() {
+ CreateQuotationProjectDialog dialog = new CreateQuotationProjectDialog(this.application);
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectDialog.java b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectDialog.java
new file mode 100644
index 0000000..801b5db
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectDialog.java
@@ -0,0 +1,513 @@
+package com.connor.ferrorTech.metal.quotationManagement.createQuotationProject;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.jdesktop.swingx.JXDatePicker;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.ListOfValuesInfo;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentFolderType;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCComponentListOfValues;
+import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCPreferenceService;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateQuotationProjectDialog extends JFrame {
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+ private JFrame frame;
+
+ private JLabel[] inputLalels;
+ private JComponent[] inputFields;
+ private JLabel[] selectLabels;
+ private JComboBox[] selectFields;
+
+ private String[] fieldName;
+ private String[] lovArrays;
+
+ private JButton okButton;
+ private JButton celButton;
+
+ private Map> lovMap;
+
+ private final String Type = "VF5bjxm";
+ private final String InnerType = "VF5xjxxd";
+ private final String InnerTypeRevision = "VF5xjxxdRevision";
+ private final String Preferences = "Salespeoples";
+ private final String FolderUIDPreferences = "VF5bjxm";
+
+ private TCComponentItemType itemType;
+ private TCComponentItemType innerItemType;
+
+ private TCComponentFolderType folderType;
+ private TCComponentFolder targetFolder;
+ private TCComponentFolder originFolder;
+
+ public CreateQuotationProjectDialog(AbstractAIFApplication application) {
+
+ this.application = application;
+ this.tcSession = (TCSession) this.application.getSession();
+ run();
+ }
+
+ /**
+ * ʼ
+ */
+ private void initUi() {
+ try {
+ frame = new JFrame("Create Quotation Projects");
+
+ frame.setSize(700, 650);
+ // ʼϢ
+ setPanelProperties();
+ // ݵJFrame λ
+ JScrollPane centerPanel = getTopPanel();
+ JPanel bottomPanel = getButtomPanel();
+
+ frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
+ frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ // ôھ
+ frame.setLocationRelativeTo(null);
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ // ÿɼ
+ frame.setVisible(true);
+
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ MessageBox.post("InitUi Error!!", "error", MessageBox.ERROR);
+ }
+ }
+
+ /**
+ * ýĿ
+ */
+ private void setPanelProperties() {
+ // Project Name Quotation drawing numberAnnualDemand Target priceWishes
+ // completing timeCustomer NameboxIs surveying productbox
+ // SalespersonboxState of emergencyboxTechnical requirementNotes
+ fieldName = new String[] { "vf5bjtzth", "vf5nxql", "vf5mbjg", "vf5khqwwcrq", "vf5khmc", "vf5sfchp", "vf5xsry",
+ "vf5jjzt", "vf5jsyq", "vf5beizhu" };
+ // Ƿ桢 State of emergency
+ lovArrays = new String[] { "VF5sflov", "VF5jjztlov" };
+ lovMap = new HashMap>();
+
+ inputLalels = new JLabel[] { new JLabel("Project name"), new JLabel("Quotation drawing number"),
+ new JLabel("Annual demand"), new JLabel("Target price"),
+ new JLabel("Customer expects quotation completion date"), new JLabel("Technical requirements"),
+ new JLabel("Remarks") };
+ selectLabels = new JLabel[] { new JLabel("Customer name"), new JLabel("Whether surveying product"),
+ new JLabel("Salesperson"), new JLabel("Emergency status") };
+
+ try {
+ inputFields = new JComponent[inputLalels.length];
+ for (int i = 0; i < inputLalels.length; i++) {
+ if (i == 4) {
+ inputFields[i] = createDatePicker();
+ } else {
+ inputFields[i] = new JTextField(14);
+ }
+ }
+
+ selectFields = new JComboBox[selectLabels.length];
+ selectFields[0] = new JComboBox(getCustomerName());
+ selectFields[1] = new JComboBox(getRealLoveName(lovArrays[0]));
+ selectFields[2] = new JComboBox(getSaleName());
+ selectFields[3] = new JComboBox(getRealLoveName(lovArrays[1]));
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ MessageBox.post("get LOV error", "error", MessageBox.ERROR);
+ }
+ okButton = new JButton("Confirm");
+ celButton = new JButton("Cancel");
+ }
+
+ private static JXDatePicker createDatePicker() {
+ // JXDatePicker
+ JXDatePicker datePicker = new JXDatePicker();
+ // ڸʽ
+ datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd"));
+ return datePicker;
+ }
+
+ private JScrollPane getTopPanel() {
+ // TODO Auto-generated method stub
+ JPanel centerPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints g = new GridBagConstraints();
+
+ // ÿJLabelJTextFieldӵformPanel
+ for (int i = 0; i < inputLalels.length; i++) {
+ if (i == inputLalels.length - 2) {
+ // ÿJLabelJTextFieldӵformPanel
+ for (int j = 0; j < selectLabels.length; j++) {
+ g.insets = new Insets(5, 30, 5, 5);// ߾
+ g.gridx = 0;
+ g.weightx = 0;
+ g.anchor = GridBagConstraints.LINE_START;
+ selectLabels[j].setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(selectLabels[j], g);
+
+ g.insets = new Insets(5, 3, 5, 30);// ߾
+ g.gridx = 1;
+ g.weightx = 1;
+ g.fill = GridBagConstraints.HORIZONTAL;
+ selectFields[j].setFont(new Font("ź", Font.BOLD, 15));
+ selectFields[j].setSelectedIndex(-1);
+ centerPanel.add(selectFields[j], g);
+ }
+ }
+ g.insets = new Insets(5, 30, 5, 5);// ߾
+ g.gridx = 0;
+ g.weightx = 0;
+ g.anchor = GridBagConstraints.LINE_START;
+ inputLalels[i].setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(inputLalels[i], g);
+
+ g.insets = new Insets(5, 3, 5, 30);// ߾
+ g.gridx = 1;
+ g.weightx = 0;
+ g.fill = GridBagConstraints.HORIZONTAL;
+ inputFields[i].setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(inputFields[i], g);
+ }
+
+ // йܵJPanel
+ return new JScrollPane(centerPanel);
+ }
+
+ private JPanel getButtomPanel() {
+ // TODO Auto-generated method stub
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ bottomPanel.add(this.okButton);
+ bottomPanel.add(this.celButton);
+ // Ӽ
+ okButton.addActionListener(e -> {
+ Boolean flag = createUser();
+ if (flag) {
+ frame.dispose(); // رմ
+ }
+ });
+ celButton.addActionListener(e -> {
+ frame.dispose(); // رմ
+ });
+ return bottomPanel;
+ }
+
+ public void run() {
+ InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
+ if (selectComponent != null && selectComponent instanceof TCComponentFolder) {
+ targetFolder = (TCComponentFolder) selectComponent;
+ initUi();
+ } else {
+ MessageBox.post("Please select a folder", "error", MessageBox.ERROR);
+ }
+
+ }
+
+ // ȡlovֵ
+ public String[] getRealLoveName(String lovName) throws TCException {
+ String[] myLovArray = null;
+ Map tempLovMap = new HashMap<>();
+ TCComponentListOfValues lobList = TCComponentListOfValuesType.findLOVByName(lovName);
+ System.out.println("lovName:" + lovName);
+ try {
+ if (lobList != null) {
+ ListOfValuesInfo info = lobList.getListOfValues();
+ String[] valuesList = info.getStringListOfValues();
+ myLovArray = new String[valuesList.length];
+ for (int w = 0; w < valuesList.length; w++) {
+ String disValue = info.getDisplayableValue(valuesList[w]);
+ myLovArray[w] = disValue;
+ tempLovMap.put(disValue, (String) valuesList[w]);
+ System.out.println("Lov dis = " + valuesList[w] + " | " + disValue);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("get Lov is error!");
+ }
+
+ lovMap.put(lovName, tempLovMap);
+ return myLovArray;
+ }
+
+ // ѯȡȥ ͻ
+ public String[] getCustomerName() {
+ LinkedHashSet customerNameLov = new LinkedHashSet();
+ try {
+ List entryNames = new ArrayList();
+ List entryValues = new ArrayList();
+ entryNames.add("vf5khjc");
+ entryValues.add("*");
+ // 1ѯƣ2ѯĿ3ѯĿӦҪѯֵ
+ InterfaceAIFComponent[] resultComponents = tcSession.search("MU_FindCustomerList",
+ entryNames.toArray(new String[entryNames.size()]),
+ entryValues.toArray(new String[entryNames.size()]));
+ for (int i = 0; i < resultComponents.length; i++) {
+ TCComponentItemRevision tcRevision = (TCComponentItemRevision) resultComponents[i];
+// TCComponent[] tcMaster = tcRevision.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
+ customerNameLov.add(tcRevision.getStringProperty("object_name"));
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ System.out.println("ѯͻƴ");
+ e.printStackTrace();
+ }
+ return customerNameLov.toArray(new String[0]);
+ }
+
+ public String[] getSaleName() {
+ TCPreferenceService preferenceService = tcSession.getPreferenceService();
+ return preferenceService.getStringValues(Preferences);
+ }
+
+ /**
+ *
+ * userNameInput; userSmallNameInput; contactsInput; contactNumberInput;
+ * industryBox; ascriptionBox; managerInput; saleBox; typeBox; stateBox
+ */
+ @SuppressWarnings("unused")
+ private Boolean createUser() {
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ String quotationName = ((JTextField) inputFields[0]).getText();
+ String drawingNumber = ((JTextField) inputFields[1]).getText();
+ String AnnualDemand = ((JTextField) inputFields[2]).getText();
+ String TargetPrice = ((JTextField) inputFields[3]).getText();
+ JXDatePicker datePicker = (JXDatePicker) inputFields[4];
+ String fileTime = "";
+ if(datePicker.getDate()!=null) {
+ fileTime = simpleDateFormat.format(datePicker.getDate());
+ }else {
+ fileTime = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now());
+ }
+ String TechnicalRequireMent = ((JTextField) inputFields[5]).getText();
+ String Notes = ((JTextField) inputFields[6]).getText();
+ String customerName = (String) selectFields[0].getSelectedItem();
+ String IsSurveying = (String) selectFields[1].getSelectedItem();
+ String SalePerson = (String) selectFields[2].getSelectedItem();
+ String StateOfEmergency = (String) selectFields[3].getSelectedItem();
+
+ System.out.println("fileTime = " + fileTime);
+ String[] split = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now()).split("-");
+ System.out.println("split = " + Arrays.toString(split));
+
+ String id = "";
+ StringBuffer fileTimeStr = new StringBuffer("");
+ fileTimeStr.append(split[0]);
+ fileTimeStr.append(split[1]);
+ fileTimeStr.append(split[2]);
+ id = fileTimeStr.toString();
+
+ try {
+ // жǷڸļ
+ Boolean flag = isExistFolder(customerName, split);
+ System.out.println("targetFolder : " + targetFolder.getStringProperty("object_name"));
+
+ String[] contentField = new String[] { drawingNumber, AnnualDemand, TargetPrice, fileTime, customerName,
+ IsSurveying, SalePerson, StateOfEmergency, TechnicalRequireMent, Notes };
+ if (quotationName == null) {
+ MessageBox.post("QuotationName cannot be empty", "create error", MessageBox.ERROR);
+ return false;
+ }
+
+ // Ŀ
+ itemType = (TCComponentItemType) this.tcSession.getTypeComponent(Type);
+ String itemID = itemType.getNewID();
+ TCComponentItem item = itemType.create(itemID, null, Type, quotationName, "", null);
+ TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
+
+ // ѯϢ
+ innerItemType = (TCComponentItemType) this.tcSession.getTypeComponent(InnerType);
+ TCComponentItem innerItem = innerItemType.create(id + "_" + queryLatestNo(id + "*"), null, InnerType,
+ quotationName, "", null);
+ TCComponentItemRevision innerRev = innerItem.getLatestItemRevision();
+
+ //
+ latestItemRevision.add("VF5xjxxdgx", innerItem);
+ TCComponent innerRevForm = innerRev.getRelatedComponent("IMAN_master_form_rev");
+ if (innerRevForm != null) {
+ for (int i = 0; i < contentField.length; i++) {
+ String trueValue = "";
+ Map tempMap = null;
+ switch (fieldName[i]) {
+ case "vf5sfchp": {
+ tempMap = lovMap.get("VF5sflov");
+ break;
+ }
+ case "vf5jjzt": {
+ tempMap = lovMap.get("VF5jjztlov");
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ if (tempMap != null) {
+ System.out.println(fieldName[i] + "lov => " + tempMap.toString());
+ trueValue = tempMap.get(contentField[i]);
+ } else {
+ trueValue = contentField[i];
+ }
+ System.out.println(" => :" + fieldName[i] + " = " + trueValue);
+ innerRevForm.setProperty(fieldName[i], trueValue);
+ }
+ targetFolder.add("contents", item);
+ ((TCComponentFolder) application.getTargetComponent()).add("contents", item);
+ targetFolder.refresh();
+ MessageBox.post("Succeed To Create Quotation Project!", "Tip", MessageBox.INFORMATION);
+ } else {
+ MessageBox.post("Failed To Create Quotation Project!", "Tip", MessageBox.ERROR);
+ }
+ } catch (TCException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (Exception e2) {
+ e2.printStackTrace();
+ }
+ return true;
+ }
+
+ public String queryLatestNo(String value) throws Exception {
+ InterfaceAIFComponent[] resultComponents = tcSession.search("MU_Find Inquiry Information Sheet",
+ new String[] { "ID" }, new String[] { value });
+ int maxValue = 0;
+ if (resultComponents.length == 0) {
+ return "01";
+ }
+ for (InterfaceAIFComponent interfaceAIFComponent : resultComponents) {
+ if (interfaceAIFComponent instanceof TCComponent) {
+ String itemId = ((TCComponent) interfaceAIFComponent).getStringProperty("item_id");
+ String[] split = itemId.split("_");
+ if (split.length >= 2) {
+ int localValue = Integer.parseInt(split[1]);
+ if (maxValue < localValue) {
+ maxValue = localValue;
+ }
+ }
+ }
+ }
+ if (maxValue != 0) {
+ maxValue ++;
+ return maxValue > 9 ? maxValue + "" : "0" + maxValue;
+ } else {
+ return "01";
+ }
+ }
+
+ public Boolean isExistFolder(String customerName, String[] folderName) {
+ TCPreferenceService getFolderUID = tcSession.getPreferenceService();
+ String value = getFolderUID.getStringValue(FolderUIDPreferences);
+
+ System.out.println("ļUID: " + value);
+ try {
+ folderType = (TCComponentFolderType) tcSession.getTypeComponent("Folder");
+ originFolder = (TCComponentFolder) tcSession.stringToComponent(value);
+// AIFComponentContext[] children = originFolder.getChildren();
+ TCComponent[] customerFolders = originFolder.getTCProperty("contents").getReferenceValueArray();
+ boolean customerFlag = true;
+ boolean yearFlag = true;
+ boolean monthFlag = true;// true ==
+ for (int i = 0; i < customerFolders.length; i++) {
+ TCComponentFolder selectCustomerFolder = (TCComponentFolder) customerFolders[i];
+ if (selectCustomerFolder.getStringProperty("object_name").equals(customerName)) {
+ TCComponent[] yearFolders = selectCustomerFolder.getTCProperty("contents").getReferenceValueArray();
+ for (int j = 0; j < yearFolders.length; j++) {
+ TCComponentFolder selectYearFolder = (TCComponentFolder) yearFolders[j];
+ if (selectYearFolder.getStringProperty("object_name").equals(folderName[0])) {
+ TCComponent[] monthFolder = selectYearFolder.getTCProperty("contents")
+ .getReferenceValueArray();
+ for (int k = 0; k < monthFolder.length; k++) {
+ TCComponentFolder selectMonthFolder = (TCComponentFolder) monthFolder[k];
+ System.out.println(
+ "ļobject_name = " + selectMonthFolder.getStringProperty("object_name"));
+ if (selectMonthFolder.getStringProperty("object_name").equals(folderName[1])) {
+ System.out.println("ڸļ");
+ targetFolder = selectMonthFolder;
+ monthFlag = false;
+ return true;
+ }
+ }
+ if (monthFlag) {
+ TCComponentFolder createMonthFolder = folderType.create(folderName[1], "", "Folder");
+ selectYearFolder.add("contents", createMonthFolder);
+ originFolder.refresh();
+ System.out.println("·ļУѾ");
+ }
+ yearFlag = false;
+ return true;
+ }
+ }
+ if (yearFlag) {
+ TCComponentFolder createMonthFolder = folderType.create(folderName[1], "", "Folder");
+
+ TCComponentFolder createYearFolder = folderType.create(folderName[0], "", "Folder");
+ createYearFolder.add("contents", createMonthFolder);
+
+ selectCustomerFolder.add("contents", createYearFolder);
+ targetFolder = createMonthFolder;
+ originFolder.refresh();
+ System.out.println("ļУѾ");
+ }
+ customerFlag = false;
+ return true;
+ }
+ }
+ if (customerFlag) {
+ // ʼ½
+ System.out.println("111");
+ TCComponentFolder createMonthFolder = folderType.create(folderName[1], "", "Folder");
+
+ TCComponentFolder createYearFolder = folderType.create(folderName[0], "", "Folder");
+ createYearFolder.add("contents", createMonthFolder);
+
+ TCComponentFolder createCustomerFolder = folderType.create(customerName, "", "Folder");
+ createCustomerFolder.add("contents", createYearFolder);
+
+ System.out.println("222 = " + originFolder.toString());
+ originFolder.add("contents", createCustomerFolder);
+ targetFolder = createMonthFolder;
+ originFolder.refresh();
+ System.out.println("ڿͻļУѾ");
+ return true;
+ }
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("ļд");
+ e.printStackTrace();
+ }
+ return false;
+ }
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectHandler.java b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectHandler.java
new file mode 100644
index 0000000..a808c68
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.quotationManagement.createQuotationProject;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateQuotationProjectHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateQuotationProjectAction action = new CreateQuotationProjectAction(application, null, null);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/quotationProjects_locale.properties b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/quotationProjects_locale.properties
new file mode 100644
index 0000000..c5a72aa
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/quotationProjects_locale.properties
@@ -0,0 +1,12 @@
+quotationProjectsDialog.0=Create Quotation Projects
+quotationProjectsDialog.1=Project name
+quotationProjectsDialog.2=Quotation drawing number
+quotationProjectsDialog.3=Annual demand
+quotationProjectsDialog.4=Target price
+quotationProjectsDialog.5=Customer expects quotation completion date
+quotationProjectsDialog.6=Customer name
+quotationProjectsDialog.7=Whether surveying product
+quotationProjectsDialog.8=Salesperson
+quotationProjectsDialog.9=Emergency status
+quotationProjectsDialog.10=Technical requirements
+quotationProjectsDialog.11=Remarks
\ No newline at end of file
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalDialog.java b/src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalDialog.java
new file mode 100644
index 0000000..ca1a852
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalDialog.java
@@ -0,0 +1,193 @@
+package com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.jdesktop.swingx.JXDatePicker;
+
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+import com.teamcenter.rac.util.PropertyLayout;
+import com.teamcenter.rac.util.UIUtilities;
+
+public class CreateTechnicalDialog extends JFrame implements Runnable {
+
+ private AbstractAIFApplication application;
+ private JFrame frame;
+
+ private JLabel nameLable;
+ private JTextField nameField;
+
+ private JButton okButton;
+ private JButton celButton;
+
+ private TCSession tcSession;
+ private TCComponentItemRevision targetRev;
+ private TCComponentItemType technicalType;
+ private final String TECHINICAL_TYPE = "VF5jsbjd";
+
+ public CreateTechnicalDialog(AbstractAIFApplication app) {
+ this.application = app;
+ this.tcSession = (TCSession) this.application.getSession();
+ }
+
+ @Override
+ public void run() {
+ boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application,
+ new String[] { "VF5bjxmRevision" }, "ItemRevision");
+ if (judgeSingleSelectComponent) {
+ initUi();
+ }
+ }
+
+ /**
+ * ʼ
+ */
+ private void initUi() {
+ try {
+ frame = new JFrame("۵");
+
+ frame.setSize(500, 300);
+ setPanelProperties();
+ JScrollPane centerPanel = getTopPanel();
+ JPanel bottomPanel = getButtomPanel();
+
+ frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
+ frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ frame.setLocationRelativeTo(null);
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ frame.setVisible(true);
+
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ MessageBox.post("InitUi Error!!", "error", MessageBox.ERROR);
+ }
+ }
+
+ /**
+ * ýĿ
+ */
+ private void setPanelProperties() {
+ nameLable = new JLabel("Technical quotation name");
+ nameField = new JTextField(14);
+
+ okButton = new JButton("Confirm");
+ celButton = new JButton("Cancel");
+ }
+
+ private JScrollPane getTopPanel() {
+ // TODO Auto-generated method stub
+ JPanel centerPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints g = new GridBagConstraints();
+
+ // ÿJLabelJTextFieldӵformPanel
+ g.insets = new Insets(5, 30, 5, 5);// ߾
+ g.gridx = 0;
+ g.weightx = 0;
+ g.anchor = GridBagConstraints.LINE_START;
+ nameLable.setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(nameLable, g);
+
+ g.insets = new Insets(5, 3, 5, 30);// ߾
+ g.gridx = 1;
+ g.weightx = 1;
+ g.fill = GridBagConstraints.HORIZONTAL;
+ nameField.setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(nameField, g);
+ // йܵJPanel
+ return new JScrollPane(centerPanel);
+ }
+
+ private JPanel getButtomPanel() {
+ // TODO Auto-generated method stub
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ bottomPanel.add(this.okButton);
+ bottomPanel.add(this.celButton);
+ // Ӽ
+ okButton.addActionListener(e -> {
+ Boolean flag = create(nameField.getText());
+ if (flag) {
+ MessageBox.post("Successfully created technical quotation !", "Success", MessageBox.INFORMATION);
+ frame.dispose(); // رմ
+ } else {
+ frame.dispose(); // رմ
+ }
+ });
+ celButton.addActionListener(e -> {
+ frame.dispose(); // رմ
+ });
+ return bottomPanel;
+ }
+
+ public Boolean create(String name) {
+ Boolean flag = true;
+ targetRev = (TCComponentItemRevision) application.getTargetContext().getComponent();
+
+ try {
+ technicalType = (TCComponentItemType) tcSession.getTypeComponent(TECHINICAL_TYPE);
+ String newID = technicalType.getNewID();
+ TCComponentItem technicalItem = technicalType.create(newID, null, TECHINICAL_TYPE, name, "", null);
+
+ // ȡĿVF5xjxxdgxϵѯϢ
+ TCComponent[] targetRevItem = targetRev.getTCProperty("VF5xjxxdgx").getReferenceValueArray();
+ if (targetRevItem.length < 1) {
+ throw new IndexOutOfBoundsException("VF5xjxxdgx ϵûж");
+ }
+
+ TCComponentItemRevision xjxxdItemRev = ((TCComponentItem) targetRevItem[0]).getLatestItemRevision();
+ TCComponent[] xjxxdItemRevMaster = xjxxdItemRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+
+ TCComponentItemRevision technicalItemRevision = technicalItem.getLatestItemRevision();
+ TCComponent[] techItemRevisionMaster = technicalItemRevision.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ techItemRevisionMaster[0].setProperty("vf5bjtzth", xjxxdItemRevMaster[0].getStringProperty("vf5bjtzth"));
+ techItemRevisionMaster[0].setProperty("vf5khmc", xjxxdItemRevMaster[0].getStringProperty("vf5khmc"));
+
+ // ڱĿ汾ıͼֽϵvf5bjtzgxϵ
+ targetRev.add("VF5jsbjdgx", technicalItem);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("Failed to create object type !");
+ e.printStackTrace();
+ flag = false;
+ } catch (IndexOutOfBoundsException e) {
+ MessageBox.post("There are no objects in the current version relationship", "Warning", MessageBox.WARNING);
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ flag = false;
+ }
+
+ return flag;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalHandler.java b/src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalHandler.java
new file mode 100644
index 0000000..7953a93
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateTechnicalHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+
+ CreateTechnicalDialog createTechnicalDialog = new CreateTechnicalDialog(application);
+ new Thread(createTechnicalDialog).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationDialog.java b/src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationDialog.java
new file mode 100644
index 0000000..0a611f4
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationDialog.java
@@ -0,0 +1,182 @@
+package com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.apache.commons.lang.StringUtils;
+
+import com.connor.ferrorTech.metal.util.TcUtil;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentItem;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCComponentItemType;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class CreateExternalQuotationDialog extends JFrame implements Runnable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private AbstractAIFApplication application;
+ private TCSession tcSession;
+ private JFrame frame;
+
+ private JLabel nameLable;
+ private JTextField nameField;
+
+ private JButton okButton;
+ private JButton celButton;
+
+ private TCComponentItemRevision targetRev;
+ private TCComponentItemType technicalType;
+ private final String TECHINICAL_TYPE = "VF5xsbjd";
+
+ public CreateExternalQuotationDialog(AbstractAIFApplication application) {
+ this.application = application;
+ this.tcSession = (TCSession) this.application.getSession();
+
+ }
+
+ @Override
+ public void run() {
+ boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application,
+ new String[] { "VF5bjxmRevision" }, "ItemRevision");
+ if (judgeSingleSelectComponent) {
+ initUi();
+ }
+ }
+
+ /**
+ * ʼ
+ */
+ private void initUi() {
+ try {
+ frame = new JFrame("Create sales quotation");
+
+ frame.setSize(500, 300);
+ // ʼϢ
+ setPanelProperties();
+ // ݵJFrame λ
+ JScrollPane centerPanel = getTopPanel();
+ JPanel bottomPanel = getButtomPanel();
+
+ frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
+ frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ // ôھ
+ frame.setLocationRelativeTo(null);
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ // ÿɼ
+ frame.setVisible(true);
+
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ MessageBox.post("InitUi Error!!", "error", MessageBox.ERROR);
+ }
+ }
+
+ /**
+ * ýĿ
+ */
+ private void setPanelProperties() {
+ nameLable = new JLabel("Sales quotation name");
+ nameField = new JTextField(14);
+
+ okButton = new JButton("Confirm");
+ celButton = new JButton("Cancel");
+ }
+
+ private JScrollPane getTopPanel() {
+ // TODO Auto-generated method stub
+ JPanel centerPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints g = new GridBagConstraints();
+
+ // ÿJLabelJTextFieldӵformPanel
+ g.insets = new Insets(5, 40, 5, 5);// ߾
+ g.gridx = 0;
+ g.weightx = 0;
+ g.anchor = GridBagConstraints.LINE_START;
+ nameLable.setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(nameLable, g);
+
+ g.insets = new Insets(5, 3, 5, 40);// ߾
+ g.gridx = 1;
+ g.weightx = 1;
+ g.fill = GridBagConstraints.HORIZONTAL;
+ nameField.setFont(new Font("ź", Font.BOLD, 15));
+ centerPanel.add(nameField, g);
+ // йܵJPanel
+ return new JScrollPane(centerPanel);
+ }
+
+ private JPanel getButtomPanel() {
+ // TODO Auto-generated method stub
+ JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ bottomPanel.add(this.okButton);
+ bottomPanel.add(this.celButton);
+ // Ӽ
+ okButton.addActionListener(e -> {
+ Boolean flag = create(nameField.getText());
+ if (flag) {
+ MessageBox.post("Successfully created external quotation !", "Success", MessageBox.INFORMATION);
+ frame.dispose(); // رմ
+ } else {
+ frame.dispose(); // رմ
+ }
+ });
+ celButton.addActionListener(e -> {
+ frame.dispose(); // رմ
+ });
+ return bottomPanel;
+ }
+
+ public Boolean create(String name) {
+ Boolean flag = true;
+ if (StringUtils.isEmpty(name)) {
+ name = "Sale quotation";
+ }
+ targetRev = (TCComponentItemRevision) application.getTargetContext().getComponent();
+ try {
+ technicalType = (TCComponentItemType) tcSession.getTypeComponent(TECHINICAL_TYPE);
+ String newID = technicalType.getNewID();
+ TCComponentItem technicalItem = technicalType.create(newID, null, TECHINICAL_TYPE, name, "", null);
+
+ // ȡĿVF5xjxxdgxϵѯϢ
+ TCComponent[] targetRevItem = targetRev.getTCProperty("VF5xjxxdgx").getReferenceValueArray();
+ TCComponentItemRevision xjxxdItemRev = ((TCComponentItem) targetRevItem[0]).getLatestItemRevision();
+ TCComponent[] xjxxdItemRevMaster = xjxxdItemRev.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+
+ TCComponentItemRevision technicalItemRevision = technicalItem.getLatestItemRevision();
+ TCComponent[] techItemRevisionMaster = technicalItemRevision.getTCProperty("IMAN_master_form_rev")
+ .getReferenceValueArray();
+ techItemRevisionMaster[0].setProperty("vf5bjtzth", xjxxdItemRevMaster[0].getStringProperty("vf5bjtzth"));
+ techItemRevisionMaster[0].setProperty("vf5khmc", xjxxdItemRevMaster[0].getStringProperty("vf5khmc"));
+
+ // ڱĿ汾ıͼֽϵvf5bjtzgxϵ
+ targetRev.add("VF5xsbjdgx", technicalItem);
+ } catch (TCException e) {
+ // TODO Auto-generated catch block
+ System.out.println("Failed to create object type !");
+ e.printStackTrace();
+ flag = false;
+ }
+ return flag;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationHandler.java b/src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationHandler.java
new file mode 100644
index 0000000..da50000
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationHandler.java
@@ -0,0 +1,23 @@
+package com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aifrcp.AIFUtility;
+
+public class CreateExternalQuotationHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+
+ AbstractAIFApplication application = AIFUtility.getCurrentApplication();
+ CreateExternalQuotationDialog action = new CreateExternalQuotationDialog(application);
+
+ new Thread(action).start();
+
+ return null;
+ }
+
+}
diff --git a/src/com/connor/ferrorTech/metal/quotationManagement/uploadQuotationDrawings/UploadDialog.java b/src/com/connor/ferrorTech/metal/quotationManagement/uploadQuotationDrawings/UploadDialog.java
new file mode 100644
index 0000000..3c3659f
--- /dev/null
+++ b/src/com/connor/ferrorTech/metal/quotationManagement/uploadQuotationDrawings/UploadDialog.java
@@ -0,0 +1,408 @@
+package com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings;
+
+import java.awt.BorderLayout;
+import java.awt.Dialog;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.filechooser.FileNameExtensionFilter;
+
+import com.connor.ferrorTech.metal.constant.ConstantPool;
+import com.teamcenter.rac.aif.AbstractAIFApplication;
+import com.teamcenter.rac.aif.AbstractAIFDialog;
+import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
+import com.teamcenter.rac.kernel.TCComponent;
+import com.teamcenter.rac.kernel.TCComponentDataset;
+import com.teamcenter.rac.kernel.TCComponentDatasetType;
+import com.teamcenter.rac.kernel.TCComponentFolder;
+import com.teamcenter.rac.kernel.TCComponentFolderType;
+import com.teamcenter.rac.kernel.TCComponentItemRevision;
+import com.teamcenter.rac.kernel.TCException;
+import com.teamcenter.rac.kernel.TCSession;
+import com.teamcenter.rac.util.MessageBox;
+
+public class UploadDialog extends AbstractAIFDialog{
+
+ private AbstractAIFApplication application;
+ private TCSession tcSession ;
+
+ private JLabel selectUploadLabel;
+ private JComponent uploadInput;
+
+ private JButton importButton;
+ private JButton okButton;
+ private JButton celButton;
+
+ private TCComponentFolderType folderType;
+ private TCComponentItemRevision targetRev;
+
+ private TCComponentDatasetType dwgType;
+ private TCComponentDatasetType pdfType;
+ private TCComponentDatasetType dxfType;
+ private TCComponentDatasetType jtType;
+ private TCComponentDatasetType stpType;
+
+ private TCComponentDatasetType docType;
+ private TCComponentDatasetType xlsType;
+ private TCComponentDatasetType pptType;
+
+ private TCComponentDatasetType wordType;
+ private TCComponentDatasetType excelType;
+ private TCComponentDatasetType pptxType;
+ private TCComponentDatasetType defaultType;
+
+// private Map parentMap;
+// private Map