From 7a424249b5d8826c68f76b599c1022bd218b2e3a Mon Sep 17 00:00:00 2001 From: ChenZichaoczc <2974997276@qq.com> Date: Tue, 3 Jun 2025 15:22:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E5=87=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- META-INF/MANIFEST.MF | 37 +- plugin.xml | 204 +-- .../CreateNPIprojectOnQuotationAction.java | 138 -- .../CreateNPIprojectOnQuotationHandler.java | 23 - src/com/connor/ferrorTech/metal/Test.java | 13 - .../batchDownload/BatchDownloadDialog.java | 406 ----- .../batchDownload/BatchDownloadHandler.java | 26 - .../ApprovalOfBomProcessHandler.java | 172 -- .../CreateChangeRequestFormDialog.java | 197 +++ .../CreateChangeRequestFormHandler.java | 82 + .../ChangeNoticeFormCreateDialog.java | 448 ------ .../ChangeNoticeFormCreateHandler.java | 218 --- .../ChangeApplyFormCreateDialog.java | 406 ----- .../ChangeApplyFormCreateHandler.java | 156 -- .../createECR/CustomTableCellRenderer.java | 24 - .../CreateNotificationDialog.java | 199 +++ .../CreateNotificationHandler.java | 66 + .../CreateProblemReportDialog.java | 177 ++ .../CreateProblemReportHandler.java | 61 + .../CreateInternalDrawingHandler.java | 19 - .../CreateProcessControlHandler.java | 18 - .../CommonAction.java | 194 --- .../CreateRedlineDrawingHandler.java | 20 - .../CreateRawMaterialDrawingAction.java | 194 --- .../CreateRawMaterialDrawingHandler.java | 21 - .../CreateSubPartsDrawingAction.java | 194 --- .../CreateSubPartsDrawingHandler.java | 20 - .../FsetupSheet/CreateSetupSheetHandler.java | 20 - .../CreateReworkInstructionAction.java | 255 --- .../CreateReworkInstructionHandler.java | 19 - .../GxTemplateAction.java | 225 --- .../HncFile/CreateNcFileHandler.java | 20 - .../CreateProcessDrawingHandler.java | 20 - .../CreatePreMillDrawingHandler.java | 21 - .../CreateJitFixtureDialog.java | 174 -- .../CreateJitFixtureHandler.java | 51 - .../KtoolingList/CreateToolingListAction.java | 237 --- .../CreateToolingListHandler.java | 21 - .../InspectionPlanHandler.java | 21 - .../CreateStandardInstructionHandler.java | 20 - .../UploadDocumentsDialog.java | 326 ---- .../UploadDocumentsHandler.java | 26 - .../ApprovalofDocumentsDialog.java | 254 --- .../ApprovalofDocumentsHandler.java | 226 --- .../FinishedProductsCreateHandler.java | 88 - .../finishedProducts/ProductsCreateFrame.java | 435 ----- .../finishedProducts_locale.properties | 13 - .../material/MaterialCreateHandler.java | 72 - .../SemiFinishedProductsCreateHandler.java | 73 - .../DbomTransitionToEbomCommand.java | 10 +- .../DbomTransitionToEbomDialog.java | 1430 ++++++++--------- .../metal/materialManage/NodeBean.java | 74 +- .../ClassificationProcessesDialog.java | 112 +- .../ClassificationProcessesOperation.java | 115 -- .../createCraft/CreateCraftDialog.java | 175 ++ .../createCraft/CreateCraftHandler.java | 50 +- .../CreateProcessesDialog.java | 129 +- .../CreateProcessesHandler.java | 44 +- .../CreateProcessesOperation.java | 68 - .../CreateClientFileAction.java | 21 - .../CreateClientFileDialog.java | 328 ---- .../CreateClientFileHandler.java | 23 - .../customerProfiles_locale.properties | 10 - .../CreateQuotationDrawingsAction.java | 97 -- .../CreateQuotationDrawingsHandler.java | 23 - .../CreateQuotationProjectAction.java | 21 - .../CreateQuotationProjectDialog.java | 513 ------ .../CreateQuotationProjectHandler.java | 23 - .../quotationProjects_locale.properties | 12 - .../CreateTechnicalDialog.java | 193 --- .../CreateTechnicalHandler.java | 23 - .../CreateExternalQuotationDialog.java | 182 --- .../CreateExternalQuotationHandler.java | 23 - .../uploadQuotationDrawings/UploadDialog.java | 408 ----- .../UploadHandler.java | 23 - .../ferrorTech/metal/util/MethodUtil.java | 4 +- 76 files changed, 1905 insertions(+), 8579 deletions(-) delete mode 100644 src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationAction.java delete mode 100644 src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/Test.java delete mode 100644 src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/bomProcess/ApprovalOfBomProcessHandler.java create mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createChangeRequestForm/CreateChangeRequestFormDialog.java create mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createChangeRequestForm/CreateChangeRequestFormHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createECR/CustomTableCellRenderer.java create mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createNotification/CreateNotificationDialog.java create mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createNotification/CreateNotificationHandler.java create mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createProblemReport/CreateProblemReportDialog.java create mode 100644 src/com/connor/ferrorTech/metal/changeManagement/createProblemReport/CreateProblemReportHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/AinternalDrawing/CreateInternalDrawingHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/BprocessControl/CreateProcessControlHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/CommonAction.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/CredlineDrawing/CreateRedlineDrawingHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingAction.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingAction.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/FsetupSheet/CreateSetupSheetHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionAction.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/GxTemplateAction.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/HncFile/CreateNcFileHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/IprocessDrawing/CreateProcessDrawingHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/JpreMillDrawing/CreatePreMillDrawingHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListAction.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/LTinspectionPlan/InspectionPlanHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/LstandardInstruction/CreateStandardInstructionHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/material/finishedProducts/FinishedProductsCreateHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/material/finishedProducts/ProductsCreateFrame.java delete mode 100644 src/com/connor/ferrorTech/metal/material/finishedProducts_locale.properties delete mode 100644 src/com/connor/ferrorTech/metal/material/material/MaterialCreateHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/material/semiFinishedProducts/SemiFinishedProductsCreateHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesOperation.java create mode 100644 src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesOperation.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileAction.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/customerProfiles_locale.properties delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsAction.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectAction.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/quotationProjects_locale.properties delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationHandler.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/uploadQuotationDrawings/UploadDialog.java delete mode 100644 src/com/connor/ferrorTech/metal/quotationManagement/uploadQuotationDrawings/UploadHandler.java diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 0cbb123..d020b44 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -38,50 +38,23 @@ Require-Bundle: org.eclipse.ui, com.teamcenter.rac.workflow.processdesigner;bundle-version="14000.3.0", TcSoaWorkflowRac;bundle-version="14000.3.0", com.teamcenter.rac.aifrcp;bundle-version="14000.3.0" -Export-Package: ., - com.connor.ferrorTech.metal, - com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate, +Export-Package: 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.changeManagement.createChangeRequestForm, + com.connor.ferrorTech.metal.changeManagement.createNotification, + com.connor.ferrorTech.metal.changeManagement.createProblemReport, 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.materialManage, 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 diff --git a/plugin.xml b/plugin.xml index a12f7b2..ab001c3 100644 --- a/plugin.xml +++ b/plugin.xml @@ -12,89 +12,32 @@ - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - - + - - - - - + @@ -102,35 +45,14 @@ - - - - - - - - - - - - - - - - - - - - - @@ -140,50 +62,13 @@ - - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - @@ -194,40 +79,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -238,49 +97,15 @@ - - - - - - - - - - - - - - - - + + - + - - - - - - - - - - - - - - - - - - - + - - - + @@ -290,7 +115,6 @@ - diff --git a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationAction.java b/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationAction.java deleted file mode 100644 index 74483b3..0000000 --- a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationAction.java +++ /dev/null @@ -1,138 +0,0 @@ -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 deleted file mode 100644 index ae6ae5d..0000000 --- a/src/com/connor/ferrorTech/metal/NPIproject/NPIprojectCreateOnQuotation/CreateNPIprojectOnQuotationHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -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/Test.java b/src/com/connor/ferrorTech/metal/Test.java deleted file mode 100644 index 308d0e1..0000000 --- a/src/com/connor/ferrorTech/metal/Test.java +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 4e64e1c..0000000 --- a/src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadDialog.java +++ /dev/null @@ -1,406 +0,0 @@ -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 deleted file mode 100644 index bc72102..0000000 --- a/src/com/connor/ferrorTech/metal/batchDownload/BatchDownloadHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 315a7ed..0000000 --- a/src/com/connor/ferrorTech/metal/bomProcess/ApprovalOfBomProcessHandler.java +++ /dev/null @@ -1,172 +0,0 @@ -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/createChangeRequestForm/CreateChangeRequestFormDialog.java b/src/com/connor/ferrorTech/metal/changeManagement/createChangeRequestForm/CreateChangeRequestFormDialog.java new file mode 100644 index 0000000..0536c59 --- /dev/null +++ b/src/com/connor/ferrorTech/metal/changeManagement/createChangeRequestForm/CreateChangeRequestFormDialog.java @@ -0,0 +1,197 @@ +package com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm; + +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.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; + +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.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.jdesktop.swingx.JXDatePicker; + +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.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 CreateChangeRequestFormDialog extends JFrame implements Runnable { + private String title; + + // sizes[0] = dialogĿȣsizes[1] = dialogĸ߶ȣsizes[2] = + // BottomPanelĶ룬sizes[3] = BottomPanelĵײ + private int[] sizes; + private JLabel[] jLabels; + private JComponent[] jComponents; + + private JButton okButton; + private JButton celButton; + + private TCSession tcSession; + private TCComponentFolder folder; + private TCComponentItemRevision rev; + + public CreateChangeRequestFormDialog(String title, Object... args) { + this.title = title; + int count = 0; + this.sizes = (int[]) args[count++]; + this.jLabels = (JLabel[]) args[count++]; + this.jComponents = (JComponent[]) args[count++]; + this.tcSession = (TCSession) args[count++]; + this.folder = (TCComponentFolder) args[count++]; + this.rev = (TCComponentItemRevision) args[count++]; + } + + @Override + public void run() { + String defaultValue = "뵥"; + initUI(defaultValue); + } + + public void initUI(String defaultValue) { + this.setTitle(title); + this.setSize(sizes[0], sizes[1]); + // ʼ + initializationComponent(); + // ݵJFrame λ + JScrollPane centerPanel = getCenterPanel(); + ((JTextField)jComponents[0]).setText(defaultValue); + 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(""); + celButton = new JButton("ȡ"); + } + + public 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)); + 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(sizes[2], 0, sizes[3], 0)); + bottomPanel.add(this.okButton); + bottomPanel.add(this.celButton); + // Ӽ + okButton.addActionListener(e -> { + try { + boolean confirmed = confirmFunction(); + if (confirmed) { + this.dispose(); // رմ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }); + celButton.addActionListener(e -> { + this.dispose(); // رմ + }); + return bottomPanel; + } + + public boolean confirmFunction() throws TCException { + Map propMap = new LinkedHashMap<>(); + String[] prop = new String[] { "object_name" }; + SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd"); + 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(); + propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : ""); + } else if (jComponents[i] instanceof JXDatePicker) { + JXDatePicker datePicker = (JXDatePicker) jComponents[i]; + Date date = datePicker.getDate(); + if (date != null) { + propMap.put(prop[i], simpleFormatter.format(date)); + } else { + propMap.put(prop[i], ""); + } + } + } + + TCComponentItemRevision bgpsdItemRev = createItem(tcSession, "VF5bgpsd", propMap.get("object_name")); + if(folder!=null) { + folder.add("contents", bgpsdItemRev.getItem()); + } + + if(rev!=null) { + bgpsdItemRev.add("VF5gldwtbggx", rev.getItem()); + TCComponentFolder parentFolder = null; + AIFComponentContext[] parent = rev.getItem().whereReferenced(); + for (int i = 0; i < parent.length; i++) { + InterfaceAIFComponent component = (TCComponent) parent[i].getComponent(); + if (component.getType().equals("Folder") || component.getType().equals("Fnd0HomeFolder")) { + parentFolder = (TCComponentFolder) parent[i].getComponent(); + break; + } + } + + parentFolder.add("contents", bgpsdItemRev.getItem()); + } + + MessageBox.post("ɹ", "Error", MessageBox.INFORMATION); + return true; + } + + 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/changeManagement/createChangeRequestForm/CreateChangeRequestFormHandler.java b/src/com/connor/ferrorTech/metal/changeManagement/createChangeRequestForm/CreateChangeRequestFormHandler.java new file mode 100644 index 0000000..ae39b7e --- /dev/null +++ b/src/com/connor/ferrorTech/metal/changeManagement/createChangeRequestForm/CreateChangeRequestFormHandler.java @@ -0,0 +1,82 @@ +package com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm; + +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.changeManagement.createProblemReport.CreateProblemReportDialog; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateChangeRequestFormHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + AbstractAIFApplication application = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = application.getTargetComponent(); + TCSession session = (TCSession) application.getSession(); + + try { + String type = targetComponent.getType(); + System.out.println("type : " + type); + + TCComponentFolder folder = null; + TCComponentItemRevision rev = null; + if (targetComponent instanceof TCComponentFolder) { + if (type.equals("Folder") || type.equals("Fnd0HomeFolder")) { + folder = (TCComponentFolder) targetComponent; + } else { + MessageBox.post("ѡļ!", "Error", MessageBox.ERROR); + return null; + } + } else if (targetComponent instanceof TCComponentItemRevision) { + if (type.equals("VF5wtbgRevision")) { + rev = (TCComponentItemRevision) targetComponent; + } else { + MessageBox.post("ѡⱨ汾!", "Error", MessageBox.ERROR); + return null; + } + } else { + MessageBox.post("ѡļлⱨ汾!", "Error", MessageBox.ERROR); + return null; + } + + JLabel[] jLabels = new JLabel[] { new JLabel("") }; + JComponent[] jComponents = new JComponent[] { new JTextField(14) }; + + CreateChangeRequestFormDialog searchTemplate = new CreateChangeRequestFormDialog("뵥", + new int[] { 400, 200, 5, 5 }, jLabels, jComponents, session,folder, rev); + new Thread(searchTemplate).start(); + + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateDialog.java b/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateDialog.java deleted file mode 100644 index 21b9496..0000000 --- a/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateDialog.java +++ /dev/null @@ -1,448 +0,0 @@ -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 deleted file mode 100644 index 662a524..0000000 --- a/src/com/connor/ferrorTech/metal/changeManagement/createECO/ChangeNoticeFormCreateHandler.java +++ /dev/null @@ -1,218 +0,0 @@ -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 deleted file mode 100644 index 6d49f25..0000000 --- a/src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateDialog.java +++ /dev/null @@ -1,406 +0,0 @@ -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 deleted file mode 100644 index d8355ab..0000000 --- a/src/com/connor/ferrorTech/metal/changeManagement/createECR/ChangeApplyFormCreateHandler.java +++ /dev/null @@ -1,156 +0,0 @@ -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 deleted file mode 100644 index 6db4b3d..0000000 --- a/src/com/connor/ferrorTech/metal/changeManagement/createECR/CustomTableCellRenderer.java +++ /dev/null @@ -1,24 +0,0 @@ -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/changeManagement/createNotification/CreateNotificationDialog.java b/src/com/connor/ferrorTech/metal/changeManagement/createNotification/CreateNotificationDialog.java new file mode 100644 index 0000000..b9bd41e --- /dev/null +++ b/src/com/connor/ferrorTech/metal/changeManagement/createNotification/CreateNotificationDialog.java @@ -0,0 +1,199 @@ +package com.connor.ferrorTech.metal.changeManagement.createNotification; + +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.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; + +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.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.jdesktop.swingx.JXDatePicker; + +import com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm.CreateChangeRequestFormDialog; +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.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 CreateNotificationDialog extends JFrame implements Runnable { + + private String title; + + // sizes[0] = dialogĿȣsizes[1] = dialogĸ߶ȣsizes[2] = + // BottomPanelĶ룬sizes[3] = BottomPanelĵײ + private int[] sizes; + private JLabel[] jLabels; + private JComponent[] jComponents; + + private JButton okButton; + private JButton celButton; + + private TCSession tcSession; + private TCComponentFolder folder; + private TCComponentItemRevision rev; + + public CreateNotificationDialog(String title, Object... args) { + this.title = title; + int count = 0; + this.sizes = (int[]) args[count++]; + this.jLabels = (JLabel[]) args[count++]; + this.jComponents = (JComponent[]) args[count++]; + this.tcSession = (TCSession) args[count++]; + this.folder = (TCComponentFolder) args[count++]; + this.rev = (TCComponentItemRevision) args[count++]; + } + + @Override + public void run() { + String defaultValue = "֪ͨ"; + initUI(defaultValue); + } + + public void initUI(String defaultValue) { + this.setTitle(title); + this.setSize(sizes[0], sizes[1]); + // ʼ + initializationComponent(); + // ݵJFrame λ + JScrollPane centerPanel = getCenterPanel(); + ((JTextField)jComponents[0]).setText(defaultValue); + 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(""); + celButton = new JButton("ȡ"); + } + + public 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)); + 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(sizes[2], 0, sizes[3], 0)); + bottomPanel.add(this.okButton); + bottomPanel.add(this.celButton); + // Ӽ + okButton.addActionListener(e -> { + try { + boolean confirmed = confirmFunction(); + if (confirmed) { + this.dispose(); // رմ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }); + celButton.addActionListener(e -> { + this.dispose(); // رմ + }); + return bottomPanel; + } + + public boolean confirmFunction() throws TCException { + Map propMap = new LinkedHashMap<>(); + String[] prop = new String[] { "object_name" }; + SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd"); + 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(); + propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : ""); + } else if (jComponents[i] instanceof JXDatePicker) { + JXDatePicker datePicker = (JXDatePicker) jComponents[i]; + Date date = datePicker.getDate(); + if (date != null) { + propMap.put(prop[i], simpleFormatter.format(date)); + } else { + propMap.put(prop[i], ""); + } + } + } + + TCComponentItemRevision bgtzdItemRev = createItem(tcSession, "VF5bgtzd", propMap.get("object_name")); + if(folder!=null) { + folder.add("contents", bgtzdItemRev.getItem()); + } + + if(rev!=null) { + bgtzdItemRev.add("VF5bgpsdgx", rev.getItem()); + TCComponentFolder parentFolder = null; + AIFComponentContext[] parent = rev.getItem().whereReferenced(); + for (int i = 0; i < parent.length; i++) { + InterfaceAIFComponent component = (TCComponent) parent[i].getComponent(); + if (component.getType().equals("Folder") || component.getType().equals("Fnd0HomeFolder")) { + parentFolder = (TCComponentFolder) parent[i].getComponent(); + break; + } + } + + parentFolder.add("contents", bgtzdItemRev.getItem()); + } + + MessageBox.post("ɹ", "Error", MessageBox.INFORMATION); + return true; + } + + 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/changeManagement/createNotification/CreateNotificationHandler.java b/src/com/connor/ferrorTech/metal/changeManagement/createNotification/CreateNotificationHandler.java new file mode 100644 index 0000000..5c4e297 --- /dev/null +++ b/src/com/connor/ferrorTech/metal/changeManagement/createNotification/CreateNotificationHandler.java @@ -0,0 +1,66 @@ +package com.connor.ferrorTech.metal.changeManagement.createNotification; + +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.changeManagement.createChangeRequestForm.CreateChangeRequestFormDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateNotificationHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + AbstractAIFApplication application = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = application.getTargetComponent(); + TCSession session = (TCSession) application.getSession(); + + try { + String type = targetComponent.getType(); + System.out.println("type : " + type); + + TCComponentFolder folder = null; + TCComponentItemRevision rev = null; + if (targetComponent instanceof TCComponentFolder) { + if (type.equals("Folder") || type.equals("Fnd0HomeFolder")) { + folder = (TCComponentFolder) targetComponent; + } else { + MessageBox.post("ѡļ!", "Error", MessageBox.ERROR); + return null; + } + } else if (targetComponent instanceof TCComponentItemRevision) { + if (type.equals("VF5bgpsdRevision")) { + rev = (TCComponentItemRevision) targetComponent; + } else { + MessageBox.post("ѡ뵥汾!", "Error", MessageBox.ERROR); + return null; + } + } else { + MessageBox.post("ѡļл뵥汾!", "Error", MessageBox.ERROR); + return null; + } + + JLabel[] jLabels = new JLabel[] { new JLabel("") }; + JComponent[] jComponents = new JComponent[] { new JTextField(14) }; + + CreateNotificationDialog searchTemplate = new CreateNotificationDialog("֪ͨ", + new int[] { 400, 200, 5, 5 }, jLabels, jComponents, session,folder, rev); + new Thread(searchTemplate).start(); + + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR); + } + return null; + } +} diff --git a/src/com/connor/ferrorTech/metal/changeManagement/createProblemReport/CreateProblemReportDialog.java b/src/com/connor/ferrorTech/metal/changeManagement/createProblemReport/CreateProblemReportDialog.java new file mode 100644 index 0000000..df59f66 --- /dev/null +++ b/src/com/connor/ferrorTech/metal/changeManagement/createProblemReport/CreateProblemReportDialog.java @@ -0,0 +1,177 @@ +package com.connor.ferrorTech.metal.changeManagement.createProblemReport; + +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.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; + +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.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.jdesktop.swingx.JXDatePicker; + +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 CreateProblemReportDialog extends JFrame implements Runnable { + private String title; + + // sizes[0] = dialogĿȣsizes[1] = dialogĸ߶ȣsizes[2] = + // BottomPanelĶ룬sizes[3] = BottomPanelĵײ + private int[] sizes; + private JLabel[] jLabels; + private JComponent[] jComponents; + + private JButton okButton; + private JButton celButton; + + private TCSession tcSession; + private TCComponentFolder target; + + public CreateProblemReportDialog(String title, Object... args) { + this.title = title; + int count = 0; + this.sizes = (int[]) args[count++]; + this.jLabels = (JLabel[]) args[count++]; + this.jComponents = (JComponent[]) args[count++]; + this.tcSession = (TCSession) args[count++]; + this.target = (TCComponentFolder) args[count++]; + } + + @Override + public void run() { + initUI(); + } + + public void initUI() { + this.setTitle(title); + this.setSize(sizes[0], sizes[1]); + // ʼ + initializationComponent(); + // ݵJFrame λ + JScrollPane centerPanel = getCenterPanel(); + ((JTextField)jComponents[0]).setText("ⱨ"); + 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(""); + celButton = new JButton("ȡ"); + } + + public 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)); + 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(sizes[2], 0, sizes[3], 0)); + bottomPanel.add(this.okButton); + bottomPanel.add(this.celButton); + // Ӽ + okButton.addActionListener(e -> { + try { + boolean confirmed = confirmFunction(); + if (confirmed) { + this.dispose(); // رմ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }); + celButton.addActionListener(e -> { + this.dispose(); // رմ + }); + return bottomPanel; + } + + public boolean confirmFunction() throws TCException { + Map propMap = new LinkedHashMap<>(); + String[] prop = new String[] { "object_name" }; + SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd"); + 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(); + propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : ""); + } else if (jComponents[i] instanceof JXDatePicker) { + JXDatePicker datePicker = (JXDatePicker) jComponents[i]; + Date date = datePicker.getDate(); + if (date != null) { + propMap.put(prop[i], simpleFormatter.format(date)); + } else { + propMap.put(prop[i], ""); + } + } + } + + TCComponentItemRevision wtbgItemRev = createItem(tcSession, "VF5wtbg", propMap.get("object_name")); + if (wtbgItemRev != null) { + System.out.println("new item : " + wtbgItemRev.getStringProperty("object_name")); + } + target.add("contents",wtbgItemRev.getItem()); + System.out.println(propMap); + MessageBox.post("ӳɹ !", "Info", MessageBox.INFORMATION); + return true; + } + + 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/changeManagement/createProblemReport/CreateProblemReportHandler.java b/src/com/connor/ferrorTech/metal/changeManagement/createProblemReport/CreateProblemReportHandler.java new file mode 100644 index 0000000..9752145 --- /dev/null +++ b/src/com/connor/ferrorTech/metal/changeManagement/createProblemReport/CreateProblemReportHandler.java @@ -0,0 +1,61 @@ +package com.connor.ferrorTech.metal.changeManagement.createProblemReport; + +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.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateProblemReportHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + AbstractAIFApplication application = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) application.getSession(); + + TCComponentFolder targetItem = (TCComponentFolder) judgeAndGetSingleSelectComponent(application); + + try { + if (targetItem != null) { + JLabel[] jLabels = new JLabel[] { new JLabel("")}; + JComponent[] jComponents = new JComponent[] { new JTextField(14)}; + + CreateProblemReportDialog searchTemplate = new CreateProblemReportDialog("ⱨ", new int[]{400, 200, 5, 5}, jLabels, jComponents,session,targetItem); + new Thread(searchTemplate).start(); + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR); + } + return null; + } + + + + public static TCComponent judgeAndGetSingleSelectComponent(AbstractAIFApplication application) { + InterfaceAIFComponent targetComponent = application.getTargetComponent(); + try { + if (targetComponent instanceof TCComponentFolder + && ((TCComponentFolder)targetComponent).getStringProperty("object_type").equals("Folder")) { + return (TCComponent) targetComponent; + } + MessageBox.post("ѡļ !", "Error", + MessageBox.ERROR); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +} diff --git a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/AinternalDrawing/CreateInternalDrawingHandler.java b/src/com/connor/ferrorTech/metal/createTechnicalDocuments/AinternalDrawing/CreateInternalDrawingHandler.java deleted file mode 100644 index 4debc5d..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/AinternalDrawing/CreateInternalDrawingHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index 2506bc8..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/BprocessControl/CreateProcessControlHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index cae7fd5..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/CommonAction.java +++ /dev/null @@ -1,194 +0,0 @@ -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 deleted file mode 100644 index 6cd1f5d..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/CredlineDrawing/CreateRedlineDrawingHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 860dde1..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingAction.java +++ /dev/null @@ -1,194 +0,0 @@ -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 deleted file mode 100644 index d487df0..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/DrawMaterialDrawing/CreateRawMaterialDrawingHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 8611205..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingAction.java +++ /dev/null @@ -1,194 +0,0 @@ -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 deleted file mode 100644 index cc20c3f..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/EsubPartsDrawing/CreateSubPartsDrawingHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 2ca2906..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/FsetupSheet/CreateSetupSheetHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 85fa9a0..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionAction.java +++ /dev/null @@ -1,255 +0,0 @@ -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 deleted file mode 100644 index 18e06db..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GreworkInstruction/CreateReworkInstructionHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index fa42dc0..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/GxTemplateAction.java +++ /dev/null @@ -1,225 +0,0 @@ -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 deleted file mode 100644 index d4e756e..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/HncFile/CreateNcFileHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index c0a2f66..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/IprocessDrawing/CreateProcessDrawingHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 9ec55ca..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JpreMillDrawing/CreatePreMillDrawingHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 589530d..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureDialog.java +++ /dev/null @@ -1,174 +0,0 @@ -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 deleted file mode 100644 index ae94fdc..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/JrjitFixtureDrawing/CreateJitFixtureHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -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 deleted file mode 100644 index 7876d98..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListAction.java +++ /dev/null @@ -1,237 +0,0 @@ -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 deleted file mode 100644 index 2d3a833..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/KtoolingList/CreateToolingListHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index a31692a..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/LTinspectionPlan/InspectionPlanHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 9d63289..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/LstandardInstruction/CreateStandardInstructionHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index af1a050..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsDialog.java +++ /dev/null @@ -1,326 +0,0 @@ -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 deleted file mode 100644 index 79417c4..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/OuploadDocuments/UploadDocumentsHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 9642b38..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsDialog.java +++ /dev/null @@ -1,254 +0,0 @@ -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 deleted file mode 100644 index 7c173d2..0000000 --- a/src/com/connor/ferrorTech/metal/createTechnicalDocuments/PapprovalofTecDocuments/ApprovalofDocumentsHandler.java +++ /dev/null @@ -1,226 +0,0 @@ -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/material/finishedProducts/FinishedProductsCreateHandler.java b/src/com/connor/ferrorTech/metal/material/finishedProducts/FinishedProductsCreateHandler.java deleted file mode 100644 index 3090199..0000000 --- a/src/com/connor/ferrorTech/metal/material/finishedProducts/FinishedProductsCreateHandler.java +++ /dev/null @@ -1,88 +0,0 @@ -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 deleted file mode 100644 index 75e5856..0000000 --- a/src/com/connor/ferrorTech/metal/material/finishedProducts/ProductsCreateFrame.java +++ /dev/null @@ -1,435 +0,0 @@ -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 deleted file mode 100644 index 08e336f..0000000 --- a/src/com/connor/ferrorTech/metal/material/finishedProducts_locale.properties +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index b1c1c0d..0000000 --- a/src/com/connor/ferrorTech/metal/material/material/MaterialCreateHandler.java +++ /dev/null @@ -1,72 +0,0 @@ -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 deleted file mode 100644 index b21e3bb..0000000 --- a/src/com/connor/ferrorTech/metal/material/semiFinishedProducts/SemiFinishedProductsCreateHandler.java +++ /dev/null @@ -1,73 +0,0 @@ -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 index 31a82b3..31ea5c4 100644 --- a/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomCommand.java +++ b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomCommand.java @@ -48,7 +48,7 @@ public class DbomTransitionToEbomCommand extends AbstractAIFCommand { //ж϶ TCComponentItem item = bomLine.getItem(); boolean isTypeof=false; - String[] prefValues = session.getPreferenceService().getStringValues("Connor_AHBXW_DBOM_Type"); //Connor_DBOM_Type + String[] prefValues = session.getPreferenceService().getStringValues("Connor_DBOM_Type"); //Connor_DBOM_Type System.out.println("prefValuse"+prefValues.toString()); for(String pref : prefValues) { if(pref.equals(item.getType())) { @@ -69,7 +69,7 @@ public class DbomTransitionToEbomCommand extends AbstractAIFCommand { //final List> bomPropertyList = this.getBomPropertys(session, bomLine); - String[] prefValueParts = session.getPreferenceService().getStringValues("Connor_AHBXW_DBOM_PartType"); + String[] prefValueParts = session.getPreferenceService().getStringValues("Connor_DBOM_PartType"); for (String string : prefValueParts) { preList.add(string); } @@ -238,9 +238,9 @@ public class DbomTransitionToEbomCommand extends AbstractAIFCommand { NodeBean nodeBean = new NodeBean(); System.out.println(bomLine.getStringProperty("bl_item_object_type")); - if(bomLine.getStringProperty("bl_item_object_type").equals("LD6_3Ddesign")) { - return; - } +// 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")); diff --git a/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomDialog.java b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomDialog.java index 15fa23e..07f0f51 100644 --- a/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomDialog.java +++ b/src/com/connor/ferrorTech/metal/materialManage/DbomTransitionToEbomDialog.java @@ -11,7 +11,6 @@ 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; @@ -32,11 +31,9 @@ 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; @@ -44,777 +41,674 @@ 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(); // չȫڵ - // +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 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(); - System.out.println("childBean.getLabel() : "+childBean.getLabel()); - System.out.println("childBean.getEbom() : "+childBean.getEbom()); - 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; - } + 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.getDbom(); + if(itemId != null && !itemId.isEmpty()) + { + try { + //ȡ + TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item"); + TCComponentItem item = itemType.find(itemId.split("-")[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[] { item }); + } 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.find(parentID); + TCComponentItemRevision itemRevision = item.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(); + } + } + + 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(); + for (int i = 0; i < tableNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i); + NodeBean childBean = (NodeBean) childNode.getUserObject(); + if(childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty()) + { + topItem = itemType.find(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(); + if(!dbom.isEmpty()) { + String id = ""; + if(dbom.contains("-")) { + id = dbom.substring(0, dbom.indexOf("-")); + }else { + id = dbom; + } + TCComponentItem createItem = itemType.find(id); + if(childBean2.getLabel().equals("1") && preList.contains(createItem.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"; + } + if(countMap.containsKey(createItem.getLatestItemRevision())) { + Integer integer = countMap.get(createItem.getLatestItemRevision()); + countMap.put(createItem.getLatestItemRevision(), Integer.parseInt(num) + integer); + }else { + countMap.put(createItem.getLatestItemRevision(), Integer.parseInt(num)); + } + } + } + } + for (int k = 0; k < node.getChildCount(); k++) { + DefaultMutableTreeTableNode childTableNode = (DefaultMutableTreeTableNode) node.getChildAt(k); + NodeBean childNodeBean = (NodeBean) childTableNode.getUserObject(); + if(childNodeBean.getLabel().equals("1")) + { + TCComponentItem item = null; + if(childNodeBean.getEbomId() == null || childNodeBean.getEbomId().isEmpty()) { + String dbom = childNodeBean.getDbom(); + String id = ""; + if(dbom.contains("-")) { + id = dbom.substring(0, dbom.indexOf("-")); + }else { + id = dbom; + } + item = itemType.find(id); + }else { + item = itemType.find(childNodeBean.getEbomId()); + } + if(preList.contains(item.getType())){ + continue; + } + String num = childNodeBean.getNum(); + if(num == null || num.isEmpty() || num.equals("0")) { + num = "1"; + } + 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()); + itemNumMap.put(item.getStringProperty("item_id"), childNodeBean.getNum()); + if(childNodeBean.getRefreshStatus().equals("Է") || childNodeBean.getRefreshStatus().equals("")) + { + adaptiveVariants((DefaultMutableTreeTableNode)(childTableNode.getParent()), itemType,true); + } + } + + } + } + } + } + if(topItem != null) + { + resultTopline = null; + this.recreateBom(topItem.getLatestItemRevision(), itemList, true,countMap); + if(resultTopline != null) + { + resultTopline.lock(); + //BOM + for (int j = 0; j < resultTopline.getChildren().length; j++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) resultTopline.getChildren()[j].getComponent(); + if(countMap.containsKey(bomLine.getItemRevision())) { + bomLine.setStringProperty("bl_quantity", String.valueOf(countMap.get(bomLine.getItemRevision()))); + } + if(itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) + { + String quantity = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id")); + if(quantity == null || quantity.isEmpty() || quantity.equals("0")) + { + String uom = ""; + try { + uom = bomLine.getPropertyDisplayableValue("bl_uom"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("λ++++++++++++++++"+uom); + if(uom.equals("ÿ")) + { + continue; + } + quantity = "1.00"; + } + System.out.println("++++++++++++++++"+quantity); + if(quantity.indexOf(".") > 0) + { + Double bomNum = Double.parseDouble(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + else + { + Integer bomNum = Integer.parseInt(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + //bomLine.setStringProperty("bl_quantity", itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"))); + } + + } + resultTopline.save(); + resultTopline.unlock(); + resultTopline.refresh(); + if(resultTopline.getBOMView() != null) + { + resultTopline.getBOMView().save(); + resultTopline.getBOMView().refresh(); + } + } + } + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItemRevision topItemRev,ArrayList itemRevisionlists, + boolean isDelete,HashMap countMap) + throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), + topItemRev, null, null); + resultTopline = topline; + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } +// for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { +// if(n_itemRevision != null) +// { +// boolean isHave = false; +// if(!isDelete) +// { +// for (AIFComponentContext children : topline.getChildren()) { +// if(n_itemRevision.getStringProperty("item_id").compareTo(children.getComponent().getProperty("bl_child_id")) == 0) +// { +// isHave = true; +// } +// } +// } +// if(!isHave) +// { +// topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); +// } +// } +// } + Set> entrySet = countMap.entrySet(); + for (Entry entry : entrySet) { + topline.add(entry.getKey().getItem(), entry.getKey(), null, false, ""); + } + topline.save(); + topline.unlock(); + topline.refresh(); + if(topline.getBOMView() != null) + { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.unlock(); + bomWindow.refresh(); + } } diff --git a/src/com/connor/ferrorTech/metal/materialManage/NodeBean.java b/src/com/connor/ferrorTech/metal/materialManage/NodeBean.java index 829f722..16c869a 100644 --- a/src/com/connor/ferrorTech/metal/materialManage/NodeBean.java +++ b/src/com/connor/ferrorTech/metal/materialManage/NodeBean.java @@ -12,76 +12,102 @@ import com.teamcenter.rac.kernel.TCComponentItemRevision; */ 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;//Ӧڵ - + 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 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; } - + + @Override + public String toString() { + return "NodeBean [dbom=" + dbom + ", dId=" + dId + ", ebom=" + ebom + ", eRevision=" + eRevision + ", ebomId=" + + ebomId + ", ebomDesc=" + ebomDesc + ", num=" + num + ", label=" + label + ", refreshStatus=" + + refreshStatus + ", parentString=" + parentString + "]"; + } + } \ No newline at end of file diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesDialog.java b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesDialog.java index 2515a15..4725164 100644 --- a/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesDialog.java +++ b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesDialog.java @@ -13,11 +13,17 @@ 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.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.TCException; import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; public class ClassificationProcessesDialog extends JFrame implements Runnable { @@ -111,7 +117,12 @@ public class ClassificationProcessesDialog extends JFrame implements Runnable { }); okButton = new JButton(ConstantPool.CH_BUTTON_CONFIRM); okButton.addActionListener(e -> { - doTask(); + try { + doTask(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } }); cancelButton = new JButton(ConstantPool.CH_BUTTON_CANCEL); cancelButton.addActionListener(e -> { @@ -145,12 +156,12 @@ public class ClassificationProcessesDialog extends JFrame implements Runnable { public JPanel createTopPanel() { JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); - topPanel.add(jLabels[0]); - topPanel.add(jComponents[0]); + topPanel.add(jLabels[0]); + topPanel.add(jComponents[0]); - topPanel.add(jLabels[1]); - topPanel.add(jComponents[1]); - topPanel.add(searchButton); + topPanel.add(jLabels[1]); + topPanel.add(jComponents[1]); + topPanel.add(searchButton); return topPanel; } @@ -222,7 +233,7 @@ public class ClassificationProcessesDialog extends JFrame implements Runnable { } } - public void doTask() { + public void doTask() throws TCException { int[] selectedRows = table.getSelectedRows(); String[][] selectedData = new String[selectedRows.length][]; @@ -237,11 +248,92 @@ public class ClassificationProcessesDialog extends JFrame implements Runnable { System.out.println("Selected Row Data: " + Arrays.toString(rowData)); } - ClassificationProcessesOperation classificationProcessesOperation = new ClassificationProcessesOperation( - application, selectedData); - this.tcSession.queueExcludedOperation(classificationProcessesOperation); +// ClassificationProcessesOperation classificationProcessesOperation = new ClassificationProcessesOperation( +// application, selectedData); +// this.tcSession.queueExcludedOperation(classificationProcessesOperation); + + TCComponentBOMLine targetBomLine = judgeSingleSelectRevision(new String[] { "VF5gyRevision" }); + if (targetBomLine != null) { + copyItem(targetBomLine, selectedData); + } else { + MessageBox.post("ȡĿBOMʧ!", "Error", MessageBox.ERROR); + } + } else { System.out.println("No rows selected"); + MessageBox.post("δѡ!", "Error", MessageBox.ERROR); + } + } + + public TCComponentBOMLine judgeSingleSelectRevision(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("ѡȷİ汾!"); + } + + 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 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("ӳɹ!", "Info", MessageBox.INFORMATION); + } else { + MessageBox.post("ʧ!", "Rrror", MessageBox.ERROR); } + view.save(); + view.unlock(); } } diff --git a/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesOperation.java b/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesOperation.java deleted file mode 100644 index 7d63e4b..0000000 --- a/src/com/connor/ferrorTech/metal/processManagement/classificationProcesses/ClassificationProcessesOperation.java +++ /dev/null @@ -1,115 +0,0 @@ -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("ȡĿBOMʧ!", "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("ӳɹ!", "Info", MessageBox.INFORMATION); - }else { - MessageBox.post("ʧ!", "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("ѡȷİ汾!"); - } - - 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/createCraft/CreateCraftDialog.java b/src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftDialog.java new file mode 100644 index 0000000..d506776 --- /dev/null +++ b/src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftDialog.java @@ -0,0 +1,175 @@ +package com.connor.ferrorTech.metal.processManagement.createCraft; + +import org.jdesktop.swingx.JXDatePicker; + +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; + +import javax.swing.*; +import java.awt.*; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @ClassName FormTest + * @Description TODO + * @Author chenzc + * @Date 2024/11/29 10:40 + **/ +public class CreateCraftDialog extends JFrame implements Runnable { + /** + * + */ + private static final long serialVersionUID = 1L; + + private String title; + + // sizes[0] = dialogĿȣsizes[1] = dialogĸ߶ȣsizes[2] = BottomPanelĶ룬sizes[3] = BottomPanelĵײ + private int[] sizes; + private JLabel[] jLabels; + private JComponent[] jComponents; + + private JButton okButton; + private JButton celButton; + + private TCSession tcSession; + private TCComponentFolder targetFolder; + + public CreateCraftDialog(String title, Object... args) { + this.title = title; + int count = 0; + this.sizes = (int[]) args[count++]; + this.jLabels = (JLabel[]) args[count++]; + this.jComponents = (JComponent[]) args[count++]; + this.tcSession = (TCSession) args[count++]; + this.targetFolder = (TCComponentFolder) args[count++]; + } + + @Override + public void run() { + initUI(); + } + + public void initUI() { + this.setTitle(title); + this.setSize(sizes[0], sizes[1]); + // ʼ + 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(""); + celButton = new JButton("ȡ"); + } + + 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)); + 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(sizes[2], 0, sizes[3], 0)); + bottomPanel.add(this.okButton); + bottomPanel.add(this.celButton); + //Ӽ + okButton.addActionListener(e -> { + try { + boolean confirmed = confirmFunction(); + if (confirmed) { + this.dispose(); // رմ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }); + celButton.addActionListener(e -> { + this.dispose(); // رմ + }); + return bottomPanel; + } + + public boolean confirmFunction() throws TCException { + Map propMap = new LinkedHashMap<>(); + String[] prop = new String[]{ + "object_name" + }; + SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd"); + 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(); + propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : ""); + } else if (jComponents[i] instanceof JXDatePicker) { + JXDatePicker datePicker = (JXDatePicker) jComponents[i]; + Date date = datePicker.getDate(); + if (date != null) { + propMap.put(prop[i], simpleFormatter.format(date)); + } else { + propMap.put(prop[i], ""); + } + } + } + + TCComponentItemRevision gyItemRev = createItem(tcSession, "VF5gy", propMap.get("object_name")); + if(gyItemRev!=null) { + System.out.println("new item : "+gyItemRev.getStringProperty("object_name")); + } + targetFolder.add("contents", gyItemRev.getItem());; + System.out.println(propMap); + MessageBox.post("ɹ !", "Info", MessageBox.INFORMATION); + return true; + } + + 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/createCraft/CreateCraftHandler.java b/src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftHandler.java index 83fcb7e..c09f583 100644 --- a/src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftHandler.java +++ b/src/com/connor/ferrorTech/metal/processManagement/createCraft/CreateCraftHandler.java @@ -1,10 +1,15 @@ package com.connor.ferrorTech.metal.processManagement.createCraft; +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.processManagement.createProcesses.CreateProcessesDialog; import com.connor.ferrorTech.metal.util.TcUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.kernel.AIFComponentContext; @@ -32,39 +37,33 @@ public class CreateCraftHandler extends AbstractHandler { this.tcSession = (TCSession) application.getSession(); boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, - new String[] { "VF5ccpRevision", "VF5bcpRevision" }, "ItemRevision"); + new String[] { "Folder","Fnd0HomeFolder" }, "Folder"); if (judgeSingleSelectComponent) { TCComponentFolder targetFolder = null; try { - targetFolder = getTargetFolder(); - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); +// targetFolder = getTargetFolder(); + InterfaceAIFComponent targetComponent = this.application.getTargetComponent(); + targetFolder = (TCComponentFolder) targetComponent; } 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(); - } + String[] chLabelName = new String[]{ + "" }; + JLabel[] jLabels = new JLabel[chLabelName.length]; + JComponent[] jComponents = new JComponent[chLabelName.length]; + for (int i = 0; i < chLabelName.length; i++) { + jComponents[i] = new JTextField(14); + jLabels[i] = new JLabel(chLabelName[i]); + } + + CreateCraftDialog action = new CreateCraftDialog("", new int[]{400, 200, 5, 5}, jLabels, jComponents,tcSession,targetFolder); + new Thread(action).start(); } else { - MessageBox.post("Currently, no folder named POR was found !", "error", MessageBox.ERROR); + MessageBox.post("ѡļΪ!", "error", MessageBox.ERROR); } } return null; @@ -125,10 +124,5 @@ public class CreateCraftHandler extends AbstractHandler { 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 index f93fd7d..c9cbe0e 100644 --- a/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesDialog.java +++ b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesDialog.java @@ -1,53 +1,60 @@ package com.connor.ferrorTech.metal.processManagement.createProcesses; -import java.awt.Frame; +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.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; +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.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.jdesktop.swingx.JXDatePicker; -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.TCComponentBOMLine; 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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; 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; +@SuppressWarnings("serial") public class CreateProcessesDialog extends JFrame implements Runnable { - - private AbstractAIFApplication application; - private TCSession tcSession; - private String title; + + // sizes[0] = dialogĿȣsizes[1] = dialogĸ߶ȣsizes[2] = + // BottomPanelĶ룬sizes[3] = BottomPanelĵײ + private int[] sizes; private JLabel[] jLabels; private JComponent[] jComponents; - private String[] lovArrays; - private JButton okButton; private JButton celButton; - private Map> lovMap; + private TCSession tcSession; + private TCComponentBOMLine target; - public CreateProcessesDialog(AbstractAIFApplication application, Object... args) { - this.application = application; - this.tcSession = (TCSession) application.getSession(); + public CreateProcessesDialog(String title, Object... args) { + this.title = title; int count = 0; - this.title = (String) args[count++]; + this.sizes = (int[]) args[count++]; this.jLabels = (JLabel[]) args[count++]; this.jComponents = (JComponent[]) args[count++]; - this.lovMap = (Map>) args[count]; + this.tcSession = (TCSession) args[count++]; + this.target = (TCComponentBOMLine) args[count++]; } @Override @@ -57,7 +64,7 @@ public class CreateProcessesDialog extends JFrame implements Runnable { public void initUI() { this.setTitle(title); - this.setSize(460, 570); + this.setSize(sizes[0], sizes[1]); // ʼ initializationComponent(); // ݵJFrame λ @@ -76,12 +83,12 @@ public class CreateProcessesDialog extends JFrame implements Runnable { /** * ýĿ */ - private void initializationComponent() { - okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM); - celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL); + public void initializationComponent() { + okButton = new JButton(""); + celButton = new JButton("ȡ"); } - private JScrollPane getCenterPanel() { + public JScrollPane getCenterPanel() { // TODO Auto-generated method stub JPanel centerPanel = new JPanel(new GridBagLayout()); GridBagConstraints customLayout = new GridBagConstraints(); @@ -100,26 +107,29 @@ public class CreateProcessesDialog extends JFrame implements Runnable { 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() { + 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.setBorder(BorderFactory.createEmptyBorder(sizes[2], 0, sizes[3], 0)); bottomPanel.add(this.okButton); bottomPanel.add(this.celButton); // Ӽ okButton.addActionListener(e -> { - this.dispose(); // رմ - boolean confirmed = confirmFunction(); + try { + boolean confirmed = confirmFunction(); + if (confirmed) { + this.dispose(); // رմ + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } }); celButton.addActionListener(e -> { this.dispose(); // رմ @@ -127,32 +137,41 @@ public class CreateProcessesDialog extends JFrame implements Runnable { return bottomPanel; } - public boolean confirmFunction() { + public boolean confirmFunction() throws TCException { Map propMap = new LinkedHashMap<>(); - String[] prop = new String[] { "object_name", "vf5gxlx", "vf5gzzxsj", "vf5zbsj", "vf5zbsjdw", "vf5jqsj", - "vf5jqsjdw", "vf5rgsj", "vf5rgsjdw", "vf5fjfy", "vf5fjfydw" }; + String[] prop = new String[] { "object_name" }; + SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd"); 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)); + propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : ""); + } else if (jComponents[i] instanceof JXDatePicker) { + JXDatePicker datePicker = (JXDatePicker) jComponents[i]; + Date date = datePicker.getDate(); + if (date != null) { + propMap.put(prop[i], simpleFormatter.format(date)); } else { - propMap.put(prop[i], displayValue); + propMap.put(prop[i], ""); } } } + + TCComponentItemRevision gxItemRev = createItem(tcSession, "VF5gy", propMap.get("object_name")); + if (gxItemRev != null) { + System.out.println("new item : " + gxItemRev.getStringProperty("object_name")); + } + target.add(gxItemRev.getItem(),gxItemRev,null,false,""); System.out.println(propMap); - CreateProcessesOperation createProcessesOperation = new CreateProcessesOperation(application, propMap); - this.tcSession.queueExcludedOperation(createProcessesOperation); + MessageBox.post("ӳɹ !", "Info", MessageBox.INFORMATION); return true; } + + 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/CreateProcessesHandler.java b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesHandler.java index 8d74694..3417cb3 100644 --- a/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesHandler.java +++ b/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesHandler.java @@ -13,6 +13,7 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import com.connor.ferrorTech.metal.processManagement.createCraft.CreateCraftDialog; import com.connor.ferrorTech.metal.util.SwingUtil; import com.connor.ferrorTech.metal.util.TcUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; @@ -32,6 +33,7 @@ public class CreateProcessesHandler extends AbstractHandler { private AbstractAIFApplication application; private TCSession tcSession; + private TCComponentBOMLine tar; @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { @@ -47,39 +49,16 @@ public class CreateProcessesHandler extends AbstractHandler { } 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>(); + JLabel[] jLabels = new JLabel[chLabelName.length]; + JComponent[] jComponents = new JComponent[chLabelName.length]; - 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]); + for (int i = 0; i < chLabelName.length; i++) { + jComponents[i] = new JTextField(14); + jLabels[i] = new JLabel(chLabelName[i]); } - - CreateProcessesDialog action = new CreateProcessesDialog(application,"Create Operation",jLabels,jComponents,lovMap); + CreateProcessesDialog action = new CreateProcessesDialog("", new int[]{400, 200, 5, 5}, jLabels, jComponents,tcSession,tar); new Thread(action).start(); } @@ -92,13 +71,14 @@ public class CreateProcessesHandler extends AbstractHandler { if(targetComponent instanceof TCComponentBOMLine) { String itemType = ((TCComponentBOMLine)targetComponent).getItemRevision().getStringProperty("object_type"); if (itemType.equals("VF5gyRevision")) { + tar = (TCComponentBOMLine) targetComponent; return true; } else { - JOptionPane.showMessageDialog(null, "Incorrect version!", "Error", JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(null, "ѡն!", "Error", JOptionPane.WARNING_MESSAGE); return false; } }else { - MessageBox.post("Please select the Bom Item !", "error", MessageBox.ERROR); + MessageBox.post("ѡBom!", "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 deleted file mode 100644 index c37131a..0000000 --- a/src/com/connor/ferrorTech/metal/processManagement/createProcesses/CreateProcessesOperation.java +++ /dev/null @@ -1,68 +0,0 @@ -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/quotationManagement/createClientFile/CreateClientFileAction.java b/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileAction.java deleted file mode 100644 index adb67b8..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileAction.java +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 5f53069..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileDialog.java +++ /dev/null @@ -1,328 +0,0 @@ -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 deleted file mode 100644 index d9e32d2..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/CreateClientFileHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 2f48033..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createClientFile/customerProfiles_locale.properties +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 0980dd4..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsAction.java +++ /dev/null @@ -1,97 +0,0 @@ -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 deleted file mode 100644 index 9672f74..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationDrawings/CreateQuotationDrawingsHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 8178d40..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectAction.java +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 801b5db..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectDialog.java +++ /dev/null @@ -1,513 +0,0 @@ -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 deleted file mode 100644 index a808c68..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/CreateQuotationProjectHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index c5a72aa..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createQuotationProject/quotationProjects_locale.properties +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index ca1a852..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalDialog.java +++ /dev/null @@ -1,193 +0,0 @@ -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 deleted file mode 100644 index 7953a93..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/createTechnicalQuotation/CreateTechnicalHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 0a611f4..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationDialog.java +++ /dev/null @@ -1,182 +0,0 @@ -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 deleted file mode 100644 index da50000..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/externalQuotationCreate/CreateExternalQuotationHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 3c3659f..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/uploadQuotationDrawings/UploadDialog.java +++ /dev/null @@ -1,408 +0,0 @@ -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> childMap; - - public UploadDialog(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() { - // TODO Auto-generated method stub - InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent(); - if (selectComponent != null && selectComponent instanceof TCComponentItemRevision) { - targetRev = (TCComponentItemRevision) selectComponent; - String type =""; - try { - type = targetRev.getStringProperty("object_type"); - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.out.println("The selected object version type is " + type); - if (type.equals("VF5bjtzRevision")) { - // ʼ - initUi(); - } else { - MessageBox.post("Please select the correct version again !", "error", MessageBox.ERROR); - } - } else { - MessageBox.post("Please select a Revision Item !", "error", MessageBox.ERROR); - } - } - - - /** - * ʼ - */ - 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!=null && !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"); - defaultType =(TCComponentDatasetType)tcSession.getTypeComponent("Zip"); - } catch (TCException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - this.dispose(); - // ϴ߼ - uploadDrawings(targetRev,file,true); - } - } - }); - - 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) { - try { - 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("Delete successfully, start to add data set: "+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); - } - } - } - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - 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!=null && referenceValueArray.length>0) { - for (TCComponent tcDataset : referenceValueArray) { - if(tcDataset instanceof TCComponentDataset) { - 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) { - if(tcFolder.getType().equals("Folder") && tcFolder.getStringProperty("object_name").equals(fileName)) { - 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){ - 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(); - try { - 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; - } - default :{ - tempData = defaultType.create(fileName, "", "Zip"); - tempData.setFiles(new String[] {filePath},new String[] {"ZIPFILE"}); - 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; - } - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - MessageBox.post(e.getMessage(), "error", MessageBox.ERROR); - } - 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/quotationManagement/uploadQuotationDrawings/UploadHandler.java b/src/com/connor/ferrorTech/metal/quotationManagement/uploadQuotationDrawings/UploadHandler.java deleted file mode 100644 index 6cf2047..0000000 --- a/src/com/connor/ferrorTech/metal/quotationManagement/uploadQuotationDrawings/UploadHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings; - -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 UploadHandler extends AbstractHandler { - - @Override - public Object execute(ExecutionEvent arg0) throws ExecutionException { - - AbstractAIFApplication application = AIFUtility.getCurrentApplication(); - UploadDialog action = new UploadDialog(application); - - new Thread(action).start(); - - return null; - } - -} diff --git a/src/com/connor/ferrorTech/metal/util/MethodUtil.java b/src/com/connor/ferrorTech/metal/util/MethodUtil.java index a52dfd7..a8c2ee1 100644 --- a/src/com/connor/ferrorTech/metal/util/MethodUtil.java +++ b/src/com/connor/ferrorTech/metal/util/MethodUtil.java @@ -419,14 +419,14 @@ public class MethodUtil { TCUserService userservice = session.getUserService(); Object[] obj = new Object[1]; obj[0] = "origin"; - userservice.call("Supor_open_bypass", obj); + userservice.call("Connor_open_bypass", obj); } public static void closeByPass(TCSession session) throws TCException { TCUserService userservice = session.getUserService(); Object[] obj = new Object[1]; obj[0] = "origin"; - userservice.call("Supor_close_bypass", obj); + userservice.call("Connor_close_bypass", obj); } public static void setProperty(TCSession session,TCComponent[] items,String propname,String propvalue) throws TCException { TCUserService userservice = session.getUserService();