commit 46f03fcd174114ded6bfb875f21dbe19e679460e Author: hongcj Date: Wed Jun 11 11:04:39 2025 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..0c7d46b --- /dev/null +++ b/.classpath @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..2a7d815 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.px.plm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..205164d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..cd320b0 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,63 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.px.plm;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: PX +Require-Bundle: org.eclipse.ui, + com.teamcenter.rac.common, + com.teamcenter.rac.tcapps, + com.teamcenter.rac.util, + com.teamcenter.rac.aifrcp, + com.teamcenter.rac.ui.commands, + com.teamcenter.rac.kernel, + com.teamcenter.rac.schedule, + TcSoaCommon, + org.eclipse.ui.views, + org.eclipse.core.runtime, + org.eclipse.ui.forms, + com.teamcenter.rac.workflow.processviewer, + com.teamcenter.rac.workflow.processdesigner, + com.teamcenter.rac.ui.views;bundle-version="8000.3.0" +Automatic-Module-Name: com.px.plm +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ClassPath: lib/aspose-cells-18.9.jar, + lib/commons-codec-1.13.jar, + lib/commons-collections4-4.4.jar, + lib/commons-compress-1.19.jar, + lib/commons-lang3-3.9.jar, + lib/commons-logging-1.2.jar, + lib/commons-math3-3.6.1.jar, + lib/datepicker.jar, + lib/fastjson-1.2.9.jar, + lib/hutool-all-5.0.7.jar, + lib/jaxb-api-2.3.1.jar, + lib/jaxb-core-2.3.0.1.jar, + lib/jaxb-impl-2.3.2.jar, + lib/jfxrt.jar, + lib/ojdbc6.jar, + lib/poi-4.1.1.jar, + lib/poi-examples-4.1.1.jar, + lib/poi-excelant-4.1.1.jar, + lib/poi-ooxml-4.1.1.jar, + lib/poi-ooxml-schemas-4.1.1.jar, + lib/poi-scratchpad-4.1.1.jar, + lib/xmlbeans-3.1.0.jar, + ., + lib/fastjson-1.2.83.jar, + lib/mssql-jdbc-7.0.0.jre8.jar, + lib/hutool-all-4.0.9.jar, + lib/hutool-all-4.1.19.jar, + lib/mssql-jdbc-6.4.0.jre7.jar, + lib/sqljdbc4.jar, + lib/jaxen-1.1.6.jar, + lib/jdom-2.0.6.jar, + lib/jdom-2.0.6-contrib.jar, + lib/jdom-2.0.6-javadoc.jar, + lib/jdom-2.0.6-junit.jar, + lib/jdom-2.0.6-sources.jar, + lib/poi-3.5.jar, + lib/serializer-2.7.2.jar, + lib/xalan-2.7.2.jar, + lib/xercesImpl.jar, + lib/xml-apis.jar diff --git a/bin/com/caxaviews/Activator.class b/bin/com/caxaviews/Activator.class new file mode 100644 index 0000000..616aa3b Binary files /dev/null and b/bin/com/caxaviews/Activator.class differ diff --git a/bin/com/caxaviews/PositionOfMouse$1.class b/bin/com/caxaviews/PositionOfMouse$1.class new file mode 100644 index 0000000..d9a41e6 Binary files /dev/null and b/bin/com/caxaviews/PositionOfMouse$1.class differ diff --git a/bin/com/caxaviews/PositionOfMouse.class b/bin/com/caxaviews/PositionOfMouse.class new file mode 100644 index 0000000..c719e25 Binary files /dev/null and b/bin/com/caxaviews/PositionOfMouse.class differ diff --git a/bin/com/caxaviews/create/createDataset.class b/bin/com/caxaviews/create/createDataset.class new file mode 100644 index 0000000..b6c15f3 Binary files /dev/null and b/bin/com/caxaviews/create/createDataset.class differ diff --git a/bin/com/caxaviews/exportdataset.zip b/bin/com/caxaviews/exportdataset.zip new file mode 100644 index 0000000..a394426 Binary files /dev/null and b/bin/com/caxaviews/exportdataset.zip differ diff --git a/bin/com/caxaviews/exportdataset/BOMLineDatasetStruct.class b/bin/com/caxaviews/exportdataset/BOMLineDatasetStruct.class new file mode 100644 index 0000000..c2b10d4 Binary files /dev/null and b/bin/com/caxaviews/exportdataset/BOMLineDatasetStruct.class differ diff --git a/bin/com/caxaviews/exportdataset/BatchExportDrawings$1.class b/bin/com/caxaviews/exportdataset/BatchExportDrawings$1.class new file mode 100644 index 0000000..bc564ff Binary files /dev/null and b/bin/com/caxaviews/exportdataset/BatchExportDrawings$1.class differ diff --git a/bin/com/caxaviews/exportdataset/BatchExportDrawings$SortContext.class b/bin/com/caxaviews/exportdataset/BatchExportDrawings$SortContext.class new file mode 100644 index 0000000..c9cf083 Binary files /dev/null and b/bin/com/caxaviews/exportdataset/BatchExportDrawings$SortContext.class differ diff --git a/bin/com/caxaviews/exportdataset/BatchExportDrawings.class b/bin/com/caxaviews/exportdataset/BatchExportDrawings.class new file mode 100644 index 0000000..60d2c4c Binary files /dev/null and b/bin/com/caxaviews/exportdataset/BatchExportDrawings.class differ diff --git a/bin/com/caxaviews/exportdataset/OneLineExcel.class b/bin/com/caxaviews/exportdataset/OneLineExcel.class new file mode 100644 index 0000000..1ed5fd5 Binary files /dev/null and b/bin/com/caxaviews/exportdataset/OneLineExcel.class differ diff --git a/bin/com/caxaviews/exportdataset/PreConfig.class b/bin/com/caxaviews/exportdataset/PreConfig.class new file mode 100644 index 0000000..5aab0fb Binary files /dev/null and b/bin/com/caxaviews/exportdataset/PreConfig.class differ diff --git a/bin/com/caxaviews/exportdataset/QueryConditionDlg$1.class b/bin/com/caxaviews/exportdataset/QueryConditionDlg$1.class new file mode 100644 index 0000000..5bf996c Binary files /dev/null and b/bin/com/caxaviews/exportdataset/QueryConditionDlg$1.class differ diff --git a/bin/com/caxaviews/exportdataset/QueryConditionDlg$2.class b/bin/com/caxaviews/exportdataset/QueryConditionDlg$2.class new file mode 100644 index 0000000..c3acbe3 Binary files /dev/null and b/bin/com/caxaviews/exportdataset/QueryConditionDlg$2.class differ diff --git a/bin/com/caxaviews/exportdataset/QueryConditionDlg.class b/bin/com/caxaviews/exportdataset/QueryConditionDlg.class new file mode 100644 index 0000000..6983fa5 Binary files /dev/null and b/bin/com/caxaviews/exportdataset/QueryConditionDlg.class differ diff --git a/bin/com/caxaviews/exportdataset/ReportCommon.class b/bin/com/caxaviews/exportdataset/ReportCommon.class new file mode 100644 index 0000000..abae078 Binary files /dev/null and b/bin/com/caxaviews/exportdataset/ReportCommon.class differ diff --git a/bin/com/caxaviews/exportdataset/ReportConfig.class b/bin/com/caxaviews/exportdataset/ReportConfig.class new file mode 100644 index 0000000..d65221d Binary files /dev/null and b/bin/com/caxaviews/exportdataset/ReportConfig.class differ diff --git a/bin/com/caxaviews/exportdataset/Shannom.class b/bin/com/caxaviews/exportdataset/Shannom.class new file mode 100644 index 0000000..a3a3ee5 Binary files /dev/null and b/bin/com/caxaviews/exportdataset/Shannom.class differ diff --git a/bin/com/caxaviews/util/Common.class b/bin/com/caxaviews/util/Common.class new file mode 100644 index 0000000..21bcee5 Binary files /dev/null and b/bin/com/caxaviews/util/Common.class differ diff --git a/bin/com/caxaviews/view/CaxaForm.class b/bin/com/caxaviews/view/CaxaForm.class new file mode 100644 index 0000000..147b2a0 Binary files /dev/null and b/bin/com/caxaviews/view/CaxaForm.class differ diff --git a/bin/com/caxaviews/view/CaxaView$select$1.class b/bin/com/caxaviews/view/CaxaView$select$1.class new file mode 100644 index 0000000..8370802 Binary files /dev/null and b/bin/com/caxaviews/view/CaxaView$select$1.class differ diff --git a/bin/com/caxaviews/view/CaxaView$select.class b/bin/com/caxaviews/view/CaxaView$select.class new file mode 100644 index 0000000..a30cc6b Binary files /dev/null and b/bin/com/caxaviews/view/CaxaView$select.class differ diff --git a/bin/com/caxaviews/view/CaxaView.class b/bin/com/caxaviews/view/CaxaView.class new file mode 100644 index 0000000..cdfd968 Binary files /dev/null and b/bin/com/caxaviews/view/CaxaView.class differ diff --git a/bin/com/caxaviews/view/GetCEXBView.class b/bin/com/caxaviews/view/GetCEXBView.class new file mode 100644 index 0000000..9ce24fd Binary files /dev/null and b/bin/com/caxaviews/view/GetCEXBView.class differ diff --git a/bin/com/caxaviews/view/MyJFrame$1.class b/bin/com/caxaviews/view/MyJFrame$1.class new file mode 100644 index 0000000..824b407 Binary files /dev/null and b/bin/com/caxaviews/view/MyJFrame$1.class differ diff --git a/bin/com/caxaviews/view/MyJFrame.class b/bin/com/caxaviews/view/MyJFrame.class new file mode 100644 index 0000000..e14d2ca Binary files /dev/null and b/bin/com/caxaviews/view/MyJFrame.class differ diff --git a/bin/com/caxaviews/view/OpenExcelProcess.class b/bin/com/caxaviews/view/OpenExcelProcess.class new file mode 100644 index 0000000..a4768e1 Binary files /dev/null and b/bin/com/caxaviews/view/OpenExcelProcess.class differ diff --git a/bin/com/caxaviews/view/SystemSoftware$MyTable.class b/bin/com/caxaviews/view/SystemSoftware$MyTable.class new file mode 100644 index 0000000..5735577 Binary files /dev/null and b/bin/com/caxaviews/view/SystemSoftware$MyTable.class differ diff --git a/bin/com/caxaviews/view/SystemSoftware.class b/bin/com/caxaviews/view/SystemSoftware.class new file mode 100644 index 0000000..158eca6 Binary files /dev/null and b/bin/com/caxaviews/view/SystemSoftware.class differ diff --git a/bin/com/caxaviews/view/Testzcb.class b/bin/com/caxaviews/view/Testzcb.class new file mode 100644 index 0000000..ab4ab7e Binary files /dev/null and b/bin/com/caxaviews/view/Testzcb.class differ diff --git a/bin/com/caxaviews/view/ViewExbHandler.class b/bin/com/caxaviews/view/ViewExbHandler.class new file mode 100644 index 0000000..023c70f Binary files /dev/null and b/bin/com/caxaviews/view/ViewExbHandler.class differ diff --git a/bin/com/caxaviews/view/WinRegistry.class b/bin/com/caxaviews/view/WinRegistry.class new file mode 100644 index 0000000..0a65785 Binary files /dev/null and b/bin/com/caxaviews/view/WinRegistry.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$1.class b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$1.class new file mode 100644 index 0000000..f5a8458 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$1.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$2.class b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$2.class new file mode 100644 index 0000000..54e5910 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$2.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$3.class b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$3.class new file mode 100644 index 0000000..ba3912e Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$3.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$4.class b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$4.class new file mode 100644 index 0000000..fc5445f Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$4.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$5$1.class b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$5$1.class new file mode 100644 index 0000000..ecd79b0 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$5$1.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$5.class b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$5.class new file mode 100644 index 0000000..1a30062 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$5.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$6.class b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$6.class new file mode 100644 index 0000000..2df71e9 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog$6.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog.class b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog.class new file mode 100644 index 0000000..a57bf94 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028AIFDialog.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Dfl028Handler.class b/bin/com/connor/dfl/plm/dfl028/Dfl028Handler.class new file mode 100644 index 0000000..18715b4 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Dfl028Handler.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Log.class b/bin/com/connor/dfl/plm/dfl028/Log.class new file mode 100644 index 0000000..8c25675 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Log.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/Mess.class b/bin/com/connor/dfl/plm/dfl028/Mess.class new file mode 100644 index 0000000..d515c27 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/Mess.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/SimpleGUI$1.class b/bin/com/connor/dfl/plm/dfl028/SimpleGUI$1.class new file mode 100644 index 0000000..5e1ef81 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/SimpleGUI$1.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/SimpleGUI.class b/bin/com/connor/dfl/plm/dfl028/SimpleGUI.class new file mode 100644 index 0000000..6355876 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/SimpleGUI.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/test.class b/bin/com/connor/dfl/plm/dfl028/test.class new file mode 100644 index 0000000..a56b9b9 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/test.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/test028$1.class b/bin/com/connor/dfl/plm/dfl028/test028$1.class new file mode 100644 index 0000000..ca809be Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/test028$1.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/test028$2.class b/bin/com/connor/dfl/plm/dfl028/test028$2.class new file mode 100644 index 0000000..3d38277 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/test028$2.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/test028$3.class b/bin/com/connor/dfl/plm/dfl028/test028$3.class new file mode 100644 index 0000000..f2bb052 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/test028$3.class differ diff --git a/bin/com/connor/dfl/plm/dfl028/test028.class b/bin/com/connor/dfl/plm/dfl028/test028.class new file mode 100644 index 0000000..e8e8b54 Binary files /dev/null and b/bin/com/connor/dfl/plm/dfl028/test028.class differ diff --git a/bin/com/connor/jd/plm/action/BOMManagementAction.class b/bin/com/connor/jd/plm/action/BOMManagementAction.class new file mode 100644 index 0000000..9e35f8f Binary files /dev/null and b/bin/com/connor/jd/plm/action/BOMManagementAction.class differ diff --git a/bin/com/connor/jd/plm/action/package-info.class b/bin/com/connor/jd/plm/action/package-info.class new file mode 100644 index 0000000..590bafe Binary files /dev/null and b/bin/com/connor/jd/plm/action/package-info.class differ diff --git a/bin/com/connor/jd/plm/beans/BOMExportBean.class b/bin/com/connor/jd/plm/beans/BOMExportBean.class new file mode 100644 index 0000000..936c86c Binary files /dev/null and b/bin/com/connor/jd/plm/beans/BOMExportBean.class differ diff --git a/bin/com/connor/jd/plm/beans/BOMLogBean.class b/bin/com/connor/jd/plm/beans/BOMLogBean.class new file mode 100644 index 0000000..09f0b97 Binary files /dev/null and b/bin/com/connor/jd/plm/beans/BOMLogBean.class differ diff --git a/bin/com/connor/jd/plm/beans/BOMManageTableBean.class b/bin/com/connor/jd/plm/beans/BOMManageTableBean.class new file mode 100644 index 0000000..ac1819d Binary files /dev/null and b/bin/com/connor/jd/plm/beans/BOMManageTableBean.class differ diff --git a/bin/com/connor/jd/plm/beans/CheckBoxPo.class b/bin/com/connor/jd/plm/beans/CheckBoxPo.class new file mode 100644 index 0000000..7cf6a46 Binary files /dev/null and b/bin/com/connor/jd/plm/beans/CheckBoxPo.class differ diff --git a/bin/com/connor/jd/plm/beans/ClassPropBean.class b/bin/com/connor/jd/plm/beans/ClassPropBean.class new file mode 100644 index 0000000..c5dcf3d Binary files /dev/null and b/bin/com/connor/jd/plm/beans/ClassPropBean.class differ diff --git a/bin/com/connor/jd/plm/beans/ComponentBean.class b/bin/com/connor/jd/plm/beans/ComponentBean.class new file mode 100644 index 0000000..75a99ef Binary files /dev/null and b/bin/com/connor/jd/plm/beans/ComponentBean.class differ diff --git a/bin/com/connor/jd/plm/beans/CustomLovBean.class b/bin/com/connor/jd/plm/beans/CustomLovBean.class new file mode 100644 index 0000000..ed357da Binary files /dev/null and b/bin/com/connor/jd/plm/beans/CustomLovBean.class differ diff --git a/bin/com/connor/jd/plm/beans/JG.class b/bin/com/connor/jd/plm/beans/JG.class new file mode 100644 index 0000000..9bb72e4 Binary files /dev/null and b/bin/com/connor/jd/plm/beans/JG.class differ diff --git a/bin/com/connor/jd/plm/beans/MachineBean.class b/bin/com/connor/jd/plm/beans/MachineBean.class new file mode 100644 index 0000000..ea7985a Binary files /dev/null and b/bin/com/connor/jd/plm/beans/MachineBean.class differ diff --git a/bin/com/connor/jd/plm/beans/ResultData.class b/bin/com/connor/jd/plm/beans/ResultData.class new file mode 100644 index 0000000..91c81f7 Binary files /dev/null and b/bin/com/connor/jd/plm/beans/ResultData.class differ diff --git a/bin/com/connor/jd/plm/beans/TransformBomBean.class b/bin/com/connor/jd/plm/beans/TransformBomBean.class new file mode 100644 index 0000000..809afcc Binary files /dev/null and b/bin/com/connor/jd/plm/beans/TransformBomBean.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$1.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$1.class new file mode 100644 index 0000000..d9d76e6 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$1.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$10.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$10.class new file mode 100644 index 0000000..b5c6b1f Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$10.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$11.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$11.class new file mode 100644 index 0000000..b6ab12a Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$11.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$12.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$12.class new file mode 100644 index 0000000..b818f25 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$12.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$13.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$13.class new file mode 100644 index 0000000..04e5bd4 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$13.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$14$1.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$14$1.class new file mode 100644 index 0000000..42be0b9 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$14$1.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$14.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$14.class new file mode 100644 index 0000000..754fe7f Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$14.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$15.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$15.class new file mode 100644 index 0000000..e068001 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$15.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$16.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$16.class new file mode 100644 index 0000000..cb2db6b Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$16.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$17.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$17.class new file mode 100644 index 0000000..e194e1c Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$17.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$18.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$18.class new file mode 100644 index 0000000..6fbe8af Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$18.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$19.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$19.class new file mode 100644 index 0000000..7606b02 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$19.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$2.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$2.class new file mode 100644 index 0000000..4bac3e7 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$2.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$20.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$20.class new file mode 100644 index 0000000..c09b1cc Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$20.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$21.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$21.class new file mode 100644 index 0000000..5b987ce Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$21.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$22.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$22.class new file mode 100644 index 0000000..fab1020 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$22.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$23.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$23.class new file mode 100644 index 0000000..de50b17 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$23.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$24.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$24.class new file mode 100644 index 0000000..4f149ec Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$24.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$3.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$3.class new file mode 100644 index 0000000..b9bb713 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$3.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$4.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$4.class new file mode 100644 index 0000000..eaecd99 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$4.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$5.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$5.class new file mode 100644 index 0000000..1d6e672 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$5.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$6.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$6.class new file mode 100644 index 0000000..8803125 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$6.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$7.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$7.class new file mode 100644 index 0000000..579f827 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$7.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$8.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$8.class new file mode 100644 index 0000000..c8e73d1 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$8.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$9.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$9.class new file mode 100644 index 0000000..d1b45e5 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame$9.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame.class b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame.class new file mode 100644 index 0000000..a4d8369 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame.class differ diff --git a/bin/com/connor/jd/plm/dialogs/BOMManagementFrame20200826改log格式.txt b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame20200826改log格式.txt new file mode 100644 index 0000000..93f6146 --- /dev/null +++ b/bin/com/connor/jd/plm/dialogs/BOMManagementFrame20200826改log格式.txt @@ -0,0 +1,2145 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import com.connor.jd.plm.beans.BOMLogBean; +import com.connor.jd.plm.beans.BOMManageTableBean; +import com.connor.jd.plm.beans.CheckBoxPo; +import com.connor.jd.plm.beans.CustomLovBean; +import com.connor.jd.plm.beans.ResultData; +import com.connor.jd.plm.table.MyCellEditor4; +import com.connor.jd.plm.table.MyCellRenderer; +import com.connor.jd.plm.utils.DBConnectionUtil; +import com.connor.jd.plm.utils.DBUtil; +import com.connor.jd.plm.utils.DatePickerUtil; +import com.connor.jd.plm.utils.DialogUtil; +import com.connor.jd.plm.utils.JDMethodUtil; +import com.connor.jd.plm.utils.KeyValComboBox; +import com.connor.jd.plm.utils.StringCreateUtil; +import com.eltima.components.ui.DatePicker; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; + +import cn.hutool.db.Db; +import cn.hutool.db.Entity; +import cn.hutool.db.sql.Condition; + +public class BOMManagementFrame extends JFrame { + private AbstractAIFApplication app; + private TCSession session; + private CardLayout rootSwitch = new CardLayout(); + private String[] colDisplayNames = new String[] { "ѡ", "", "Ӽ", "λ", "", "״̬" }; + private String[] colDisplayNames2 = new String[] { "", "޸û", "ʱ", "" }; + private JPanel root; + private Map tableDataMap = new HashMap(); + private BOMManagementFrame $this; + private List logDataList; + private Map winMap = new HashMap(); + private TCComponentItemRevision targetRev; + private TCComponentItemRevision targetRev2; + private boolean isLogcreated = false; + private int doIndex = 0; + private boolean complate = false; + private List checkItemType = new ArrayList(); + private JButton[] topBtns; + private TCComponentBOMWindowType winType; + private int width = 1200; + private int height = 800; + private int widthOffset = 0; + private int heightOffset = 0; + private JLabel p1TargetLabel; + private JButton p1TargetBtn; + private JLabel p1ReplaceLabel; + private JButton p1ReplaceBtn; + private JLabel p1UnitLabel; + private KeyValComboBox p1UnitCombo; + private JLabel p1NumLabel; + private JTextField p1NumText; + private JCheckBox p1SelectAll; + private JTable p1Table; + private JScrollPane p1jsp; + private JButton p1BottomBtn1; + private JButton p1BottomBtn2; + private JButton p1BottomBtn3; + private JButton p1BottomBtn4; + private JPanel p1Left; + private JScrollPane p1TreePanel; + private JPanel p1Right; + private JLabel p2TargetLabel; + private JButton p2TargetBtn; + private JLabel p2ChangeNumLabel; + private JTextField p2NumText; + private JCheckBox p2SelectAll; + private JTable p2Table; + private JScrollPane p2jsp; + private JButton p2BottomBtn1; + private JButton p2BottomBtn2; + private JButton p2BottomBtn3; + private JButton p2BottomBtn4; + private JPanel p2Left; + private JScrollPane p2TreePanel; + private JPanel p2Right; + private JLabel p3TargetLabel; + private JButton p3TargetBtn; + private JLabel p3AddLabel; + private JButton p3AddBtn; + private JLabel p3UnitLabel; + private KeyValComboBox p3UnitCombo; + private JLabel p3NumLabel; + private JTextField p3NumText; + private JCheckBox p3SelectAll; + private JTable p3Table; + private JScrollPane p3jsp; + private JButton p3BottomBtn1; + private JButton p3BottomBtn2; + private JButton p3BottomBtn3; + private JButton p3BottomBtn4; + private JPanel p3Left; + private JScrollPane p3TreePanel; + private JPanel p3Right; + private JLabel p4TargetLabel; + private JButton p4TargetBtn; + private JCheckBox p4SelectAll; + private JTable p4Table; + private JScrollPane p4jsp; + private JButton p4BottomBtn1; + private JButton p4BottomBtn2; + private JButton p4BottomBtn3; + private JButton p4BottomBtn4; + private JPanel p4Left; + private JScrollPane p4TreePanel; + private JPanel p4Right; + private JLabel p5UserLabel; + private JTextField p5UserText; + private JLabel p5TimeLabel; + private DatePicker p5TimeStartText; + private JLabel toLabel; + private DatePicker p5TimeEndText; + private JLabel p5ContentLabel; + private JTextArea p5ContentText; + private JScrollPane p5Contentjsp; + private JButton p5Search; + private JButton p5Download; + private JTable p5Table; + private JScrollPane p5jsp; + private Map uiSize = new HashMap<>(); + private JPanel p1; + private JPanel p2; + private JPanel p3; + private JPanel p4; + private JPanel p5; + private Set addedBOMLine = new HashSet<>(); + + public BOMManagementFrame(AbstractAIFApplication app) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + $this = this; + String[] prefArray = JDMethodUtil.getPrefStrArray("connor_bom_check_type", session); + if (prefArray != null) { + checkItemType = Arrays.asList(prefArray); + } + TCTypeService service = session.getTypeService(); + try { + this.winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + init(); + } + + private void init() { + this.setTitle("BOM"); + this.setSize(new Dimension(1200, 800)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + super.componentResized(e); + Component comp = e.getComponent(); + $this.widthOffset = comp.getWidth() - $this.width; + $this.heightOffset = comp.getHeight() - $this.height; + if ($this.widthOffset != 0 || $this.heightOffset != 0) { + System.out.println("width===>" + comp.getWidth()); + System.out.println("height===>" + comp.getHeight()); + $this.width = comp.getWidth(); + $this.height = comp.getHeight(); + $this.resize(); + } + } + }); + this.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + $this.setAlwaysOnTop(true); + } + }); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + container.setSize(new Dimension(1200, 800)); + + TCTypeService typeService = session.getTypeService(); + Vector unitVector = new Vector(); + try { + TCComponent[] uomArray = typeService.getTypeComponent("UnitOfMeasure").extent(); + unitVector.add(new CheckBoxPo(" ", " ")); + for (TCComponent comp : uomArray) { + unitVector.add(new CheckBoxPo(comp.toString(), comp)); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ͷ + JPanel topBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topBtns = new JButton[5]; + topBtns[0] = new JButton("滻"); + topBtns[1] = new JButton(""); + topBtns[2] = new JButton(""); + topBtns[3] = new JButton("ɾ"); + topBtns[4] = new JButton("־"); +// topBtns[5] = new JButton("԰ť"); + topBtns[0].setSelected(true); + for (JButton btn : topBtns) { + topBtnPanel.add(btn); + btn.addActionListener(panelSwitch()); + } + container.add(topBtnPanel, BorderLayout.NORTH); + + // root + root = new JPanel(rootSwitch); + + // 滻 + p1 = new JPanel(); + p1.setLayout(null); + + // 滻 + p1Left = new JPanel(); + p1Left.setLayout(null); + p1Left.setBounds(0, 0, 800, 800); + p1Left.setBorder(BorderFactory.createEtchedBorder()); + + p1TargetLabel = new JLabel("Ŀϱ"); + p1TargetLabel.setBounds(20, 20, 100, 25); + p1TargetBtn = new JButton(); + p1TargetBtn.setBounds(130, 20, 400, 25); + p1ReplaceLabel = new JLabel("滻ϱ"); + p1ReplaceLabel.setBounds(20, 60, 100, 25); + p1ReplaceBtn = new JButton(); + p1ReplaceBtn.setBounds(130, 60, 400, 25); + p1UnitLabel = new JLabel("λ"); + p1UnitLabel.setBounds(560, 60, 50, 25); + p1UnitCombo = new KeyValComboBox(unitVector); + p1UnitCombo.setBounds(610, 60, 50, 25); + p1NumLabel = new JLabel(""); + p1NumLabel.setBounds(680, 60, 50, 25); + p1NumText = new JTextField(); + p1NumText.setBounds(730, 60, 50, 25); + p1SelectAll = new JCheckBox("ȫѡ"); + p1SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p1model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p1Table = new JTable(p1model); + p1Table.getColumnModel().getColumn(0).setMinWidth(60); + p1Table.getColumnModel().getColumn(0).setMaxWidth(60); + p1Table.getColumnModel().getColumn(1).setMinWidth(200); + p1Table.getColumnModel().getColumn(2).setMinWidth(200); + p1Table.getColumnModel().getColumn(3).setMinWidth(100); + p1Table.getColumnModel().getColumn(4).setMinWidth(100); + p1Table.getColumnModel().getColumn(5).setMinWidth(100); + p1Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p1Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p1Table.setRowHeight(25); + p1Table.setAutoscrolls(true); + p1Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p1Table.getTableHeader().setReorderingAllowed(false); + p1Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p1sorter = new TableRowSorter(p1model); + p1Table.setRowSorter(p1sorter); + p1jsp = new JScrollPane(p1Table); + p1jsp.setBounds(20, 130, 760, 500); + + p1BottomBtn1 = new JButton(""); + p1BottomBtn1.setBounds(80, 650, 100, 25); + p1BottomBtn2 = new JButton("滻"); + p1BottomBtn2.setBounds(260, 650, 100, 25); + p1BottomBtn3 = new JButton(""); + p1BottomBtn3.setBounds(440, 650, 100, 25); + p1BottomBtn4 = new JButton("ȡ"); + p1BottomBtn4.setBounds(620, 650, 100, 25); + + p1Left.add(p1TargetLabel); + p1Left.add(p1TargetBtn); + p1Left.add(p1ReplaceLabel); + p1Left.add(p1ReplaceBtn); + p1Left.add(p1UnitLabel); + p1Left.add(p1UnitCombo); + p1Left.add(p1NumLabel); + p1Left.add(p1NumText); + p1Left.add(p1SelectAll); + p1Left.add(p1jsp); + p1Left.add(p1BottomBtn1); + p1Left.add(p1BottomBtn2); + p1Left.add(p1BottomBtn3); + p1Left.add(p1BottomBtn4); + + // 滻ұ + p1Right = new JPanel(); + p1Right.setLayout(null); + p1Right.setBounds(800, 0, 400, 800); + p1Right.setBorder(BorderFactory.createEtchedBorder()); + + p1TreePanel = new JScrollPane(); + p1TreePanel.setBounds(20, 130, 360, 500); + p1Right.add(p1TreePanel); + + // ¼ + p1SelectAll.addItemListener(selectAll(p1Table)); + p1Table.addMouseListener(showTree(p1Right)); + p1BottomBtn4.addActionListener(cancel()); + p1BottomBtn1.addActionListener(batchRevise(p1Table, p1SelectAll)); + p1BottomBtn2.addActionListener(batchReplace()); + p1BottomBtn3.addActionListener(startWorkFlow(p1Table)); + p1TargetBtn.addActionListener(clickSearch(p1Table, p1SelectAll)); + p1ReplaceBtn.addActionListener(clickSearch(null, null)); + + p1.add(p1Left); + p1.add(p1Right); + + // + p2 = new JPanel(); + p2.setLayout(null); + + // + p2Left = new JPanel(); + p2Left.setLayout(null); + p2Left.setBounds(0, 0, 800, 800); + p2Left.setBorder(BorderFactory.createEtchedBorder()); + + p2TargetLabel = new JLabel("Ŀϱ"); + p2TargetLabel.setBounds(20, 20, 100, 25); + p2TargetBtn = new JButton(); + p2TargetBtn.setBounds(130, 20, 400, 25); + p2ChangeNumLabel = new JLabel(""); + p2ChangeNumLabel.setBounds(20, 60, 100, 25); + p2NumText = new JTextField(); + p2NumText.setBounds(130, 60, 50, 25); + + p2SelectAll = new JCheckBox("ȫѡ"); + p2SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p2model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p2Table = new JTable(p2model); + p2Table.getColumnModel().getColumn(0).setMinWidth(60); + p2Table.getColumnModel().getColumn(0).setMaxWidth(60); + p2Table.getColumnModel().getColumn(1).setMinWidth(200); + p2Table.getColumnModel().getColumn(2).setMinWidth(200); + p2Table.getColumnModel().getColumn(3).setMinWidth(100); + p2Table.getColumnModel().getColumn(4).setMinWidth(100); + p2Table.getColumnModel().getColumn(5).setMinWidth(100); + p2Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p2Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p2Table.setRowHeight(25); + p2Table.setAutoscrolls(true); + p2Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p2Table.getTableHeader().setReorderingAllowed(false); + p2Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p2sorter = new TableRowSorter(p2model); + p2Table.setRowSorter(p2sorter); + p2jsp = new JScrollPane(p2Table); + p2jsp.setBounds(20, 130, 760, 500); + + p2BottomBtn1 = new JButton(""); + p2BottomBtn1.setBounds(80, 650, 100, 25); + p2BottomBtn2 = new JButton(""); + p2BottomBtn2.setBounds(260, 650, 100, 25); + p2BottomBtn3 = new JButton(""); + p2BottomBtn3.setBounds(440, 650, 100, 25); + p2BottomBtn4 = new JButton("ȡ"); + p2BottomBtn4.setBounds(620, 650, 100, 25); + + p2Left.add(p2TargetLabel); + p2Left.add(p2TargetBtn); + p2Left.add(p2ChangeNumLabel); + p2Left.add(p2NumText); + p2Left.add(p2SelectAll); + p2Left.add(p2jsp); + p2Left.add(p2BottomBtn1); + p2Left.add(p2BottomBtn2); + p2Left.add(p2BottomBtn3); + p2Left.add(p2BottomBtn4); + + // ұ + p2Right = new JPanel(); + p2Right.setLayout(null); + p2Right.setBounds(800, 0, 400, 800); + p2Right.setBorder(BorderFactory.createEtchedBorder()); + + p2TreePanel = new JScrollPane(); + p2TreePanel.setBounds(20, 130, 360, 500); + p2Right.add(p2TreePanel); + + // ¼ + p2SelectAll.addItemListener(selectAll(p2Table)); + p2Table.addMouseListener(showTree(p2Right)); + p2BottomBtn4.addActionListener(cancel()); + p2BottomBtn1.addActionListener(batchRevise(p2Table, p2SelectAll)); + p2BottomBtn2.addActionListener(batchModify()); + p2BottomBtn3.addActionListener(startWorkFlow(p2Table)); + p2TargetBtn.addActionListener(clickSearch(p2Table, p2SelectAll)); + + p2.add(p2Left); + p2.add(p2Right); + + // + p3 = new JPanel(); + p3.setLayout(null); + + // + p3Left = new JPanel(); + p3Left.setLayout(null); + p3Left.setBounds(0, 0, 800, 800); + p3Left.setBorder(BorderFactory.createEtchedBorder()); + + p3TargetLabel = new JLabel("οϱ"); + p3TargetLabel.setBounds(20, 20, 100, 25); + p3TargetBtn = new JButton(); + p3TargetBtn.setBounds(130, 20, 400, 25); + p3AddLabel = new JLabel("ϱ"); + p3AddLabel.setBounds(20, 60, 100, 25); + p3AddBtn = new JButton(); + p3AddBtn.setBounds(130, 60, 400, 25); + p3UnitLabel = new JLabel("λ"); + p3UnitLabel.setBounds(560, 60, 50, 25); + p3UnitCombo = new KeyValComboBox(unitVector); + p3UnitCombo.setBounds(610, 60, 50, 25); + p3NumLabel = new JLabel(""); + p3NumLabel.setBounds(680, 60, 50, 25); + p3NumText = new JTextField(); + p3NumText.setBounds(730, 60, 50, 25); + + p3SelectAll = new JCheckBox("ȫѡ"); + p3SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p3model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p3Table = new JTable(p3model); + p3Table.getColumnModel().getColumn(0).setMinWidth(60); + p3Table.getColumnModel().getColumn(0).setMaxWidth(60); + p3Table.getColumnModel().getColumn(1).setMinWidth(200); + p3Table.getColumnModel().getColumn(2).setMinWidth(200); + p3Table.getColumnModel().getColumn(3).setMinWidth(100); + p3Table.getColumnModel().getColumn(4).setMinWidth(100); + p3Table.getColumnModel().getColumn(5).setMinWidth(100); + p3Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p3Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p3Table.setRowHeight(25); + p3Table.setAutoscrolls(true); + p3Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p3Table.getTableHeader().setReorderingAllowed(false); + p3Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p3sorter = new TableRowSorter(p3model); + p3Table.setRowSorter(p3sorter); + p3jsp = new JScrollPane(p3Table); + p3jsp.setBounds(20, 130, 760, 500); + + p3BottomBtn1 = new JButton(""); + p3BottomBtn1.setBounds(80, 650, 100, 25); + p3BottomBtn2 = new JButton(""); + p3BottomBtn2.setBounds(260, 650, 100, 25); + p3BottomBtn3 = new JButton(""); + p3BottomBtn3.setBounds(440, 650, 100, 25); + p3BottomBtn4 = new JButton("ȡ"); + p3BottomBtn4.setBounds(620, 650, 100, 25); + + p3Left.add(p3TargetLabel); + p3Left.add(p3TargetBtn); + p3Left.add(p3AddLabel); + p3Left.add(p3AddBtn); + p3Left.add(p3UnitLabel); + p3Left.add(p3UnitCombo); + p3Left.add(p3NumLabel); + p3Left.add(p3NumText); + p3Left.add(p3SelectAll); + p3Left.add(p3jsp); + p3Left.add(p3BottomBtn1); + p3Left.add(p3BottomBtn2); + p3Left.add(p3BottomBtn3); + p3Left.add(p3BottomBtn4); + + // ұ + p3Right = new JPanel(); + p3Right.setLayout(null); + p3Right.setBounds(800, 0, 400, 800); + p3Right.setBorder(BorderFactory.createEtchedBorder()); + + p3TreePanel = new JScrollPane(); + p3TreePanel.setBounds(20, 130, 360, 500); + p3Right.add(p3TreePanel); + + // ¼ + p3SelectAll.addItemListener(selectAll(p3Table)); + p3Table.addMouseListener(showTree(p3Right)); + p3BottomBtn4.addActionListener(cancel()); + p3BottomBtn1.addActionListener(batchRevise(p3Table, p3SelectAll)); + p3BottomBtn2.addActionListener(batchAdd()); + p3BottomBtn3.addActionListener(startWorkFlow(p3Table)); + p3TargetBtn.addActionListener(clickSearch(p3Table, p3SelectAll)); + p3AddBtn.addActionListener(clickSearch(null, null)); + + p3.add(p3Left); + p3.add(p3Right); + + // ɾ + p4 = new JPanel(); + p4.setLayout(null); + + // ɾ + p4Left = new JPanel(); + p4Left.setLayout(null); + p4Left.setBounds(0, 0, 800, 800); + p4Left.setBorder(BorderFactory.createEtchedBorder()); + + p4TargetLabel = new JLabel("Ŀϱ"); + p4TargetLabel.setBounds(20, 20, 100, 25); + p4TargetBtn = new JButton(); + p4TargetBtn.setBounds(130, 20, 400, 25); + + p4SelectAll = new JCheckBox("ȫѡ"); + p4SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p4model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p4Table = new JTable(p4model); + p4Table.getColumnModel().getColumn(0).setMinWidth(60); + p4Table.getColumnModel().getColumn(0).setMaxWidth(60); + p4Table.getColumnModel().getColumn(1).setMinWidth(200); + p4Table.getColumnModel().getColumn(2).setMinWidth(200); + p4Table.getColumnModel().getColumn(3).setMinWidth(100); + p4Table.getColumnModel().getColumn(4).setMinWidth(100); + p4Table.getColumnModel().getColumn(5).setMinWidth(100); + p4Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p4Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p4Table.setRowHeight(25); + p4Table.setAutoscrolls(true); + p4Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p4Table.getTableHeader().setReorderingAllowed(false); + p4Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p4sorter = new TableRowSorter(p4model); + p4Table.setRowSorter(p4sorter); + p4jsp = new JScrollPane(p4Table); + p4jsp.setBounds(20, 130, 760, 500); + + p4BottomBtn1 = new JButton(""); + p4BottomBtn1.setBounds(80, 650, 100, 25); + p4BottomBtn2 = new JButton("ɾ"); + p4BottomBtn2.setBounds(260, 650, 100, 25); + p4BottomBtn3 = new JButton(""); + p4BottomBtn3.setBounds(440, 650, 100, 25); + p4BottomBtn4 = new JButton("ȡ"); + p4BottomBtn4.setBounds(620, 650, 100, 25); + + p4Left.add(p4TargetLabel); + p4Left.add(p4TargetBtn); + p4Left.add(p4SelectAll); + p4Left.add(p4jsp); + p4Left.add(p4BottomBtn1); + p4Left.add(p4BottomBtn2); + p4Left.add(p4BottomBtn3); + p4Left.add(p4BottomBtn4); + + // ұ + p4Right = new JPanel(); + p4Right.setLayout(null); + p4Right.setBounds(800, 0, 400, 800); + p4Right.setBorder(BorderFactory.createEtchedBorder()); + + p4TreePanel = new JScrollPane(); + p4TreePanel.setBounds(20, 130, 360, 500); + p4Right.add(p4TreePanel); + + // ¼ + p4SelectAll.addItemListener(selectAll(p4Table)); + p4Table.addMouseListener(showTree(p4Right)); + p4BottomBtn4.addActionListener(cancel()); + p4BottomBtn1.addActionListener(batchRevise(p4Table, p4SelectAll)); + p4BottomBtn2.addActionListener(batchRemove()); + p4BottomBtn3.addActionListener(startWorkFlow(p4Table)); + p4TargetBtn.addActionListener(clickSearch(p4Table, p4SelectAll)); + + p4.add(p4Left); + p4.add(p4Right); + + // ־ + p5 = new JPanel(); + p5.setLayout(null); + + p5UserLabel = new JLabel("޸û"); + p5UserLabel.setBounds(20, 40, 70, 25); + p5UserText = new JTextField(); + p5UserText.setBounds(100, 40, 150, 25); + p5TimeLabel = new JLabel("޸ʱ"); + p5TimeLabel.setBounds(300, 40, 70, 25); + p5TimeStartText = DatePickerUtil.getDatePicker(null); + p5TimeStartText.setBounds(380, 40, 100, 25); + toLabel = new JLabel(""); + toLabel.setBounds(490, 40, 20, 25); + p5TimeEndText = DatePickerUtil.getDatePicker(null); + p5TimeEndText.setBounds(520, 40, 100, 25); + p5ContentLabel = new JLabel("޸"); + p5ContentLabel.setBounds(670, 40, 70, 25); + p5ContentText = new JTextArea(); + p5ContentText.setLineWrap(true); + p5ContentText.setWrapStyleWord(true); + p5Contentjsp = new JScrollPane(p5ContentText); + p5Contentjsp.setBounds(750, 20, 200, 80); + p5Search = new JButton(""); + p5Search.setBounds(1000, 40, 60, 25); + p5Download = new JButton("־"); + p5Download.setBounds(1080, 40, 100, 25); + + DefaultTableModel p5model = new DefaultTableModel(colDisplayNames2, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p5Table = new JTable(p5model); + p5Table.getColumnModel().getColumn(0).setMinWidth(60); + p5Table.getColumnModel().getColumn(0).setMaxWidth(60); + p5Table.getColumnModel().getColumn(1).setMinWidth(200); + p5Table.getColumnModel().getColumn(2).setMinWidth(200); + p5Table.getColumnModel().getColumn(3).setMinWidth(700); + p5Table.setRowHeight(25); + p5Table.setAutoscrolls(true); + p5Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p5Table.getTableHeader().setReorderingAllowed(false); + RowSorter p5sorter = new TableRowSorter(p5model); + p5Table.setRowSorter(p5sorter); + p5jsp = new JScrollPane(p5Table); + p5jsp.setBounds(20, 130, 1160, 580); + + // ¼ + p5Search.addActionListener(searchLog()); + p5Download.addActionListener(downloadLog(p5Table)); + p5UserText.addKeyListener(logSearchEnter()); + p5TimeStartText.addKeyListener(logSearchEnter()); + p5TimeEndText.addKeyListener(logSearchEnter()); + + p5.add(p5UserLabel); + p5.add(p5UserText); + p5.add(p5TimeLabel); + p5.add(p5TimeStartText); + p5.add(toLabel); + p5.add(p5TimeEndText); + p5.add(p5ContentLabel); + p5.add(p5Contentjsp); + p5.add(p5Search); + p5.add(p5Download); + p5.add(p5jsp); + + root.add("batchReplace", p1); + root.add("batchModify", p2); + root.add("batchAdd", p3); + root.add("batchRemove", p4); + root.add("updateLog", p5); + + rootSwitch.show(root, "batchReplace"); + container.add(root, BorderLayout.CENTER); + this.setVisible(true); + } + + private ActionListener panelSwitch() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String text = ((JButton) e.getSource()).getText(); + for (int i = 0; i < topBtns.length; i++) { + topBtns[i].setSelected(topBtns[i].getText().equals(text)); + } + switch (text) { + case "滻": + clearTable(p1Table, p1SelectAll); + p1Right.removeAll(); + JScrollPane panel1 = new JScrollPane(); + panel1.setBounds(p1TreePanel.getX(), p1TreePanel.getY(), p1TreePanel.getWidth(), + p1TreePanel.getHeight()); + p1TreePanel = panel1; + p1Right.add(panel1); + p1Right.revalidate(); + p1Right.repaint(); + rootSwitch.show(root, "batchReplace"); + break; + case "": + clearTable(p2Table, p2SelectAll); + p2Right.removeAll(); + JScrollPane panel2 = new JScrollPane(); + panel2.setBounds(p2TreePanel.getX(), p2TreePanel.getY(), p2TreePanel.getWidth(), + p2TreePanel.getHeight()); + p2TreePanel = panel2; + p2Right.add(panel2); + p2Right.revalidate(); + p2Right.repaint(); + rootSwitch.show(root, "batchModify"); + break; + case "": + clearTable(p3Table, p3SelectAll); + p3Right.removeAll(); + JScrollPane panel3 = new JScrollPane(); + panel3.setBounds(p3TreePanel.getX(), p3TreePanel.getY(), p3TreePanel.getWidth(), + p3TreePanel.getHeight()); + p3TreePanel = panel3; + p3Right.add(panel3); + p3Right.revalidate(); + p3Right.repaint(); + rootSwitch.show(root, "batchAdd"); + break; + case "ɾ": + clearTable(p4Table, p4SelectAll); + p4Right.removeAll(); + JScrollPane panel4 = new JScrollPane(); + panel4.setBounds(p4TreePanel.getX(), p4TreePanel.getY(), p4TreePanel.getWidth(), + p4TreePanel.getHeight()); + p4TreePanel = panel4; + p4Right.add(panel4); + p4Right.revalidate(); + p4Right.repaint(); + rootSwitch.show(root, "batchRemove"); + break; + case "־": + createLogDataSourceTable(); + clearTable(p5Table, null); + rootSwitch.show(root, "updateLog"); + break; + default: +// createLogDataSourceTable(); + } + } + }; + } + + private void showWhereUesd(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + // TODO Auto-generated method stub + clearTable(table, selectAll); + if (table == null || targetRev == null) { + return; + } + long startTime = System.currentTimeMillis(); + List tableDataList = new ArrayList(); + try { + String revString = targetRev.getProperty("object_string"); + TCComponent[] usedComps = targetRev.whereUsed((short) 0); + System.out.println("װ======>" + usedComps.length); + + tableDataMap.clear(); +// Map usedMap = usedFilter(usedComps); +// for (Entry entry : usedMap.entrySet()) { + for (TCComponentItemRevision parentRev : usedFilter(usedComps)) { +// TCComponentItemRevision parentRev = entry.getValue(); + String parentString = parentRev.getProperty("object_string"); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.put(parentString, win); + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (revString.equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + Object[] rowData = new Object[] { new JCheckBox(), parentString, revString, unit, num, status }; + rowPrint(rowData); + tableDataList.add(rowData); + tableDataMap.put(parentString, + new BOMManageTableBean(parentString, revString, parentRev, targetRev, topLine, child)); + // TODO bomһchildܻ쳣ֻӰһ + break; + } + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + if (tableDataList == null || tableDataList.size() == 0) { + JOptionPane.showMessageDialog($this, "ҵӦ󣬵öûκװװöľ°汾ȷϱǷȷ", "ʾ", + JOptionPane.WARNING_MESSAGE); + return; + } + + for (Object[] rowData : tableDataList) { + model.addRow(rowData); + } + table.revalidate(); + table.repaint(); + System.out.println("װʾɣʱ" + (System.currentTimeMillis() - startTime) + "ms"); + } + + private MouseAdapter showTree(JPanel panelRight) { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + JTable table = (JTable) e.getSource(); + String parentString = table.getValueAt(table.getSelectedRow(), 1).toString(); + System.out.println("select row=====>" + table.getSelectedRow()); + System.out.println("parentName=====>" + parentString); + CustomLovBean lovBean = null; + try { + lovBean = new CustomLovBean(tableDataMap.get(parentString).getChildString()); + CustomLovBean subBean = new CustomLovBean(parentString); + lovBean.addSub(subBean); + getTreeData(tableDataMap.get(parentString).getParentRev(), subBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + panelRight.removeAll(); + JTree tree = createTree(lovBean); + JScrollPane treePanel = new JScrollPane(tree); + treePanel.setBounds(20, 130, 360, 500); + panelRight.add(treePanel); + panelRight.revalidate(); + panelRight.repaint(); + } + } + }; + } + + private void getTreeData(TCComponent rev, CustomLovBean lov) throws TCException { + TCComponent[] comps = rev.whereUsed((short) 0); + if (comps == null || comps.length == 0) { + return; + } + for (TCComponent comp : comps) { + CustomLovBean sub = new CustomLovBean(comp.getProperty("object_string")); + System.out.println(sub.displayName); + lov.addSub(sub); + getTreeData(comp, sub); + } + } + + private void clearTable(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int cnt = model.getRowCount(); + for (int i = 0; i < cnt; i++) { + model.removeRow(0); + } + table.revalidate(); + table.repaint(); + if (selectAll != null) { + selectAll.setSelected(false); + } + tableDataMap.clear(); + addedBOMLine.clear(); + try { + closeWin(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JTree createTree(CustomLovBean lovData) { + if (lovData == null || "".equals(lovData.displayName)) { + return new JTree(); + } + DefaultMutableTreeNode root = new DefaultMutableTreeNode(lovData.displayName); + DefaultMutableTreeNode parent = root; + DefaultTreeModel treeModel = new DefaultTreeModel(root); + + initTree(lovData, parent, treeModel); + + JTree tree = new JTree(treeModel); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + cellRenderer.setTextNonSelectionColor(Color.black); + cellRenderer.setTextSelectionColor(Color.blue); + return tree; + } + + private void initTree(CustomLovBean lovData, DefaultMutableTreeNode parent, DefaultTreeModel treeModel) { + if (!lovData.hasChild()) { + return; + } + List subList = lovData.getSub(); + for (CustomLovBean sub : subList) { + DefaultMutableTreeNode temp = new DefaultMutableTreeNode(sub.displayName); + treeModel.insertNodeInto(temp, parent, parent.getChildCount()); + initTree(sub, temp, treeModel); + } + } + + private ItemListener selectAll(JTable table) { + return new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + boolean select = ((JCheckBox) e.getSource()).isSelected(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox checkBox = (JCheckBox) table.getValueAt(i, 0); + checkBox.setSelected(select); + table.revalidate(); + table.repaint(); + } + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + $this.dispose(); + } + }; + } + + private ActionListener batchRevise(JTable table, JCheckBox selectAll) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkAccess(selectedRowList).isRes()) { + return; + } + List msgData = new ArrayList(); + for (int i = 0; i < selectedRowList.size(); i++) { + try { + TCComponentItemRevision newRev = selectedRowList.get(i).getParentRev().saveAs(null); + String parentString = newRev.getProperty("object_string"); + selectedRowList.get(i).setParentRev(newRev); + selectedRowList.get(i).setParentString(parentString); + msgData.add(new String[] { msgData.size() + 1 + "", selectedRowList.get(i).getParentString(), + newRev.getProperty("object_string"), "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + } + +// showWhereUesd(table, selectAll); + updateSelectedRow(table, selectedRowList); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "汾(ǰ)", "汾()", "" }, + msgData).panel; + JOptionPane.showMessageDialog($this, jsp, "", JOptionPane.PLAIN_MESSAGE); + } + }; + } + + private List usedFilter(TCComponent[] comps) throws TCException { +// Map sameParentUsedMap = new HashMap(); + List list = new ArrayList<>(); + for (TCComponent comp : comps) { + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; +// String itemId; +// if (sameParentUsedMap.containsKey(itemId = comp.getProperty("item_id"))) { +// if (sameParentUsedMap.get(itemId).getProperty("item_revision_id") +// .compareTo(comp.getProperty("item_revision_id")) < 0) { +// sameParentUsedMap.put(itemId, rev); +// } +// } else { + if (rev.getItem().getLatestItemRevision().getUid().equals(rev.getUid())) { + list.add(rev); + } +// sameParentUsedMap.put(itemId, rev); +// } + } + } + return list; + } + + private void createLogDataSourceTable() { + if (isLogcreated) { + return; + } + String sql1 = "CREATE TABLE JD2_BOMManageLog ( id NUMBER ( 38, 0 ) primary key, modify_user VARCHAR2 ( 200 ), modify_time DATE, modify_content VARCHAR2 ( 500 ), target1 VARCHAR2 ( 100 ), target2 VARCHAR2 ( 100 ), parent VARCHAR2 ( 100 ), operation VARCHAR2 ( 50 ), unit VARCHAR2 ( 100 ), num VARCHAR2 ( 100 ))"; + String sql2 = "CREATE sequence JD2_BOMManageLog_seq minvalue 1 maxvalue 99999999 INCREMENT BY 1 START WITH 1"; + String sql3 = "CREATE OR REPLACE TRIGGER JD2_BOMManageLog_tri before INSERT ON JD2_BOMManageLog FOR each ROW BEGIN SELECT JD2_BOMManageLog_seq.nextval INTO : new.id FROM dual; END;"; + try { + List temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("user_tables", + new Condition("table_name", "JD2_BOMMANAGELOG")); + if (temp == null || temp.size() == 0) { + Db.use(DBUtil.getDataSource(session)).execute(sql1); + System.out.println("JD2_BOMMANAGELOG create success"); + } + temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("user_sequences", + new Condition("sequence_name", "JD2_BOMMANAGELOG_SEQ")); + if (temp == null || temp.size() == 0) { + Db.use(DBUtil.getDataSource(session)).execute(sql2); + System.out.println("JD2_BOMMANAGELOG_SEQ create success"); + } + temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("all_triggers", + new Condition("trigger_name", "JD2_BOMMANAGELOG_TRI")); + if (temp == null || temp.size() == 0) { + DBConnectionUtil.dbConn(session).createStatement().execute(sql3); + System.out.println("JD2_BOMManageLog_tri create success"); + } + isLogcreated = true; + System.out.println("init log success"); + } catch (Exception e) { + // TODO Auto-generated catch block + JOptionPane.showMessageDialog($this, "ݿʧܣѡjd2_db_settings", "", JOptionPane.ERROR_MESSAGE); + e.printStackTrace(); + } + } + + private ActionListener searchLog() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String username = p5UserText.getText().trim(); + String content = p5ContentText.getText(); + if (username == null || "".equals(username)) { + return; + } + + String sql = "select * from JD2_BOMMANAGELOG where "; + if (!"*".equals(username)) { + sql += "modify_user like '%" + username + "%' and"; + } + sql += " modify_time between to_date('" + p5TimeStartText.getText() + + " 00:00:00','yyyy-MM-dd hh24:mi:ss') and to_date('" + p5TimeEndText.getText() + + " 23:59:59','yyyy-MM-dd hh24:mi:ss')"; + if (content != null && !"".equals(content)) { + sql += " and modify_content like '%" + content + "%'"; + } + sql += "order by MODIFY_TIME asc"; + System.out.println(sql); + try { + logDataList = Db.use(DBUtil.getDataSource(session)).query(sql); + System.out.println("log size=====>" + logDataList.size()); + DefaultTableModel model = (DefaultTableModel) p5Table.getModel(); + for (Entity entity : logDataList) { + Object[] objArr = new Object[] { entity.get("ID"), entity.get("MODIFY_USER"), + entity.get("MODIFY_TIME"), entity.get("MODIFY_CONTENT") }; + model.addRow(objArr); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + } + p5Table.revalidate(); + p5Table.repaint(); + } + }; + } + + private ActionListener downloadLog(JTable table) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (table.getRowCount() > 0) { + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setMultiSelectionEnabled(false); + chooser.setCurrentDirectory(FileSystemView.getFileSystemView().getHomeDirectory()); + chooser.showOpenDialog($this); + File folder = chooser.getSelectedFile(); + FileWriter fileWriter = null; + String fileName = "BOM־-" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + ".txt"; + try { + fileWriter = new FileWriter(folder.getPath() + File.separator + fileName);// ıļ + String temp; + System.out.println(logDataList.size()); + for (Entity entity : logDataList) { + fileWriter.write((temp = entity.get("ID").toString()) + + StringCreateUtil.createBlank(10 - temp.length()) + + (temp = entity.get("MODIFY_USER").toString()) + + StringCreateUtil.createBlank(20 - temp.length()) + + (temp = entity.get("MODIFY_TIME").toString()) + + StringCreateUtil.createBlank(30 - temp.length()) + + entity.get("MODIFY_CONTENT").toString() + "\r\n"); + } + fileWriter.flush(); + fileWriter.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + } + + JOptionPane.showMessageDialog($this, "־ɹ\r\n·" + folder + File.separator + fileName, "ʾ", + JOptionPane.WARNING_MESSAGE); + } + } + }; + + } + + private ActionListener batchReplace() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p1NumText.getText().trim(); + String text = p1UnitCombo.getSelectedText().trim(); + Object value = p1UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p1Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + List logData = new ArrayList(); + L1: for (int i = 0; i < selectedRowList.size(); i++) { + try { + doIndex++; + BOMManageTableBean bean = selectedRowList.get(i); + System.out.println(value.toString()); + if (!addedBOMLine.add(targetRev2)) { + continue L1; + } + AIFComponentContext[] aifs = bean.getParentLine().getChildren(); + for (AIFComponentContext aif : aifs) { + String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() + .getProperty("object_string"); + if (objStr.equals(targetRev2.getProperty("object_string"))) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), targetRev2.getProperty("object_string"), + value.toString(), numStr, "ʧܣѴͬӼ" }); + continue L1; + } + } + String seq = selectedRowList.get(i).getChildLine().getProperty("bl_sequence_no"); + bean.getParentLine().remove("", bean.getChildLine()); + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity", "bl_sequence_no" }, + new String[] { numStr, seq }); + msgData.add( + new String[] { msgData.size() + 1 + "", bean.getParentString(), bean.getChildString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + BOMLogBean logBean = new BOMLogBean(bean.getChildString(), + targetRev2.getProperty("object_string"), bean.getParentString(), "滻", value.toString(), + "", numStr); + logData.add(logBean); + selectedRowList.get(i).setChildString(targetRev2.getProperty("object_string")); + selectedRowList.get(i).setChildRev(targetRev2); + selectedRowList.get(i).setChildLine(childLine); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("滻ִϣʱ" + (endTime - startTime) + "ms"); + doLog("滻", logData); + JScrollPane jsp = DialogUtil + .createTableMsg(new String[] { "", "", "ԭӼ", "滻Ӽ", "λ", "", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "滻 ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow2(p1Table, selectedRowList); + } + }; + } + + private ActionListener batchModify() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p2NumText.getText(); + List selectedRowList = getselectedRow(p2Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + List logData = new ArrayList<>(); + for (BOMManageTableBean bean : selectedRowList) { + String oldNumStr = ""; + try { + doIndex++; + oldNumStr = bean.getChildLine().getProperty("bl_quantity"); + bean.getChildLine().setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), oldNumStr, numStr, "ɹ" }); + BOMLogBean logBean = new BOMLogBean(bean.getChildString(), + targetRev2.getProperty("object_string"), bean.getParentString(), "޸", "", oldNumStr, + numStr); + logData.add(logBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("޸", logData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "ԭ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "Ľ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow(p2Table, selectedRowList); + } + }; + } + + private ActionListener batchAdd() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p3NumText.getText().trim(); + String text = p3UnitCombo.getSelectedText().trim(); + Object value = p3UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p3Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + List logData = new ArrayList<>(); + L1: for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + System.out.println(value.toString()); + if (!addedBOMLine.add(targetRev2)) { + continue L1; + } + AIFComponentContext[] aifs = bean.getParentLine().getChildren(); + for (AIFComponentContext aif : aifs) { + String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() + .getProperty("object_string"); + if (objStr.equals(targetRev2.getProperty("object_string"))) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, + "ʧܣѴͬӼ" }); + continue L1; + } + } + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + BOMLogBean logBean = new BOMLogBean(bean.getChildString(), + targetRev2.getProperty("object_string"), bean.getParentString(), "", value.toString(), + "", numStr); + logData.add(logBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("", logData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "λ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, " ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// showWhereUesd(p3Table, p3SelectAll); + } + }; + } + + private ActionListener batchRemove() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(p4Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + List logData = new ArrayList<>(); + for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + if (bean.getChildLine() == null) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "bomLineڣѾɹɾ" }); + } else { + bean.getParentLine().remove("", bean.getChildLine()); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "ɹ" }); + BOMLogBean logBean = new BOMLogBean(bean.getChildString(), + targetRev2.getProperty("object_string"), bean.getParentString(), "ɾ", "", "", ""); + logData.add(logBean); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ɾִϣʱ" + (endTime - startTime) + "ms"); + doLog("ɾ", logData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "ɾӼ", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "ɾ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// removeSelectRow(p4Table); + updateSelectedRow3(p4Table, selectedRowList); + } + }; + } + + private List getselectedRow(JTable table) { + List selectedList = new ArrayList(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + System.out.println("select=====>" + table.getValueAt(i, 1)); + selectedList.add(tableDataMap.get(table.getValueAt(i, 1))); + } + } + return selectedList; + } + + private void updateSelectedRow(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + try { + TCComponentItemRevision parentRev = newRowData.get(index).getParentRev(); + String parentString = newRowData.get(index).getParentString(); + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.get(table.getValueAt(i, 1).toString()).close(); + winMap.remove(table.getValueAt(i, 1)); + winMap.put(parentString, win); + tableDataMap.remove(table.getValueAt(i, 1).toString()); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (newRowData.get(index).getChildString() + .equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + JCheckBox selected = new JCheckBox(); + selected.setSelected(true); + Object[] rowData = new Object[] { selected, parentString, + newRowData.get(index).getChildString(), unit, num, status }; + rowPrint(rowData); + for (int ii = 0; ii < rowData.length; ii++) { + table.setValueAt(rowData[ii], i, ii); + } + tableDataMap.put(parentString, new BOMManageTableBean(parentString, + newRowData.get(index).getChildString(), parentRev, targetRev, topLine, child)); + break; + } + } + index++; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow2(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + try { + TCComponentBOMLine child = bean.getChildLine(); + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + table.setValueAt(bean.getChildString(), i, 2); + table.setValueAt(unit, index, 3); + table.setValueAt(num, index, 4); + tableDataMap.get(bean.getParentString()).setChildRev(bean.getChildRev()); + tableDataMap.get(bean.getParentString()).setChildString(bean.getChildString()); + tableDataMap.get(bean.getParentString()).setChildLine(child); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow3(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + table.setValueAt("", i, 2); + table.setValueAt("", index, 3); + table.setValueAt("", index, 4); + tableDataMap.get(bean.getParentString()).setChildLine(null); + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void removeSelectRow(JTable table) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int i = 0; + while (i < table.getRowCount()) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + model.removeRow(i); + continue; + } + i++; + } + table.revalidate(); + table.repaint(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + new Thread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + try { + closeWin(); + System.out.println("closed"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }).start(); + + super.dispose(); + } + + private void saveWin() throws TCException { + for (Entry entry : winMap.entrySet()) { + if (entry.getValue() != null) { + entry.getValue().save(); + } + + } + } + + private void closeWin() throws TCException { + saveWin(); + + for (Entry entry : winMap.entrySet()) { + entry.getValue().close(); + } + winMap.clear(); + } + + private void doLog(String operation, List logData) { + createLogDataSourceTable(); + String username = ""; + try { + username = session.getUser().getUserName() + "(" + session.getUser().getUserId() + ")"; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + String datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + List sqls = new ArrayList(); + for (BOMLogBean bean : logData) { + StringBuilder builder = new StringBuilder(); + builder.append( + "insert into JD2_BOMMANAGELOG (MODIFY_USER,MODIFY_TIME,MODIFY_CONTENT,TARGET1,TARGET2,PARENT,OPERATION,UNIT,NUM) VALUES ('"); + builder.append(username); + builder.append("',to_date('"); + builder.append(datetime); + builder.append("','yyyy-MM-dd hh24:mi:ss'),'"); + if ("滻".equals(operation)) { + String temp = String.format("%sӼ%s滻Ϊ%s;%s;%s", bean.getParent(), bean.getTarget1(), + bean.getTarget2(), bean.getUnit(), bean.getNum()); + builder.append(temp + "','"); + } else if ("޸".equals(operation)) { + String temp = String.format("%sӼ%s%sΪ%s", bean.getParent(), bean.getTarget1(), bean.getOldNum(), + bean.getNum()); + builder.append(temp + "','"); + } else if ("".equals(operation)) { + String temp = String.format("%sӼ%s;%s;%s", bean.getParent(), bean.getTarget2(), bean.getUnit(), + bean.getNum()); + builder.append(temp + "','"); + } else if ("ɾ".equals(operation)) { + String temp = String.format("%sɾӼ%s", bean.getParent(), bean.getTarget1()); + builder.append(temp + "','"); + } + builder.append(bean.getTarget1() + "','"); + builder.append(bean.getTarget2() + "','"); + builder.append(bean.getParent() + "','"); + builder.append(bean.getUnit() + "','"); + builder.append(operation + "','"); + builder.append(bean.getNum() + "');"); + sqls.add(builder.toString()); + } + + try { + Db.use(DBUtil.getDataSource(session)).executeBatch(sqls.toArray(new String[sqls.size()])); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private ActionListener clickSearch(JTable table, JCheckBox selectAll) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JDialog content = DialogUtil.createSearchAndSelectRevDialog($this, table, selectAll, + (JButton) e.getSource()); + } + }; + } + + public void okCallback(JTable revTable, JTable table, JCheckBox selectAll, JButton field) { + // TODO Auto-generated method stub + int rowIndex = revTable.getSelectedRow(); + if (rowIndex < 0) { + return; + } + String text = revTable.getValueAt(rowIndex, 0).toString(); + System.out.println(text); + field.setText(text); + if ("".equals(text)) { + return; + } + if (table != null) { + targetRev = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + showWhereUesd(table, selectAll); + } else { + targetRev2 = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + } + } + + private KeyAdapter logSearchEnter() { + return new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + super.keyTyped(e); + if (e.getKeyChar() == KeyEvent.VK_ENTER) { + p5Search.doClick(); + } + } + }; + } + + private void updateTitleShowProgress(List list) { + new Thread(new Runnable() { + + @Override + public void run() { + int num = 1; + String temp; + doIndex = 0; + while (!complate) { + $this.setTitle("ڴ" + (temp = StringCreateUtil.createPoint(num % 3)) + + StringCreateUtil.createBlank(5 - temp.length()) + list.get(doIndex).getParentString() + + " " + (doIndex + 1) + "/" + list.size()); + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + num++; + } + $this.setTitle("BOM"); + doIndex = -1; + complate = false; + } + }).start(); + } + + private boolean checkReleaseStatus(TCComponentItemRevision rev) { + try { + System.out.println("item type======>" + rev.getItem().getType()); + if (checkItemType.contains(rev.getItem().getType())) { + return true; + } + TCComponent form = rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] statusArray = form.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + if ("".equals(status) || "JD2_DJJY".equals(status) || "JD2_DJKY".equals(status)) { + return false; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } + + private ResultData checkAccess(List data) { + for (BOMManageTableBean bean : data) { + boolean isAccess = true; + try { + isAccess = session.getTCAccessControlService().checkPrivilege(bean.getParentLine(), "WRITE"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (!isAccess) { + try { + return new ResultData(false, "ǰûûж" + bean.getParentLine().getProperty("object_string") + "дȨ", + bean.getParentLine()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return new ResultData(true, "", null); + } + + private boolean checkTargetAndSelect(TCComponentItemRevision rev, List data) { + if (!checkReleaseStatus(rev)) { + JOptionPane.showMessageDialog($this, "Ŀδߴڶ״̬޷BOM", "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + ResultData res = checkAccess(data); + if (!res.isRes()) { + JOptionPane.showMessageDialog($this, res.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + return true; + } + + private ActionListener startWorkFlow(JTable table) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List select = getselectedRow(table); + List parentRev = new ArrayList<>(); + for (BOMManageTableBean bean : select) { + parentRev.add(bean.getParentRev()); + } + $this.setExtendedState(JFrame.ICONIFIED); + NewProcessCommand command = new NewProcessCommand(AIFUtility.getActiveDesktop(), app, + parentRev.toArray(new TCComponentItemRevision[parentRev.size()])); + } + }; + } + + private void rowPrint(Object[] arr) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (Object obj : arr) { + if (obj instanceof JCheckBox) { + sb.append(((JCheckBox) obj).isSelected()); + } else { + sb.append(obj.toString()); + } + sb.append(","); + } + if (sb.length() > 1) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append("]"); + System.out.println(sb.toString()); + } + + private void resize() { + double left = 2 * this.widthOffset / 3.0; + double right = this.widthOffset - left; + + int bottom1 = p1BottomBtn2.getX() - p1BottomBtn1.getX() - p1BottomBtn1.getWidth(); + int bottom2 = p1BottomBtn3.getX() - p1BottomBtn2.getX() - p1BottomBtn2.getWidth(); + int botttom3 = p1BottomBtn4.getX() - p1BottomBtn3.getX() - p1BottomBtn3.getWidth(); + + // p1 + int p1x1 = p1TargetBtn.getX() - p1TargetLabel.getX() - p1TargetLabel.getWidth(); + int p1x2 = p1ReplaceBtn.getX() - p1ReplaceLabel.getX() - p1ReplaceLabel.getWidth(); + int p1x3 = p1UnitLabel.getX() - p1ReplaceBtn.getX() - p1ReplaceBtn.getWidth(); + int p1x4 = p1NumLabel.getX() - p1UnitCombo.getX() - p1UnitCombo.getWidth(); + p1TargetLabel.setBounds(p1TargetLabel.getX() + getOffset(left, 20, 800), 20, + p1TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p1TargetBtn.setBounds(p1TargetLabel.getX() + p1TargetLabel.getWidth() + p1x1 + getOffset(left, 10, 800), 20, + p1TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p1ReplaceLabel.setBounds(p1ReplaceLabel.getX() + getOffset(left, 20, 800), 60, + p1ReplaceLabel.getWidth() + getOffset(left, 100, 800), 25); + p1ReplaceBtn.setBounds(p1ReplaceLabel.getX() + p1ReplaceLabel.getWidth() + p1x2 + getOffset(left, 10, 800), 60, + p1ReplaceBtn.getWidth() + getOffset(left, 400, 800), 25); + p1UnitLabel.setBounds(p1ReplaceBtn.getX() + p1ReplaceBtn.getWidth() + p1x3 + getOffset(left, 30, 800), 60, + p1UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p1UnitCombo.setBounds(p1UnitLabel.getX() + p1UnitLabel.getWidth(), 60, + p1UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p1NumLabel.setBounds(p1UnitCombo.getX() + p1UnitCombo.getWidth() + p1x4 + getOffset(left, 20, 800), 60, + p1NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p1NumText.setBounds(p1NumLabel.getX() + p1NumLabel.getWidth(), 60, + p1NumText.getWidth() + getOffset(left, 50, 800), 25); + p1SelectAll.setBounds(p1SelectAll.getX() + getOffset(left, 20, 800), 100, + p1SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p1jsp.setBounds(p1jsp.getX() + getOffset(left, 20, 800), p1jsp.getY(), + p1jsp.getWidth() + getOffset(left, 760, 800), p1jsp.getHeight() + this.heightOffset); + p1BottomBtn1.setBounds(p1BottomBtn1.getX() + getOffset(left, 80, 800), p1BottomBtn1.getY() + this.heightOffset, + p1BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn2.setBounds(p1BottomBtn1.getX() + p1BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p1BottomBtn2.getY() + this.heightOffset, p1BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn3.setBounds(p1BottomBtn2.getX() + p1BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p1BottomBtn3.getY() + this.heightOffset, p1BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn4.setBounds(p1BottomBtn3.getX() + p1BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p1BottomBtn4.getY() + this.heightOffset, p1BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p1Left.setBounds(0, 0, p1Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p1Left.getHeight() + this.heightOffset); + p1TreePanel.setBounds(p1TreePanel.getX() + getOffset(right, 20, 400), 130, + p1TreePanel.getWidth() + getOffset(right, 360, 400), p1TreePanel.getHeight() + this.heightOffset); + p1Right.setBounds(p1Left.getX() + p1Left.getWidth(), 0, + p1Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p1Right.getHeight() + this.heightOffset); + p1.revalidate(); + p1.repaint(); + + // p2 + int p2x1 = p2TargetBtn.getX() - p2TargetLabel.getX() - p2TargetLabel.getWidth(); + int p2x2 = p2NumText.getX() - p2ChangeNumLabel.getX() - p2ChangeNumLabel.getWidth(); + p2TargetLabel.setBounds(p2TargetLabel.getX() + getOffset(left, 20, 800), 20, + p2TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p2TargetBtn.setBounds(p2TargetLabel.getX() + p2TargetLabel.getWidth() + p2x1 + getOffset(left, 10, 800), 20, + p2TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p2ChangeNumLabel.setBounds(p2ChangeNumLabel.getX() + getOffset(left, 20, 800), 60, + p2ChangeNumLabel.getWidth() + getOffset(left, 100, 800), 25); + p2NumText.setBounds(p2ChangeNumLabel.getX() + p2ChangeNumLabel.getWidth() + p2x2 + getOffset(left, 10, 800), 60, + p2NumText.getWidth() + getOffset(left, 50, 800), 25); + p2SelectAll.setBounds(p2SelectAll.getX() + getOffset(left, 20, 800), 100, + p2SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p2jsp.setBounds(p2jsp.getX() + getOffset(left, 20, 800), p2jsp.getY(), + p2jsp.getWidth() + getOffset(left, 760, 800), p2jsp.getHeight() + this.heightOffset); + p2BottomBtn1.setBounds(p2BottomBtn1.getX() + getOffset(left, 80, 800), p2BottomBtn1.getY() + this.heightOffset, + p2BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn2.setBounds(p2BottomBtn1.getX() + p2BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p2BottomBtn2.getY() + this.heightOffset, p2BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn3.setBounds(p2BottomBtn2.getX() + p2BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p2BottomBtn3.getY() + this.heightOffset, p2BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn4.setBounds(p2BottomBtn3.getX() + p2BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p2BottomBtn4.getY() + this.heightOffset, p2BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p2Left.setBounds(0, 0, p2Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p2Left.getHeight() + this.heightOffset); + p2TreePanel.setBounds(p2TreePanel.getX() + getOffset(right, 20, 400), 130, + p2TreePanel.getWidth() + getOffset(right, 360, 400), p2TreePanel.getHeight() + this.heightOffset); + p2Right.setBounds(p2Left.getX() + p2Left.getWidth(), 0, + p2Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p2Right.getHeight() + this.heightOffset); + p2.revalidate(); + p2.repaint(); + + // p3 + int p3x1 = p3TargetBtn.getX() - p3TargetLabel.getX() - p3TargetLabel.getWidth(); + int p3x2 = p3AddBtn.getX() - p3AddLabel.getX() - p3AddLabel.getWidth(); + int p3x3 = p3UnitLabel.getX() - p3AddBtn.getX() - p3AddBtn.getWidth(); + int p3x4 = p3NumLabel.getX() - p3UnitCombo.getX() - p3UnitCombo.getWidth(); + p3TargetLabel.setBounds(p3TargetLabel.getX() + getOffset(left, 20, 800), 20, + p3TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p3TargetBtn.setBounds(p3TargetLabel.getX() + p3TargetLabel.getWidth() + p3x1 + getOffset(left, 10, 800), 20, + p3TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p3AddLabel.setBounds(p3AddLabel.getX() + getOffset(left, 20, 800), 60, + p3AddLabel.getWidth() + getOffset(left, 100, 800), 25); + p3AddBtn.setBounds(p3AddLabel.getX() + p3AddLabel.getWidth() + p3x2 + getOffset(left, 10, 800), 60, + p3AddBtn.getWidth() + getOffset(left, 400, 800), 25); + p3UnitLabel.setBounds(p3AddBtn.getX() + p3AddBtn.getWidth() + p3x3 + getOffset(left, 30, 800), 60, + p3UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p3UnitCombo.setBounds(p3UnitLabel.getX() + p3UnitLabel.getWidth(), 60, + p3UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p3NumLabel.setBounds(p3UnitCombo.getX() + p3UnitCombo.getWidth() + p3x4 + getOffset(left, 20, 800), 60, + p3NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p3NumText.setBounds(p3NumLabel.getX() + p3NumLabel.getWidth(), 60, + p3NumText.getWidth() + getOffset(left, 50, 800), 25); + p3SelectAll.setBounds(p3SelectAll.getX() + getOffset(left, 20, 800), 100, + p3SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p3jsp.setBounds(p3jsp.getX() + getOffset(left, 20, 800), p3jsp.getY(), + p3jsp.getWidth() + getOffset(left, 760, 800), p3jsp.getHeight() + this.heightOffset); + p3BottomBtn1.setBounds(p3BottomBtn1.getX() + getOffset(left, 80, 800), p3BottomBtn1.getY() + this.heightOffset, + p3BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn2.setBounds(p3BottomBtn1.getX() + p3BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p3BottomBtn2.getY() + this.heightOffset, p3BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn3.setBounds(p3BottomBtn2.getX() + p3BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p3BottomBtn3.getY() + this.heightOffset, p3BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn4.setBounds(p3BottomBtn3.getX() + p3BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p3BottomBtn4.getY() + this.heightOffset, p3BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p3Left.setBounds(0, 0, p3Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p3Left.getHeight() + this.heightOffset); + p3TreePanel.setBounds(p3TreePanel.getX() + getOffset(right, 20, 400), 130, + p3TreePanel.getWidth() + getOffset(right, 360, 400), p3TreePanel.getHeight() + this.heightOffset); + p3Right.setBounds(p3Left.getX() + p3Left.getWidth(), 0, + p3Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p3Right.getHeight() + this.heightOffset); + p3.revalidate(); + p3.repaint(); + + // p4 + int p4x1 = p4TargetBtn.getX() - p4TargetLabel.getX() - p4TargetLabel.getWidth(); + p4TargetLabel.setBounds(p4TargetLabel.getX() + getOffset(left, 20, 800), 20, + p4TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p4TargetBtn.setBounds(p4TargetLabel.getX() + p4TargetLabel.getWidth() + p4x1 + getOffset(left, 10, 800), 20, + p4TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p4SelectAll.setBounds(p4SelectAll.getX() + getOffset(left, 20, 800), 100, + p4SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p4jsp.setBounds(p4jsp.getX() + getOffset(left, 20, 800), p4jsp.getY(), + p4jsp.getWidth() + getOffset(left, 760, 800), p4jsp.getHeight() + this.heightOffset); + p4BottomBtn1.setBounds(p4BottomBtn1.getX() + getOffset(left, 80, 800), p4BottomBtn1.getY() + this.heightOffset, + p4BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn2.setBounds(p4BottomBtn1.getX() + p4BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p4BottomBtn2.getY() + this.heightOffset, p4BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn3.setBounds(p4BottomBtn2.getX() + p4BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p4BottomBtn3.getY() + this.heightOffset, p4BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn4.setBounds(p4BottomBtn3.getX() + p4BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p4BottomBtn4.getY() + this.heightOffset, p4BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p4Left.setBounds(0, 0, p4Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p4Left.getHeight() + this.heightOffset); + p4TreePanel.setBounds(p4TreePanel.getX() + getOffset(right, 20, 400), 130, + p4TreePanel.getWidth() + getOffset(right, 360, 400), p4TreePanel.getHeight() + this.heightOffset); + p4Right.setBounds(p4Left.getX() + p4Left.getWidth(), 0, + p4Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p4Right.getHeight() + this.heightOffset); + p4.revalidate(); + p4.repaint(); + + // p5 + int p5x1 = p5UserText.getX() - p5UserLabel.getX() - p5UserLabel.getWidth(); + int p5x2 = p5TimeLabel.getX() - p5UserText.getX() - p5UserText.getWidth(); + int p5x3 = p5TimeStartText.getX() - p5TimeLabel.getX() - p5TimeLabel.getWidth(); + int p5x4 = toLabel.getX() - p5TimeStartText.getX() - p5TimeStartText.getWidth(); + int p5x5 = p5TimeEndText.getX() - toLabel.getX() - toLabel.getWidth(); + int p5x6 = p5ContentLabel.getX() - p5TimeEndText.getX() - p5TimeEndText.getWidth(); + int p5x7 = p5Contentjsp.getX() - p5ContentLabel.getX() - p5ContentLabel.getWidth(); + int p5x8 = p5Search.getX() - p5Contentjsp.getX() - p5Contentjsp.getWidth(); + int p5x9 = p5Download.getX() - p5Search.getX() - p5Search.getWidth(); + p5UserLabel.setBounds(p5UserLabel.getX(), 40, p5UserLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), + 25); + p5UserText.setBounds(p5UserLabel.getX() + p5UserLabel.getWidth() + p5x1 + getOffset(this.widthOffset, 10, 1200), + 40, p5UserText.getWidth() + getOffset(this.widthOffset, 150, 1200), 25); + p5TimeLabel.setBounds(p5UserText.getX() + p5UserText.getWidth() + p5x2 + getOffset(this.widthOffset, 50, 1200), + 40, p5TimeLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5TimeStartText.setBounds( + p5TimeLabel.getX() + p5TimeLabel.getWidth() + p5x3 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeStartText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + toLabel.setBounds( + p5TimeStartText.getX() + p5TimeStartText.getWidth() + p5x4 + getOffset(this.widthOffset, 10, 1200), 40, + toLabel.getWidth() + getOffset(this.widthOffset, 20, 1200), 25); + p5TimeEndText.setBounds(toLabel.getX() + toLabel.getWidth() + p5x5 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeEndText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5ContentLabel.setBounds( + p5TimeEndText.getX() + p5TimeEndText.getWidth() + p5x6 + getOffset(this.widthOffset, 50, 1200), 40, + p5ContentLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5Contentjsp.setBounds( + p5ContentLabel.getX() + p5ContentLabel.getWidth() + p5x7 + getOffset(this.widthOffset, 10, 1200), 20, + p5Contentjsp.getWidth() + getOffset(this.widthOffset, 200, 1200), 80); + p5Search.setBounds(p5Contentjsp.getX() + p5Contentjsp.getWidth() + p5x8 + getOffset(this.widthOffset, 50, 1200), + 40, p5Search.getWidth() + getOffset(this.widthOffset, 60, 1200), 25); + p5Download.setBounds(p5Search.getX() + p5Search.getWidth() + p5x9 + getOffset(this.widthOffset, 20, 1200), 40, + p5Download.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5jsp.setBounds(p5jsp.getX() + getOffset(this.widthOffset, 20, 1200), p5jsp.getY(), + p5jsp.getWidth() + getOffset(this.widthOffset, 1160, 1200), p5jsp.getHeight() + this.heightOffset); + p5.revalidate(); + p5.repaint(); + } + + private int getOffset(double num1, int num2, int num3) { + return (int) (num1 * num2 / num3); + } + + private int getResultNum(List msgData, boolean success) { + int num = 0; + String str = success ? "ɹ" : "ʧ"; + for (String[] row : msgData) { + if (row[row.length - 1].contains(str)) { + num++; + } + } + return num; + } +} diff --git a/bin/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.class b/bin/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.class new file mode 100644 index 0000000..d95d4d6 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.class differ diff --git a/bin/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.class b/bin/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.class new file mode 100644 index 0000000..9ff5814 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.class differ diff --git a/bin/com/connor/jd/plm/dialogs/CheckBoxTreeNode.class b/bin/com/connor/jd/plm/dialogs/CheckBoxTreeNode.class new file mode 100644 index 0000000..ec92ec4 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/CheckBoxTreeNode.class differ diff --git a/bin/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.class b/bin/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.class new file mode 100644 index 0000000..c547123 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.class differ diff --git a/bin/com/connor/jd/plm/dialogs/ColorMaterialBean.class b/bin/com/connor/jd/plm/dialogs/ColorMaterialBean.class new file mode 100644 index 0000000..633f78b Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/ColorMaterialBean.class differ diff --git a/bin/com/connor/jd/plm/dialogs/MyTreeCellRenderer.class b/bin/com/connor/jd/plm/dialogs/MyTreeCellRenderer.class new file mode 100644 index 0000000..0c40d80 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/MyTreeCellRenderer.class differ diff --git a/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$1.class b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$1.class new file mode 100644 index 0000000..fe0743f Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$1.class differ diff --git a/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$2.class b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$2.class new file mode 100644 index 0000000..bb9debe Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$2.class differ diff --git a/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$3.class b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$3.class new file mode 100644 index 0000000..11f64fd Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$3.class differ diff --git a/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$4.class b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$4.class new file mode 100644 index 0000000..785c22e Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$4.class differ diff --git a/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$5.class b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$5.class new file mode 100644 index 0000000..8d09b07 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$5.class differ diff --git a/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$6.class b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$6.class new file mode 100644 index 0000000..66d74ba Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog$6.class differ diff --git a/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.class b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.class new file mode 100644 index 0000000..d7b1e64 Binary files /dev/null and b/bin/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.class differ diff --git a/bin/com/connor/jd/plm/handlers/BOMManagementHandler.class b/bin/com/connor/jd/plm/handlers/BOMManagementHandler.class new file mode 100644 index 0000000..985d90e Binary files /dev/null and b/bin/com/connor/jd/plm/handlers/BOMManagementHandler.class differ diff --git a/bin/com/connor/jd/plm/table/ButtonEditor.class b/bin/com/connor/jd/plm/table/ButtonEditor.class new file mode 100644 index 0000000..15dc5cd Binary files /dev/null and b/bin/com/connor/jd/plm/table/ButtonEditor.class differ diff --git a/bin/com/connor/jd/plm/table/ButtonEditor2.class b/bin/com/connor/jd/plm/table/ButtonEditor2.class new file mode 100644 index 0000000..1a12bcf Binary files /dev/null and b/bin/com/connor/jd/plm/table/ButtonEditor2.class differ diff --git a/bin/com/connor/jd/plm/table/CTMap.class b/bin/com/connor/jd/plm/table/CTMap.class new file mode 100644 index 0000000..12011f9 Binary files /dev/null and b/bin/com/connor/jd/plm/table/CTMap.class differ diff --git a/bin/com/connor/jd/plm/table/CTUI.class b/bin/com/connor/jd/plm/table/CTUI.class new file mode 100644 index 0000000..369dfee Binary files /dev/null and b/bin/com/connor/jd/plm/table/CTUI.class differ diff --git a/bin/com/connor/jd/plm/table/CTable.class b/bin/com/connor/jd/plm/table/CTable.class new file mode 100644 index 0000000..48857bd Binary files /dev/null and b/bin/com/connor/jd/plm/table/CTable.class differ diff --git a/bin/com/connor/jd/plm/table/CTest$1.class b/bin/com/connor/jd/plm/table/CTest$1.class new file mode 100644 index 0000000..e9f9f74 Binary files /dev/null and b/bin/com/connor/jd/plm/table/CTest$1.class differ diff --git a/bin/com/connor/jd/plm/table/CTest.class b/bin/com/connor/jd/plm/table/CTest.class new file mode 100644 index 0000000..3e2cde9 Binary files /dev/null and b/bin/com/connor/jd/plm/table/CTest.class differ diff --git a/bin/com/connor/jd/plm/table/CellSpan.class b/bin/com/connor/jd/plm/table/CellSpan.class new file mode 100644 index 0000000..f9b140b Binary files /dev/null and b/bin/com/connor/jd/plm/table/CellSpan.class differ diff --git a/bin/com/connor/jd/plm/table/DatePickerCellEditor.class b/bin/com/connor/jd/plm/table/DatePickerCellEditor.class new file mode 100644 index 0000000..9beff88 Binary files /dev/null and b/bin/com/connor/jd/plm/table/DatePickerCellEditor.class differ diff --git a/bin/com/connor/jd/plm/table/DefaultModel.class b/bin/com/connor/jd/plm/table/DefaultModel.class new file mode 100644 index 0000000..a9052f8 Binary files /dev/null and b/bin/com/connor/jd/plm/table/DefaultModel.class differ diff --git a/bin/com/connor/jd/plm/table/JCheckPanel.class b/bin/com/connor/jd/plm/table/JCheckPanel.class new file mode 100644 index 0000000..17e5102 Binary files /dev/null and b/bin/com/connor/jd/plm/table/JCheckPanel.class differ diff --git a/bin/com/connor/jd/plm/table/JRadioPanel.class b/bin/com/connor/jd/plm/table/JRadioPanel.class new file mode 100644 index 0000000..e7dd484 Binary files /dev/null and b/bin/com/connor/jd/plm/table/JRadioPanel.class differ diff --git a/bin/com/connor/jd/plm/table/MessageBox2.class b/bin/com/connor/jd/plm/table/MessageBox2.class new file mode 100644 index 0000000..1422878 Binary files /dev/null and b/bin/com/connor/jd/plm/table/MessageBox2.class differ diff --git a/bin/com/connor/jd/plm/table/MyCellEditor.class b/bin/com/connor/jd/plm/table/MyCellEditor.class new file mode 100644 index 0000000..990d0a8 Binary files /dev/null and b/bin/com/connor/jd/plm/table/MyCellEditor.class differ diff --git a/bin/com/connor/jd/plm/table/MyCellEditor1.class b/bin/com/connor/jd/plm/table/MyCellEditor1.class new file mode 100644 index 0000000..33a0cd2 Binary files /dev/null and b/bin/com/connor/jd/plm/table/MyCellEditor1.class differ diff --git a/bin/com/connor/jd/plm/table/MyCellEditor2.class b/bin/com/connor/jd/plm/table/MyCellEditor2.class new file mode 100644 index 0000000..079ebd9 Binary files /dev/null and b/bin/com/connor/jd/plm/table/MyCellEditor2.class differ diff --git a/bin/com/connor/jd/plm/table/MyCellEditor3.class b/bin/com/connor/jd/plm/table/MyCellEditor3.class new file mode 100644 index 0000000..7c26228 Binary files /dev/null and b/bin/com/connor/jd/plm/table/MyCellEditor3.class differ diff --git a/bin/com/connor/jd/plm/table/MyCellEditor4.class b/bin/com/connor/jd/plm/table/MyCellEditor4.class new file mode 100644 index 0000000..2303ef0 Binary files /dev/null and b/bin/com/connor/jd/plm/table/MyCellEditor4.class differ diff --git a/bin/com/connor/jd/plm/table/MyCellRenderer.class b/bin/com/connor/jd/plm/table/MyCellRenderer.class new file mode 100644 index 0000000..13db491 Binary files /dev/null and b/bin/com/connor/jd/plm/table/MyCellRenderer.class differ diff --git a/bin/com/connor/jd/plm/table/MyComboBoxRenderer.class b/bin/com/connor/jd/plm/table/MyComboBoxRenderer.class new file mode 100644 index 0000000..12e851d Binary files /dev/null and b/bin/com/connor/jd/plm/table/MyComboBoxRenderer.class differ diff --git a/bin/com/connor/jd/plm/table/TableCellTextAreaRenderer.class b/bin/com/connor/jd/plm/table/TableCellTextAreaRenderer.class new file mode 100644 index 0000000..0de4426 Binary files /dev/null and b/bin/com/connor/jd/plm/table/TableCellTextAreaRenderer.class differ diff --git a/bin/com/connor/jd/plm/table/TempTest.class b/bin/com/connor/jd/plm/table/TempTest.class new file mode 100644 index 0000000..57fa756 Binary files /dev/null and b/bin/com/connor/jd/plm/table/TempTest.class differ diff --git a/bin/com/connor/jd/plm/util/package-info.class b/bin/com/connor/jd/plm/util/package-info.class new file mode 100644 index 0000000..c42252c Binary files /dev/null and b/bin/com/connor/jd/plm/util/package-info.class differ diff --git a/bin/com/connor/jd/plm/utils/BasicDataSource.class b/bin/com/connor/jd/plm/utils/BasicDataSource.class new file mode 100644 index 0000000..e5968f7 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/BasicDataSource.class differ diff --git a/bin/com/connor/jd/plm/utils/DBConnectionUtil.class b/bin/com/connor/jd/plm/utils/DBConnectionUtil.class new file mode 100644 index 0000000..d8a0c84 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DBConnectionUtil.class differ diff --git a/bin/com/connor/jd/plm/utils/DBUtil.class b/bin/com/connor/jd/plm/utils/DBUtil.class new file mode 100644 index 0000000..a531dce Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DBUtil.class differ diff --git a/bin/com/connor/jd/plm/utils/DatePickerUtil$1.class b/bin/com/connor/jd/plm/utils/DatePickerUtil$1.class new file mode 100644 index 0000000..1c3694c Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DatePickerUtil$1.class differ diff --git a/bin/com/connor/jd/plm/utils/DatePickerUtil.class b/bin/com/connor/jd/plm/utils/DatePickerUtil.class new file mode 100644 index 0000000..480a97d Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DatePickerUtil.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil$1.class b/bin/com/connor/jd/plm/utils/DialogUtil$1.class new file mode 100644 index 0000000..15f4935 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil$1.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil$2.class b/bin/com/connor/jd/plm/utils/DialogUtil$2.class new file mode 100644 index 0000000..5676a7f Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil$2.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil$3.class b/bin/com/connor/jd/plm/utils/DialogUtil$3.class new file mode 100644 index 0000000..9241aba Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil$3.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil$4.class b/bin/com/connor/jd/plm/utils/DialogUtil$4.class new file mode 100644 index 0000000..7473ffa Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil$4.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil$5.class b/bin/com/connor/jd/plm/utils/DialogUtil$5.class new file mode 100644 index 0000000..2c12e80 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil$5.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil$6.class b/bin/com/connor/jd/plm/utils/DialogUtil$6.class new file mode 100644 index 0000000..1472178 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil$6.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil$7.class b/bin/com/connor/jd/plm/utils/DialogUtil$7.class new file mode 100644 index 0000000..e0227e8 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil$7.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil$TableMsg.class b/bin/com/connor/jd/plm/utils/DialogUtil$TableMsg.class new file mode 100644 index 0000000..bb8aee4 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil$TableMsg.class differ diff --git a/bin/com/connor/jd/plm/utils/DialogUtil.class b/bin/com/connor/jd/plm/utils/DialogUtil.class new file mode 100644 index 0000000..f442278 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/DialogUtil.class differ diff --git a/bin/com/connor/jd/plm/utils/ExcelInfoScanner.class b/bin/com/connor/jd/plm/utils/ExcelInfoScanner.class new file mode 100644 index 0000000..419445d Binary files /dev/null and b/bin/com/connor/jd/plm/utils/ExcelInfoScanner.class differ diff --git a/bin/com/connor/jd/plm/utils/JDMethodUtil.class b/bin/com/connor/jd/plm/utils/JDMethodUtil.class new file mode 100644 index 0000000..4456b85 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/JDMethodUtil.class differ diff --git a/bin/com/connor/jd/plm/utils/KeyValComboBox$1.class b/bin/com/connor/jd/plm/utils/KeyValComboBox$1.class new file mode 100644 index 0000000..f5e9c63 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/KeyValComboBox$1.class differ diff --git a/bin/com/connor/jd/plm/utils/KeyValComboBox.class b/bin/com/connor/jd/plm/utils/KeyValComboBox.class new file mode 100644 index 0000000..106ef71 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/KeyValComboBox.class differ diff --git a/bin/com/connor/jd/plm/utils/SimpleExcelUtil.class b/bin/com/connor/jd/plm/utils/SimpleExcelUtil.class new file mode 100644 index 0000000..123af74 Binary files /dev/null and b/bin/com/connor/jd/plm/utils/SimpleExcelUtil.class differ diff --git a/bin/com/connor/jd/plm/utils/StringCreateUtil.class b/bin/com/connor/jd/plm/utils/StringCreateUtil.class new file mode 100644 index 0000000..86d1a5a Binary files /dev/null and b/bin/com/connor/jd/plm/utils/StringCreateUtil.class differ diff --git a/bin/com/px/plm/handlers/SampleHandler.class b/bin/com/px/plm/handlers/SampleHandler.class new file mode 100644 index 0000000..b59014d Binary files /dev/null and b/bin/com/px/plm/handlers/SampleHandler.class differ diff --git a/bin/com/uds/update/UDSStartup$1$1.class b/bin/com/uds/update/UDSStartup$1$1.class new file mode 100644 index 0000000..98dc545 Binary files /dev/null and b/bin/com/uds/update/UDSStartup$1$1.class differ diff --git a/bin/com/uds/update/UDSStartup$1.class b/bin/com/uds/update/UDSStartup$1.class new file mode 100644 index 0000000..c452018 Binary files /dev/null and b/bin/com/uds/update/UDSStartup$1.class differ diff --git a/bin/com/uds/update/UDSStartup.class b/bin/com/uds/update/UDSStartup.class new file mode 100644 index 0000000..afdb10f Binary files /dev/null and b/bin/com/uds/update/UDSStartup.class differ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..22911c3 --- /dev/null +++ b/build.properties @@ -0,0 +1,45 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + lib/aspose-cells-18.9.jar,\ + lib/commons-codec-1.13.jar,\ + lib/commons-collections4-4.4.jar,\ + lib/commons-compress-1.19.jar,\ + lib/commons-lang3-3.9.jar,\ + lib/commons-logging-1.2.jar,\ + lib/commons-math3-3.6.1.jar,\ + lib/datepicker.jar,\ + lib/fastjson-1.2.9.jar,\ + lib/hutool-all-5.0.7.jar,\ + lib/jaxb-api-2.3.1.jar,\ + lib/jaxb-core-2.3.0.1.jar,\ + lib/jaxb-impl-2.3.2.jar,\ + lib/jfxrt.jar,\ + lib/ojdbc6.jar,\ + lib/poi-4.1.1.jar,\ + lib/poi-examples-4.1.1.jar,\ + lib/poi-excelant-4.1.1.jar,\ + lib/poi-ooxml-4.1.1.jar,\ + lib/poi-ooxml-schemas-4.1.1.jar,\ + lib/poi-scratchpad-4.1.1.jar,\ + lib/xmlbeans-3.1.0.jar,\ + lib/fastjson-1.2.83.jar,\ + lib/mssql-jdbc-7.0.0.jre8.jar,\ + lib/hutool-all-4.0.9.jar,\ + lib/hutool-all-4.1.19.jar,\ + lib/mssql-jdbc-6.4.0.jre7.jar,\ + lib/sqljdbc4.jar,\ + lib/jaxen-1.1.6.jar,\ + lib/jdom-2.0.6.jar,\ + lib/jdom-2.0.6-contrib.jar,\ + lib/jdom-2.0.6-javadoc.jar,\ + lib/jdom-2.0.6-junit.jar,\ + lib/jdom-2.0.6-sources.jar,\ + lib/poi-3.5.jar,\ + lib/serializer-2.7.2.jar,\ + lib/xalan-2.7.2.jar,\ + lib/xercesImpl.jar,\ + lib/xml-apis.jar diff --git a/details.txt b/details.txt new file mode 100644 index 0000000..c173e94 --- /dev/null +++ b/details.txt @@ -0,0 +1 @@ +һϢ \ No newline at end of file diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/lib/aspose-cells-18.9.jar b/lib/aspose-cells-18.9.jar new file mode 100644 index 0000000..2cefe55 Binary files /dev/null and b/lib/aspose-cells-18.9.jar differ diff --git a/lib/commons-codec-1.13.jar b/lib/commons-codec-1.13.jar new file mode 100644 index 0000000..bf6ccb3 Binary files /dev/null and b/lib/commons-codec-1.13.jar differ diff --git a/lib/commons-collections4-4.4.jar b/lib/commons-collections4-4.4.jar new file mode 100644 index 0000000..da06c3e Binary files /dev/null and b/lib/commons-collections4-4.4.jar differ diff --git a/lib/commons-compress-1.19.jar b/lib/commons-compress-1.19.jar new file mode 100644 index 0000000..5c9f52a Binary files /dev/null and b/lib/commons-compress-1.19.jar differ diff --git a/lib/commons-lang3-3.9.jar b/lib/commons-lang3-3.9.jar new file mode 100644 index 0000000..0d89693 Binary files /dev/null and b/lib/commons-lang3-3.9.jar differ diff --git a/lib/commons-logging-1.2.jar b/lib/commons-logging-1.2.jar new file mode 100644 index 0000000..93a3b9f Binary files /dev/null and b/lib/commons-logging-1.2.jar differ diff --git a/lib/commons-math3-3.6.1.jar b/lib/commons-math3-3.6.1.jar new file mode 100644 index 0000000..0ff582c Binary files /dev/null and b/lib/commons-math3-3.6.1.jar differ diff --git a/lib/datepicker.jar b/lib/datepicker.jar new file mode 100644 index 0000000..8304d36 Binary files /dev/null and b/lib/datepicker.jar differ diff --git a/lib/fastjson-1.2.83.jar b/lib/fastjson-1.2.83.jar new file mode 100644 index 0000000..fd843ae Binary files /dev/null and b/lib/fastjson-1.2.83.jar differ diff --git a/lib/jaxb-api-2.3.1.jar b/lib/jaxb-api-2.3.1.jar new file mode 100644 index 0000000..4565865 Binary files /dev/null and b/lib/jaxb-api-2.3.1.jar differ diff --git a/lib/jaxb-core-2.3.0.1.jar b/lib/jaxb-core-2.3.0.1.jar new file mode 100644 index 0000000..431e143 Binary files /dev/null and b/lib/jaxb-core-2.3.0.1.jar differ diff --git a/lib/jaxb-impl-2.3.2.jar b/lib/jaxb-impl-2.3.2.jar new file mode 100644 index 0000000..58035e8 Binary files /dev/null and b/lib/jaxb-impl-2.3.2.jar differ diff --git a/lib/jaxen-1.1.6.jar b/lib/jaxen-1.1.6.jar new file mode 100644 index 0000000..52f47a4 Binary files /dev/null and b/lib/jaxen-1.1.6.jar differ diff --git a/lib/jdom-2.0.6-contrib.jar b/lib/jdom-2.0.6-contrib.jar new file mode 100644 index 0000000..78fa2c8 Binary files /dev/null and b/lib/jdom-2.0.6-contrib.jar differ diff --git a/lib/jdom-2.0.6-javadoc.jar b/lib/jdom-2.0.6-javadoc.jar new file mode 100644 index 0000000..1b10787 Binary files /dev/null and b/lib/jdom-2.0.6-javadoc.jar differ diff --git a/lib/jdom-2.0.6-junit.jar b/lib/jdom-2.0.6-junit.jar new file mode 100644 index 0000000..08ff33c Binary files /dev/null and b/lib/jdom-2.0.6-junit.jar differ diff --git a/lib/jdom-2.0.6-sources.jar b/lib/jdom-2.0.6-sources.jar new file mode 100644 index 0000000..afeb101 Binary files /dev/null and b/lib/jdom-2.0.6-sources.jar differ diff --git a/lib/jdom-2.0.6.jar b/lib/jdom-2.0.6.jar new file mode 100644 index 0000000..2850ca1 Binary files /dev/null and b/lib/jdom-2.0.6.jar differ diff --git a/lib/jfxrt.jar b/lib/jfxrt.jar new file mode 100644 index 0000000..49b7d90 Binary files /dev/null and b/lib/jfxrt.jar differ diff --git a/lib/ojdbc6.jar b/lib/ojdbc6.jar new file mode 100644 index 0000000..ec3d6f1 Binary files /dev/null and b/lib/ojdbc6.jar differ diff --git a/lib/poi-3.5.jar b/lib/poi-3.5.jar new file mode 100644 index 0000000..6418222 Binary files /dev/null and b/lib/poi-3.5.jar differ diff --git a/lib/poi-examples-4.1.1.jar b/lib/poi-examples-4.1.1.jar new file mode 100644 index 0000000..334db49 Binary files /dev/null and b/lib/poi-examples-4.1.1.jar differ diff --git a/lib/poi-excelant-4.1.1.jar b/lib/poi-excelant-4.1.1.jar new file mode 100644 index 0000000..f0eb13a Binary files /dev/null and b/lib/poi-excelant-4.1.1.jar differ diff --git a/lib/poi-ooxml-4.1.1.jar b/lib/poi-ooxml-4.1.1.jar new file mode 100644 index 0000000..bf3569d Binary files /dev/null and b/lib/poi-ooxml-4.1.1.jar differ diff --git a/lib/poi-ooxml-schemas-4.1.1.jar b/lib/poi-ooxml-schemas-4.1.1.jar new file mode 100644 index 0000000..d4d0292 Binary files /dev/null and b/lib/poi-ooxml-schemas-4.1.1.jar differ diff --git a/lib/poi-scratchpad-4.1.1.jar b/lib/poi-scratchpad-4.1.1.jar new file mode 100644 index 0000000..1b6a94f Binary files /dev/null and b/lib/poi-scratchpad-4.1.1.jar differ diff --git a/lib/serializer-2.7.2.jar b/lib/serializer-2.7.2.jar new file mode 100644 index 0000000..10c881c Binary files /dev/null and b/lib/serializer-2.7.2.jar differ diff --git a/lib/sqljdbc4.jar b/lib/sqljdbc4.jar new file mode 100644 index 0000000..b73ace0 Binary files /dev/null and b/lib/sqljdbc4.jar differ diff --git a/lib/swt-win32-win32-x86_64-3.5.2.jar b/lib/swt-win32-win32-x86_64-3.5.2.jar new file mode 100644 index 0000000..617bc16 Binary files /dev/null and b/lib/swt-win32-win32-x86_64-3.5.2.jar differ diff --git a/lib/xalan-2.7.2.jar b/lib/xalan-2.7.2.jar new file mode 100644 index 0000000..abdabe3 Binary files /dev/null and b/lib/xalan-2.7.2.jar differ diff --git a/lib/xercesImpl.jar b/lib/xercesImpl.jar new file mode 100644 index 0000000..0aaa990 Binary files /dev/null and b/lib/xercesImpl.jar differ diff --git a/lib/xml-apis.jar b/lib/xml-apis.jar new file mode 100644 index 0000000..4673346 Binary files /dev/null and b/lib/xml-apis.jar differ diff --git a/lib/xmlbeans-3.1.0.jar b/lib/xmlbeans-3.1.0.jar new file mode 100644 index 0000000..18e568f Binary files /dev/null and b/lib/xmlbeans-3.1.0.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..444c983 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/caxaviews/Activator.java b/src/com/caxaviews/Activator.java new file mode 100644 index 0000000..6d00c62 --- /dev/null +++ b/src/com/caxaviews/Activator.java @@ -0,0 +1,23 @@ +package com.caxaviews; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +public class Activator extends AbstractUIPlugin { + public static final String PLUGIN_ID = "com.caxaviews"; + private static Activator plugin; + + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + public static Activator getDefault() { + return plugin; + } +} diff --git a/src/com/caxaviews/PositionOfMouse.java b/src/com/caxaviews/PositionOfMouse.java new file mode 100644 index 0000000..5400ac0 --- /dev/null +++ b/src/com/caxaviews/PositionOfMouse.java @@ -0,0 +1,36 @@ +package com.caxaviews; + +import java.awt.FlowLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class PositionOfMouse extends JFrame { + private JLabel label; + + public PositionOfMouse() { + super("Գ"); + this.setSize(400, 300); + this.setVisible(true); + this.setLayout(new FlowLayout(1)); + this.setDefaultCloseOperation(3); + final JLabel label = new JLabel("˴ʾҼ"); + this.add(label); + this.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getButton() == 3) { + int x = e.getX(); + int y = e.getY(); + String banner = "굱ǰλõ" + x + "," + y; + label.setText(banner); + } + + } + }); + } + + public static void main(String[] args) { + new PositionOfMouse(); + } +} diff --git a/src/com/caxaviews/create/createDataset.java b/src/com/caxaviews/create/createDataset.java new file mode 100644 index 0000000..388a9cf --- /dev/null +++ b/src/com/caxaviews/create/createDataset.java @@ -0,0 +1,125 @@ +package com.caxaviews.create; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinition; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +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 java.io.File; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +public class createDataset extends AbstractHandler { + public Object execute(ExecutionEvent event) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent sel = AIFUtility.getTargetComponent(); + TCSession session = (TCSession)app.getSession(); + if (!(sel instanceof TCComponentItemRevision)) { + MessageBox.post("ѡ汾в", "", 1); + return null; + } else { + try { + TCComponentItemType itemType = (TCComponentItemType)session.getTypeComponent("Item"); + TCComponentItem item = itemType.find("000583"); + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + AIFComponentContext[] children = itemRevision.getChildren(); + TCComponentDataset dataset = null; + + for(int i = 0; i < children.length; ++i) { + if (children[i].getComponent() instanceof TCComponentDataset) { + dataset = (TCComponentDataset)children[i].getComponent(); + break; + } + } + + if (dataset == null) { + MessageBox.post("ģļδҵ", "", 1); + return null; + } + + TCComponentItemRevision rev = (TCComponentItemRevision)sel; + String localDirName = System.getProperty("java.io.tmpdir"); + File file = DatasetFileToLocalDir(dataset, localDirName, rev); + File newFile = new File(file.getParent() + File.separator + rev.getItem().getProperty("item_id") + ".exb"); + file.renameTo(newFile); + TCComponentDatasetType datasetType = (TCComponentDatasetType)session.getTypeComponent("U2_EXB"); + String[] filepath = new String[]{newFile.getAbsolutePath()}; + String[] namedReferences = new String[]{"U2_EXB"}; + TCComponentDataset dataset2 = datasetType.setFiles(rev.getProperty("current_id") + "_" + rev.getProperty("item_revision_id"), "desc", "U2_EXB", filepath, namedReferences); + rev.add("IMAN_specification", dataset2); + } catch (Exception var18) { + var18.printStackTrace(); + MessageBox.post(var18.getLocalizedMessage(), "", 1); + } + + return null; + } + } + + public static File DatasetFileToLocalDir(TCComponentDataset componentDataset, String localDirName, TCComponentItemRevision rev) { + File dirObject = new File(localDirName); + if (!dirObject.exists()) { + dirObject.mkdirs(); + } + + if (componentDataset == null) { + return null; + } else { + try { + componentDataset = componentDataset.latest(); + TCComponentDatasetDefinition Defin = componentDataset.getDatasetDefinitionComponent(); + String namedRefName = Defin.getNamedReferences()[0]; + String[] namedRefFileName = componentDataset.getFileNames(namedRefName); + if (namedRefFileName != null && namedRefFileName.length != 0) { + File tempFileObject = new File(localDirName, namedRefFileName[0]); + if (tempFileObject.exists()) { + tempFileObject.delete(); + } + + File tempFile = componentDataset.getFile(namedRefName, namedRefFileName[0], localDirName); + String DatasetName = componentDataset.getProperty("object_name"); + String PathName = tempFile.getPath(); + String ExtendName = PathName.substring(PathName.lastIndexOf("."), PathName.length()); + String DownloadFileName = ""; + if (DatasetName.toLowerCase().endsWith(ExtendName.toLowerCase())) { + DownloadFileName = DatasetName; + } else { + DownloadFileName = DatasetName + ExtendName; + } + + File objectFile = new File(localDirName, DownloadFileName); + if (!objectFile.getName().equals(tempFile.getName())) { + if (objectFile.exists()) { + objectFile.delete(); + } + + tempFile.renameTo(objectFile); + } else { + objectFile = tempFile; + } + + return objectFile; + } else { + MessageBox.post("ݼûжӦ!", "ϵͳô", 1); + return null; + } + } catch (TCException var14) { + var14.printStackTrace(); + MessageBox.post("ݼô!", "ϵͳô", 1); + return null; + } catch (Exception var15) { + MessageBox.post("ݼ!", "ϵͳô", 1); + return null; + } + } + } +} diff --git a/src/com/caxaviews/exportdataset.zip b/src/com/caxaviews/exportdataset.zip new file mode 100644 index 0000000..a394426 Binary files /dev/null and b/src/com/caxaviews/exportdataset.zip differ diff --git a/src/com/caxaviews/exportdataset/BOMLineDatasetStruct.java b/src/com/caxaviews/exportdataset/BOMLineDatasetStruct.java new file mode 100644 index 0000000..ea20dd0 --- /dev/null +++ b/src/com/caxaviews/exportdataset/BOMLineDatasetStruct.java @@ -0,0 +1,14 @@ +package com.caxaviews.exportdataset; + +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; + +public class BOMLineDatasetStruct { + public TCComponentDataset Dataset = null; + public TCComponentBOMLine BOMLine = null; + + public BOMLineDatasetStruct(TCComponentDataset Dataset, TCComponentBOMLine BOMLine) { + this.Dataset = Dataset; + this.BOMLine = BOMLine; + } +} diff --git a/src/com/caxaviews/exportdataset/BatchExportDrawings.java b/src/com/caxaviews/exportdataset/BatchExportDrawings.java new file mode 100644 index 0000000..6e498eb --- /dev/null +++ b/src/com/caxaviews/exportdataset/BatchExportDrawings.java @@ -0,0 +1,419 @@ +package com.caxaviews.exportdataset; + +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.lang.reflect.InvocationTargetException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class BatchExportDrawings extends AbstractHandler { + String ExportFolderPath = null; + String FolderName = null; + private TCComponentBOMLine selectedBOMLine = null; + boolean ExportAll = false; + ArrayList DataseStructtArray = new ArrayList(); + String TemplateFileName = null; + TCComponentItemType ItemType = null; + private TCSession session = null; + int StartLine = 6; + int CurrentLine; + int AppendLine; + int pages; + int k; + + public BatchExportDrawings() { + this.CurrentLine = this.StartLine; + this.AppendLine = 43; + this.pages = 1; + this.k = 1; + } + + public Object execute(ExecutionEvent e) throws ExecutionException { + InterfaceAIFComponent[] AIFComp = AIFUtility.getTargetComponents(); + if (AIFComp == null) { + MessageBox.post("ûѡBOMУ", "ʾ", 4); + return null; + } else if (AIFComp.length == 0) { + MessageBox.post("ѡһBOMУ", "ʾ", 4); + return null; + } else { + List bomLines = new ArrayList(); + + for(int i = 0; i < AIFComp.length; ++i) { + if (!(AIFComp[i] instanceof TCComponentBOMLine)) { + MessageBox.post("ѡĶаBOMжѡ", "ʾ", 1); + return null; + } + + bomLines.add((TCComponentBOMLine)AIFComp[i]); + } + + Shell shell = Display.getCurrent().getActiveShell(); + org.eclipse.swt.widgets.MessageBox messageBox = new org.eclipse.swt.widgets.MessageBox(shell, 194); + messageBox.setMessage(":ȫͼֽ\n:ȡ"); + messageBox.setText("ʾ"); + int Result = messageBox.open(); + if (Result == 64) { + this.ExportAll = true; + } + + if (Result == 128) { + return null; + } else { + this.DataseStructtArray.clear(); + + for(int i = 0; i < bomLines.size(); ++i) { + this.selectedBOMLine = (TCComponentBOMLine)bomLines.get(i); + this.CollectTool(this.selectedBOMLine); + } + + if (this.DataseStructtArray.size() == 0) { + MessageBox.post("ûҵҪͼֽ", "ʾ", 4); + return null; + } else { + try { + DirectoryDialog dlg = new DirectoryDialog(shell, 8192); + String path = readTxt(); + dlg.setFilterPath(path); + this.ExportFolderPath = dlg.open(); + System.out.println(this.ExportFolderPath); + writerTxt(this.ExportFolderPath); + if (this.ExportFolderPath == null) { + return null; + } + + this.FolderName = this.selectedBOMLine.getProperty("bl_item_item_id") + "_" + this.selectedBOMLine.getProperty("bl_rev_item_revision_id"); + String FolderPath = this.ExportFolderPath + "\\" + this.FolderName; + if (this.ExportAll) { + System.out.println(FolderPath); + } + + File Folder = new File(FolderPath); + if (!Folder.exists()) { + Folder.mkdir(); + } + + if (!Folder.exists()) { + MessageBox.post(Folder.getParent() + "", "ʾ", 4); + return null; + } + + String TemplatePath = ReportCommon.GetPreference("UDS_Report_Templates_Path"); + this.TemplateFileName = TemplatePath + "\\DrawingListReport.xls"; + File templateFile = new File(this.TemplateFileName); + if (!templateFile.exists()) { + MessageBox.post("ģļ" + this.TemplateFileName + "ڣڹԱϵ", "ʾ", 4); + return null; + } + + System.out.println("TemplateFileName:" + this.TemplateFileName); + Collections.sort(this.DataseStructtArray, new BatchExportDrawings.SortContext()); + + try { + IRunnableWithProgress runnable = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask("ڵݼ", BatchExportDrawings.this.DataseStructtArray.size()); + BatchExportDrawings.this.ExportDataset(monitor, BatchExportDrawings.this.ExportFolderPath, BatchExportDrawings.this.FolderName); + monitor.done(); + } + }; + (new ProgressMonitorDialog(shell)).run(true, true, runnable); + } catch (Exception var14) { + var14.printStackTrace(); + } + } catch (Exception var15) { + var15.printStackTrace(); + } + + return null; + } + } + } + } + + void ExportDataset(IProgressMonitor monitor, String ExportFolderPath, String FolderName) { + String FolderPath = ExportFolderPath + "\\" + FolderName; + if (this.ExportAll) { + System.out.println("FolderPath:" + FolderPath); + } + + try { + FileInputStream fileInputStream = new FileInputStream(this.TemplateFileName); + POIFSFileSystem fs = new POIFSFileSystem(fileInputStream); + HSSFWorkbook wb = new HSSFWorkbook(fs); + HSSFSheet sheet = wb.getSheetAt(0); + this.StartLine = 6; + this.CurrentLine = this.StartLine; + this.AppendLine = 43; + this.pages = (int)Math.ceil((double)(this.DataseStructtArray.size() / 38)) + 1; + this.k = 1; + String DrawingListNo = this.selectedBOMLine.getProperty("bl_item_item_id") + "/" + this.selectedBOMLine.getItemRevision().getProperty("item_revision_id") + "-TM"; + HSSFCell Cell = ReportCommon.GetCell(sheet, "J44"); + ReportCommon.WbFillCell(Cell, DrawingListNo); + String time = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date()); + Cell = ReportCommon.GetCell(sheet, "J46"); + ReportCommon.WbFillCell(Cell, time); + ReportCommon.createMultiPages(this.pages, sheet, 47); + int j = 0; + ArrayList HasWrite2Excle = new ArrayList(); + + for(int i = 0; i < this.DataseStructtArray.size(); ++i) { + BOMLineDatasetStruct ds = (BOMLineDatasetStruct)this.DataseStructtArray.get(i); + System.out.println(ds.Dataset.toString() + " Downing..."); + if (!HasExsit(HasWrite2Excle, ds.BOMLine.getItemRevision())) { + this.WriteSaiTuList(ds, sheet); + HasWrite2Excle.add(ds.BOMLine.getItemRevision()); + } + + if (this.ExportAll) { + TCComponentDataset dataset = null; + dataset = ds.Dataset; + ReportCommon.DatasetFileToLocalDir(dataset, FolderPath); + } + + monitor.worked(1); + monitor.setTaskName("ڵݼ"); + j = i + 1; + monitor.subTask("ǰȡ" + j + ""); + } + + String outputFileName = FolderPath + "\\ͼֽ嵥.xls"; + FileOutputStream out = new FileOutputStream(outputFileName); + wb.write(out); + out.close(); + fileInputStream.close(); + MessageBox.post("ɣ" + String.valueOf(j) + "!", "ʾ", 2); + } catch (Exception var17) { + var17.printStackTrace(); + } + + } + + void WriteSaiTuList(BOMLineDatasetStruct ds, HSSFSheet sheet) { + try { + TCComponentItemRevision ItemRev = ds.BOMLine.getItemRevision(); + if (this.k <= this.pages && this.CurrentLine > this.AppendLine) { + this.CurrentLine = 47 * this.k + 6; + this.AppendLine = 47 * this.k + 38; + this.StartLine = 6 * (this.k + 1) + 4 * this.k; + ++this.k; + } + + String Rev = ItemRev.getProperty("item_revision_id"); + String TuHao = ItemRev.getProperty("item_id") + "/" + Rev; + HSSFCell Cell = ReportCommon.GetCell(sheet, "A" + String.valueOf(this.CurrentLine)); + ReportCommon.WbFillCell(Cell, String.valueOf(this.CurrentLine - this.StartLine + this.k)); + Cell = ReportCommon.GetCell(sheet, "B" + String.valueOf(this.CurrentLine)); + ReportCommon.WbFillCell(Cell, TuHao); + Cell = ReportCommon.GetCell(sheet, "D" + String.valueOf(this.CurrentLine)); + ReportCommon.WbFillCell(Cell, ds.BOMLine.getProperty("u2_groupNo")); + Cell = ReportCommon.GetCell(sheet, "E" + String.valueOf(this.CurrentLine)); + ReportCommon.WbFillCell(Cell, ds.BOMLine.getProperty("bl_rev_object_name")); + Cell = ReportCommon.GetCell(sheet, "H" + String.valueOf(this.CurrentLine)); + ReportCommon.WbFillCell(Cell, ds.BOMLine.getProperty("u2_originalNo")); + Cell = ReportCommon.GetCell(sheet, "F" + String.valueOf(this.CurrentLine)); + ReportCommon.WbFillCell(Cell, ds.BOMLine.getProperty("u2_pages")); + Cell = ReportCommon.GetCell(sheet, "K" + String.valueOf(this.CurrentLine)); + ReportCommon.WbFillCell(Cell, ds.BOMLine.getProperty("u2_drawingSize")); + ++this.CurrentLine; + } catch (Exception var7) { + var7.printStackTrace(); + } + + } + + void CollectTool(TCComponentBOMLine parentLine) { + try { + this.CheckTIF(parentLine); + } catch (Exception var3) { + var3.printStackTrace(); + } + + } + + void CheckTIF(TCComponentBOMLine bomline) { + try { + TCComponentItemRevision ItemRev = bomline.getItemRevision(); + TCComponent[] Datasets = ItemRev.getRelatedComponents("IMAN_specification"); + + for(int i = 0; i < Datasets.length; ++i) { + String Type = Datasets[i].getProperty("object_type"); + if ((Type.equals("Ŀͼֽ") || Type.equals("PDF") || Type.equals("MSExcel") || Type.equals("CAXAͼֽ") || Type.equals("AutoCADͼֽ")) && !HasExsit(this.DataseStructtArray, (TCComponentDataset)Datasets[i])) { + BOMLineDatasetStruct ds = new BOMLineDatasetStruct((TCComponentDataset)Datasets[i], bomline); + this.DataseStructtArray.add(ds); + } + } + } catch (Exception var7) { + var7.printStackTrace(); + } + + } + + public static boolean HasExsit(ArrayList DataseStructtArray, TCComponentDataset dataset) { + for(int i = 0; i < DataseStructtArray.size(); ++i) { + try { + BOMLineDatasetStruct ds = (BOMLineDatasetStruct)DataseStructtArray.get(i); + if (ds.Dataset.getUid().equals(dataset.getUid())) { + return true; + } + } catch (Exception var4) { + var4.printStackTrace(); + } + } + + return false; + } + + public static boolean HasExsit(ArrayList RevArray, TCComponentItemRevision Rev) { + for(int i = 0; i < RevArray.size(); ++i) { + try { + if (((TCComponentItemRevision)RevArray.get(i)).getProperty("item_id").equals(Rev.getProperty("item_id"))) { + return true; + } + } catch (Exception var4) { + var4.printStackTrace(); + } + } + + return false; + } + + int GetLevel(TCComponentBOMLine parentLine) { + int Level = 0; + + try { + while((parentLine = parentLine.parent()) != null) { + ++Level; + } + + return Level; + } catch (Exception var4) { + var4.printStackTrace(); + return 0; + } + } + + public static void writerTxt(String ExportFolderPath) { + BufferedWriter fw = null; + + try { + Shannom shannom = new Shannom(); + String path = shannom.path(); + String userName = shannom.currentUser(); + String filePath = path + userName + ".txt"; + File file = new File(filePath); + if (!file.exists()) { + file.createNewFile(); + } + + fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, false), "UTF-8")); + fw.append(ExportFolderPath); + fw.flush(); + } catch (Exception var15) { + var15.printStackTrace(); + } finally { + if (fw != null) { + try { + fw.close(); + } catch (IOException var14) { + var14.printStackTrace(); + } + } + + } + + } + + public static String readTxt() { + Shannom shannom = new Shannom(); + String path = shannom.path(); + String userName = shannom.currentUser(); + String filePath = path + userName + ".txt"; + String str = null; + BufferedReader reader = null; + + String var8; + try { + File file = new File(filePath); + if (!file.exists()) { + file.createNewFile(); + } + + reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8")); + if ((str = reader.readLine()) == null) { + return str; + } + + var8 = str; + } catch (FileNotFoundException var19) { + var19.printStackTrace(); + return str; + } catch (IOException var20) { + var20.printStackTrace(); + return str; + } finally { + try { + reader.close(); + } catch (IOException var18) { + var18.printStackTrace(); + } + + } + + return var8; + } + + class SortContext implements Comparator { + public int compare(Object a, Object b) { + try { + BOMLineDatasetStruct ds1 = (BOMLineDatasetStruct)a; + BOMLineDatasetStruct ds2 = (BOMLineDatasetStruct)b; + String Size1 = ds1.BOMLine.getItemRevision().getProperty("u2_drawingSize"); + String Size2 = ds2.BOMLine.getItemRevision().getProperty("u2_drawingSize"); + if (Size1.equals(Size2)) { + String id1 = ds1.BOMLine.getProperty("bl_item_item_id"); + String id2 = ds2.BOMLine.getProperty("bl_item_item_id"); + return id1.compareTo(id2); + } else { + return Size1.compareTo(Size2); + } + } catch (Exception var9) { + var9.printStackTrace(); + return 0; + } + } + } +} diff --git a/src/com/caxaviews/exportdataset/OneLineExcel.java b/src/com/caxaviews/exportdataset/OneLineExcel.java new file mode 100644 index 0000000..8f12205 --- /dev/null +++ b/src/com/caxaviews/exportdataset/OneLineExcel.java @@ -0,0 +1,37 @@ +package com.caxaviews.exportdataset; + +import com.teamcenter.rac.kernel.TCComponentBOMLine; + +public class OneLineExcel { + public String no; + public String level; + public String pos; + public String itemNo; + public String name; + public String origNo; + public String quantity; + public String material; + public String weight; + public String drawingNo; + public String square; + public String modsymbol; + public String remarks; + public TCComponentBOMLine bomline; + + public OneLineExcel(TCComponentBOMLine bomline, String no, String level, String pos, String itemNo, String name, String origNo, String quantity, String material, String weight, String drawingNo, String square, String modsymbol, String remarks) { + this.bomline = bomline; + this.no = no; + this.level = level; + this.pos = pos; + this.itemNo = itemNo; + this.name = name; + this.origNo = origNo; + this.quantity = quantity; + this.material = material; + this.weight = weight; + this.drawingNo = drawingNo; + this.square = square; + this.modsymbol = modsymbol; + this.remarks = remarks; + } +} diff --git a/src/com/caxaviews/exportdataset/PreConfig.java b/src/com/caxaviews/exportdataset/PreConfig.java new file mode 100644 index 0000000..7a410db --- /dev/null +++ b/src/com/caxaviews/exportdataset/PreConfig.java @@ -0,0 +1,13 @@ +package com.caxaviews.exportdataset; + +public class PreConfig { + public String Pos; + public String Type; + public String Value; + + public PreConfig(String Pos, String Type, String Value) { + this.Pos = Pos; + this.Type = Type; + this.Value = Value; + } +} diff --git a/src/com/caxaviews/exportdataset/QueryConditionDlg.java b/src/com/caxaviews/exportdataset/QueryConditionDlg.java new file mode 100644 index 0000000..a15ef16 --- /dev/null +++ b/src/com/caxaviews/exportdataset/QueryConditionDlg.java @@ -0,0 +1,60 @@ +package com.caxaviews.exportdataset; + +import com.teamcenter.rac.util.HorizontalLayout; +import com.teamcenter.rac.util.VerticalLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +public class QueryConditionDlg extends JDialog { + public ArrayList ValueFieldAry = new ArrayList(); + public boolean ISCancel = false; + + public QueryConditionDlg(String[] Names, String[] Values) { + this.ValueFieldAry.clear(); + JPanel ConditionPanel = new JPanel(new VerticalLayout()); + + for(int i = 0; i < Names.length; ++i) { + JPanel LabsPanel = new JPanel(new HorizontalLayout()); + JPanel TxtsPanel = new JPanel(new HorizontalLayout()); + JLabel lab = new JLabel(Names[i]); + JTextField txt = new JTextField(20); + txt.setText(Values[i]); + this.ValueFieldAry.add(txt); + LabsPanel.add("top.bind", lab); + TxtsPanel.add("top.bind", txt); + ConditionPanel.add("left", LabsPanel); + ConditionPanel.add("right", TxtsPanel); + } + + JPanel pane3 = new JPanel(); + JButton btnOK = new JButton("ȷ"); + pane3.add(btnOK); + btnOK.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + QueryConditionDlg.this.dispose(); + } + }); + JButton btnCancel = new JButton("ȡ"); + pane3.add(btnCancel); + btnCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + QueryConditionDlg.this.ISCancel = true; + QueryConditionDlg.this.dispose(); + } + }); + this.setLayout(new VerticalLayout()); + this.add("top", ConditionPanel); + this.add("bottom", pane3); + this.setTitle("òѯ"); + this.setLocation(450, 300); + this.setModal(true); + this.setAlwaysOnTop(true); + this.pack(); + } +} diff --git a/src/com/caxaviews/exportdataset/ReportCommon.java b/src/com/caxaviews/exportdataset/ReportCommon.java new file mode 100644 index 0000000..03d1c18 --- /dev/null +++ b/src/com/caxaviews/exportdataset/ReportCommon.java @@ -0,0 +1,1976 @@ +package com.caxaviews.exportdataset; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.AEShell; +import com.teamcenter.rac.kernel.AEShellManager; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMViewRevision; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinition; +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.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRevisionRule; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCQueryClause; +import com.teamcenter.rac.kernel.TCReservationService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTaskState; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; +import java.io.File; +import java.io.FileOutputStream; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFHeader; +import org.apache.poi.hssf.usermodel.HSSFPrintSetup; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.Region; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class ReportCommon { + public static synchronized boolean datasetFileToLocalDir(TCSession imanSession, String datasetType, String datasetName, String namedRefName, String localFileName, String localDirName) { + File fileObject = null; + File dirObject = new File(localDirName); + if (!dirObject.exists()) { + dirObject.mkdirs(); + } + + TCComponentDataset componentDataset = findDatasetByName(imanSession, datasetType, datasetName); + if (componentDataset == null) { + MessageBox.post("ݼ<" + datasetName + ">ûҵ!", "ϵͳô", 1); + return false; + } else { + File tempFileObject; + try { + componentDataset = componentDataset.latest(); + String[] namedRefFileName = componentDataset.getFileNames(namedRefName); + if (namedRefFileName == null || namedRefFileName.length == 0) { + MessageBox.post("ݼ<" + datasetName + ">ûжӦ!", "ϵͳô", 1); + return false; + } + + tempFileObject = new File(localDirName, namedRefFileName[0]); + if (tempFileObject.exists()) { + tempFileObject.delete(); + } + + fileObject = componentDataset.getFile(namedRefName, namedRefFileName[0], localDirName); + } catch (TCException var11) { + System.out.print("ݼ<" + datasetName + ">ô!\n"); + return false; + } + + tempFileObject = new File(localDirName, localFileName); + if (!fileObject.getAbsolutePath().toUpperCase().equals(tempFileObject.getAbsolutePath().toUpperCase())) { + if (tempFileObject.exists()) { + tempFileObject.delete(); + } + + fileObject.renameTo(tempFileObject); + } + + return true; + } + } + + public static TCComponentDataset findDatasetByName(TCSession imanSession, String datasetType, String datasetName) { + try { + if (datasetName != null) { + TCTypeService typeService = imanSession.getTypeService(); + TCComponentDatasetType imanDatasetType = (TCComponentDatasetType)typeService.getTypeComponent(datasetType); + TCComponentDataset[] imanComponentAllDataset = imanDatasetType.findAll(datasetName); + + for(int i = 0; i < imanComponentAllDataset.length; ++i) { + if (imanComponentAllDataset[i].getProperty("object_type").equals(datasetType) && imanComponentAllDataset[i].getProperty("last_mod_user").compareTo("infodba") == 0 && imanComponentAllDataset[i].getProperty("object_string").compareTo(datasetName) == 0) { + return imanComponentAllDataset[i]; + } + } + } + + return null; + } catch (TCException var7) { + System.out.print("ݼ<" + datasetType + ">!"); + return null; + } + } + + public static TCComponentDataset findDatasetByName(TCSession imanSession, String datasetType, String datasetName, String Desc) { + try { + if (datasetName != null) { + TCTypeService typeService = imanSession.getTypeService(); + TCComponentDatasetType imanDatasetType = (TCComponentDatasetType)typeService.getTypeComponent(datasetType); + TCComponentDataset[] imanComponentAllDataset = imanDatasetType.findAll(datasetName); + + for(int i = 0; i < imanComponentAllDataset.length; ++i) { + if (imanComponentAllDataset[i].getProperty("object_type").equals(datasetType) && imanComponentAllDataset[i].getProperty("last_mod_user").compareTo("infodba") == 0 && imanComponentAllDataset[i].getProperty("object_string").compareTo(datasetName) == 0 && imanComponentAllDataset[i].getProperty("object_desc").equals("Template")) { + return imanComponentAllDataset[i]; + } + } + } + + return null; + } catch (TCException var8) { + System.out.print("ݼ<" + datasetType + ">!"); + return null; + } + } + + public static void DatasetFileToLocalDir(TCComponentDataset componentDataset, String localDirName) { + File dirObject = new File(localDirName); + if (!dirObject.exists()) { + dirObject.mkdirs(); + } + + if (componentDataset != null) { + try { + componentDataset = componentDataset.latest(); + TCComponentDatasetDefinition Defin = componentDataset.getDatasetDefinitionComponent(); + String namedRefName = Defin.getNamedReferences()[0]; + String[] namedRefFileName = componentDataset.getFileNames(namedRefName); + if (namedRefFileName == null || namedRefFileName.length == 0) { + MessageBox.post("ݼûжӦ!", "ϵͳô", 1); + return; + } + + for(int i = 0; i < namedRefFileName.length; ++i) { + File tempFileObject = new File(localDirName, namedRefFileName[i]); + if (tempFileObject.exists()) { + tempFileObject.delete(); + } + + File tempFile = componentDataset.getFile(namedRefName, namedRefFileName[i], localDirName); + String DatasetName = namedRefFileName[i]; + String PathName = tempFile.getPath(); + PathName.substring(PathName.lastIndexOf("."), PathName.length()); + String FileName = DatasetName.replaceAll("/", "_"); + File objectFile = new File(localDirName, FileName); + if (!objectFile.getName().equals(tempFile.getName())) { + if (objectFile.exists()) { + objectFile.delete(); + } + + tempFile.renameTo(objectFile); + } + } + } catch (TCException var13) { + MessageBox.post("ݼô!", "ϵͳô", 1); + } + + } + } + + public static boolean TDatasetFileToLocalDir(TCComponentDataset componentDataset, String namedRefName, String localFileName, String localDirName) { + File dirObject = new File(localDirName); + if (!dirObject.exists()) { + dirObject.mkdirs(); + } + + if (componentDataset == null) { + return false; + } else { + try { + componentDataset = componentDataset.latest(); + String[] namedRefFileName = componentDataset.getFileNames(namedRefName); + if (namedRefFileName != null && namedRefFileName.length != 0) { + File tempFileObject = new File(localDirName, namedRefFileName[0]); + if (tempFileObject.exists()) { + tempFileObject.delete(); + } + + File tempFile = componentDataset.getFile(namedRefName, namedRefFileName[0], localDirName); + File newFile; + if (localFileName.endsWith("dft")) { + newFile = new File(localDirName + "\\" + localFileName); + tempFile.renameTo(newFile); + } else { + newFile = new File(localDirName + localFileName + ".xls"); + tempFile.renameTo(newFile); + } + + return true; + } else { + MessageBox.post("ݼûжӦ!", "ϵͳô", 1); + return false; + } + } catch (TCException var9) { + MessageBox.post("ݼô!", "ϵͳô", 1); + return false; + } + } + } + + public static String RemoveZero(String str) { + String Temp = str; + + for(int i = 0; i < Temp.length(); ++i) { + if ((Temp.charAt(i) > '9' || Temp.charAt(i) < '0') && Temp.charAt(i) != '.') { + return str; + } + } + + if (Temp.indexOf(".") > 0) { + while(Temp.endsWith("0")) { + Temp = Temp.substring(0, Temp.length() - 1); + } + + if (Temp.endsWith(".")) { + Temp = Temp.substring(0, Temp.length() - 1); + } + } + + return Temp; + } + + public static void WbFillCell1(HSSFSheet DestSheet, HSSFCell cell, String str) { + try { + if (str.compareTo("") == 0) { + return; + } + + if (cell != null) { + cell.setCellValue(str); + } + } catch (Exception var4) { + var4.printStackTrace(); + } + + } + + public static void WbFillCell(HSSFCell cell, String str) { + try { + cell.setCellValue(str); + } catch (Exception var3) { + var3.printStackTrace(); + } + + } + + public static String GetSheetNameFormSheet(HSSFWorkbook wb, HSSFSheet DestSheet) { + for(int m = 0; m < wb.getNumberOfSheets(); ++m) { + if (wb.getSheetAt(m) == DestSheet) { + return wb.getSheetName(m); + } + } + + return ""; + } + + public static void ChangeCellStyle(HSSFWorkbook destwb, HSSFCell DestCell, short color) { + if (DestCell != null) { + HSSFCellStyle newStyle = destwb.createCellStyle(); + HSSFCellStyle oldStyle = DestCell.getCellStyle(); + HSSFFont newfont = destwb.createFont(); + if (oldStyle != null) { + HSSFFont oldfont = destwb.getFontAt(oldStyle.getFontIndex()); + if (oldfont.getColor() == 9) { + return; + } + + newfont.setFontName(oldfont.getFontName()); + newfont.setFontHeight(oldfont.getFontHeight()); + newfont.setBoldweight(oldfont.getBoldweight()); + newfont.setFontHeightInPoints(oldfont.getFontHeightInPoints()); + newfont.setItalic(oldfont.getItalic()); + newfont.setUnderline(oldfont.getUnderline()); + newfont.setColor(color); + newStyle.setFont(newfont); + newStyle.setBorderLeft(oldStyle.getBorderLeft()); + newStyle.setBorderBottom(oldStyle.getBorderBottom()); + newStyle.setBorderRight(oldStyle.getBorderRight()); + newStyle.setBorderTop(oldStyle.getBorderTop()); + newStyle.setVerticalAlignment(oldStyle.getVerticalAlignment()); + newStyle.setAlignment(oldStyle.getAlignment()); + newStyle.setWrapText(oldStyle.getWrapText()); + newStyle.setDataFormat(oldStyle.getDataFormat()); + if (color == 8) { + newStyle.setFillForegroundColor((short)10); + newStyle.setFillBackgroundColor((short)10); + newStyle.setFillPattern((short)1); + } + } + + DestCell.setCellStyle(newStyle); + } + + } + + public static int GetCol(String Pos) { + int Col = 0; + String TempPos = GetStr(Pos); + int len = TempPos.length(); + + for(int j = 1; j <= len; ++j) { + Col += (TempPos.charAt(j - 1) - 65 + 1) * (int)Math.pow(26.0D, (double)(len - j)); + } + + --Col; + return Col; + } + + public static String GetCellValue(HSSFCell Cell) { + try { + if (Cell.getCellType() == 1) { + return Cell.getStringCellValue().trim(); + } else { + String temp; + if (Cell.getCellType() == 0) { + temp = String.valueOf(Cell.getNumericCellValue()); + temp = RemoveZero(temp); + return temp; + } else if (Cell.getCellType() == 2) { + temp = Cell.getStringCellValue().trim(); + if (temp.equals("")) { + temp = String.valueOf(Cell.getNumericCellValue()); + } + + temp = RemoveZero(temp); + return temp; + } else { + return ""; + } + } + } catch (Exception var2) { + return ""; + } + } + + public static HSSFCell GetCell(HSSFSheet sheet0, String POS) { + try { + int Col = GetCol(POS); + int Row = Integer.parseInt(GetNum(POS)) - 1; + HSSFRow Sheet0Row = sheet0.getRow(Row); + if (Sheet0Row == null) { + Sheet0Row = sheet0.createRow(Row); + } + + HSSFCell Sheet0Cell = Sheet0Row.getCell(Col); + if (Sheet0Cell == null) { + Sheet0Cell = Sheet0Row.createCell(Col); + } + + return Sheet0Cell; + } catch (Exception var6) { + return null; + } + } + + public static HSSFCell GetCell(HSSFSheet sheet0, int Row, int Col) { + HSSFRow Sheet0Row = sheet0.getRow(Row); + if (Sheet0Row == null) { + Sheet0Row = sheet0.createRow(Row); + } + + HSSFCell Sheet0Cell = Sheet0Row.getCell(Col); + if (Sheet0Cell == null) { + Sheet0Cell = Sheet0Row.createCell(Col); + } + + return Sheet0Cell; + } + + public static String TranslateValue(ReportConfig RCfg, TCComponent comp, String Value) { + String[] Tags = Value.split("%"); + String Result = ""; + + for(int i = 0; i < Tags.length; ++i) { + if ((i + 1) % 2 == 0) { + Tags[i] = GetVariValue(RCfg, comp, Tags[i]); + } + + Result = Result + Tags[i]; + } + + return Result; + } + + public static String GetVariValue(ReportConfig RCfg, TCComponent comp, String VariName) { + PreConfig VariConfig = GetVariConfigValue(RCfg, VariName); + String Result = ""; + if (VariConfig != null) { + String TempStr; + for(TempStr = VariConfig.Value; TempStr.split("%").length > 1; TempStr = TranslateValue(RCfg, comp, TempStr)) { + } + + Result = GetComponentValue(RCfg, comp, VariConfig.Type, TempStr); + } + + return Result; + } + + public static PreConfig GetVariConfigValue(ReportConfig RCfg, String Key) { + for(int i = 0; i < RCfg.VarNameConfig.size(); ++i) { + PreConfig precfg = (PreConfig)RCfg.VarNameConfig.get(i); + if (precfg.Pos.equals(Key)) { + return precfg; + } + } + + return null; + } + + public static String GetStr(String str) { + str = str.toUpperCase(); + int index = 0; + + for(int i = 0; i < str.length(); ++i) { + if (str.charAt(i) - 65 >= 0) { + index = i; + } + } + + return str.substring(0, index + 1); + } + + public static String GetNum(String str) { + str = str.toUpperCase(); + int index = 0; + + for(int i = 0; i < str.length(); ++i) { + if (str.charAt(i) - 65 >= 0) { + index = i; + } + } + + return str.substring(index + 1, str.length()); + } + + public static boolean isNumeric(String str) { + return Pattern.compile("^\\-?\\d+\\.?\\d*$").matcher(str).find(); + } + + public static boolean isAllNumber(String str) { + if (str.length() == 0) { + return false; + } else { + for(int i = 0; i < str.length(); ++i) { + char temp = str.charAt(i); + if (temp > '9' || temp < '0') { + return false; + } + } + + return true; + } + } + + public static TCComponentTask GetTask(TCComponent objectCm) { + try { + AIFComponentContext[] aff = objectCm.whereReferenced(); + + for(int j = 0; j < aff.length; ++j) { + if (aff[j].getComponent() instanceof TCComponentTask) { + ((TCComponentTask)aff[j].getComponent()).getState(); + return (TCComponentTask)aff[j].getComponent(); + } + } + } catch (TCException var3) { + var3.printStackTrace(); + } + + return null; + } + + public static TCComponentPseudoFolder GetTargets(TCComponent objectCm) { + try { + TCComponentPseudoFolder pfReferences = null; + AIFComponentContext[] aff = objectCm.whereReferenced(); + + for(int j = 0; j < aff.length; ++j) { + if (aff[j].getComponent() instanceof TCComponentTask) { + TCTaskState state = ((TCComponentTask)aff[j].getComponent()).getState(); + if (state.getIntValue() == 4) { + AIFComponentContext[] affre = ((TCComponentTask)aff[j].getComponent()).getChildren(); + + for(int ii = 0; ii < affre.length; ++ii) { + if (affre[ii].getComponent() instanceof TCComponentPseudoFolder && affre[ii].getComponent().toString().equals("Targets")) { + pfReferences = (TCComponentPseudoFolder)affre[ii].getComponent(); + return pfReferences; + } + } + } + } + } + } catch (TCException var7) { + var7.printStackTrace(); + } + + return null; + } + + public static TCComponent[] ExecQuery(TCComponentQuery itemQuery, String[] names, String[] values) { + try { + TCQueryClause[] Clause = itemQuery.describe(); + + for(int i = 0; i < names.length; ++i) { + for(int m = 0; m < Clause.length; ++m) { + if (names[i].equals(Clause[m].getUserEntryName())) { + names[i] = Clause[m].getUserEntryNameDisplay(); + break; + } + } + } + + TCComponent[] Comp2 = itemQuery.execute(names, values); + return Comp2; + } catch (Exception var6) { + return null; + } + } + + public static TCComponentFolder GetInfodbaHome(TCSession session) { + try { + TCComponentQueryType queryType = (TCComponentQueryType)session.getTypeComponent("ImanQuery"); + TCComponentQuery itemQuery = (TCComponentQuery)queryType.find("General..."); + if (itemQuery == null) { + itemQuery = (TCComponentQuery)queryType.find("..."); + } + + String[] names = new String[]{"Name", "Type", "OwningUser"}; + String[] values = new String[]{"Home", "Folder", "*infodba*"}; + TCComponent[] items = ExecQuery(itemQuery, names, values); + return (TCComponentFolder)items[0]; + } catch (Exception var6) { + return null; + } + } + + public static TCComponentFolder GetFolderByPath(TCSession session, String Path) { + try { + TCComponentFolder Home = GetInfodbaHome(session); + if (Home == null) { + return null; + } else { + String[] Paths = Path.split("\\\\"); + TCComponentFolder comp = Home; + + for(int i = 0; i < Paths.length; ++i) { + comp = (TCComponentFolder)GetRelatioinCompByName(comp, Paths[i]); + if (comp == null) { + return null; + } + } + + return comp; + } + } catch (Exception var6) { + return null; + } + } + + public static AIFComponentContext GetContextByPath(TCSession session, String Path) { + try { + TCComponentFolder Home = GetInfodbaHome(session); + if (Home != null) { + String[] Paths = Path.split("\\\\"); + TCComponent comp = Home; + AIFComponentContext Context = null; + + for(int i = 0; i < Paths.length; ++i) { + if (Context != null) { + comp = (TCComponent)Context.getComponent(); + } + + Context = GetRelatioinContextByName((TCComponent)comp, Paths[i]); + if (Context == null) { + return null; + } + } + + return Context; + } else { + return null; + } + } catch (Exception var7) { + return null; + } + } + + public static AIFComponentContext GetRelatioinContextByName(TCComponent comp, String ObjectName) { + try { + AIFComponentContext[] context = comp.getChildren(); + + for(int i = 0; i < context.length; ++i) { + TCComponent subcomp = (TCComponent)context[i].getComponent(); + if (subcomp.getProperty("object_name").equals(ObjectName)) { + return context[i]; + } + } + } catch (Exception var5) { + System.out.println(var5.toString()); + } + + return null; + } + + public static TCComponent[] GetQueryResult(TCSession session, String QueryName, String[] Names, String[] Values) { + try { + TCComponentQueryType queryType = (TCComponentQueryType)session.getTypeComponent("ImanQuery"); + TCComponentQuery itemQuery = (TCComponentQuery)queryType.find(QueryName); + if (itemQuery == null) { + return null; + } else { + TCComponent[] items = ExecQuery(itemQuery, Names, Values); + return items; + } + } catch (Exception var7) { + return null; + } + } + + public static TCComponent[] GetQueryResultUsingDefaultValue(TCSession session, String QueryName, String[] Names, String[] Values) { + try { + TCComponentQueryType queryType = (TCComponentQueryType)session.getTypeComponent("ImanQuery"); + TCComponentQuery itemQuery = (TCComponentQuery)queryType.find(QueryName); + if (itemQuery == null) { + return null; + } else { + Map ConditionMap = new HashMap(); + + for(int i = 0; i < Names.length; ++i) { + ConditionMap.put(Names[i], Values[i]); + } + + TCQueryClause[] Clause = itemQuery.describe(); + Map QueryMap = new HashMap(); + + for(int i = 0; i < Clause.length; ++i) { + String Key = Clause[i].getUserEntryName(); + String DisplayName = Clause[i].getUserEntryNameDisplay(); + String DefalutName = Clause[i].getDefaultValue(); + if (DefalutName.length() > 0) { + QueryMap.put(DisplayName, DefalutName); + } + + if (ConditionMap.containsKey(Key)) { + QueryMap.put(DisplayName, (String)ConditionMap.get(Key)); + } + } + + if (QueryMap.isEmpty()) { + return new TCComponent[0]; + } else { + String[] SearchNames = new String[QueryMap.size()]; + String[] SearchValues = new String[QueryMap.size()]; + int i = 0; + Object[] keys = QueryMap.keySet().toArray(); + + for(int m = 0; m < keys.length; ++m) { + String val = (String)QueryMap.get(keys[m]); + SearchNames[i] = (String)keys[m]; + SearchValues[i] = val; + ++i; + } + + TCComponent[] items = itemQuery.execute(SearchNames, SearchValues); + return items; + } + } + } catch (Exception var15) { + return null; + } + } + + public static TCComponentFolder GetReportTemplateFolder(TCSession session, String FolderName) { + try { + TCComponentFolder ReportFolder = null; + TCComponentFolder HomeFolder = GetInfodbaHome(session); + if (HomeFolder == null) { + System.out.print("ûҵInfodbaļ\n"); + return null; + } else { + AIFComponentContext[] SubFolder = HomeFolder.getChildren(); + + for(int i = 0; i < SubFolder.length; ++i) { + if (SubFolder[i].getComponent().getType().compareTo("Folder") == 0) { + ReportFolder = (TCComponentFolder)SubFolder[i].getComponent(); + if (ReportFolder.getProperty("object_name").compareTo(FolderName) == 0) { + return ReportFolder; + } + } + } + + System.out.print("ûҵInfodbaļļ:" + FolderName + "\n"); + return null; + } + } catch (Exception var6) { + System.out.print("ûҵInfodbaļļ:" + FolderName + "\n"); + return null; + } + } + + public static String GetComponentValue(ReportConfig RCfg, TCComponent GetQueryResult, String Type, String value) { + String[] Steps = value.split("\\."); + TCComponent CurComp = GetQueryResult; + String Result = ""; + + try { + for(int i = 0; i < Steps.length; ++i) { + if (CurComp != null) { + String CurValue = Steps[i].trim(); + if (Type.equals("FORMULA")) { + if (RCfg.CalcCell != null) { + RCfg.CalcCell.setCellFormula(value); + FormulaEvaluator evaluator = RCfg.wb.getCreationHelper().createFormulaEvaluator(); + evaluator.evaluateFormulaCell(RCfg.CalcCell); + Result = RCfg.CalcCell.getStringCellValue(); + } + } else if (CurValue.equals("JOB")) { + CurComp = ((TCComponent)CurComp).getCurrentJob(); + } else if (CurValue.equals("TASK")) { + if (CurComp != null) { + TCComponentTask RootTask = ((TCComponentProcess)CurComp).getRootTask(); + TCComponent[] Tasks = RootTask.getRelatedComponents("child_tasks"); + + for(int j = 0; j < Tasks.length; ++j) { + CurComp = (TCComponentTask)Tasks[j]; + if (((TCComponentTask)CurComp).getState() == TCTaskState.PENDING) { + break; + } + } + } + } else { + String QueryString; + if (CurValue.startsWith("GRM(")) { + QueryString = CurValue.substring(4, CurValue.length() - 1); + CurComp = GetReleateComponent(RCfg, (TCComponent)CurComp, QueryString); + } else if (CurValue.startsWith("PSEParent")) { + TCComponent[] Parent = ((TCComponent)CurComp).whereUsed((short)0); + if (Parent.length >= 1) { + CurComp = Parent[0]; + } else { + CurComp = null; + } + } else if (CurValue.startsWith("QUERY(")) { + QueryString = CurValue.substring(CurValue.indexOf("(") + 1, CurValue.length() - 1); + String[] Querys = QueryString.split("\\|"); + if (Querys.length == 3) { + String QueryName = Querys[0]; + String[] Names = Querys[1].split(";"); + String[] Values = Querys[2].split(";"); + TCSession session = GetQueryResult.getSession(); + TCComponentQueryType queryType = (TCComponentQueryType)session.getTypeComponent("ImanQuery"); + TCComponentQuery itemQuery = (TCComponentQuery)queryType.find(QueryName); + if (itemQuery != null) { + TCComponent[] items = ExecQuery(itemQuery, Names, Values); + if (items.length > 0) { + CurComp = items[0]; + } else { + CurComp = null; + } + } else { + CurComp = null; + } + } else { + CurComp = null; + } + } else if (CurValue.startsWith("VALUE(")) { + Result = CurValue.substring(CurValue.indexOf("(") + 1, CurValue.length() - 1); + } else { + Result = GetPropertyValue((TCComponent)CurComp, CurValue); + } + } + } + } + } catch (Exception var18) { + } + + return Result; + } + + public static String GetPropertyValue(TCComponent CurComp, String CurValue) { + String Result = ""; + + try { + String PropertyName = CurValue; + String format = "yyyy-MM-dd HH:mm:ss"; + if (CurValue.indexOf("[") >= 0) { + PropertyName = CurValue.substring(0, CurValue.indexOf("[")); + format = CurValue.substring(CurValue.indexOf("[") + 1, CurValue.length() - 1); + } + + TCProperty Porpery = CurComp.getTCProperty(PropertyName); + if (Porpery.getPropertyType() == 2) { + Date TempData = Porpery.getDateValue(); + if (TempData != null) { + SimpleDateFormat displayFormatter = new SimpleDateFormat(format); + Result = displayFormatter.format(TempData); + } + } else if (Porpery.getPropertyType() == 5) { + Result = Porpery.getUIFValue(); + } else if (Porpery.getPropertyType() == 3) { + Result = Porpery.getUIFValue(); + } else { + Result = Porpery.getUIFValue(); + } + } catch (Exception var8) { + } + + return Result; + } + + public static ArrayList GetSecondComponents(TCComponent CurComp, String GRMString) { + ArrayList SecondComponentsAry = new ArrayList(); + + try { + String RelationName = GRMString; + String CheckString = ""; + String CheckField = ""; + String CheckValue = ""; + if (GRMString.split(":").length > 1) { + RelationName = GRMString.split(":")[0]; + CheckString = GRMString.split(":")[1]; + CheckField = CheckString.split("=")[0]; + CheckValue = CheckString.split("=")[1]; + } + + if (RelationName.equals("LatestItemRevision")) { + TCComponent TempComp = ((TCComponentItem)CurComp).getLatestItemRevision(); + if (TempComp != null) { + SecondComponentsAry.add(TempComp); + } + } else if (RelationName.equals("Item")) { + TCComponent TempComp = ((TCComponentItemRevision)CurComp).getItem(); + if (TempComp != null) { + SecondComponentsAry.add(TempComp); + } + } else { + TCComponent[] Comps = CurComp.getRelatedComponents(RelationName); + if (Comps != null && Comps.length > 0) { + for(int n = 0; n < Comps.length; ++n) { + String PropertyValue = Comps[n].getProperty(CheckField); + if (PropertyValue.equals(CheckValue)) { + SecondComponentsAry.add(Comps[n]); + } + } + } + } + } catch (Exception var10) { + var10.printStackTrace(); + } + + return SecondComponentsAry; + } + + static TCComponent GetReleateComponent(ReportConfig RCfg, TCComponent CurComp, String GRMString) { + Object ResultComp = null; + + try { + String RelationName = GRMString; + String CheckString = ""; + String CheckField = ""; + String CheckValue = ""; + if (GRMString.split(":").length > 1) { + RelationName = GRMString.split(":")[0]; + CheckString = GRMString.split(":")[1]; + CheckField = CheckString.split("=")[0]; + CheckValue = CheckString.split("=")[1]; + } + + if (RelationName.equals("LatestItemRevision")) { + ResultComp = ((TCComponentItem)CurComp).getLatestItemRevision(); + } else { + TCComponent[] Comps = CurComp.getRelatedComponents(RelationName); + if (Comps != null && Comps.length > 0) { + if (GRMString.length() > 0) { + for(int n = 0; n < Comps.length; ++n) { + if (GetComponentValue(RCfg, Comps[n], "=", CheckField).equals(CheckValue)) { + ResultComp = Comps[n]; + break; + } + } + } else { + CurComp = Comps[0]; + } + } + } + } catch (Exception var10) { + } + + return (TCComponent)ResultComp; + } + + public static TCComponentDataset createOrUpdateDataset(TCSession TCSession, String localFile, String datasetType, String datasetNamedRef, String datasetName, TCComponent itemRevision, String relationType, boolean replaceAlert) { + TCComponentDataset datasetComponent = null; + + try { + TCTypeService typeService = TCSession.getTypeService(); + TCComponentDatasetType TCDatasetType = (TCComponentDatasetType)typeService.getTypeComponent(datasetType); + TCComponent[] TCComponent = itemRevision.getRelatedComponents(relationType); + if (TCComponent != null && TCComponent.length > 0) { + for(int i = 0; i < TCComponent.length; ++i) { + if (TCComponent[i].getProperty("object_type").equals(datasetType) && TCComponent[i].getProperty("object_name").equals(datasetName)) { + datasetComponent = (TCComponentDataset)TCComponent[i]; + break; + } + } + } + + String[] filePathNames = new String[]{localFile}; + String[] namedRefs = new String[]{datasetNamedRef}; + if (datasetComponent == null) { + datasetComponent = TCDatasetType.setFiles(datasetName, "Created by program.", datasetType, filePathNames, namedRefs); + itemRevision.add(relationType, datasetComponent); + return datasetComponent; + } else { + boolean confirm = true; + if (replaceAlert) { + confirm = MessageDialog.openQuestion((Shell)null, "ȷ", datasetName + "ѾڣǷ񸲸ǣ"); + } + + if (confirm) { + TCDatasetType.setFiles(datasetComponent, filePathNames, namedRefs); + } + + return datasetComponent; + } + } catch (Exception var15) { + var15.printStackTrace(); + MessageBox.post(var15); + return null; + } + } + + public static TCComponentDataset HHMcreateOrUpdateDataset(TCSession TCSession, String localFile, String datasetType, String datasetNamedRef, String datasetName, TCComponent itemRevision, String relationType, boolean replaceAlert) { + TCComponentDataset datasetComponent = null; + + try { + TCTypeService typeService = TCSession.getTypeService(); + TCComponentDatasetType TCDatasetType = (TCComponentDatasetType)typeService.getTypeComponent(datasetType); + TCComponent[] TCComponent = itemRevision.getRelatedComponents(relationType); + if (TCComponent != null && TCComponent.length > 0) { + for(int i = 0; i < TCComponent.length; ++i) { + if (TCComponent[i].getProperty("object_type").equals(datasetType) && TCComponent[i].getProperty("object_name").equals(datasetName)) { + datasetComponent = (TCComponentDataset)TCComponent[i]; + break; + } + } + } + + String[] filePathNames = new String[]{localFile}; + String[] namedRefs = new String[]{datasetNamedRef}; + if (datasetComponent == null) { + datasetComponent = TCDatasetType.setFiles(datasetName, "Created by program.", datasetType, filePathNames, namedRefs); + itemRevision.add(relationType, datasetComponent); + return datasetComponent; + } else { + int confirm; + if (replaceAlert) { + Shell shell = Display.getCurrent().getActiveShell(); + org.eclipse.swt.widgets.MessageBox messageBox = new org.eclipse.swt.widgets.MessageBox(shell, 194); + messageBox.setMessage(":Ѵݼļ\n\n:Ѵݼļ"); + messageBox.setText("ʾ"); + confirm = messageBox.open(); + } else { + confirm = 64; + } + + if (confirm == 64) { + TCDatasetType.setFiles(datasetComponent, filePathNames, namedRefs); + } + + return datasetComponent; + } + } catch (Exception var18) { + Exception e = var18; + + try { + TCComponentFolder NewStuff = TCComponentFolder.getNewStuffFolder(TCSession); + NewStuff.add("contents", datasetComponent); + MessageBox.post(e.toString() + "\nѱNewStuffĿ¼", "ʾ", 2); + } catch (Exception var17) { + var17.printStackTrace(); + } + + return null; + } + } + + public static void UpLoad(TCSession session, TCComponentItemRevision ItemRev, HSSFWorkbook wb, String BOMName, String ReportTempPath) { + try { + String time = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date()); + String datasetName = ItemRev.getProperty("item_id") + "_" + ItemRev.getProperty("item_revision_id") + BOMName; + String filename = ReportTempPath + BOMName + time + ".xls"; + File file = new File(filename); + if (file.exists()) { + file.delete(); + } + + FileOutputStream FileOutput = new FileOutputStream(filename); + wb.write(FileOutput); + FileOutput.close(); + HHMcreateOrUpdateDataset(session, filename, "MSExcel", "excel", datasetName, ItemRev, "IMAN_specification", true); + } catch (Exception var10) { + var10.printStackTrace(); + } + + } + + public static void HHM1UpLoad(TCSession session, TCComponentItemRevision ItemRev, HSSFWorkbook wb, String BOMName, String ReportTempPath) { + try { + String time = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date()); + String datasetName = ItemRev.getProperty("item_id") + BOMName; + String filename = ReportTempPath + BOMName + time + ".xls"; + File file = new File(filename); + if (file.exists()) { + file.delete(); + } + + FileOutputStream FileOutput = new FileOutputStream(filename); + wb.write(FileOutput); + FileOutput.close(); + HHMcreateOrUpdateDataset(session, filename, "MSExcel", "excel", datasetName, ItemRev, "TC_Attaches", true); + } catch (Exception var10) { + var10.printStackTrace(); + } + + } + + public static void UpLoadNew(TCSession session, TCComponentItemRevision ItemRev, HSSFWorkbook wb, String BOMName, String ReportTempPath) { + try { + String time = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date()); + String datasetName = ItemRev.getProperty("item_id") + BOMName; + String filename = ReportTempPath + BOMName + time + ".xls"; + File file = new File(filename); + if (file.exists()) { + file.delete(); + } + + FileOutputStream FileOutput = new FileOutputStream(filename); + wb.write(FileOutput); + FileOutput.close(); + HHMcreateOrUpdateDataset(session, filename, "MSExcel", "excel", datasetName, ItemRev, "TC_Attaches", true); + } catch (Exception var10) { + var10.printStackTrace(); + } + + } + + public static TCComponentDataset SAAEcreateDataset(TCSession TCSession, String localFile, String datasetType, String datasetNamedRef, String datasetName, TCComponent itemRevision, String relationType) { + TCComponentDataset datasetComponent = null; + + try { + TCTypeService typeService = TCSession.getTypeService(); + TCComponentDatasetType TCDatasetType = (TCComponentDatasetType)typeService.getTypeComponent(datasetType); + String[] filePathNames = new String[]{localFile}; + String[] namedRefs = new String[]{datasetNamedRef}; + if (datasetComponent == null) { + datasetComponent = TCDatasetType.setFiles(datasetName, "Created by program.", datasetType, filePathNames, namedRefs); + itemRevision.add(relationType, datasetComponent); + } + + return datasetComponent; + } catch (Exception var13) { + try { + TCComponentFolder NewStuff = TCComponentFolder.getNewStuffFolder(TCSession); + NewStuff.add("contents", datasetComponent); + MessageBox.post("ûеǰдȨޣѱNewStuffĿ¼", "ʾ", 2); + } catch (TCException var12) { + var12.printStackTrace(); + } + + return null; + } + } + + public static TCComponentDataset createDataset(TCSession TCSession, String localFile, String datasetType, String datasetNamedRef, String datasetName, TCComponent itemRevision, String relationType) { + TCComponentDataset datasetComponent = null; + + try { + TCTypeService typeService = TCSession.getTypeService(); + TCComponentDatasetType TCDatasetType = (TCComponentDatasetType)typeService.getTypeComponent(datasetType); + String[] filePathNames = new String[]{localFile}; + String[] namedRefs = new String[]{datasetNamedRef}; + if (datasetComponent == null) { + datasetComponent = TCDatasetType.setFiles(datasetName, "Created by program.", datasetType, filePathNames, namedRefs); + itemRevision.add(relationType, datasetComponent); + } + + return datasetComponent; + } catch (Exception var12) { + MessageBox.post(var12); + return null; + } + } + + public static Date StrToDate(String str) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = null; + + try { + date = format.parse(str); + } catch (Exception var4) { + var4.printStackTrace(); + } + + return date; + } + + public static boolean ISExitAR(String[] ToolList, String StructureNoStr) { + try { + for(int i = 0; i < ToolList.length; ++i) { + String A = ToolList[i]; + if (StructureNoStr.equals(A)) { + return true; + } + } + } catch (Exception var4) { + var4.printStackTrace(); + } + + return false; + } + + public static boolean DeleteItem(TCSession session, TCComponentItem Item, boolean Alter) { + try { + AIFComponentContext[] ParentComp = Item.whereReferenced(); + + for(int j = 0; j < ParentComp.length; ++j) { + AIFComponentContext[] ParentChildComp = ((TCComponent)ParentComp[j].getComponent()).getChildren(); + String context = ""; + + for(int k = 0; k < ParentChildComp.length; ++k) { + if (ParentChildComp[k].getComponent() == Item) { + context = ParentChildComp[k].getContext().toString(); + if (!context.equals("") && !context.equals("revision_list")) { + ((TCComponent)ParentComp[j].getComponent()).remove(context, Item); + } + } + } + } + + Item.delete(); + return true; + } catch (Exception var8) { + System.out.println(var8.toString()); + if (Alter) { + MessageBox.post(var8); + } + + return false; + } + } + + public static boolean CheckCheckOut(TCSession session, TCComponentItem Item, boolean Alter) { + try { + TCReservationService tcreservationservice = session.getReservationService(); + if (!ChenckInComp(tcreservationservice, Item, Alter)) { + return false; + } else if (!ChenckInComp(tcreservationservice, Item.getLatestItemRevision(), Alter)) { + return false; + } else if (!ChenckInComp(tcreservationservice, Item.getRelatedComponent("IMAN_master_form"), Alter)) { + return false; + } else { + return ChenckInComp(tcreservationservice, Item.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev"), Alter); + } + } catch (Exception var4) { + return false; + } + } + + static boolean ChenckInComp(TCReservationService tcreservationservice, TCComponent comp, boolean Alter) { + if (comp == null) { + return true; + } else { + try { + if (tcreservationservice.isReserved(comp)) { + tcreservationservice.unreserve(comp); + } + + if (tcreservationservice.isReserved(comp)) { + System.out.println(comp.toString() + ":ǩʧ!"); + return false; + } else { + return true; + } + } catch (Exception var4) { + System.out.println(var4.toString()); + if (Alter) { + MessageBox.post(var4); + } + + return false; + } + } + } + + public static boolean CopyPages(int pages, HSSFSheet sheet, int linesPerPage, int StartRow) { + if (pages <= 0) { + return true; + } else { + int regionNum = sheet.getNumMergedRegions(); + if (StartRow > linesPerPage) { + MessageBox.post("ģļÿҳʵڲõÿҳ", "", 1); + return false; + } else { + int[] pageBreaks = sheet.getRowBreaks(); + int i; + if (pageBreaks != null) { + for(i = 0; i < pageBreaks.length; ++i) { + sheet.removeRowBreak(pageBreaks[i]); + } + } + + for(i = 0; i < pages; ++i) { + sheet.setRowBreak((i + 1) * linesPerPage - 1); + } + + for(i = 1; i <= pages; ++i) { + for(int j = 0; j < regionNum; ++j) { + Region region = sheet.getMergedRegionAt(j); + if (region.getRowTo() > StartRow) { + region.setRowFrom(region.getRowFrom() + i * linesPerPage); + region.setRowTo(region.getRowTo() + i * linesPerPage); + sheet.addMergedRegion(region); + } + } + } + + for(i = StartRow; i <= StartRow + linesPerPage; ++i) { + HSSFRow tempRow = sheet.getRow(i); + if (tempRow != null) { + for(int k = 1; k <= pages; ++k) { + HSSFRow tttempRow = sheet.createRow(i + k * linesPerPage); + tttempRow.setHeight(tempRow.getHeight()); + } + + int beginCell = tempRow.getFirstCellNum(); + int endCell = tempRow.getLastCellNum(); + if (beginCell >= 0) { + for(int j = beginCell; j <= endCell; ++j) { + HSSFCell tempCell = tempRow.getCell(j); + if (tempCell != null) { + int cellType = tempCell.getCellType(); + + for(int k = 1; k <= pages; ++k) { + HSSFRow tttempRow = sheet.getRow(i + k * linesPerPage); + HSSFCell tttempCell = tttempRow.createCell(j); + tttempCell.setCellStyle(tempCell.getCellStyle()); + tttempCell.setCellType(tempCell.getCellType()); + if (cellType == 0) { + tttempCell.setCellValue(tempCell.getNumericCellValue()); + } else if (cellType == 1) { + tttempCell.setCellValue(tempCell.getStringCellValue()); + } else if (cellType == 2) { + tttempCell.setCellFormula(tempCell.getCellFormula()); + } + } + } + } + } + } + } + + return true; + } + } + } + + public static List GetSingleLecelBOM(TCComponentItemRevision ItemRev, String ViewType, String FindType) { + ArrayList SubItemVec = new ArrayList(); + + try { + TCComponent[] recompView = ItemRev.getRelatedComponents(ViewType); + + for(int i = 0; i < recompView.length; ++i) { + if (recompView[i].getSubType().startsWith(FindType)) { + SubItemVec.add((TCComponentItem)recompView[i]); + } + } + } catch (Exception var6) { + } + + return SubItemVec; + } + + public static List GetAllBOM(TCComponentItemRevision ItemRev, String FindType) { + ArrayList ALlSubItemVec = new ArrayList(); + + try { + TCComponent[] ViewComp = ItemRev.getRelatedComponents("structure_revisions"); + + for(int i = 0; i < ViewComp.length; ++i) { + List SingleViewItemVec = GetAllBOM(ItemRev, ViewComp[i].getType(), FindType); + + for(int j = 0; j < SingleViewItemVec.size(); ++j) { + ALlSubItemVec.add((TCComponentItem)SingleViewItemVec.get(j)); + } + } + } catch (Exception var7) { + } + + return ALlSubItemVec; + } + + public static List GetAllBOM(TCComponentItemRevision ItemRev, String ViewType, String FindType) { + ArrayList AllSubItemVec = new ArrayList(); + + try { + TCComponent[] SubItem = ItemRev.getRelatedComponents(ViewType); + + for(int i = 0; i < SubItem.length; ++i) { + if (SubItem[i].getSubType().equals(FindType)) { + AllSubItemVec.add((TCComponentItem)SubItem[i]); + } + + List NextSubItemVec = GetAllBOM(((TCComponentItem)SubItem[i]).getLatestItemRevision(), ViewType, FindType); + + for(int j = 0; j < NextSubItemVec.size(); ++j) { + AllSubItemVec.add((TCComponentItem)NextSubItemVec.get(j)); + } + } + } catch (Exception var8) { + System.out.println(var8.toString()); + } + + return AllSubItemVec; + } + + public static TCComponentItemRevision GetLastReleasedItemRevision(TCComponentItem Item) { + try { + TCComponentItemRevision[] ItemRev = Item.getReleasedItemRevisions(); + if (ItemRev == null) { + return null; + } else { + return ItemRev.length == 0 ? null : ItemRev[0]; + } + } catch (Exception var2) { + System.out.println(var2.toString()); + return null; + } + } + + public static boolean ExistInArray(ArrayList DatasetArray, TCComponent NewComp) { + if (NewComp == null) { + return true; + } else { + for(int i = 0; i < DatasetArray.size(); ++i) { + TCComponent OldComp = (TCComponent)DatasetArray.get(i); + if (OldComp == NewComp) { + return true; + } + } + + return false; + } + } + + public static TCComponentBOMViewRevision GetBOMViewRevision(TCComponentItemRevision ItemRev, String TypeName) { + try { + TCComponent[] Views = ItemRev.getRelatedComponents("structure_revisions"); + + for(int i = 0; i < Views.length; ++i) { + if (Views[i].getProperty("object_type").equals(TypeName)) { + return (TCComponentBOMViewRevision)Views[i]; + } + } + } catch (Exception var4) { + MessageBox.post(var4); + } + + return null; + } + + public static TCComponentRevisionRule GetGivenRule(String RuleName) { + try { + TCSession session = (TCSession)AIFUtility.getDefaultSession(); + TCComponentRevisionRule[] rrs = TCComponentRevisionRule.listAllRules(session); + + for(int i = 0; i < rrs.length; ++i) { + if (rrs[i].getProperty("object_name").equals(RuleName)) { + return rrs[i]; + } + } + + return null; + } catch (Exception var4) { + return null; + } + } + + public static boolean DeleteFile(String FileName) { + if (FileName != null) { + File tempFile = new File(FileName); + if (tempFile.exists()) { + tempFile.delete(); + } + + if (!tempFile.exists()) { + return true; + } + } + + return false; + } + + public static TCComponent GetRelatioinCompByType(TCComponent comp, String ObjectType) { + try { + AIFComponentContext[] context = comp.getChildren(); + + for(int i = 0; i < context.length; ++i) { + TCComponent subcomp = (TCComponent)context[i].getComponent(); + if (subcomp.getProperty("object_type").equals(ObjectType)) { + return subcomp; + } + } + } catch (Exception var5) { + } + + return null; + } + + public static TCComponent GetRelatioinCompByName(TCComponent comp, String ObjectName) { + try { + AIFComponentContext[] context = comp.getChildren(); + + for(int i = 0; i < context.length; ++i) { + TCComponent subcomp = (TCComponent)context[i].getComponent(); + if (subcomp.getProperty("object_name").equals(ObjectName)) { + return subcomp; + } + } + } catch (Exception var5) { + } + + return null; + } + + public static Date getDateBefore(Date d, int day) { + Calendar now = Calendar.getInstance(); + now.setTime(d); + now.set(5, now.get(5) - day); + return now.getTime(); + } + + public static Date getDateAfter(Date d, int day) { + Calendar now = Calendar.getInstance(); + now.setTime(d); + now.set(5, now.get(5) + day); + return now.getTime(); + } + + public static String GetUDSConfigPath(String PreferenceName) { + try { + TCSession session = (TCSession)AIFUtility.getDefaultSession(); + TCPreferenceService PreferService = session.getPreferenceService(); + String UDSCodeConfigPath = PreferService.getString(1, PreferenceName); + if (UDSCodeConfigPath == null || UDSCodeConfigPath.equals("")) { + UDSCodeConfigPath = PreferService.getString(4, PreferenceName); + } + + if (UDSCodeConfigPath != null && !UDSCodeConfigPath.equals("")) { + if (!UDSCodeConfigPath.endsWith("\\")) { + UDSCodeConfigPath = UDSCodeConfigPath + "\\"; + } + + return UDSCodeConfigPath; + } else { + System.out.println("ûҵѡ:" + PreferenceName); + return ""; + } + } catch (Exception var4) { + var4.printStackTrace(); + return ""; + } + } + + public static String GetPreference(String PreferenceName) { + try { + TCSession session = (TCSession)AIFUtility.getDefaultSession(); + TCPreferenceService PreferService = session.getPreferenceService(); + String UDSCodeConfigPath = PreferService.getString(1, PreferenceName); + if (UDSCodeConfigPath == null || UDSCodeConfigPath.equals("")) { + UDSCodeConfigPath = PreferService.getString(4, PreferenceName); + } + + if (UDSCodeConfigPath != null && !UDSCodeConfigPath.equals("")) { + return UDSCodeConfigPath; + } else { + System.out.println("ûҵѡ:" + PreferenceName); + return ""; + } + } catch (Exception var4) { + var4.printStackTrace(); + return ""; + } + } + + public static String GetPreference(TCSession session, String PreferenceName) { + try { + TCPreferenceService PreferService = session.getPreferenceService(); + String UDSCodeConfigPath = PreferService.getString(1, PreferenceName); + if (UDSCodeConfigPath == null || UDSCodeConfigPath.equals("")) { + UDSCodeConfigPath = PreferService.getString(4, PreferenceName); + } + + if (UDSCodeConfigPath != null && !UDSCodeConfigPath.equals("")) { + return UDSCodeConfigPath; + } else { + System.out.println("ûҵѡ:" + PreferenceName); + return ""; + } + } catch (Exception var4) { + var4.printStackTrace(); + return ""; + } + } + + public static void setStringCellValue(HSSFRow row, int cellNum, String cellString) { + if (cellString != null) { + HSSFCell cell = row.getCell((short)cellNum); + cell.setCellValue(cellString); + } + + } + + public static String getStringCellValue(HSSFRow row, int cellNum) { + String returnValue = ""; + HSSFCell cell = row.getCell((short)cellNum); + int cellType = cell.getCellType(); + if (cellType == 1) { + returnValue = cell.getStringCellValue(); + } else if (cellType == 0) { + returnValue = Double.toString(cell.getNumericCellValue()); + } else if (cellType == 2) { + returnValue = null; + } else if (cellType == 3) { + returnValue = ""; + } else if (cellType == 5) { + returnValue = "Err"; + } else { + returnValue = "Unknown"; + } + + if (returnValue != null) { + returnValue = returnValue.trim(); + } + + return returnValue; + } + + public static void InsertRow(HSSFSheet sheet, int startRow, int rows) { + try { + sheet.shiftRows(startRow, sheet.getLastRowNum(), rows, true, false); + + for(int i = 0; i < rows; ++i) { + try { + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + HSSFRow sourceRow = sheet.createRow(startRow); + HSSFRow targetRow = sheet.getRow(startRow + rows); + ArrayList ToAddRegion = new ArrayList(); + int regionNum = sheet.getNumMergedRegions(); + + int m; + for(m = 0; m < regionNum; ++m) { + Region region = sheet.getMergedRegionAt(m); + if (region.getRowTo() == startRow + rows && region.getRowFrom() == startRow + rows) { + region.setRowFrom(startRow); + region.setRowTo(startRow); + ToAddRegion.add(region); + } + } + + for(m = 0; m < ToAddRegion.size(); ++m) { + sheet.addMergedRegion((org.apache.poi.ss.util.Region)ToAddRegion.get(m)); + } + + sourceRow.setHeight(targetRow.getHeight()); + + for(m = targetRow.getFirstCellNum(); m < targetRow.getPhysicalNumberOfCells(); ++m) { + sourceCell = sourceRow.createCell(m); + targetCell = targetRow.getCell(m); + sourceCell.setCellStyle(targetCell.getCellStyle()); + sourceCell.setCellType(targetCell.getCellType()); + } + + ++startRow; + } catch (Exception var12) { + var12.printStackTrace(); + } + } + } catch (Exception var13) { + var13.printStackTrace(); + } + + } + + public static TCComponentDataset getDatasetObjectOfItemRev(TCComponentItemRevision itemRev, String datasetType, String datasetName, String relationType) { + TCComponentDataset returnValue = null; + + try { + int count = 0; + TCComponent[] tempComponent = itemRev.getRelatedComponents(relationType); + + for(int i = 0; i < tempComponent.length; ++i) { + if (tempComponent[i].getType().equals(datasetType)) { + TCComponentDataset tempDataset = (TCComponentDataset)tempComponent[i]; + if (tempDataset.getProperty("object_name").equals(datasetName)) { + ++count; + returnValue = tempDataset; + } + } + } + + if (count == 0) { + MessageBox.post("汾ȱҪݼ\n:" + itemRev.toString() + " :" + datasetType + " :" + datasetName + " ϵ:" + relationType, "", 4); + returnValue = null; + } + + if (count > 1) { + MessageBox.post("汾³ֶͬݼ\n:" + itemRev.toString() + " :" + datasetType + " :" + datasetName + " ϵ:" + relationType, "", 4); + returnValue = null; + } + } catch (TCException var9) { + MessageBox.post("ݼʱδ֪", "", 1); + returnValue = null; + } + + return returnValue; + } + + public static boolean datasetFileToLocalDir(TCComponentDataset datasetTag, String localFileName, String localDirName) { + File fileObject = null; + String datasetName = null; + String namedRefName = null; + File dirObject = new File(localDirName); + if (!dirObject.exists()) { + dirObject.mkdirs(); + } + + File tempFileObject; + try { + TCComponentDataset componentDataset = datasetTag.latest(); + datasetName = componentDataset.getProperty("object_name"); + namedRefName = componentDataset.getDatasetDefinitionComponent().getNamedReferences()[0]; + String[] namedRefFileName = componentDataset.getFileNames(namedRefName); + if (namedRefFileName == null || namedRefFileName.length == 0) { + MessageBox.post("ݼ<" + datasetName + ">ûжӦ!", "ϵͳô", 1); + return false; + } + + tempFileObject = new File(localDirName, namedRefFileName[0]); + if (tempFileObject.exists()) { + tempFileObject.delete(); + } + + fileObject = componentDataset.getFile(namedRefName, namedRefFileName[0], localDirName); + } catch (Exception var10) { + MessageBox.post("ݼ<" + datasetName + ">ô!", "ϵͳô", 1); + return false; + } + + tempFileObject = new File(localDirName, localFileName); + if (tempFileObject.exists()) { + tempFileObject.delete(); + } + + fileObject.renameTo(tempFileObject); + return true; + } + + public static File ExportDataset(TCComponentDataset componentDataset, String localDirName) { + File TempfileObject = null; + File ResultFileObject = null; + String datasetName = null; + String namedRefName = null; + File dirObject = new File(localDirName); + if (!dirObject.exists()) { + dirObject.mkdirs(); + } + + try { + datasetName = componentDataset.getProperty("object_name"); + datasetName = datasetName.replaceAll("/", "-"); + namedRefName = componentDataset.getDatasetDefinitionComponent().getNamedReferences()[0]; + String[] namedRefFileName = componentDataset.getFileNames(namedRefName); + if (namedRefFileName != null && namedRefFileName.length != 0) { + String TempDir = componentDataset.getWorkingDir(); + TempfileObject = new File(TempDir, namedRefFileName[0]); + if (TempfileObject.exists()) { + TempfileObject.delete(); + } + + TempfileObject = componentDataset.getFile(namedRefName, namedRefFileName[0], TempDir); + String Ext = namedRefFileName[0].substring(namedRefFileName[0].lastIndexOf(".")); + String localFileName = datasetName + Ext; + ResultFileObject = new File(localDirName, localFileName); + if (ResultFileObject.exists()) { + ResultFileObject.delete(); + } + + TempfileObject.renameTo(ResultFileObject); + return ResultFileObject; + } else { + System.out.println("ݼ<" + datasetName + ">ûжӦ!"); + return null; + } + } catch (Exception var11) { + System.out.println("ݼ<" + datasetName + ">:" + var11.toString()); + return null; + } + } + + public static HSSFSheet copySheet(HSSFSheet sheetFrom, HSSFSheet sheetTo) { + CellRangeAddress region = null; + Row rowFrom = null; + Row rowTo = null; + Cell cellFrom = null; + Cell cellTo = null; + + int intRow; + for(intRow = 0; intRow < sheetFrom.getNumMergedRegions(); ++intRow) { + region = sheetFrom.getMergedRegion(intRow); + if (region.getFirstColumn() >= sheetFrom.getFirstRowNum() && region.getLastRow() <= sheetFrom.getLastRowNum()) { + sheetTo.addMergedRegion(region); + } + } + + for(intRow = sheetFrom.getFirstRowNum(); intRow <= sheetFrom.getLastRowNum(); ++intRow) { + rowFrom = sheetFrom.getRow(intRow); + rowTo = sheetTo.createRow(intRow); + if (rowFrom != null) { + rowTo.setHeight(rowFrom.getHeight()); + + for(int intCol = 0; intCol <= rowFrom.getLastCellNum(); ++intCol) { + sheetTo.setDefaultColumnStyle(intCol, sheetFrom.getColumnStyle(intCol)); + sheetTo.setColumnWidth(intCol, sheetFrom.getColumnWidth(intCol)); + cellFrom = rowFrom.getCell(intCol); + cellTo = rowTo.createCell(intCol); + if (cellFrom != null) { + cellTo.setCellStyle(cellFrom.getCellStyle()); + cellTo.setCellType(cellFrom.getCellType()); + if (cellFrom.getStringCellValue() != null && !"".equals(cellFrom.getStringCellValue().trim())) { + cellTo.setCellValue(cellFrom.getStringCellValue()); + } + } + } + } + } + + sheetTo.setMargin((short)2, sheetFrom.getMargin((short)2)); + sheetTo.setMargin((short)3, sheetFrom.getMargin((short)3)); + sheetTo.setMargin((short)0, sheetFrom.getMargin((short)0)); + sheetTo.setMargin((short)1, sheetFrom.getMargin((short)1)); + sheetTo.setHorizontallyCenter(true); + sheetTo.setVerticallyCenter(true); + sheetTo.setFitToPage(true); + HSSFPrintSetup ps = sheetTo.getPrintSetup(); + ps.setFooterMargin(0.25D); + ps.setHeaderMargin(0.25D); + sheetTo.setAutobreaks(true); + ps.setScale((short)82); + ps.setFitHeight((short)0); + ps.setFitWidth((short)1); + ps.setLandscape(true); + ps.setPaperSize((short)9); + HSSFHeader header = sheetTo.getHeader(); + header.setCenter(sheetFrom.getHeader().getCenter()); + header.setLeft(sheetFrom.getHeader().getLeft()); + header.setRight(sheetFrom.getHeader().getRight()); + sheetTo.setDisplayGridlines(false); + sheetTo.setZoom(80, 100); + return sheetTo; + } + + public static boolean createMultiPages(int pages, HSSFSheet sheet, int linesPerPage) { + int regionNum = sheet.getNumMergedRegions(); + int beginRow = sheet.getFirstRowNum(); + int endRow = sheet.getLastRowNum(); + if (endRow + 1 > linesPerPage) { + MessageBox.post("ģļÿҳʵڲõÿҳ", "", 1); + return false; + } else { + int[] pageBreaks = sheet.getRowBreaks(); + int i; + if (pageBreaks != null) { + for(i = 0; i < pageBreaks.length; ++i) { + sheet.removeRowBreak(pageBreaks[i]); + } + } + + for(i = 0; i < pages; ++i) { + sheet.setRowBreak((i + 1) * linesPerPage - 1); + } + + for(i = 1; i < pages; ++i) { + for(int j = 0; j < regionNum; ++j) { + Region region = sheet.getMergedRegionAt(j); + region.setRowFrom(region.getRowFrom() + i * linesPerPage); + region.setRowTo(region.getRowTo() + i * linesPerPage); + sheet.addMergedRegion(region); + } + } + + for(i = beginRow; i <= endRow; ++i) { + HSSFRow tempRow = sheet.getRow(i); + + for(int k = 1; k < pages; ++k) { + HSSFRow tttempRow = sheet.createRow(i + k * linesPerPage); + tttempRow.setHeight(tempRow.getHeight()); + } + + int beginCell = tempRow.getFirstCellNum(); + int endCell = tempRow.getLastCellNum(); + if (beginCell >= 0) { + for(int j = beginCell; j <= endCell; ++j) { + try { + HSSFCell tempCell = tempRow.getCell((short)j); + if (tempCell != null) { + int cellType = tempCell.getCellType(); + + for(int k = 1; k < pages; ++k) { + HSSFRow tttempRow = sheet.getRow(i + k * linesPerPage); + HSSFCell tttempCell = tttempRow.createCell((short)j); + tttempCell.setCellStyle(tempCell.getCellStyle()); + tttempCell.setCellType(tempCell.getCellType()); + if (cellType == 0) { + tttempCell.setCellValue(tempCell.getNumericCellValue()); + } else if (cellType == 1) { + tttempCell.setCellValue(tempCell.getStringCellValue()); + } else if (cellType == 2) { + tttempCell.setCellFormula(tempCell.getCellFormula()); + } + } + } + } catch (Exception var17) { + var17.printStackTrace(); + } + } + } + } + + return true; + } + } + + public static void deleteLocalDir(File dirFileObject) { + if (dirFileObject.isDirectory()) { + File[] fl = dirFileObject.listFiles(); + + for(int i = 0; i < fl.length; ++i) { + deleteLocalDir(fl[i]); + } + } + + dirFileObject.delete(); + } + + public static TCComponentDataset getDatasetFormName(String DirName) { + TCSession tcsession = (TCSession)AIFUtility.getCurrentApplication().getSession(); + AEShellManager aeshellmanager = tcsession.getAEShellManager(); + AEShell[] Shells = aeshellmanager.getShells(); + File TargetDir = new File(DirName); + + for(int m = 0; m < Shells.length; ++m) { + AEShell OneShell = Shells[m]; + File Dir = new File(OneShell.askWorkingDir()); + if (TargetDir.compareTo(Dir) == 0) { + TCComponentDataset Dataset = OneShell.askSelectedDataset(); + return Dataset; + } + } + + return null; + } + + public static int GetLevel(TCComponentBOMLine parentLine) { + int Level = 0; + + try { + while((parentLine = parentLine.parent()) != null) { + ++Level; + } + + return Level; + } catch (Exception var2) { + return 0; + } + } + + public static TCComponentBOMLine GetModule(TCComponentBOMLine bomline) { + try { + String Selfobject_type = bomline.getItem().getTCProperty("object_type").getStringValue(); + if (Selfobject_type.equals("U2_Module")) { + return bomline; + } else { + TCComponentBOMLine parent = bomline.parent(); + return GetModule(parent); + } + } catch (Exception var3) { + var3.printStackTrace(); + return null; + } + } + + public static String GetVersion(TCComponentBOMLine bomline) { + Object Version = null; + + try { + GetModule(bomline).getItem(); + } catch (Exception var3) { + var3.printStackTrace(); + } + + return (String)Version; + } + + public static BigDecimal GetRollUpNum(TCComponentBOMLine SelComp) { + try { + TCComponentBOMLine ParentBOMLine = SelComp.parent(); + if (ParentBOMLine == null) { + return new BigDecimal("1"); + } else { + String bl_quantity = SelComp.getProperty("bl_quantity"); + + BigDecimal RollupBig; + for(RollupBig = GetBigDecimal(bl_quantity); ParentBOMLine != null; ParentBOMLine = ParentBOMLine.parent()) { + BigDecimal ParentBig = GetRollUpNum(ParentBOMLine); + RollupBig = RollupBig.multiply(ParentBig); + } + + return RollupBig; + } + } catch (Exception var5) { + var5.printStackTrace(); + return new BigDecimal("1"); + } + } + + public static BigDecimal GetBigDecimal(String Value) { + try { + BigDecimal S1 = new BigDecimal(Value); + return S1; + } catch (Exception var2) { + return new BigDecimal("0"); + } + } +} diff --git a/src/com/caxaviews/exportdataset/ReportConfig.java b/src/com/caxaviews/exportdataset/ReportConfig.java new file mode 100644 index 0000000..822fc2a --- /dev/null +++ b/src/com/caxaviews/exportdataset/ReportConfig.java @@ -0,0 +1,107 @@ +package com.caxaviews.exportdataset; + +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.Vector; +import javax.swing.JTextField; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; + +public class ReportConfig { + public String QueryName; + public String[] Names; + public String[] Values; + public String StartLine; + public String StandStyleRowNum; + public Vector VarNameConfig = new Vector(); + public Vector CommonTableConfig = new Vector(); + public Vector CycleTableConfig = new Vector(); + public HSSFCell CalcCell; + public HSSFRow CalcRow; + public HSSFWorkbook wb; + public boolean ISCancel; + + public ReportConfig(String FileName) { + try { + FileInputStream fileInputStream = new FileInputStream(FileName); + POIFSFileSystem fs = new POIFSFileSystem(fileInputStream); + HSSFWorkbook wb = new HSSFWorkbook(fs); + this.ISCancel = false; + HSSFSheet SheetConfig1 = wb.getSheetAt(wb.getSheetIndex("Config")); + HSSFRow Sheet1Row = SheetConfig1.getRow(0); + HSSFCell Sheet1Cell = Sheet1Row.getCell(2); + this.QueryName = ReportCommon.GetCellValue(Sheet1Cell).trim(); + if (!this.QueryName.equals("")) { + Sheet1Row = SheetConfig1.getRow(1); + Sheet1Cell = Sheet1Row.getCell(2); + this.Names = ReportCommon.GetCellValue(Sheet1Cell).trim().split(";"); + Sheet1Row = SheetConfig1.getRow(2); + Sheet1Cell = Sheet1Row.getCell(2); + this.Values = ReportCommon.GetCellValue(Sheet1Cell).trim().split(";"); + if (this.Names.length > 0) { + QueryConditionDlg dlg = new QueryConditionDlg(this.Names, this.Values); + dlg.show(); + if (dlg.ISCancel) { + this.ISCancel = true; + return; + } + + ArrayList ValueFieldAry = dlg.ValueFieldAry; + + for(int i = 0; i < this.Names.length; ++i) { + this.Values[i] = ((JTextField)ValueFieldAry.get(i)).getText(); + } + } + } + + Sheet1Row = SheetConfig1.getRow(3); + Sheet1Cell = Sheet1Row.getCell(2); + this.StartLine = ReportCommon.GetCellValue(Sheet1Cell).trim(); + Sheet1Row = SheetConfig1.getRow(4); + Sheet1Cell = Sheet1Row.getCell(2); + this.StandStyleRowNum = ReportCommon.GetCellValue(Sheet1Cell).trim(); + this.CalcRow = SheetConfig1.getRow(0); + if (this.CalcRow == null) { + this.CalcRow = SheetConfig1.createRow(0); + } + + this.CalcCell = this.CalcRow.getCell(3); + if (this.CalcCell == null) { + this.CalcCell = this.CalcRow.createCell(3); + } + + for(int j = 5; j <= SheetConfig1.getLastRowNum(); ++j) { + try { + Sheet1Row = SheetConfig1.getRow(j); + Sheet1Cell = Sheet1Row.getCell(0); + String Pos = ReportCommon.GetCellValue(Sheet1Cell).trim(); + Sheet1Row = SheetConfig1.getRow(j); + Sheet1Cell = Sheet1Row.getCell(1); + String Type = ReportCommon.GetCellValue(Sheet1Cell).trim(); + Sheet1Row = SheetConfig1.getRow(j); + Sheet1Cell = Sheet1Row.getCell(2); + String Value = ReportCommon.GetCellValue(Sheet1Cell).trim(); + PreConfig precfg = new PreConfig(Pos, Type, Value); + if (Pos.indexOf("%") >= 0) { + precfg.Pos = precfg.Pos.replaceAll("%", ""); + this.VarNameConfig.add(precfg); + } else if (ReportCommon.GetNum(Pos).length() > 0) { + this.CommonTableConfig.add(precfg); + } else { + this.CycleTableConfig.add(precfg); + } + } catch (Exception var13) { + } + } + + fileInputStream.close(); + wb = null; + } catch (Exception var14) { + this.wb = null; + } + + } +} diff --git a/src/com/caxaviews/exportdataset/Shannom.java b/src/com/caxaviews/exportdataset/Shannom.java new file mode 100644 index 0000000..92165d1 --- /dev/null +++ b/src/com/caxaviews/exportdataset/Shannom.java @@ -0,0 +1,130 @@ +package com.caxaviews.exportdataset; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import java.math.BigDecimal; +import java.util.ArrayList; + +public class Shannom { + public String path() { + AIFDesktop desk = AIFDesktop.getActiveDesktop(); + AbstractAIFUIApplication app = desk.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + String ReportTemplatePath = this.GetPreference(session, "UDSBatchExportDrawing"); + ReportTemplatePath.equals(""); + return ReportTemplatePath; + } + + public String GetPreference(TCSession session, String PreferenceName) { + try { + TCPreferenceService PreferService = session.getPreferenceService(); + String UDSCodeConfigPath = PreferService.getString(1, PreferenceName); + if (UDSCodeConfigPath == null || UDSCodeConfigPath.equals("")) { + UDSCodeConfigPath = PreferService.getString(4, PreferenceName); + } + + if (UDSCodeConfigPath != null && !UDSCodeConfigPath.equals("")) { + return UDSCodeConfigPath; + } else { + System.out.println("ûҵѡ:" + PreferenceName); + return ""; + } + } catch (Exception var5) { + var5.printStackTrace(); + return ""; + } + } + + public String currentUser() { + String userName = ""; + AIFDesktop desk = AIFDesktop.getActiveDesktop(); + AbstractAIFUIApplication app = desk.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + userName = session.getUserName(); + return userName; + } + + public BigDecimal GetRollUpNum(TCComponentBOMLine SelComp) { + try { + TCComponentBOMLine ParentBOMLine = SelComp.parent(); + if (ParentBOMLine == null) { + return new BigDecimal("1"); + } else { + String bl_quantity = SelComp.getProperty("bl_quantity"); + if (bl_quantity == null || bl_quantity.length() == 0) { + bl_quantity = "1"; + } + + BigDecimal RollupBig; + for(RollupBig = (new Shannom()).GetBigDecimal(bl_quantity); ParentBOMLine != null; ParentBOMLine = ParentBOMLine.parent()) { + BigDecimal ParentBig = this.GetRollUpNum(ParentBOMLine); + RollupBig = RollupBig.multiply(ParentBig); + System.out.println("hehe" + ParentBOMLine.getItem().getProperty("item_id")); + System.out.println("" + RollupBig.toString()); + } + + return RollupBig; + } + } catch (Exception var6) { + var6.printStackTrace(); + return new BigDecimal("1"); + } + } + + public BigDecimal GetBigDecimal(String Value) { + try { + BigDecimal S1 = new BigDecimal(Value); + return S1; + } catch (Exception var3) { + return new BigDecimal("0"); + } + } + + public int getRoll(OneLineExcel SelBean) throws NumberFormatException, TCException { + TCComponentBOMLine currentLine = (TCComponentBOMLine)AIFUtility.getCurrentApplication().getTargetComponent(); + String currentQuantity = currentLine.getProperty("bl_quantity"); + if (currentQuantity == null || currentQuantity.equals("") || currentQuantity.equals("0")) { + currentQuantity = "1"; + } + + String totalNum_str = SelBean.quantity; + int totalNum; + if (totalNum_str != null && !SelBean.quantity.equals("") && !SelBean.quantity.equals("0")) { + totalNum = Integer.parseInt(totalNum_str); + } else { + totalNum = 1; + } + + ArrayList numArray = new ArrayList(); + TCComponentBOMLine parentCpm = SelBean.bomline.parent(); + if (currentLine != SelBean.bomline) { + while(true) { + if (currentLine == parentCpm) { + numArray.add(currentQuantity); + if (numArray.size() != 0) { + for(int i = 0; i < numArray.size(); ++i) { + totalNum *= Integer.parseInt((String)numArray.get(i)); + } + } + break; + } + + String parentNum = ""; + parentNum = parentCpm.getProperty("bl_quantity"); + if (parentNum == null || parentNum.equals("") || parentNum.equals("0")) { + parentNum = "1"; + } + + numArray.add(parentNum); + parentCpm = parentCpm.parent(); + } + } + + return totalNum; + } +} diff --git a/src/com/caxaviews/util/Common.java b/src/com/caxaviews/util/Common.java new file mode 100644 index 0000000..41cbb1a --- /dev/null +++ b/src/com/caxaviews/util/Common.java @@ -0,0 +1,127 @@ +package com.caxaviews.util; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.output.Format; +import org.jdom2.output.XMLOutputter; + +public class Common { + public static void printX(TCComponentItemRevision itemRevision, String datasetName, TCComponentDataset component) { + Element root = new Element("root"); + Document document = new Document(root); + + try { + TCComponentItem item = itemRevision.getItem(); + root.addContent((new Element("ItemRevUID")).setText(itemRevision.getUid())); + root.addContent((new Element("ItemID")).setText(item.getProperty("current_id"))); + if (!itemRevision.getProperty("u2_material").equals("")) { + root.addContent((new Element("u2_material")).setText(itemRevision.getProperty("u2_material"))); + } + + if (!itemRevision.getProperty("u2_mass").equals("")) { + root.addContent((new Element("u2_mass")).setText(itemRevision.getProperty("u2_mass"))); + } + + if (!itemRevision.getProperty("u2_originalNo").equals("")) { + root.addContent((new Element("u2_originalNo")).setText(itemRevision.getProperty("u2_originalNo"))); + } + + if (!itemRevision.getProperty("u2_objectModel").equals("")) { + root.addContent((new Element("u2_objectModel")).setText(itemRevision.getProperty("u2_objectModel"))); + } + + if (!item.getProperty("current_name").equals("")) { + root.addContent((new Element("object_name")).setText(item.getProperty("current_name"))); + } + + if (!itemRevision.getProperty("item_revision_id").equals("")) { + root.addContent((new Element("item_revision_id")).setText(itemRevision.getProperty("item_revision_id"))); + } + } catch (Exception var12) { + MessageBox.post(var12.getLocalizedMessage(), "", 1); + var12.printStackTrace(); + return; + } + + Format format = Format.getPrettyFormat(); + format.setEncoding("gbk"); + format.setIndent(" "); + XMLOutputter XMLOut = new XMLOutputter(format); + + try { + String filePath = "C:/CAXATemp"; + File file = new File(filePath); + if (!file.exists()) { + file.mkdir(); + } + + FileOutputStream fileOut = new FileOutputStream(filePath + "/" + datasetName + "_" + component.getUid() + ".xml"); + XMLOut.output(document, fileOut); + fileOut.flush(); + fileOut.close(); + } catch (FileNotFoundException var10) { + var10.printStackTrace(); + } catch (IOException var11) { + var11.printStackTrace(); + } + + } + + public static String GetPreference(String PreferenceName) { + try { + TCSession session = (TCSession)AIFUtility.getDefaultSession(); + TCPreferenceService PreferService = session.getPreferenceService(); + String UDSCodeConfigPath = PreferService.getString(1, PreferenceName); + if (UDSCodeConfigPath == null || UDSCodeConfigPath.equals("")) { + UDSCodeConfigPath = PreferService.getString(3, PreferenceName); + } + + if (UDSCodeConfigPath == null || UDSCodeConfigPath.equals("")) { + UDSCodeConfigPath = PreferService.getString(4, PreferenceName); + } + + if (UDSCodeConfigPath != null && !UDSCodeConfigPath.equals("")) { + return UDSCodeConfigPath; + } else { + System.out.println("ûҵѡ:" + PreferenceName); + return ""; + } + } catch (Exception var4) { + var4.printStackTrace(); + return ""; + } + } + + public static String[] GetPreferences(String PreferenceName) { + try { + String[] PreferencesValues = new String[0]; + TCSession session = (TCSession)AIFUtility.getDefaultSession(); + TCPreferenceService PreferService = session.getPreferenceService(); + PreferencesValues = PreferService.getStringArray(1, PreferenceName); + if (PreferencesValues == null || PreferencesValues.length == 0) { + PreferencesValues = PreferService.getStringArray(4, PreferenceName); + } + + if (PreferencesValues != null && PreferencesValues.length != 0) { + return PreferencesValues; + } else { + System.out.println("ûҵѡ:" + PreferenceName); + return new String[0]; + } + } catch (Exception var4) { + var4.printStackTrace(); + return new String[0]; + } + } +} diff --git a/src/com/caxaviews/view/CaxaForm.java b/src/com/caxaviews/view/CaxaForm.java new file mode 100644 index 0000000..533493d --- /dev/null +++ b/src/com/caxaviews/view/CaxaForm.java @@ -0,0 +1,77 @@ +package com.caxaviews.view; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.ole.win32.OleAutomation; +import org.eclipse.swt.ole.win32.OleControlSite; +import org.eclipse.swt.ole.win32.OleFrame; +import org.eclipse.swt.ole.win32.Variant; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.Shell; + +public class CaxaForm { + private static Shell shell = null; + private static OleFrame _frame = null; + private static OleControlSite _site = null; + private static OleAutomation _auto = null; + + public static int getID(String name) { + try { + int[] ids = _auto.getIDsOfNames(new String[]{name}); + System.out.println(name); + if (ids.length >= 0) { + return ids[0]; + } + } catch (RuntimeException var2) { + var2.printStackTrace(); + } + + return -1; + } + + public static Variant execute(String methodName, String path) { + int mid = getID(methodName); + System.out.println("121212121====" + mid); + if (mid < 0) { + return null; + } else { + Variant[] rtnv = new Variant[]{new Variant(path)}; + Variant retVariant = null; + + try { + retVariant = _auto.invoke(1, rtnv); + } catch (RuntimeException var6) { + var6.printStackTrace(); + } + + return retVariant; + } + } + + public static void main(String[] args) { + Display display = Display.getDefault(); + shell = new Shell(display); + shell.setSize(new Point(800, 600)); + Menu menu = new Menu(shell, 2); + shell.setMenuBar(menu); + MenuItem first = new MenuItem(menu, 0); + first.setText("first"); + _frame = new OleFrame(shell, 0); + _frame.setSize(750, 550); + _site = new OleControlSite(_frame, 65536, "CAXAVIEW.CaxaViewCtrl.1"); + _site.setSize(750, 550); + _site.doVerb(-1); + _auto = new OleAutomation(_site); + shell.open(); + execute("OpenFile", "E:\\11.exb"); + + while(!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + + display.dispose(); + } +} diff --git a/src/com/caxaviews/view/CaxaView.java b/src/com/caxaviews/view/CaxaView.java new file mode 100644 index 0000000..13201df --- /dev/null +++ b/src/com/caxaviews/view/CaxaView.java @@ -0,0 +1,295 @@ +package com.caxaviews.view; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinition; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +import java.awt.Robot; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Timer; +import java.util.TimerTask; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTException; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.ole.win32.OleAutomation; +import org.eclipse.swt.ole.win32.OleControlSite; +import org.eclipse.swt.ole.win32.OleFrame; +import org.eclipse.swt.ole.win32.Variant; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.part.ViewPart; + +public class CaxaView extends ViewPart { + private static OleFrame frame = null; + private static OleControlSite site = null; + private static OleAutomation _auto = null; + private static String tempUid = ""; + private static int count = 0; + private static int temp = 0; + protected static String def_Path = System.getProperty("java.io.tmpdir"); + public static boolean isShow = true; + public static SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm"); + public void createPartControl(Composite parent) { + System.out.println("caxaView1"); + parent.setLayout(new FillLayout()); + Text t = new Text(parent, 65536); + t.setBackground(parent.getDisplay().getSystemColor(1)); + t.setForeground(parent.getDisplay().getSystemColor(9)); + Font initialFont = t.getFont(); + FontData[] fontData = initialFont.getFontData(); + for(int i = 0; i < fontData.length; ++i) { + fontData[i].setHeight(18); + } + temp = 0; + Font newFont = new Font(parent.getDisplay(), fontData); + t.setFont(newFont); + t.setText("鿴CAXAͼֽ"); + IWorkbenchPage page = this.getSite().getPage(); + page.addSelectionListener(new CaxaView.select(parent, t)); + } + + protected void CAXAView(Composite parent, Text t, Object is) { + if (is != null) { + try { + TCComponent component = null; + if (is instanceof AIFComponentContext) { + AIFComponentContext context = (AIFComponentContext)is; + component = (TCComponent)context.getComponent(); + } + + if (component.getType().toString().equals("U2_EXB")) { + isShow = true; + TCComponentDataset dataset = (TCComponentDataset)component; + File fileDir = new File(def_Path.trim() + "\\CAXADir\\"); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + String[] filenames = fileDir.list(); + String filename = ""; + String[] var12 = filenames; + int var11 = filenames.length; + for(int var10 = 0; var10 < var11; ++var10) { + String name = var12[var10]; + if (name.contains(dataset.getUid())) { + filename = name; + break; + } + } + File oldFile = new File(def_Path.trim() + "\\CAXADir\\" + filename); + String nowdate = formatter.format(new Date()); + if (oldFile.exists() && !filename.equals("")) { + long last_mod_date = Long.valueOf(dataset.getProperty("last_mod_date").replace("-", "").replace(":", "").replace(" ", "").trim()); + long tempEXB_date = Long.valueOf(filename.replace(dataset.getUid() + ".exb", "").trim()); + if (tempEXB_date >= last_mod_date) { + isShow = false; + } + } + if (tempUid.equals("") || !tempUid.equals(dataset.getUid())) { + isShow = true; + } + if (isShow) { + tempUid = dataset.getUid(); + String object_name = dataset.getProperty("object_name"); + object_name = object_name.replace(".exb", "").trim(); + if (MyJFrame.readtxt().trim().length() != 0) { + def_Path = MyJFrame.readtxt(); + } + if (oldFile != null) { + oldFile.delete(); + } + File file = DatasetFileToLocalDir(dataset, def_Path.trim() + "\\CAXADir\\"); + File newFile = new File(file.getParent() + File.separator + nowdate + dataset.getUid() + ".exb"); + file.renameTo(newFile); + if (newFile != null) { + if (t.getVisible()) { + t.setVisible(false); + } + this.exbView(parent, newFile.getAbsolutePath()); + } + } + } else { + if (frame != null) { + frame.dispose(); + } + tempUid = ""; + boolean bo = t.getVisible(); + if (!bo) { + parent.setLayout(new FillLayout()); + t.setVisible(true); + } + t.setText(is.toString()); + count = 0; + tempUid = ""; + } + } catch (Exception var15) { + var15.printStackTrace(); + } + } + } + protected void exbView(Composite parent, String path) { + if (frame != null) { + frame.dispose(); + } + frame = new OleFrame(parent, 0); + frame.setBounds(0, 0, 800, 500); + frame.setVisible(true); + try { + site = new OleControlSite(frame, SWT.NONE, "CAXAVIEW.CaxaViewCtrl.1"); + site.setBounds(0, 0, 800, 500); + site.doVerb(-1); + _auto = new OleAutomation(site); + execute("OpenFile", path); + } catch (SWTException e) { + System.err.println("Failed to create Ole Control Site. Details: " + e.getMessage()); + e.printStackTrace(); + } + ++count; + } + public void setFocus() { + } + public static int getID(String name) { + try { + int[] ids = _auto.getIDsOfNames(new String[]{name}); + if (ids.length >= 0) { + return ids[0]; + } + } catch (RuntimeException var2) { + var2.printStackTrace(); + } + + return -1; + } + public static Variant execute(String methodName, String path) { + int mid = getID(methodName); + if (mid < 0) { + return null; + } else { + Variant[] rtnv = new Variant[]{new Variant(path)}; + Variant retVariant = null; + + try { + retVariant = _auto.invoke(mid, rtnv); + } catch (RuntimeException var6) { + var6.printStackTrace(); + } + + return retVariant; + } + } + public static File DatasetFileToLocalDir(TCComponentDataset componentDataset, String localDirName) { + File dirObject = new File(localDirName); + if (!dirObject.exists()) { + dirObject.mkdirs(); + } + + if (componentDataset == null) { + return null; + } else { + try { + componentDataset = componentDataset.latest(); + TCComponentDatasetDefinition Defin = componentDataset.getDatasetDefinitionComponent(); + String namedRefName = Defin.getNamedReferences()[0]; + String[] namedRefFileName = componentDataset.getFileNames(namedRefName); + if (namedRefFileName != null && namedRefFileName.length != 0) { + File tempFileObject = new File(localDirName, namedRefFileName[0]); + if (tempFileObject.exists()) { + tempFileObject.delete(); + } + + File tempFile = componentDataset.getFile(namedRefName, namedRefFileName[0], localDirName); + String DatasetName = componentDataset.getProperty("object_name"); + String PathName = tempFile.getPath(); + String ExtendName = PathName.substring(PathName.lastIndexOf("."), PathName.length()); + String DownloadFileName = null; + if (DatasetName.toLowerCase().endsWith(ExtendName.toLowerCase())) { + DownloadFileName = DatasetName; + } else { + DownloadFileName = DatasetName + ExtendName; + } + + File objectFile = new File(localDirName, DownloadFileName); + if (!objectFile.getName().equals(tempFile.getName())) { + if (objectFile.exists()) { + objectFile.delete(); + } + + tempFile.renameTo(objectFile); + } else { + objectFile = tempFile; + } + + return objectFile; + } else { + MessageBox.post("ݼûжӦ!", "ϵͳô", 1); + return null; + } + } catch (TCException var13) { + MessageBox.post("ݼô!", "ϵͳô", 1); + return null; + } catch (Exception var14) { + MessageBox.post("ݼ!", "ϵͳô", 1); + return null; + } + } + } + + + + class select implements ISelectionListener { + Composite parent; + Text t; + + public select(Composite parent, Text t) { + this.parent = parent; + this.t = t; + CaxaView.count = 0; + IViewPart viewPart = CaxaView.this.getSite().getPage().findView("com.teamcenter.rac.ui.views.SummaryView"); + if (viewPart != null) { + final Rectangle rectangle = viewPart.getViewSite().getShell().getBounds(); + if (CaxaView.temp == 0) { + Timer timer = new Timer(); + timer.schedule(new TimerTask() { + public void run() { + try { + Robot robot = new Robot(); + robot.mouseMove(rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2); + robot.mousePress(16); + robot.mouseRelease(16); + CaxaView.temp = 100; + } catch (Exception var2) { + var2.printStackTrace(); + } + + } + }, 1500L); + } + } + + } + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + if (selection instanceof StructuredSelection) { + StructuredSelection is = (StructuredSelection)selection; + Object object = is.getFirstElement(); + CaxaView.this.CAXAView(this.parent, this.t, object); + } else { + // ԴǽṹѡӡһϢ߲κβ + System.out.println("The current selection is not a structured selection."); + } + } + } +} diff --git a/src/com/caxaviews/view/GetCEXBView.java b/src/com/caxaviews/view/GetCEXBView.java new file mode 100644 index 0000000..45d28fe --- /dev/null +++ b/src/com/caxaviews/view/GetCEXBView.java @@ -0,0 +1,199 @@ +package com.caxaviews.view; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; + +public class GetCEXBView { + public static void main(String[] args) throws IOException { + String path = getViewPath(); + System.out.println(path); + + } + + private static String getViewPath1() throws IOException, + UnsupportedEncodingException { + Runtime runtime = Runtime.getRuntime(); + Process process1 = null; + // 32λ + process1 = runtime + .exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\CAXA\\CAXALiveUpdate\\"); + BufferedReader in1 = new BufferedReader(new InputStreamReader( + process1.getInputStream(), "GBK")); + String string = null; + String s32 = null; + String caxaViewPath = ""; + // 32λ + while ((s32 = in1.readLine()) != null) { + process1 = runtime.exec("cmd /c reg query " + s32 + + " /v InstallDir"); + BufferedReader name = new BufferedReader(new InputStreamReader( + process1.getInputStream(), "GBK")); + name.readLine(); + name.readLine();// ȥǰϢ + if ((caxaViewPath = name.readLine()) != null) { + caxaViewPath = caxaViewPath.replaceAll( + "InstallDir REG_SZ ", ""); // ȥϢ + } + + } + + // System.out.println(caxaViewPath); + return caxaViewPath; + } + + private static String getViewPath() throws IOException, + UnsupportedEncodingException { + Runtime runtime = Runtime.getRuntime(); + Process process1 = null; + // 32λ + process1 = runtime + .exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"); + BufferedReader in1 = new BufferedReader(new InputStreamReader( + process1.getInputStream(), "GBK")); + String string = null; + String s32 = null; + String caxaViewPath = ""; + // 32λ + while ((s32 = in1.readLine()) != null) { +// process1 = runtime.exec("cmd /c reg query " + s32 +// + " /v DisplayName"); +// BufferedReader name = new BufferedReader(new InputStreamReader( +// process1.getInputStream(), "GBK")); +// name.readLine(); +// name.readLine();// ȥǰϢ +// if ((caxaViewPath = name.readLine()) != null) { +// caxaViewPath = caxaViewPath.replaceAll( +// "DisplayVersion REG_SZ ", ""); // ȥϢ +// } + caxaViewPath = queryValue1(s32); + if(caxaViewPath.length()>0 ){ + break; + } + + } + + // System.out.println(caxaViewPath); + return caxaViewPath; + } + // ѯÿһϸϢ + private static String queryValue1(String string) throws IOException { + + String InstallLocation = ""; // װ· + + + Runtime runtime = Runtime.getRuntime(); + Process process = null; + BufferedReader br = null; + + // װ· + process = runtime.exec("cmd /c reg query " + string + + " /v InstallLocation"); + br = new BufferedReader(new InputStreamReader(process.getInputStream(), + "GBK")); + br.readLine(); + br.readLine();// ȥǰϢ + if ((InstallLocation = br.readLine()) != null) { + InstallLocation = InstallLocation.replaceAll( + "InstallLocation REG_SZ ", ""); // ȥϢ + } + if(InstallLocation!=null&&InstallLocation.contains("CAXA Shared")){ + InstallLocation=InstallLocation.split("CAXA Shared")[0]+"CAXA Shared\\CAXA CAD VIEWER\\BIN64\\CEXBVIEWER.exe"; + }else{ + InstallLocation=""; + } + return InstallLocation; + } + // ѯÿһϸϢ + private static String[] queryValue(String string) throws IOException { + String nameString = ""; // + String versionString = ""; // 汾 + + String publisherString = ""; // + String InstallLocation = ""; // װ· + String InstallDate = ""; // װʱ + + Runtime runtime = Runtime.getRuntime(); + Process process = null; + BufferedReader br = null; + // + process = runtime + .exec("cmd /c reg query " + string + " /v DisplayName"); + br = new BufferedReader(new InputStreamReader(process.getInputStream(), + "GBK")); + br.readLine(); + br.readLine();// ȥǰϢ + if ((nameString = br.readLine()) != null) { + nameString = nameString.replaceAll("DisplayName REG_SZ ", ""); // ȥϢ + } + + // 汾 + process = runtime.exec("cmd /c reg query " + string + + " /v DisplayVersion"); + br = new BufferedReader(new InputStreamReader(process.getInputStream(), + "GBK")); + br.readLine(); + br.readLine();// ȥǰϢ + if ((versionString = br.readLine()) != null) { + versionString = versionString.replaceAll( + "DisplayVersion REG_SZ ", ""); // ȥϢ + } + // + process = runtime.exec("cmd /c reg query " + string + " /v Publisher"); + br = new BufferedReader(new InputStreamReader(process.getInputStream(), + "GBK")); + br.readLine(); + br.readLine();// ȥǰϢ + if ((publisherString = br.readLine()) != null) { + publisherString = publisherString.replaceAll( + "Publisher REG_SZ ", ""); // ȥϢ + } + // װ· + process = runtime.exec("cmd /c reg query " + string + + " /v InstallLocation"); + br = new BufferedReader(new InputStreamReader(process.getInputStream(), + "GBK")); + br.readLine(); + br.readLine();// ȥǰϢ + if ((InstallLocation = br.readLine()) != null) { + InstallLocation = InstallLocation.replaceAll( + "InstallLocation REG_SZ ", ""); // ȥϢ + } + // װʱ + process = runtime + .exec("cmd /c reg query " + string + " /v InstallDate"); + br = new BufferedReader(new InputStreamReader(process.getInputStream(), + "GBK")); + br.readLine(); + br.readLine();// ȥǰϢ + if ((InstallDate = br.readLine()) != null) { + InstallDate = InstallDate.replaceAll("InstallDate REG_SZ ", + ""); // ȥϢ + } + + String[] resultString = new String[6]; + resultString[0] = nameString;// == null ? null : new + // String(nameString.getBytes(),"GB-2312"); + resultString[1] = versionString;// == null ? null : new + // String(versionString.getBytes(),"GB-2312"); + resultString[2] = publisherString;// == null ? null : new + // String(publisherString.getBytes(),"GB-2312"); + resultString[3] = InstallLocation;// == null ? null : new + // String(uninstallPathString.getBytes(),"GB-2312"); + resultString[4] = InstallDate;// == null ? null : new + // String(uninstallPathString.getBytes(),"GB-2312"); + if (nameString != null && !"".equals(nameString)) { + if ("ѶQQ".equals(nameString.trim()) + || "΢".equals(nameString.trim())) { + String instantMessaging = "";// ʱͨѶ + resultString[5] = instantMessaging; + } + } + if (resultString[0] == null) + resultString = null; // ûֵIJʾ + return resultString; + } +} diff --git a/src/com/caxaviews/view/MyJFrame.java b/src/com/caxaviews/view/MyJFrame.java new file mode 100644 index 0000000..c2a01c3 --- /dev/null +++ b/src/com/caxaviews/view/MyJFrame.java @@ -0,0 +1,88 @@ +package com.caxaviews.view; + +import com.teamcenter.rac.util.MessageBox; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.RandomAccessFile; +import javax.swing.JFileChooser; +import javax.swing.JFrame; + +public class MyJFrame { + protected static String FilePath = null; + protected static String def_path = System.getProperty("java.io.tmpdir"); + + public static String setFilePath(String oldPath) { + Double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); + Double height = Toolkit.getDefaultToolkit().getScreenSize().getHeight(); + final JFrame jf = new JFrame(); + jf.setVisible(true); + jf.setSize(500, 300); + final JFileChooser jfc = new JFileChooser(); + jfc.setVisible(true); + jfc.setSize(500, 300); + jfc.setFileSelectionMode(1); + jfc.setApproveButtonText("ȷ"); + jfc.setCurrentDirectory(new File(oldPath)); + jf.getContentPane().add(jfc); + jf.pack(); + jf.setLocation((int)((width - 500.0D) / 2.0D), (int)((height - 300.0D) / 2.0D)); + jfc.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (event.getActionCommand().equals("ApproveSelection")) { + MyJFrame.FilePath = jfc.getSelectedFile().getAbsolutePath(); + + try { + MyJFrame.writetxt(MyJFrame.FilePath); + } catch (IOException var3) { + var3.printStackTrace(); + } + + MessageBox.post("·óɹΪ" + MyJFrame.FilePath, "óɹ", 0); + jf.dispose(); + } else if (event.getActionCommand().equals("CancelSelection")) { + MyJFrame.FilePath = null; + jf.dispose(); + } + + } + }); + return null; + } + + protected static void writetxt(String filePath2) throws IOException { + File txt = new File(def_path + "\\CAXAFilePath.txt"); + if (!txt.exists()) { + txt.createNewFile(); + } + + RandomAccessFile mm = new RandomAccessFile(txt, "rw"); + mm.writeBytes(filePath2); + mm.close(); + } + + public static String readtxt() { + String oldPath = ""; + String read = null; + File file = new File(def_path + "\\CAXAFilePath.txt"); + if (file.exists()) { + try { + FileReader fr = new FileReader(file); + + for(BufferedReader br = new BufferedReader(fr); (read = br.readLine()) != null; oldPath = oldPath + read) { + } + } catch (FileNotFoundException var5) { + var5.printStackTrace(); + } catch (IOException var6) { + var6.printStackTrace(); + } + } + + return oldPath; + } +} diff --git a/src/com/caxaviews/view/OpenExcelProcess.java b/src/com/caxaviews/view/OpenExcelProcess.java new file mode 100644 index 0000000..5fcfc47 --- /dev/null +++ b/src/com/caxaviews/view/OpenExcelProcess.java @@ -0,0 +1,67 @@ +package com.caxaviews.view; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +public class OpenExcelProcess { + public static void main(String[] args) { + // Excel ļ· + String excelFilePath = "C:\\Users\\Administrator\\Desktop\\ſǼָ1.exb"; + + // ϵͳǷ Excel + boolean excelProcessExists = checkExcelProcess(); + + // Excel ̣ʹеĽ̴ļһµ Excel ̴ļ + if (excelProcessExists) { + openFileInExistingExcelProcess(excelFilePath); + } else { + openFileInNewExcelProcess(excelFilePath); + } +// openFileInNewExcelProcess(excelFilePath); + } + + // ϵͳǷ Excel + private static boolean checkExcelProcess() { + boolean excelProcessExists = false; + try { + Process process = Runtime.getRuntime().exec("tasklist /FI \"IMAGENAME eq CEXBVIEWER.exe\""); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + if (line.contains("CEXBVIEWER.exe")) { + excelProcessExists = true; + break; + } + } + reader.close(); + process.waitFor(); + } catch (Exception e) { + e.printStackTrace(); + } + return excelProcessExists; + } + + // ʹе Excel ̴ļ + private static void openFileInExistingExcelProcess(String filePath) { + try { + ProcessBuilder processBuilder = new ProcessBuilder(); + processBuilder.command("cmd.exe", "/c", "start", "C:\\Program Files\\Common Files\\CAXA Shared\\CAXA CAD VIEWER\\BIN64\\CEXBVIEWER.exe", filePath); + processBuilder.start(); + System.out.println("ļе Excel д򿪡"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + // һµ Excel ̴ļ + private static void openFileInNewExcelProcess(String filePath) { + try { + ProcessBuilder processBuilder = new ProcessBuilder(); + processBuilder.command("cmd.exe", "/c", "start", "C:\\Program Files\\Common Files\\CAXA Shared\\CAXA CAD VIEWER\\BIN64\\CEXBVIEWER.exe", "/r", filePath); + processBuilder.start(); + System.out.println("ļµ Excel д򿪡"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/caxaviews/view/PDFViewer.java b/src/com/caxaviews/view/PDFViewer.java new file mode 100644 index 0000000..6e9650a --- /dev/null +++ b/src/com/caxaviews/view/PDFViewer.java @@ -0,0 +1,155 @@ +//package com.caxaviews.view; +// +//import java.io.File; +//import java.util.List; +// +//import org.eclipse.swt.events.ControlAdapter; +//import org.eclipse.swt.events.ControlEvent; +//import org.eclipse.swt.graphics.Rectangle; +//import org.eclipse.swt.internal.win32.OS; +//import org.eclipse.swt.internal.win32.SHELLEXECUTEINFO; +//import org.eclipse.swt.internal.win32.TCHAR; +//import org.eclipse.swt.layout.FillLayout; +//import org.eclipse.swt.widgets.Composite; +//import org.eclipse.ui.IWorkbenchPart; +// +//import com.teamcenter.rac.aif.kernel.AIFComponentContext; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.kernel.TCComponentDataset; +//import com.teamcenter.rac.ui.views.AbstractContentViewPart; +// +//@SuppressWarnings("restriction") +//public class PDFViewer extends AbstractContentViewPart { +// long hwnd = 0; +// private Composite composite; +// private Object currentObj = null; +// +// @Override +// protected void processEmptySelection(IWorkbenchPart iWorkbenchPart, List list) { +// if (list.size() != 1) { +// return; +// } +// Object target = list.get(0); +// if (target != null && !(target.equals(currentObj))) { +// try { +// changePDF(target); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// } +// +// public PDFViewer() { +// this.setProcessNullSelectionsEnabled(true); +// this.setUseScrolledForm(false); +// this.setShowHeader(true); +// this.setMultiSelectionSupported(true); +// this.setUISupportsAssociate(false); +// this.setUISupportsSetScope(true); +// this.setUISupportsViewLocking(true); +// this.setUseInitialInputJobEnabled(false); +// this.setProcessSelectionFromSiblingViewEnabled(true); +// +// } +// +// @Override +// protected void createContent(Composite composite) { +// this.composite = composite; +// // composite.setBackground(sShell.getDisplay().getSystemColor(SWT.COLOR_BLACK)); +// composite.setBounds(0, 0, 800, 600); +// composite.setLayout(new FillLayout()); +// composite.addControlListener(new ControlAdapter() { +// public void controlResized(ControlEvent e) { +// if (hwnd != 0) { +// Rectangle cRect = ((Composite) (e.widget)).getClientArea(); +// // ȫ +// OS.SetWindowPos(hwnd, 0, 0, 0, cRect.width, cRect.height, OS.SWP_NOZORDER | OS.SWP_NOACTIVATE | OS.SWP_ASYNCWINDOWPOS); +// } +// } +// }); +// } +// +// private void changePDF(Object target) throws Exception { +// if (!(target instanceof AIFComponentContext)) { +// return; +// } +// InterfaceAIFComponent comp = ((AIFComponentContext) target).getComponent(); +// if (comp instanceof TCComponentDataset) { +// TCComponentDataset dataset = (TCComponentDataset) comp; +// if (dataset.isTypeOf("PDF")) { +// System.out.println("PDFļ" + dataset); +// String path = System.getenv("temp"); +// if (path == null) { +// path = "C:\\TEMP\\"; +// } +// File[] files = dataset.getFiles("", path); +// if (files != null && files.length > 0) { +// // System.out.println(files[0]); +// startExe(files[0]); +// +// } +// } +// } +// currentObj = target; +// +// } +// +// private boolean executeProgess(String fileName, String openFile) throws Exception { +// long hHeap = OS.GetProcessHeap(); +// TCHAR buffer = new TCHAR(0, fileName, true); +// int byteCount = buffer.length() * TCHAR.sizeof; +// long lpFile = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount); +// OS.MoveMemory(lpFile, buffer, byteCount); +// +// TCHAR actionBuffer = new TCHAR(0, "open", true); +// int actionByteCouont = actionBuffer.length() * TCHAR.sizeof; +// long actionAlloc = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, actionByteCouont); +// OS.MoveMemory(actionAlloc, actionBuffer, actionByteCouont); +// +// TCHAR openFileBuffer = new TCHAR(0, openFile, true); +// int openFileByteCount = openFileBuffer.length() * TCHAR.sizeof; +// long openFileAlloc = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, openFileByteCount); +// OS.MoveMemory(openFileAlloc, openFileBuffer, openFileByteCount); +// +// SHELLEXECUTEINFO info = new SHELLEXECUTEINFO(); +// info.cbSize = SHELLEXECUTEINFO.sizeof; +// info.lpFile = lpFile; +// info.lpVerb = actionAlloc; +// info.lpParameters = openFileAlloc; +// // +// info.nShow = OS.SW_HIDE; +// +// boolean result = OS.ShellExecuteEx(info); +// if (lpFile != 0) +// OS.HeapFree(hHeap, 0, lpFile); +// return result; +// } +// +// protected void startExe(File file) throws Exception { +// // ر֮ǰĴ +// if (hwnd != 0) { +// OS.SendMessage(hwnd, OS.WM_SYSCOMMAND, OS.SC_CLOSE, 0); +// hwnd = 0; +// } +// // PDF +// String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); +// String exePath = path.substring(1, path.indexOf("com.connor.pdfviewer")).replace("/", "\\"); +// executeProgess(exePath + "SumatraPDF.exe", file.getAbsolutePath()); +// // ȡ +// while (hwnd == 0) { +// hwnd = OS.FindWindow(new TCHAR(0, "SUMATRA_PDF_FRAME", true), null); // Notepad,rsedc_wclass +// Thread.sleep(10); +// } +// System.out.println("hwnd = " + hwnd); +// // &~WS_BORDERȥǶ߿һǶijҪʾ߿дɾ +// int oldStyle = OS.GetWindowLong(hwnd, OS.GWL_STYLE); +// OS.SetWindowLong(hwnd, OS.GWL_STYLE, oldStyle & ~OS.WS_BORDER); +// // compositeΪرĿؼ +// OS.SetParent(hwnd, composite.handle); +// // +// OS.SendMessage(hwnd, OS.WM_SYSCOMMAND, OS.SC_MAXIMIZE, 0); +// } +// +// +// +//} diff --git a/src/com/caxaviews/view/SystemSoftware.java b/src/com/caxaviews/view/SystemSoftware.java new file mode 100644 index 0000000..7d81a38 --- /dev/null +++ b/src/com/caxaviews/view/SystemSoftware.java @@ -0,0 +1,214 @@ +package com.caxaviews.view; +/** + * @author kevin.long + * @description Javaȡϵͳװб,,ҪͨRuntimeʵ, + * JNIҲ, + */ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextPane; + +public class SystemSoftware { + private JFrame f = new JFrame("ϵͳѾװб"); + private JTextPane textPane = new JTextPane(); + private MyTable myTable=new MyTable(); + public static Charset charset = Charset.forName("GBK"); + public SystemSoftware() { + f.setLocation(300, 200); + f.setSize(800,500); + JScrollPane jScrollPane = new JScrollPane(myTable.getTable()); + f.add(jScrollPane); + f.setVisible(true); + f.setDefaultCloseOperation(f.EXIT_ON_CLOSE); + + try { + check(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void check() throws Exception { + textPane.setText("Ѿװ"); + Runtime runtime = Runtime.getRuntime(); + Process process = null; + Process process1 = null; + //64λ + process = runtime.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"); + //32λ + process1 = runtime.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"); + //HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall + BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream(),"GBK")); + BufferedReader in1 = new BufferedReader(new InputStreamReader(process1.getInputStream(),"GBK")); + String string = null; + String s32 = null; + + List list64 = new ArrayList(); + List list32 = new ArrayList(); + List list = new ArrayList(); + + + while ((string = in.readLine()) != null) { + process = runtime.exec("cmd /c reg query " + string + + " /v DisplayName"); + BufferedReader name = new BufferedReader(new InputStreamReader( + process.getInputStream(),"GBK")); + String[] message = queryValue(string); + if(message!=null){ + myTable.addRow(message); + //list64.add(message); + } + f.repaint(); + } + //32λ + while ((s32 = in1.readLine()) != null) { + process1 = runtime.exec("cmd /c reg query " + s32 + + " /v DisplayName"); + BufferedReader name = new BufferedReader(new InputStreamReader( + process1.getInputStream(),"GBK")); + String[] message = queryValue(s32); + if(message!=null){ + myTable.addRow(message); + // list32.add(message); + } + f.repaint(); + } + /*for(Object[] obj64:list64){ + list.add(obj64); + } + for(Object[] obj32:list32){ + boolean flag=false; + for(Object[] obj64:list64){ + if(Arrays.equals(obj32, obj64)){ + flag=true; + } + } + if(!flag){ + list.add(obj32); + } + } + for(Object[] obj:list){ + myTable.addRow(obj); + f.repaint(); + }*/ + + + + in.close(); + in1.close(); + process.destroy(); + process1.destroy(); + + } + + //ѯÿһϸϢ + private String[] queryValue(String string) throws IOException { + String nameString = ""; // + String versionString = ""; //汾 + + String publisherString=""; // + String InstallLocation = ""; //װ· + String InstallDate = ""; //װʱ + + + Runtime runtime = Runtime.getRuntime(); + Process process = null; + BufferedReader br = null; + // + process = runtime.exec("cmd /c reg query " + string + " /v DisplayName"); + br = new BufferedReader(new InputStreamReader(process + .getInputStream(),"GBK")); + br.readLine();br.readLine();//ȥǰϢ + if((nameString=br.readLine())!=null){ + nameString=nameString.replaceAll("DisplayName REG_SZ ", ""); //ȥϢ + } + + //汾 + process = runtime.exec("cmd /c reg query " + string + " /v DisplayVersion"); + br = new BufferedReader(new InputStreamReader(process + .getInputStream(),"GBK")); + br.readLine();br.readLine();//ȥǰϢ + if((versionString=br.readLine())!=null){ + versionString=versionString.replaceAll("DisplayVersion REG_SZ ", ""); //ȥϢ + } + // + process = runtime.exec("cmd /c reg query " + string + " /v Publisher"); + br = new BufferedReader(new InputStreamReader(process + .getInputStream(),"GBK")); + br.readLine();br.readLine();//ȥǰϢ + if((publisherString=br.readLine())!=null){ + publisherString =publisherString.replaceAll("Publisher REG_SZ ", ""); //ȥϢ + } + //װ· + process = runtime.exec("cmd /c reg query " + string + " /v InstallLocation"); + br = new BufferedReader(new InputStreamReader(process + .getInputStream(),"GBK")); + br.readLine();br.readLine();//ȥǰϢ + if((InstallLocation=br.readLine())!=null){ + InstallLocation=InstallLocation.replaceAll("InstallLocation REG_SZ ", ""); //ȥϢ + } + //װʱ + process = runtime.exec("cmd /c reg query " + string + " /v InstallDate"); + br = new BufferedReader(new InputStreamReader(process + .getInputStream(),"GBK")); + br.readLine();br.readLine();//ȥǰϢ + if((InstallDate=br.readLine())!=null){ + InstallDate=InstallDate.replaceAll("InstallDate REG_SZ ", ""); //ȥϢ + } + + String[] resultString=new String[6]; + resultString[0]= nameString ;//== null ? null : new String(nameString.getBytes(),"GB-2312"); + resultString[1]= versionString ;//== null ? null : new String(versionString.getBytes(),"GB-2312"); + resultString[2]= publisherString ;//== null ? null : new String(publisherString.getBytes(),"GB-2312"); + resultString[3]= InstallLocation ;//== null ? null : new String(uninstallPathString.getBytes(),"GB-2312"); + resultString[4]= InstallDate ;//== null ? null : new String(uninstallPathString.getBytes(),"GB-2312"); + if(nameString !=null && !"".equals(nameString)){ + if("ѶQQ".equals(nameString.trim()) || "΢".equals(nameString.trim())){ + String instantMessaging="";//ʱͨѶ + resultString[5]=instantMessaging; + } + } + if(resultString[0]==null) resultString=null; //ûֵIJʾ + return resultString; + } + + //б + private class MyTable{ + private JTable jTable; + private Object[][] data=new Object[220][6]; + private Object[] colNames= { "","汾","","װ·","װʱ","ʱͨѶ"}; + private int p=-1; + + public MyTable(){ + + } + public void addRow(Object[] data){ + p++; + if(p>=220) return ; + this.data[p]=data; + } + public JTable getTable(){ + + + + jTable=new JTable(data,colNames); + return jTable; + } + + } + + public static void main(String[] args) { + new SystemSoftware(); + /* int[] a={1,2,3,4}; + int[] b={1,2,3,4,5}; + System.out.println(Arrays.equals(a, b));*/ + } +} diff --git a/src/com/caxaviews/view/Testzcb.java b/src/com/caxaviews/view/Testzcb.java new file mode 100644 index 0000000..815d62f --- /dev/null +++ b/src/com/caxaviews/view/Testzcb.java @@ -0,0 +1,42 @@ +package com.caxaviews.view; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; +public class Testzcb { + + + public static void main(String[] args) throws BackingStoreException { +// Preferences root = Preferences.userRoot(); +// String value= root.get("HKEY_USERS\\S-1-5-21-1847647819-1614280485-1362812710-500_Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache", "C:\\Program Files\\Common Files\\CAXA Shared\\CAXA CAD VIEWER\\BIN64\\CEXBVIEWER.exe"); +// System.out.println(value); + String sss = "cmd /c \"C:\\Program Files\\Common Files\\CAXA Shared\\CAXA CAD VIEWER\\BIN64\\CEXBVIEWER.exe\" "; + sss=sss+"C:\\Users\\Administrator\\Desktop\\ſǼָ.exb"; + exeCmd(sss); + + } + private static void exeCmd(String cmdCode) { + BufferedReader br = null; + try { + Process p = Runtime.getRuntime().exec(cmdCode); + br = new BufferedReader(new InputStreamReader(p.getInputStream(), "GBK")); + String line; + StringBuilder sb = new StringBuilder(); + while ((line = br.readLine()) != null) { + sb.append(line); + sb.append("\n"); + } + System.out.println(sb.toString()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } diff --git a/src/com/caxaviews/view/ViewExbHandler.java b/src/com/caxaviews/view/ViewExbHandler.java new file mode 100644 index 0000000..fdc9938 --- /dev/null +++ b/src/com/caxaviews/view/ViewExbHandler.java @@ -0,0 +1,179 @@ +package com.caxaviews.view; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.jd.plm.action.BOMManagementAction; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; + +public class ViewExbHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + // ãȻ + TCComponent dataset = (TCComponent) app.getTargetComponent(); + String path = downLoadFile(dataset); + String viewPath = ""; + try { + viewPath = getViewPath(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + if(viewPath.length()>0){ + System.out.println(viewPath); + + String sss = "cmd /c \"" + viewPath + "\" "; + sss = sss + path; + System.out.println(sss); + exeCmd(sss); + }else{ + MessageBox.post("ǷװCAXA CAD2016(x64)","",MessageBox.INFORMATION); + } + return null; + } + + private String getViewPath() throws IOException, + UnsupportedEncodingException { + Runtime runtime = Runtime.getRuntime(); + Process process1 = null; + // 32λ + process1 = runtime + .exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"); + BufferedReader in1 = new BufferedReader(new InputStreamReader( + process1.getInputStream(), "GBK")); + String string = null; + String s32 = null; + String caxaViewPath = ""; + // 32λ + while ((s32 = in1.readLine()) != null) { + caxaViewPath = queryValue1(s32).trim(); + if (caxaViewPath.length() > 0) { + break; + } + } + return caxaViewPath; + } + + // ѯÿһϸϢ + private String queryValue1(String string) throws IOException { + + String InstallLocation = ""; // װ· + + Runtime runtime = Runtime.getRuntime(); + Process process = null; + BufferedReader br = null; + + // װ· + process = runtime.exec("cmd /c reg query " + string + + " /v InstallLocation"); + br = new BufferedReader(new InputStreamReader(process.getInputStream(), + "GBK")); + br.readLine(); + br.readLine();// ȥǰϢ + if ((InstallLocation = br.readLine()) != null) { + InstallLocation = InstallLocation.replaceAll( + "InstallLocation REG_SZ ", ""); // ȥϢ + } + if (InstallLocation != null && InstallLocation.contains("CAXA Shared")) { + InstallLocation = InstallLocation.split("CAXA Shared")[0] + + "CAXA Shared\\CAXA CAD VIEWER\\BIN64\\CEXBVIEWER.exe"; + } else { + InstallLocation = ""; + } + return InstallLocation; + } + + private void exeCmd(String cmdCode) { + BufferedReader br = null; + try { + Process p = Runtime.getRuntime().exec(cmdCode); + // br = new BufferedReader(new InputStreamReader(p.getInputStream(), + // "GBK")); + // String line; + // StringBuilder sb = new StringBuilder(); + // while ((line = br.readLine()) != null) { + // sb.append(line); + // sb.append("\n"); + // } + // System.out.println(sb.toString()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + /** + * ļ + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public String downLoadFile(TCComponent comp) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + return fileName; + } + } + } catch (TCException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return value; + } + +} diff --git a/src/com/caxaviews/view/WinRegistry.java b/src/com/caxaviews/view/WinRegistry.java new file mode 100644 index 0000000..81e9199 --- /dev/null +++ b/src/com/caxaviews/view/WinRegistry.java @@ -0,0 +1,388 @@ +package com.caxaviews.view; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.ArrayList; +import java.util.List; +import java.util.prefs.Preferences; + +public class WinRegistry { + public static final int HKEY_CURRENT_USER = 0x80000001; + public static final int HKEY_LOCAL_MACHINE = 0x80000002; + public static final int REG_SUCCESS = 0; + public static final int REG_NOTFOUND = 2; + public static final int REG_ACCESSDENIED = 5; + + private static final int KEY_ALL_ACCESS = 0xf003f; + private static final int KEY_READ = 0x20019; + private static final Preferences userRoot = Preferences.userRoot(); + private static final Preferences systemRoot = Preferences.systemRoot(); + private static final Class userClass = userRoot.getClass(); + private static final Method regOpenKey; + private static final Method regCloseKey; + private static final Method regQueryValueEx; + private static final Method regEnumValue; + private static final Method regQueryInfoKey; + private static final Method regEnumKeyEx; + private static final Method regCreateKeyEx; + private static final Method regSetValueEx; + private static final Method regDeleteKey; + private static final Method regDeleteValue; + + static { + try { + regOpenKey = userClass.getDeclaredMethod("WindowsRegOpenKey", + new Class[] { int.class, byte[].class, int.class }); + regOpenKey.setAccessible(true); + regCloseKey = userClass.getDeclaredMethod("WindowsRegCloseKey", + new Class[] { int.class }); + regCloseKey.setAccessible(true); + regQueryValueEx = userClass.getDeclaredMethod("WindowsRegQueryValueEx", + new Class[] { int.class, byte[].class }); + regQueryValueEx.setAccessible(true); + regEnumValue = userClass.getDeclaredMethod("WindowsRegEnumValue", + new Class[] { int.class, int.class, int.class }); + regEnumValue.setAccessible(true); + regQueryInfoKey = userClass.getDeclaredMethod("WindowsRegQueryInfoKey1", + new Class[] { int.class }); + regQueryInfoKey.setAccessible(true); + regEnumKeyEx = userClass.getDeclaredMethod( + "WindowsRegEnumKeyEx", new Class[] { int.class, int.class, + int.class }); + regEnumKeyEx.setAccessible(true); + regCreateKeyEx = userClass.getDeclaredMethod( + "WindowsRegCreateKeyEx", new Class[] { int.class, + byte[].class }); + regCreateKeyEx.setAccessible(true); + regSetValueEx = userClass.getDeclaredMethod( + "WindowsRegSetValueEx", new Class[] { int.class, + byte[].class, byte[].class }); + regSetValueEx.setAccessible(true); + regDeleteValue = userClass.getDeclaredMethod( + "WindowsRegDeleteValue", new Class[] { int.class, + byte[].class }); + regDeleteValue.setAccessible(true); + regDeleteKey = userClass.getDeclaredMethod( + "WindowsRegDeleteKey", new Class[] { int.class, + byte[].class }); + regDeleteKey.setAccessible(true); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + + private WinRegistry() { } + + /** + * Read a value from key and value name + * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE + * @param key + * @param valueName + * @return the value + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + */ + public static String readString(int hkey, String key, String valueName) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + if (hkey == HKEY_LOCAL_MACHINE) { + return readString(systemRoot, hkey, key, valueName); + } + else if (hkey == HKEY_CURRENT_USER) { + return readString(userRoot, hkey, key, valueName); + } + else { + throw new IllegalArgumentException("hkey=" + hkey); + } + } + + /** + * Read value(s) and value name(s) form given key + * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE + * @param key + * @return the value name(s) plus the value(s) + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + */ + public static Map readStringValues(int hkey, String key) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + if (hkey == HKEY_LOCAL_MACHINE) { + return readStringValues(systemRoot, hkey, key); + } + else if (hkey == HKEY_CURRENT_USER) { + return readStringValues(userRoot, hkey, key); + } + else { + throw new IllegalArgumentException("hkey=" + hkey); + } + } + + /** + * Read the value name(s) from a given key + * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE + * @param key + * @return the value name(s) + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + */ + public static List readStringSubKeys(int hkey, String key) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + if (hkey == HKEY_LOCAL_MACHINE) { + return readStringSubKeys(systemRoot, hkey, key); + } + else if (hkey == HKEY_CURRENT_USER) { + return readStringSubKeys(userRoot, hkey, key); + } + else { + throw new IllegalArgumentException("hkey=" + hkey); + } + } + + /** + * Create a key + * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE + * @param key + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + */ + public static void createKey(int hkey, String key) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + int [] ret; + if (hkey == HKEY_LOCAL_MACHINE) { + ret = createKey(systemRoot, hkey, key); + regCloseKey.invoke(systemRoot, new Object[] { new Integer(ret[0]) }); + } + else if (hkey == HKEY_CURRENT_USER) { + ret = createKey(userRoot, hkey, key); + regCloseKey.invoke(userRoot, new Object[] { new Integer(ret[0]) }); + } + else { + throw new IllegalArgumentException("hkey=" + hkey); + } + if (ret[1] != REG_SUCCESS) { + throw new IllegalArgumentException("rc=" + ret[1] +" key=" + key); + } + } + + /** + * Write a value in a given key/value name + * @param hkey + * @param key + * @param valueName + * @param value + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + */ + public static void writeStringValue + (int hkey, String key, String valueName, String value) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + if (hkey == HKEY_LOCAL_MACHINE) { + writeStringValue(systemRoot, hkey, key, valueName, value); + } + else if (hkey == HKEY_CURRENT_USER) { + writeStringValue(userRoot, hkey, key, valueName, value); + } + else { + throw new IllegalArgumentException("hkey=" + hkey); + } + } + + /** + * Delete a given key + * @param hkey + * @param key + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + */ + public static void deleteKey(int hkey, String key) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + int rc = -1; + if (hkey == HKEY_LOCAL_MACHINE) { + rc = deleteKey(systemRoot, hkey, key); + } + else if (hkey == HKEY_CURRENT_USER) { + rc = deleteKey(userRoot, hkey, key); + } + if (rc != REG_SUCCESS) { + throw new IllegalArgumentException("rc=" + rc +" key=" + key); + } + } + + /** + * delete a value from a given key/value name + * @param hkey + * @param key + * @param value + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + */ + public static void deleteValue(int hkey, String key, String value) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + int rc = -1; + if (hkey == HKEY_LOCAL_MACHINE) { + rc = deleteValue(systemRoot, hkey, key, value); + } + else if (hkey == HKEY_CURRENT_USER) { + rc = deleteValue(userRoot, hkey, key, value); + } + if (rc != REG_SUCCESS) { + throw new IllegalArgumentException("rc=" + rc +" key=" + key +" value=" + value); + } + } + + // ===================== + + private static int deleteValue + (Preferences root, int hkey, String key, String value) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + int[] handles = (int[]) regOpenKey.invoke(root, new Object[] { + new Integer(hkey), toCstr(key), new Integer(KEY_ALL_ACCESS) }); + if (handles[1] != REG_SUCCESS) { + return handles[1]; // can be REG_NOTFOUND, REG_ACCESSDENIED + } + int rc =((Integer) regDeleteValue.invoke(root, + new Object[] { + new Integer(handles[0]), toCstr(value) + })).intValue(); + regCloseKey.invoke(root, new Object[] { new Integer(handles[0]) }); + return rc; + } + + private static int deleteKey(Preferences root, int hkey, String key) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + int rc =((Integer) regDeleteKey.invoke(root, + new Object[] { new Integer(hkey), toCstr(key) })).intValue(); + return rc; // can REG_NOTFOUND, REG_ACCESSDENIED, REG_SUCCESS + } + + private static String readString(Preferences root, int hkey, String key, String value) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + int[] handles = (int[]) regOpenKey.invoke(root, new Object[] { + new Integer(hkey), toCstr(key), new Integer(KEY_READ) }); + if (handles[1] != REG_SUCCESS) { + return null; + } + byte[] valb = (byte[]) regQueryValueEx.invoke(root, new Object[] { + new Integer(handles[0]), toCstr(value) }); + regCloseKey.invoke(root, new Object[] { new Integer(handles[0]) }); + return (valb != null ? new String(valb).trim() : null); + } + + private static Map readStringValues + (Preferences root, int hkey, String key) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + HashMap results = new HashMap(); + int[] handles = (int[]) regOpenKey.invoke(root, new Object[] { + new Integer(hkey), toCstr(key), new Integer(KEY_READ) }); + if (handles[1] != REG_SUCCESS) { + return null; + } + int[] info = (int[]) regQueryInfoKey.invoke(root, + new Object[] { new Integer(handles[0]) }); + + int count = info[0]; // count + int maxlen = info[3]; // value length max + for(int index=0; index readStringSubKeys + (Preferences root, int hkey, String key) + throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException + { + List results = new ArrayList(); + int[] handles = (int[]) regOpenKey.invoke(root, new Object[] { + new Integer(hkey), toCstr(key), new Integer(KEY_READ) + }); + if (handles[1] != REG_SUCCESS) { + return null; + } + int[] info = (int[]) regQueryInfoKey.invoke(root, + new Object[] { new Integer(handles[0]) }); + + int count = info[0]; // Fix: info[2] was being used here with wrong results. Suggested by davenpcj, confirmed by Petrucio + int maxlen = info[3]; // value length max + for(int index=0; index fmsFilelist = new ArrayList(); + private ArrayList hzmlist = new ArrayList(); + private ArrayList namelist = new ArrayList(); + private FileInputStream fis; + private FileOutputStream fos; + private JPanel btnPanel1; + private String hzm; + private int iDataset = 0; + private String datasetDir; + private JProgressBar bar; + private long fileSize = 0; + private Boolean allCheck = false; + private List noFileList = new ArrayList(); + private List datasetList = new ArrayList(); + private String pathString; + ExecutorService pool = Executors.newCachedThreadPool(); + private LinkedHashMap typeMap = new LinkedHashMap(); + private List typeCheckBoxs = new ArrayList(); + private List referDateTypeList = new ArrayList(); + private JComboBox comboBox; + private JPanel jComboBoxPanel; + + public Dfl028AIFDialog(AbstractAIFApplication arg0) { + this.app = arg0; + this.session = (TCSession) app.getSession(); + this.targets = app.getTargetComponents(); + + } + + @SuppressWarnings("deprecation") + @Override + public void run() { + // ȡѡ + // String[] datesetTypes = + // session.getPreferenceService().getStringValues("Download_Dataset_Types"); + String dateset = session.getPreferenceService().getString(0, "Download_Dataset_Types"); + if (dateset == null || dateset.length() == 0) { + MessageBox.post("ѡ[Download_Dataset_Types]δ", "ʾ", MessageBox.INFORMATION); + return; + } + try { + String datesetType = session.getPreferenceService().getString(0, "Download_Dataset_Types"); + String[] split2 = datesetType.split(";"); + for (int i = 0; i < split2.length; i++) { + + System.out.println(split2[i]); + String[] split = split2[i].split("::"); + typeMap.put(split[0], split[1]); + } + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("ѡ[Download_Dataset_Types]ʽ", "ʾ", MessageBox.INFORMATION); + return; + } + + String referStrings = session.getPreferenceService().getString(0, "Download_Dataset_Sdpxqc_Rel_Types"); + if (referStrings == null || referStrings.length() == 0) { + }else { + String[] split3 = referStrings.split(";"); + for (int i = 0; i < split3.length; i++) { + System.out.println(split3[i]); + if (!split3[i].contains("::")) { + MessageBox.post("ѡ[Download_Dataset_Sdpxqc_Rel_Types]", "ʾ", MessageBox.INFORMATION); + return; + } + String[] split = split3[i].split("::"); + for (String str : split[1].split("##")) { + referDateTypeList.add(str); + } + } + } + + + // ʾ + init(); + + } + + // ȡļб + private void getload(TCComponentDataset dataset, String path, List list, String itemid) { + System.out.println("----------------------getload"); + try { + TCComponentTcFile[] file = dataset.getTcFiles(); + System.out.println("datasetNam=" + dataset.getStringProperty("object_name")); + if (file == null || file.length == 0) { + if (itemid.equals("sjj")) { + System.out.println("itemid=sjj"); + String noFileString = path + "_" + dataset.getStringProperty("object_name"); + noFileList.add(noFileString); + } else { + AIFComponentContext[] itemRev = dataset.whereReferenced(); + String items = ""; + for (AIFComponentContext context : itemRev) { + if (context.getComponent() instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) context.getComponent(); + items = revision.getStringProperty("item_id") + "_" + + revision.getStringProperty("current_revision_id"); + } + } + String noFileString = items + "_" + dataset.getStringProperty("object_name"); + noFileList.add(noFileString); + } + return; + } else { + for (int i = 0; i < file.length; i++) { + if (!file[i].getType().equals("ImanFile")) { + continue; + } + // ȡ׺ + hzm = file[i].getTCProperty("file_ext").getStringValue(); + String uid = file[i].getUid(); + System.out.println("=======list========"); + System.out.println("i=" + i); + for (String s : list) { + System.out.println(s); + } + System.out.println("hzm=" + hzm); + System.out.println("uid=" + uid); + System.out.println("=======list========"); + // ȡļ׺ + if (list.contains(hzm)) { + String name = file[i].getTCProperty("original_file_name").getStringValue(); + + if (name.contains(".")) { + // ȡļ׺ + name = name.substring(0, name.lastIndexOf(".")); + } + System.out.println("name=" + name); + String replace = name.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + System.out.println("replace=" + replace); + // ȡļû + File fmsFile = file[i].getFmsFile(); + hzmlist.add(hzm); +// namelist.add(path + File.separator + replace); + namelist.add(replace); +// System.out.println("namelist.add=" + path + File.separator + replace); + System.out.println("namelist.add=" + replace); + fmsFilelist.add(fmsFile); + fileSize = fileSize + fmsFile.length(); + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("" + e.getMessage(), "", MessageBox.ERROR); + } + + } + + // ļصָ· + private void downloadfile(String fpath) { + long hasReadByte = 0L;// Ѿȡֽڸ + float result; + int progressSize = 0; + final Log log = new Log(); + List messes = new ArrayList(); + int succ = 0; + int erro = 0; + for (int i = 0; i < hzmlist.size(); i++) { + Mess mess = new Mess(); + String filename = ""; + String path = ""; + try { + // ƴļ + filename = namelist.get(i) + "." + hzmlist.get(i); + System.out.println("fpath=" + fpath); + System.out.println("namelist.get(" + i + ")=" + namelist.get(i)); + // ƴ·ȫļ + path = fpath + File.separator + filename; + System.out.println("path=8.3" + path); + File fileout = new File(path); + fis = new FileInputStream(fmsFilelist.get(i)); + fos = new FileOutputStream(fileout); + byte[] bs = new byte[1024]; + int len = 0; + while ((len = fis.read(bs)) != -1) { + fos.write(bs, 0, len); + hasReadByte = hasReadByte + len; + result = (float) ((double) hasReadByte / fileSize); + progressSize = Math.round(result * 100); + updateProgress(bar, progressSize); + } + if (progressSize < 100) { + updateProgress(bar, progressSize); + } + if (progressSize == 100) { + bar.setForeground(Color.blue); + + } + if (fos != null) + fos.close(); + if (fis != null) + fis.close(); + mess.setName(filename); + mess.setPath(path); + mess.setMess("سɹ"); + messes.add(mess); + succ++; + } catch (Exception e) { + // TODO Auto-generated catch block + mess.setName(filename); + mess.setPath(path); + mess.setMess("ʧܣ"+e.getMessage()); + erro++; + messes.add(mess); + continue; + }finally { + try { + if (fos != null) + fos.close(); + if (fis != null) + fis.close(); + + } catch (IOException e) { + // TODO Auto-generated catch block + + e.printStackTrace(); + } + } + } + log.setSuccessNum("ɹĿ"+succ); + log.setErrorNum("ʧĿ"+erro); + log.setMessages(messes); + this.dispose(); + //ʾ + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + new SimpleGUI(log); + } + }); + } + + + // ·ѡ + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null); + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile(); + jtf.setText(f.getAbsolutePath()); + } + } + + // ʼ + private void init() { + this.setTitle("ݼ"); + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(650, 300)); + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + // һУͼֽ + btnPanel1 = new JPanel(); + JLabel drawingtype = new JLabel("ļ:"); + btnPanel1.add("1.1.left.top", drawingtype); + // typemap + int x = 1; + int y = 2; + for (String key : typeMap.keySet()) { + String value = typeMap.get(key); + JCheckBox checkBox = new JCheckBox(value); + checkBox.setSelected(true); + btnPanel1.add(x + "." + y + ".left.top", checkBox); + y++; + if (y == 10) { + y = 2; + x++; + } + typeCheckBoxs.add(checkBox); + } + // ȫѡť + JPanel jbuJPanel = new JPanel(); + JButton selectAllButton = new JButton("ȫѡ"); + JButton isSelectButton = new JButton("ȡȫѡ"); + jbuJPanel.add("1.1.left.top", selectAllButton); + jbuJPanel.add("1.2.left.top", isSelectButton); + selectAllButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + for (JCheckBox jCheckBox : typeCheckBoxs) { + jCheckBox.setSelected(true); + } + } + }); + isSelectButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + for (JCheckBox jCheckBox : typeCheckBoxs) { + jCheckBox.setSelected(false); + } + } + }); + if(targets[0] instanceof TCComponentBOMLine) { + // ѡ + String[] options = { "ǰ", "" }; + comboBox = new JComboBox(options); + jComboBoxPanel = new JPanel(); + jComboBoxPanel.add(new JLabel(": ")); + jComboBoxPanel.add(comboBox); + } + + + // ѡ + jLabel = new JLabel("·:"); + jtf.setText(deskPath); + jButton = new JButton(""); + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath)); + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + JPanel panel = new JPanel(); + panel.add("1.1.left.top", jLabel); + panel.add("1.2.left.top", jtf); + panel.add("1.3.left.top", jButton); + panel.add("2.1.left.top", okBut); + panel.add("2.2.left.top", celBut); + this.add("1.1.left.top", btnPanel1); + this.add("2.1.left.top", jbuJPanel); + if(targets[0] instanceof TCComponentBOMLine) { + this.add("3.1.left.top", jComboBoxPanel); + this.add("4.1.left.top", panel); + }else { + this.add("3.1.left.top", panel); + } + + this.setBounds(5, 5, 5, 5); + jButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Iterator> iterator = typeMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry secondEntry = iterator.next(); + String keyValue = secondEntry.getKey(); + if (!keyValue.contains("@@")) { + MessageBox.post("ѡ", "error", MessageBox.ERROR); + return; + } + String[] split2 = keyValue.split("@@"); + + String key = split2[0]; + if (key.contains("##")) { + String[] split = key.split("##"); + for (String str : split) { + datasetList.add(str); + } + } else { + datasetList.add(key); + + } + } + + Component[] jcbs2 = btnPanel1.getComponents();// ѡݴ + Boolean btnpa1 = false; + for (Component component : jcbs2) { + if (component instanceof JCheckBox) { + JCheckBox checkBox = (JCheckBox) component; + if (checkBox.isSelected()) { + btnpa1 = true; + } + } + } + if (!btnpa1) { + MessageBox.post("ѡ", "ʾ", 2); + return; + } + + // TODO Auto-generated method stub + if (true) { + getTypes(); + if (fmsFilelist.size() != 0) { + System.out.print("ʼ"); + final String fpath = jtf.getText(); + if (fpath != null && (!fpath.trim().equals(""))) { +// ProgressBarThread wait = new ProgressBarThread("", "С"); +// wait.start(); + new Thread(new Runnable() { + @Override + public void run() { + JDialog dialog = new JDialog(); + bar = new JProgressBar(0, 100); + Container contentPane = dialog.getContentPane(); + contentPane.setLayout(new GridLayout(2, 1)); + JTextField text = new JTextField(""); + contentPane.add("1.1.center.top", text); + contentPane.add("2.1.center.top", bar); + dialog.setSize(300, 100); + dialog.setVisible(true); + dialog.setLocationRelativeTo(dialog.getParent()); + downloadfile(fpath); + dialog.setVisible(false); + File dir = new File(jtf.getText()); + if (dir.exists() && dir.isDirectory()) { + try { + Desktop.getDesktop().open(dir); + } catch (IOException e) { + System.out.println("޷ļ: " + e.getMessage()); + } + } else { + System.out.println("ļв"); + } + } + }).start(); +// wait.setBool(true);// رս +// wait.interrupt(); + + } else { + MessageBox.post("ļ·Ϊ!", "", MessageBox.INFORMATION); + } + } else { + MessageBox.post("ûҵͼֽ", "ʾ", 2); + } + if (noFileList.size() != 0) { + OutputStreamWriter outputStreamWriter; + try { + outputStreamWriter = new OutputStreamWriter( + new FileOutputStream(pathString + File.separator + "ݼû.txt")); + BufferedWriter bWriter = new BufferedWriter(outputStreamWriter); + for (String liString : noFileList) { + bWriter.write(liString); + bWriter.newLine(); + } + bWriter.close(); + outputStreamWriter.close(); + + if (Desktop.isDesktopSupported()) { + File worksheet = new File(pathString + File.separator + "ݼû.txt"); + Desktop.getDesktop().open(worksheet); // or Desktop.getDesktop().edit(worksheet); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + + } + }); + celBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + this.pack(); + this.setResizable(false); + this.centerToScreen(); + this.showDialog(); + } + + // ȡͼֽ + public void getTypes() { + List list = new ArrayList(); + + for (int i = 0; i < typeCheckBoxs.size(); i++) { + JCheckBox checkBox = typeCheckBoxs.get(i); + if (checkBox.isSelected()) { + String text = checkBox.getText(); + Iterator> iterator = typeMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + if (entry.getValue().equals(text)) { + String key = entry.getKey(); + if (key.contains("@@")) { + String[] split = key.split("@@"); + + if(split[1].contains(",")) { + String[] split2 = split[1].split(","); + for(String string : split2) { + list.add(string); + list.add(string.toLowerCase()); + } + }else { + list.add(split[1]); + list.add(split[1].toLowerCase()); + + } + break; + } + } + } + } + } + + try { + for (int i = 0; i < targets.length; i++) { + + if (targets[i] instanceof TCComponentBOMLine) { + List itemlist = new ArrayList(); + // ִлȡ͵ķ + itemlist = getitemType(); + if (itemlist == null) { + return; + } + // bom + TCComponentBOMLine line = (TCComponentBOMLine) targets[i]; + // жϵǰѡǷ + String string = comboBox.getSelectedItem().toString(); + if (string != null && "".equals(string)) { + // ȡ + getAllLine("\\"+line.getItemRevision().getProperty("object_type"),line); + for (Entry> entry : pathAndDataLineMap.entrySet()) { + List value = entry.getValue(); + for(TCComponentBOMLine bomLine : value) { + TCComponentItemRevision rev = bomLine.getItemRevision(); + String objName = rev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + String revtype = rev.getType(); + String orString = rev.getStringProperty("u2_originalNo"); + if(orString == null) { + orString = ""; + }else { + orString = "_" + orString; + } + String dataDir2 = jtf.getText() + File.separator + entry.getKey() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace +orString;// 汾ļ + System.out.println("ļӣ"+dataDir2); + File csFile = new File(dataDir2); + // ݰ汾Լļ + String dataName = entry.getKey()+File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + orString;// ļ + System.out.println("dataNameļӣ"+dataName); + pathString = dataDir2; +// if (!csFile.exists()) { +// csFile.mkdirs(); +// } + System.out.println("cs" + rev.toString() + list.get(0)); + String dataName2 = ""; + // ͼ ȥҷ ļѾ + System.out.println("getOutPart1,dataName=" + dataName); + // getOutPart(rev, dataName, list); + String dataDir3 = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + File.separator + + rev.getStringProperty("item_id") + "_" + rev.getStringProperty("current_revision_id") + + "_" + replace;// 汾ļܳ +// File csFile2 = new File(dataDir3); +// if (!csFile2.exists()) { +// csFile2.mkdir(); +// } + dataName2 = dataName + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace; + if (referDateTypeList.size() == 0) { + referDateTypeList.add("IMAN_specification"); + } + for (String referName : referDateTypeList) { + TCComponent[] datasets = rev.getReferenceListProperty(referName); + for (int j = 0; j < datasets.length; j++) { + // ȡݼ + TCComponentDataset dataset01 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset01 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // ִлȡ׺ķ +// gethzm(dataset01); + // ִлȡ͵ķ + String type = dataset01.getType(); + // жlisthzmֵַ itemlistrevtypeֵ + if (itemlist.contains(revtype) || itemlist.size() == 0) { + for (String aString : datasetList) { + System.out.println(aString); + } + if (datasetList.contains(type)) { + // ȡݼ + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + // ִgetload + System.out.println("getload1"); + getload(dataset02, dataName, list, rev.getStringProperty("item_id")); + //getload(dataset02, dataName2, list, rev.getStringProperty("item_id")); + } + } + } + } + } + } + } else { + TCComponentItemRevision rev = line.getItemRevision(); + String objName = rev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + String revtype = rev.getType(); + String orString = rev.getStringProperty("u2_originalNo"); + if(orString == null) { + orString = ""; + }else { + orString = "_" + orString; + } + String dataDir2 = jtf.getText()+ File.separator + rev.getProperty("object_type") + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + orString;// 汾ļ + File csFile = new File(dataDir2); + // ݰ汾Լļ + String dataName = rev.getProperty("object_type") + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + orString;// ļ + pathString = dataDir2; +// if (!csFile.exists()) { +// csFile.mkdirs(); +// } + System.out.println("cs" + rev.toString() + list.get(0)); + String dataName2 = ""; + // ͼ ȥҷ ļѾ + System.out.println("getOutPart1,dataName=" + dataName); + // getOutPart(rev, dataName, list); + String dataDir3 = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + File.separator + + rev.getStringProperty("item_id") + "_" + rev.getStringProperty("current_revision_id") + + "_" + replace;// 汾ļܳ +// File csFile2 = new File(dataDir3); +// if (!csFile2.exists()) { +// csFile2.mkdir(); +// } + dataName2 = dataName + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace; + if (referDateTypeList.size() == 0) { + referDateTypeList.add("IMAN_specification"); + } + for (String referName : referDateTypeList) { + TCComponent[] datasets = rev.getReferenceListProperty(referName); + for (int j = 0; j < datasets.length; j++) { + // ȡݼ + TCComponentDataset dataset01 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset01 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // ִлȡ׺ķ +// gethzm(dataset01); + // ִлȡ͵ķ + String type = dataset01.getType(); + // жlisthzmֵַ itemlistrevtypeֵ + if (itemlist.contains(revtype) || itemlist.size() == 0) { + for (String aString : datasetList) { + System.out.println(aString); + } + if (datasetList.contains(type)) { + // ȡݼ + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + // ִgetload + System.out.println("getload1"); + getload(dataset02, dataName, list, rev.getStringProperty("item_id")); + //getload(dataset02, dataName2, list, rev.getStringProperty("item_id")); + } + } + } + } + } + + } else if (targets[i] instanceof TCComponentItemRevision) { + List itemlist = new ArrayList(); + // ִлȡ͵ķ + itemlist = getitemType(); + if (itemlist == null) { + return; + } + TCComponentItemRevision rev = (TCComponentItemRevision) targets[i]; + String revtype = rev.getStringProperty("object_type"); + System.out.println("ѡĿ:" + revtype); + + String objName = rev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + String orString = rev.getStringProperty("u2_originalNo"); + if(orString == null) { + orString = ""; + }else { + orString = "_" + orString; + } + String dataDir = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + orString;// 汾ļ + + File csFile = new File(dataDir); + // ݰ汾Լļ + String dataName = rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + orString;// ļ + String dataName2 = ""; + pathString = dataDir; +// if (!csFile.exists()) { +// csFile.mkdir(); +// } + // ͼ ȥҷ ļѾ + System.out.println("getOutPart2,dataName=" + dataName); + // getOutPart(rev, dataName, list); + String dataDir3 = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + File.separator + + rev.getStringProperty("item_id") + "_" + rev.getStringProperty("current_revision_id") + + "_" + replace;// 汾ļܳ +// System.out.println("dataDir3:" + dataDir3); +// File csFile2 = new File(dataDir3); +// if (!csFile2.exists()) { +// csFile2.mkdir(); +// } + dataName2 = dataName + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace;// ļ + System.out.println("dataName2:" + dataName2); + if (referDateTypeList.size() == 0) { + referDateTypeList.add("IMAN_specification"); + } + for (String referName : referDateTypeList) { + System.out.println("referName:" + referName); + TCComponent[] datasets = rev.getReferenceListProperty(referName); + System.out.println("datasets:" + datasets); + if (datasets != null) { + for (int j = 0; j < datasets.length; j++) { + System.out.println("-----------------"); + // ȡݼ + TCComponentDataset dataset02 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // ִлȡ׺ķ +// gethzm(dataset02); + String type = dataset02.getType(); + // ж + System.out.println("itemlist.contains(revtype)" + itemlist.contains(revtype)); + if (itemlist.contains(revtype) || itemlist.size()==0) { + System.out.println("type:" + type); + for (String aString : datasetList) { + System.out.println(aString); + } + if (datasetList.contains(type)) { + System.out.println("!!!!!!!!!!!!!!!"); + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + System.out.println("ļ"); + getload(dataset, dataName, list, rev.getStringProperty("item_id")); + //getload(dataset, dataName2, list, rev.getStringProperty("item_id")); + } + } + } + } + + } + } else if (targets[i] instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) targets[i]; + String dataName = ""; + String objName = dataset.getStringProperty("object_name"); + String replaceName = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + if (iDataset == 0) { + dataName = jtf.getText()+ File.separator + replaceName; + datasetDir = replaceName; + pathString = dataName; + File csFile = new File(dataName); +// if (!csFile.exists()) { +// csFile.mkdirs(); +// } + } + iDataset = 1; + String type = dataset.getType(); +// gethzm(dataset); + if (datasetList.contains(type) || datasetList.size()==0) { + getload(dataset, datasetDir, list, "sjj"); + } + } else if (targets[i] instanceof TCComponentFolder) { + + //ȡļļеݻԼӦļַ + getDatasetAndPath("",(TCComponentFolder)targets[i]); + for (Entry entry : pathAndDataMap.entrySet()) { + TCComponentDataset dataset = entry.getKey(); + System.out.println("dataset:"+dataset.getStringProperty("object_name")); + String path = entry.getValue(); + System.out.println("path:"+path); + File csFile = new File(jtf.getText()+path); + datasetDir = path; +// if (!csFile.exists()) { +// csFile.mkdirs(); +// } + String type = dataset.getType(); +// gethzm(dataset); + System.out.println("type:"+type); + for(String tupeString : datasetList) { + System.out.println("tupeString:"+tupeString); + } + if (datasetList.contains(type) || datasetList.size()==0) { + getload(dataset, datasetDir, list, "sjj"); + } + + + } + } else if (targets[i] instanceof TCComponentItem) { + List itemlist = new ArrayList(); + // ִлȡ͵ķ + itemlist = getitemType(); + TCComponentItem item = (TCComponentItem) targets[i]; +// item.getReleasedItemRevisions(); + TCComponentItemRevision rev = item.getLatestItemRevision(); + String revtype = rev.getType(); + String objName = rev.getStringProperty("object_name"); + String replace = objName.replace("/", "-").replace("<", "-").replace(">", "-").replace(":", "-") + .replace("|", "-").replace("\\", "-").replace("*", "-").replace("?", "-"); + String orString = rev.getStringProperty("u2_originalNo"); + if(orString == null) { + orString = ""; + }else { + orString = "_" + orString; + } + String dataDir2 = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + orString;// 汾ļ + + File csFile = new File(dataDir2); + // ݰ汾Լļ + String dataName = rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + orString;// ļ + pathString = dataDir2; +// if (!csFile.exists()) { +// csFile.mkdir(); +// +// } + String dataName2 = ""; + // ͼ ȥҷ ļѾ + System.out.println("getOutPart3,dataName=" + dataName); + //getOutPart(rev, dataName, list); + String dataDir3 = jtf.getText() + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + File.separator + + rev.getStringProperty("item_id") + "_" + rev.getStringProperty("current_revision_id") + + "_" + replace;// 汾ļܳ +// File csFile2 = new File(dataDir3); +// if (!csFile2.exists()) { +// csFile2.mkdir(); +// } + + dataName2 = dataName + File.separator + rev.getStringProperty("item_id") + "_" + + rev.getStringProperty("current_revision_id") + "_" + replace + orString;// ļ + +// TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); +// TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + if(referDateTypeList.size()==0) { + referDateTypeList.add("IMAN_specification"); + } + for(String referName : referDateTypeList) { + TCComponent[] datasets = rev.getReferenceListProperty(referName); + for (int j = 0; j < datasets.length; j++) { + // ȡݼ + TCComponentDataset dataset02 = null; + if (datasets[j] instanceof TCComponentDataset) { + dataset02 = (TCComponentDataset) datasets[j]; + } else { + continue; + } + // ִлȡ׺ķ + String type = dataset02.getType(); +// gethzm(dataset02); + if (itemlist.contains(revtype) || itemlist.size()==0) { + if (datasetList.contains(type)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + System.out.println("getload4"); + getload(dataset, dataName, list, rev.getStringProperty("item_id")); + //getload(dataset, dataName2, list, rev.getStringProperty("item_id")); + } + } + } + } + + } else { + MessageBox.post("ѡеIJǰ汾BOMжݼ", "error", MessageBox.ERROR); + return; + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + + private Map pathAndDataMap = new HashMap(); + private void getDatasetAndPath(String path, TCComponentFolder folder) throws TCException { + // TODO Auto-generated method stub + AIFComponentContext[] children = folder.getChildren(); + for(AIFComponentContext aifComponentContext : children) { + TCComponent component = (TCComponent)aifComponentContext.getComponent(); + if(component instanceof TCComponentDataset) { + pathAndDataMap.put((TCComponentDataset)component,path+"\\"+folder.getStringProperty("object_name")); + }else if(component instanceof TCComponentFolder){ + getDatasetAndPath(path+"\\"+folder.getStringProperty("object_name"),(TCComponentFolder)component); + } + } + } + + /** + * ȡ + * + * @param line + */ + + private Map> pathAndDataLineMap = new HashMap>(); + private void getAllLine(String path,TCComponentBOMLine line) throws TCException { + System.out.println("bomline:"+line.getItemRevision().getStringProperty("object_name")); + System.out.println("path:"+path); + //жǷkey + String property = line.getItemRevision().getProperty("object_type"); + if(pathAndDataLineMap.size()>0 && pathAndDataLineMap.containsKey(property)) { + pathAndDataLineMap.get(property).add(line); + }else { + List bonBomLines = new ArrayList(); + bonBomLines.add(line); + pathAndDataLineMap.put(property, bonBomLines); + } + if(line.hasChildren()) { + AIFComponentContext[] childrens = line.getChildren(); + for (AIFComponentContext aifComponentContext : childrens) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) aifComponentContext.getComponent(); + getAllLine(bomLine.getItemRevision().getProperty("object_type"),bomLine); + } + } + } + + // ȡ + public List getitemType() { + List itemlist = new ArrayList(); + + String value = session.getPreferenceService().getString(0, "Download_Dataset_Sdpxqc_Item_Types"); + if (value == null || value.length() == 0) { + + }else { + String[] split = value.split(";"); + if (split != null && split.length > 0) { + for (int i = 0; i < split.length; i++) { + itemlist.add(split[i]); + } + + } + } + + return itemlist; + } + + private static void updateProgress(JProgressBar copyProgressBar, int progressSize) { + copyProgressBar.setString(progressSize + "%"); + copyProgressBar.setValue(progressSize); + } + + public static String GetPreference(TCSession session, String PreferenceName) { + try { + TCPreferenceService PreferService = session.getPreferenceService(); + String UDSCodeConfigPath = PreferService.getString(1, PreferenceName); + if (UDSCodeConfigPath == null || UDSCodeConfigPath.equals("")) { + UDSCodeConfigPath = PreferService.getString(4, PreferenceName); + } + + if (UDSCodeConfigPath != null && !UDSCodeConfigPath.equals("")) { + return UDSCodeConfigPath; + } else { + System.out.println("ûҵѡ:" + PreferenceName); + return ""; + } + } catch (Exception var4) { + var4.printStackTrace(); + return ""; + } + } +} diff --git a/src/com/connor/dfl/plm/dfl028/Dfl028Handler.java b/src/com/connor/dfl/plm/dfl028/Dfl028Handler.java new file mode 100644 index 0000000..d5c80a5 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl028/Dfl028Handler.java @@ -0,0 +1,60 @@ +package com.connor.dfl.plm.dfl028; + +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.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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Dfl028Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + InterfaceAIFComponent[] targetComponents = app.getTargetComponents(); + TCSession session = (TCSession)app.getSession(); + TCComponentUser user = session.getUser(); + try { + int level = user.getIntProperty("license_level"); + System.out.println("license_level ->" + level); + if (level == 1) { + MessageBox.post("ǰ¼ûûȨݼ", "ʾ", 2); + return null; + } + } catch (TCException e) { + e.printStackTrace(); + } + if(targetComponents == null || targetComponents.length == 0) { + MessageBox.post("ѡҪصݣֻѡBOMline󡢶汾ݼļж", "ʾ", 2); + return null; + } + for(InterfaceAIFComponent targetComponent : targetComponents) { + if(!(targetComponent instanceof TCComponentBOMLine) && !(targetComponent instanceof TCComponentItemRevision) + && !(targetComponent instanceof TCComponentDataset) && !(targetComponent instanceof TCComponentFolder) + && !(targetComponent instanceof TCComponentItem)) { + MessageBox.post("ѡҪصݣֻѡBOMline󡢶汾ݼļж", "ʾ", 2); + return null; + } + } + + Dfl028AIFDialog dialog = new Dfl028AIFDialog(app); + new Thread(dialog).start(); + + return null; + } + +} diff --git a/src/com/connor/dfl/plm/dfl028/Log.java b/src/com/connor/dfl/plm/dfl028/Log.java new file mode 100644 index 0000000..0d1ecb2 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl028/Log.java @@ -0,0 +1,61 @@ +package com.connor.dfl.plm.dfl028; + +import java.util.List; + +public class Log { + String successNum; + String errorNum; + List messages; + + + public Log() { + super(); + } + + + public Log(String successNum, String errorNum, List messages) { + super(); + this.successNum = successNum; + this.errorNum = errorNum; + this.messages = messages; + } + + + public String getSuccessNum() { + return successNum; + } + + + public void setSuccessNum(String successNum) { + this.successNum = successNum; + } + + + public String getErrorNum() { + return errorNum; + } + + + public void setErrorNum(String errorNum) { + this.errorNum = errorNum; + } + + + public List getMessages() { + return messages; + } + + + public void setMessages(List messages) { + this.messages = messages; + } + + + @Override + public String toString() { + return "Log [successNum=" + successNum + ", errorNum=" + errorNum + ", messages=" + messages + "]"; + } + + + +} diff --git a/src/com/connor/dfl/plm/dfl028/Mess.java b/src/com/connor/dfl/plm/dfl028/Mess.java new file mode 100644 index 0000000..879f62c --- /dev/null +++ b/src/com/connor/dfl/plm/dfl028/Mess.java @@ -0,0 +1,57 @@ +package com.connor.dfl.plm.dfl028; + +public class Mess { + private String name; + private String path; + private String mess; + + + public Mess() { + super(); + } + + + public Mess(String name, String path, String mess) { + super(); + this.name = name; + this.path = path; + this.mess = mess; + } + + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public String getPath() { + return path; + } + + + public void setPath(String path) { + this.path = path; + } + + + public String getMess() { + return mess; + } + + + public void setMess(String mess) { + this.mess = mess; + } + + + @Override + public String toString() { + return "Mess [name=" + name + ", path=" + path + ", mess=" + mess + "]"; + } + +} diff --git a/src/com/connor/dfl/plm/dfl028/SimpleGUI.java b/src/com/connor/dfl/plm/dfl028/SimpleGUI.java new file mode 100644 index 0000000..cc946d7 --- /dev/null +++ b/src/com/connor/dfl/plm/dfl028/SimpleGUI.java @@ -0,0 +1,120 @@ +package com.connor.dfl.plm.dfl028; + + +import javax.swing.*; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.awt.Desktop; + +public class SimpleGUI extends JFrame { + + private String succString; + private String errString; + private String mess; + private JLabel successLabel, failureLabel; + private JButton detailButton; + + public SimpleGUI(Log log) { + succString = log.getSuccessNum(); + errString = log.getErrorNum(); + mess = JSON.toJSONString(log, SerializerFeature.PrettyFormat); + mess = reduceConsecutiveBackslashes(mess); + + setTitle("Ϣ"); + setSize(250, 110); + setDefaultCloseOperation(2); + setLayout(new BorderLayout()); // ʹBorderLayout + + // ɹʧܱǩ + successLabel = new JLabel("ɹĿ" + succString); + failureLabel = new JLabel("ʧĿ" + errString); + + JPanel contentPanel = new JPanel(); + contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); // ֱ + contentPanel.add(successLabel); + contentPanel.add(Box.createVerticalStrut(10)); // Ӽ + contentPanel.add(failureLabel); + + add(contentPanel, BorderLayout.CENTER); // + + // 鿴鰴ťù̶С + detailButton = new JButton("鿴"); + detailButton.setPreferredSize(new Dimension(100, 30)); // ðťС + detailButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + createAndOpenFile(); + dispose(); + } + }); + + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); // ʽ֣ж + buttonPanel.add(detailButton); + + add(buttonPanel, BorderLayout.PAGE_END); // ťҳײ + setAlwaysOnTop(true); + setLocationRelativeTo(null); // ھʾ + setVisible(true); + } + + public static String reduceConsecutiveBackslashes(String input) { + StringBuilder sb = new StringBuilder(); + int count = 0; + for (char c : input.toCharArray()) { + if (c == '\\') { + count++; + if (count <= 2) { + sb.append(c); + } + } else { + count = 0; + sb.append(c); + } + } + return sb.toString(); + } + + private void createAndOpenFile() { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); + String timestamp = sdf.format(date); + + String fileNamePrefix = "prefix_" + timestamp; + String fileNameSuffix = ".txt"; + File file = File.createTempFile(fileNamePrefix, fileNameSuffix,null); +// File file = new File("details.txt"); + if (!file.exists()) { + file.createNewFile(); + } + + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + writer.write(mess); + writer.close(); + + Desktop desktop = Desktop.getDesktop(); + if (desktop.isSupported(Desktop.Action.OPEN)) { + desktop.open(file); + } else { + System.out.println("޷ļ"); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + +} \ No newline at end of file diff --git a/src/com/connor/dfl/plm/dfl028/test.java b/src/com/connor/dfl/plm/dfl028/test.java new file mode 100644 index 0000000..032d71d --- /dev/null +++ b/src/com/connor/dfl/plm/dfl028/test.java @@ -0,0 +1,10 @@ +package com.connor.dfl.plm.dfl028; + +public class test { + public static void main(String[] args) { + String string = "abc"; + String[] split = string.split(";"); + System.out.println(split.length); + System.out.println(split[0]); + } +} diff --git a/src/com/connor/dfl/plm/dfl028/test028.java b/src/com/connor/dfl/plm/dfl028/test028.java new file mode 100644 index 0000000..3f293ad --- /dev/null +++ b/src/com/connor/dfl/plm/dfl028/test028.java @@ -0,0 +1,476 @@ +package com.connor.dfl.plm.dfl028; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +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.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class test028 extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent[] targets; + private JLabel jLabel; + private JTextField jtf = new JTextField(20); + private JButton jButton; + private JFileChooser jFileChooser; + private JButton okBut = new JButton(""); + private JButton celBut = new JButton("ȡ"); + private List fmsFilelist = new ArrayList(); + private List hzmlist = new ArrayList(); + private List namelist = new ArrayList(); + private FileInputStream fis; + private FileOutputStream fos; + private JPanel btnPanel1; + private JPanel btnPanel2; + private JPanel btnPanel3; + private String hzm; + + public test028(AbstractAIFApplication arg0){ + this.app = arg0; + this.session = (TCSession)app.getSession(); + this.targets = app.getTargetComponents(); + + } + @Override + public void run() { + //ʾ + init(); + + + //òѯť +// qryBtn.setEnabled(true); + } + //ȡļб + private void getload(TCComponentDataset dataset){ + try { + TCComponentTcFile[] file = dataset.getTcFiles(); + if(file == null || file.length ==0){ + MessageBox.post("ݼûõļ飡", + "WARNING",MessageBox.WARNING); + return; + }else{ + for(int i=0;i list = new ArrayList(); + Component[] jcbs = btnPanel1.getComponents();//ѡݴ + for(Component component : jcbs) { + JCheckBox jcb = (JCheckBox) component; + if(jcb.isSelected()) { + list.add(jcb.getText()); + if("DWG".equals(jcb.getText())) { + list.add("DWG"); + list.add("dwg"); + }else if ("STP".equals(jcb.getText())) { + list.add("stp"); + }else if("PDF".equals(jcb.getText())) { + list.add("pdf"); + }else if("idw".equals(jcb.getText())) { + list.add("idw"); + }else if ("ipt".equals(jcb.getText())) { + list.add("ipt"); + }else if ("iam".equals(jcb.getText())) { + list.add("iam"); + }else if ("STEP".equals(jcb.getText())) { + list.add("STEP"); + } + } + } + //жlistĴСССڵ0ȫ + if(list.size() <= 0) { + list.add("DWG"); + list.add("dwg"); + list.add("pdf"); + list.add("stp"); + list.add("idw"); + list.add("iam"); + list.add("STEP"); + } + try { + for (int i = 0; i < targets.length; i++) { + if(targets[i] instanceof TCComponentBOMLine){ + List itemlist = new ArrayList(); + //ִлȡ͵ķ + itemlist = getitemType(); + //bom + TCComponentBOMLine line = (TCComponentBOMLine) targets[i]; + TCComponentItemRevision rev = line.getItemRevision(); + String revtype = rev.getStringProperty("object_type"); + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < datasets.length; j++) { + //ȡݼ + TCComponentDataset dataset01 = (TCComponentDataset) datasets[j]; + //ִлȡ׺ķ + gethzm(dataset01); + System.out.println("9.07test׺"+hzm); + //ִлȡ͵ķ + itemlist = getitemType(); + + //жlisthzmֵַ itemlistrevtypeֵ + if(itemlist.contains(revtype)) { + if(list.contains(hzm)) { + //ȡݼ + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //ִgetload + getload(dataset02); + } + } + } + for (int j = 0; j < datasets2.length; j++) { + //ȡݼ + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //ִлȡ׺ķ + gethzm(dataset02); + String type2 = datasets2[j].getType(); + //жǷΪҪ + if(itemlist.contains(revtype)) { + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset); + } + } + } + } + else if(targets[i] instanceof TCComponentItemRevision){ + List itemlist = new ArrayList(); + //ִлȡ͵ķ + itemlist = getitemType(); + TCComponentItemRevision rev = (TCComponentItemRevision) targets[i]; + String revtype = rev.getStringProperty("object_type"); + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < datasets.length; j++) { + + //ȡݼ + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //ִлȡ׺ķ + gethzm(dataset02); + //ж + if(itemlist.contains(revtype)) { + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + System.out.println("ļ"); + getload(dataset); + } + } + } + for (int j = 0; j < datasets2.length; j++) { + //ȡݼ + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //ִлȡ׺ķ + gethzm(dataset02); + //ж + if (itemlist.contains(revtype)) { + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset); + } + } + } + }else if(targets[i] instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) targets[i]; + getload(dataset); + }else if(targets[i] instanceof TCComponentItem){ + List itemlist = new ArrayList(); + //ִлȡ͵ķ + itemlist = getitemType(); + TCComponentItem item = (TCComponentItem) targets[i]; + TCComponentItemRevision rev = item.getLatestItemRevision(); + String revtype = rev.getStringProperty("object_type"); + TCComponent[] datasets = rev.getReferenceListProperty("IMAN_specification"); + TCComponent[] datasets2 = rev.getReferenceListProperty("IMAN_Rendering"); + for (int j = 0; j < datasets.length; j++) { + //ȡݼ + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //ִлȡ׺ķ + gethzm(dataset02); + if(itemlist.contains(revtype)) { + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + getload(dataset); + } + } + } + for (int j = 0; j < datasets2.length; j++) { + //ȡݼ + TCComponentDataset dataset02 = (TCComponentDataset) datasets[j]; + //ִлȡ׺ķ + gethzm(dataset02); + if(itemlist.contains(revtype)) { + if(list.contains(hzm)) { + TCComponentDataset dataset = (TCComponentDataset) datasets2[j]; + getload(dataset); + } + } + } + }else { + MessageBox.post("ѡеIJǰ汾BOMжݼ","error",MessageBox.ERROR); + return; + } + } + } catch (Exception e) { + // TODO: handle exception + } + } + //ȡ + public List getitemType() { + List itemlist = new ArrayList(); + Component[] jcbs = btnPanel2.getComponents();//ѡݴ + //ѡ + for(Component component : jcbs) { + JCheckBox jcb = (JCheckBox) component; + //жԪǷѡ + if(jcb.isSelected()) { + itemlist.add(jcb.getText()); + itemlist.add(jcb.getText()); + if("ȫ".equals(jcb.getText())) { + itemlist.add("T2_VirtualRevision"); + itemlist.add("T2_OutBuyPartRevision"); + itemlist.add("T2_outsourceRevision"); + }else if ("Э".equals(jcb.getText())) { + itemlist.add("T2_outsourceRevision"); + }else if ("⹺".equals(jcb.getText())) { + itemlist.add("T2_OutBuyPartRevision"); + }else if ("".equals(jcb.getText())) { + itemlist.add("T2_VirtualRevision"); + } + } + } + return itemlist; + } + +} diff --git a/src/com/connor/jd/plm/action/BOMManagementAction.java b/src/com/connor/jd/plm/action/BOMManagementAction.java new file mode 100644 index 0000000..4382d38 --- /dev/null +++ b/src/com/connor/jd/plm/action/BOMManagementAction.java @@ -0,0 +1,25 @@ +package com.connor.jd.plm.action; + +import com.connor.jd.plm.dialogs.BOMManagementFrame; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class BOMManagementAction extends AbstractAIFAction { + + private AIFDesktop app; + private AbstractAIFApplication arg2; + public BOMManagementAction(AIFDesktop arg0, String arg1,AbstractAIFApplication arg2) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.arg2 = arg2; + } + + @Override + public void run() { + // TODO Auto-generated method stub + new BOMManagementFrame(arg2); + } + +} diff --git a/src/com/connor/jd/plm/action/package-info.java b/src/com/connor/jd/plm/action/package-info.java new file mode 100644 index 0000000..8e74581 --- /dev/null +++ b/src/com/connor/jd/plm/action/package-info.java @@ -0,0 +1 @@ +package com.connor.jd.plm.action; \ No newline at end of file diff --git a/src/com/connor/jd/plm/beans/BOMExportBean.java b/src/com/connor/jd/plm/beans/BOMExportBean.java new file mode 100644 index 0000000..af04fe1 --- /dev/null +++ b/src/com/connor/jd/plm/beans/BOMExportBean.java @@ -0,0 +1,104 @@ +package com.connor.jd.plm.beans; + +public class BOMExportBean { + private String pid;// id + private String prev;// 汾 + private String cid;// id + private String crev;// Ӱ汾 + private String childCount;// + private String childUnit;// ӵλ + private String HLCount;// + private String SN;// + + public BOMExportBean(String pid, String prev, String cid, String crev, String childCount, String childUnit, + String HLCount, String SN) { + super(); + this.pid = pid; + this.prev = prev; + this.cid = cid; + this.crev = crev; + this.childCount = childCount; + this.childUnit = childUnit; + this.HLCount = HLCount; + this.SN = SN; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getPrev() { + return prev; + } + + public void setPrev(String prev) { + this.prev = prev; + } + + public String getCid() { + return cid; + } + + public void setCid(String cid) { + this.cid = cid; + } + + public String getCrev() { + return crev; + } + + public void setCrev(String crev) { + this.crev = crev; + } + + public String getChildCount() { + return childCount; + } + + public void setChildCount(String childCount) { + this.childCount = childCount; + } + + public String getChildUnit() { + return childUnit; + } + + public void setChildUnit(String childUnit) { + this.childUnit = childUnit; + } + + public String getHLCount() { + return HLCount; + } + + public void setHLCount(String HLCount) { + this.HLCount = HLCount; + } + + public String getSN() { + return SN; + } + + public void setSN(String SN) { + this.SN = SN; + } + + public int isNegative() { + if (HLCount == null || HLCount.isEmpty()) { + return 0; + } + int hlCountValue = 0; + try { + hlCountValue = Integer.parseInt(HLCount); + } catch (NumberFormatException e) { + // HLCountЧҲѡ׳쳣߷Ĭֵ˴0 + return 0; + } + return hlCountValue < 0 ? 1 : 0; + } + +} diff --git a/src/com/connor/jd/plm/beans/BOMLogBean.java b/src/com/connor/jd/plm/beans/BOMLogBean.java new file mode 100644 index 0000000..56555fc --- /dev/null +++ b/src/com/connor/jd/plm/beans/BOMLogBean.java @@ -0,0 +1,80 @@ +package com.connor.jd.plm.beans; + +public class BOMLogBean { + private String target1; + private String target2; + private String parent; + private String operation; + private String unit; + private String oldNum; + private String num; + + public BOMLogBean(String target1, String target2, String parent, String operation, String unit, String oldNum, + String num) { + super(); + this.target1 = target1; + this.target2 = target2; + this.parent = parent; + this.operation = operation; + this.unit = unit; + this.oldNum = oldNum; + this.num = num; + } + + public String getTarget1() { + return target1; + } + + public void setTarget1(String target1) { + this.target1 = target1; + } + + public String getTarget2() { + return target2; + } + + public void setTarget2(String target2) { + this.target2 = target2; + } + + public String getParent() { + return parent; + } + + public void setParent(String parent) { + this.parent = parent; + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getOldNum() { + return oldNum; + } + + public void setOldNum(String oldNum) { + this.oldNum = oldNum; + } + + public String getNum() { + return num; + } + + public void setNum(String num) { + this.num = num; + } + +} diff --git a/src/com/connor/jd/plm/beans/BOMManageTableBean.java b/src/com/connor/jd/plm/beans/BOMManageTableBean.java new file mode 100644 index 0000000..0c7600d --- /dev/null +++ b/src/com/connor/jd/plm/beans/BOMManageTableBean.java @@ -0,0 +1,74 @@ +package com.connor.jd.plm.beans; + +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +public class BOMManageTableBean { + + private String parentString; + private String childString; + private TCComponentItemRevision parentRev; + private TCComponentItemRevision childRev; + private TCComponentBOMLine parentLine; + private TCComponentBOMLine childLine; + + public BOMManageTableBean(String parentString, String childString, TCComponentItemRevision parentRev, + TCComponentItemRevision childRev, TCComponentBOMLine parentLine, TCComponentBOMLine childLine) { + super(); + this.parentString = parentString; + this.childString = childString; + this.parentRev = parentRev; + this.childRev = childRev; + this.parentLine = parentLine; + this.childLine = childLine; + } + + public String getParentString() { + return parentString; + } + + public void setParentString(String parentString) { + this.parentString = parentString; + } + + public String getChildString() { + return childString; + } + + public void setChildString(String childString) { + this.childString = childString; + } + + public TCComponentItemRevision getParentRev() { + return parentRev; + } + + public void setParentRev(TCComponentItemRevision parentRev) { + this.parentRev = parentRev; + } + + public TCComponentItemRevision getChildRev() { + return childRev; + } + + public void setChildRev(TCComponentItemRevision childRev) { + this.childRev = childRev; + } + + public TCComponentBOMLine getParentLine() { + return parentLine; + } + + public void setParentLine(TCComponentBOMLine parentLine) { + this.parentLine = parentLine; + } + + public TCComponentBOMLine getChildLine() { + return childLine; + } + + public void setChildLine(TCComponentBOMLine childLine) { + this.childLine = childLine; + } + +} diff --git a/src/com/connor/jd/plm/beans/CheckBoxPo.java b/src/com/connor/jd/plm/beans/CheckBoxPo.java new file mode 100644 index 0000000..b7c280c --- /dev/null +++ b/src/com/connor/jd/plm/beans/CheckBoxPo.java @@ -0,0 +1,14 @@ +package com.connor.jd.plm.beans; + +public class CheckBoxPo { + public Object value = null; + public String text = null; + + public CheckBoxPo() { + } + + public CheckBoxPo(String text, Object value) { + this.value = value; + this.text = text; + } +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/beans/ClassPropBean.java b/src/com/connor/jd/plm/beans/ClassPropBean.java new file mode 100644 index 0000000..12cf40a --- /dev/null +++ b/src/com/connor/jd/plm/beans/ClassPropBean.java @@ -0,0 +1,39 @@ +package com.connor.jd.plm.beans; + +public class ClassPropBean { + private int id; + private String name; + private String value; + + public ClassPropBean(int id, String name, String value) { + super(); + this.id = id; + this.name = name; + this.value = value; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/com/connor/jd/plm/beans/ComponentBean.java b/src/com/connor/jd/plm/beans/ComponentBean.java new file mode 100644 index 0000000..31c5cd8 --- /dev/null +++ b/src/com/connor/jd/plm/beans/ComponentBean.java @@ -0,0 +1,101 @@ +package com.connor.jd.plm.beans; + +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.value.ObservableValue; + +public class ComponentBean { + + private int compId; + private SimpleStringProperty type; + private SimpleStringProperty project; + private SimpleStringProperty time; + private SimpleStringProperty number; + private SimpleStringProperty cost; + private int addId;// ֻ + private int stage;// ״̬ 0Ϊݿȡģ1Ϊģ2Ϊݿȡ޸˵ + + public int getAddId() { + return addId; + } + + public void setAddId(int addId) { + this.addId = addId; + } + + public int getStage() { + return stage; + } + + public void setStage(int stage) { + this.stage = stage; + } + + public ObservableValue typeProperty() { + return type; + } + + public ObservableValue projectProperty() { + return project; + } + + public ObservableValue timeProperty() { + return time; + } + + public ObservableValue numberProperty() { + return number; + } + + public ObservableValue costProperty() { + return cost; + } + + public int getCompId() { + return compId; + } + + public void setCompId(int compId) { + this.compId = compId; + } + + public String getType() { + return type.get(); + } + + public void setType(String type) { + this.type = new SimpleStringProperty(type); + } + + public String getProject() { + return project.get(); + } + + public void setProject(String project) { + this.project = new SimpleStringProperty(project); + } + + public String getTime() { + return time.get(); + } + + public void setTime(String time) { + this.time = new SimpleStringProperty(time); + } + + public String getNumber() { + return number.get(); + } + + public void setNumber(String number) { + this.number = new SimpleStringProperty(number); + } + + public String getCost() { + return cost.get(); + } + + public void setCost(String cost) { + this.cost = new SimpleStringProperty(cost); + } + +} diff --git a/src/com/connor/jd/plm/beans/CustomLovBean.java b/src/com/connor/jd/plm/beans/CustomLovBean.java new file mode 100644 index 0000000..75157ec --- /dev/null +++ b/src/com/connor/jd/plm/beans/CustomLovBean.java @@ -0,0 +1,38 @@ +package com.connor.jd.plm.beans; + +import java.util.ArrayList; +import java.util.List; + +public class CustomLovBean { + private List sub = new ArrayList(); + public String displayName = ""; + + public CustomLovBean(String displayName) { + super(); + this.displayName = displayName; + } + + public CustomLovBean(String displayName, String[] subArray) { + super(); + this.displayName = displayName; + translateArrayToSub(subArray); + } + + public void translateArrayToSub(String[] subArray) { + for (int i = 0; i < subArray.length; i++) { + sub.add(new CustomLovBean(subArray[i])); + } + } + + public List getSub() { + return sub; + } + + public boolean hasChild() { + return sub.size() != 0; + } + + public void addSub(CustomLovBean clb) { + sub.add(clb); + } +} diff --git a/src/com/connor/jd/plm/beans/JG.java b/src/com/connor/jd/plm/beans/JG.java new file mode 100644 index 0000000..cf10668 --- /dev/null +++ b/src/com/connor/jd/plm/beans/JG.java @@ -0,0 +1,38 @@ +package com.connor.jd.plm.beans; + +public class JG { + int row; + int times; + String jg; + + public JG(int row, int times, String jg) { + super(); + this.row = row; + this.times = times; + this.jg = jg; + } + + public int getTimes() { + return times; + } + + public void setTimes(int times) { + this.times = times; + } + + public String getJg() { + return jg; + } + + public void setJg(String jg) { + this.jg = jg; + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } +} diff --git a/src/com/connor/jd/plm/beans/MachineBean.java b/src/com/connor/jd/plm/beans/MachineBean.java new file mode 100644 index 0000000..51ebd0f --- /dev/null +++ b/src/com/connor/jd/plm/beans/MachineBean.java @@ -0,0 +1,75 @@ +package com.connor.jd.plm.beans; + +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.value.ObservableValue; + +public class MachineBean { + + private int macId; + private SimpleStringProperty type; + private SimpleStringProperty project; + private SimpleStringProperty cost; + private int addId;// ֻ + private int stage;// ״̬ 0Ϊݿȡģ1Ϊģ2Ϊݿȡ޸˵ + + public int getMacId() { + return macId; + } + + public void setMacId(int macId) { + this.macId = macId; + } + + public int getAddId() { + return addId; + } + + public void setAddId(int addId) { + this.addId = addId; + } + + public int getStage() { + return stage; + } + + public void setStage(int stage) { + this.stage = stage; + } + + public ObservableValue typeProperty() { + return type; + } + + public ObservableValue projectProperty() { + return project; + } + + public ObservableValue costProperty() { + return cost; + } + + public String getType() { + return type.get(); + } + + public void setType(String type) { + this.type = new SimpleStringProperty(type); + } + + public String getProject() { + return project.get(); + } + + public void setProject(String project) { + this.project = new SimpleStringProperty(project); + } + + public String getCost() { + return cost.get(); + } + + public void setCost(String cost) { + this.cost = new SimpleStringProperty(cost); + ; + } +} diff --git a/src/com/connor/jd/plm/beans/ResultData.java b/src/com/connor/jd/plm/beans/ResultData.java new file mode 100644 index 0000000..ac5430d --- /dev/null +++ b/src/com/connor/jd/plm/beans/ResultData.java @@ -0,0 +1,39 @@ +package com.connor.jd.plm.beans; + +public class ResultData { + private boolean res; + private String Message; + private Object data; + + public ResultData(boolean res, String message, Object data) { + super(); + this.res = res; + Message = message; + this.data = data; + } + + public boolean isRes() { + return res; + } + + public void setRes(boolean res) { + this.res = res; + } + + public String getMessage() { + return Message; + } + + public void setMessage(String message) { + Message = message; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + +} diff --git a/src/com/connor/jd/plm/beans/TransformBomBean.java b/src/com/connor/jd/plm/beans/TransformBomBean.java new file mode 100644 index 0000000..19aba19 --- /dev/null +++ b/src/com/connor/jd/plm/beans/TransformBomBean.java @@ -0,0 +1,36 @@ +package com.connor.jd.plm.beans; + +import java.util.HashMap; +import java.util.Map; + +import javax.swing.Icon; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +public class TransformBomBean { + public String displayName; + public TCComponentBOMLine line; + public TCComponentItemRevision selectRev; + public Map map=new HashMap(); + + public TransformBomBean(TCComponentBOMLine line) { + // TODO Auto-generated constructor stub + try { + this.line = line; + this.displayName=line.getProperty("object_string"); + } catch (TCException e) { + // TODO Auto-generated catch blocks + e.printStackTrace(); + } + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return displayName; + } + +} diff --git a/src/com/connor/jd/plm/dialogs/BOMManagementFrame.java b/src/com/connor/jd/plm/dialogs/BOMManagementFrame.java new file mode 100644 index 0000000..16c1e2a --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/BOMManagementFrame.java @@ -0,0 +1,2325 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.sql.DataSource; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.SwingUtilities; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import com.connor.jd.plm.beans.BOMManageTableBean; +import com.connor.jd.plm.beans.CheckBoxPo; +import com.connor.jd.plm.beans.CustomLovBean; +import com.connor.jd.plm.beans.ResultData; +import com.connor.jd.plm.table.MyCellEditor4; +import com.connor.jd.plm.table.MyCellRenderer; +import com.connor.jd.plm.utils.DBConnectionUtil; +import com.connor.jd.plm.utils.DBUtil; +import com.connor.jd.plm.utils.DatePickerUtil; +import com.connor.jd.plm.utils.DialogUtil; +import com.connor.jd.plm.utils.JDMethodUtil; +import com.connor.jd.plm.utils.KeyValComboBox; +import com.connor.jd.plm.utils.SimpleExcelUtil; +import com.connor.jd.plm.utils.StringCreateUtil; +import com.eltima.components.ui.DatePicker; +import com.teamcenter.rac.aif.AIFClipboard; +import com.teamcenter.rac.aif.AIFPortal; +import com.teamcenter.rac.aif.AIFTransferable; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +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.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; + +public class BOMManagementFrame extends JFrame { + private AbstractAIFApplication app; + private TCSession session; + private CardLayout rootSwitch = new CardLayout(); + private String[] colDisplayNames = new String[] { "ѡ", "", "Ӽ", "λ", "", "״̬" }; + private String[] colDisplayNames2 = new String[] { "", "޸û", "ʱ", "" }; + private JPanel root; + private Map tableDataMap = new HashMap(); + private BOMManagementFrame $this; + private ArrayList> logDataList; + private Map winMap = new HashMap(); + private TCComponentItemRevision targetRev; + private TCComponentItemRevision targetRev2; + private boolean isLogcreated = false; + private int doIndex = 0; + private boolean complate = false; + private List checkItemType = new ArrayList(); + private JButton[] topBtns; + private TCComponentBOMWindowType winType; + private int width = 1200; + private int height = 800; + private int widthOffset = 0; + private int heightOffset = 0; + private JLabel p1TargetLabel; + private JButton p1TargetBtn; + private JLabel p1ReplaceLabel; + private JButton p1ReplaceBtn; + private JLabel p1UnitLabel; + private KeyValComboBox p1UnitCombo; + private JLabel p1NumLabel; + private JTextField p1NumText; + private JCheckBox p1SelectAll; + private JButton copyButton; + private JTable p1Table; + private JScrollPane p1jsp; + private JButton p1BottomBtn1; + private JButton p1BottomBtn2; + private JButton p1BottomBtn3; + private JButton p1BottomBtn4; + private JPanel p1Left; + private JScrollPane p1TreePanel; + private JPanel p1Right; + private JLabel p2TargetLabel; + private JButton p2TargetBtn; + private JLabel p2ChangeNumLabel; + private JTextField p2NumText; + private JCheckBox p2SelectAll; + private JTable p2Table; + private JScrollPane p2jsp; + private JButton p2BottomBtn1; + private JButton p2BottomBtn2; + private JButton p2BottomBtn3; + private JButton p2BottomBtn4; + private JPanel p2Left; + private JScrollPane p2TreePanel; + private JPanel p2Right; + private JLabel p3TargetLabel; + private JButton p3TargetBtn; + private JLabel p3AddLabel; + private JButton p3AddBtn; + private JLabel p3UnitLabel; + private KeyValComboBox p3UnitCombo; + private JLabel p3NumLabel; + private JTextField p3NumText; + private JCheckBox p3SelectAll; + private JTable p3Table; + private JScrollPane p3jsp; + private JButton p3BottomBtn1; + private JButton p3BottomBtn2; + private JButton p3BottomBtn3; + private JButton p3BottomBtn4; + private JPanel p3Left; + private JScrollPane p3TreePanel; + private JPanel p3Right; + private JLabel p4TargetLabel; + private JButton p4TargetBtn; + private JCheckBox p4SelectAll; + private JTable p4Table; + private JScrollPane p4jsp; + private JButton p4BottomBtn1; + private JButton p4BottomBtn2; + private JButton p4BottomBtn3; + private JButton p4BottomBtn4; + private JPanel p4Left; + private JScrollPane p4TreePanel; + private JPanel p4Right; + private JLabel p5UserLabel; + private JTextField p5UserText; + private JLabel p5TimeLabel; + private DatePicker p5TimeStartText; + private JLabel toLabel; + private DatePicker p5TimeEndText; + private JLabel p5ContentLabel; + private JTextArea p5ContentText; + private JScrollPane p5Contentjsp; + private JButton p5Search; + private JComboBox p5Download; + private JTable p5Table; + private JScrollPane p5jsp; + private Map uiSize = new HashMap(); + private JPanel p1; + private JPanel p2; + private JPanel p3; + private JPanel p4; + private JPanel p5; + private Set addedBOMLine = new HashSet(); + public static List itemList = new ArrayList(); + + public BOMManagementFrame(AbstractAIFApplication app) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + $this = this; + String[] prefArray = JDMethodUtil.getPrefStrArray("connor_bom_check_type", session); + if (prefArray != null) { + checkItemType = Arrays.asList(prefArray); + } + TCTypeService service = session.getTypeService(); + try { + this.winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + init(); + } + + private void init() { + this.setTitle("BOM"); + this.setSize(new Dimension(1200, 800)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + super.componentResized(e); + Component comp = e.getComponent(); + $this.widthOffset = comp.getWidth() - $this.width; + $this.heightOffset = comp.getHeight() - $this.height; + if ($this.widthOffset != 0 || $this.heightOffset != 0) { + System.out.println("width===>" + comp.getWidth()); + System.out.println("height===>" + comp.getHeight()); + $this.width = comp.getWidth(); + $this.height = comp.getHeight(); + $this.resize(); + } + } + }); + this.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + $this.setAlwaysOnTop(true); + } + }); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + container.setSize(new Dimension(1200, 800)); + + TCTypeService typeService = session.getTypeService(); + Vector unitVector = new Vector(); + try { + TCComponent[] uomArray = typeService.getTypeComponent("UnitOfMeasure").extent(); + unitVector.add(new CheckBoxPo(" ", " ")); + for (TCComponent comp : uomArray) { + unitVector.add(new CheckBoxPo(comp.toString(), comp)); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ͷ + JPanel topBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topBtns = new JButton[5]; + topBtns[0] = new JButton("滻"); + topBtns[1] = new JButton(""); + topBtns[2] = new JButton(""); + topBtns[3] = new JButton("ɾ"); + topBtns[4] = new JButton("־"); + + topBtns[0].setSelected(true); + for (JButton btn : topBtns) { + topBtnPanel.add(btn); + btn.addActionListener(panelSwitch()); + } + container.add(topBtnPanel, BorderLayout.NORTH); + root = new JPanel(rootSwitch); + + // 滻 + p1 = new JPanel(); + p1.setLayout(null); + + // 滻 + p1Left = new JPanel(); + p1Left.setLayout(null); + p1Left.setBounds(0, 0, 800, 800); + p1Left.setBorder(BorderFactory.createEtchedBorder()); + + p1TargetLabel = new JLabel("Ŀԭͼ"); + p1TargetLabel.setBounds(20, 20, 100, 25); + p1TargetBtn = new JButton(); + p1TargetBtn.setBounds(130, 20, 400, 25); + p1ReplaceLabel = new JLabel("滻ԭͼ"); + p1ReplaceLabel.setBounds(20, 60, 100, 25); + p1ReplaceBtn = new JButton(); + p1ReplaceBtn.setBounds(130, 60, 400, 25); + p1UnitLabel = new JLabel("λ"); + p1UnitLabel.setBounds(560, 60, 50, 25); + p1UnitCombo = new KeyValComboBox(unitVector); + p1UnitCombo.setBounds(610, 60, 50, 25); + p1NumLabel = new JLabel(""); + p1NumLabel.setBounds(680, 60, 50, 25); + p1NumText = new JTextField(); + p1NumText.setBounds(730, 60, 50, 25); + p1SelectAll = new JCheckBox("ȫѡ"); + p1SelectAll.setBounds(20, 100, 100, 25); + copyButton = new JButton(""); + copyButton.setBounds(120, 100, 60, 25); + DefaultTableModel p1model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p1Table = new JTable(p1model); + p1Table.getColumnModel().getColumn(0).setMinWidth(60); + p1Table.getColumnModel().getColumn(0).setMaxWidth(60); + p1Table.getColumnModel().getColumn(1).setMinWidth(200); + p1Table.getColumnModel().getColumn(2).setMinWidth(200); + p1Table.getColumnModel().getColumn(3).setMinWidth(100); + p1Table.getColumnModel().getColumn(4).setMinWidth(100); + p1Table.getColumnModel().getColumn(5).setMinWidth(100); + p1Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p1Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p1Table.setRowHeight(25); + p1Table.setAutoscrolls(true); + p1Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p1Table.getTableHeader().setReorderingAllowed(false); + p1Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p1sorter = new TableRowSorter(p1model); + p1Table.setRowSorter(p1sorter); + p1jsp = new JScrollPane(p1Table); + p1jsp.setBounds(20, 130, 760, 500); + + p1BottomBtn1 = new JButton(""); + p1BottomBtn1.setBounds(80, 650, 100, 25); + p1BottomBtn2 = new JButton("滻"); + p1BottomBtn2.setBounds(260, 650, 100, 25); + p1BottomBtn3 = new JButton(""); + p1BottomBtn3.setBounds(440, 650, 100, 25); + p1BottomBtn4 = new JButton("ȡ"); + p1BottomBtn4.setBounds(620, 650, 100, 25); + + p1Left.add(p1TargetLabel); + p1Left.add(p1TargetBtn); + p1Left.add(p1ReplaceLabel); + p1Left.add(p1ReplaceBtn); + // p1Left.add(p1UnitLabel); + // p1Left.add(p1UnitCombo); + p1Left.add(p1NumLabel); + p1Left.add(p1NumText); + p1Left.add(p1SelectAll); + p1Left.add(copyButton); + p1Left.add(p1jsp); + p1Left.add(p1BottomBtn1); + p1Left.add(p1BottomBtn2); + p1Left.add(p1BottomBtn3); + p1Left.add(p1BottomBtn4); + + // 滻ұ + p1Right = new JPanel(); + p1Right.setLayout(null); + p1Right.setBounds(800, 0, 400, 800); + p1Right.setBorder(BorderFactory.createEtchedBorder()); + + p1TreePanel = new JScrollPane(); + p1TreePanel.setBounds(20, 130, 360, 500); + p1Right.add(p1TreePanel); + + // ¼ + p1SelectAll.addItemListener(selectAll(p1Table)); + copyButton.addActionListener(copy(p1Table)); + p1Table.addMouseListener(showTree(p1Right)); + p1BottomBtn4.addActionListener(cancel()); + p1BottomBtn1.addActionListener(batchRevise(p1Table, p1SelectAll)); + p1BottomBtn2.addActionListener(batchReplace()); + p1BottomBtn3.addActionListener(startWorkFlow(p1Table)); + p1TargetBtn.addActionListener(clickSearch(p1Table, p1SelectAll)); + p1ReplaceBtn.addActionListener(clickSearch(null, null)); + + p1.add(p1Left); + p1.add(p1Right); + + // + p2 = new JPanel(); + p2.setLayout(null); + + // + p2Left = new JPanel(); + p2Left.setLayout(null); + p2Left.setBounds(0, 0, 800, 800); + p2Left.setBorder(BorderFactory.createEtchedBorder()); + + p2TargetLabel = new JLabel("Ŀԭͼ"); + p2TargetLabel.setBounds(20, 20, 100, 25); + p2TargetBtn = new JButton(); + p2TargetBtn.setBounds(130, 20, 400, 25); + p2ChangeNumLabel = new JLabel(""); + p2ChangeNumLabel.setBounds(20, 60, 100, 25); + p2NumText = new JTextField(); + p2NumText.setBounds(130, 60, 50, 25); + + p2SelectAll = new JCheckBox("ȫѡ"); + p2SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p2model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p2Table = new JTable(p2model); + p2Table.getColumnModel().getColumn(0).setMinWidth(60); + p2Table.getColumnModel().getColumn(0).setMaxWidth(60); + p2Table.getColumnModel().getColumn(1).setMinWidth(200); + p2Table.getColumnModel().getColumn(2).setMinWidth(200); + p2Table.getColumnModel().getColumn(3).setMinWidth(100); + p2Table.getColumnModel().getColumn(4).setMinWidth(100); + p2Table.getColumnModel().getColumn(5).setMinWidth(100); + p2Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p2Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p2Table.setRowHeight(25); + p2Table.setAutoscrolls(true); + p2Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p2Table.getTableHeader().setReorderingAllowed(false); + p2Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p2sorter = new TableRowSorter(p2model); + p2Table.setRowSorter(p2sorter); + p2jsp = new JScrollPane(p2Table); + p2jsp.setBounds(20, 130, 760, 500); + + p2BottomBtn1 = new JButton(""); + p2BottomBtn1.setBounds(80, 650, 100, 25); + p2BottomBtn2 = new JButton(""); + p2BottomBtn2.setBounds(260, 650, 100, 25); + p2BottomBtn3 = new JButton(""); + p2BottomBtn3.setBounds(440, 650, 100, 25); + p2BottomBtn4 = new JButton("ȡ"); + p2BottomBtn4.setBounds(620, 650, 100, 25); + + p2Left.add(p2TargetLabel); + p2Left.add(p2TargetBtn); + p2Left.add(p2ChangeNumLabel); + p2Left.add(p2NumText); + p2Left.add(p2SelectAll); + p2Left.add(p2jsp); + p2Left.add(p2BottomBtn1); + p2Left.add(p2BottomBtn2); + p2Left.add(p2BottomBtn3); + p2Left.add(p2BottomBtn4); + + // ұ + p2Right = new JPanel(); + p2Right.setLayout(null); + p2Right.setBounds(800, 0, 400, 800); + p2Right.setBorder(BorderFactory.createEtchedBorder()); + + p2TreePanel = new JScrollPane(); + p2TreePanel.setBounds(20, 130, 360, 500); + p2Right.add(p2TreePanel); + + // ¼ + p2SelectAll.addItemListener(selectAll(p2Table)); + p2Table.addMouseListener(showTree(p2Right)); + p2BottomBtn4.addActionListener(cancel()); + p2BottomBtn1.addActionListener(batchRevise(p2Table, p2SelectAll)); + p2BottomBtn2.addActionListener(batchModify()); + p2BottomBtn3.addActionListener(startWorkFlow(p2Table)); + p2TargetBtn.addActionListener(clickSearch(p2Table, p2SelectAll)); + + p2.add(p2Left); + p2.add(p2Right); + + // + p3 = new JPanel(); + p3.setLayout(null); + + // + p3Left = new JPanel(); + p3Left.setLayout(null); + p3Left.setBounds(0, 0, 800, 800); + p3Left.setBorder(BorderFactory.createEtchedBorder()); + + p3TargetLabel = new JLabel("οԭͼ"); + p3TargetLabel.setBounds(20, 20, 100, 25); + p3TargetBtn = new JButton(); + p3TargetBtn.setBounds(130, 20, 400, 25); + p3AddLabel = new JLabel("ԭͼ"); + p3AddLabel.setBounds(20, 60, 100, 25); + p3AddBtn = new JButton(); + p3AddBtn.setBounds(130, 60, 400, 25); + p3UnitLabel = new JLabel("λ"); + p3UnitLabel.setBounds(560, 60, 50, 25); + p3UnitCombo = new KeyValComboBox(unitVector); + p3UnitCombo.setBounds(610, 60, 50, 25); + p3NumLabel = new JLabel(""); + p3NumLabel.setBounds(680, 60, 50, 25); + p3NumText = new JTextField(); + p3NumText.setBounds(730, 60, 50, 25); + + p3SelectAll = new JCheckBox("ȫѡ"); + p3SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p3model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p3Table = new JTable(p3model); + p3Table.getColumnModel().getColumn(0).setMinWidth(60); + p3Table.getColumnModel().getColumn(0).setMaxWidth(60); + p3Table.getColumnModel().getColumn(1).setMinWidth(200); + p3Table.getColumnModel().getColumn(2).setMinWidth(200); + p3Table.getColumnModel().getColumn(3).setMinWidth(100); + p3Table.getColumnModel().getColumn(4).setMinWidth(100); + p3Table.getColumnModel().getColumn(5).setMinWidth(100); + p3Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p3Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p3Table.setRowHeight(25); + p3Table.setAutoscrolls(true); + p3Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p3Table.getTableHeader().setReorderingAllowed(false); + p3Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p3sorter = new TableRowSorter(p3model); + p3Table.setRowSorter(p3sorter); + p3jsp = new JScrollPane(p3Table); + p3jsp.setBounds(20, 130, 760, 500); + + p3BottomBtn1 = new JButton(""); + p3BottomBtn1.setBounds(80, 650, 100, 25); + p3BottomBtn2 = new JButton(""); + p3BottomBtn2.setBounds(260, 650, 100, 25); + p3BottomBtn3 = new JButton(""); + p3BottomBtn3.setBounds(440, 650, 100, 25); + p3BottomBtn4 = new JButton("ȡ"); + p3BottomBtn4.setBounds(620, 650, 100, 25); + + p3Left.add(p3TargetLabel); + p3Left.add(p3TargetBtn); + p3Left.add(p3AddLabel); + p3Left.add(p3AddBtn); + p3Left.add(p3UnitLabel); + p3Left.add(p3UnitCombo); + p3Left.add(p3NumLabel); + p3Left.add(p3NumText); + p3Left.add(p3SelectAll); + p3Left.add(p3jsp); + p3Left.add(p3BottomBtn1); + p3Left.add(p3BottomBtn2); + p3Left.add(p3BottomBtn3); + p3Left.add(p3BottomBtn4); + + // ұ + p3Right = new JPanel(); + p3Right.setLayout(null); + p3Right.setBounds(800, 0, 400, 800); + p3Right.setBorder(BorderFactory.createEtchedBorder()); + + p3TreePanel = new JScrollPane(); + p3TreePanel.setBounds(20, 130, 360, 500); + p3Right.add(p3TreePanel); + + // ¼ + p3SelectAll.addItemListener(selectAll(p3Table)); + p3Table.addMouseListener(showTree(p3Right)); + p3BottomBtn4.addActionListener(cancel()); + p3BottomBtn1.addActionListener(batchRevise(p3Table, p3SelectAll)); + p3BottomBtn2.addActionListener(batchAdd()); + p3BottomBtn3.addActionListener(startWorkFlow(p3Table)); + p3TargetBtn.addActionListener(clickSearch(p3Table, p3SelectAll)); + p3AddBtn.addActionListener(clickSearch(null, null)); + + p3.add(p3Left); + p3.add(p3Right); + + // ɾ + p4 = new JPanel(); + p4.setLayout(null); + + // ɾ + p4Left = new JPanel(); + p4Left.setLayout(null); + p4Left.setBounds(0, 0, 800, 800); + p4Left.setBorder(BorderFactory.createEtchedBorder()); + + p4TargetLabel = new JLabel("Ŀԭͼ"); + p4TargetLabel.setBounds(20, 20, 100, 25); + p4TargetBtn = new JButton(); + p4TargetBtn.setBounds(130, 20, 400, 25); + + p4SelectAll = new JCheckBox("ȫѡ"); + p4SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p4model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p4Table = new JTable(p4model); + p4Table.getColumnModel().getColumn(0).setMinWidth(60); + p4Table.getColumnModel().getColumn(0).setMaxWidth(60); + p4Table.getColumnModel().getColumn(1).setMinWidth(200); + p4Table.getColumnModel().getColumn(2).setMinWidth(200); + p4Table.getColumnModel().getColumn(3).setMinWidth(100); + p4Table.getColumnModel().getColumn(4).setMinWidth(100); + p4Table.getColumnModel().getColumn(5).setMinWidth(100); + p4Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p4Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p4Table.setRowHeight(25); + p4Table.setAutoscrolls(true); + p4Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p4Table.getTableHeader().setReorderingAllowed(false); + p4Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p4sorter = new TableRowSorter(p4model); + p4Table.setRowSorter(p4sorter); + p4jsp = new JScrollPane(p4Table); + p4jsp.setBounds(20, 130, 760, 500); + + p4BottomBtn1 = new JButton(""); + p4BottomBtn1.setBounds(80, 650, 100, 25); + p4BottomBtn2 = new JButton("ɾ"); + p4BottomBtn2.setBounds(260, 650, 100, 25); + p4BottomBtn3 = new JButton(""); + p4BottomBtn3.setBounds(440, 650, 100, 25); + p4BottomBtn4 = new JButton("ȡ"); + p4BottomBtn4.setBounds(620, 650, 100, 25); + + p4Left.add(p4TargetLabel); + p4Left.add(p4TargetBtn); + p4Left.add(p4SelectAll); + p4Left.add(p4jsp); + p4Left.add(p4BottomBtn1); + p4Left.add(p4BottomBtn2); + p4Left.add(p4BottomBtn3); + p4Left.add(p4BottomBtn4); + + // ұ + p4Right = new JPanel(); + p4Right.setLayout(null); + p4Right.setBounds(800, 0, 400, 800); + p4Right.setBorder(BorderFactory.createEtchedBorder()); + + p4TreePanel = new JScrollPane(); + p4TreePanel.setBounds(20, 130, 360, 500); + p4Right.add(p4TreePanel); + + // ¼ + p4SelectAll.addItemListener(selectAll(p4Table)); + p4Table.addMouseListener(showTree(p4Right)); + p4BottomBtn4.addActionListener(cancel()); + p4BottomBtn1.addActionListener(batchRevise(p4Table, p4SelectAll)); + p4BottomBtn2.addActionListener(batchRemove()); + p4BottomBtn3.addActionListener(startWorkFlow(p4Table)); + p4TargetBtn.addActionListener(clickSearch(p4Table, p4SelectAll)); + + p4.add(p4Left); + p4.add(p4Right); + + // ־ + p5 = new JPanel(); + p5.setLayout(null); + + p5UserLabel = new JLabel("޸û"); + p5UserLabel.setBounds(20, 40, 70, 25); + p5UserText = new JTextField(); + p5UserText.setBounds(100, 40, 150, 25); + p5TimeLabel = new JLabel("޸ʱ"); + p5TimeLabel.setBounds(300, 40, 70, 25); + p5TimeStartText = DatePickerUtil.getDatePicker(null); + p5TimeStartText.setBounds(380, 40, 100, 25); + toLabel = new JLabel(""); + toLabel.setBounds(490, 40, 20, 25); + p5TimeEndText = DatePickerUtil.getDatePicker(null); + p5TimeEndText.setBounds(520, 40, 100, 25); + p5ContentLabel = new JLabel("޸"); + p5ContentLabel.setBounds(670, 40, 70, 25); + p5ContentText = new JTextArea(); + p5ContentText.setLineWrap(true); + p5ContentText.setWrapStyleWord(true); + p5Contentjsp = new JScrollPane(p5ContentText); + p5Contentjsp.setBounds(750, 20, 200, 80); + p5Search = new JButton(""); + p5Search.setBounds(1000, 40, 60, 25); + p5Download = new JComboBox(); + p5Download.addItem("־"); + p5Download.addItem("Ϊtxt"); + p5Download.addItem("Ϊexcel"); + p5Download.setSelectedItem("־"); + p5Download.setBounds(1080, 40, 100, 25); + + DefaultTableModel p5model = new DefaultTableModel(colDisplayNames2, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p5Table = new JTable(p5model); + p5Table.getColumnModel().getColumn(0).setMinWidth(60); + p5Table.getColumnModel().getColumn(0).setMaxWidth(60); + p5Table.getColumnModel().getColumn(1).setMinWidth(200); + p5Table.getColumnModel().getColumn(2).setMinWidth(200); + p5Table.getColumnModel().getColumn(3).setMinWidth(700); + p5Table.setRowHeight(25); + p5Table.setAutoscrolls(true); + p5Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p5Table.getTableHeader().setReorderingAllowed(false); + RowSorter p5sorter = new TableRowSorter(p5model); + p5Table.setRowSorter(p5sorter); + p5jsp = new JScrollPane(p5Table); + p5jsp.setBounds(20, 130, 1160, 580); + + // ¼ + p5Search.addActionListener(searchLog()); + p5Download.addItemListener(downloadLog(p5Table)); + p5UserText.addKeyListener(logSearchEnter()); + p5TimeStartText.addKeyListener(logSearchEnter()); + p5TimeEndText.addKeyListener(logSearchEnter()); + + p5.add(p5UserLabel); + p5.add(p5UserText); + p5.add(p5TimeLabel); + p5.add(p5TimeStartText); + p5.add(toLabel); + p5.add(p5TimeEndText); + p5.add(p5ContentLabel); + p5.add(p5Contentjsp); + p5.add(p5Search); + p5.add(p5Download); + p5.add(p5jsp); + + root.add("batchReplace", p1); + root.add("batchModify", p2); + root.add("batchAdd", p3); + root.add("batchRemove", p4); + root.add("updateLog", p5); + + rootSwitch.show(root, "batchReplace"); + container.add(root, BorderLayout.CENTER); + this.setVisible(true); + } + + private ActionListener copy(final JTable table) { + + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List isSelectComp = new ArrayList(); + StringBuilder haveStringBuilder = new StringBuilder(); + haveStringBuilder.append(""); + haveStringBuilder.append("\n"); + for (int i = 0; i < table.getRowCount(); i++) { + if(((JCheckBox) table.getValueAt(i, 0)).isSelected()) { + try { + isSelectComp.add(((TCComponentItemRevision)itemList.get(i)).getItem().getLatestItemRevision()); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + haveStringBuilder.append(table.getValueAt(i, 1).toString()); + haveStringBuilder.append("\n"); + } + } + haveStringBuilder.append("ѸƵа"); + //Ƶа + AIFClipboard cutBoard = AIFPortal.getClipboard(); + AIFTransferable aIFTransferable = new AIFTransferable(isSelectComp); + cutBoard.setContents(aIFTransferable, null); + + JTextArea textArea = new JTextArea(haveStringBuilder.toString()); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setPreferredSize(new Dimension(400, 300)); + JOptionPane.showMessageDialog($this, scrollPane, "ʾ", + JOptionPane.WARNING_MESSAGE); + } + }; + } + + private ActionListener panelSwitch() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + String text = ((JButton) e.getSource()).getText(); + + for (int i = 0; i < topBtns.length; i++) { + topBtns[i].setSelected(topBtns[i].getText().equals(text)); + } + + if ("滻".equals(text)) { + clearTable(p1Table, p1SelectAll); + p1Right.removeAll(); + JScrollPane panel1 = new JScrollPane(); + panel1.setBounds(p1TreePanel.getX(), p1TreePanel.getY(), p1TreePanel.getWidth(), + p1TreePanel.getHeight()); + p1TreePanel = panel1; + p1Right.add(panel1); + p1Right.revalidate(); + p1Right.repaint(); + rootSwitch.show(root, "batchReplace"); + } else if ("".equals(text)) { + clearTable(p2Table, p2SelectAll); + p2Right.removeAll(); + JScrollPane panel2 = new JScrollPane(); + panel2.setBounds(p2TreePanel.getX(), p2TreePanel.getY(), p2TreePanel.getWidth(), + p2TreePanel.getHeight()); + p2TreePanel = panel2; + p2Right.add(panel2); + p2Right.revalidate(); + p2Right.repaint(); + rootSwitch.show(root, "batchModify"); + } else if ("".equals(text)) { + clearTable(p3Table, p3SelectAll); + p3Right.removeAll(); + JScrollPane panel3 = new JScrollPane(); + panel3.setBounds(p3TreePanel.getX(), p3TreePanel.getY(), p3TreePanel.getWidth(), + p3TreePanel.getHeight()); + p3TreePanel = panel3; + p3Right.add(panel3); + p3Right.revalidate(); + p3Right.repaint(); + rootSwitch.show(root, "batchAdd"); + } else if ("ɾ".equals(text)) { + clearTable(p4Table, p4SelectAll); + p4Right.removeAll(); + JScrollPane panel4 = new JScrollPane(); + panel4.setBounds(p4TreePanel.getX(), p4TreePanel.getY(), p4TreePanel.getWidth(), + p4TreePanel.getHeight()); + p4TreePanel = panel4; + p4Right.add(panel4); + p4Right.revalidate(); + p4Right.repaint(); + rootSwitch.show(root, "batchRemove"); + } else if ("־".equals(text)) { + createLogDataSourceTable(); + clearTable(p5Table, null); + rootSwitch.show(root, "updateLog"); + } + } + }; + } + + private void showWhereUesd(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + // TODO Auto-generated method stub + clearTable(table, selectAll); + if (table == null || targetRev == null) { + return; + } + long startTime = System.currentTimeMillis(); + List tableDataList = new ArrayList(); + try { + String revString = targetRev.getProperty("object_string"); + TCComponent[] usedComps = targetRev.whereUsed((short) 0); + System.out.println("װ======>" + usedComps.length); + + tableDataMap.clear(); +// Map usedMap = usedFilter(usedComps); +// for (Entry entry : usedMap.entrySet()) { + for (TCComponentItemRevision parentRev : usedFilter(usedComps)) { +// TCComponentItemRevision parentRev = entry.getValue(); + String parentString = parentRev.getProperty("object_string"); + + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.put(parentString, win); + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (revString.equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + Object[] rowData = new Object[] { new JCheckBox(), parentString, revString, unit, num, status }; + rowPrint(rowData); + tableDataList.add(rowData); + tableDataMap.put(parentString, + new BOMManageTableBean(parentString, revString, parentRev, targetRev, topLine, child)); + // TODO bomһchildܻ쳣ֻӰһ + break; + } + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + if (tableDataList == null || tableDataList.size() == 0) { + JOptionPane.showMessageDialog($this, "ҵӦ󣬵öûκװװöľ°汾ȷϱǷȷ", "ʾ", + JOptionPane.WARNING_MESSAGE); + return; + } + + for (Object[] rowData : tableDataList) { + model.addRow(rowData); + } + table.revalidate(); + table.repaint(); + System.out.println("װʾɣʱ" + (System.currentTimeMillis() - startTime) + "ms"); + } + + private MouseAdapter showTree(final JPanel panelRight) { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + JTable table = (JTable) e.getSource(); + String parentString = table.getValueAt(table.getSelectedRow(), 1).toString(); + System.out.println("select row=====>" + table.getSelectedRow()); + System.out.println("parentName=====>" + parentString); + CustomLovBean lovBean = null; + try { + lovBean = new CustomLovBean(tableDataMap.get(parentString).getChildString()); + CustomLovBean subBean = new CustomLovBean(parentString); + lovBean.addSub(subBean); + getTreeData(tableDataMap.get(parentString).getParentRev(), subBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + panelRight.removeAll(); + JTree tree = createTree(lovBean); + JScrollPane treePanel = new JScrollPane(tree); + treePanel.setBounds(20, 130, 360, 500); + panelRight.add(treePanel); + panelRight.revalidate(); + panelRight.repaint(); + } + } + }; + } + + private void getTreeData(TCComponent rev, CustomLovBean lov) throws TCException { + TCComponent[] comps = rev.whereUsed((short) 0); + if (comps == null || comps.length == 0) { + return; + } + for (TCComponent comp : comps) { + CustomLovBean sub = new CustomLovBean(comp.getProperty("object_string")); + System.out.println(sub.displayName); + lov.addSub(sub); + getTreeData(comp, sub); + } + } + + private void clearTable(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int cnt = model.getRowCount(); + for (int i = 0; i < cnt; i++) { + model.removeRow(0); + } + table.revalidate(); + table.repaint(); + if (selectAll != null) { + selectAll.setSelected(false); + } + tableDataMap.clear(); + addedBOMLine.clear(); + try { + closeWin(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JTree createTree(CustomLovBean lovData) { + if (lovData == null || "".equals(lovData.displayName)) { + return new JTree(); + } + DefaultMutableTreeNode root = new DefaultMutableTreeNode(lovData.displayName); + DefaultMutableTreeNode parent = root; + DefaultTreeModel treeModel = new DefaultTreeModel(root); + + initTree(lovData, parent, treeModel); + + JTree tree = new JTree(treeModel); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + cellRenderer.setTextNonSelectionColor(Color.black); + cellRenderer.setTextSelectionColor(Color.blue); + return tree; + } + + private void initTree(CustomLovBean lovData, DefaultMutableTreeNode parent, DefaultTreeModel treeModel) { + if (!lovData.hasChild()) { + return; + } + List subList = lovData.getSub(); + for (CustomLovBean sub : subList) { + DefaultMutableTreeNode temp = new DefaultMutableTreeNode(sub.displayName); + treeModel.insertNodeInto(temp, parent, parent.getChildCount()); + initTree(sub, temp, treeModel); + } + } + + private ItemListener selectAll(final JTable table) { + return new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + boolean select = ((JCheckBox) e.getSource()).isSelected(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox checkBox = (JCheckBox) table.getValueAt(i, 0); + checkBox.setSelected(select); + table.revalidate(); + table.repaint(); + } + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + $this.dispose(); + } + }; + } + + private ActionListener batchRevise(final JTable table, JCheckBox selectAll) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkAccess(selectedRowList).isRes()) { + return; + } + List msgData = new ArrayList(); + for (int i = 0; i < selectedRowList.size(); i++) { + try { + TCComponentItemRevision newRev = selectedRowList.get(i).getParentRev().saveAs(null); + String parentString = newRev.getProperty("object_string"); + msgData.add(new String[] { msgData.size() + 1 + "", selectedRowList.get(i).getParentString(), + newRev.getProperty("object_string"), "ɹ" }); + selectedRowList.get(i).setParentRev(newRev); + selectedRowList.get(i).setParentString(parentString); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); +// JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + msgData.add(new String[] { msgData.size() + 1 + "", selectedRowList.get(i).getParentString(), + "", "ʧܣ鿴Ƿظ棬ϸϢ" + e1.getMessage() }); + } + } + +// showWhereUesd(table, selectAll); + updateSelectedRow(table, selectedRowList); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "汾(ǰ)", "汾()", "" }, + msgData).panel; + JOptionPane.showMessageDialog($this, jsp, "", JOptionPane.PLAIN_MESSAGE); + } + }; + } + + private List usedFilter(TCComponent[] comps) throws TCException { +// Map sameParentUsedMap = new HashMap(); + List list = new ArrayList(); + if(itemList.size()>0) { + itemList.clear(); + } + + for (TCComponent comp : comps) { + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; +// String itemId; +// if (sameParentUsedMap.containsKey(itemId = comp.getProperty("item_id"))) { +// if (sameParentUsedMap.get(itemId).getProperty("item_revision_id") +// .compareTo(comp.getProperty("item_revision_id")) < 0) { +// sameParentUsedMap.put(itemId, rev); +// } +// } else { + if (rev.getItem().getLatestItemRevision().getUid().equals(rev.getUid())) { + list.add(rev); + itemList.add(rev); + } +// sameParentUsedMap.put(itemId, rev); +// } + } + } + return list; + } + + private void createLogDataSourceTable() { + if (isLogcreated) { + return; + } + String sql1 = "IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'PX_BOMManageLog') " + + "CREATE TABLE PX_BOMManageLog (" + "id BIGINT PRIMARY KEY IDENTITY(1, 1), " + + "modify_user NVARCHAR(200), " + "modify_time DATETIME, " + "modify_content NVARCHAR(500) " + ")"; + + DataSource dataSource = DBUtil.getDataSource(session); + Connection conn = null; + Statement stmt = null; + ResultSet rs = null; + try { + conn = dataSource.getConnection(); + stmt = conn.createStatement(); + stmt.executeUpdate(sql1); + System.out.println("PX_BOMManageLog create success"); + + isLogcreated = true; + System.out.println("init log success"); + } catch (SQLException e) { + JOptionPane.showMessageDialog(null, "ݿʧܣѡpx_db_link", "", JOptionPane.ERROR_MESSAGE); + e.printStackTrace(); + } finally { + try { + if (rs != null) { + rs.close(); + } + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + private ActionListener searchLog() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String username = p5UserText.getText().trim(); + String content = p5ContentText.getText(); + if (username == null || "".equals(username)) { + return; + } + + String sql = "select * from \"PX_BOMManageLog\" where "; + if (!"*".equals(username)) { + sql += "modify_user like '%" + username + "%' and"; + } + sql += " modify_time BETWEEN CONVERT(datetime, '" + p5TimeStartText.getText() + + " 00:00:00', 120) AND CONVERT(datetime, '" + p5TimeEndText.getText() + " 23:59:59', 120)"; + if (content != null && !"".equals(content)) { + sql += " and modify_content like '%" + content + "%'"; + } + sql += "order by modify_time asc"; + System.out.println(sql); + try { + Connection conn = DBUtil.getDataSource(session).getConnection(); + PreparedStatement pstmt = conn.prepareStatement(sql); + ResultSet rs = pstmt.executeQuery(); + + logDataList = new ArrayList>(); + while (rs.next()) { + HashMap record = new HashMap(); + record.put("ͼ", rs.getObject("id")); + record.put("޸", rs.getString("modify_user")); + record.put("޸ʱ", rs.getTimestamp("modify_time").toString()); // תΪҪڸʽ + record.put("޸", rs.getString("modify_content")); + System.out.println("ʼȡݿݵmap"); + logDataList.add(record); + + } + // ѭlogDataList + for (HashMap logData : logDataList) { + System.out.println("Log Data:"); + for (Map.Entry entry : logData.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + + System.out.printf("key:"+key+",value:"+value); + } + System.out.println(); // ӿзָͬlog + } + final DefaultTableModel model = new DefaultTableModel(); + model.setColumnIdentifiers(new String[] { "ͼ", "޸", "޸ʱ", "޸" }); + DefaultTableModel model1 = (DefaultTableModel) p5Table.getModel(); + for (int a = 0;a entity = logDataList.get(a); + + Object[] rowData = new Object[] { entity.get("ͼ"), entity.get("޸"), + entity.get("޸ʱ"), entity.get("޸") }; + model1.addRow(rowData); + + p5Table.repaint(); + } + + +// for (HashMap entity : logDataList) { +// Object[] rowData = new Object[] { entity.get("ͼ"), entity.get("޸"), +// entity.get("޸ʱ"), entity.get("޸") }; +// System.out.println(rowData.toString()); +// p5Table.setValueAt(e, ERROR, ABORT); +// model.addRow(rowData); +// } +// +// p5Table.setModel(model); + + rs.close(); + pstmt.close(); + conn.close(); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + //p5Table.setModel(model); + p5Table.revalidate(); + p5Table.repaint(); + } + }); + + } catch (SQLException e1) { + e1.printStackTrace(); + return; + } + p5Table.revalidate(); + p5Table.repaint(); + + } + }; + } + + private ItemListener downloadLog(final JTable table) { + return new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent paramItemEvent) { + // TODO Auto-generated method stub + if (paramItemEvent.getStateChange() == ItemEvent.DESELECTED) { + return; + } + String selectItem = ((JComboBox) paramItemEvent.getSource()).getSelectedItem().toString(); + System.out.println(selectItem); + if (!selectItem.contains("txt") && !selectItem.contains("excel")) { + return; + } + if (table.getRowCount() > 0) { + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setMultiSelectionEnabled(false); + chooser.setCurrentDirectory(FileSystemView.getFileSystemView().getHomeDirectory()); + chooser.showOpenDialog($this); + File folder = chooser.getSelectedFile(); + if (folder == null) { + p5Download.setSelectedItem("־"); + return; + } + String fileName = ""; + if (selectItem.contains("txt")) { + FileWriter fileWriter = null; + fileName = "BOM־-" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + ".txt"; + try { + fileWriter = new FileWriter(folder.getPath() + File.separator + fileName); // ıļ + String temp; + System.out.println(logDataList.size()); + for (HashMap map : logDataList) { + fileWriter.write((temp = map.get("ID").toString()) + + StringCreateUtil.createBlank(10 - temp.length()) + + (temp = map.get("MODIFY_USER").toString()) + + StringCreateUtil.createBlank(20 - temp.length()) + + (temp = map.get("MODIFY_TIME").toString()) + + StringCreateUtil.createBlank(30 - temp.length()) + + map.get("MODIFY_CONTENT").toString() + "\r\n"); + } + fileWriter.flush(); + fileWriter.close(); + } catch (IOException e1) { + e1.printStackTrace(); + return; + } + } else { + fileName = "BOM־-" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + ".xlsx"; + String[] header = new String[] { "", "޸û", "ʱ", "" }; + List data = new ArrayList(); + System.out.println(logDataList.size()); + for (HashMap map : logDataList) { + data.add(new String[] { map.get("ID").toString(), map.get("MODIFY_USER").toString(), + map.get("MODIFY_TIME").toString(), map.get("MODIFY_CONTENT").toString() }); + } + SimpleExcelUtil.exportExcel(folder.getPath() + File.separator + fileName, header, data); + } + + JOptionPane.showMessageDialog($this, "־ɹ\r\n·" + folder + File.separator + fileName, "ʾ", + JOptionPane.WARNING_MESSAGE); + p5Download.setSelectedItem("־"); + } + } + }; + + } + + private ActionListener batchReplace() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p1NumText.getText().trim(); + // String text = p1UnitCombo.getSelectedText().trim(); + // Object value = p1UnitCombo.getSelectedValue(); + System.out.println(numStr); +// if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { +// JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); +// return; +// } + List selectedRowList = getselectedRow(p1Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + L1: for (int i = 0; i < selectedRowList.size(); i++) { + try { + doIndex++; + BOMManageTableBean bean = selectedRowList.get(i); + // System.out.println(value.toString()); + if (!addedBOMLine.add(bean.getParentRev().getUid() + targetRev2.getUid())) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), targetRev2.getProperty("object_string"), numStr, + "ʧܣ滻һΣ滻" }); + continue L1; + } +// AIFComponentContext[] aifs = bean.getParentLine().getChildren(); +// for (AIFComponentContext aif : aifs) { +// String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() +// .getProperty("object_string"); +// if (objStr.equals(targetRev2.getProperty("object_string"))) { +// msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), +// bean.getChildString(), targetRev2.getProperty("object_string"), numStr, +// "ʧܣѴͬӼ" }); +// continue L1; +// } +// } + String seq = selectedRowList.get(i).getChildLine().getProperty("bl_sequence_no"); + bean.getParentLine().remove("", bean.getChildLine()); + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + // childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity", "bl_sequence_no" }, + new String[] { numStr, seq }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), targetRev2.getProperty("object_string"), numStr, "ɹ" }); + selectedRowList.get(i).setChildString(targetRev2.getProperty("object_string")); + selectedRowList.get(i).setChildRev(targetRev2); + selectedRowList.get(i).setChildLine(childLine); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("滻ִϣʱ" + (endTime - startTime) + "ms"); + doLog("滻", msgData); + JScrollPane jsp = DialogUtil + .createTableMsg(new String[] { "", "", "ԭӼ", "滻Ӽ", "", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "滻 ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow2(p1Table, selectedRowList); + } + }; + } + + private ActionListener batchModify() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p2NumText.getText(); + List selectedRowList = getselectedRow(p2Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + for (BOMManageTableBean bean : selectedRowList) { + String oldNumStr = ""; + try { + doIndex++; + oldNumStr = bean.getChildLine().getProperty("bl_quantity"); + bean.getChildLine().setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), oldNumStr, numStr, "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("޸", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "ԭ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "Ľ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow(p2Table, selectedRowList); + } + }; + } + + private ActionListener batchAdd() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p3NumText.getText().trim(); + String text = p3UnitCombo.getSelectedText().trim(); + Object value = p3UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p3Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + L1: for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + System.out.println(value.toString()); + if (!addedBOMLine.add(bean.getParentRev().getUid() + targetRev2.getUid())) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, + "ʧܣӹһΣظ" }); + continue L1; + } +// AIFComponentContext[] aifs = bean.getParentLine().getChildren(); +// for (AIFComponentContext aif : aifs) { +// String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() +// .getProperty("object_string"); +// if (objStr.equals(targetRev2.getProperty("object_string"))) { +// msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), +// targetRev2.getProperty("object_string"), value.toString(), numStr, +// "ʧܣѴͬӼ" }); +// continue L1; +// } +// } + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "λ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, " ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// showWhereUesd(p3Table, p3SelectAll); + } + }; + } + + private ActionListener batchRemove() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(p4Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + if (bean.getChildLine() == null) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "bomLineڣѾɹɾ" }); + } else { + bean.getParentLine().remove("", bean.getChildLine()); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "ɹ" }); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ɾִϣʱ" + (endTime - startTime) + "ms"); + doLog("ɾ", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "ɾӼ", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "ɾ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// removeSelectRow(p4Table); + updateSelectedRow3(p4Table, selectedRowList); + } + }; + } + + private List getselectedRow(JTable table) { + List selectedList = new ArrayList(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + System.out.println("select=====>" + table.getValueAt(i, 1)); + selectedList.add(tableDataMap.get(table.getValueAt(i, 1))); + } + } + return selectedList; + } + + private void updateSelectedRow(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + try { + TCComponentItemRevision parentRev = newRowData.get(index).getParentRev(); + String parentString = newRowData.get(index).getParentString(); + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.get(table.getValueAt(i, 1).toString()).close(); + winMap.remove(table.getValueAt(i, 1)); + winMap.put(parentString, win); + tableDataMap.remove(table.getValueAt(i, 1).toString()); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (newRowData.get(index).getChildString() + .equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + JCheckBox selected = new JCheckBox(); + selected.setSelected(true); + Object[] rowData = new Object[] { selected, parentString, + newRowData.get(index).getChildString(), unit, num, status }; + rowPrint(rowData); + for (int ii = 0; ii < rowData.length; ii++) { + table.setValueAt(rowData[ii], i, ii); + } + tableDataMap.put(parentString, new BOMManageTableBean(parentString, + newRowData.get(index).getChildString(), parentRev, targetRev, topLine, child)); + break; + } + } + index++; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow2(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + try { + TCComponentBOMLine child = bean.getChildLine(); + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + table.setValueAt(bean.getChildString(), i, 2); + table.setValueAt(unit, index, 3); + table.setValueAt(num, index, 4); + tableDataMap.get(bean.getParentString()).setChildRev(bean.getChildRev()); + tableDataMap.get(bean.getParentString()).setChildString(bean.getChildString()); + tableDataMap.get(bean.getParentString()).setChildLine(child); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow3(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + table.setValueAt("", i, 2); + table.setValueAt("", index, 3); + table.setValueAt("", index, 4); + tableDataMap.get(bean.getParentString()).setChildLine(null); + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void removeSelectRow(JTable table) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int i = 0; + while (i < table.getRowCount()) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + model.removeRow(i); + continue; + } + i++; + } + table.revalidate(); + table.repaint(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + new Thread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + try { + closeWin(); + System.out.println("closed"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }).start(); + + super.dispose(); + } + + private void saveWin() throws TCException { + for (Entry entry : winMap.entrySet()) { + if (entry.getValue() != null) { + entry.getValue().save(); + } + + } + } + + private void closeWin() throws TCException { + saveWin(); + + for (Entry entry : winMap.entrySet()) { + entry.getValue().close(); + } + winMap.clear(); + } + + private void doLog(String operation, List msgData) { + createLogDataSourceTable(); + String content = ""; + if ("滻".equals(operation)) { + content = "%sӼ%s滻Ϊ%s;%s;%s"; + } else if ("޸".equals(operation)) { + content = "%sӼ%s%sΪ%s"; + } else if ("".equals(operation)) { + content = "%sӼ%s;%s;%s"; + } else if ("ɾ".equals(operation)) { + content = "%sɾӼ%s"; + } + String username = ""; + try { + username = session.getUser().getOSUserName() + "(" + session.getUser().getUserId() + ")"; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + String datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + List sqls = new ArrayList(); + int num = countOccurrences(content, "%s"); + for (String[] arr : msgData) { + String[] row = new String[num]; + for (int i = 0; i < num; i++) { + row[i] = arr[i + 1]; + } + String temp = formatContent(content, row); + String sql = buildInsertSql(username, datetime, temp); + + sqls.add(sql); + } + Connection conn = null; + PreparedStatement pstmt = null; +// try { +// conn = DBUtil.getDataSource(session).getConnection(); +// PreparedStatement pstmt1 = conn.prepareStatement(buildInsertSql(null, null, null)); +// for (String sql : sqls) { +// System.out.println("sql:"+sql); +// pstmt1.clearParameters(); +// pstmt1.setString(1, getUsernameFromSql(sql)); +// pstmt1.setString(2, datetime); +// pstmt1.setString(3, getContentFromSql(sql)); +// pstmt1.addBatch(); +// } +// +// pstmt1.executeBatch(); +// +// } catch (SQLException e) { +// e.printStackTrace(); +// } + try { + conn = DBUtil.getDataSource(session).getConnection(); + + for (String sql : sqls) { + System.out.println("sql:" + sql); + + // ֱӴִStatement + Statement stmt = conn.createStatement(); + int rowsAffected = stmt.executeUpdate(sql); + stmt.close(); + } + + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private int countOccurrences(String content, String target) { + int count = 0; + int index = 0; + while ((index = content.indexOf(target, index)) != -1) { + count++; + index += target.length(); + } + return count; + } + + private String formatContent(String content, String[] replacements) { + StringBuilder sb = new StringBuilder(content); + int start = 0; + for (String replacement : replacements) { + int index = sb.indexOf("%s", start); + if (index == -1) + break; + sb.replace(index, index + 2, replacement); + start = index + replacement.length(); + } + return sb.toString(); + } + + private String buildInsertSql(String username, String datetime, String content) { + return "INSERT INTO \"PX_BOMManageLog\" (modify_user, modify_time, modify_content) VALUES ('"+username+"', '"+datetime+"', '"+content+"')"; + } + + private String getUsernameFromSql(String sql) { + // ʵSQLṹusername磺 + int startUsername = sql.indexOf("'") + 1; + int endUsername = sql.indexOf("'", startUsername); + return sql.substring(startUsername, endUsername); + } + + private String getContentFromSql(String sql) { + // ʵSQLṹcontent磺 + int startContent = sql.lastIndexOf("'") + 1; + return sql.substring(startContent); + } + + private ActionListener clickSearch(final JTable table, final JCheckBox selectAll) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JDialog content = DialogUtil.createSearchAndSelectRevDialog($this, table, selectAll, + (JButton) e.getSource()); + } + }; + } + + public void okCallback(JTable revTable, JTable table, JCheckBox selectAll, JButton field) { + // TODO Auto-generated method stub + int rowIndex = revTable.getSelectedRow(); + if (rowIndex < 0) { + return; + } + String text = revTable.getValueAt(rowIndex, 0).toString(); + System.out.println(text); + field.setText(text); + if ("".equals(text)) { + return; + } + if (table != null) { + targetRev = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + showWhereUesd(table, selectAll); + } else { + targetRev2 = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + } + } + + private KeyAdapter logSearchEnter() { + return new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + super.keyTyped(e); + if (e.getKeyChar() == KeyEvent.VK_ENTER) { + p5Search.doClick(); + } + } + }; + } + + private void updateTitleShowProgress(final List list) { + new Thread(new Runnable() { + + @Override + public void run() { + int num = 1; + String temp; + doIndex = 0; + while (!complate) { + $this.setTitle("ڴ" + (temp = StringCreateUtil.createPoint(num % 3)) + + StringCreateUtil.createBlank(5 - temp.length()) + list.get(doIndex).getParentString() + + " " + (doIndex + 1) + "/" + list.size()); + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + num++; + } + $this.setTitle("BOM"); + doIndex = -1; + complate = false; + } + }).start(); + } + +// private boolean checkReleaseStatus(TCComponentItemRevision rev) { +// try { +// System.out.println("item type======>" + rev.getItem().getType()); +// if (checkItemType.contains(rev.getItem().getType())) { +// return true; +// } +// TCComponent form = rev.getRelatedComponents("IMAN_master_form_rev")[0]; +// TCComponent[] statusArray = form.getRelatedComponents("release_status_list"); +// String status = ""; +// if (statusArray != null && statusArray.length > 0) { +// status = statusArray[statusArray.length - 1].getProperty("object_name"); +// } +// if ("".equals(status) || "JD2_DJJY".equals(status) || "JD2_DJKY".equals(status)|| "TCM Released".equals(status)) { +// return false; +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return true; +// } + + private ResultData checkAccess(List data) { + for (BOMManageTableBean bean : data) { + boolean isAccess = true; + try { + isAccess = session.getTCAccessControlService().checkPrivilege(bean.getParentLine(), "WRITE"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (!isAccess) { + try { + return new ResultData(false, "ǰûûж" + bean.getParentLine().getProperty("object_string") + "дȨ", + bean.getParentLine()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return new ResultData(true, "", null); + } + + private boolean checkTargetAndSelect(TCComponentItemRevision rev, List data) { +// if (!checkReleaseStatus(rev)) { +// JOptionPane.showMessageDialog($this, "Ŀδߴڶ״̬޷BOM", "ʾ", JOptionPane.WARNING_MESSAGE); +// return false; +// } + ResultData res = checkAccess(data); + if (!res.isRes()) { + JOptionPane.showMessageDialog($this, res.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + return true; + } + + private ActionListener startWorkFlow(final JTable table) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List select = getselectedRow(table); + List parentRev = new ArrayList(); + for (BOMManageTableBean bean : select) { + parentRev.add(bean.getParentRev()); + } + $this.setExtendedState(JFrame.ICONIFIED); + NewProcessCommand command = new NewProcessCommand(AIFUtility.getActiveDesktop(), app, + parentRev.toArray(new TCComponentItemRevision[parentRev.size()])); + } + }; + } + + private void rowPrint(Object[] arr) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (Object obj : arr) { + if (obj instanceof JCheckBox) { + sb.append(((JCheckBox) obj).isSelected()); + } else { + sb.append(obj.toString()); + } + sb.append(","); + } + if (sb.length() > 1) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append("]"); + System.out.println(sb.toString()); + } + + private void resize() { + double left = 2 * this.widthOffset / 3.0; + double right = this.widthOffset - left; + + int bottom1 = p1BottomBtn2.getX() - p1BottomBtn1.getX() - p1BottomBtn1.getWidth(); + int bottom2 = p1BottomBtn3.getX() - p1BottomBtn2.getX() - p1BottomBtn2.getWidth(); + int botttom3 = p1BottomBtn4.getX() - p1BottomBtn3.getX() - p1BottomBtn3.getWidth(); + + // p1 + int p1x1 = p1TargetBtn.getX() - p1TargetLabel.getX() - p1TargetLabel.getWidth(); + int p1x2 = p1ReplaceBtn.getX() - p1ReplaceLabel.getX() - p1ReplaceLabel.getWidth(); + int p1x3 = p1UnitLabel.getX() - p1ReplaceBtn.getX() - p1ReplaceBtn.getWidth(); + int p1x4 = p1NumLabel.getX() - p1UnitCombo.getX() - p1UnitCombo.getWidth(); + p1TargetLabel.setBounds(p1TargetLabel.getX() + getOffset(left, 20, 800), 20, + p1TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p1TargetBtn.setBounds(p1TargetLabel.getX() + p1TargetLabel.getWidth() + p1x1 + getOffset(left, 10, 800), 20, + p1TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p1ReplaceLabel.setBounds(p1ReplaceLabel.getX() + getOffset(left, 20, 800), 60, + p1ReplaceLabel.getWidth() + getOffset(left, 100, 800), 25); + p1ReplaceBtn.setBounds(p1ReplaceLabel.getX() + p1ReplaceLabel.getWidth() + p1x2 + getOffset(left, 10, 800), 60, + p1ReplaceBtn.getWidth() + getOffset(left, 400, 800), 25); + p1UnitLabel.setBounds(p1ReplaceBtn.getX() + p1ReplaceBtn.getWidth() + p1x3 + getOffset(left, 30, 800), 60, + p1UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p1UnitCombo.setBounds(p1UnitLabel.getX() + p1UnitLabel.getWidth(), 60, + p1UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p1NumLabel.setBounds(p1ReplaceBtn.getX() + p1ReplaceBtn.getWidth() + p1x3 + getOffset(left, 30, 800), 60, + p1UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p1NumText.setBounds(p1UnitLabel.getX() + p1UnitLabel.getWidth(), 60, + p1UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p1SelectAll.setBounds(p1SelectAll.getX() + getOffset(left, 20, 800), 100, + p1SelectAll.getWidth() + getOffset(left, 100, 800), 25); + copyButton.setBounds(copyButton.getX() + getOffset(left, 120, 800), 100, + copyButton.getWidth() + getOffset(left, 100, 800), 25); + p1jsp.setBounds(p1jsp.getX() + getOffset(left, 20, 800), p1jsp.getY(), + p1jsp.getWidth() + getOffset(left, 760, 800), p1jsp.getHeight() + this.heightOffset); + p1BottomBtn1.setBounds(p1BottomBtn1.getX() + getOffset(left, 80, 800), p1BottomBtn1.getY() + this.heightOffset, + p1BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn2.setBounds(p1BottomBtn1.getX() + p1BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p1BottomBtn2.getY() + this.heightOffset, p1BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); +// p1BottomBtn3.setBounds(p1BottomBtn2.getX() + p1BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), +// p1BottomBtn3.getY() + this.heightOffset, p1BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn4.setBounds(p1BottomBtn2.getX() + p1BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p1BottomBtn3.getY() + this.heightOffset, p1BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p1Left.setBounds(0, 0, p1Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p1Left.getHeight() + this.heightOffset); + p1TreePanel.setBounds(p1TreePanel.getX() + getOffset(right, 20, 400), 130, + p1TreePanel.getWidth() + getOffset(right, 360, 400), p1TreePanel.getHeight() + this.heightOffset); + p1Right.setBounds(p1Left.getX() + p1Left.getWidth(), 0, + p1Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p1Right.getHeight() + this.heightOffset); + p1.revalidate(); + p1.repaint(); + + // p2 + int p2x1 = p2TargetBtn.getX() - p2TargetLabel.getX() - p2TargetLabel.getWidth(); + int p2x2 = p2NumText.getX() - p2ChangeNumLabel.getX() - p2ChangeNumLabel.getWidth(); + p2TargetLabel.setBounds(p2TargetLabel.getX() + getOffset(left, 20, 800), 20, + p2TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p2TargetBtn.setBounds(p2TargetLabel.getX() + p2TargetLabel.getWidth() + p2x1 + getOffset(left, 10, 800), 20, + p2TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p2ChangeNumLabel.setBounds(p2ChangeNumLabel.getX() + getOffset(left, 20, 800), 60, + p2ChangeNumLabel.getWidth() + getOffset(left, 100, 800), 25); + p2NumText.setBounds(p2ChangeNumLabel.getX() + p2ChangeNumLabel.getWidth() + p2x2 + getOffset(left, 10, 800), 60, + p2NumText.getWidth() + getOffset(left, 50, 800), 25); + p2SelectAll.setBounds(p2SelectAll.getX() + getOffset(left, 20, 800), 100, + p2SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p2jsp.setBounds(p2jsp.getX() + getOffset(left, 20, 800), p2jsp.getY(), + p2jsp.getWidth() + getOffset(left, 760, 800), p2jsp.getHeight() + this.heightOffset); + p2BottomBtn1.setBounds(p2BottomBtn1.getX() + getOffset(left, 80, 800), p2BottomBtn1.getY() + this.heightOffset, + p2BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn2.setBounds(p2BottomBtn1.getX() + p2BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p2BottomBtn2.getY() + this.heightOffset, p2BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn3.setBounds(p2BottomBtn2.getX() + p2BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p2BottomBtn3.getY() + this.heightOffset, p2BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn4.setBounds(p2BottomBtn3.getX() + p2BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p2BottomBtn4.getY() + this.heightOffset, p2BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p2Left.setBounds(0, 0, p2Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p2Left.getHeight() + this.heightOffset); + p2TreePanel.setBounds(p2TreePanel.getX() + getOffset(right, 20, 400), 130, + p2TreePanel.getWidth() + getOffset(right, 360, 400), p2TreePanel.getHeight() + this.heightOffset); + p2Right.setBounds(p2Left.getX() + p2Left.getWidth(), 0, + p2Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p2Right.getHeight() + this.heightOffset); + p2.revalidate(); + p2.repaint(); + + // p3 + int p3x1 = p3TargetBtn.getX() - p3TargetLabel.getX() - p3TargetLabel.getWidth(); + int p3x2 = p3AddBtn.getX() - p3AddLabel.getX() - p3AddLabel.getWidth(); + int p3x3 = p3UnitLabel.getX() - p3AddBtn.getX() - p3AddBtn.getWidth(); + int p3x4 = p3NumLabel.getX() - p3UnitCombo.getX() - p3UnitCombo.getWidth(); + p3TargetLabel.setBounds(p3TargetLabel.getX() + getOffset(left, 20, 800), 20, + p3TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p3TargetBtn.setBounds(p3TargetLabel.getX() + p3TargetLabel.getWidth() + p3x1 + getOffset(left, 10, 800), 20, + p3TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p3AddLabel.setBounds(p3AddLabel.getX() + getOffset(left, 20, 800), 60, + p3AddLabel.getWidth() + getOffset(left, 100, 800), 25); + p3AddBtn.setBounds(p3AddLabel.getX() + p3AddLabel.getWidth() + p3x2 + getOffset(left, 10, 800), 60, + p3AddBtn.getWidth() + getOffset(left, 400, 800), 25); + p3UnitLabel.setBounds(p3AddBtn.getX() + p3AddBtn.getWidth() + p3x3 + getOffset(left, 30, 800), 60, + p3UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p3UnitCombo.setBounds(p3UnitLabel.getX() + p3UnitLabel.getWidth(), 60, + p3UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p3NumLabel.setBounds(p3UnitCombo.getX() + p3UnitCombo.getWidth() + p3x4 + getOffset(left, 20, 800), 60, + p3NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p3NumText.setBounds(p3NumLabel.getX() + p3NumLabel.getWidth(), 60, + p3NumText.getWidth() + getOffset(left, 50, 800), 25); + p3SelectAll.setBounds(p3SelectAll.getX() + getOffset(left, 20, 800), 100, + p3SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p3jsp.setBounds(p3jsp.getX() + getOffset(left, 20, 800), p3jsp.getY(), + p3jsp.getWidth() + getOffset(left, 760, 800), p3jsp.getHeight() + this.heightOffset); + p3BottomBtn1.setBounds(p3BottomBtn1.getX() + getOffset(left, 80, 800), p3BottomBtn1.getY() + this.heightOffset, + p3BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn2.setBounds(p3BottomBtn1.getX() + p3BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p3BottomBtn2.getY() + this.heightOffset, p3BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn3.setBounds(p3BottomBtn2.getX() + p3BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p3BottomBtn3.getY() + this.heightOffset, p3BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn4.setBounds(p3BottomBtn3.getX() + p3BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p3BottomBtn4.getY() + this.heightOffset, p3BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p3Left.setBounds(0, 0, p3Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p3Left.getHeight() + this.heightOffset); + p3TreePanel.setBounds(p3TreePanel.getX() + getOffset(right, 20, 400), 130, + p3TreePanel.getWidth() + getOffset(right, 360, 400), p3TreePanel.getHeight() + this.heightOffset); + p3Right.setBounds(p3Left.getX() + p3Left.getWidth(), 0, + p3Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p3Right.getHeight() + this.heightOffset); + p3.revalidate(); + p3.repaint(); + + // p4 + int p4x1 = p4TargetBtn.getX() - p4TargetLabel.getX() - p4TargetLabel.getWidth(); + p4TargetLabel.setBounds(p4TargetLabel.getX() + getOffset(left, 20, 800), 20, + p4TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p4TargetBtn.setBounds(p4TargetLabel.getX() + p4TargetLabel.getWidth() + p4x1 + getOffset(left, 10, 800), 20, + p4TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p4SelectAll.setBounds(p4SelectAll.getX() + getOffset(left, 20, 800), 100, + p4SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p4jsp.setBounds(p4jsp.getX() + getOffset(left, 20, 800), p4jsp.getY(), + p4jsp.getWidth() + getOffset(left, 760, 800), p4jsp.getHeight() + this.heightOffset); + p4BottomBtn1.setBounds(p4BottomBtn1.getX() + getOffset(left, 80, 800), p4BottomBtn1.getY() + this.heightOffset, + p4BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn2.setBounds(p4BottomBtn1.getX() + p4BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p4BottomBtn2.getY() + this.heightOffset, p4BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn3.setBounds(p4BottomBtn2.getX() + p4BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p4BottomBtn3.getY() + this.heightOffset, p4BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn4.setBounds(p4BottomBtn3.getX() + p4BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p4BottomBtn4.getY() + this.heightOffset, p4BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p4Left.setBounds(0, 0, p4Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p4Left.getHeight() + this.heightOffset); + p4TreePanel.setBounds(p4TreePanel.getX() + getOffset(right, 20, 400), 130, + p4TreePanel.getWidth() + getOffset(right, 360, 400), p4TreePanel.getHeight() + this.heightOffset); + p4Right.setBounds(p4Left.getX() + p4Left.getWidth(), 0, + p4Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p4Right.getHeight() + this.heightOffset); + p4.revalidate(); + p4.repaint(); + + // p5 + int p5x1 = p5UserText.getX() - p5UserLabel.getX() - p5UserLabel.getWidth(); + int p5x2 = p5TimeLabel.getX() - p5UserText.getX() - p5UserText.getWidth(); + int p5x3 = p5TimeStartText.getX() - p5TimeLabel.getX() - p5TimeLabel.getWidth(); + int p5x4 = toLabel.getX() - p5TimeStartText.getX() - p5TimeStartText.getWidth(); + int p5x5 = p5TimeEndText.getX() - toLabel.getX() - toLabel.getWidth(); + int p5x6 = p5ContentLabel.getX() - p5TimeEndText.getX() - p5TimeEndText.getWidth(); + int p5x7 = p5Contentjsp.getX() - p5ContentLabel.getX() - p5ContentLabel.getWidth(); + int p5x8 = p5Search.getX() - p5Contentjsp.getX() - p5Contentjsp.getWidth(); + int p5x9 = p5Download.getX() - p5Search.getX() - p5Search.getWidth(); + p5UserLabel.setBounds(p5UserLabel.getX(), 40, p5UserLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), + 25); + p5UserText.setBounds(p5UserLabel.getX() + p5UserLabel.getWidth() + p5x1 + getOffset(this.widthOffset, 10, 1200), + 40, p5UserText.getWidth() + getOffset(this.widthOffset, 150, 1200), 25); + p5TimeLabel.setBounds(p5UserText.getX() + p5UserText.getWidth() + p5x2 + getOffset(this.widthOffset, 50, 1200), + 40, p5TimeLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5TimeStartText.setBounds( + p5TimeLabel.getX() + p5TimeLabel.getWidth() + p5x3 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeStartText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + toLabel.setBounds( + p5TimeStartText.getX() + p5TimeStartText.getWidth() + p5x4 + getOffset(this.widthOffset, 10, 1200), 40, + toLabel.getWidth() + getOffset(this.widthOffset, 20, 1200), 25); + p5TimeEndText.setBounds(toLabel.getX() + toLabel.getWidth() + p5x5 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeEndText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5ContentLabel.setBounds( + p5TimeEndText.getX() + p5TimeEndText.getWidth() + p5x6 + getOffset(this.widthOffset, 50, 1200), 40, + p5ContentLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5Contentjsp.setBounds( + p5ContentLabel.getX() + p5ContentLabel.getWidth() + p5x7 + getOffset(this.widthOffset, 10, 1200), 20, + p5Contentjsp.getWidth() + getOffset(this.widthOffset, 200, 1200), 80); + p5Search.setBounds(p5Contentjsp.getX() + p5Contentjsp.getWidth() + p5x8 + getOffset(this.widthOffset, 50, 1200), + 40, p5Search.getWidth() + getOffset(this.widthOffset, 60, 1200), 25); + p5Download.setBounds(p5Search.getX() + p5Search.getWidth() + p5x9 + getOffset(this.widthOffset, 20, 1200), 40, + p5Download.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5jsp.setBounds(p5jsp.getX() + getOffset(this.widthOffset, 20, 1200), p5jsp.getY(), + p5jsp.getWidth() + getOffset(this.widthOffset, 1160, 1200), p5jsp.getHeight() + this.heightOffset); + p5.revalidate(); + p5.repaint(); + } + + private int getOffset(double num1, int num2, int num3) { + return (int) (num1 * num2 / num3); + } + + private int getResultNum(List msgData, boolean success) { + int num = 0; + String str = success ? "ɹ" : "ʧ"; + for (String[] row : msgData) { + if (row[row.length - 1].contains(str)) { + num++; + } + } + return num; + } +} diff --git a/src/com/connor/jd/plm/dialogs/BOMManagementFrame20200826改log格式.txt b/src/com/connor/jd/plm/dialogs/BOMManagementFrame20200826改log格式.txt new file mode 100644 index 0000000..93f6146 --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/BOMManagementFrame20200826改log格式.txt @@ -0,0 +1,2145 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import com.connor.jd.plm.beans.BOMLogBean; +import com.connor.jd.plm.beans.BOMManageTableBean; +import com.connor.jd.plm.beans.CheckBoxPo; +import com.connor.jd.plm.beans.CustomLovBean; +import com.connor.jd.plm.beans.ResultData; +import com.connor.jd.plm.table.MyCellEditor4; +import com.connor.jd.plm.table.MyCellRenderer; +import com.connor.jd.plm.utils.DBConnectionUtil; +import com.connor.jd.plm.utils.DBUtil; +import com.connor.jd.plm.utils.DatePickerUtil; +import com.connor.jd.plm.utils.DialogUtil; +import com.connor.jd.plm.utils.JDMethodUtil; +import com.connor.jd.plm.utils.KeyValComboBox; +import com.connor.jd.plm.utils.StringCreateUtil; +import com.eltima.components.ui.DatePicker; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; + +import cn.hutool.db.Db; +import cn.hutool.db.Entity; +import cn.hutool.db.sql.Condition; + +public class BOMManagementFrame extends JFrame { + private AbstractAIFApplication app; + private TCSession session; + private CardLayout rootSwitch = new CardLayout(); + private String[] colDisplayNames = new String[] { "ѡ", "", "Ӽ", "λ", "", "״̬" }; + private String[] colDisplayNames2 = new String[] { "", "޸û", "ʱ", "" }; + private JPanel root; + private Map tableDataMap = new HashMap(); + private BOMManagementFrame $this; + private List logDataList; + private Map winMap = new HashMap(); + private TCComponentItemRevision targetRev; + private TCComponentItemRevision targetRev2; + private boolean isLogcreated = false; + private int doIndex = 0; + private boolean complate = false; + private List checkItemType = new ArrayList(); + private JButton[] topBtns; + private TCComponentBOMWindowType winType; + private int width = 1200; + private int height = 800; + private int widthOffset = 0; + private int heightOffset = 0; + private JLabel p1TargetLabel; + private JButton p1TargetBtn; + private JLabel p1ReplaceLabel; + private JButton p1ReplaceBtn; + private JLabel p1UnitLabel; + private KeyValComboBox p1UnitCombo; + private JLabel p1NumLabel; + private JTextField p1NumText; + private JCheckBox p1SelectAll; + private JTable p1Table; + private JScrollPane p1jsp; + private JButton p1BottomBtn1; + private JButton p1BottomBtn2; + private JButton p1BottomBtn3; + private JButton p1BottomBtn4; + private JPanel p1Left; + private JScrollPane p1TreePanel; + private JPanel p1Right; + private JLabel p2TargetLabel; + private JButton p2TargetBtn; + private JLabel p2ChangeNumLabel; + private JTextField p2NumText; + private JCheckBox p2SelectAll; + private JTable p2Table; + private JScrollPane p2jsp; + private JButton p2BottomBtn1; + private JButton p2BottomBtn2; + private JButton p2BottomBtn3; + private JButton p2BottomBtn4; + private JPanel p2Left; + private JScrollPane p2TreePanel; + private JPanel p2Right; + private JLabel p3TargetLabel; + private JButton p3TargetBtn; + private JLabel p3AddLabel; + private JButton p3AddBtn; + private JLabel p3UnitLabel; + private KeyValComboBox p3UnitCombo; + private JLabel p3NumLabel; + private JTextField p3NumText; + private JCheckBox p3SelectAll; + private JTable p3Table; + private JScrollPane p3jsp; + private JButton p3BottomBtn1; + private JButton p3BottomBtn2; + private JButton p3BottomBtn3; + private JButton p3BottomBtn4; + private JPanel p3Left; + private JScrollPane p3TreePanel; + private JPanel p3Right; + private JLabel p4TargetLabel; + private JButton p4TargetBtn; + private JCheckBox p4SelectAll; + private JTable p4Table; + private JScrollPane p4jsp; + private JButton p4BottomBtn1; + private JButton p4BottomBtn2; + private JButton p4BottomBtn3; + private JButton p4BottomBtn4; + private JPanel p4Left; + private JScrollPane p4TreePanel; + private JPanel p4Right; + private JLabel p5UserLabel; + private JTextField p5UserText; + private JLabel p5TimeLabel; + private DatePicker p5TimeStartText; + private JLabel toLabel; + private DatePicker p5TimeEndText; + private JLabel p5ContentLabel; + private JTextArea p5ContentText; + private JScrollPane p5Contentjsp; + private JButton p5Search; + private JButton p5Download; + private JTable p5Table; + private JScrollPane p5jsp; + private Map uiSize = new HashMap<>(); + private JPanel p1; + private JPanel p2; + private JPanel p3; + private JPanel p4; + private JPanel p5; + private Set addedBOMLine = new HashSet<>(); + + public BOMManagementFrame(AbstractAIFApplication app) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + $this = this; + String[] prefArray = JDMethodUtil.getPrefStrArray("connor_bom_check_type", session); + if (prefArray != null) { + checkItemType = Arrays.asList(prefArray); + } + TCTypeService service = session.getTypeService(); + try { + this.winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + init(); + } + + private void init() { + this.setTitle("BOM"); + this.setSize(new Dimension(1200, 800)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + super.componentResized(e); + Component comp = e.getComponent(); + $this.widthOffset = comp.getWidth() - $this.width; + $this.heightOffset = comp.getHeight() - $this.height; + if ($this.widthOffset != 0 || $this.heightOffset != 0) { + System.out.println("width===>" + comp.getWidth()); + System.out.println("height===>" + comp.getHeight()); + $this.width = comp.getWidth(); + $this.height = comp.getHeight(); + $this.resize(); + } + } + }); + this.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + $this.setAlwaysOnTop(true); + } + }); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + container.setSize(new Dimension(1200, 800)); + + TCTypeService typeService = session.getTypeService(); + Vector unitVector = new Vector(); + try { + TCComponent[] uomArray = typeService.getTypeComponent("UnitOfMeasure").extent(); + unitVector.add(new CheckBoxPo(" ", " ")); + for (TCComponent comp : uomArray) { + unitVector.add(new CheckBoxPo(comp.toString(), comp)); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ͷ + JPanel topBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topBtns = new JButton[5]; + topBtns[0] = new JButton("滻"); + topBtns[1] = new JButton(""); + topBtns[2] = new JButton(""); + topBtns[3] = new JButton("ɾ"); + topBtns[4] = new JButton("־"); +// topBtns[5] = new JButton("԰ť"); + topBtns[0].setSelected(true); + for (JButton btn : topBtns) { + topBtnPanel.add(btn); + btn.addActionListener(panelSwitch()); + } + container.add(topBtnPanel, BorderLayout.NORTH); + + // root + root = new JPanel(rootSwitch); + + // 滻 + p1 = new JPanel(); + p1.setLayout(null); + + // 滻 + p1Left = new JPanel(); + p1Left.setLayout(null); + p1Left.setBounds(0, 0, 800, 800); + p1Left.setBorder(BorderFactory.createEtchedBorder()); + + p1TargetLabel = new JLabel("Ŀϱ"); + p1TargetLabel.setBounds(20, 20, 100, 25); + p1TargetBtn = new JButton(); + p1TargetBtn.setBounds(130, 20, 400, 25); + p1ReplaceLabel = new JLabel("滻ϱ"); + p1ReplaceLabel.setBounds(20, 60, 100, 25); + p1ReplaceBtn = new JButton(); + p1ReplaceBtn.setBounds(130, 60, 400, 25); + p1UnitLabel = new JLabel("λ"); + p1UnitLabel.setBounds(560, 60, 50, 25); + p1UnitCombo = new KeyValComboBox(unitVector); + p1UnitCombo.setBounds(610, 60, 50, 25); + p1NumLabel = new JLabel(""); + p1NumLabel.setBounds(680, 60, 50, 25); + p1NumText = new JTextField(); + p1NumText.setBounds(730, 60, 50, 25); + p1SelectAll = new JCheckBox("ȫѡ"); + p1SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p1model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p1Table = new JTable(p1model); + p1Table.getColumnModel().getColumn(0).setMinWidth(60); + p1Table.getColumnModel().getColumn(0).setMaxWidth(60); + p1Table.getColumnModel().getColumn(1).setMinWidth(200); + p1Table.getColumnModel().getColumn(2).setMinWidth(200); + p1Table.getColumnModel().getColumn(3).setMinWidth(100); + p1Table.getColumnModel().getColumn(4).setMinWidth(100); + p1Table.getColumnModel().getColumn(5).setMinWidth(100); + p1Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p1Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p1Table.setRowHeight(25); + p1Table.setAutoscrolls(true); + p1Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p1Table.getTableHeader().setReorderingAllowed(false); + p1Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p1sorter = new TableRowSorter(p1model); + p1Table.setRowSorter(p1sorter); + p1jsp = new JScrollPane(p1Table); + p1jsp.setBounds(20, 130, 760, 500); + + p1BottomBtn1 = new JButton(""); + p1BottomBtn1.setBounds(80, 650, 100, 25); + p1BottomBtn2 = new JButton("滻"); + p1BottomBtn2.setBounds(260, 650, 100, 25); + p1BottomBtn3 = new JButton(""); + p1BottomBtn3.setBounds(440, 650, 100, 25); + p1BottomBtn4 = new JButton("ȡ"); + p1BottomBtn4.setBounds(620, 650, 100, 25); + + p1Left.add(p1TargetLabel); + p1Left.add(p1TargetBtn); + p1Left.add(p1ReplaceLabel); + p1Left.add(p1ReplaceBtn); + p1Left.add(p1UnitLabel); + p1Left.add(p1UnitCombo); + p1Left.add(p1NumLabel); + p1Left.add(p1NumText); + p1Left.add(p1SelectAll); + p1Left.add(p1jsp); + p1Left.add(p1BottomBtn1); + p1Left.add(p1BottomBtn2); + p1Left.add(p1BottomBtn3); + p1Left.add(p1BottomBtn4); + + // 滻ұ + p1Right = new JPanel(); + p1Right.setLayout(null); + p1Right.setBounds(800, 0, 400, 800); + p1Right.setBorder(BorderFactory.createEtchedBorder()); + + p1TreePanel = new JScrollPane(); + p1TreePanel.setBounds(20, 130, 360, 500); + p1Right.add(p1TreePanel); + + // ¼ + p1SelectAll.addItemListener(selectAll(p1Table)); + p1Table.addMouseListener(showTree(p1Right)); + p1BottomBtn4.addActionListener(cancel()); + p1BottomBtn1.addActionListener(batchRevise(p1Table, p1SelectAll)); + p1BottomBtn2.addActionListener(batchReplace()); + p1BottomBtn3.addActionListener(startWorkFlow(p1Table)); + p1TargetBtn.addActionListener(clickSearch(p1Table, p1SelectAll)); + p1ReplaceBtn.addActionListener(clickSearch(null, null)); + + p1.add(p1Left); + p1.add(p1Right); + + // + p2 = new JPanel(); + p2.setLayout(null); + + // + p2Left = new JPanel(); + p2Left.setLayout(null); + p2Left.setBounds(0, 0, 800, 800); + p2Left.setBorder(BorderFactory.createEtchedBorder()); + + p2TargetLabel = new JLabel("Ŀϱ"); + p2TargetLabel.setBounds(20, 20, 100, 25); + p2TargetBtn = new JButton(); + p2TargetBtn.setBounds(130, 20, 400, 25); + p2ChangeNumLabel = new JLabel(""); + p2ChangeNumLabel.setBounds(20, 60, 100, 25); + p2NumText = new JTextField(); + p2NumText.setBounds(130, 60, 50, 25); + + p2SelectAll = new JCheckBox("ȫѡ"); + p2SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p2model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p2Table = new JTable(p2model); + p2Table.getColumnModel().getColumn(0).setMinWidth(60); + p2Table.getColumnModel().getColumn(0).setMaxWidth(60); + p2Table.getColumnModel().getColumn(1).setMinWidth(200); + p2Table.getColumnModel().getColumn(2).setMinWidth(200); + p2Table.getColumnModel().getColumn(3).setMinWidth(100); + p2Table.getColumnModel().getColumn(4).setMinWidth(100); + p2Table.getColumnModel().getColumn(5).setMinWidth(100); + p2Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p2Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p2Table.setRowHeight(25); + p2Table.setAutoscrolls(true); + p2Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p2Table.getTableHeader().setReorderingAllowed(false); + p2Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p2sorter = new TableRowSorter(p2model); + p2Table.setRowSorter(p2sorter); + p2jsp = new JScrollPane(p2Table); + p2jsp.setBounds(20, 130, 760, 500); + + p2BottomBtn1 = new JButton(""); + p2BottomBtn1.setBounds(80, 650, 100, 25); + p2BottomBtn2 = new JButton(""); + p2BottomBtn2.setBounds(260, 650, 100, 25); + p2BottomBtn3 = new JButton(""); + p2BottomBtn3.setBounds(440, 650, 100, 25); + p2BottomBtn4 = new JButton("ȡ"); + p2BottomBtn4.setBounds(620, 650, 100, 25); + + p2Left.add(p2TargetLabel); + p2Left.add(p2TargetBtn); + p2Left.add(p2ChangeNumLabel); + p2Left.add(p2NumText); + p2Left.add(p2SelectAll); + p2Left.add(p2jsp); + p2Left.add(p2BottomBtn1); + p2Left.add(p2BottomBtn2); + p2Left.add(p2BottomBtn3); + p2Left.add(p2BottomBtn4); + + // ұ + p2Right = new JPanel(); + p2Right.setLayout(null); + p2Right.setBounds(800, 0, 400, 800); + p2Right.setBorder(BorderFactory.createEtchedBorder()); + + p2TreePanel = new JScrollPane(); + p2TreePanel.setBounds(20, 130, 360, 500); + p2Right.add(p2TreePanel); + + // ¼ + p2SelectAll.addItemListener(selectAll(p2Table)); + p2Table.addMouseListener(showTree(p2Right)); + p2BottomBtn4.addActionListener(cancel()); + p2BottomBtn1.addActionListener(batchRevise(p2Table, p2SelectAll)); + p2BottomBtn2.addActionListener(batchModify()); + p2BottomBtn3.addActionListener(startWorkFlow(p2Table)); + p2TargetBtn.addActionListener(clickSearch(p2Table, p2SelectAll)); + + p2.add(p2Left); + p2.add(p2Right); + + // + p3 = new JPanel(); + p3.setLayout(null); + + // + p3Left = new JPanel(); + p3Left.setLayout(null); + p3Left.setBounds(0, 0, 800, 800); + p3Left.setBorder(BorderFactory.createEtchedBorder()); + + p3TargetLabel = new JLabel("οϱ"); + p3TargetLabel.setBounds(20, 20, 100, 25); + p3TargetBtn = new JButton(); + p3TargetBtn.setBounds(130, 20, 400, 25); + p3AddLabel = new JLabel("ϱ"); + p3AddLabel.setBounds(20, 60, 100, 25); + p3AddBtn = new JButton(); + p3AddBtn.setBounds(130, 60, 400, 25); + p3UnitLabel = new JLabel("λ"); + p3UnitLabel.setBounds(560, 60, 50, 25); + p3UnitCombo = new KeyValComboBox(unitVector); + p3UnitCombo.setBounds(610, 60, 50, 25); + p3NumLabel = new JLabel(""); + p3NumLabel.setBounds(680, 60, 50, 25); + p3NumText = new JTextField(); + p3NumText.setBounds(730, 60, 50, 25); + + p3SelectAll = new JCheckBox("ȫѡ"); + p3SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p3model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p3Table = new JTable(p3model); + p3Table.getColumnModel().getColumn(0).setMinWidth(60); + p3Table.getColumnModel().getColumn(0).setMaxWidth(60); + p3Table.getColumnModel().getColumn(1).setMinWidth(200); + p3Table.getColumnModel().getColumn(2).setMinWidth(200); + p3Table.getColumnModel().getColumn(3).setMinWidth(100); + p3Table.getColumnModel().getColumn(4).setMinWidth(100); + p3Table.getColumnModel().getColumn(5).setMinWidth(100); + p3Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p3Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p3Table.setRowHeight(25); + p3Table.setAutoscrolls(true); + p3Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p3Table.getTableHeader().setReorderingAllowed(false); + p3Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p3sorter = new TableRowSorter(p3model); + p3Table.setRowSorter(p3sorter); + p3jsp = new JScrollPane(p3Table); + p3jsp.setBounds(20, 130, 760, 500); + + p3BottomBtn1 = new JButton(""); + p3BottomBtn1.setBounds(80, 650, 100, 25); + p3BottomBtn2 = new JButton(""); + p3BottomBtn2.setBounds(260, 650, 100, 25); + p3BottomBtn3 = new JButton(""); + p3BottomBtn3.setBounds(440, 650, 100, 25); + p3BottomBtn4 = new JButton("ȡ"); + p3BottomBtn4.setBounds(620, 650, 100, 25); + + p3Left.add(p3TargetLabel); + p3Left.add(p3TargetBtn); + p3Left.add(p3AddLabel); + p3Left.add(p3AddBtn); + p3Left.add(p3UnitLabel); + p3Left.add(p3UnitCombo); + p3Left.add(p3NumLabel); + p3Left.add(p3NumText); + p3Left.add(p3SelectAll); + p3Left.add(p3jsp); + p3Left.add(p3BottomBtn1); + p3Left.add(p3BottomBtn2); + p3Left.add(p3BottomBtn3); + p3Left.add(p3BottomBtn4); + + // ұ + p3Right = new JPanel(); + p3Right.setLayout(null); + p3Right.setBounds(800, 0, 400, 800); + p3Right.setBorder(BorderFactory.createEtchedBorder()); + + p3TreePanel = new JScrollPane(); + p3TreePanel.setBounds(20, 130, 360, 500); + p3Right.add(p3TreePanel); + + // ¼ + p3SelectAll.addItemListener(selectAll(p3Table)); + p3Table.addMouseListener(showTree(p3Right)); + p3BottomBtn4.addActionListener(cancel()); + p3BottomBtn1.addActionListener(batchRevise(p3Table, p3SelectAll)); + p3BottomBtn2.addActionListener(batchAdd()); + p3BottomBtn3.addActionListener(startWorkFlow(p3Table)); + p3TargetBtn.addActionListener(clickSearch(p3Table, p3SelectAll)); + p3AddBtn.addActionListener(clickSearch(null, null)); + + p3.add(p3Left); + p3.add(p3Right); + + // ɾ + p4 = new JPanel(); + p4.setLayout(null); + + // ɾ + p4Left = new JPanel(); + p4Left.setLayout(null); + p4Left.setBounds(0, 0, 800, 800); + p4Left.setBorder(BorderFactory.createEtchedBorder()); + + p4TargetLabel = new JLabel("Ŀϱ"); + p4TargetLabel.setBounds(20, 20, 100, 25); + p4TargetBtn = new JButton(); + p4TargetBtn.setBounds(130, 20, 400, 25); + + p4SelectAll = new JCheckBox("ȫѡ"); + p4SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p4model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p4Table = new JTable(p4model); + p4Table.getColumnModel().getColumn(0).setMinWidth(60); + p4Table.getColumnModel().getColumn(0).setMaxWidth(60); + p4Table.getColumnModel().getColumn(1).setMinWidth(200); + p4Table.getColumnModel().getColumn(2).setMinWidth(200); + p4Table.getColumnModel().getColumn(3).setMinWidth(100); + p4Table.getColumnModel().getColumn(4).setMinWidth(100); + p4Table.getColumnModel().getColumn(5).setMinWidth(100); + p4Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p4Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p4Table.setRowHeight(25); + p4Table.setAutoscrolls(true); + p4Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p4Table.getTableHeader().setReorderingAllowed(false); + p4Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p4sorter = new TableRowSorter(p4model); + p4Table.setRowSorter(p4sorter); + p4jsp = new JScrollPane(p4Table); + p4jsp.setBounds(20, 130, 760, 500); + + p4BottomBtn1 = new JButton(""); + p4BottomBtn1.setBounds(80, 650, 100, 25); + p4BottomBtn2 = new JButton("ɾ"); + p4BottomBtn2.setBounds(260, 650, 100, 25); + p4BottomBtn3 = new JButton(""); + p4BottomBtn3.setBounds(440, 650, 100, 25); + p4BottomBtn4 = new JButton("ȡ"); + p4BottomBtn4.setBounds(620, 650, 100, 25); + + p4Left.add(p4TargetLabel); + p4Left.add(p4TargetBtn); + p4Left.add(p4SelectAll); + p4Left.add(p4jsp); + p4Left.add(p4BottomBtn1); + p4Left.add(p4BottomBtn2); + p4Left.add(p4BottomBtn3); + p4Left.add(p4BottomBtn4); + + // ұ + p4Right = new JPanel(); + p4Right.setLayout(null); + p4Right.setBounds(800, 0, 400, 800); + p4Right.setBorder(BorderFactory.createEtchedBorder()); + + p4TreePanel = new JScrollPane(); + p4TreePanel.setBounds(20, 130, 360, 500); + p4Right.add(p4TreePanel); + + // ¼ + p4SelectAll.addItemListener(selectAll(p4Table)); + p4Table.addMouseListener(showTree(p4Right)); + p4BottomBtn4.addActionListener(cancel()); + p4BottomBtn1.addActionListener(batchRevise(p4Table, p4SelectAll)); + p4BottomBtn2.addActionListener(batchRemove()); + p4BottomBtn3.addActionListener(startWorkFlow(p4Table)); + p4TargetBtn.addActionListener(clickSearch(p4Table, p4SelectAll)); + + p4.add(p4Left); + p4.add(p4Right); + + // ־ + p5 = new JPanel(); + p5.setLayout(null); + + p5UserLabel = new JLabel("޸û"); + p5UserLabel.setBounds(20, 40, 70, 25); + p5UserText = new JTextField(); + p5UserText.setBounds(100, 40, 150, 25); + p5TimeLabel = new JLabel("޸ʱ"); + p5TimeLabel.setBounds(300, 40, 70, 25); + p5TimeStartText = DatePickerUtil.getDatePicker(null); + p5TimeStartText.setBounds(380, 40, 100, 25); + toLabel = new JLabel(""); + toLabel.setBounds(490, 40, 20, 25); + p5TimeEndText = DatePickerUtil.getDatePicker(null); + p5TimeEndText.setBounds(520, 40, 100, 25); + p5ContentLabel = new JLabel("޸"); + p5ContentLabel.setBounds(670, 40, 70, 25); + p5ContentText = new JTextArea(); + p5ContentText.setLineWrap(true); + p5ContentText.setWrapStyleWord(true); + p5Contentjsp = new JScrollPane(p5ContentText); + p5Contentjsp.setBounds(750, 20, 200, 80); + p5Search = new JButton(""); + p5Search.setBounds(1000, 40, 60, 25); + p5Download = new JButton("־"); + p5Download.setBounds(1080, 40, 100, 25); + + DefaultTableModel p5model = new DefaultTableModel(colDisplayNames2, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p5Table = new JTable(p5model); + p5Table.getColumnModel().getColumn(0).setMinWidth(60); + p5Table.getColumnModel().getColumn(0).setMaxWidth(60); + p5Table.getColumnModel().getColumn(1).setMinWidth(200); + p5Table.getColumnModel().getColumn(2).setMinWidth(200); + p5Table.getColumnModel().getColumn(3).setMinWidth(700); + p5Table.setRowHeight(25); + p5Table.setAutoscrolls(true); + p5Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p5Table.getTableHeader().setReorderingAllowed(false); + RowSorter p5sorter = new TableRowSorter(p5model); + p5Table.setRowSorter(p5sorter); + p5jsp = new JScrollPane(p5Table); + p5jsp.setBounds(20, 130, 1160, 580); + + // ¼ + p5Search.addActionListener(searchLog()); + p5Download.addActionListener(downloadLog(p5Table)); + p5UserText.addKeyListener(logSearchEnter()); + p5TimeStartText.addKeyListener(logSearchEnter()); + p5TimeEndText.addKeyListener(logSearchEnter()); + + p5.add(p5UserLabel); + p5.add(p5UserText); + p5.add(p5TimeLabel); + p5.add(p5TimeStartText); + p5.add(toLabel); + p5.add(p5TimeEndText); + p5.add(p5ContentLabel); + p5.add(p5Contentjsp); + p5.add(p5Search); + p5.add(p5Download); + p5.add(p5jsp); + + root.add("batchReplace", p1); + root.add("batchModify", p2); + root.add("batchAdd", p3); + root.add("batchRemove", p4); + root.add("updateLog", p5); + + rootSwitch.show(root, "batchReplace"); + container.add(root, BorderLayout.CENTER); + this.setVisible(true); + } + + private ActionListener panelSwitch() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String text = ((JButton) e.getSource()).getText(); + for (int i = 0; i < topBtns.length; i++) { + topBtns[i].setSelected(topBtns[i].getText().equals(text)); + } + switch (text) { + case "滻": + clearTable(p1Table, p1SelectAll); + p1Right.removeAll(); + JScrollPane panel1 = new JScrollPane(); + panel1.setBounds(p1TreePanel.getX(), p1TreePanel.getY(), p1TreePanel.getWidth(), + p1TreePanel.getHeight()); + p1TreePanel = panel1; + p1Right.add(panel1); + p1Right.revalidate(); + p1Right.repaint(); + rootSwitch.show(root, "batchReplace"); + break; + case "": + clearTable(p2Table, p2SelectAll); + p2Right.removeAll(); + JScrollPane panel2 = new JScrollPane(); + panel2.setBounds(p2TreePanel.getX(), p2TreePanel.getY(), p2TreePanel.getWidth(), + p2TreePanel.getHeight()); + p2TreePanel = panel2; + p2Right.add(panel2); + p2Right.revalidate(); + p2Right.repaint(); + rootSwitch.show(root, "batchModify"); + break; + case "": + clearTable(p3Table, p3SelectAll); + p3Right.removeAll(); + JScrollPane panel3 = new JScrollPane(); + panel3.setBounds(p3TreePanel.getX(), p3TreePanel.getY(), p3TreePanel.getWidth(), + p3TreePanel.getHeight()); + p3TreePanel = panel3; + p3Right.add(panel3); + p3Right.revalidate(); + p3Right.repaint(); + rootSwitch.show(root, "batchAdd"); + break; + case "ɾ": + clearTable(p4Table, p4SelectAll); + p4Right.removeAll(); + JScrollPane panel4 = new JScrollPane(); + panel4.setBounds(p4TreePanel.getX(), p4TreePanel.getY(), p4TreePanel.getWidth(), + p4TreePanel.getHeight()); + p4TreePanel = panel4; + p4Right.add(panel4); + p4Right.revalidate(); + p4Right.repaint(); + rootSwitch.show(root, "batchRemove"); + break; + case "־": + createLogDataSourceTable(); + clearTable(p5Table, null); + rootSwitch.show(root, "updateLog"); + break; + default: +// createLogDataSourceTable(); + } + } + }; + } + + private void showWhereUesd(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + // TODO Auto-generated method stub + clearTable(table, selectAll); + if (table == null || targetRev == null) { + return; + } + long startTime = System.currentTimeMillis(); + List tableDataList = new ArrayList(); + try { + String revString = targetRev.getProperty("object_string"); + TCComponent[] usedComps = targetRev.whereUsed((short) 0); + System.out.println("װ======>" + usedComps.length); + + tableDataMap.clear(); +// Map usedMap = usedFilter(usedComps); +// for (Entry entry : usedMap.entrySet()) { + for (TCComponentItemRevision parentRev : usedFilter(usedComps)) { +// TCComponentItemRevision parentRev = entry.getValue(); + String parentString = parentRev.getProperty("object_string"); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.put(parentString, win); + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (revString.equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + Object[] rowData = new Object[] { new JCheckBox(), parentString, revString, unit, num, status }; + rowPrint(rowData); + tableDataList.add(rowData); + tableDataMap.put(parentString, + new BOMManageTableBean(parentString, revString, parentRev, targetRev, topLine, child)); + // TODO bomһchildܻ쳣ֻӰһ + break; + } + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + if (tableDataList == null || tableDataList.size() == 0) { + JOptionPane.showMessageDialog($this, "ҵӦ󣬵öûκװװöľ°汾ȷϱǷȷ", "ʾ", + JOptionPane.WARNING_MESSAGE); + return; + } + + for (Object[] rowData : tableDataList) { + model.addRow(rowData); + } + table.revalidate(); + table.repaint(); + System.out.println("װʾɣʱ" + (System.currentTimeMillis() - startTime) + "ms"); + } + + private MouseAdapter showTree(JPanel panelRight) { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + JTable table = (JTable) e.getSource(); + String parentString = table.getValueAt(table.getSelectedRow(), 1).toString(); + System.out.println("select row=====>" + table.getSelectedRow()); + System.out.println("parentName=====>" + parentString); + CustomLovBean lovBean = null; + try { + lovBean = new CustomLovBean(tableDataMap.get(parentString).getChildString()); + CustomLovBean subBean = new CustomLovBean(parentString); + lovBean.addSub(subBean); + getTreeData(tableDataMap.get(parentString).getParentRev(), subBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + panelRight.removeAll(); + JTree tree = createTree(lovBean); + JScrollPane treePanel = new JScrollPane(tree); + treePanel.setBounds(20, 130, 360, 500); + panelRight.add(treePanel); + panelRight.revalidate(); + panelRight.repaint(); + } + } + }; + } + + private void getTreeData(TCComponent rev, CustomLovBean lov) throws TCException { + TCComponent[] comps = rev.whereUsed((short) 0); + if (comps == null || comps.length == 0) { + return; + } + for (TCComponent comp : comps) { + CustomLovBean sub = new CustomLovBean(comp.getProperty("object_string")); + System.out.println(sub.displayName); + lov.addSub(sub); + getTreeData(comp, sub); + } + } + + private void clearTable(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int cnt = model.getRowCount(); + for (int i = 0; i < cnt; i++) { + model.removeRow(0); + } + table.revalidate(); + table.repaint(); + if (selectAll != null) { + selectAll.setSelected(false); + } + tableDataMap.clear(); + addedBOMLine.clear(); + try { + closeWin(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JTree createTree(CustomLovBean lovData) { + if (lovData == null || "".equals(lovData.displayName)) { + return new JTree(); + } + DefaultMutableTreeNode root = new DefaultMutableTreeNode(lovData.displayName); + DefaultMutableTreeNode parent = root; + DefaultTreeModel treeModel = new DefaultTreeModel(root); + + initTree(lovData, parent, treeModel); + + JTree tree = new JTree(treeModel); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + cellRenderer.setTextNonSelectionColor(Color.black); + cellRenderer.setTextSelectionColor(Color.blue); + return tree; + } + + private void initTree(CustomLovBean lovData, DefaultMutableTreeNode parent, DefaultTreeModel treeModel) { + if (!lovData.hasChild()) { + return; + } + List subList = lovData.getSub(); + for (CustomLovBean sub : subList) { + DefaultMutableTreeNode temp = new DefaultMutableTreeNode(sub.displayName); + treeModel.insertNodeInto(temp, parent, parent.getChildCount()); + initTree(sub, temp, treeModel); + } + } + + private ItemListener selectAll(JTable table) { + return new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + boolean select = ((JCheckBox) e.getSource()).isSelected(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox checkBox = (JCheckBox) table.getValueAt(i, 0); + checkBox.setSelected(select); + table.revalidate(); + table.repaint(); + } + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + $this.dispose(); + } + }; + } + + private ActionListener batchRevise(JTable table, JCheckBox selectAll) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkAccess(selectedRowList).isRes()) { + return; + } + List msgData = new ArrayList(); + for (int i = 0; i < selectedRowList.size(); i++) { + try { + TCComponentItemRevision newRev = selectedRowList.get(i).getParentRev().saveAs(null); + String parentString = newRev.getProperty("object_string"); + selectedRowList.get(i).setParentRev(newRev); + selectedRowList.get(i).setParentString(parentString); + msgData.add(new String[] { msgData.size() + 1 + "", selectedRowList.get(i).getParentString(), + newRev.getProperty("object_string"), "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + } + +// showWhereUesd(table, selectAll); + updateSelectedRow(table, selectedRowList); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "汾(ǰ)", "汾()", "" }, + msgData).panel; + JOptionPane.showMessageDialog($this, jsp, "", JOptionPane.PLAIN_MESSAGE); + } + }; + } + + private List usedFilter(TCComponent[] comps) throws TCException { +// Map sameParentUsedMap = new HashMap(); + List list = new ArrayList<>(); + for (TCComponent comp : comps) { + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; +// String itemId; +// if (sameParentUsedMap.containsKey(itemId = comp.getProperty("item_id"))) { +// if (sameParentUsedMap.get(itemId).getProperty("item_revision_id") +// .compareTo(comp.getProperty("item_revision_id")) < 0) { +// sameParentUsedMap.put(itemId, rev); +// } +// } else { + if (rev.getItem().getLatestItemRevision().getUid().equals(rev.getUid())) { + list.add(rev); + } +// sameParentUsedMap.put(itemId, rev); +// } + } + } + return list; + } + + private void createLogDataSourceTable() { + if (isLogcreated) { + return; + } + String sql1 = "CREATE TABLE JD2_BOMManageLog ( id NUMBER ( 38, 0 ) primary key, modify_user VARCHAR2 ( 200 ), modify_time DATE, modify_content VARCHAR2 ( 500 ), target1 VARCHAR2 ( 100 ), target2 VARCHAR2 ( 100 ), parent VARCHAR2 ( 100 ), operation VARCHAR2 ( 50 ), unit VARCHAR2 ( 100 ), num VARCHAR2 ( 100 ))"; + String sql2 = "CREATE sequence JD2_BOMManageLog_seq minvalue 1 maxvalue 99999999 INCREMENT BY 1 START WITH 1"; + String sql3 = "CREATE OR REPLACE TRIGGER JD2_BOMManageLog_tri before INSERT ON JD2_BOMManageLog FOR each ROW BEGIN SELECT JD2_BOMManageLog_seq.nextval INTO : new.id FROM dual; END;"; + try { + List temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("user_tables", + new Condition("table_name", "JD2_BOMMANAGELOG")); + if (temp == null || temp.size() == 0) { + Db.use(DBUtil.getDataSource(session)).execute(sql1); + System.out.println("JD2_BOMMANAGELOG create success"); + } + temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("user_sequences", + new Condition("sequence_name", "JD2_BOMMANAGELOG_SEQ")); + if (temp == null || temp.size() == 0) { + Db.use(DBUtil.getDataSource(session)).execute(sql2); + System.out.println("JD2_BOMMANAGELOG_SEQ create success"); + } + temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("all_triggers", + new Condition("trigger_name", "JD2_BOMMANAGELOG_TRI")); + if (temp == null || temp.size() == 0) { + DBConnectionUtil.dbConn(session).createStatement().execute(sql3); + System.out.println("JD2_BOMManageLog_tri create success"); + } + isLogcreated = true; + System.out.println("init log success"); + } catch (Exception e) { + // TODO Auto-generated catch block + JOptionPane.showMessageDialog($this, "ݿʧܣѡjd2_db_settings", "", JOptionPane.ERROR_MESSAGE); + e.printStackTrace(); + } + } + + private ActionListener searchLog() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String username = p5UserText.getText().trim(); + String content = p5ContentText.getText(); + if (username == null || "".equals(username)) { + return; + } + + String sql = "select * from JD2_BOMMANAGELOG where "; + if (!"*".equals(username)) { + sql += "modify_user like '%" + username + "%' and"; + } + sql += " modify_time between to_date('" + p5TimeStartText.getText() + + " 00:00:00','yyyy-MM-dd hh24:mi:ss') and to_date('" + p5TimeEndText.getText() + + " 23:59:59','yyyy-MM-dd hh24:mi:ss')"; + if (content != null && !"".equals(content)) { + sql += " and modify_content like '%" + content + "%'"; + } + sql += "order by MODIFY_TIME asc"; + System.out.println(sql); + try { + logDataList = Db.use(DBUtil.getDataSource(session)).query(sql); + System.out.println("log size=====>" + logDataList.size()); + DefaultTableModel model = (DefaultTableModel) p5Table.getModel(); + for (Entity entity : logDataList) { + Object[] objArr = new Object[] { entity.get("ID"), entity.get("MODIFY_USER"), + entity.get("MODIFY_TIME"), entity.get("MODIFY_CONTENT") }; + model.addRow(objArr); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + } + p5Table.revalidate(); + p5Table.repaint(); + } + }; + } + + private ActionListener downloadLog(JTable table) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (table.getRowCount() > 0) { + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setMultiSelectionEnabled(false); + chooser.setCurrentDirectory(FileSystemView.getFileSystemView().getHomeDirectory()); + chooser.showOpenDialog($this); + File folder = chooser.getSelectedFile(); + FileWriter fileWriter = null; + String fileName = "BOM־-" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + ".txt"; + try { + fileWriter = new FileWriter(folder.getPath() + File.separator + fileName);// ıļ + String temp; + System.out.println(logDataList.size()); + for (Entity entity : logDataList) { + fileWriter.write((temp = entity.get("ID").toString()) + + StringCreateUtil.createBlank(10 - temp.length()) + + (temp = entity.get("MODIFY_USER").toString()) + + StringCreateUtil.createBlank(20 - temp.length()) + + (temp = entity.get("MODIFY_TIME").toString()) + + StringCreateUtil.createBlank(30 - temp.length()) + + entity.get("MODIFY_CONTENT").toString() + "\r\n"); + } + fileWriter.flush(); + fileWriter.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + } + + JOptionPane.showMessageDialog($this, "־ɹ\r\n·" + folder + File.separator + fileName, "ʾ", + JOptionPane.WARNING_MESSAGE); + } + } + }; + + } + + private ActionListener batchReplace() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p1NumText.getText().trim(); + String text = p1UnitCombo.getSelectedText().trim(); + Object value = p1UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p1Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + List logData = new ArrayList(); + L1: for (int i = 0; i < selectedRowList.size(); i++) { + try { + doIndex++; + BOMManageTableBean bean = selectedRowList.get(i); + System.out.println(value.toString()); + if (!addedBOMLine.add(targetRev2)) { + continue L1; + } + AIFComponentContext[] aifs = bean.getParentLine().getChildren(); + for (AIFComponentContext aif : aifs) { + String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() + .getProperty("object_string"); + if (objStr.equals(targetRev2.getProperty("object_string"))) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), targetRev2.getProperty("object_string"), + value.toString(), numStr, "ʧܣѴͬӼ" }); + continue L1; + } + } + String seq = selectedRowList.get(i).getChildLine().getProperty("bl_sequence_no"); + bean.getParentLine().remove("", bean.getChildLine()); + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity", "bl_sequence_no" }, + new String[] { numStr, seq }); + msgData.add( + new String[] { msgData.size() + 1 + "", bean.getParentString(), bean.getChildString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + BOMLogBean logBean = new BOMLogBean(bean.getChildString(), + targetRev2.getProperty("object_string"), bean.getParentString(), "滻", value.toString(), + "", numStr); + logData.add(logBean); + selectedRowList.get(i).setChildString(targetRev2.getProperty("object_string")); + selectedRowList.get(i).setChildRev(targetRev2); + selectedRowList.get(i).setChildLine(childLine); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("滻ִϣʱ" + (endTime - startTime) + "ms"); + doLog("滻", logData); + JScrollPane jsp = DialogUtil + .createTableMsg(new String[] { "", "", "ԭӼ", "滻Ӽ", "λ", "", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "滻 ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow2(p1Table, selectedRowList); + } + }; + } + + private ActionListener batchModify() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p2NumText.getText(); + List selectedRowList = getselectedRow(p2Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + List logData = new ArrayList<>(); + for (BOMManageTableBean bean : selectedRowList) { + String oldNumStr = ""; + try { + doIndex++; + oldNumStr = bean.getChildLine().getProperty("bl_quantity"); + bean.getChildLine().setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), oldNumStr, numStr, "ɹ" }); + BOMLogBean logBean = new BOMLogBean(bean.getChildString(), + targetRev2.getProperty("object_string"), bean.getParentString(), "޸", "", oldNumStr, + numStr); + logData.add(logBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("޸", logData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "ԭ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "Ľ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow(p2Table, selectedRowList); + } + }; + } + + private ActionListener batchAdd() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p3NumText.getText().trim(); + String text = p3UnitCombo.getSelectedText().trim(); + Object value = p3UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p3Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + List logData = new ArrayList<>(); + L1: for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + System.out.println(value.toString()); + if (!addedBOMLine.add(targetRev2)) { + continue L1; + } + AIFComponentContext[] aifs = bean.getParentLine().getChildren(); + for (AIFComponentContext aif : aifs) { + String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() + .getProperty("object_string"); + if (objStr.equals(targetRev2.getProperty("object_string"))) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, + "ʧܣѴͬӼ" }); + continue L1; + } + } + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + BOMLogBean logBean = new BOMLogBean(bean.getChildString(), + targetRev2.getProperty("object_string"), bean.getParentString(), "", value.toString(), + "", numStr); + logData.add(logBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("", logData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "λ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, " ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// showWhereUesd(p3Table, p3SelectAll); + } + }; + } + + private ActionListener batchRemove() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(p4Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + List logData = new ArrayList<>(); + for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + if (bean.getChildLine() == null) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "bomLineڣѾɹɾ" }); + } else { + bean.getParentLine().remove("", bean.getChildLine()); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "ɹ" }); + BOMLogBean logBean = new BOMLogBean(bean.getChildString(), + targetRev2.getProperty("object_string"), bean.getParentString(), "ɾ", "", "", ""); + logData.add(logBean); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ɾִϣʱ" + (endTime - startTime) + "ms"); + doLog("ɾ", logData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "ɾӼ", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "ɾ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// removeSelectRow(p4Table); + updateSelectedRow3(p4Table, selectedRowList); + } + }; + } + + private List getselectedRow(JTable table) { + List selectedList = new ArrayList(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + System.out.println("select=====>" + table.getValueAt(i, 1)); + selectedList.add(tableDataMap.get(table.getValueAt(i, 1))); + } + } + return selectedList; + } + + private void updateSelectedRow(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + try { + TCComponentItemRevision parentRev = newRowData.get(index).getParentRev(); + String parentString = newRowData.get(index).getParentString(); + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.get(table.getValueAt(i, 1).toString()).close(); + winMap.remove(table.getValueAt(i, 1)); + winMap.put(parentString, win); + tableDataMap.remove(table.getValueAt(i, 1).toString()); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (newRowData.get(index).getChildString() + .equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + JCheckBox selected = new JCheckBox(); + selected.setSelected(true); + Object[] rowData = new Object[] { selected, parentString, + newRowData.get(index).getChildString(), unit, num, status }; + rowPrint(rowData); + for (int ii = 0; ii < rowData.length; ii++) { + table.setValueAt(rowData[ii], i, ii); + } + tableDataMap.put(parentString, new BOMManageTableBean(parentString, + newRowData.get(index).getChildString(), parentRev, targetRev, topLine, child)); + break; + } + } + index++; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow2(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + try { + TCComponentBOMLine child = bean.getChildLine(); + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + table.setValueAt(bean.getChildString(), i, 2); + table.setValueAt(unit, index, 3); + table.setValueAt(num, index, 4); + tableDataMap.get(bean.getParentString()).setChildRev(bean.getChildRev()); + tableDataMap.get(bean.getParentString()).setChildString(bean.getChildString()); + tableDataMap.get(bean.getParentString()).setChildLine(child); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow3(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + table.setValueAt("", i, 2); + table.setValueAt("", index, 3); + table.setValueAt("", index, 4); + tableDataMap.get(bean.getParentString()).setChildLine(null); + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void removeSelectRow(JTable table) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int i = 0; + while (i < table.getRowCount()) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + model.removeRow(i); + continue; + } + i++; + } + table.revalidate(); + table.repaint(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + new Thread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + try { + closeWin(); + System.out.println("closed"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }).start(); + + super.dispose(); + } + + private void saveWin() throws TCException { + for (Entry entry : winMap.entrySet()) { + if (entry.getValue() != null) { + entry.getValue().save(); + } + + } + } + + private void closeWin() throws TCException { + saveWin(); + + for (Entry entry : winMap.entrySet()) { + entry.getValue().close(); + } + winMap.clear(); + } + + private void doLog(String operation, List logData) { + createLogDataSourceTable(); + String username = ""; + try { + username = session.getUser().getUserName() + "(" + session.getUser().getUserId() + ")"; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + String datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + List sqls = new ArrayList(); + for (BOMLogBean bean : logData) { + StringBuilder builder = new StringBuilder(); + builder.append( + "insert into JD2_BOMMANAGELOG (MODIFY_USER,MODIFY_TIME,MODIFY_CONTENT,TARGET1,TARGET2,PARENT,OPERATION,UNIT,NUM) VALUES ('"); + builder.append(username); + builder.append("',to_date('"); + builder.append(datetime); + builder.append("','yyyy-MM-dd hh24:mi:ss'),'"); + if ("滻".equals(operation)) { + String temp = String.format("%sӼ%s滻Ϊ%s;%s;%s", bean.getParent(), bean.getTarget1(), + bean.getTarget2(), bean.getUnit(), bean.getNum()); + builder.append(temp + "','"); + } else if ("޸".equals(operation)) { + String temp = String.format("%sӼ%s%sΪ%s", bean.getParent(), bean.getTarget1(), bean.getOldNum(), + bean.getNum()); + builder.append(temp + "','"); + } else if ("".equals(operation)) { + String temp = String.format("%sӼ%s;%s;%s", bean.getParent(), bean.getTarget2(), bean.getUnit(), + bean.getNum()); + builder.append(temp + "','"); + } else if ("ɾ".equals(operation)) { + String temp = String.format("%sɾӼ%s", bean.getParent(), bean.getTarget1()); + builder.append(temp + "','"); + } + builder.append(bean.getTarget1() + "','"); + builder.append(bean.getTarget2() + "','"); + builder.append(bean.getParent() + "','"); + builder.append(bean.getUnit() + "','"); + builder.append(operation + "','"); + builder.append(bean.getNum() + "');"); + sqls.add(builder.toString()); + } + + try { + Db.use(DBUtil.getDataSource(session)).executeBatch(sqls.toArray(new String[sqls.size()])); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private ActionListener clickSearch(JTable table, JCheckBox selectAll) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JDialog content = DialogUtil.createSearchAndSelectRevDialog($this, table, selectAll, + (JButton) e.getSource()); + } + }; + } + + public void okCallback(JTable revTable, JTable table, JCheckBox selectAll, JButton field) { + // TODO Auto-generated method stub + int rowIndex = revTable.getSelectedRow(); + if (rowIndex < 0) { + return; + } + String text = revTable.getValueAt(rowIndex, 0).toString(); + System.out.println(text); + field.setText(text); + if ("".equals(text)) { + return; + } + if (table != null) { + targetRev = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + showWhereUesd(table, selectAll); + } else { + targetRev2 = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + } + } + + private KeyAdapter logSearchEnter() { + return new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + super.keyTyped(e); + if (e.getKeyChar() == KeyEvent.VK_ENTER) { + p5Search.doClick(); + } + } + }; + } + + private void updateTitleShowProgress(List list) { + new Thread(new Runnable() { + + @Override + public void run() { + int num = 1; + String temp; + doIndex = 0; + while (!complate) { + $this.setTitle("ڴ" + (temp = StringCreateUtil.createPoint(num % 3)) + + StringCreateUtil.createBlank(5 - temp.length()) + list.get(doIndex).getParentString() + + " " + (doIndex + 1) + "/" + list.size()); + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + num++; + } + $this.setTitle("BOM"); + doIndex = -1; + complate = false; + } + }).start(); + } + + private boolean checkReleaseStatus(TCComponentItemRevision rev) { + try { + System.out.println("item type======>" + rev.getItem().getType()); + if (checkItemType.contains(rev.getItem().getType())) { + return true; + } + TCComponent form = rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] statusArray = form.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + if ("".equals(status) || "JD2_DJJY".equals(status) || "JD2_DJKY".equals(status)) { + return false; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } + + private ResultData checkAccess(List data) { + for (BOMManageTableBean bean : data) { + boolean isAccess = true; + try { + isAccess = session.getTCAccessControlService().checkPrivilege(bean.getParentLine(), "WRITE"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (!isAccess) { + try { + return new ResultData(false, "ǰûûж" + bean.getParentLine().getProperty("object_string") + "дȨ", + bean.getParentLine()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return new ResultData(true, "", null); + } + + private boolean checkTargetAndSelect(TCComponentItemRevision rev, List data) { + if (!checkReleaseStatus(rev)) { + JOptionPane.showMessageDialog($this, "Ŀδߴڶ״̬޷BOM", "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + ResultData res = checkAccess(data); + if (!res.isRes()) { + JOptionPane.showMessageDialog($this, res.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + return true; + } + + private ActionListener startWorkFlow(JTable table) { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List select = getselectedRow(table); + List parentRev = new ArrayList<>(); + for (BOMManageTableBean bean : select) { + parentRev.add(bean.getParentRev()); + } + $this.setExtendedState(JFrame.ICONIFIED); + NewProcessCommand command = new NewProcessCommand(AIFUtility.getActiveDesktop(), app, + parentRev.toArray(new TCComponentItemRevision[parentRev.size()])); + } + }; + } + + private void rowPrint(Object[] arr) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (Object obj : arr) { + if (obj instanceof JCheckBox) { + sb.append(((JCheckBox) obj).isSelected()); + } else { + sb.append(obj.toString()); + } + sb.append(","); + } + if (sb.length() > 1) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append("]"); + System.out.println(sb.toString()); + } + + private void resize() { + double left = 2 * this.widthOffset / 3.0; + double right = this.widthOffset - left; + + int bottom1 = p1BottomBtn2.getX() - p1BottomBtn1.getX() - p1BottomBtn1.getWidth(); + int bottom2 = p1BottomBtn3.getX() - p1BottomBtn2.getX() - p1BottomBtn2.getWidth(); + int botttom3 = p1BottomBtn4.getX() - p1BottomBtn3.getX() - p1BottomBtn3.getWidth(); + + // p1 + int p1x1 = p1TargetBtn.getX() - p1TargetLabel.getX() - p1TargetLabel.getWidth(); + int p1x2 = p1ReplaceBtn.getX() - p1ReplaceLabel.getX() - p1ReplaceLabel.getWidth(); + int p1x3 = p1UnitLabel.getX() - p1ReplaceBtn.getX() - p1ReplaceBtn.getWidth(); + int p1x4 = p1NumLabel.getX() - p1UnitCombo.getX() - p1UnitCombo.getWidth(); + p1TargetLabel.setBounds(p1TargetLabel.getX() + getOffset(left, 20, 800), 20, + p1TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p1TargetBtn.setBounds(p1TargetLabel.getX() + p1TargetLabel.getWidth() + p1x1 + getOffset(left, 10, 800), 20, + p1TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p1ReplaceLabel.setBounds(p1ReplaceLabel.getX() + getOffset(left, 20, 800), 60, + p1ReplaceLabel.getWidth() + getOffset(left, 100, 800), 25); + p1ReplaceBtn.setBounds(p1ReplaceLabel.getX() + p1ReplaceLabel.getWidth() + p1x2 + getOffset(left, 10, 800), 60, + p1ReplaceBtn.getWidth() + getOffset(left, 400, 800), 25); + p1UnitLabel.setBounds(p1ReplaceBtn.getX() + p1ReplaceBtn.getWidth() + p1x3 + getOffset(left, 30, 800), 60, + p1UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p1UnitCombo.setBounds(p1UnitLabel.getX() + p1UnitLabel.getWidth(), 60, + p1UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p1NumLabel.setBounds(p1UnitCombo.getX() + p1UnitCombo.getWidth() + p1x4 + getOffset(left, 20, 800), 60, + p1NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p1NumText.setBounds(p1NumLabel.getX() + p1NumLabel.getWidth(), 60, + p1NumText.getWidth() + getOffset(left, 50, 800), 25); + p1SelectAll.setBounds(p1SelectAll.getX() + getOffset(left, 20, 800), 100, + p1SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p1jsp.setBounds(p1jsp.getX() + getOffset(left, 20, 800), p1jsp.getY(), + p1jsp.getWidth() + getOffset(left, 760, 800), p1jsp.getHeight() + this.heightOffset); + p1BottomBtn1.setBounds(p1BottomBtn1.getX() + getOffset(left, 80, 800), p1BottomBtn1.getY() + this.heightOffset, + p1BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn2.setBounds(p1BottomBtn1.getX() + p1BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p1BottomBtn2.getY() + this.heightOffset, p1BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn3.setBounds(p1BottomBtn2.getX() + p1BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p1BottomBtn3.getY() + this.heightOffset, p1BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn4.setBounds(p1BottomBtn3.getX() + p1BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p1BottomBtn4.getY() + this.heightOffset, p1BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p1Left.setBounds(0, 0, p1Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p1Left.getHeight() + this.heightOffset); + p1TreePanel.setBounds(p1TreePanel.getX() + getOffset(right, 20, 400), 130, + p1TreePanel.getWidth() + getOffset(right, 360, 400), p1TreePanel.getHeight() + this.heightOffset); + p1Right.setBounds(p1Left.getX() + p1Left.getWidth(), 0, + p1Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p1Right.getHeight() + this.heightOffset); + p1.revalidate(); + p1.repaint(); + + // p2 + int p2x1 = p2TargetBtn.getX() - p2TargetLabel.getX() - p2TargetLabel.getWidth(); + int p2x2 = p2NumText.getX() - p2ChangeNumLabel.getX() - p2ChangeNumLabel.getWidth(); + p2TargetLabel.setBounds(p2TargetLabel.getX() + getOffset(left, 20, 800), 20, + p2TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p2TargetBtn.setBounds(p2TargetLabel.getX() + p2TargetLabel.getWidth() + p2x1 + getOffset(left, 10, 800), 20, + p2TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p2ChangeNumLabel.setBounds(p2ChangeNumLabel.getX() + getOffset(left, 20, 800), 60, + p2ChangeNumLabel.getWidth() + getOffset(left, 100, 800), 25); + p2NumText.setBounds(p2ChangeNumLabel.getX() + p2ChangeNumLabel.getWidth() + p2x2 + getOffset(left, 10, 800), 60, + p2NumText.getWidth() + getOffset(left, 50, 800), 25); + p2SelectAll.setBounds(p2SelectAll.getX() + getOffset(left, 20, 800), 100, + p2SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p2jsp.setBounds(p2jsp.getX() + getOffset(left, 20, 800), p2jsp.getY(), + p2jsp.getWidth() + getOffset(left, 760, 800), p2jsp.getHeight() + this.heightOffset); + p2BottomBtn1.setBounds(p2BottomBtn1.getX() + getOffset(left, 80, 800), p2BottomBtn1.getY() + this.heightOffset, + p2BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn2.setBounds(p2BottomBtn1.getX() + p2BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p2BottomBtn2.getY() + this.heightOffset, p2BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn3.setBounds(p2BottomBtn2.getX() + p2BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p2BottomBtn3.getY() + this.heightOffset, p2BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn4.setBounds(p2BottomBtn3.getX() + p2BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p2BottomBtn4.getY() + this.heightOffset, p2BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p2Left.setBounds(0, 0, p2Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p2Left.getHeight() + this.heightOffset); + p2TreePanel.setBounds(p2TreePanel.getX() + getOffset(right, 20, 400), 130, + p2TreePanel.getWidth() + getOffset(right, 360, 400), p2TreePanel.getHeight() + this.heightOffset); + p2Right.setBounds(p2Left.getX() + p2Left.getWidth(), 0, + p2Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p2Right.getHeight() + this.heightOffset); + p2.revalidate(); + p2.repaint(); + + // p3 + int p3x1 = p3TargetBtn.getX() - p3TargetLabel.getX() - p3TargetLabel.getWidth(); + int p3x2 = p3AddBtn.getX() - p3AddLabel.getX() - p3AddLabel.getWidth(); + int p3x3 = p3UnitLabel.getX() - p3AddBtn.getX() - p3AddBtn.getWidth(); + int p3x4 = p3NumLabel.getX() - p3UnitCombo.getX() - p3UnitCombo.getWidth(); + p3TargetLabel.setBounds(p3TargetLabel.getX() + getOffset(left, 20, 800), 20, + p3TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p3TargetBtn.setBounds(p3TargetLabel.getX() + p3TargetLabel.getWidth() + p3x1 + getOffset(left, 10, 800), 20, + p3TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p3AddLabel.setBounds(p3AddLabel.getX() + getOffset(left, 20, 800), 60, + p3AddLabel.getWidth() + getOffset(left, 100, 800), 25); + p3AddBtn.setBounds(p3AddLabel.getX() + p3AddLabel.getWidth() + p3x2 + getOffset(left, 10, 800), 60, + p3AddBtn.getWidth() + getOffset(left, 400, 800), 25); + p3UnitLabel.setBounds(p3AddBtn.getX() + p3AddBtn.getWidth() + p3x3 + getOffset(left, 30, 800), 60, + p3UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p3UnitCombo.setBounds(p3UnitLabel.getX() + p3UnitLabel.getWidth(), 60, + p3UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p3NumLabel.setBounds(p3UnitCombo.getX() + p3UnitCombo.getWidth() + p3x4 + getOffset(left, 20, 800), 60, + p3NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p3NumText.setBounds(p3NumLabel.getX() + p3NumLabel.getWidth(), 60, + p3NumText.getWidth() + getOffset(left, 50, 800), 25); + p3SelectAll.setBounds(p3SelectAll.getX() + getOffset(left, 20, 800), 100, + p3SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p3jsp.setBounds(p3jsp.getX() + getOffset(left, 20, 800), p3jsp.getY(), + p3jsp.getWidth() + getOffset(left, 760, 800), p3jsp.getHeight() + this.heightOffset); + p3BottomBtn1.setBounds(p3BottomBtn1.getX() + getOffset(left, 80, 800), p3BottomBtn1.getY() + this.heightOffset, + p3BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn2.setBounds(p3BottomBtn1.getX() + p3BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p3BottomBtn2.getY() + this.heightOffset, p3BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn3.setBounds(p3BottomBtn2.getX() + p3BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p3BottomBtn3.getY() + this.heightOffset, p3BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn4.setBounds(p3BottomBtn3.getX() + p3BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p3BottomBtn4.getY() + this.heightOffset, p3BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p3Left.setBounds(0, 0, p3Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p3Left.getHeight() + this.heightOffset); + p3TreePanel.setBounds(p3TreePanel.getX() + getOffset(right, 20, 400), 130, + p3TreePanel.getWidth() + getOffset(right, 360, 400), p3TreePanel.getHeight() + this.heightOffset); + p3Right.setBounds(p3Left.getX() + p3Left.getWidth(), 0, + p3Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p3Right.getHeight() + this.heightOffset); + p3.revalidate(); + p3.repaint(); + + // p4 + int p4x1 = p4TargetBtn.getX() - p4TargetLabel.getX() - p4TargetLabel.getWidth(); + p4TargetLabel.setBounds(p4TargetLabel.getX() + getOffset(left, 20, 800), 20, + p4TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p4TargetBtn.setBounds(p4TargetLabel.getX() + p4TargetLabel.getWidth() + p4x1 + getOffset(left, 10, 800), 20, + p4TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p4SelectAll.setBounds(p4SelectAll.getX() + getOffset(left, 20, 800), 100, + p4SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p4jsp.setBounds(p4jsp.getX() + getOffset(left, 20, 800), p4jsp.getY(), + p4jsp.getWidth() + getOffset(left, 760, 800), p4jsp.getHeight() + this.heightOffset); + p4BottomBtn1.setBounds(p4BottomBtn1.getX() + getOffset(left, 80, 800), p4BottomBtn1.getY() + this.heightOffset, + p4BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn2.setBounds(p4BottomBtn1.getX() + p4BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p4BottomBtn2.getY() + this.heightOffset, p4BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn3.setBounds(p4BottomBtn2.getX() + p4BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p4BottomBtn3.getY() + this.heightOffset, p4BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn4.setBounds(p4BottomBtn3.getX() + p4BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p4BottomBtn4.getY() + this.heightOffset, p4BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p4Left.setBounds(0, 0, p4Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p4Left.getHeight() + this.heightOffset); + p4TreePanel.setBounds(p4TreePanel.getX() + getOffset(right, 20, 400), 130, + p4TreePanel.getWidth() + getOffset(right, 360, 400), p4TreePanel.getHeight() + this.heightOffset); + p4Right.setBounds(p4Left.getX() + p4Left.getWidth(), 0, + p4Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p4Right.getHeight() + this.heightOffset); + p4.revalidate(); + p4.repaint(); + + // p5 + int p5x1 = p5UserText.getX() - p5UserLabel.getX() - p5UserLabel.getWidth(); + int p5x2 = p5TimeLabel.getX() - p5UserText.getX() - p5UserText.getWidth(); + int p5x3 = p5TimeStartText.getX() - p5TimeLabel.getX() - p5TimeLabel.getWidth(); + int p5x4 = toLabel.getX() - p5TimeStartText.getX() - p5TimeStartText.getWidth(); + int p5x5 = p5TimeEndText.getX() - toLabel.getX() - toLabel.getWidth(); + int p5x6 = p5ContentLabel.getX() - p5TimeEndText.getX() - p5TimeEndText.getWidth(); + int p5x7 = p5Contentjsp.getX() - p5ContentLabel.getX() - p5ContentLabel.getWidth(); + int p5x8 = p5Search.getX() - p5Contentjsp.getX() - p5Contentjsp.getWidth(); + int p5x9 = p5Download.getX() - p5Search.getX() - p5Search.getWidth(); + p5UserLabel.setBounds(p5UserLabel.getX(), 40, p5UserLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), + 25); + p5UserText.setBounds(p5UserLabel.getX() + p5UserLabel.getWidth() + p5x1 + getOffset(this.widthOffset, 10, 1200), + 40, p5UserText.getWidth() + getOffset(this.widthOffset, 150, 1200), 25); + p5TimeLabel.setBounds(p5UserText.getX() + p5UserText.getWidth() + p5x2 + getOffset(this.widthOffset, 50, 1200), + 40, p5TimeLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5TimeStartText.setBounds( + p5TimeLabel.getX() + p5TimeLabel.getWidth() + p5x3 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeStartText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + toLabel.setBounds( + p5TimeStartText.getX() + p5TimeStartText.getWidth() + p5x4 + getOffset(this.widthOffset, 10, 1200), 40, + toLabel.getWidth() + getOffset(this.widthOffset, 20, 1200), 25); + p5TimeEndText.setBounds(toLabel.getX() + toLabel.getWidth() + p5x5 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeEndText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5ContentLabel.setBounds( + p5TimeEndText.getX() + p5TimeEndText.getWidth() + p5x6 + getOffset(this.widthOffset, 50, 1200), 40, + p5ContentLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5Contentjsp.setBounds( + p5ContentLabel.getX() + p5ContentLabel.getWidth() + p5x7 + getOffset(this.widthOffset, 10, 1200), 20, + p5Contentjsp.getWidth() + getOffset(this.widthOffset, 200, 1200), 80); + p5Search.setBounds(p5Contentjsp.getX() + p5Contentjsp.getWidth() + p5x8 + getOffset(this.widthOffset, 50, 1200), + 40, p5Search.getWidth() + getOffset(this.widthOffset, 60, 1200), 25); + p5Download.setBounds(p5Search.getX() + p5Search.getWidth() + p5x9 + getOffset(this.widthOffset, 20, 1200), 40, + p5Download.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5jsp.setBounds(p5jsp.getX() + getOffset(this.widthOffset, 20, 1200), p5jsp.getY(), + p5jsp.getWidth() + getOffset(this.widthOffset, 1160, 1200), p5jsp.getHeight() + this.heightOffset); + p5.revalidate(); + p5.repaint(); + } + + private int getOffset(double num1, int num2, int num3) { + return (int) (num1 * num2 / num3); + } + + private int getResultNum(List msgData, boolean success) { + int num = 0; + String str = success ? "ɹ" : "ʧ"; + for (String[] row : msgData) { + if (row[row.length - 1].contains(str)) { + num++; + } + } + return num; + } +} diff --git a/src/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.java b/src/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.java new file mode 100644 index 0000000..bc4a752 --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.java @@ -0,0 +1,107 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.net.URL; + +import javax.swing.ImageIcon; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; +import javax.swing.tree.TreeCellRenderer; + +import com.connor.jd.plm.beans.TransformBomBean; +import com.teamcenter.rac.kernel.TCException; + +public class CheckBoxTreeCellRenderer extends JPanel implements TreeCellRenderer { + protected JCheckBox check; + protected CheckBoxTreeLabel label; + + public CheckBoxTreeCellRenderer() { + setLayout(null); + add(check = new JCheckBox()); + add(label = new CheckBoxTreeLabel()); + // òɱ༭ + check.setEnabled(false); + check.setBackground(UIManager.getColor("Tree.textBackground")); + label.setForeground(UIManager.getColor("Tree.textForeground")); + } + + /** + * صһJPanel󣬸öаһJCheckBox + * һJLabel󡣲ҸÿǷѡJCheckBox ǷѡС + */ + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, + boolean leaf, int row, boolean hasFocus) { + String stringValue = tree.convertValueToText(value, selected, expanded, leaf, row, hasFocus); + setEnabled(tree.isEnabled()); + check.setSelected(((CheckBoxTreeNode) value).isSelected()); + label.setFont(tree.getFont()); + label.setText(stringValue); + label.setSelected(selected); + label.setFocus(hasFocus); + + CheckBoxTreeNode node = (CheckBoxTreeNode) value; + TransformBomBean bean = (TransformBomBean) node.getUserObject(); + try { + String type = bean.line.getItemRevision().getType(); + if (type.equals("WX3_ZPTRevision")) { + URL resource = CheckBoxTreeCellRenderer.class.getResource("/com/connor/wxplm/utils/WX3_zptrev.png"); + label.setIcon(new ImageIcon(resource)); + } else if (type.equals("WX3_LJTRevision")) { + URL resource = CheckBoxTreeCellRenderer.class.getResource("/com/connor/wxplm/utils/WX3_ljtrev.png"); + label.setIcon(new ImageIcon(resource)); + } else if (type.equals("WX3_WLRevision")) { + URL resource = CheckBoxTreeCellRenderer.class.getResource("/com/connor/wxplm/utils/WX3_WLRev.png"); + label.setIcon(new ImageIcon(resource)); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + /* + * if(leaf) label.setIcon(UIManager.getIcon("Tree.leafIcon")); else if(expanded) + * label.setIcon(UIManager.getIcon("Tree.expandedIcon")); else + * label.setIcon(UIManager.getIcon("Tree.closedIcon")); + */ + + return this; + } + + @Override + public Dimension getPreferredSize() { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + return new Dimension(dCheck.width + dLabel.width, + dCheck.height < dLabel.height ? dLabel.height : dCheck.height); + } + + @Override + public void doLayout() { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + int yCheck = 0; + int yLabel = 0; + if (dCheck.height < dLabel.height) + yCheck = (dLabel.height - dCheck.height) / 2; + else + yLabel = (dCheck.height - dLabel.height) / 2; + check.setLocation(0, yCheck); + check.setBounds(0, yCheck, dCheck.width, dCheck.height); + label.setLocation(dCheck.width, yLabel); + label.setBounds(dCheck.width, yLabel, dLabel.width, dLabel.height); + } + + @Override + public void setBackground(Color color) { + if (color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } + +} diff --git a/src/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.java b/src/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.java new file mode 100644 index 0000000..2c8b26c --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.java @@ -0,0 +1,66 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; + +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; + +public class CheckBoxTreeLabel extends JLabel { + private boolean isSelected; + private boolean hasFocus; + + public CheckBoxTreeLabel() { + } + + @Override + public void setBackground(Color color) { + if (color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } + + @Override + public void paint(Graphics g) { + String str; + if ((str = getText()) != null) { + if (0 < str.length()) { + if (isSelected) + g.setColor(UIManager.getColor("Tree.selectionBackground")); + else + g.setColor(UIManager.getColor("Tree.textBackground")); + Dimension d = getPreferredSize(); + int imageOffset = 0; + Icon currentIcon = getIcon(); + if (currentIcon != null) + imageOffset = currentIcon.getIconWidth() + Math.max(0, getIconTextGap() - 1); + g.fillRect(imageOffset, 0, d.width - 1 - imageOffset, d.height); + if (hasFocus) { + g.setColor(UIManager.getColor("Tree.selectionBorderColor")); + g.drawRect(imageOffset, 0, d.width - 1 - imageOffset, d.height - 1); + } + } + } + super.paint(g); + } + + @Override + public Dimension getPreferredSize() { + Dimension retDimension = super.getPreferredSize(); + if (retDimension != null) + retDimension = new Dimension(retDimension.width + 3, retDimension.height); + return retDimension; + } + + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + } + + public void setFocus(boolean hasFocus) { + this.hasFocus = hasFocus; + } + +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/dialogs/CheckBoxTreeNode.java b/src/com/connor/jd/plm/dialogs/CheckBoxTreeNode.java new file mode 100644 index 0000000..65e71b9 --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/CheckBoxTreeNode.java @@ -0,0 +1,92 @@ +package com.connor.jd.plm.dialogs; + +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.MutableTreeNode; +import javax.swing.tree.TreeNode; + +public class CheckBoxTreeNode extends DefaultMutableTreeNode { + protected boolean isSelected; + protected boolean isSelectable = true; + public CheckBoxTreeNode() { + this(null); + } + + public CheckBoxTreeNode(Object userObject) { + this(userObject, true, false); + } + + public CheckBoxTreeNode(Object userObject, boolean allowsChildren, boolean isSelected) { + super(userObject, allowsChildren); + this.isSelected = isSelected; + } + + public boolean isSelected() { + return isSelected; + } + + public void setSelected(boolean _isSelected) { + this.isSelected = _isSelected; + + /*if (_isSelected) { + // ѡУеӽ㶼ѡ + if (children != null) { + for (Object obj : children) { + CheckBoxTreeNode node = (CheckBoxTreeNode) obj; + if (_isSelected != node.isSelected()) + node.setSelected(_isSelected); + } + } + // ϼ飬ӽ㶼ѡУôҲѡ + CheckBoxTreeNode pNode = (CheckBoxTreeNode) parent; + // ʼpNodeӽڵǷ񶼱ѡ + if (pNode != null) { + int index = 0; + for (; index < pNode.children.size(); ++index) { + CheckBoxTreeNode pChildNode = (CheckBoxTreeNode) pNode.children.get(index); + if (!pChildNode.isSelected()) + break; + } + + * pNodeӽ㶼ѾѡУѡи㣬 ÷һݹ鷽ڴ˲ҪеΪ + * ѡи󣬸㱾ϼġ + + if (index == pNode.children.size()) { + if (pNode.isSelected() != _isSelected) + pNode.setSelected(_isSelected); + } + } + } else { + + * ȡ㵼ӽȡôʱеӽ㶼Ӧѡϵģ + * ӽȡ¸ȡȻ󸸽ȡҪȡӽ㣬 ʱDzҪȡӽġ + + if (children != null) { + int index = 0; + for (; index < children.size(); ++index) { + CheckBoxTreeNode childNode = (CheckBoxTreeNode) children.get(index); + if (!childNode.isSelected()) + break; + } + // ȡʱ + if (index == children.size()) { + for (int i = 0; i < children.size(); ++i) { + CheckBoxTreeNode node = (CheckBoxTreeNode) children.get(i); + if (node.isSelected() != _isSelected) + node.setSelected(_isSelected); + } + } + } + + // ȡֻҪһӽڵ㲻ѡϵģôڵͲӦñѡϡ + CheckBoxTreeNode pNode = (CheckBoxTreeNode) parent; + if (pNode != null && pNode.isSelected() != _isSelected) + pNode.setSelected(_isSelected); + }*/ + } + + // ɱ༭ + public boolean setSelectable(boolean bol) { + + return isSelectable = bol; + } +} diff --git a/src/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.java b/src/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.java new file mode 100644 index 0000000..6631a27 --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.java @@ -0,0 +1,30 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; + + + +public class CheckBoxTreeNodeSelectionListener extends MouseAdapter { + @Override + public void mouseClicked(MouseEvent event) { + + JTree tree = (JTree) event.getSource(); + int x = event.getX(); + int y = event.getY(); + int row = tree.getRowForLocation(x, y); + TreePath path = tree.getPathForRow(row); + if (path != null) { + CheckBoxTreeNode node = (CheckBoxTreeNode) path.getLastPathComponent(); + if (node != null&&node.isSelectable) { + boolean isSelected = !node.isSelected(); + node.setSelected(isSelected); + ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node); + } + } + } +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/dialogs/ColorMaterialBean.java b/src/com/connor/jd/plm/dialogs/ColorMaterialBean.java new file mode 100644 index 0000000..318496e --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/ColorMaterialBean.java @@ -0,0 +1,14 @@ +package com.connor.jd.plm.dialogs; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +public class ColorMaterialBean { + public List colorMaterial = new ArrayList(); + public Map data = new HashMap(); + +} diff --git a/src/com/connor/jd/plm/dialogs/MyTreeCellRenderer.java b/src/com/connor/jd/plm/dialogs/MyTreeCellRenderer.java new file mode 100644 index 0000000..dcaeb3f --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/MyTreeCellRenderer.java @@ -0,0 +1,40 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.Component; + +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; + +import com.teamcenter.rac.kernel.TCSession; + +public class MyTreeCellRenderer extends DefaultTreeCellRenderer { + private TCSession session; + + public MyTreeCellRenderer(TCSession session) { + this.session = session; + } + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, + int row, boolean hasFocus) { + + super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + + setText(value.toString()); + + if (sel) { + setForeground(getTextSelectionColor()); + } else { + setForeground(getTextNonSelectionColor()); + } + + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + String str = node.toString(); + if (!"".equals(str)) { +// session.search(arg0, arg1, arg2) + } + + return this; + } +} diff --git a/src/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.java b/src/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.java new file mode 100644 index 0000000..6347dbd --- /dev/null +++ b/src/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.java @@ -0,0 +1,892 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.ScrollPaneConstants; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + +import com.connor.jd.plm.beans.TransformBomBean; +import com.connor.jd.plm.utils.DialogUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMViewRevision; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * bomתΪbom + * + * @author conner.mcc + * + */ +public class TransformDesignToPartDialog extends AbstractAIFDialog implements ActionListener { + private AbstractAIFApplication app; + private TCSession session; + private TCComponentBOMLine topBomline; + private JButton okButton; + private JButton celButton; + private JTree tree; + private CheckBoxTreeNode topTree; + private List> comboxList; + private JPanel rightJPanel; + private Map> checkBoxTreeNodelMap; + private Map, JButton> boxJButtonMap; + private JPanel leftJPanel; + private int index = 1; + private String[] types; + TCComponentBOMWindow win; + + public TransformDesignToPartDialog(AbstractAIFApplication app, TCComponentBOMLine topBomline, String[] types) { + // TODO Auto-generated constructor stub + System.out.println("step:-3------------------"); + comboxList = new ArrayList>(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.topBomline = topBomline; + this.types = types; + createWindow(); + + initUI(); + } + + private void createWindow() { + try { + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + win = winType.create(null); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ʼ + */ + private void initUI() { + this.setTitle("DBOMתEBOM"); + this.setSize(new Dimension(700, 400)); + JPanel rightroot = new JPanel(new BorderLayout()); + rightJPanel = new JPanel(new PropertyLayout()); + rightroot.setBorder(BorderFactory.createTitledBorder("")); + leftJPanel = new JPanel(new BorderLayout()); + leftJPanel.setBorder(BorderFactory.createTitledBorder("ͼֽ")); + leftJPanel.setPreferredSize(new Dimension(350, 300)); + rightroot.setPreferredSize(new Dimension(350, 300)); + getBOMTreeAndwl(); + JScrollPane leftpane = new JScrollPane(tree); + leftpane.setBorder(null); + leftJPanel.add(leftpane); + JScrollPane rightpane = new JScrollPane(rightJPanel); + rightroot.add(rightpane); + rightpane.setBorder(null); + final JScrollBar bar2 = rightpane.getVerticalScrollBar(); + final JScrollBar bar1 = leftpane.getVerticalScrollBar(); + rightpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + leftpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + bar2.addAdjustmentListener(new AdjustmentListener() { + + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + // TODO Auto-generated method stub + if (e.getValueIsAdjusting()) { + bar1.setValue(e.getValue()); + } + } + }); + + bar1.addAdjustmentListener(new AdjustmentListener() { + + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + // TODO Auto-generated method stub + if (e.getValueIsAdjusting()) { + bar2.setValue(e.getValue()); + } + } + }); + + leftpane.getVerticalScrollBar().setUnitIncrement(10); + leftpane.addMouseWheelListener(new MouseWheelListener() { + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + if (e.getScrollType() == e.WHEEL_UNIT_SCROLL && bar1.getValue() >= 0 + && bar1.getValue() <= bar1.getVisibleAmount()) { + int scroll = e.getUnitsToScroll(); + bar2.setValue(scroll * bar1.getUnitIncrement()); + + } + } + }); + + rightpane.getVerticalScrollBar().setUnitIncrement(10); + rightpane.addMouseWheelListener(new MouseWheelListener() { + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + if (e.getScrollType() == e.WHEEL_UNIT_SCROLL && bar1.getValue() >= 0 + && bar1.getValue() <= bar1.getVisibleAmount()) { + int scroll = e.getUnitsToScroll(); + bar1.setValue(scroll * bar2.getUnitIncrement()); + + } + } + }); + + JPanel botomJPanel = new JPanel(new ButtonLayout()); + okButton = new JButton("ת"); + okButton.addActionListener(this); + celButton = new JButton("˳"); + celButton.addActionListener(this); + + botomJPanel.add("1.1.left.top", okButton); + botomJPanel.add("1.2.left.top", new JLabel(" ")); + botomJPanel.add("1.3.left.top", celButton); + JPanel rootJPanel = new JPanel(new PropertyLayout()); + rootJPanel.add("1.1.left.top", leftJPanel); + rootJPanel.add("1.2.left.top", rightroot); + + this.setLayout(new BorderLayout()); + this.add(rootJPanel, BorderLayout.CENTER); + this.add(botomJPanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + this.setResizable(false); + } + + /** + * @param line BOMӵṹ + * @param node + * @throws TCException + */ + public void treeModel(TCComponentBOMLine line, CheckBoxTreeNode node) throws TCException { + System.out.println(line.getProperty("object_string") + "-------------------"); + AIFComponentContext[] children = line.getChildren(); + for (AIFComponentContext conetext : children) { + TCComponentBOMLine childLine = (TCComponentBOMLine) conetext.getComponent(); + final CheckBoxTreeNode childNode = new CheckBoxTreeNode(new TransformBomBean(childLine)); + childNode.setSelectable(false); + node.add(childNode); + setCombox(childLine, childNode); + treeModel(childLine, childNode); + } + } + + private void getBOMTreeAndwl() { + try { + checkBoxTreeNodelMap = new HashMap>(); + boxJButtonMap = new HashMap, JButton>(); + topTree = new CheckBoxTreeNode(new TransformBomBean(topBomline)); + setCombox(topBomline, topTree); + System.out.println("##########" + topTree.toString() + "##########"); + treeModel(topBomline, topTree); + tree = new JTree(); + tree.setEnabled(false); + tree.setRowHeight(30); + DefaultTreeModel model = new DefaultTreeModel(topTree); + tree.addMouseListener(new CheckBoxTreeNodeSelectionListener()); + tree.setModel(model); + tree.setCellRenderer(new CheckBoxTreeCellRenderer()); + tree.putClientProperty("JTree.lineStyle", "Angled"); + topTree.setSelectable(false); + tree.expandPath(new TreePath(topTree.getPath())); + Enumeration enumeration = topTree.preorderEnumeration(); + while (enumeration.hasMoreElements()) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement(); + if (!node.isLeaf()) { + TreePath path = new TreePath(node.getPath()); + tree.expandPath(path); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(okButton)) { + try { + System.out.println("ת"); + if (win == null) + createWindow(); + ColorMaterialBean bean = new ColorMaterialBean(); + createMaterialBom(topTree, bean); + if (bean.colorMaterial.size() != 0) { + System.out.println( + Arrays.deepToString(bean.colorMaterial.toArray(new String[bean.colorMaterial.size()][]))); + JScrollPane msgPanel = DialogUtil.createTableMsg(new String[] { "ID", "汾", "", "ɫ" }, + bean.colorMaterial).panel; + int r = JOptionPane.showConfirmDialog((Component) e.getSource(), msgPanel, "ɫȷ", + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); + if (r == JOptionPane.OK_OPTION) { + createBom1(bean); + } else { + System.out.println("cancel"); + return; + } + } else { + createBom1(bean); + } + MessageBox.post("תbomɹ", "ʾ", MessageBox.INFORMATION); + this.dispose(); + } catch (TCException e1) { + + // TODO Auto-generated catch block + MessageBox.post(e1.getMessage(), "תbomʧ", MessageBox.INFORMATION); + e1.printStackTrace(); + } finally { + try { + + win.close(); + win = null; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } else if (e.getSource().equals(celButton)) { + + dispose(); + } + + } + + @SuppressWarnings("unchecked") + private void createBom1(ColorMaterialBean bean) throws TCException { + for (Entry entry : bean.data.entrySet()) { + List arg1 = entry.getValue()[1] == null ? null + : (List) entry.getValue()[1]; + List arg2 = entry.getValue()[2] == null ? null : (List) entry.getValue()[2]; + List arg3 = entry.getValue()[3] == null ? null : (List) entry.getValue()[3]; + try { + createBom(entry.getKey(), arg1, arg2, arg3); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * TreeӦitemѡ + * + * @param wl + *//* + * private void checkSelected(String wl) { for (TransformBomBean bean : bomlist) + * { if (bean.map.containsKey(wl)) { bean.selectCount++; if (bean.selectCount > + * 1) { MessageBox.post("ֻΪǰͼֽѡһϽBOMת", "", MessageBox.WARNING); + * return; } System.out.println(bean.displayName + "ѡʾ"); + * System.out.println(checkBoxTreeNodelMap.containsKey(bean.displayName) ); + * checkBoxTreeNodelMap.get(bean.displayName).setSelected(true); + * findInTree(bean.displayName); TransformBomBean bean1 = (TransformBomBean) + * checkBoxTreeNodelMap.get(bean.displayName).getUserObject(); bean1.selectRev = + * (TCComponentItemRevision) bean.map.get(wl); } } } + */ + + /** + * TreeӦitemȡѡ + * + * @param wl + *//* + * private void checkDisSelected(String wl) { for (TransformBomBean bean : + * bomlist) { if (bean.map.containsKey(wl)) { bean.selectCount--; + * checkBoxTreeNodelMap.get(bean.displayName).setSelected(false); } } } + */ + + /** + * BOM + * + * @param node + * @throws TCException + */ + private void createMaterialBom(CheckBoxTreeNode node, ColorMaterialBean colorMaterialBean) throws TCException { + // System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); + TransformBomBean bean = (TransformBomBean) node.getUserObject(); + TCComponentItemRevision materialRev = bean.selectRev; + // Ѿϵbom + /* + * if (WXMethodUtil.isRevBomReleased(materialRev)) { System.out.println(""); + * return; } + */ + + if (isLoopBom(node)) { + MessageBox.post("ѭBOMṹ", "", MessageBox.WARNING); + return; + } + int childCount = node.getChildCount(); + List childrenList = new ArrayList(); + List quantityList = new ArrayList(); + for (int i = 0; i < childCount; i++) { + CheckBoxTreeNode childNode = (CheckBoxTreeNode) node.getChildAt(i); + if (childNode.isSelected()) { + TransformBomBean bean1 = (TransformBomBean) childNode.getUserObject(); + childrenList.add(bean1.selectRev); + quantityList.add(bean1.line.getProperty("bl_quantity")); + // жǷ񷢲 + if (isRevBomReleased(bean1.selectRev)) { + // ʹԭbom + System.out.println("ԭ"); + if (isLoopBom(childNode)) { + MessageBox.post("ѭBOMṹ", "", MessageBox.WARNING); + return; + } + } else { + createMaterialBom(childNode, colorMaterialBean); + } + } + } + + for (TCComponentItemRevision material : childrenList) { + if (material.getClassificationObjects().length > 0) { + String ys = null; + TCComponentICO ico = material.getClassificationObjects()[0]; + ICSProperty[] props = ico.getICSProperties(true); + for (ICSProperty prop : props) { + if (prop.getId() == 1007) { + ys = prop.getValue(); + break; + } + } + if (ys != null && !"".equals(ys)) { + System.out.println("ɫ" + material.getProperty("object_string")); + colorMaterialBean.colorMaterial.add(new String[] { material.getProperty("item_id"), + material.getProperty("item_revision_id"), material.getProperty("object_name"), ys }); + } + } + } + colorMaterialBean.data.put(materialRev, new Object[] { materialRev, childrenList, null, quantityList }); + } + + private TreePath findInPath(TreePath treePath, String str) { + Object object = treePath.getLastPathComponent(); + if (object == null) { + return null; + } + + String value = object.toString(); + if (str.equals(value)) { + return treePath; + } else { + TreeModel model = tree.getModel(); + int n = model.getChildCount(object); + for (int i = 0; i < n; i++) { + Object child = model.getChild(object, i); + TreePath path = treePath.pathByAddingChild(child); + path = findInPath(path, str); + if (path != null) { + return path; + } + } + return null; + } + } + + private void findInTree(String str) { + Object root = tree.getModel().getRoot(); + TreePath treePath = new TreePath(root); + treePath = findInPath(treePath, str); + if (treePath != null) { + tree.setSelectionPath(treePath); + CheckBoxTreeNode node = (CheckBoxTreeNode) tree.getLastSelectedPathComponent(); + tree.scrollPathToVisible(treePath); + } + } + + /** + * @param line + * @param childNode + * @return ع + */ + public String[] getBomRef(TCComponentBOMLine line, CheckBoxTreeNode childNode) { + try { + if (line == null) { + return null; + } + AIFComponentContext[] aifContext = line.getItemRevision().whereReferencedByTypeRelation(types, + new String[] { "TC_Is_Represented_By" }); + if (aifContext == null || aifContext.length == 0) { + return new String[] { "" }; + } else { + AIFComponentContext[] newContext = isNewRev(aifContext); + String[] wl = new String[newContext.length]; + TransformBomBean bean = (TransformBomBean) childNode.getUserObject(); + for (int i = 0; i < wl.length; i++) { + TCComponentItemRevision comp = (TCComponentItemRevision) newContext[i].getComponent(); + wl[i] = comp.getProperty("object_string"); + bean.map.put(wl[i], comp); + } + + return wl; + } + } catch (TCException e) { + e.printStackTrace(); + } + return new String[] { "" }; + } + + /** + * ѡ + * + * @param childLine + * @param childNode + */ + private void setCombox(TCComponentBOMLine childLine, final CheckBoxTreeNode childNode) { + try { + System.out.println(childLine.getItemRevision().getType() + "<<<<<<<<<<"); + final String[] bomRef = getBomRef(childLine, childNode); + final DefaultComboBoxModel model = new DefaultComboBoxModel(); + model.addElement(""); + for (String str : bomRef) { + model.addElement(str); + } + + final JComboBox childbox = new JComboBox(); + + // ģť + final JButton search = new JButton(""); + checkBoxTreeNodelMap.put(childNode, childbox); + boxJButtonMap.put(childbox, search); + childbox.setModel(model); + childbox.setSelectedIndex(-1); + childbox.setEditable(true); + + if (childbox.getItemCount() <= 2 && childbox.getItemAt(1) != null && !childbox.getItemAt(1).equals("")) { + childbox.setSelectedIndex(1); + childbox.setEditable(false); + childNode.setSelected(true); + search.setEnabled(false); + childbox.enable(false); + TransformBomBean bean = (TransformBomBean) childNode.getUserObject(); + bean.selectRev = bean.map.get(childbox.getSelectedItem().toString()); + } else if (childbox.getItemCount() <= 2) { + childbox.setEditable(false); + search.setEnabled(false); + childbox.enable(false); + } + if (childLine.getItemRevision().getType().equals("PartRevision")) { + childbox.setEditable(false); + search.setEnabled(false); + childNode.setSelected(true); + childbox.enable(false); + TransformBomBean bean = (TransformBomBean) childNode.getUserObject(); + bean.selectRev = childLine.getItemRevision(); + } + childbox.setPreferredSize(new Dimension(240, 23)); + search.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + if (childbox.isEditable() && search.isEnabled()) { + String str = childbox.getEditor().getItem().toString(); + model.removeAllElements(); + model.addElement(""); + for (int i = 0; i < bomRef.length; i++) { + if (bomRef[i].contains(str)) { + model.addElement(bomRef[i]); + } + } + childbox.setModel(model); + childbox.setPopupVisible(true); + } + } + }); + + childbox.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + try { + if (e.getStateChange() == 1) { + if (childbox.getSelectedIndex() > 0) { + TransformBomBean bean = (TransformBomBean) childNode.getUserObject(); + bean.selectRev = bean.map.get(childbox.getSelectedItem().toString()); + childNode.setSelected(true); + System.out.println("-----------" + bean.displayName); + // жǷ ȫѡ + boolean released = isReleased(bean.selectRev, childNode); + System.out.println("<<<<<<<<<<Ƿ񷢲:" + released); + tree.repaint(); + } else { + System.out.println("<<<<<<<<<<ѡ:"); + restoreSelect(childNode); + childNode.setSelected(false); + tree.repaint(); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + comboxList.add(childbox); + rightJPanel.add((index) + ".1.left.top", childbox); + rightJPanel.add((index++) + ".2.left.top", search); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * жǷ񷢲 + * + * @param rev + * @param childNode + * @return + */ + private boolean isReleased(TCComponentItemRevision rev, CheckBoxTreeNode childNode) { + + try { + System.out.println("ִж" + rev.getProperty("object_name")); + if (rev != null && isRevBomReleased(rev)) { + setUnable(childNode); + return true; + } else { + restoreSelect(childNode); + return false; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + + private void setUnable(CheckBoxTreeNode childNode) { + int childCount = childNode.getChildCount(); + for (int i = 0; i < childCount; i++) { + CheckBoxTreeNode node = (CheckBoxTreeNode) childNode.getChildAt(i); + JComboBox box = checkBoxTreeNodelMap.get(node); + box.setSelectedIndex(-1); + box.setEditable(false); + box.setEnabled(false); + node.setSelected(false); + boxJButtonMap.get(box).setEnabled(false); + setUnable(node); + } + } + + /** + * ԭ + * + * @param childNode + * @throws TCException + */ + private void restoreSelect(CheckBoxTreeNode childNode) throws TCException { + int childCount = childNode.getChildCount(); + for (int i = 0; i < childCount; i++) { + CheckBoxTreeNode node = (CheckBoxTreeNode) childNode.getChildAt(i); + JComboBox childbox = checkBoxTreeNodelMap.get(node); + TransformBomBean bean = (TransformBomBean) node.getUserObject(); + childbox.setEditable(true); + childbox.setEnabled(true); + childbox.setSelectedIndex(-1); + if (childbox.getItemCount() <= 2 && !childbox.getItemAt(1).equals("")) { + childbox.setSelectedIndex(1); + childbox.setEditable(false); + childbox.setEnabled(false); + node.setSelected(true); + boxJButtonMap.get(childbox).setEnabled(false); + bean.selectRev = bean.map.get(childbox.getSelectedItem().toString()); + } else if (childbox.getItemCount() <= 2) { + childbox.setEditable(false); + childbox.setEnabled(false); + boxJButtonMap.get(childbox).setEnabled(false); + } + if (bean.line.getItemRevision().isTypeOf("PartRevision")) { + childbox.setEditable(false); + boxJButtonMap.get(childbox).setEnabled(false); + node.setSelected(true); + childbox.setEnabled(false); + bean.selectRev = bean.line.getItemRevision(); + } + restoreSelect(node); + } + + } + + /** + * жǷΪ°汾 ޳ɰ汾 + * + * @param aifContext + * @return + */ + private AIFComponentContext[] isNewRev(AIFComponentContext[] aifContext) { + try { + List list = new ArrayList(); + for (int i = 0; i < aifContext.length; i++) { + TCComponentItemRevision rev = (TCComponentItemRevision) aifContext[i].getComponent(); + if (rev.getItem().getLatestItemRevision().equals(rev)) { + list.add(aifContext[i]); + } + } + AIFComponentContext[] newContext = new AIFComponentContext[list.size()]; + for (int i = 0; i < list.size(); i++) { + newContext[i] = list.get(i); + } + return newContext; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * жѭ + * + * @param node + * @return + */ + private boolean isLoopBom(CheckBoxTreeNode node) { + try { + HashSet loopSet = new HashSet(); + boolean checkLoop = checkLoop(node, loopSet); + return checkLoop; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + + /** + * Ҹ,жǷͬ + * + * @param node + * @param loopSet + * @return + * @throws TCException + */ + private boolean checkLoop(CheckBoxTreeNode node, HashSet loopSet) throws TCException { + TransformBomBean bean = (TransformBomBean) node.getUserObject(); + TCComponentItemRevision materialRev = bean.selectRev; + boolean add = loopSet.add(materialRev); + if (!add) { + return true; + } else { + CheckBoxTreeNode parent = (CheckBoxTreeNode) node.getParent(); + if (parent == null) { + return false; + } else { + return checkLoop(parent, loopSet); + } + } + } + + public void getAllBomItemByBomline(TCComponentBOMLine line, List itemList) throws TCException { + if (line == null) { + return; + } + itemList.add(line.getItem()); + AIFComponentContext[] contextS = line.getChildren(); + for (AIFComponentContext context : contextS) { + TCComponentBOMLine child = (TCComponentBOMLine) context.getComponent(); + getAllBomItemByBomline(child, itemList); + } + } + + /** + * bom + * + * @param selectIndex + * @throws Exception + */ + public void createBom(TCComponentItemRevision parentRev, List childRevList, + List queryNoList, List countNoList) throws Exception { + if (childRevList == null || childRevList.size() == 0) { + return; + } + if (parentRev == null) { + return; + } + String[] setProps = { "bl_quantity" }; + TCComponentBOMLine line = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + AIFComponentContext[] childrenContext = line.getChildren(); + + win.lock(); + // Ƴеbomline + if (childrenContext.length != 0) { + for (AIFComponentContext child : childrenContext) { + line.lock(); + line.remove("", (TCComponent) child.getComponent()); + line.save(); + line.unlock(); + } + // return; + } + for (int i = 0; i < childRevList.size(); i++) { + TCComponentItemRevision rev = childRevList.get(i); + line.lock(); + TCComponentBOMLine childBomLine = line.add(rev.getItem(), rev, null, false, ""); + line.save(); + line.unlock(); + if (countNoList.get(i) != null && !countNoList.get(i).equals("")) { + childBomLine.lock(); + childBomLine.setProperties(setProps, new String[] { countNoList.get(i) }); + childBomLine.save(); + childBomLine.unlock(); + } + + } + try { + win.save(); + win.unlock(); + } catch (Exception e) { + win.unlock(); + win.close(); + win = null; + System.out.println("windows close"); + TCComponent[] comps = parentRev.getTCProperty("structure_revisions").getReferenceValueArray(); + if (comps.length > 0) { + parentRev.remove("structure_revisions", comps[0]); + comps[0].delete(); + ; + } + e.printStackTrace(); + throw e; + } + + } + + /** + * ǷѾ + * + * @param comp + * @return + * @throws TCException + */ + public boolean isCompReleased(TCComponent comp) throws TCException { + TCComponent[] comps = comp.getRelatedComponents("release_status_list"); + if (comps != null && comps.length > 0) { + return true; + } + return false; + } + + /** + * ǷBOM + * + * @param rev + * @return + */ + public boolean isRevHadBom(TCComponentItemRevision rev) { + boolean isHad = false; + if (rev != null) { + try { + TCComponentBOMLine topLine = win.setWindowTopLine(rev.getItem(), rev, null, null); + if (topLine != null) { + if (topLine.getChildren().length > 0) { + isHad = true; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + return isHad; + } + + /** + * жѾĶǷBOM + * + * @param rev + * @return + */ + public boolean isRevBomReleased(TCComponentItemRevision rev) { + boolean isReleased = false; + try { + if (isCompReleased(rev)) { + win.setWindowTopLine(rev.getItem(), rev, null, null); + // TCComponentBOMLine line = window.getTopBOMLine(); + // if(line.getChildren().length!=0){ + // isReleased = true; + // } + if (isRevHadBom(rev)) { + TCComponentBOMViewRevision bvr = win.askBvr(); + if (bvr != null) { + TCComponent[] status = bvr.getReferenceListProperty("release_status_list"); + if (status != null && status.length != 0) { + isReleased = true; + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + isReleased = true; + } + return isReleased; + + } + + private boolean isYSMaterial(TCComponentItemRevision rev) { + try { + Map map = rev.getClassificationAttributes(); + if (map.get("ɫ") != null && !"".equals(map.get("ɫ"))) { + return true; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + +} diff --git a/src/com/connor/jd/plm/handlers/BOMManagementHandler.java b/src/com/connor/jd/plm/handlers/BOMManagementHandler.java new file mode 100644 index 0000000..57e6d71 --- /dev/null +++ b/src/com/connor/jd/plm/handlers/BOMManagementHandler.java @@ -0,0 +1,22 @@ +package com.connor.jd.plm.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.jd.plm.action.BOMManagementAction; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class BOMManagementHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + BOMManagementAction action = new BOMManagementAction(AIFUtility.getActiveDesktop(), "",app); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/jd/plm/table/ButtonEditor.java b/src/com/connor/jd/plm/table/ButtonEditor.java new file mode 100644 index 0000000..c1b33cd --- /dev/null +++ b/src/com/connor/jd/plm/table/ButtonEditor.java @@ -0,0 +1,54 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JOptionPane; +import javax.swing.JTable; + +import com.teamcenter.rac.util.DateButton; + +public class ButtonEditor extends DefaultCellEditor { + protected DateButton button; + private String label; + private boolean isPushed; + + public ButtonEditor(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + + return button; + } + + public Object getCellEditorValue() { + //yyyyMMdd + SimpleDateFormat format=new SimpleDateFormat("yyyyMMdd"); + SimpleDateFormat format2=new SimpleDateFormat("MM"); + SimpleDateFormat format3=new SimpleDateFormat("dd"); + Date data = new Date(); + System.out.println("aaa===>"+format2.format(data)); + System.out.println("bbb===>"+format3.format(data)); + System.out.println("ccc===>"+format.format(data)); + + return format.format(button.getDate()); + } + +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/table/ButtonEditor2.java b/src/com/connor/jd/plm/table/ButtonEditor2.java new file mode 100644 index 0000000..094ec6c --- /dev/null +++ b/src/com/connor/jd/plm/table/ButtonEditor2.java @@ -0,0 +1,48 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JTable; + +import com.teamcenter.rac.util.DateButton; + +public class ButtonEditor2 extends DefaultCellEditor { + + protected DateButton button; + private String label; + private boolean isPushed; + + public ButtonEditor2(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + + return button; + } + + public Object getCellEditorValue() { + //yyyyMMdd HH:mm + SimpleDateFormat format=new SimpleDateFormat("HH:mm"); + Date data = new Date(); + System.out.println("ccc===>"+format.format(data)); + + return format.format(button.getDate()); + } + + +} diff --git a/src/com/connor/jd/plm/table/CTMap.java b/src/com/connor/jd/plm/table/CTMap.java new file mode 100644 index 0000000..b32d7b0 --- /dev/null +++ b/src/com/connor/jd/plm/table/CTMap.java @@ -0,0 +1,207 @@ +package com.connor.jd.plm.table; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Point; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + + @Override + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + @Override + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) { + return true; + } + return false; + } + + + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + + public void insertRow(int row) { + Vector rowData = new Vector(getColumnCount()); + + dataVector.insertElementAt(rowData, row); + System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + + int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + } + } + } + span = newSpan; + rowSize = span.length; + } + + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size()-1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount()-1; i++) { + + ((Vector)dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/src/com/connor/jd/plm/table/CTUI.java b/src/com/connor/jd/plm/table/CTUI.java new file mode 100644 index 0000000..831439d --- /dev/null +++ b/src/com/connor/jd/plm/table/CTUI.java @@ -0,0 +1,94 @@ +package com.connor.jd.plm.table; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c){ + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = table.getColumnModel().getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = table.rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = table.getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, table.getRowHeight() + table.getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) table.getModel(); + int numColumns = table.getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = table.getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = table.getRowMargin(); + int spacingWidth = table.getColumnModel().getColumnMargin(); + + Color c = g.getColor(); + g.setColor(table.getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + spacingHeight / 2, cellRect.width - spacingWidth, + cellRect.height - spacingHeight); + + if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { + Component component = table.getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = table.getCellRenderer(row, column); + Component component = table.prepareRenderer(renderer, row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, + true); + } + } +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/table/CTable.java b/src/com/connor/jd/plm/table/CTable.java new file mode 100644 index 0000000..9e3923b --- /dev/null +++ b/src/com/connor/jd/plm/table/CTable.java @@ -0,0 +1,145 @@ +package com.connor.jd.plm.table; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +public class CTable extends JTable { + Map map; + public CTable(TableModel model) { + super(model); + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + map=new HashMap(); + } + public String getToolTipText(MouseEvent e) { + int row=this.rowAtPoint(e.getPoint()); + int col=this.columnAtPoint(e.getPoint()); + String tiptextString=null; + if(row>-1 && col>-1){ + Object value=this.getValueAt(row, col); + if(null!=value && !"".equals(value)) + tiptextString=value.toString();//ʾԪ + } + return tiptextString; + } + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if ((row < 0) || (column < 0) || (getRowCount() <= row) || (getColumnCount() <= column)) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth() + columnMargin; + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + spacing.height / 2, + cellFrame.width - spacing.width, cellFrame.height - spacing.height); + } + return cellFrame; + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height); + } + public void setCombo(int row,int col,TableCellEditor ce){ + map.put(new Point(row,col), ce); + } + public TableCellEditor getCellEditor(int row, int column){ + Point point = new Point(row,column); + if(map.containsKey(point)){ + return map.get(point); + }else{ + return super.getCellEditor(row, column); + } + } + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/table/CTest.java b/src/com/connor/jd/plm/table/CTest.java new file mode 100644 index 0000000..465f200 --- /dev/null +++ b/src/com/connor/jd/plm/table/CTest.java @@ -0,0 +1,42 @@ +package com.connor.jd.plm.table; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JScrollPane; + +//import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class CTest { + static int[] rows; + static JScrollPane pane; + + public static void main(String args[]) { + final CTMap map = new CTMap(5, 5); + final CTable table = new CTable(map); + table.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + pane = new JScrollPane(table); + JButton button = new JButton("add"); + table.setShowGrid(false); + final JDialog dialog = new JDialog(); + dialog.setLayout(new BorderLayout()); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + table.setRowHeight(2, 50); + table.revalidate(); + table.repaint(); + + } + }); + dialog.add(pane, BorderLayout.CENTER); + dialog.add(button, BorderLayout.SOUTH); + dialog.setPreferredSize(new Dimension(500, 500)); + dialog.show(); + } +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/table/CellSpan.java b/src/com/connor/jd/plm/table/CellSpan.java new file mode 100644 index 0000000..a454f89 --- /dev/null +++ b/src/com/connor/jd/plm/table/CellSpan.java @@ -0,0 +1,14 @@ +package com.connor.jd.plm.table; + +interface CellSpan { + public final int ROW = 0; + public final int COLUMN = 1; + + public int[] getSpan(int row, int column); + public void setSpan(int[] span, int row, int column); + + public boolean isVisible(int row, int column); + + public void combine(int[] rows, int[] columns); + +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/table/DatePickerCellEditor.java b/src/com/connor/jd/plm/table/DatePickerCellEditor.java new file mode 100644 index 0000000..3bbf573 --- /dev/null +++ b/src/com/connor/jd/plm/table/DatePickerCellEditor.java @@ -0,0 +1,34 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JTable; +import javax.swing.JTextField; + +import com.connor.jd.plm.utils.DatePickerUtil; +import com.eltima.components.ui.DatePicker; + +public class DatePickerCellEditor extends DefaultCellEditor { + + private DatePicker datePicker; + + public DatePickerCellEditor(JTextField arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + // TODO Auto-generated method stub + datePicker = DatePickerUtil.getDatePicker(null); + return datePicker; + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + return datePicker.getText(); + } + +} diff --git a/src/com/connor/jd/plm/table/DefaultModel.java b/src/com/connor/jd/plm/table/DefaultModel.java new file mode 100644 index 0000000..d27ef16 --- /dev/null +++ b/src/com/connor/jd/plm/table/DefaultModel.java @@ -0,0 +1,100 @@ +package com.connor.jd.plm.table; + +import java.awt.Dimension; +import java.util.Vector; + +import javax.swing.table.DefaultTableModel; + +public class DefaultModel extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + @Override + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + @Override + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) { + return true; + } + return false; + } + + public DefaultModel(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + +} diff --git a/src/com/connor/jd/plm/table/JCheckPanel.java b/src/com/connor/jd/plm/table/JCheckPanel.java new file mode 100644 index 0000000..b61e4ce --- /dev/null +++ b/src/com/connor/jd/plm/table/JCheckPanel.java @@ -0,0 +1,83 @@ +package com.connor.jd.plm.table; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.ButtonGroup; +import javax.swing.JCheckBox; +import javax.swing.JPanel; + +public class JCheckPanel extends JPanel { + private JCheckBox[] buttons = null; + private ButtonGroup buttonGroup = new ButtonGroup(); + + public JCheckPanel(String[] text) { + super(); + buttons = new JCheckBox[text.length]; + for (int i = 0; i < text.length; i++) { + buttons[i] = new JCheckBox(text[i]); + buttons[i].setPreferredSize(new Dimension(100, 25)); + buttonGroup.add(buttons[i]); + add(buttons[i]); + } + setLayout(new FlowLayout(FlowLayout.LEFT)); + } + + public JCheckPanel(String[] text, boolean isSingle) { + buttons = new JCheckBox[text.length]; + for (int i = 0; i < text.length; i++) { + buttons[i] = new JCheckBox(text[i]); + buttons[i].setPreferredSize(new Dimension(60, 25)); + if (isSingle) { + buttonGroup.add(buttons[i]); + } + add(buttons[i]); + } + setLayout(new FlowLayout(FlowLayout.LEFT)); + } + + public JCheckBox[] getButtons() { + return buttons; + } + + public List getSelected() { + List list = new ArrayList(); + for (JCheckBox check : buttons) { + if (check.isSelected()) { + list.add(check); + } + } + return list; + } + + public String getSelectedText() { + List list = getSelected(); + if (list.size() == 0) { + return null; + } + String str = ""; + for (JCheckBox jcb : list) { + str += jcb.getText(); + str += ","; + } + return str.substring(0, str.length() - 1); + } + + public void setSelected(int index) { + buttons[index].setSelected(true); + } + + public void setSelected(String value) { + String[] arr = value.split(","); + for (int i = 0; i < arr.length; i++) { + for (int ii = 0; ii < buttons.length; ii++) { + if (buttons[ii].getText().equals(arr[i])) { + buttons[ii].setSelected(true); + break; + } + } + } + } +} diff --git a/src/com/connor/jd/plm/table/JRadioPanel.java b/src/com/connor/jd/plm/table/JRadioPanel.java new file mode 100644 index 0000000..440a761 --- /dev/null +++ b/src/com/connor/jd/plm/table/JRadioPanel.java @@ -0,0 +1,47 @@ +package com.connor.jd.plm.table; + +import java.awt.FlowLayout; + +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.JRadioButton; + +public class JRadioPanel extends JPanel { + private JRadioButton[] buttons = null; + private ButtonGroup buttonGroup = new ButtonGroup(); + + public JRadioPanel(String[] text) { + super(); + buttons = new JRadioButton[text.length]; + for (int i = 0; i < text.length; i++) { + buttons[i] = new JRadioButton(text[i]); + buttonGroup.add(buttons[i]); + add(buttons[i]); + } + setLayout(new FlowLayout(FlowLayout.LEFT)); + } + + public JRadioButton[] getButtons() { + return buttons; + } + + public JRadioButton getSelected() { + for (JRadioButton jb : buttons) { + if (jb.isSelected()) { + return jb; + } + } + return null; + } + + public void setSelected(int index) { + buttons[index].setSelected(true); + } + + public void setSelected(String value) { + for (int i = 0; i < buttons.length; i++) { + buttons[i].setSelected(buttons[i].getText().equals(value.trim())); + } + } + +} diff --git a/src/com/connor/jd/plm/table/MessageBox2.java b/src/com/connor/jd/plm/table/MessageBox2.java new file mode 100644 index 0000000..c7dc822 --- /dev/null +++ b/src/com/connor/jd/plm/table/MessageBox2.java @@ -0,0 +1,39 @@ +package com.connor.jd.plm.table; + +import javax.swing.JOptionPane; + +public class MessageBox2 { + + private static String Title = "ʾ"; + public static final int DEFAULT_OPTION = -1; + public static final int YES_NO_OPTION = 10; + public static final int YES_NO_CANCEL_OPTION = 11; + public static final int OK_CANCEL_OPTION = 12; + public static final int YES_OPTION = 0; + public static final int NO_OPTION = 1; + public static final int CANCEL_OPTION = 2; + public static final int OK_OPTION = 0; + public static final int CLOSED_OPTION = -1; + public static final int ERROR_MESSAGE = 0; + public static final int INFORMATION_MESSAGE = 1; + public static final int WARNING_MESSAGE = 2; + public static final int QUESTION_MESSAGE = 3; + public static final int PLAIN_MESSAGE = -1; + + public static int Show(String Msg, int Option) { + switch (Option) { + case YES_NO_OPTION: + case YES_NO_CANCEL_OPTION: + case OK_CANCEL_OPTION: + return JOptionPane.showConfirmDialog(null, Msg, Title, Option - 10); + default: + JOptionPane.showMessageDialog(null, Msg, Title, Option); + } + return 0; + } + + public static int Show(String Msg) { + return Show(Msg, INFORMATION_MESSAGE); + } + +} diff --git a/src/com/connor/jd/plm/table/MyCellEditor.java b/src/com/connor/jd/plm/table/MyCellEditor.java new file mode 100644 index 0000000..e2a6648 --- /dev/null +++ b/src/com/connor/jd/plm/table/MyCellEditor.java @@ -0,0 +1,122 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextField; + +import com.teamcenter.rac.util.MessageBox; + +public class MyCellEditor extends DefaultCellEditor { + private JRadioPanel radio = null; + private JCheckPanel check = null; + private JComboBox comboBox = null; + private int type = -1; + private int row; + private int col; + private int top; + private int end; + private int bottom; + private JTable table; + + public MyCellEditor(JTextField var1) { + super(var1); + // TODO Auto-generated constructor stub + } + + public MyCellEditor(JTextField var1, int top, int end, int bottom) { + super(var1); + // TODO Auto-generated constructor stub + this.top = top; + this.end = end; + this.bottom = bottom; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof JRadioPanel) { + radio = (JRadioPanel) value; + type = 1; + return radio; + } else if (value instanceof JCheckPanel) { + check = (JCheckPanel) value; + type = 2; + return check; + } else if (value instanceof JComboBox) { + comboBox = (JComboBox) value; + type = 3; + return comboBox; + } + this.row = row; + this.col = column; + this.bottom = table.getRowCount() - end; + this.table = table; + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + if (type == 1) { + return radio; + } + if (type == 2) { + return check; + } + if (type == 3) { + return comboBox; + } + + Object obj = super.getCellEditorValue(); + if (obj != null && !"".equals(obj.toString().trim()) && row >= top && row <= bottom && col >= 7 + && col < table.getColumnCount() - 3) { + try { + Double.parseDouble(obj.toString().trim()); + } catch (Exception e) { + MessageBox.post("ֻ", "", MessageBox.ERROR); + return null; + } + } + return obj; + } + + @Override + public boolean stopCellEditing() { + // TODO Auto-generated method stub + if (row >= top && row <= bottom && col >= 7 && col < table.getColumnCount() - 3) { + double min = Double.MAX_VALUE; + double max = Double.MIN_VALUE; + Object obj; + for (int i = 7; i < col; i++) { + obj = table.getValueAt(row, i); + if (obj != null && !"".equals(obj.toString().trim())) { + min = Math.min(min, Double.parseDouble(obj.toString().trim())); + max = Math.max(max, Double.parseDouble(obj.toString().trim())); + } + } + obj = getCellEditorValue(); + if (obj != null && !"".equals(obj.toString().trim())) { + min = Math.min(min, Double.parseDouble(obj.toString().trim())); + max = Math.max(max, Double.parseDouble(obj.toString().trim())); + } + for (int i = col + 1; i < table.getColumnCount() - 3; i++) { + obj = table.getValueAt(row, i); + if (obj != null && !"".equals(obj.toString().trim())) { + min = Math.min(min, Double.parseDouble(obj.toString().trim())); + max = Math.max(max, Double.parseDouble(obj.toString().trim())); + } + } + if (max > Double.MIN_VALUE) { + table.setValueAt(String.format("%.2f", min), row, table.getColumnCount() - 3); + table.setValueAt(String.format("%.2f", max), row, table.getColumnCount() - 2); + } else { + table.setValueAt("", row, table.getColumnCount() - 3); + table.setValueAt("", row, table.getColumnCount() - 2); + } + } + return super.stopCellEditing(); + } + +} diff --git a/src/com/connor/jd/plm/table/MyCellEditor1.java b/src/com/connor/jd/plm/table/MyCellEditor1.java new file mode 100644 index 0000000..6abc0f1 --- /dev/null +++ b/src/com/connor/jd/plm/table/MyCellEditor1.java @@ -0,0 +1,300 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.DefaultCellEditor; +import javax.swing.JTable; +import javax.swing.JTextField; + +import com.teamcenter.rac.util.MessageBox; + +public class MyCellEditor1 extends DefaultCellEditor { + private int col; + private int row; + private JTable table; + private int top; + private int end; + private int bottom; + private List data; + private double low = 0.0; + private double up = 0.0; + private int cnt = 0; + private int lowCnt = 0; + private int upCnt = 0; + + public MyCellEditor1(JTextField paramJTextField) { + super(paramJTextField); + // TODO Auto-generated constructor stub + } + + public MyCellEditor1(JTextField paramJTextField, int top, int end, int bottom) { + super(paramJTextField); + // TODO Auto-generated constructor stub + this.top = top; + this.end = end; + this.bottom = bottom; + } + + public double getLow() { + return low; + } + + public void setLow(double low) { + this.low = low; + } + + public double getUp() { + return up; + } + + public void setUp(double up) { + this.up = up; + } + + public int getCnt() { + return cnt; + } + + public void setCnt(int cnt) { + this.cnt = cnt; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + this.col = column; + this.row = row; + this.table = table; + bottom = table.getRowCount() - end; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + Object obj = super.getCellEditorValue(); + if (obj != null && !"".equals(obj.toString().trim()) && row >= top - 3 && row <= bottom) { + try { + Double.parseDouble(obj.toString().trim()); + } catch (Exception e) { + MessageBox.post("ֻ", "", MessageBox.ERROR); + return null; + } + } + return obj; + } + + @Override + public boolean stopCellEditing() { + // TODO Auto-generated method stub + System.out.println("top:" + top + ",end:" + end + ",bottom:" + bottom + " ¼У" + col); + data = new ArrayList(); + Object now = getCellEditorValue(); + Object obj = null; + + if (row == 2) { + if (now != null && !"".equals(now.toString().trim())) { + low = Double.parseDouble(now.toString().trim()); + lowCnt = 1; + } else { + low = 0.0; + lowCnt = 0; + } + } + if (row == 3) { + if (now != null && !"".equals(now.toString().trim())) { + up = Double.parseDouble(now.toString().trim()); + upCnt = 1; + } else { + up = 0.0; + upCnt = 0; + } + } + cnt = lowCnt + upCnt; + System.out.println("lowCnt===>" + lowCnt); + System.out.println("upCnt====>" + upCnt); + for (int i = top; i < row && i <= bottom; i++) { + obj = table.getModel().getValueAt(i, col); + if (obj != null && !"".equals(obj.toString().trim())) { + data.add(Double.parseDouble(obj.toString().trim())); + } + } + if (row >= top && row <= bottom && now != null && !"".equals(now.toString().trim())) { + data.add(Double.parseDouble(now.toString().trim())); + } + if (row + 1 >= top) { + for (int i = row + 1; i <= bottom; i++) { + obj = table.getModel().getValueAt(i, col); + if (obj != null && !"".equals(obj.toString().trim())) { + data.add(Double.parseDouble(obj.toString().trim())); + } + } + } else { + for (int i = top; i <= bottom; i++) { + obj = table.getModel().getValueAt(i, col); + if (obj != null && !"".equals(obj.toString().trim())) { + data.add(Double.parseDouble(obj.toString().trim())); + } + } + } + + System.out.println(Arrays.toString(data.toArray())); + + double sum = 0; + double max = Double.MIN_VALUE; + double min = Double.MAX_VALUE; + for (Double d : data) { + sum += d; + max = Math.max(max, d); + min = Math.min(min, d); + } + if (sum != 0) { + double r = max - min; + double avg = sum / data.size(); + table.getModel().setValueAt(String.format("%.2f", min), bottom + 1, col); + table.getModel().setValueAt(String.format("%.2f", max), bottom + 2, col); + table.getModel().setValueAt(String.format("%.2f", r), bottom + 3, col); + table.getModel().setValueAt(String.format("%.2f", avg), bottom + 5, col); + if (data.size() - 1 > 0) { + double stdevSum = 0; + for (Double d : data) { + stdevSum += Math.pow(d - avg, 2); + } + double stdev = Math.sqrt(stdevSum / (data.size() - 1)); + double bar1 = avg - 3 * stdev; + double bar2 = avg + 3 * stdev; + table.getModel().setValueAt(String.format("%.2f", stdev), bottom + 4, col); + table.getModel().setValueAt(String.format("%.2f", bar1), bottom + 6, col); + table.getModel().setValueAt(String.format("%.2f", bar2), bottom + 7, col); + + double cp = 0.0; + if (cnt == 0) { + table.getModel().setValueAt("", bottom + 8, col); + } else if (cnt == 2) { + cp = (up - low) / (6 * stdev); + table.getModel().setValueAt(String.format("%.2f", cp), bottom + 8, col); + } else if (doubleIsEqual(up, 0.0)) { + cp = (avg - low) / (3 * stdev); + table.getModel().setValueAt(String.format("%.2f", cp), bottom + 8, col); + } else { + cp = (up - avg) / (3 * stdev); + table.getModel().setValueAt(String.format("%.2f", cp), bottom + 8, col); + } + double cpu = 0.0; + if (doubleIsEqual(up, 0.0)) { + table.getModel().setValueAt("", bottom + 9, col); + } else { + cpu = (up - avg) / (3 * stdev); + table.getModel().setValueAt(String.format("%.2f", cpu), bottom + 9, col); + } + double cpl = 0.0; + if (doubleIsEqual(low, 0.0)) { + table.getModel().setValueAt("", bottom + 10, col); + } else { + cpl = (avg - low) / (3 * stdev); + table.getModel().setValueAt(String.format("%.2f", cpl), bottom + 10, col); + } + double cpk = 0.0; + if (cnt == 2) { + cpk = (1 - 2 * Math.abs(((low + up) / 2 - avg)) / (up - low)) * cp; + table.getModel().setValueAt(String.format("%.2f", cpk), bottom + 11, col); + } else { + cpk = cp; + table.getModel().setValueAt(doubleIsEqual(cpk, 0.0) ? "" : String.format("%.2f", cpk), bottom + 11, + col); + } + double su = 0.0; + if (doubleIsEqual(cpu, 0.0)) { + table.getModel().setValueAt("", bottom + 12, col); + } else { + su = (1 - normSDist(cpu * 3)) * 1000000; + table.getModel().setValueAt(String.format("%.2f", su), bottom + 12, col); + } + double sl = 0.0; + if (doubleIsEqual(cpl, 0.0)) { + table.getModel().setValueAt("", bottom + 13, col); + } else { + sl = (1 - normSDist(cpl * 3)) * 1000000; + table.getModel().setValueAt(String.format("%.2f", sl), bottom + 13, col); + } + if (cnt == 0) { + table.getModel().setValueAt("", bottom + 14, col); + } else { + table.getModel().setValueAt(String.format("%.2f", su + sl), bottom + 14, col); + } + if (cnt == 0) { + table.getModel().setValueAt("", bottom + 15, col); + } else if (cpk > 1.99) { + table.getModel().setValueAt("dz", bottom + 15, col); + } else if (cpk > 1.66) { + table.getModel().setValueAt("ܺ", bottom + 15, col); + } else if (cpk > 1.32) { + table.getModel().setValueAt("", bottom + 15, col); + } else if (cpk > 0.99) { + table.getModel().setValueAt("", bottom + 15, col); + } else { + table.getModel().setValueAt("", bottom + 15, col); + } + System.out.println("cp:" + cp + ",cpu:" + cpu + ",cpl:" + cpl + ",cpk:" + cpk + ",su:" + su + ",sl:" + + sl + ",ppm:" + (su + sl)); + } else { + table.getModel().setValueAt("", bottom + 4, col); + table.getModel().setValueAt("", bottom + 6, col); + table.getModel().setValueAt("", bottom + 7, col); + table.getModel().setValueAt("", bottom + 8, col); + table.getModel().setValueAt("", bottom + 9, col); + table.getModel().setValueAt("", bottom + 10, col); + table.getModel().setValueAt("", bottom + 11, col); + table.getModel().setValueAt("", bottom + 12, col); + table.getModel().setValueAt("", bottom + 13, col); + table.getModel().setValueAt("", bottom + 14, col); + table.getModel().setValueAt("", bottom + 15, col); + } + } else { + table.getModel().setValueAt("", bottom + 1, col); + table.getModel().setValueAt("", bottom + 2, col); + table.getModel().setValueAt("", bottom + 3, col); + table.getModel().setValueAt("", bottom + 5, col); + table.getModel().setValueAt("", bottom + 4, col); + table.getModel().setValueAt("", bottom + 6, col); + table.getModel().setValueAt("", bottom + 7, col); + table.getModel().setValueAt("", bottom + 8, col); + table.getModel().setValueAt("", bottom + 9, col); + table.getModel().setValueAt("", bottom + 10, col); + table.getModel().setValueAt("", bottom + 11, col); + table.getModel().setValueAt("", bottom + 12, col); + table.getModel().setValueAt("", bottom + 13, col); + table.getModel().setValueAt("", bottom + 14, col); + table.getModel().setValueAt("", bottom + 15, col); + } + return super.stopCellEditing(); + } + + private boolean doubleIsEqual(double a, double b) { + return Math.abs(a - b) < 0.000001; + } + + private double normSDist(double z) { + // this guards against overflow + if (z > 6) + return 1; + if (z < -6) + return 0; + + double gamma = 0.231641900, a1 = 0.319381530, a2 = -0.356563782, a3 = 1.781477973, a4 = -1.821255978, + a5 = 1.330274429; + + double x = Math.abs(z); + double t = 1 / (1 + gamma * x); + + double n = 1 - (1 / (Math.sqrt(2 * Math.PI)) * Math.exp(-z * z / 2)) + * (a1 * t + a2 * Math.pow(t, 2) + a3 * Math.pow(t, 3) + a4 * Math.pow(t, 4) + a5 * Math.pow(t, 5)); + if (z < 0) + return 1.0 - n; + + return n; + } + +} diff --git a/src/com/connor/jd/plm/table/MyCellEditor2.java b/src/com/connor/jd/plm/table/MyCellEditor2.java new file mode 100644 index 0000000..ccdef61 --- /dev/null +++ b/src/com/connor/jd/plm/table/MyCellEditor2.java @@ -0,0 +1,48 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor2 extends DefaultCellEditor { + private JLabel img = null; + private JComboBox jued = null; + private int type = -1; + + public MyCellEditor2(JTextField var1) { + super(var1); + // TODO Auto-generated constructor stub + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof JLabel) { + img = (JLabel) value; + type = 1; + return img; + } + if (value instanceof JComboBox) { + jued = (JComboBox) value; + type = 2; + return jued; + } + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + if (type == 1) { + return img; + } + if (type == 2) { + return jued; + } + return super.getCellEditorValue(); + } + +} diff --git a/src/com/connor/jd/plm/table/MyCellEditor3.java b/src/com/connor/jd/plm/table/MyCellEditor3.java new file mode 100644 index 0000000..f5b2295 --- /dev/null +++ b/src/com/connor/jd/plm/table/MyCellEditor3.java @@ -0,0 +1,39 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor3 extends DefaultCellEditor { + private JCheckPanel check = null; + private int type = -1; + + public MyCellEditor3(JTextField arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + // TODO Auto-generated method stub + if (value instanceof JCheckPanel) { + check = (JCheckPanel) value; + type = 1; + return check; + } + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + if (type == 1) { + return check; + } + return super.getCellEditorValue(); + } + +} diff --git a/src/com/connor/jd/plm/table/MyCellEditor4.java b/src/com/connor/jd/plm/table/MyCellEditor4.java new file mode 100644 index 0000000..6cd3bb4 --- /dev/null +++ b/src/com/connor/jd/plm/table/MyCellEditor4.java @@ -0,0 +1,38 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor4 extends DefaultCellEditor { + private int type = -1; + private JCheckBox check; + + public MyCellEditor4(JTextField arg0) { + super(arg0); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof JCheckBox) { + System.out.println("123456789abcdefg"); + check = (JCheckBox) value; + type = 1; + return check; + } + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + if (type == 1) { + return check; + } + return super.getCellEditorValue(); + } + +} diff --git a/src/com/connor/jd/plm/table/MyCellRenderer.java b/src/com/connor/jd/plm/table/MyCellRenderer.java new file mode 100644 index 0000000..ed11b04 --- /dev/null +++ b/src/com/connor/jd/plm/table/MyCellRenderer.java @@ -0,0 +1,19 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; + +public class MyCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + // TODO Auto-generated method stub + if (value instanceof JCheckBox) { + return (JCheckBox) value; + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } +} diff --git a/src/com/connor/jd/plm/table/MyComboBoxRenderer.java b/src/com/connor/jd/plm/table/MyComboBoxRenderer.java new file mode 100644 index 0000000..d66441a --- /dev/null +++ b/src/com/connor/jd/plm/table/MyComboBoxRenderer.java @@ -0,0 +1,24 @@ +package com.connor.jd.plm.table; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import javax.swing.SwingConstants; + +public class MyComboBoxRenderer extends JLabel implements ListCellRenderer { + public MyComboBoxRenderer() { + setOpaque(true); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + setBackground(isSelected ? new Color(0xff0078D7) : Color.WHITE); + setHorizontalAlignment(SwingConstants.CENTER); + setText(value.toString()); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/table/TableCellTextAreaRenderer.java b/src/com/connor/jd/plm/table/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..e91e9a5 --- /dev/null +++ b/src/com/connor/jd/plm/table/TableCellTextAreaRenderer.java @@ -0,0 +1,72 @@ +package com.connor.jd.plm.table; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.BorderFactory; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.table.TableCellRenderer; + +public class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + public TableCellTextAreaRenderer() { + setLineWrap(true); + setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + setBackground(Color.white); + setForeground(Color.black); + if(isSelected){ + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // Ϲæ + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + +// @Override +// public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, +// int row, int column) { +// // TODO Auto-generated method stub +// int maxPreferredHeight = 0; +// for (int i = 0; i < table.getColumnCount(); i++) { +// setText("" + table.getValueAt(row, i)); +// setSize(table.getColumnModel().getColumn(column).getWidth(), 0); +// maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); +// } +// setBorder(BorderFactory.createLineBorder(Color.white)); +// setBackground(Color.white); +// setForeground(Color.black); +// if(isSelected){ +// setBackground(new Color(0, 120, 215)); +// setForeground(Color.white); +// } +// String val=(String) table.getValueAt(row, column); +// int w=0; +// if(val!=null){ +// w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); +// } +// if(w!=0){ +// //System.out.println("height:"+table.getRowHeight()*(w+1)); +// table.setRowHeight(row,table.getRowHeight()*(w+1)); +// } +// +// +// setText(value == null ? "" : value.toString()); +// return this; +// } +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/table/TempTest.java b/src/com/connor/jd/plm/table/TempTest.java new file mode 100644 index 0000000..82c971c --- /dev/null +++ b/src/com/connor/jd/plm/table/TempTest.java @@ -0,0 +1,57 @@ +package com.connor.jd.plm.table; + +import java.awt.BorderLayout; + +import javax.swing.JButton; +import javax.swing.JDialog; + +public class TempTest { + public static void main(String[] args) { + String temp="";; + String[] name=new String[]{"DZʧЧģʽͺ","СԹͼ","ʼƷ嵥","Ƽƻ","СԲƷ֤","ԭϿ","Ϣ","Ӧ̻ϵ","ԭϽϼ","Ӧ̳۱","ԭת׶","Ŀ˼·ܽ","䷽","С","Լⵥ","ɿĿ֤","Сɫ¼","С鹤ռ¼","ݱ","ɿ֤","ʵܽᱨ","С鹤յ","С鰲żƻ","Ʒоܱ","뵥","ԲƷ֤","עܹռ¼","ϼⱨ","Ŀ¼","ǰԤжƻ","ͻϹռ¼","ͻܽ","СԽ׶"}; + String t=""; + String te=""; + String[] name2=new String[]{"ԭ嵥","Ʒ嵥","BOM","ԲƷ֤","","ͼ","嵥","PFMEA","ʼоƻ","ȷϼƻ","ƽƻ","տ","²Ʒ","̼¼ܽ","Ŀ","Թ֤","ʼо","ƽ","","ܽᱨ","ɿ֤","֤","ⱨ","Ŀ¼","ǰԤжƻ","ͻϹռ¼","ͻܽ","Խ׶"}; + String[] name3=new String[]{"ԿƼƻ","տ","PSW","̼¼ܽ","Ŀ","PFMEA","ͼ","ԹŻƻ","ԹŻܽ","ͻʹȶԷ","ԭȶԷ","ƷȶԷ","ȶԷ","Խ׶"}; + for(int i=0;i settingMap = new HashMap(); + for (String s : dbSettings) { + settingMap.put(s.substring(0, s.indexOf(":")), s.substring(s.indexOf(":") + 1, s.length())); + } + System.out.println(settingMap.get("url") + settingMap.get("user") + settingMap.get("pass")); + c = DriverManager.getConnection(settingMap.get("url"), settingMap.get("user"), settingMap.get("pass")); + } +// c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:TC", name, pass); + // ݵķ, 򵥵,һҳ TCݿʵƣصļtest.sqlпִ鿴 + // "jdbc:oracle:thin:@:˿:ϵͳʵ", username, password, + // ,ҪԼ֪ڼԲ֪. + // ˿һĬ1521, ҪǸı˾ͿԼļļlistener.ora + // ϵͳʵһĬorcl, ҪDzǵĻ select name from v$database; + // username,password,ǵ½ݿû. + + } catch (SQLException e) { + e.printStackTrace(); + } catch (Exception e1) { + e1.printStackTrace(); + } + return c; + } +} diff --git a/src/com/connor/jd/plm/utils/DBUtil.java b/src/com/connor/jd/plm/utils/DBUtil.java new file mode 100644 index 0000000..949185b --- /dev/null +++ b/src/com/connor/jd/plm/utils/DBUtil.java @@ -0,0 +1,120 @@ +package com.connor.jd.plm.utils; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +import javax.sql.DataSource; +import javax.swing.JOptionPane; + +import com.teamcenter.rac.kernel.TCSession; + +public class DBUtil { + + public static DataSource getDataSource(TCSession session) { + Map settingMap = getDbSetting(session); + BasicDataSource dataSource = new BasicDataSource(); + dataSource.setUrl(settingMap.get("url")); + dataSource.setUsername(settingMap.get("user")); + dataSource.setPassword(settingMap.get("pass")); + return dataSource; + } + + private static Map getDbSetting(TCSession session) { + Map settingMap = null; + String[] dbSettings = JDMethodUtil.getPrefStrArray("px_db_link", session); + if (dbSettings.length != 3) { + JOptionPane.showMessageDialog(null, "px_db_linkݿô", "", JOptionPane.ERROR); + } else { + settingMap = new HashMap(); + for (String s : dbSettings) { + settingMap.put(s.substring(0, s.indexOf(":")), s.substring(s.indexOf(":") + 1, s.length())); + } + } + return settingMap; + } + +} + +//ʾDataSourceӿʵ֣ʾ⣬ʵĿвֱôʹ +class BasicDataSource implements javax.sql.DataSource { + private String url; + private String user; + private String password; + + public void setUrl(String url) { + this.url = url; + } + + public void setUsername(String user) { + this.user = user; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public Connection getConnection() throws SQLException { + try { + Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return DriverManager.getConnection(url, user, password); + } + + @Override + public PrintWriter getLogWriter() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public void setLoginTimeout(int seconds) throws SQLException { + // TODO Auto-generated method stub + + } + + @Override + public int getLoginTimeout() throws SQLException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } + + @Override + public T unwrap(Class iface) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + @Override + public Connection getConnection(String username, String password) throws SQLException { + // TODO Auto-generated method stub + return DriverManager.getConnection(url, user, password); + } +} diff --git a/src/com/connor/jd/plm/utils/DatePickerUtil.java b/src/com/connor/jd/plm/utils/DatePickerUtil.java new file mode 100644 index 0000000..17ed2a2 --- /dev/null +++ b/src/com/connor/jd/plm/utils/DatePickerUtil.java @@ -0,0 +1,80 @@ +package com.connor.jd.plm.utils; + +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Date; +import java.util.Locale; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +import com.eltima.components.ui.DatePicker; + +public class DatePickerUtil { + public static void main(String[] args) { + + final JFrame f = new JFrame("LoL"); + f.setSize(400, 300); + f.setLocation(200, 200); + f.setLayout(null); + + final DatePicker datepick; + datepick = getDatePicker("yyyy-MM-dd hh:mm"); + + f.add(datepick); + + JButton b = new JButton("ȡʱ"); + b.setBounds(137, 183, 100, 30); + f.add(b); + + b.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(f, "ȡؼеڣ" + datepick.getText()); + System.out.println(datepick.getValue()); + } + }); + + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + f.setVisible(true); + } + + public static DatePicker getDatePicker(String format) { + final DatePicker datepick; + // ʽ ¼ʱѡUI + String DefaultFormat = "yyyy-MM-dd"; + // ǰʱ + Date date = new Date(); + // + Font font = new Font("Times New Roman", Font.BOLD, 14); + + Dimension dimension = new Dimension(180, 24); + +// int[] hilightDays = { 1, 3, 5, 7 }; + +// int[] disabledDays = { 4, 6, 5, 9 }; + + datepick = new DatePicker(date, format == null ? DefaultFormat : format, font, dimension); + + datepick.setLocation(137, 83); + datepick.setBounds(137, 83, 180, 24); + // һ·Ҫʾ +// datepick.setHightlightdays(hilightDays, Color.red); + // һ·вҪӣʻɫʾ +// datepick.setDisableddays(disabledDays); + // ù + datepick.setLocale(Locale.CHINA); + // ʱɼ + if (format != null) { + datepick.setTimePanleVisible(true); + } else { + datepick.setTimePanleVisible(false); + } + return datepick; + } +} diff --git a/src/com/connor/jd/plm/utils/DialogUtil.java b/src/com/connor/jd/plm/utils/DialogUtil.java new file mode 100644 index 0000000..af40a6d --- /dev/null +++ b/src/com/connor/jd/plm/utils/DialogUtil.java @@ -0,0 +1,315 @@ +package com.connor.jd.plm.utils; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog.ModalityType; +import java.awt.Dimension; +import java.awt.ItemSelectable; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.jd.plm.dialogs.BOMManagementFrame; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class DialogUtil { + + public static TableMsg createTableMsg(String[] header, List msgContent) { + DefaultTableModel msgModel = new DefaultTableModel(header, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + // TODO Auto-generated method stub + return false; + } + }; + JTable msgTable = new JTable(msgModel); + for (int columnIndex = 0; columnIndex < msgTable.getColumnCount(); columnIndex++) { + // msgTable.getColumnModel().getColumn(columnIndex).setMinWidth(100); + msgTable.getColumnModel().getColumn(columnIndex).setPreferredWidth(200); + } + msgTable.setRowHeight(25); + msgTable.setShowGrid(false); + msgTable.setAutoscrolls(true); + msgTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + msgTable.getTableHeader().setReorderingAllowed(false); +// msgTable.getTableHeader().setVisible(false); + + for (String[] row : msgContent) { + msgModel.addRow(row); + } + + msgTable.invalidate(); + msgTable.repaint(); + JScrollPane msgPanel = new JScrollPane(msgTable); + msgPanel.setPreferredSize(new Dimension(header.length * 200, 400)); + msgPanel.setBorder(BorderFactory.createEmptyBorder()); + return new TableMsg(msgPanel, msgTable); + } + + public static JDialog createSearchAndSelectRevDialog(final BOMManagementFrame frame, final JTable paramTable, + final JCheckBox selectAll, final JButton field) { + final JDialog dialog = new JDialog(); + dialog.setTitle("汾"); + dialog.setSize(520, 400); + dialog.setResizable(true); + dialog.setAlwaysOnTop(true); + dialog.setLocationRelativeTo(frame); + dialog.setModalityType(ModalityType.APPLICATION_MODAL); + + final JPanel content = new JPanel(); + content.setLayout(null); + content.setPreferredSize(new Dimension(520, 400)); + JLabel targetLabel = new JLabel("Ŀ"); + targetLabel.setBounds(10, 10, 50, 25); + final JTextField targetText = new JTextField(); + targetText.setForeground(Color.GRAY); + if (!"".equals(field.getText())) { + targetText.setText(""); + targetText.setForeground(Color.BLACK); + } + targetText.setBounds(20, 50, 300, 25); + final JButton searchBtn = new JButton(""); + searchBtn.setBounds(380, 50, 100, 25); + + String[] colDisplayNames = new String[] { "", "", "״̬", "", "ID", "" }; + final DefaultTableModel model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + return false; + } + }; + final JTable table = new JTable(model); + table.getColumnModel().getColumn(0).setMinWidth(100); + table.getColumnModel().getColumn(1).setMinWidth(100); + table.getColumnModel().getColumn(2).setMinWidth(100); + table.getColumnModel().getColumn(3).setMinWidth(100); + table.getColumnModel().getColumn(4).setMinWidth(60); + table.getColumnModel().getColumn(4).setPreferredWidth(60); + TableColumnModel tcm = table.getColumnModel(); + TableColumn tc = tcm.getColumn(5); + tc.setWidth(0); + tc.setPreferredWidth(0); + tc.setMaxWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(5).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(5).setMinWidth(0); + table.setRowHeight(25); + table.setAutoscrolls(true); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.getTableHeader().setReorderingAllowed(false); + JScrollPane jsp = new JScrollPane(table); + jsp.setBounds(20, 100, 460, 200); + + JButton okBtn = new JButton("ȷ"); + okBtn.setBounds(140, 320, 100, 25); + JButton cancelBtn = new JButton("ȡ"); + cancelBtn.setBounds(260, 320, 100, 25); + + targetText.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + if ("".equals(targetText.getText())) { + targetText.setText("ҪͼID"); + targetText.setForeground(Color.GRAY); + } + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + if ("ҪͼID".equals(targetText.getText())) { + targetText.setText(""); + targetText.setForeground(Color.BLACK); + } + } + }); + + targetText.addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent paramKeyEvent) { + // TODO Auto-generated method stub + super.keyTyped(paramKeyEvent); + if (paramKeyEvent.getKeyChar() == KeyEvent.VK_ENTER) { + searchBtn.doClick(); + } + } + }); + + searchBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int cnt = model.getRowCount(); + for (int i = 0; i < cnt; i++) { + model.removeRow(0); + } + + table.revalidate(); + table.repaint(); + String text = targetText.getText(); + System.out.println(text); + if ("ҪͼID".equals(text)) { + return; + } + long startTime = System.currentTimeMillis(); + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + TCComponentItem[] items = getTarget(content, text, session); + if (items == null) { + return; + } + List tableDataList = new ArrayList(); + List idslList = new ArrayList(); + for (TCComponentItem item : items) { + try { + item.refresh(); + if(idslList.size()>0 && idslList.contains(item.getStringProperty("item_id"))) { + continue; + } + idslList.add(item.getStringProperty("item_id")); + TCComponentItemRevision comp = item.getLatestItemRevision(); + String objetcString = comp.getProperty("object_string"); + TCComponent[] forms = comp.getRelatedComponents("IMAN_master_form_rev"); + String desc = ""; + if (forms.length > 0) { + desc = forms[0].getProperty("object_desc"); + } + TCComponent[] statusArray = comp.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + String owningUser = comp.getProperty("owning_user"); + String groupId = comp.getProperty("owning_group"); + tableDataList.add(new Object[] { objetcString, desc, status, owningUser, groupId, comp }); + +// TCComponent[] comps = item.getRelatedComponents("revision_list"); +// for (TCComponent comp : comps) { +// String objetcString = comp.getProperty("object_string"); +// TCComponent[] forms = comp.getRelatedComponents("IMAN_master_form_rev"); +// String desc = ""; +// if (forms.length > 0) { +// desc = forms[0].getProperty("object_desc"); +// } +// TCComponent[] statusArray = comp.getRelatedComponents("release_status_list"); +// String status = ""; +// if (statusArray != null && statusArray.length > 0) { +// status = statusArray[statusArray.length - 1].getProperty("object_name"); +// } +// String owningUser = comp.getProperty("owning_user"); +// String groupId = comp.getProperty("owning_group"); +// tableDataList.add(new Object[] { objetcString, desc, status, owningUser, groupId, comp }); +// BOMManagementFrame.itemList.add(comp); +// } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + for (Object[] rowData : tableDataList) { + model.addRow(rowData); + } + table.revalidate(); + table.repaint(); + System.out.println("ʾʱ" + (System.currentTimeMillis() - startTime) + "ms"); + } + }); + + okBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent paramActionEvent) { + // TODO Auto-generated method stub + frame.okCallback(table, paramTable, selectAll, field); +// dialog.setVisible(false); + dialog.dispose(); + } + }); + + cancelBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent paramActionEvent) { + // TODO Auto-generated method stub +// dialog.setVisible(false); + dialog.dispose(); + } + }); + + content.add(targetLabel); + content.add(targetText); + content.add(searchBtn); + content.add(jsp); + content.add(okBtn); + content.add(cancelBtn); + + dialog.add(content); + dialog.setVisible(true); + return dialog; + } + + private static TCComponentItem[] getTarget(Component parent, String itemId, TCSession session) { + TCComponent[] comps = null; + try { + comps = session.search("PX_originalNo", new String[] { "u2_originalNo","ID" }, new String[] { itemId,itemId }); +// TCComponentItemType type = new TCComponentItemType(); +// comps = type.findItems(itemId); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return null; + } + if (comps == null || comps.length == 0) { + JOptionPane.showMessageDialog(parent, "ЧͼţȷͼǷȷ", "ʾ", JOptionPane.WARNING_MESSAGE); + return null; + } + TCComponentItem[] items = new TCComponentItem[comps.length]; + for (int i = 0; i < comps.length; i++) { + try { + items[i] = ((TCComponentItemRevision) comps[i]).getItem(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return items; + } + + public static class TableMsg { + public JScrollPane panel; + public JTable table; + + public TableMsg(JScrollPane panel, JTable table) { + super(); + this.panel = panel; + this.table = table; + } + + } +} diff --git a/src/com/connor/jd/plm/utils/ExcelInfoScanner.java b/src/com/connor/jd/plm/utils/ExcelInfoScanner.java new file mode 100644 index 0000000..11ce297 --- /dev/null +++ b/src/com/connor/jd/plm/utils/ExcelInfoScanner.java @@ -0,0 +1,47 @@ +package com.connor.jd.plm.utils; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import com.aspose.cells.Cells; +import com.aspose.cells.License; +import com.aspose.cells.Workbook; +import com.aspose.cells.WorksheetCollection; + +public class ExcelInfoScanner { + + public static Map getClassPropOptions(String path, String nodeName) { + Map res = new HashMap(); + try { + getLicense(); + Workbook excel = new Workbook(path); + WorksheetCollection wc = excel.getWorksheets(); + Cells cells = wc.get(0).getCells(); + for (int i = 0; i <= cells.getMaxDataRow(); i++) { + if (cells.get(i, 0).getStringValue().equals(nodeName)) { + res.put(cells.get(i, 1).getIntValue(), cells.get(i, 2).getStringValue()); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return res; + } + + public static boolean getLicense() throws Exception { + boolean result = false; + try { + InputStream is = com.aspose.cells.Cell.class.getResourceAsStream("/com/aspose/cells/resources/license.xml"); + License aposeLic = new License(); + aposeLic.setLicense(is); + result = true; + is.close(); + } catch (Exception e) { + e.printStackTrace(System.out); + throw e; + } + return result; + } +} diff --git a/src/com/connor/jd/plm/utils/JDMethodUtil.java b/src/com/connor/jd/plm/utils/JDMethodUtil.java new file mode 100644 index 0000000..bd73a4c --- /dev/null +++ b/src/com/connor/jd/plm/utils/JDMethodUtil.java @@ -0,0 +1,45 @@ +package com.connor.jd.plm.utils; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class JDMethodUtil { + + public static TCPreferenceService service; + public static TCUserService userservice; + + /** + * + * + * @param prefName + * @return + */ + public static String getPrefStr(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /** + * + * + * @param prefName + * @return + */ + public static String[] getPrefStrArray(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + if (strs == null) { + strs = new String[] { "" }; + } + return strs; + } +} diff --git a/src/com/connor/jd/plm/utils/KeyValComboBox.java b/src/com/connor/jd/plm/utils/KeyValComboBox.java new file mode 100644 index 0000000..5659013 --- /dev/null +++ b/src/com/connor/jd/plm/utils/KeyValComboBox.java @@ -0,0 +1,96 @@ +package com.connor.jd.plm.utils; + +import java.awt.Component; +import java.util.Vector; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JComboBox; +import javax.swing.JList; + +import com.connor.jd.plm.beans.CheckBoxPo; + +public class KeyValComboBox extends JComboBox { + + public KeyValComboBox(Vector values) { + super(values); + rendererData(); // Ⱦ + } + + public void rendererData() { + DefaultListCellRenderer render = new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) value; + this.setText(po.text); + } + return this; + } + }; + this.setRenderer(render); + } + + // ޸Comboxе + public void updateData(Vector values) { + setModel(new DefaultComboBoxModel(values)); + rendererData(); + } + + @Override + public void setSelectedItem(Object anObject) { // ѡtext봫IJͬ + if (anObject != null) { + if (anObject instanceof CheckBoxPo) { + super.setSelectedItem(anObject); + } + if (anObject instanceof String) { + for (int index = 0; index < getItemCount(); index++) { + CheckBoxPo po = (CheckBoxPo) getItemAt(index); + if (po.text.equals(anObject.toString())) { + super.setSelectedIndex(index); + } + } + } + } else { + super.setSelectedItem(anObject); + } + } + + public void setSelectedValue(Object anObject) { // ѡvalue봫IJͬ + if (anObject != null) { + if (anObject instanceof CheckBoxPo) { + super.setSelectedItem(anObject); + } + if (anObject instanceof String) { + for (int index = 0; index < getItemCount(); index++) { + CheckBoxPo po = (CheckBoxPo) getItemAt(index); + if (po.value.equals(anObject.toString())) { + super.setSelectedIndex(index); + } + } + } + } else { + super.setSelectedItem(anObject); + } + } + + // ѡļֵ + public Object getSelectedValue() { + if (getSelectedItem() instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) getSelectedItem(); + return po.value; + } + return (getSelectedItem() != null) ? getSelectedItem().toString() : null; + } + + // ѡʾı + public String getSelectedText() { + if (getSelectedItem() instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) getSelectedItem(); + return po.text; + } + return (getSelectedItem() != null) ? getSelectedItem().toString() : null; + } +} \ No newline at end of file diff --git a/src/com/connor/jd/plm/utils/SimpleExcelUtil.java b/src/com/connor/jd/plm/utils/SimpleExcelUtil.java new file mode 100644 index 0000000..e975127 --- /dev/null +++ b/src/com/connor/jd/plm/utils/SimpleExcelUtil.java @@ -0,0 +1,69 @@ +package com.connor.jd.plm.utils; + +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import com.aspose.cells.Cells; +import com.aspose.cells.License; +import com.aspose.cells.Workbook; +import com.aspose.cells.WorksheetCollection; + +public class SimpleExcelUtil { + public static void exportExcel(String path, String[] header, List data) { + if (path == null || data == null) { + return; + } + try { + File file = new File(path); + file.createNewFile(); + + getLicense(); + + Workbook excel = new Workbook(path); + WorksheetCollection wc = excel.getWorksheets(); + Cells cells = wc.get(0).getCells(); + int rowIndex = 0; + if (header != null) { + for (int columnIndex = 0; columnIndex < header.length; columnIndex++) { + cells.get(rowIndex, columnIndex).setValue(header[columnIndex]); + } + rowIndex++; + } + for (String[] arr : data) { + for (int columnIndex = 0; columnIndex < arr.length; columnIndex++) { + cells.get(rowIndex, columnIndex).setValue(arr[columnIndex]); + } + rowIndex++; + } + excel.save(path); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static boolean getLicense() throws Exception { + boolean result = false; + try { + InputStream is = com.aspose.cells.Cell.class.getResourceAsStream("/com/aspose/cells/resources/license.xml"); + License aposeLic = new License(); + aposeLic.setLicense(is); + result = true; + is.close(); + } catch (Exception e) { + e.printStackTrace(System.out); + throw e; + } + return result; + } + + public static void main(String[] args) { + List test = new ArrayList(); + test.add(new String[] { "zzz", "xxx" }); + SimpleExcelUtil.exportExcel(System.getenv("temp") + File.separator + "xxxxxxxxxxxxxxxxxxxx.xlsx", + new String[] { "1", "2" }, test); + System.out.println(System.getenv("temp")); + } +} diff --git a/src/com/connor/jd/plm/utils/StringCreateUtil.java b/src/com/connor/jd/plm/utils/StringCreateUtil.java new file mode 100644 index 0000000..57e6a19 --- /dev/null +++ b/src/com/connor/jd/plm/utils/StringCreateUtil.java @@ -0,0 +1,21 @@ +package com.connor.jd.plm.utils; + +public class StringCreateUtil { + public static String createBlank(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append(" "); + num--; + } + return sb.toString(); + } + + public static String createPoint(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append("."); + num--; + } + return sb.toString(); + } +} diff --git a/src/com/px/plm/handlers/SampleHandler.java b/src/com/px/plm/handlers/SampleHandler.java new file mode 100644 index 0000000..f23a684 --- /dev/null +++ b/src/com/px/plm/handlers/SampleHandler.java @@ -0,0 +1,21 @@ +package com.px.plm.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; + +public class SampleHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); + MessageDialog.openInformation( + window.getShell(), + "Plm", + "Hello, Eclipse world"); + return null; + } +} diff --git a/src/com/uds/update/UDSStartup.java b/src/com/uds/update/UDSStartup.java new file mode 100644 index 0000000..35eb281 --- /dev/null +++ b/src/com/uds/update/UDSStartup.java @@ -0,0 +1,95 @@ +package com.uds.update; + +import com.caxaviews.util.Common; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +public class UDSStartup implements IStartup { + public int count = 0; + public String tempUid = ""; + + public void earlyStartup() { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + + try { + try { + PlatformUI.getWorkbench().showPerspective("com.teamcenter.rac.gettingstarted.GettingStartedPerspective", window).resetPerspective(); + PlatformUI.getWorkbench().showPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective", window); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().addSelectionListener(new ISelectionListener() { + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + if (selection instanceof StructuredSelection) { + StructuredSelection is = (StructuredSelection)selection; + //IStructuredSelection is = (IStructuredSelection)selection; + TCComponent component = null; + Object object = is.getFirstElement(); + if (object instanceof AIFComponentContext) { + AIFComponentContext context = (AIFComponentContext)object; + component = (TCComponent)context.getComponent(); + } + + if (component != null) { + if (component.getType().toString().equals("U2_EXB")) { + TCComponentDataset dataset = (TCComponentDataset)component; + + try { + String other_name = dataset.getProperty("ref_list").replace(".exb", "").trim(); + UDSStartup.this.getItemInfo(dataset, other_name); + } catch (Exception var8) { + var8.printStackTrace(); + } + } else { + UDSStartup.this.tempUid = ""; + UDSStartup.this.count = 0; + } + } + } + + + } + }); + } catch (Exception var3) { + var3.printStackTrace(); + } + } catch (Exception var4) { + var4.printStackTrace(); + } + + } + }); + } + + public void getItemInfo(TCComponentDataset component, String object_name) { + try { + AIFComponentContext[] components = component.whereReferenced(); + TCComponentItemRevision itemRevision = null; + + for(int i = 0; i < components.length; ++i) { + if (components[i].getComponent() instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision)components[i].getComponent(); + } + } + + if (itemRevision == null) { + return; + } + + Common.printX(itemRevision, object_name, component); + } catch (TCException var6) { + var6.printStackTrace(); + } + + } +}