commit 7dd96c4240e800c89a157b276999599ef121d989 Author: lijh Date: Tue Mar 10 11:24:03 2026 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..64378ca --- /dev/null +++ b/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..53eb7c9 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + cust.com.ysr + + + + + + 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..f42de36 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..242c1cb --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,52 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: YSR +Bundle-SymbolicName: cust.com.ysr;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Bundle-Activator: cust.com.ysr.Activator +Require-Bundle: org.eclipse.ui;bundle-version="3.8.0", + org.eclipse.core.runtime, + com.teamcenter.rac.kernel;bundle-version="11000.2.0", + com.teamcenter.rac.aifrcp;bundle-version="11000.2.0", + com.teamcenter.rac.util;bundle-version="11000.2.0", + com.teamcenter.rac.tcapps;bundle-version="11000.2.0", + com.teamcenter.rac.common;bundle-version="11000.2.0", + com.teamcenter.rac.processhistory;bundle-version="11000.2.0", + com.teamcenter.rac.auditmanager;bundle-version="11000.2.0", + Fnd0SoaAuditManagerRac;bundle-version="11000.2.0", + com.teamcenter.rac.schedule;bundle-version="11000.2.0", + org.eclipse.osgi.services;bundle-version="3.3.100", + org.eclipse.osgi.util;bundle-version="3.2.300", + org.eclipse.core.databinding;bundle-version="1.4.1", + org.eclipse.core.databinding.beans;bundle-version="1.2.200", + org.eclipse.core.databinding.property;bundle-version="1.4.100", + com.teamcenter.rac.viewer;bundle-version="11000.2.0", + com.teamcenter.rac.ui.views;bundle-version="11000.2.0", + TcSoaCommon;bundle-version="11000.2.0", + TcSoaCoreRac;bundle-version="11000.2.0", + TcSoaCoreTypes;bundle-version="11000.2.0", + org.eclipse.ui.forms;bundle-version="3.5.200", + org.apache.poi.39, + Fnd0SoaAuditManagerTypes;bundle-version="11000.2.0", + cn.com.origin.autocodemanager;bundle-version="1.0.0", + cn.com.origin.autocode;bundle-version="1.0.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Export-Package: cn.com.teamcenter.rac.form, + com.teamcenter.rac.viewer.stylesheet.beans, + cust.com.rac.integration, + cust.com.ysr +Import-Package: jxl, + jxl.biff, + jxl.biff.drawing, + jxl.biff.formula, + jxl.demo, + jxl.format, + jxl.read.biff, + jxl.write, + jxl.write.biff, + org.apache.log4j, + org.dom4j, + org.dom4j.io +Bundle-ClassPath: . diff --git a/bin/cn/com/customization/create/CreateFolderFromTemplateCommand.class b/bin/cn/com/customization/create/CreateFolderFromTemplateCommand.class new file mode 100644 index 0000000..20b9925 Binary files /dev/null and b/bin/cn/com/customization/create/CreateFolderFromTemplateCommand.class differ diff --git a/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$1.class b/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$1.class new file mode 100644 index 0000000..201c04d Binary files /dev/null and b/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$1.class differ diff --git a/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$2.class b/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$2.class new file mode 100644 index 0000000..7a940ef Binary files /dev/null and b/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$2.class differ diff --git a/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$3.class b/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$3.class new file mode 100644 index 0000000..e9073f3 Binary files /dev/null and b/bin/cn/com/customization/create/CreateFolderFromTemplateDialog$3.class differ diff --git a/bin/cn/com/customization/create/CreateFolderFromTemplateDialog.class b/bin/cn/com/customization/create/CreateFolderFromTemplateDialog.class new file mode 100644 index 0000000..7f2827e Binary files /dev/null and b/bin/cn/com/customization/create/CreateFolderFromTemplateDialog.class differ diff --git a/bin/cn/com/customization/create/CreateFolderFromTemplateHandler.class b/bin/cn/com/customization/create/CreateFolderFromTemplateHandler.class new file mode 100644 index 0000000..b025d2f Binary files /dev/null and b/bin/cn/com/customization/create/CreateFolderFromTemplateHandler.class differ diff --git a/bin/cn/com/customization/download/BatchDownLoadFileCommand.class b/bin/cn/com/customization/download/BatchDownLoadFileCommand.class new file mode 100644 index 0000000..ddd33e4 Binary files /dev/null and b/bin/cn/com/customization/download/BatchDownLoadFileCommand.class differ diff --git a/bin/cn/com/customization/download/BatchDownLoadFileCommand2.class b/bin/cn/com/customization/download/BatchDownLoadFileCommand2.class new file mode 100644 index 0000000..7359759 Binary files /dev/null and b/bin/cn/com/customization/download/BatchDownLoadFileCommand2.class differ diff --git a/bin/cn/com/customization/download/BatchDownLoadFileHandler.class b/bin/cn/com/customization/download/BatchDownLoadFileHandler.class new file mode 100644 index 0000000..a69d2c1 Binary files /dev/null and b/bin/cn/com/customization/download/BatchDownLoadFileHandler.class differ diff --git a/bin/cn/com/customization/download/BatchDownLoadFileHandler2.class b/bin/cn/com/customization/download/BatchDownLoadFileHandler2.class new file mode 100644 index 0000000..48f2d83 Binary files /dev/null and b/bin/cn/com/customization/download/BatchDownLoadFileHandler2.class differ diff --git a/bin/cn/com/customization/download/DatasetFileDown.class b/bin/cn/com/customization/download/DatasetFileDown.class new file mode 100644 index 0000000..6bae79e Binary files /dev/null and b/bin/cn/com/customization/download/DatasetFileDown.class differ diff --git a/bin/cn/com/customization/download/DatasetFileDown2.class b/bin/cn/com/customization/download/DatasetFileDown2.class new file mode 100644 index 0000000..1403a7f Binary files /dev/null and b/bin/cn/com/customization/download/DatasetFileDown2.class differ diff --git a/bin/cn/com/customization/download/DeleteNullDir.class b/bin/cn/com/customization/download/DeleteNullDir.class new file mode 100644 index 0000000..4182321 Binary files /dev/null and b/bin/cn/com/customization/download/DeleteNullDir.class differ diff --git a/bin/cn/com/customization/imports/ImportBatchDirectoryCommand$1.class b/bin/cn/com/customization/imports/ImportBatchDirectoryCommand$1.class new file mode 100644 index 0000000..53d5f3d Binary files /dev/null and b/bin/cn/com/customization/imports/ImportBatchDirectoryCommand$1.class differ diff --git a/bin/cn/com/customization/imports/ImportBatchDirectoryCommand.class b/bin/cn/com/customization/imports/ImportBatchDirectoryCommand.class new file mode 100644 index 0000000..1a25d53 Binary files /dev/null and b/bin/cn/com/customization/imports/ImportBatchDirectoryCommand.class differ diff --git a/bin/cn/com/customization/imports/ImportBatchDirectoryHandler.class b/bin/cn/com/customization/imports/ImportBatchDirectoryHandler.class new file mode 100644 index 0000000..e026872 Binary files /dev/null and b/bin/cn/com/customization/imports/ImportBatchDirectoryHandler.class differ diff --git a/bin/cn/com/customization/imports/ImportBatchFileCommand$1.class b/bin/cn/com/customization/imports/ImportBatchFileCommand$1.class new file mode 100644 index 0000000..a363e6c Binary files /dev/null and b/bin/cn/com/customization/imports/ImportBatchFileCommand$1.class differ diff --git a/bin/cn/com/customization/imports/ImportBatchFileCommand.class b/bin/cn/com/customization/imports/ImportBatchFileCommand.class new file mode 100644 index 0000000..36648cd Binary files /dev/null and b/bin/cn/com/customization/imports/ImportBatchFileCommand.class differ diff --git a/bin/cn/com/customization/imports/ImportBatchFileHandler.class b/bin/cn/com/customization/imports/ImportBatchFileHandler.class new file mode 100644 index 0000000..a20d4fc Binary files /dev/null and b/bin/cn/com/customization/imports/ImportBatchFileHandler.class differ diff --git a/bin/cn/com/customization/imports/importfiles/CreateDataSet.class b/bin/cn/com/customization/imports/importfiles/CreateDataSet.class new file mode 100644 index 0000000..ded9605 Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/CreateDataSet.class differ diff --git a/bin/cn/com/customization/imports/importfiles/CreateFolder.class b/bin/cn/com/customization/imports/importfiles/CreateFolder.class new file mode 100644 index 0000000..3ceb797 Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/CreateFolder.class differ diff --git a/bin/cn/com/customization/imports/importfiles/GetAllDataSetNames.class b/bin/cn/com/customization/imports/importfiles/GetAllDataSetNames.class new file mode 100644 index 0000000..c9d57e5 Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/GetAllDataSetNames.class differ diff --git a/bin/cn/com/customization/imports/importfiles/GetAllOptionValue.class b/bin/cn/com/customization/imports/importfiles/GetAllOptionValue.class new file mode 100644 index 0000000..24af958 Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/GetAllOptionValue.class differ diff --git a/bin/cn/com/customization/imports/importfiles/GetChoosePath$1.class b/bin/cn/com/customization/imports/importfiles/GetChoosePath$1.class new file mode 100644 index 0000000..75e61c0 Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/GetChoosePath$1.class differ diff --git a/bin/cn/com/customization/imports/importfiles/GetChoosePath.class b/bin/cn/com/customization/imports/importfiles/GetChoosePath.class new file mode 100644 index 0000000..34398df Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/GetChoosePath.class differ diff --git a/bin/cn/com/customization/imports/importfiles/GetCommonInfo.class b/bin/cn/com/customization/imports/importfiles/GetCommonInfo.class new file mode 100644 index 0000000..3312c51 Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/GetCommonInfo.class differ diff --git a/bin/cn/com/customization/imports/importfiles/GetTargetComponent.class b/bin/cn/com/customization/imports/importfiles/GetTargetComponent.class new file mode 100644 index 0000000..409abdd Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/GetTargetComponent.class differ diff --git a/bin/cn/com/customization/imports/importfiles/ImportFile.class b/bin/cn/com/customization/imports/importfiles/ImportFile.class new file mode 100644 index 0000000..ef528ae Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/ImportFile.class differ diff --git a/bin/cn/com/customization/imports/importfiles/ORProgressBar$1.class b/bin/cn/com/customization/imports/importfiles/ORProgressBar$1.class new file mode 100644 index 0000000..5d59d8d Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/ORProgressBar$1.class differ diff --git a/bin/cn/com/customization/imports/importfiles/ORProgressBar$TaskThread.class b/bin/cn/com/customization/imports/importfiles/ORProgressBar$TaskThread.class new file mode 100644 index 0000000..64d50a5 Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/ORProgressBar$TaskThread.class differ diff --git a/bin/cn/com/customization/imports/importfiles/ORProgressBar.class b/bin/cn/com/customization/imports/importfiles/ORProgressBar.class new file mode 100644 index 0000000..bd3ce81 Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/ORProgressBar.class differ diff --git a/bin/cn/com/customization/imports/importfiles/ORProgressBarThread.class b/bin/cn/com/customization/imports/importfiles/ORProgressBarThread.class new file mode 100644 index 0000000..c4ad75c Binary files /dev/null and b/bin/cn/com/customization/imports/importfiles/ORProgressBarThread.class differ diff --git a/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$1.class b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$1.class new file mode 100644 index 0000000..b2a36bd Binary files /dev/null and b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$1.class differ diff --git a/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$2.class b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$2.class new file mode 100644 index 0000000..a39fcf2 Binary files /dev/null and b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$2.class differ diff --git a/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$3.class b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$3.class new file mode 100644 index 0000000..7a41c8d Binary files /dev/null and b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$3.class differ diff --git a/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$4.class b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$4.class new file mode 100644 index 0000000..3ce35de Binary files /dev/null and b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog$4.class differ diff --git a/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog.class b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog.class new file mode 100644 index 0000000..6e235e2 Binary files /dev/null and b/bin/cn/com/customization/project/CopyFolderAndAssginToProjectDialog.class differ diff --git a/bin/cn/com/customization/project/CreateProjectFolderCommand$1.class b/bin/cn/com/customization/project/CreateProjectFolderCommand$1.class new file mode 100644 index 0000000..88f40ad Binary files /dev/null and b/bin/cn/com/customization/project/CreateProjectFolderCommand$1.class differ diff --git a/bin/cn/com/customization/project/CreateProjectFolderCommand.class b/bin/cn/com/customization/project/CreateProjectFolderCommand.class new file mode 100644 index 0000000..30058af Binary files /dev/null and b/bin/cn/com/customization/project/CreateProjectFolderCommand.class differ diff --git a/bin/cn/com/customization/project/CreateProjectFolderHandler.class b/bin/cn/com/customization/project/CreateProjectFolderHandler.class new file mode 100644 index 0000000..e41b61b Binary files /dev/null and b/bin/cn/com/customization/project/CreateProjectFolderHandler.class differ diff --git a/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchCommand.class b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchCommand.class new file mode 100644 index 0000000..413c24e Binary files /dev/null and b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchCommand.class differ diff --git a/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$1.class b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$1.class new file mode 100644 index 0000000..0cc81c6 Binary files /dev/null and b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$1.class differ diff --git a/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$2.class b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$2.class new file mode 100644 index 0000000..a462957 Binary files /dev/null and b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$2.class differ diff --git a/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$3.class b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$3.class new file mode 100644 index 0000000..28775fa Binary files /dev/null and b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog$3.class differ diff --git a/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog.class b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog.class new file mode 100644 index 0000000..69ee013 Binary files /dev/null and b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog.class differ diff --git a/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchHandler.class b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchHandler.class new file mode 100644 index 0000000..3b5feca Binary files /dev/null and b/bin/cn/com/customization/purchasing/PurchasingDepartmentSearchHandler.class differ diff --git a/bin/cn/com/customization/schedule/AbstracModifyDialog$1.class b/bin/cn/com/customization/schedule/AbstracModifyDialog$1.class new file mode 100644 index 0000000..11a7398 Binary files /dev/null and b/bin/cn/com/customization/schedule/AbstracModifyDialog$1.class differ diff --git a/bin/cn/com/customization/schedule/AbstracModifyDialog$2.class b/bin/cn/com/customization/schedule/AbstracModifyDialog$2.class new file mode 100644 index 0000000..2cb4d7c Binary files /dev/null and b/bin/cn/com/customization/schedule/AbstracModifyDialog$2.class differ diff --git a/bin/cn/com/customization/schedule/AbstracModifyDialog$buttonListener.class b/bin/cn/com/customization/schedule/AbstracModifyDialog$buttonListener.class new file mode 100644 index 0000000..2a69700 Binary files /dev/null and b/bin/cn/com/customization/schedule/AbstracModifyDialog$buttonListener.class differ diff --git a/bin/cn/com/customization/schedule/AbstracModifyDialog.class b/bin/cn/com/customization/schedule/AbstracModifyDialog.class new file mode 100644 index 0000000..febffbf Binary files /dev/null and b/bin/cn/com/customization/schedule/AbstracModifyDialog.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanCommand$1.class b/bin/cn/com/customization/schedule/BOMTransPlanCommand$1.class new file mode 100644 index 0000000..c0bd8cb Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanCommand$1.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanCommand.class b/bin/cn/com/customization/schedule/BOMTransPlanCommand.class new file mode 100644 index 0000000..c8ff9ad Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanCommand.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanDialog$1.class b/bin/cn/com/customization/schedule/BOMTransPlanDialog$1.class new file mode 100644 index 0000000..c64d4f1 Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanDialog$1.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanDialog$2.class b/bin/cn/com/customization/schedule/BOMTransPlanDialog$2.class new file mode 100644 index 0000000..498833a Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanDialog$2.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanDialog$3.class b/bin/cn/com/customization/schedule/BOMTransPlanDialog$3.class new file mode 100644 index 0000000..d6eca46 Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanDialog$3.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanDialog$4.class b/bin/cn/com/customization/schedule/BOMTransPlanDialog$4.class new file mode 100644 index 0000000..711df3e Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanDialog$4.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanDialog$ScheduleDefaultTreeCellRenderer.class b/bin/cn/com/customization/schedule/BOMTransPlanDialog$ScheduleDefaultTreeCellRenderer.class new file mode 100644 index 0000000..1296df6 Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanDialog$ScheduleDefaultTreeCellRenderer.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanDialog.class b/bin/cn/com/customization/schedule/BOMTransPlanDialog.class new file mode 100644 index 0000000..68b7161 Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanDialog.class differ diff --git a/bin/cn/com/customization/schedule/BOMTransPlanHandler.class b/bin/cn/com/customization/schedule/BOMTransPlanHandler.class new file mode 100644 index 0000000..8316279 Binary files /dev/null and b/bin/cn/com/customization/schedule/BOMTransPlanHandler.class differ diff --git a/bin/cn/com/customization/schedule/CheckBoxTreeCellRenderer.class b/bin/cn/com/customization/schedule/CheckBoxTreeCellRenderer.class new file mode 100644 index 0000000..67795b6 Binary files /dev/null and b/bin/cn/com/customization/schedule/CheckBoxTreeCellRenderer.class differ diff --git a/bin/cn/com/customization/schedule/CheckBoxTreeLabel.class b/bin/cn/com/customization/schedule/CheckBoxTreeLabel.class new file mode 100644 index 0000000..326da7c Binary files /dev/null and b/bin/cn/com/customization/schedule/CheckBoxTreeLabel.class differ diff --git a/bin/cn/com/customization/schedule/CheckBoxTreeNode.class b/bin/cn/com/customization/schedule/CheckBoxTreeNode.class new file mode 100644 index 0000000..6192d4e Binary files /dev/null and b/bin/cn/com/customization/schedule/CheckBoxTreeNode.class differ diff --git a/bin/cn/com/customization/schedule/CheckBoxTreeNodeSelectionListener.class b/bin/cn/com/customization/schedule/CheckBoxTreeNodeSelectionListener.class new file mode 100644 index 0000000..68e8148 Binary files /dev/null and b/bin/cn/com/customization/schedule/CheckBoxTreeNodeSelectionListener.class differ diff --git a/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameCommand.class b/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameCommand.class new file mode 100644 index 0000000..2082f95 Binary files /dev/null and b/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameCommand.class differ diff --git a/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameDialog.class b/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameDialog.class new file mode 100644 index 0000000..fc11bb6 Binary files /dev/null and b/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameDialog.class differ diff --git a/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameHandler.class b/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameHandler.class new file mode 100644 index 0000000..3cc4e1f Binary files /dev/null and b/bin/cn/com/customization/schedule/ModifyTaskOrDeliveryNameHandler.class differ diff --git a/bin/cn/com/customization/schedule/YSRScheduleTreeTableModel.class b/bin/cn/com/customization/schedule/YSRScheduleTreeTableModel.class new file mode 100644 index 0000000..a3b954e Binary files /dev/null and b/bin/cn/com/customization/schedule/YSRScheduleTreeTableModel.class differ diff --git a/bin/cn/com/customization/schedule/YSRTreeTable.class b/bin/cn/com/customization/schedule/YSRTreeTable.class new file mode 100644 index 0000000..c21ec62 Binary files /dev/null and b/bin/cn/com/customization/schedule/YSRTreeTable.class differ diff --git a/bin/cn/com/customization/util/CheckBoxColumnRender.class b/bin/cn/com/customization/util/CheckBoxColumnRender.class new file mode 100644 index 0000000..45797b5 Binary files /dev/null and b/bin/cn/com/customization/util/CheckBoxColumnRender.class differ diff --git a/bin/cn/com/customization/util/ColumnGroup$1.class b/bin/cn/com/customization/util/ColumnGroup$1.class new file mode 100644 index 0000000..580fcba Binary files /dev/null and b/bin/cn/com/customization/util/ColumnGroup$1.class differ diff --git a/bin/cn/com/customization/util/ColumnGroup.class b/bin/cn/com/customization/util/ColumnGroup.class new file mode 100644 index 0000000..1b7a898 Binary files /dev/null and b/bin/cn/com/customization/util/ColumnGroup.class differ diff --git a/bin/cn/com/customization/util/DataSetFinder.class b/bin/cn/com/customization/util/DataSetFinder.class new file mode 100644 index 0000000..db09596 Binary files /dev/null and b/bin/cn/com/customization/util/DataSetFinder.class differ diff --git a/bin/cn/com/customization/util/GetAllUserIds.class b/bin/cn/com/customization/util/GetAllUserIds.class new file mode 100644 index 0000000..01bb7ed Binary files /dev/null and b/bin/cn/com/customization/util/GetAllUserIds.class differ diff --git a/bin/cn/com/customization/util/GetChoosePath$1.class b/bin/cn/com/customization/util/GetChoosePath$1.class new file mode 100644 index 0000000..28fe445 Binary files /dev/null and b/bin/cn/com/customization/util/GetChoosePath$1.class differ diff --git a/bin/cn/com/customization/util/GetChoosePath.class b/bin/cn/com/customization/util/GetChoosePath.class new file mode 100644 index 0000000..08e9b19 Binary files /dev/null and b/bin/cn/com/customization/util/GetChoosePath.class differ diff --git a/bin/cn/com/customization/util/GetCommonInfo.class b/bin/cn/com/customization/util/GetCommonInfo.class new file mode 100644 index 0000000..73fb11b Binary files /dev/null and b/bin/cn/com/customization/util/GetCommonInfo.class differ diff --git a/bin/cn/com/customization/util/GetMessageDialog$1.class b/bin/cn/com/customization/util/GetMessageDialog$1.class new file mode 100644 index 0000000..9c21cad Binary files /dev/null and b/bin/cn/com/customization/util/GetMessageDialog$1.class differ diff --git a/bin/cn/com/customization/util/GetMessageDialog$2.class b/bin/cn/com/customization/util/GetMessageDialog$2.class new file mode 100644 index 0000000..04abe6b Binary files /dev/null and b/bin/cn/com/customization/util/GetMessageDialog$2.class differ diff --git a/bin/cn/com/customization/util/GetMessageDialog.class b/bin/cn/com/customization/util/GetMessageDialog.class new file mode 100644 index 0000000..e09da88 Binary files /dev/null and b/bin/cn/com/customization/util/GetMessageDialog.class differ diff --git a/bin/cn/com/customization/util/GetMessagePromptDialog$1.class b/bin/cn/com/customization/util/GetMessagePromptDialog$1.class new file mode 100644 index 0000000..c0d74ca Binary files /dev/null and b/bin/cn/com/customization/util/GetMessagePromptDialog$1.class differ diff --git a/bin/cn/com/customization/util/GetMessagePromptDialog$2.class b/bin/cn/com/customization/util/GetMessagePromptDialog$2.class new file mode 100644 index 0000000..39e7094 Binary files /dev/null and b/bin/cn/com/customization/util/GetMessagePromptDialog$2.class differ diff --git a/bin/cn/com/customization/util/GetMessagePromptDialog.class b/bin/cn/com/customization/util/GetMessagePromptDialog.class new file mode 100644 index 0000000..0607b58 Binary files /dev/null and b/bin/cn/com/customization/util/GetMessagePromptDialog.class differ diff --git a/bin/cn/com/customization/util/GroupableTableHeader.class b/bin/cn/com/customization/util/GroupableTableHeader.class new file mode 100644 index 0000000..52dc574 Binary files /dev/null and b/bin/cn/com/customization/util/GroupableTableHeader.class differ diff --git a/bin/cn/com/customization/util/GroupableTableHeaderUI$1.class b/bin/cn/com/customization/util/GroupableTableHeaderUI$1.class new file mode 100644 index 0000000..6163f8f Binary files /dev/null and b/bin/cn/com/customization/util/GroupableTableHeaderUI$1.class differ diff --git a/bin/cn/com/customization/util/GroupableTableHeaderUI$2.class b/bin/cn/com/customization/util/GroupableTableHeaderUI$2.class new file mode 100644 index 0000000..51b5f5d Binary files /dev/null and b/bin/cn/com/customization/util/GroupableTableHeaderUI$2.class differ diff --git a/bin/cn/com/customization/util/GroupableTableHeaderUI$3.class b/bin/cn/com/customization/util/GroupableTableHeaderUI$3.class new file mode 100644 index 0000000..3c77ee1 Binary files /dev/null and b/bin/cn/com/customization/util/GroupableTableHeaderUI$3.class differ diff --git a/bin/cn/com/customization/util/GroupableTableHeaderUI.class b/bin/cn/com/customization/util/GroupableTableHeaderUI.class new file mode 100644 index 0000000..c358ff1 Binary files /dev/null and b/bin/cn/com/customization/util/GroupableTableHeaderUI.class differ diff --git a/bin/cn/com/customization/util/KUtil.class b/bin/cn/com/customization/util/KUtil.class new file mode 100644 index 0000000..408c971 Binary files /dev/null and b/bin/cn/com/customization/util/KUtil.class differ diff --git a/bin/cn/com/customization/util/PackFailDownInfo.class b/bin/cn/com/customization/util/PackFailDownInfo.class new file mode 100644 index 0000000..5edec0e Binary files /dev/null and b/bin/cn/com/customization/util/PackFailDownInfo.class differ diff --git a/bin/cn/com/customization/util/PackResultInfo.class b/bin/cn/com/customization/util/PackResultInfo.class new file mode 100644 index 0000000..0438bb7 Binary files /dev/null and b/bin/cn/com/customization/util/PackResultInfo.class differ diff --git a/bin/cn/com/customization/util/PackSuccessfulInfo.class b/bin/cn/com/customization/util/PackSuccessfulInfo.class new file mode 100644 index 0000000..d15b4ed Binary files /dev/null and b/bin/cn/com/customization/util/PackSuccessfulInfo.class differ diff --git a/bin/cn/com/customization/util/QueryTaskOpinionTableHead$1.class b/bin/cn/com/customization/util/QueryTaskOpinionTableHead$1.class new file mode 100644 index 0000000..58afe83 Binary files /dev/null and b/bin/cn/com/customization/util/QueryTaskOpinionTableHead$1.class differ diff --git a/bin/cn/com/customization/util/QueryTaskOpinionTableHead$2.class b/bin/cn/com/customization/util/QueryTaskOpinionTableHead$2.class new file mode 100644 index 0000000..58fffaf Binary files /dev/null and b/bin/cn/com/customization/util/QueryTaskOpinionTableHead$2.class differ diff --git a/bin/cn/com/customization/util/QueryTaskOpinionTableHead$3.class b/bin/cn/com/customization/util/QueryTaskOpinionTableHead$3.class new file mode 100644 index 0000000..87c3657 Binary files /dev/null and b/bin/cn/com/customization/util/QueryTaskOpinionTableHead$3.class differ diff --git a/bin/cn/com/customization/util/QueryTaskOpinionTableHead.class b/bin/cn/com/customization/util/QueryTaskOpinionTableHead.class new file mode 100644 index 0000000..be3a847 Binary files /dev/null and b/bin/cn/com/customization/util/QueryTaskOpinionTableHead.class differ diff --git a/bin/cn/com/customization/util/ResultDialog$1.class b/bin/cn/com/customization/util/ResultDialog$1.class new file mode 100644 index 0000000..3751690 Binary files /dev/null and b/bin/cn/com/customization/util/ResultDialog$1.class differ diff --git a/bin/cn/com/customization/util/ResultDialog$buttonListener.class b/bin/cn/com/customization/util/ResultDialog$buttonListener.class new file mode 100644 index 0000000..3d2f30e Binary files /dev/null and b/bin/cn/com/customization/util/ResultDialog$buttonListener.class differ diff --git a/bin/cn/com/customization/util/ResultDialog.class b/bin/cn/com/customization/util/ResultDialog.class new file mode 100644 index 0000000..0ce09bb Binary files /dev/null and b/bin/cn/com/customization/util/ResultDialog.class differ diff --git a/bin/cn/com/customization/util/ResultTableModel.class b/bin/cn/com/customization/util/ResultTableModel.class new file mode 100644 index 0000000..ae5359f Binary files /dev/null and b/bin/cn/com/customization/util/ResultTableModel.class differ diff --git a/bin/cn/com/customization/util/ShowMessageDialog$1.class b/bin/cn/com/customization/util/ShowMessageDialog$1.class new file mode 100644 index 0000000..21561d7 Binary files /dev/null and b/bin/cn/com/customization/util/ShowMessageDialog$1.class differ diff --git a/bin/cn/com/customization/util/ShowMessageDialog.class b/bin/cn/com/customization/util/ShowMessageDialog.class new file mode 100644 index 0000000..018ef84 Binary files /dev/null and b/bin/cn/com/customization/util/ShowMessageDialog.class differ diff --git a/bin/cn/com/customization/util/TableColorRender.class b/bin/cn/com/customization/util/TableColorRender.class new file mode 100644 index 0000000..f1620f2 Binary files /dev/null and b/bin/cn/com/customization/util/TableColorRender.class differ diff --git a/bin/cn/com/customization/util/TableColumnRender.class b/bin/cn/com/customization/util/TableColumnRender.class new file mode 100644 index 0000000..68a256e Binary files /dev/null and b/bin/cn/com/customization/util/TableColumnRender.class differ diff --git a/bin/cn/com/customization/util/UtilApi.class b/bin/cn/com/customization/util/UtilApi.class new file mode 100644 index 0000000..160ec4a Binary files /dev/null and b/bin/cn/com/customization/util/UtilApi.class differ diff --git a/bin/cn/com/customization/util/WriteAndCopyFile.class b/bin/cn/com/customization/util/WriteAndCopyFile.class new file mode 100644 index 0000000..44bd025 Binary files /dev/null and b/bin/cn/com/customization/util/WriteAndCopyFile.class differ diff --git a/bin/cn/com/customization/util/image/info.png b/bin/cn/com/customization/util/image/info.png new file mode 100644 index 0000000..48dd7d0 Binary files /dev/null and b/bin/cn/com/customization/util/image/info.png differ diff --git a/bin/cn/com/teamcenter/rac/form/GCSelectionUserCommand.class b/bin/cn/com/teamcenter/rac/form/GCSelectionUserCommand.class new file mode 100644 index 0000000..8e785e5 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/GCSelectionUserCommand.class differ diff --git a/bin/cn/com/teamcenter/rac/form/ORTableColorRender.class b/bin/cn/com/teamcenter/rac/form/ORTableColorRender.class new file mode 100644 index 0000000..d1cb81d Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/ORTableColorRender.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$1.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$1.class new file mode 100644 index 0000000..3680f00 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$1.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$10.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$10.class new file mode 100644 index 0000000..d6dc4c8 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$10.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$2.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$2.class new file mode 100644 index 0000000..4db7632 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$2.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$3.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$3.class new file mode 100644 index 0000000..c79ec44 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$3.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$4.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$4.class new file mode 100644 index 0000000..eff2d39 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$4.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$5.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$5.class new file mode 100644 index 0000000..adc1aec Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$5.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$6.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$6.class new file mode 100644 index 0000000..c6c6c27 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$6.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$7.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$7.class new file mode 100644 index 0000000..bf39f41 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$7.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$8.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$8.class new file mode 100644 index 0000000..6f400cb Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$8.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$9.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$9.class new file mode 100644 index 0000000..0f4f263 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm$9.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm.class b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm.class new file mode 100644 index 0000000..235b217 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_ProjectForm.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$1.class b/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$1.class new file mode 100644 index 0000000..dee00eb Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$1.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$2.class b/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$2.class new file mode 100644 index 0000000..fc28249 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$2.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$3.class b/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$3.class new file mode 100644 index 0000000..ba8934a Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster$3.class differ diff --git a/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster.class b/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster.class new file mode 100644 index 0000000..3510c43 Binary files /dev/null and b/bin/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster.class differ diff --git a/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..04ca04b --- /dev/null +++ b/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1,2 @@ +YSR8_QuotationRevisionMaster.FORMJAVARENDERING=cn.com.teamcenter.rac.form.YSR8_QuotationRevisionMaster +YSR8_ProjectForm.FORMJAVARENDERING=cn.com.teamcenter.rac.form.YSR8_ProjectForm \ No newline at end of file diff --git a/bin/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean$IC_GenerateIDButtonSelectionAdapter.class b/bin/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean$IC_GenerateIDButtonSelectionAdapter.class new file mode 100644 index 0000000..d716e53 Binary files /dev/null and b/bin/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean$IC_GenerateIDButtonSelectionAdapter.class differ diff --git a/bin/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean.class b/bin/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean.class new file mode 100644 index 0000000..6d939b3 Binary files /dev/null and b/bin/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean.class differ diff --git a/bin/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale.properties b/bin/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale.properties new file mode 100644 index 0000000..c552968 --- /dev/null +++ b/bin/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale.properties @@ -0,0 +1,15 @@ +// @@ +// ================================================== +// Copyright 2011. +// Siemens Product Lifecycle Management Software Inc. +// All Rights Reserved. +// ================================================== +// @@ + +message.PREFIX=Value must match one of the following patterns: +assignButton.TEXT = Assign +sameAsOldId=An existing item is found. +invalidType=Selected Type should be an Item. +invalidID.MESSAGE=Unable to create item - an invalid ID entered! +error.TITLE = New Item ... +mandatoryGCID.TEXT=It is mandatory to enter a value. \ No newline at end of file diff --git a/bin/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale_zh_CN.properties b/bin/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale_zh_CN.properties new file mode 100644 index 0000000..5695826 --- /dev/null +++ b/bin/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale_zh_CN.properties @@ -0,0 +1,15 @@ +// @@ +// ================================================== +// Copyright 2011. +// Siemens Product Lifecycle Management Software Inc. +// All Rights Reserved. +// ================================================== +// @@ + +message.PREFIX=\u503C\u5FC5\u987B\u540C\u4EE5\u4E0B\u4E00\u79CD\u6837\u5F0F\u5339\u914D\uFF1A +assignButton.TEXT = \u6307\u6D3E +sameAsOldId=\u627E\u5230\u73B0\u6709\u96F6\u7EC4\u4EF6\u3002 +invalidType=\u9009\u5B9A\u7684\u7C7B\u578B\u5E94\u4E3A\u96F6\u7EC4\u4EF6\u3002 +invalidID.MESSAGE=\u65E0\u6CD5\u521B\u5EFA\u96F6\u7EC4\u4EF6 - \u8F93\u5165\u7684 ID \u65E0\u6548\uFF01 +error.TITLE = \u65B0\u5EFA\u96F6\u7EC4\u4EF6... +mandatoryGCID.TEXT=\u5F3A\u5236\u8F93\u5165\u503C\u3002 \ No newline at end of file diff --git a/bin/cust/com/rac/changename/ChangeNameAction.class b/bin/cust/com/rac/changename/ChangeNameAction.class new file mode 100644 index 0000000..edc91fa Binary files /dev/null and b/bin/cust/com/rac/changename/ChangeNameAction.class differ diff --git a/bin/cust/com/rac/changename/ChangeNameDialog.class b/bin/cust/com/rac/changename/ChangeNameDialog.class new file mode 100644 index 0000000..2e9c02e Binary files /dev/null and b/bin/cust/com/rac/changename/ChangeNameDialog.class differ diff --git a/bin/cust/com/rac/changename/ChangeNameHandler.class b/bin/cust/com/rac/changename/ChangeNameHandler.class new file mode 100644 index 0000000..80982a0 Binary files /dev/null and b/bin/cust/com/rac/changename/ChangeNameHandler.class differ diff --git a/bin/cust/com/rac/integration/AccepComHandler.class b/bin/cust/com/rac/integration/AccepComHandler.class new file mode 100644 index 0000000..3e247b8 Binary files /dev/null and b/bin/cust/com/rac/integration/AccepComHandler.class differ diff --git a/bin/cust/com/rac/integration/DeliveryApplicationHandler.class b/bin/cust/com/rac/integration/DeliveryApplicationHandler.class new file mode 100644 index 0000000..18ed1a1 Binary files /dev/null and b/bin/cust/com/rac/integration/DeliveryApplicationHandler.class differ diff --git a/bin/cust/com/rac/integration/InterationOperation.class b/bin/cust/com/rac/integration/InterationOperation.class new file mode 100644 index 0000000..bca4cdc Binary files /dev/null and b/bin/cust/com/rac/integration/InterationOperation.class differ diff --git a/bin/cust/com/rac/integration/ProjectPlanHandler.class b/bin/cust/com/rac/integration/ProjectPlanHandler.class new file mode 100644 index 0000000..8d4838f Binary files /dev/null and b/bin/cust/com/rac/integration/ProjectPlanHandler.class differ diff --git a/bin/cust/com/rac/integration/QuotationListHandler.class b/bin/cust/com/rac/integration/QuotationListHandler.class new file mode 100644 index 0000000..738395a Binary files /dev/null and b/bin/cust/com/rac/integration/QuotationListHandler.class differ diff --git a/bin/cust/com/rac/integration/RequestServer.class b/bin/cust/com/rac/integration/RequestServer.class new file mode 100644 index 0000000..c3ee661 Binary files /dev/null and b/bin/cust/com/rac/integration/RequestServer.class differ diff --git a/bin/cust/com/rac/integration/UnicodeInputStream.class b/bin/cust/com/rac/integration/UnicodeInputStream.class new file mode 100644 index 0000000..3410c69 Binary files /dev/null and b/bin/cust/com/rac/integration/UnicodeInputStream.class differ diff --git a/bin/cust/com/rac/integration/XMLDocAPI.class b/bin/cust/com/rac/integration/XMLDocAPI.class new file mode 100644 index 0000000..02ed02b Binary files /dev/null and b/bin/cust/com/rac/integration/XMLDocAPI.class differ diff --git a/bin/cust/com/rac/integration/test.class b/bin/cust/com/rac/integration/test.class new file mode 100644 index 0000000..e9b663f Binary files /dev/null and b/bin/cust/com/rac/integration/test.class differ diff --git a/bin/cust/com/rac/workflow/ComparatorTask.class b/bin/cust/com/rac/workflow/ComparatorTask.class new file mode 100644 index 0000000..b707d1c Binary files /dev/null and b/bin/cust/com/rac/workflow/ComparatorTask.class differ diff --git a/bin/cust/com/rac/workflow/CustAddReleaseHandler.class b/bin/cust/com/rac/workflow/CustAddReleaseHandler.class new file mode 100644 index 0000000..8780942 Binary files /dev/null and b/bin/cust/com/rac/workflow/CustAddReleaseHandler.class differ diff --git a/bin/cust/com/rac/workflow/CustRemoveReleaseHandler.class b/bin/cust/com/rac/workflow/CustRemoveReleaseHandler.class new file mode 100644 index 0000000..228f501 Binary files /dev/null and b/bin/cust/com/rac/workflow/CustRemoveReleaseHandler.class differ diff --git a/bin/cust/com/rac/workflow/ExportSearchResult.class b/bin/cust/com/rac/workflow/ExportSearchResult.class new file mode 100644 index 0000000..6f4a23d Binary files /dev/null and b/bin/cust/com/rac/workflow/ExportSearchResult.class differ diff --git a/bin/cust/com/rac/workflow/PackExcelInfo.class b/bin/cust/com/rac/workflow/PackExcelInfo.class new file mode 100644 index 0000000..042322f Binary files /dev/null and b/bin/cust/com/rac/workflow/PackExcelInfo.class differ diff --git a/bin/cust/com/rac/workflow/QueryTaskOpinionCommand.class b/bin/cust/com/rac/workflow/QueryTaskOpinionCommand.class new file mode 100644 index 0000000..45355b7 Binary files /dev/null and b/bin/cust/com/rac/workflow/QueryTaskOpinionCommand.class differ diff --git a/bin/cust/com/rac/workflow/QueryTaskOpinionHandler.class b/bin/cust/com/rac/workflow/QueryTaskOpinionHandler.class new file mode 100644 index 0000000..b1e8b69 Binary files /dev/null and b/bin/cust/com/rac/workflow/QueryTaskOpinionHandler.class differ diff --git a/bin/cust/com/rac/workflow/QueryTaskOpinionOperation$SignInfo.class b/bin/cust/com/rac/workflow/QueryTaskOpinionOperation$SignInfo.class new file mode 100644 index 0000000..75f6ea5 Binary files /dev/null and b/bin/cust/com/rac/workflow/QueryTaskOpinionOperation$SignInfo.class differ diff --git a/bin/cust/com/rac/workflow/QueryTaskOpinionOperation.class b/bin/cust/com/rac/workflow/QueryTaskOpinionOperation.class new file mode 100644 index 0000000..5b517c6 Binary files /dev/null and b/bin/cust/com/rac/workflow/QueryTaskOpinionOperation.class differ diff --git a/bin/cust/com/rac/workflow/QueryTaskProcessCommand$1.class b/bin/cust/com/rac/workflow/QueryTaskProcessCommand$1.class new file mode 100644 index 0000000..f960a86 Binary files /dev/null and b/bin/cust/com/rac/workflow/QueryTaskProcessCommand$1.class differ diff --git a/bin/cust/com/rac/workflow/QueryTaskProcessCommand.class b/bin/cust/com/rac/workflow/QueryTaskProcessCommand.class new file mode 100644 index 0000000..ee99832 Binary files /dev/null and b/bin/cust/com/rac/workflow/QueryTaskProcessCommand.class differ diff --git a/bin/cust/com/rac/workflow/QueryTaskProcessHandler.class b/bin/cust/com/rac/workflow/QueryTaskProcessHandler.class new file mode 100644 index 0000000..7e51dae Binary files /dev/null and b/bin/cust/com/rac/workflow/QueryTaskProcessHandler.class differ diff --git a/bin/cust/com/rac/workflow/SearchResultDialog$1.class b/bin/cust/com/rac/workflow/SearchResultDialog$1.class new file mode 100644 index 0000000..9df1601 Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchResultDialog$1.class differ diff --git a/bin/cust/com/rac/workflow/SearchResultDialog$SearchResults.class b/bin/cust/com/rac/workflow/SearchResultDialog$SearchResults.class new file mode 100644 index 0000000..3e1db61 Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchResultDialog$SearchResults.class differ diff --git a/bin/cust/com/rac/workflow/SearchResultDialog$buttonListener.class b/bin/cust/com/rac/workflow/SearchResultDialog$buttonListener.class new file mode 100644 index 0000000..baae678 Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchResultDialog$buttonListener.class differ diff --git a/bin/cust/com/rac/workflow/SearchResultDialog.class b/bin/cust/com/rac/workflow/SearchResultDialog.class new file mode 100644 index 0000000..86c209d Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchResultDialog.class differ diff --git a/bin/cust/com/rac/workflow/SearchResultTableModel.class b/bin/cust/com/rac/workflow/SearchResultTableModel.class new file mode 100644 index 0000000..a9357fd Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchResultTableModel.class differ diff --git a/bin/cust/com/rac/workflow/SearchTaskDialog$1.class b/bin/cust/com/rac/workflow/SearchTaskDialog$1.class new file mode 100644 index 0000000..c9a4253 Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchTaskDialog$1.class differ diff --git a/bin/cust/com/rac/workflow/SearchTaskDialog$SearchCondition.class b/bin/cust/com/rac/workflow/SearchTaskDialog$SearchCondition.class new file mode 100644 index 0000000..8d0ac7d Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchTaskDialog$SearchCondition.class differ diff --git a/bin/cust/com/rac/workflow/SearchTaskDialog$buttonListener.class b/bin/cust/com/rac/workflow/SearchTaskDialog$buttonListener.class new file mode 100644 index 0000000..0284599 Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchTaskDialog$buttonListener.class differ diff --git a/bin/cust/com/rac/workflow/SearchTaskDialog.class b/bin/cust/com/rac/workflow/SearchTaskDialog.class new file mode 100644 index 0000000..43ffa0d Binary files /dev/null and b/bin/cust/com/rac/workflow/SearchTaskDialog.class differ diff --git a/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand$1.class b/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand$1.class new file mode 100644 index 0000000..5e46285 Binary files /dev/null and b/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand$1.class differ diff --git a/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand.class b/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand.class new file mode 100644 index 0000000..f0bc3a6 Binary files /dev/null and b/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand.class differ diff --git a/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowHandler.class b/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowHandler.class new file mode 100644 index 0000000..d848c08 Binary files /dev/null and b/bin/cust/com/rac/workflow/SubmitAttachmentInWorkflowHandler.class differ diff --git a/bin/cust/com/ysr/Activator.class b/bin/cust/com/ysr/Activator.class new file mode 100644 index 0000000..0afdccc Binary files /dev/null and b/bin/cust/com/ysr/Activator.class differ diff --git a/bin/cust/com/ysr/test.class b/bin/cust/com/ysr/test.class new file mode 100644 index 0000000..e1429b1 Binary files /dev/null and b/bin/cust/com/ysr/test.class differ diff --git a/bin/ysr/com/teamcenter/BPMTest.class b/bin/ysr/com/teamcenter/BPMTest.class new file mode 100644 index 0000000..3022352 Binary files /dev/null and b/bin/ysr/com/teamcenter/BPMTest.class differ diff --git a/bin/ysr/com/teamcenter/ObjectFactory.class b/bin/ysr/com/teamcenter/ObjectFactory.class new file mode 100644 index 0000000..ffded2d Binary files /dev/null and b/bin/ysr/com/teamcenter/ObjectFactory.class differ diff --git a/bin/ysr/com/teamcenter/SendAccepComToBPM.class b/bin/ysr/com/teamcenter/SendAccepComToBPM.class new file mode 100644 index 0000000..174d166 Binary files /dev/null and b/bin/ysr/com/teamcenter/SendAccepComToBPM.class differ diff --git a/bin/ysr/com/teamcenter/SendAccepComToBPMResponse.class b/bin/ysr/com/teamcenter/SendAccepComToBPMResponse.class new file mode 100644 index 0000000..d2bdd6d Binary files /dev/null and b/bin/ysr/com/teamcenter/SendAccepComToBPMResponse.class differ diff --git a/bin/ysr/com/teamcenter/SendAccepComToPLM.class b/bin/ysr/com/teamcenter/SendAccepComToPLM.class new file mode 100644 index 0000000..0ee3ae9 Binary files /dev/null and b/bin/ysr/com/teamcenter/SendAccepComToPLM.class differ diff --git a/bin/ysr/com/teamcenter/SendAccepComToPLMResponse.class b/bin/ysr/com/teamcenter/SendAccepComToPLMResponse.class new file mode 100644 index 0000000..6bd6d5e Binary files /dev/null and b/bin/ysr/com/teamcenter/SendAccepComToPLMResponse.class differ diff --git a/bin/ysr/com/teamcenter/SendDeliveryDateToPLM.class b/bin/ysr/com/teamcenter/SendDeliveryDateToPLM.class new file mode 100644 index 0000000..5a4db9c Binary files /dev/null and b/bin/ysr/com/teamcenter/SendDeliveryDateToPLM.class differ diff --git a/bin/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.class b/bin/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.class new file mode 100644 index 0000000..d6aab59 Binary files /dev/null and b/bin/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.class differ diff --git a/bin/ysr/com/teamcenter/SendOrderNoticeToPLM.class b/bin/ysr/com/teamcenter/SendOrderNoticeToPLM.class new file mode 100644 index 0000000..c0f249a Binary files /dev/null and b/bin/ysr/com/teamcenter/SendOrderNoticeToPLM.class differ diff --git a/bin/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.class b/bin/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.class new file mode 100644 index 0000000..f394d35 Binary files /dev/null and b/bin/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.class differ diff --git a/bin/ysr/com/teamcenter/SendPStartNotificationToPLM.class b/bin/ysr/com/teamcenter/SendPStartNotificationToPLM.class new file mode 100644 index 0000000..8a4f51e Binary files /dev/null and b/bin/ysr/com/teamcenter/SendPStartNotificationToPLM.class differ diff --git a/bin/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.class b/bin/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.class new file mode 100644 index 0000000..14b62c5 Binary files /dev/null and b/bin/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.class differ diff --git a/bin/ysr/com/teamcenter/SendQuotationToPLM.class b/bin/ysr/com/teamcenter/SendQuotationToPLM.class new file mode 100644 index 0000000..163252b Binary files /dev/null and b/bin/ysr/com/teamcenter/SendQuotationToPLM.class differ diff --git a/bin/ysr/com/teamcenter/SendQuotationToPLMResponse.class b/bin/ysr/com/teamcenter/SendQuotationToPLMResponse.class new file mode 100644 index 0000000..b68e3ae Binary files /dev/null and b/bin/ysr/com/teamcenter/SendQuotationToPLMResponse.class differ diff --git a/bin/ysr/com/teamcenter/SendTravelOrderToPLM.class b/bin/ysr/com/teamcenter/SendTravelOrderToPLM.class new file mode 100644 index 0000000..ea9b6d4 Binary files /dev/null and b/bin/ysr/com/teamcenter/SendTravelOrderToPLM.class differ diff --git a/bin/ysr/com/teamcenter/SendTravelOrderToPLMResponse.class b/bin/ysr/com/teamcenter/SendTravelOrderToPLMResponse.class new file mode 100644 index 0000000..58aa1bb Binary files /dev/null and b/bin/ysr/com/teamcenter/SendTravelOrderToPLMResponse.class differ diff --git a/bin/ysr/com/teamcenter/YSRServerDelegate.class b/bin/ysr/com/teamcenter/YSRServerDelegate.class new file mode 100644 index 0000000..bee18a9 Binary files /dev/null and b/bin/ysr/com/teamcenter/YSRServerDelegate.class differ diff --git a/bin/ysr/com/teamcenter/YSRServerService.class b/bin/ysr/com/teamcenter/YSRServerService.class new file mode 100644 index 0000000..cf4153c Binary files /dev/null and b/bin/ysr/com/teamcenter/YSRServerService.class differ diff --git a/bin/ysr/com/teamcenter/package-info.class b/bin/ysr/com/teamcenter/package-info.class new file mode 100644 index 0000000..5678b94 Binary files /dev/null and b/bin/ysr/com/teamcenter/package-info.class differ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..6377a88 --- /dev/null +++ b/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + plugin_zh_CN.properties,\ + plugin.properties diff --git a/jxl.jar b/jxl.jar new file mode 100644 index 0000000..b210c06 Binary files /dev/null and b/jxl.jar differ diff --git a/plugin.properties b/plugin.properties new file mode 100644 index 0000000..785d3b8 --- /dev/null +++ b/plugin.properties @@ -0,0 +1,2 @@ +custYSR=CUST YSR +CreatePorjectFolder=Create Porject Folder \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..3afe8d5 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,558 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugin_zh_CN.properties b/plugin_zh_CN.properties new file mode 100644 index 0000000..9ae2c16 --- /dev/null +++ b/plugin_zh_CN.properties @@ -0,0 +1,18 @@ +custYSR=\u5BA2\u6237\u5316\u83DC\u5355 +batchimport=\u6279\u91CF\u5BFC\u5165 +ImportBatchFileHandler=\u6279\u91CF\u5BFC\u5165\u5230\u6570\u636E\u96C6\u7248\u672C +ImportBatchDirectoryHandler=Windows\u76EE\u5F55\u53CA\u6587\u4EF6\u5BFC\u5165 +batchdownload=\u6279\u91CF\u4E0B\u8F7D +BatchDownLoadFileHandler=\u6587\u4EF6\u6279\u91CF\u4E0B\u8F7D +CreatePorjectFolder=\u521B\u5EFA\u9879\u76EE\u6587\u4EF6\u5939 +ItemRename=\u91CD\u547D\u540D +QueryTaskOpinionHandler=\u67E5\u8BE2\u5BA1\u6279\u610F\u89C1 +QueryTaskProcessHandler=\u67E5\u8BE2\u4EFB\u52A1\u6D41\u7A0B +BOMTransPlan=BOM\u8F6C\u8BA1\u5212 +ProjectPlan=\u9879\u76EE\u8BA1\u5212\u4F20\u9012 +DeliveryApplication=\u53D1\u8D27\u7533\u8BF7\u4F20\u9012 +AccepCom=\u9A8C\u6536\u59D4\u6258\u63A5\u53E3 +QuotationList=\u62A5\u4EF7\u6E05\u5355\u4F20\u9012 +CreateFolderFromTemplate=\u521B\u5EFA\u5E38\u89C4\u6587\u4EF6\u5939\u7ED3\u6784 +ModifyTaskorDeliveryName=\u6279\u91CF\u66F4\u6539\u65F6\u95F4\u8868\u4EFB\u52A1\u6216\u4EA4\u4ED8\u7269 +PurchasingDepartmentSearch=\u91C7\u8D2D\u79D1\u5230\u8D27\u4EFB\u52A1\u67E5\u8BE2 \ No newline at end of file diff --git a/src/cn/com/customization/create/CreateFolderFromTemplateCommand.java b/src/cn/com/customization/create/CreateFolderFromTemplateCommand.java new file mode 100644 index 0000000..edae2a6 --- /dev/null +++ b/src/cn/com/customization/create/CreateFolderFromTemplateCommand.java @@ -0,0 +1,19 @@ +package cn.com.customization.create; + + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class CreateFolderFromTemplateCommand extends AbstractAIFCommand { + AbstractAIFUIApplication app; + public CreateFolderFromTemplateCommand( + AbstractAIFUIApplication abstractaifuiapplication, String string) { + super(); + this.app = abstractaifuiapplication; + System.out.println("2" + "\nݽString=" + string); + new CreateFolderFromTemplateDialog(AIFUtility.getActiveDesktop().getFrame(), app); + + } + +} diff --git a/src/cn/com/customization/create/CreateFolderFromTemplateDialog.java b/src/cn/com/customization/create/CreateFolderFromTemplateDialog.java new file mode 100644 index 0000000..88c23e8 --- /dev/null +++ b/src/cn/com/customization/create/CreateFolderFromTemplateDialog.java @@ -0,0 +1,348 @@ +package cn.com.customization.create; + +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; + +import org.apache.log4j.Logger; + +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.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * ļиƶԻ + * + * @author + */ +@SuppressWarnings("serial") +public class CreateFolderFromTemplateDialog extends AbstractAIFDialog { + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(CreateFolderFromTemplateDialog.class); + + private TCSession session; + + private TCComponent tcTargets[]; + + @SuppressWarnings("rawtypes") + private JList jlist; + + private TCTypeService tctypeservice; + + private TCComponentFolder selectedFolder = null; + + private AbstractAIFApplication app = null; + + public CreateFolderFromTemplateDialog(Frame parent, AbstractAIFApplication papp) { + super(parent, true); + app = papp; + session = (TCSession) papp.getSession(); + int flag = checkTargets(); + if (flag == 0) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + initDialog(); + } + }); + + } + + // } else if (flag == 1) { + // + // MessageBox.post("ѡȷĿ", "ʾ", 2); + // } else if (flag == 2) { + // + // MessageBox.post("ûжѡĿдȨޣ", "ʾ", 2); + // } else if (flag == 3) { + // + // MessageBox.post("ѡĿ", "ʾ", 2); + // } + } + + /* + * ʼ + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void initDialog() { + this.setTitle("ļнṹ"); + JPanel mainPanel = new JPanel(new PropertyLayout()); + this.getContentPane().add(mainPanel); + JPanel listPanel = new JPanel(); + TCComponent[] tccoms = getTemplateFolder(); + // String str[]={"111","2222"}; + jlist = new JList(tccoms); + jlist.setSelectionMode(0); + JScrollPane jListScrollPane = new JScrollPane(jlist); + jListScrollPane.setPreferredSize(new Dimension(380, 150)); + jlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listPanel.add(jListScrollPane); + + JPanel botPanel = new JPanel(); + botPanel.setLayout(new ButtonLayout(ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 10)); + JButton ok_button = new JButton("ʼ"); + ok_button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + action(e); + } + + }); + + JButton cannel_button = new JButton("ȡ"); + cannel_button.setActionCommand("ȡ"); + cannel_button.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + action(e); + + } + + }); + botPanel.add(ok_button); + botPanel.add(cannel_button); + JLabel jl1 = new JLabel("ѡҪƵļ"); + + mainPanel.add("1.1.center.center", jl1); + mainPanel.add("2.1.center.center", listPanel); + mainPanel.add("3.1.center.center", botPanel); + this.pack(); + this.centerToScreen(); + this.setVisible(true); + + } + + @SuppressWarnings("deprecation") + public void action(ActionEvent e) { + if (logger.isDebugEnabled()) { + logger.debug("actionPerformed(ActionEvent) - start"); //$NON-NLS-1$ + } + + if (e.getActionCommand().equals("ʼ")) { + Object[] values = jlist.getSelectedValues(); + try { + int number = values.length; + if (number > 0) { + + TCComponentFolder model_root_folder = (TCComponentFolder) jlist.getSelectedValue(); + System.out.println("model_root_folder" + model_root_folder); + + tctypeservice = session.getTypeService(); + if (logger.isInfoEnabled()) { + logger.info("actionPerformed(ActionEvent) - TCTypeService tctypeservice=" + tctypeservice); //$NON-NLS-1$ + } + + // ʼfolder + System.out.println("ʼĿĿ¼ļ"); + // createFolder(model_root_folder, this.selectedFolder); + AIFComponentContext aif[] = model_root_folder.getChildren(); + + for (int i = 0; i < aif.length; i++) { + InterfaceAIFComponent inter = aif[i].getComponent(); + + if (inter instanceof TCComponentFolder) { + + TCComponentFolder srcsubf = (TCComponentFolder) inter; + createFolder(srcsubf, this.selectedFolder, ""); + } + } + } else { + MessageBox.post("ûѡκģ", "ʾ", 2); + + if (logger.isDebugEnabled()) { + logger.debug("actionPerformed(ActionEvent) - end"); //$NON-NLS-1$ + } + return; + } + } catch (Exception e1) { + logger.error("actionPerformed(ActionEvent)", e1); //$NON-NLS-1$ + + e1.printStackTrace(); + } + + dispose(); + } else if (e.getActionCommand().equals("ȡ")) { + + dispose(); + } + + if (logger.isDebugEnabled()) { + logger.debug("actionPerformed(ActionEvent) - end"); //$NON-NLS-1$ + } + } + + /* + * ѡеǷ + */ + private int checkTargets() { + if (logger.isDebugEnabled()) { + logger.debug("checkTargets() - start"); //$NON-NLS-1$ + } + + int flag = 0; + AIFComponentContext aifcomponentcontext[] = app.getTargetContexts(); + if (aifcomponentcontext != null && aifcomponentcontext.length >= 0) { + tcTargets = new TCComponent[aifcomponentcontext.length]; + for (int i = 0; i < aifcomponentcontext.length; i++) { + tcTargets[i] = (TCComponent) aifcomponentcontext[i].getComponent(); + System.out.println("tcTargets[i]===" + tcTargets[i]); + } + selectedFolder = (TCComponentFolder) tcTargets[0]; + try { + if (!checkAccessPrivilige(session.getUser(), tcTargets[0], "WRITE")) { + flag = 2; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + flag = 3; + } + + if (logger.isDebugEnabled()) { + logger.debug("checkTargets() - end"); //$NON-NLS-1$ + } + return flag; + } + + /** + * ûָǷijȨ + * + * @param user + * û + * @param comp + * + * @param accessName + * Ȩ + * @return ǷȨ + * @throws TCException + */ + private boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + if (logger.isDebugEnabled()) { + logger.debug("checkAccessPrivilige(TCComponentUser, TCComponent, String) - start"); //$NON-NLS-1$ + } + + if (logger.isInfoEnabled()) { + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - TCComponentUser user=" + user); //$NON-NLS-1$ + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - TCComponentUser comp=" + comp); //$NON-NLS-1$ + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - TCComponentUser accessName=" + accessName); //$NON-NLS-1$ + } + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + if (logger.isInfoEnabled()) { + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - TCAccessControlService accessService=" + accessService); //$NON-NLS-1$ + } + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + if (logger.isInfoEnabled()) { + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - boolean returnboolean=" + returnboolean); //$NON-NLS-1$ + } + + if (logger.isDebugEnabled()) { + logger.debug("checkAccessPrivilige(TCComponentUser, TCComponent, String) - end"); //$NON-NLS-1$ + } + return returnboolean; + } + + // ģ + public TCComponentFolder[] getTemplateFolder() { + TCComponentFolder[] result = null; + try { + String str_key = "Type"; + String str_value = "YSR8_SDFolder"; + String str_key2 = "OwningUser"; + String str_value2 = "infodba"; + + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find("..."); + querytype.clearCache(); + String as[] = new String[2]; + String as1[] = new String[2]; + as[0] = textService.getTextValue(str_key); + as1[0] = str_value; + as[1] = textService.getTextValue(str_key2); + as1[1] = str_value2; + query.clearCache(); + System.out.println("query " + query); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + + if (list != null) { + int count = list.getListCount(); + System.out.println(" folder coutn " + count); + result = new TCComponentFolder[count]; + for (int i = 0; i < count; i++) { + result[i] = (TCComponentFolder) list.get(i).getComponent(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return result; + } + + /* + * ģݹѭͬĿ¼ṹ + */ + public void createFolder(TCComponentFolder srcrootf, TCComponentFolder targetrootf, String foldername) { + + try { + String subf_name = ""; + String object_desc = ""; + if (foldername.equals("")) { + subf_name = srcrootf.getProperty("object_name"); + object_desc = srcrootf.getProperty("object_desc"); + } else { + subf_name = foldername; + object_desc = selectedFolder.getProperty("object_desc"); + } + // System.out.println("subf_name "+subf_name); + TCComponentFolderType foldertype = (TCComponentFolderType) tctypeservice.getTypeComponent("Folder"); + TCComponentFolder subfolder = foldertype.create(subf_name, "", "Folder"); + subfolder.setProperty("object_desc", object_desc); + targetrootf.add("contents", subfolder); + + AIFComponentContext aif[] = srcrootf.getChildren(); + + for (int i = 0; i < aif.length; i++) { + InterfaceAIFComponent inter = aif[i].getComponent(); + + if (inter instanceof TCComponentFolder) { + + TCComponentFolder srcsubf = (TCComponentFolder) inter; + createFolder(srcsubf, subfolder, ""); + } + } + } catch (TCException e) { + logger.error("createFolder(TCComponentFolder, TCComponentFolder)", e); //$NON-NLS-1$ + e.printStackTrace(); + } + + } +} diff --git a/src/cn/com/customization/create/CreateFolderFromTemplateHandler.java b/src/cn/com/customization/create/CreateFolderFromTemplateHandler.java new file mode 100644 index 0000000..c1831ab --- /dev/null +++ b/src/cn/com/customization/create/CreateFolderFromTemplateHandler.java @@ -0,0 +1,21 @@ +package cn.com.customization.create; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +//ļнṹ +public class CreateFolderFromTemplateHandler extends AbstractHandler implements IHandler{ + + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new CreateFolderFromTemplateCommand(app,"CreateFolderFromTemplateHandler"); + return null; + } + +} diff --git a/src/cn/com/customization/download/BatchDownLoadFileCommand.java b/src/cn/com/customization/download/BatchDownLoadFileCommand.java new file mode 100644 index 0000000..7f09827 --- /dev/null +++ b/src/cn/com/customization/download/BatchDownLoadFileCommand.java @@ -0,0 +1,64 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: BatchDownLoadFileCommand.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-4-20 16:05 liqz Ini ļCommand +#======================================================================================================= +*/ +package cn.com.customization.download; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class BatchDownLoadFileCommand extends AbstractAIFCommand { + + private AbstractAIFUIApplication application; + private TCSession session; + public BatchDownLoadFileCommand(AbstractAIFUIApplication abstractaifapplication) throws TCException { + application = abstractaifapplication; + session = (TCSession)application.getSession(); + execute(); + } + + private void execute() throws TCException { + try { + final InterfaceAIFComponent targetCom = application.getTargetComponent(); + if (targetCom != null) { + String strType = targetCom.getType(); + System.out.println("targetCom.type============" + strType); + //String name = targetCom.toString().trim(); + System.out.println("targetCom.toString============" + targetCom.toString()); + if (strType.equals("TasksToPerform") || targetCom instanceof TCComponentFolder || targetCom instanceof TCComponentPseudoFolder || targetCom instanceof TCComponentItemRevision || targetCom instanceof TCComponentTask || targetCom instanceof TCComponentItem) { + System.out.println("ʼ..."); + DatasetFileDown filedown = new DatasetFileDown(application, session, targetCom, false); + //-*-*- 10.1Ķ + new Thread(filedown).start(); + //new Thread((Runnable) filedown).start(); + } else { + MessageBox.post("ѡĶͲȷ", "WARNING", 1); + return; + } + } else { + MessageBox.post("ѡ", "WARNING", 1); + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/cn/com/customization/download/BatchDownLoadFileCommand2.java b/src/cn/com/customization/download/BatchDownLoadFileCommand2.java new file mode 100644 index 0000000..cef5643 --- /dev/null +++ b/src/cn/com/customization/download/BatchDownLoadFileCommand2.java @@ -0,0 +1,65 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: BatchDownLoadFileCommand.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-4-20 16:05 liqz Ini ļCommand +#======================================================================================================= +*/ +package cn.com.customization.download; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class BatchDownLoadFileCommand2 extends AbstractAIFCommand { + + private AbstractAIFUIApplication application; + private TCSession session; + public BatchDownLoadFileCommand2(AbstractAIFUIApplication abstractaifapplication) throws TCException { + application = abstractaifapplication; + session = (TCSession)application.getSession(); + execute(); + } + + private void execute() throws TCException { + try { + final InterfaceAIFComponent targetCom = application.getTargetComponent(); + if (targetCom != null) { + String strType = targetCom.getType(); + System.out.println("targetCom.type============" + strType); +// String name = targetCom.toString().trim(); + System.out.println("targetCom.toString============" + targetCom.toString()); + if (targetCom instanceof TCComponentTask || targetCom instanceof TCComponentFolder || targetCom instanceof TCComponentPseudoFolder || + targetCom instanceof TCComponentItem || + targetCom instanceof TCComponentItemRevision) { + DatasetFileDown2 filedown = new DatasetFileDown2(application, session, targetCom); + //-*-*- 10.1Ķ + //new Thread((Runnable) filedown).start(); + new Thread(filedown).start(); + } else { + MessageBox.post("ѡĶͲȷ", "WARNING", 1); + return; + } + } else { + MessageBox.post("ѡ", "WARNING", 1); + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/cn/com/customization/download/BatchDownLoadFileHandler.java b/src/cn/com/customization/download/BatchDownLoadFileHandler.java new file mode 100644 index 0000000..94afda3 --- /dev/null +++ b/src/cn/com/customization/download/BatchDownLoadFileHandler.java @@ -0,0 +1,43 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: BatchDownLoadFileHandler.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2017-5-20 15:50 SZ Ini ļHandler +#======================================================================================================= +*/ +package cn.com.customization.download; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class BatchDownLoadFileHandler extends AbstractHandler implements IHandler{ + + /* + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + BatchDownLoadFileCommand command= new BatchDownLoadFileCommand(app); + command.executeModal(); + } + catch (TCException e) { + e.printStackTrace(); + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cn/com/customization/download/BatchDownLoadFileHandler2.java b/src/cn/com/customization/download/BatchDownLoadFileHandler2.java new file mode 100644 index 0000000..44a5bc2 --- /dev/null +++ b/src/cn/com/customization/download/BatchDownLoadFileHandler2.java @@ -0,0 +1,43 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: BatchDownLoadFileHandler.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2017-5-20 15:50 SZ Ini ļHandler +#======================================================================================================= +*/ +package cn.com.customization.download; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class BatchDownLoadFileHandler2 extends AbstractHandler implements IHandler{ + + /* + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + BatchDownLoadFileCommand2 command = new BatchDownLoadFileCommand2(app); + command.executeModal(); + } + catch (TCException e) { + e.printStackTrace(); + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cn/com/customization/download/DatasetFileDown.java b/src/cn/com/customization/download/DatasetFileDown.java new file mode 100644 index 0000000..53ed365 --- /dev/null +++ b/src/cn/com/customization/download/DatasetFileDown.java @@ -0,0 +1,795 @@ +/* +#============================================================================= +# +# copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: DatasetFileDown.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz ݼ(From Shaangu) +# 2011-5-19 liqz ޸ δݼļµݼҲ +#============================================================================= + */ +package cn.com.customization.download; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ConfirmationDialog; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.customization.imports.importfiles.ORProgressBarThread; +import cn.com.customization.util.GetCommonInfo; +import cn.com.customization.util.PackFailDownInfo; +import cn.com.customization.util.PackResultInfo; +import cn.com.customization.util.PackSuccessfulInfo; +import cn.com.customization.util.ResultDialog; +import cn.com.customization.util.ShowMessageDialog; +import cn.com.customization.util.UtilApi; +import cn.com.customization.util.WriteAndCopyFile; + +@SuppressWarnings("deprecation") +public class DatasetFileDown extends AbstractAIFOperation implements Runnable { + private TCSession session = null; + private InterfaceAIFComponent targetComponent = null; + private ORProgressBarThread progressbarthread = null; + private GetCommonInfo checkcommon; + private String path = ""; + private int downDataSetCount = 0; + private int isNotHavePriviligeCount = 0; + private int haveEqualDataSetCount = 0; + private String validTypeOption = "CUST_batchdown_validtype"; + // origin_showLogFileеֵΪtrue־ļc:\\batchExportDataset.log + private String isShowLogOption = "CUST_showLogFile"; + private int notReleasedDataSetCount = 0; + private boolean isDownReleased = false; + private List haveDownDataSet = null; + private WriteAndCopyFile writeLog; + private String logFileName = "c:/batchExportDataset.log"; + private List notExistFiles = new ArrayList(); + private int downCount = 0; + private List failDownInfos = new ArrayList(); + private int needDownCount = 0; + private List successfulInfos = new ArrayList(); + private String currentJob = ""; + private String successfulDir = System.getenv("temp");//"c:/ugs/log"; + private boolean isShiftProcessDown; + private String changePackageName = "ĵ"; + private String technologyPackageName = "ļ"; + + //private TCUserService userService = null; + private List logsList = new ArrayList(); + private boolean isContainsGGD = false; + private boolean isContainsTechnologyItem = false; + + public DatasetFileDown(AbstractAIFApplication application, TCSession tcsession, InterfaceAIFComponent targetCom, boolean isShiftProcessDown) { + checkcommon = new GetCommonInfo(tcsession); + session = tcsession; + targetComponent = targetCom; + writeLog = new WriteAndCopyFile(); + this.isShiftProcessDown = isShiftProcessDown; + + //userService = (TCUserService) session.getUserService(); + + File dir = new File(successfulDir); + if (!dir.exists()) { + dir.mkdir(); + } + if (isShowLog()) { + File file = new File(logFileName); + if (file.exists()) { + writeLog.writeFile(logFileName, false, "\r\n"); + } else { + try { + file.createNewFile(); + writeLog.writeFile(logFileName, false, "\r\n"); + } catch (IOException e) { + e.printStackTrace(); + } + } + } else { + File file = new File(logFileName); + if (file.exists()) { + file.delete(); + } + } + } + + private void writeLogFile(String fileName, String content) { + if (isShowLog()) { + content = content + "\r\n"; + writeLog.writeFile(fileName, true, content); + } + } + + private void writeSuccessfulLogFile(String fileName, String content) { + content = content + "\r\n"; + writeLog.writeFile(fileName, true, content); + logsList.add(content); + } + + public String getTime() { + String strTime = ""; + try { + SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss:SSS"); + strTime = bartDateFormat.format(new Date()); + // System.out.println(strTime); + } catch (Exception e) { + e.printStackTrace(); + } + return strTime; + } + + @Override + public void executeOperation() throws Exception { + System.out.println("Begin to call filedown operation..."); + String cuurentPath = checkcommon.getChoosePath(); + path = cuurentPath; + isDownReleased = false; + isDownReleased(); + haveDownDataSet = new ArrayList(); + if ((cuurentPath != null) && (cuurentPath.length() == 0)) { + return; + } else { + if (checkcommon.isExistFiles(cuurentPath)) { + int value = ConfirmationDialog.post("ʾ","ָĿ¼·ǿգǷ?"); + if(value == ConfirmationDialog.NO){ + return; + } + } + } + try { + writeLogFile(logFileName, "ʼ: " + getTime()); + // writeLogFile("ѡ·Ϊ: " + cuurentPath, logFileName); + writeLogFile(logFileName, " "); + int importAll = 0; + + PackSuccessfulInfo succesfulDataset = new PackSuccessfulInfo(); + succesfulDataset.setIndex(""); + succesfulDataset.setItemID("ID"); + succesfulDataset.setItemRev("汾"); + succesfulDataset.setItemOwner(""); + succesfulDataset.setDataset("ݼ"); + succesfulDataset.setRefFile(""); + successfulInfos.add(succesfulDataset); + + if (targetComponent instanceof TCComponentItemRevision) { + progressbarthread = new ORProgressBarThread("ݼ......", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("..."); + getDataSetFromItemRevision((TCComponentItemRevision) targetComponent, cuurentPath); + } else { + if (targetComponent instanceof TCComponentDataset) { + return; + } else { + if (targetComponent instanceof TCComponentItem) { + progressbarthread = new ORProgressBarThread("ݼ......", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("..."); + getDataSetFromItem((TCComponentItem) targetComponent, cuurentPath); + } else { + if (targetComponent instanceof TCComponentFolder) { +// importAll = new GetMessageDialog("INFO", "Ƿ񵼳ļ?").getValue(); + importAll = ConfirmationDialog.post("ʾ","Ƿ񵼳ļ?"); + currentJob = ((TCComponentFolder) targetComponent).getProperty("object_name"); + System.out.println("TCComponentFolder===========" + targetComponent); + } else { + if (targetComponent instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) targetComponent; + // task.getName(); ǩ + TCComponentProcess process = task.getProcess(); + if (process != null) { + currentJob = process.toString(); // 000009/H;1-sgitem + System.out.println("targetComponent.currentJob()===========" + currentJob); + } + } + } + progressbarthread = new ORProgressBarThread("ݼ......", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("..."); + getTargetCom(targetComponent, cuurentPath, importAll); + } + } + } + session.setReadyStatus(); + progressbarthread.setBool(true); + + writeLogFile(logFileName, " "); + writeLogFile(logFileName, "ܽ᣺"); + writeLogFile(logFileName, "ݼ:" + haveDownDataSet.size() + ""); + writeLogFile(logFileName, "δݼ:" + notReleasedDataSetCount + ""); + writeLogFile(logFileName, "Ȩݼ:" + isNotHavePriviligeCount + ""); + writeLogFile(logFileName, "Ҫļ:" + needDownCount + ""); + writeLogFile(logFileName, "ɹļ:" + downDataSetCount + ""); + writeLogFile(logFileName, "ļݼ:" + notExistFiles.size() + ""); + writeLogFile(logFileName, "δɹļ:" + (needDownCount - downDataSetCount) + ""); + + PackResultInfo resultInfo = new PackResultInfo(); + SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd:HHmmss"); + String time = date.format(new Date()); + resultInfo.setTime(time); + resultInfo.setPerson(session.getUser().toString()); + resultInfo.setJob(currentJob); + + resultInfo.setExistDataSetCount(haveDownDataSet.size()); + resultInfo.setNeedNum(needDownCount); + resultInfo.setSuccessNum(downDataSetCount); + resultInfo.setNoReleasedNum(notReleasedDataSetCount); + resultInfo.setNoPrivilegelNum(isNotHavePriviligeCount); + resultInfo.setNoReferenceNum(notExistFiles.size()); + resultInfo.setEqualNameNum(haveEqualDataSetCount); + resultInfo.setFailNum((needDownCount - downDataSetCount)); + resultInfo.setFailDownInfo(failDownInfos); + + // ʱ䣺2010-06-15:8890 ˣXXXXXX, ѡ̣Ŀ¼XXXXXXXXXX + // ݼ:80 + // δݼ76 + // Ȩݼ0 + // ļ30 + // ɹļ80 + // ļݼ0 + + // δɹļб + // id 汾 ݼ + String logPath = successfulDir + "/ļ־_" + (new SimpleDateFormat("yyyyMMdd")).format(new Date()) + ".log"; + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "==========================================================================================================================="); + writeSuccessfulLogFile(logPath, "ʱ:" + time + " :" + session.getUser().toString() + " ѡ(Ŀ¼):" + currentJob); + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "ݼ:" + haveDownDataSet.size()); + writeSuccessfulLogFile(logPath, "δݼ:" + notReleasedDataSetCount); + writeSuccessfulLogFile(logPath, "Ȩݼ:" + isNotHavePriviligeCount); + writeSuccessfulLogFile(logPath, "ļ:" + needDownCount); + writeSuccessfulLogFile(logPath, "ɹļ:" + downDataSetCount); + writeSuccessfulLogFile(logPath, "ļݼ:" + notExistFiles.size()); + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "ѳɹļб:"); + writeSuccessfulLogFile(logPath, "---------------------------------------------------------------------------"); + for (int i = 0; i < successfulInfos.size(); i++) { + PackSuccessfulInfo successfulInfo = successfulInfos.get(i); + writeSuccessfulLogFile(logPath, appendSpace(successfulInfo.getIndex().trim(), 5) + appendSpace(successfulInfo.getItemID().trim(), 32) + appendSpace((successfulInfo.getItemRev() == null ? "" : successfulInfo.getItemRev().trim()), 5) + appendSpace(successfulInfo.getItemOwner().trim(), 25) + appendSpace(successfulInfo.getDataset().trim(), 50) + appendSpace(successfulInfo.getRefFile().trim(), 50)); + } + writeSuccessfulLogFile(logPath, " "); + // ־ remove by sz 2017-6-1 +// try { +// Object objs[] = new Object[1]; +// objs[0] = logsList.toArray(); +// userService.call("DatasetDownLog", objs); +// } catch (TCException e) { +// e.printStackTrace(); +// } + //end remove + if (haveDownDataSet.size() == 0) { + new ShowMessageDialog("Ϣʾ", "0ݼ", ""); + return; + } + new ResultDialog(resultInfo, session); + } catch (Exception e) { + session.setReadyStatus(); + if (progressbarthread != null) { + progressbarthread.setBool(true); + } + MessageBox.post("ݵ쳣:" + e.getMessage(), "ERROR", 1); + e.printStackTrace(); + } + } + + private String appendSpace(String str, int num) { + if (str.length() < num) { + for (int i = UtilApi.length(str) + 1; i <= num; i++) { + str += " "; + } + } + return str; + } + + private void getTargetType(InterfaceAIFComponent aif) { + isContainsGGD = false; + isContainsTechnologyItem = false; + try { + if (aif.getChildren() != null) { + AIFComponentContext[] getChild = aif.getChildren(); + if (getChild.length != 0) { + isContainsTechnologyItem = true; + int revCount = 0; + for (int i = 0; i < getChild.length; i++) { + InterfaceAIFComponent childComponent = getChild[i].getComponent(); + if (childComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) childComponent; + if (itemRevision != null) { + ++revCount; + String revType = itemRevision.getType(); + if (revType.equals("GGDitem Revision") || revType.equals("HTDitem Revision")) { + isContainsGGD = true; + isContainsTechnologyItem = false; + } else { + if (!revType.equals("ļ Revision")) { + isContainsTechnologyItem = false; + } + } + } + } + } + if (revCount == 0) { + isContainsTechnologyItem = false; + } + } + } + } catch (Exception e) { + session.setReadyStatus(); + progressbarthread.setBool(true); + MessageBox.post("ʱ:" + e.getMessage(), "ERROR", 1); + e.printStackTrace(); + } + } + + /** + * getTargetCom:õݼ + * @param @return 趨ļ + * @param aif + * @param cuurentPath ļҪ· + * @param importAll importAll=2ҪļУ1ֻǵһļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void getTargetCom(InterfaceAIFComponent aif, String cuurentPath, int importAll) { + if (aif.toString().equalsIgnoreCase("root_target_attachments") || aif.toString().equalsIgnoreCase("Ŀ")) { + System.out.println("aif=============" + aif); + getTargetType(aif); + if (isContainsGGD) { + cuurentPath = createFile(path, changePackageName); + } else { + if (isContainsTechnologyItem) { + cuurentPath = createFile(path, technologyPackageName); + } + } + } + System.out.println("cuurentPath=============" + cuurentPath); + try { + AIFComponentContext[] getChild = aif.getChildren(); + if (getChild.length != 0) { + for (int i = 0; i < getChild.length; i++) { + InterfaceAIFComponent childComponent = getChild[i].getComponent(); + if (childComponent instanceof TCComponentDataset) { + datasetFileDown((TCComponentDataset) childComponent, cuurentPath, null); + } else if (childComponent instanceof TCComponentTask) { + getTargetCom(childComponent, cuurentPath, importAll); + } else if (childComponent instanceof TCComponentItem) { + if (aif instanceof TCComponentPseudoFolder) { + TCComponentPseudoFolder psefolder1 = (TCComponentPseudoFolder) aif; + String objectString1 = psefolder1.getProperty("object_string"); + if ((objectString1.equalsIgnoreCase("root_target_attachments")) || (objectString1.equalsIgnoreCase("root_reference_attachments")) || (objectString1.equalsIgnoreCase("Ŀ")) || (objectString1.equalsIgnoreCase(""))) { + continue; + } + } + getDataSetFromItem((TCComponentItem) childComponent, cuurentPath); + } else if ((childComponent instanceof TCComponentFolder)) { + if (aif instanceof TCComponentPseudoFolder) { + TCComponentPseudoFolder psefolder1 = (TCComponentPseudoFolder) aif; + String objectString1 = psefolder1.getProperty("object_string"); + if ((objectString1.equalsIgnoreCase("root_target_attachments")) || (objectString1.equalsIgnoreCase("root_reference_attachments")) || (objectString1.equalsIgnoreCase("Ŀ")) || (objectString1.equalsIgnoreCase(""))) { + continue; + } + } +// if (!path.equalsIgnoreCase(cuurentPath)) { +// continue; +// } + File file = null; + if (importAll == 2) { + String folderName = childComponent.toString(); + List list = new ArrayList(); + list.add("\\"); + list.add("/"); + list.add(":"); + list.add("*"); + list.add("?"); + list.add("\""); + list.add("<"); + list.add(">"); + list.add("|"); + for (int j = 0; j < list.size(); j++) { + while (folderName.indexOf(list.get(j)) >= 0) { + folderName = folderName.replace(list.get(j), "_"); + } + } + file = new File(cuurentPath + "\\" + folderName); + if (!file.exists()) { + file.mkdir(); + } else { + file = new File(cuurentPath + "\\" + folderName + "_" + UtilApi.getTimeNum()); + file.mkdir(); + } + getTargetCom(childComponent, file.getAbsolutePath(), importAll); + } else { + continue; + } + } else if (childComponent instanceof TCComponentItemRevision) { + getDataSetFromItemRevision((TCComponentItemRevision) childComponent, cuurentPath); + } else { + if (childComponent instanceof TCComponentPseudoFolder) { + TCComponentPseudoFolder psefolder = (TCComponentPseudoFolder) childComponent; + String objectString = psefolder.getProperty("object_string"); + if (objectString.equalsIgnoreCase("root_target_attachments") || objectString.equalsIgnoreCase("Ŀ")) { + getTargetCom(childComponent, cuurentPath, importAll); + } + } + } + } + } + } catch (Exception e) { + session.setReadyStatus(); + progressbarthread.setBool(true); + MessageBox.post("ȡʱ쳣:" + e.getMessage(), "ERROR", 1); + e.printStackTrace(); + } + } + + /** + * getDataSetFromItemRevision:ͨ汾õݼ + * @param @return 趨ļ + * @param tcRevision + * @param cuurentPath ļҪ· + * @throws + * @since CodingExampleVer 1.1 + */ + private void getDataSetFromItemRevision(TCComponentItemRevision tcRevision, String cuurentPath) { + if (tcRevision == null) { + return; + } + try { + tcRevision.refresh(); + } catch (TCException e2) { + e2.printStackTrace(); + } + try { + TCComponent tccomps[] = tcRevision.getRelatedComponents("IMAN_specification"); + try { + String type = tcRevision.getType(); + String revision = tcRevision.getProperty("item_revision_id"); + + if (isShiftProcessDown) { + TCComponentProcess process = tcRevision.getCurrentJob(); + String processName = process.getRootTask().toString(); + // System.out.println("processName===============" + + // processName); + // System.out.println("type================" + type); + if (processName.startsWith("SG_ECR_") && (type.equals("GGDitem Revision"))) { + for (int i = 0; i < tccomps.length; i++) { + if (tccomps[i] instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) tccomps[i]; + if ((dataset.toString().contains("/" + revision + "/")) || (dataset.toString().contains("/" + revision))) { + datasetFileDown(dataset, cuurentPath, tcRevision); + } + } + } + } else { + if (processName.startsWith("SG_HTR_")) { + for (int i = 0; i < tccomps.length; i++) { + if (tccomps[i] instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) tccomps[i]; + if ((dataset.toString().contains("/" + revision + "/")) || (dataset.toString().contains("/" + revision))) { + datasetFileDown(dataset, cuurentPath, tcRevision); + } + } + } + } else { + for (int i = 0; i < tccomps.length; i++) { + if (tccomps[i] instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) tccomps[i]; + datasetFileDown(dataset, cuurentPath, tcRevision); + } + } + } + } + } else { + for (int i = 0; i < tccomps.length; i++) { + if (tccomps[i] instanceof TCComponentDataset) { + datasetFileDown((TCComponentDataset) tccomps[i], cuurentPath, tcRevision); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * getDataSetFromItem:ͨItemõݼ + * @param @return 趨ļ + * @param item + * @param cuurentPath ļҪ· + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void getDataSetFromItem(TCComponentItem item, String cuurentPath) { + TCComponentItemRevision tcRevision; + try { + item.refresh(); + } catch (TCException e2) { + e2.printStackTrace(); + } + try { + tcRevision = item.getLatestItemRevision(); + if (tcRevision == null) { + return; + } + try { + TCComponent tccomps[] = tcRevision.getRelatedComponents("IMAN_specification"); + for (int i = 0; i < tccomps.length; i++) { + if (tccomps[i] instanceof TCComponentDataset) { + datasetFileDown((TCComponentDataset) tccomps[i], cuurentPath, tcRevision); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + /** + * datasetFileDown:ݼļ + * @param @return 趨ļ + * @param dataset + * @param fileCurrentPath + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + + private void datasetFileDown(TCComponentDataset dataSet, String fileCurrentPath, TCComponentItemRevision itemRevision) { + try { + dataSet.refresh(); + } catch (TCException e2) { + e2.printStackTrace(); + } + if (haveDownDataSet != null) { + if (haveDownDataSet.contains(dataSet)) { + return; + } + } + // String fileCurrentPath = currentPath; + haveDownDataSet.add(dataSet); + PackFailDownInfo dataSetInfo = new PackFailDownInfo(); + try { + String itemID = ""; + String rev = ""; + if (itemRevision != null) { + itemID = itemRevision.getProperty("item_id"); + rev = itemRevision.getProperty("current_revision_id"); + } + String owner = dataSet.getProperty("owning_user"); + dataSetInfo.setOwner(owner); + dataSetInfo.setItemId(itemID); + dataSetInfo.setRev(rev); + dataSetInfo.setDatasetName(dataSet.toString()); + dataSetInfo.setDataSet(dataSet); + dataSetInfo.setItemRev(itemRevision); + } catch (TCException e3) { + writeLogFile(logFileName, e3.getMessage()); + e3.printStackTrace(); + } + + writeLogFile(logFileName, "ݼ:" + dataSet.toString()); + // System.out.println("dataSet............" + dataSet.toString()); + try { + String release = dataSet.getProperty("release_status_list").trim(); + if (release != null) { + // String regex = ".*Released.*"; + // Pattern pattern = Pattern.compile(regex, + // Pattern.CASE_INSENSITIVE); + // Matcher match = pattern.matcher(release); + // boolean find = match.find(); + if (release.length() == 0) { + notReleasedDataSetCount++; + writeLogFile(logFileName, "δ"); + if (isDownReleased) { + dataSetInfo.setReason("δ"); + failDownInfos.add(dataSetInfo); + writeLogFile(logFileName, ""); + return; + } + } else { + writeLogFile(logFileName, "Ѿ"); + } + } + } catch (TCException e2) { + e2.printStackTrace(); + } + try { + boolean isCanExport = false; + isCanExport = checkAccessPrivilige(session.getUser(), dataSet, "EXPORT"); + if (!isCanExport) { + ++isNotHavePriviligeCount; + dataSetInfo.setReason("ûеȨ"); + failDownInfos.add(dataSetInfo); + writeLogFile(logFileName, "ûеȨ"); + writeLogFile(logFileName, " "); + return; + } else { + writeLogFile(logFileName, "еȨ "); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + TCComponentTcFile tcFile = null; + String fileName = ""; + try { + if ((dataSet.getTcFiles() != null) && (dataSet.getTcFiles().length > 0)) { + for (int i = 0; i < dataSet.getTcFiles().length; i++) { + tcFile = dataSet.getTcFiles()[i]; + if (tcFile == null) { + return; + } + tcFile.refresh(); + fileName = tcFile.getProperty("original_file_name"); + if (fileName != null) { + needDownCount++; + dataSetInfo.setFilePath(fileCurrentPath); + dataSetInfo.setReference_file(fileName); + dataSetInfo.setNeedDown("true"); + String fileType = ""; + String preFileName = ""; + int index = fileName.lastIndexOf("."); + if (index > 0) { + fileType = fileName.substring(index, fileName.length()); + preFileName = fileName.substring(0, index); + } else { + preFileName = fileName; + } + boolean flag = checkcommon.existFile(fileCurrentPath, fileName); + if (flag) { + haveEqualDataSetCount++; + int pos = fileName.indexOf('.'); + if (pos > 0) { + fileName = preFileName + "_" + UtilApi.getTimeNum() + fileType; + } + } + if (fileName.indexOf('/') >= 0) { + fileName = fileName.replace('/', '_'); + } + downCount = 0; + getTCFile(tcFile, fileCurrentPath, fileName, dataSetInfo); + } + } + } else { + dataSetInfo.setReason("ļ"); + failDownInfos.add(dataSetInfo); + notExistFiles.add(dataSet.toString()); + writeLogFile(logFileName, "ļ"); + } + writeLogFile(logFileName, " "); + } catch (Throwable e) { + writeLogFile(logFileName, "ļʱ쳣"); + writeLogFile(logFileName, e.getMessage()); + writeLogFile(logFileName, " "); + e.printStackTrace(); + } + } + + private File getTCFile(TCComponentTcFile tcFile, String fileCurrentPath, String fileName, PackFailDownInfo dataSetInfo) { + ++downCount; + if (downCount == 2) { + writeLogFile(logFileName, "ڶ"); + } + File file = null; + try { + file = tcFile.getFile(fileCurrentPath, fileName); + if (file != null) { + ++downDataSetCount; + writeLogFile(logFileName, "ļ:" + fileName + " " + getTime()); + writeLogFile(logFileName, " "); + // successfulInfos + PackSuccessfulInfo succesfulDataset = new PackSuccessfulInfo(); + succesfulDataset.setIndex(String.valueOf(downDataSetCount)); + succesfulDataset.setItemID(dataSetInfo.getItemId()); + succesfulDataset.setItemRev(dataSetInfo.getRev()); + succesfulDataset.setItemOwner(dataSetInfo.getOwner()); + succesfulDataset.setDataset(dataSetInfo.getDatasetName()); + succesfulDataset.setRefFile(file.getName()); + successfulInfos.add(succesfulDataset); + } else { + writeLogFile(logFileName, "ûеļ"); + } + } catch (Throwable e) { + writeLogFile(logFileName, "ļʱ쳣"); + String exceptionMessage = e.getMessage(); + writeLogFile(logFileName, exceptionMessage); + writeLogFile(logFileName, " "); + e.printStackTrace(); + if (downCount < 2) { + file = getTCFile(tcFile, fileCurrentPath, fileName, dataSetInfo); + } else { + dataSetInfo.setReason(exceptionMessage); + failDownInfos.add(dataSetInfo); + } + } + return file; + } + + /** + * checkAccessPrivilige:ûԸComponentǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } + + private boolean isShowLog() { + boolean isShowLog = false; + TCPreferenceService preSer = session.getPreferenceService(); + String value = preSer.getString(4, isShowLogOption).trim(); + if (value.equalsIgnoreCase("true")) { + isShowLog = true; + } + return isShowLog; + } + + public void isDownReleased() { + TCPreferenceService preSer = session.getPreferenceService(); + String type = preSer.getString(4, validTypeOption).trim(); + if (type.equalsIgnoreCase("released")) { + isDownReleased = true; + } + } + + private String createFile(String filePath, String fileName) { + System.out.println("·" + filePath + "/" + fileName); + File file = new File(filePath + "/" + fileName); + if (!file.exists()) { + try { + file.mkdir(); + } catch (Exception e) { + e.printStackTrace(); + } + } + return file.getAbsolutePath(); + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + System.out.println("run________________-"); + executeOperation(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/customization/download/DatasetFileDown2.java b/src/cn/com/customization/download/DatasetFileDown2.java new file mode 100644 index 0000000..8f7b17a --- /dev/null +++ b/src/cn/com/customization/download/DatasetFileDown2.java @@ -0,0 +1,716 @@ +/* +#============================================================================= +# +# copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: DatasetFileDown.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz ݼ(From Shaangu) +# 2011-5-19 liqz ޸ δݼļµݼҲ +#============================================================================= + */ +package cn.com.customization.download; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import cn.com.customization.imports.importfiles.ORProgressBarThread; +import cn.com.customization.util.GetCommonInfo; +import cn.com.customization.util.PackFailDownInfo; +import cn.com.customization.util.PackResultInfo; +import cn.com.customization.util.PackSuccessfulInfo; +import cn.com.customization.util.ResultDialog; +import cn.com.customization.util.ShowMessageDialog; +import cn.com.customization.util.UtilApi; +import cn.com.customization.util.WriteAndCopyFile; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ConfirmationDialog; +import com.teamcenter.rac.util.MessageBox; + +public class DatasetFileDown2 extends AbstractAIFOperation implements Runnable { + private TCSession session = null; + private InterfaceAIFComponent targetComponent = null; +// private TCUserService userService = null; + + private ORProgressBarThread progressbarthread = null; + private GetCommonInfo checkcommon = null; + + // origin_showLogFileеֵΪtrue־ļc:\\batchExportDataset.log + private String isShowLogOption = "CUST_showLogFile"; + private boolean isShowLog = false; + private String logFileName = "c:/batchExportDataset.log"; + private WriteAndCopyFile writeLog; + //Ƿֻrelease״̬ + private String validTypeOption = "CUST_batchdown_validtype"; + private boolean isDownReleased = false; + + private List logsList = new ArrayList(); + + private String rootPath = ""; + private List haveDownDataSet = null; + private List successfulInfos = new ArrayList(); + + private String successfulDir = System.getenv("temp");//"c:/ugs/log"; + private int downDataSetCount = 0; + private int isNotHavePriviligeCount = 0; + private int haveEqualDataSetCount = 0; + private int notReleasedDataSetCount = 0; + private List notExistFiles = new ArrayList(); + private int downCount = 0; + private List failDownInfos = new ArrayList(); + private int needDownCount = 0; + + private HashMap allItemRevisionMap = new HashMap(); + private HashMap allItemMap = new HashMap(); + private HashMap allComponentMap = new HashMap(); + + + public DatasetFileDown2(AbstractAIFApplication application, TCSession tcsession, InterfaceAIFComponent targetCom) { + session = tcsession; + targetComponent = targetCom; +// userService = (TCUserService)session.getUserService(); + + checkcommon = new GetCommonInfo(tcsession); + writeLog = new WriteAndCopyFile(); + + isDownReleased(); + getIsShowLog(); + if (isShowLog) { + File file = new File(logFileName); + if (file.exists()) { + writeLog.writeFile(logFileName, false, "\r\n"); + } else { + try { + file.createNewFile(); + writeLog.writeFile(logFileName, false, "\r\n"); + } catch (IOException e) { + e.printStackTrace(); + } + } + } else { + File file = new File(logFileName); + if (file.exists()) { + file.delete(); + } + } + } + + @SuppressWarnings("deprecation") + public void isDownReleased() { + TCPreferenceService preSer = session.getPreferenceService(); + String type = preSer.getString(4, validTypeOption).trim(); + if (type.equalsIgnoreCase("released")) { + isDownReleased = true; + } + } + + @SuppressWarnings("deprecation") + private void getIsShowLog() { + TCPreferenceService preSer = session.getPreferenceService(); + String value = preSer.getString(4, isShowLogOption).trim(); + if (value.equalsIgnoreCase("true")) { + isShowLog = true; + } + } + + private void writeLogFile(String fileName, String content) { + if (isShowLog) { + content = content + "\r\n"; + writeLog.writeFile(fileName, true, content); + } + } + + private void writeSuccessfulLogFile(String fileName, String content) { + content = content + "\r\n"; + writeLog.writeFile(fileName, true, content); + logsList.add(content); + } + + public String getTime() { + String strTime = ""; + try { + SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss:SSS"); + strTime = bartDateFormat.format(new Date()); + } catch (Exception e) { + e.printStackTrace(); + } + return strTime; + } + + private String appendSpace(String str, int num) { + if (str.length() < num) { + for (int i = UtilApi.length(str) + 1; i <= num; i++) { + str += " "; + } + } + return str; + } + + /** + * checkAccessPrivilige:ûԸComponentǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } + + + + + ////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + @Override + public void run() { + try { + System.out.println("run________________-"); + executeOperation(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + + ////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + @Override + public void executeOperation() throws Exception { + DeleteNullDir deleteNullDir1 = new DeleteNullDir(); + List list1 = deleteNullDir1.visitAll(new File("C:\\Users\\Administrator\\Desktop\\00000\\wtbg1")); + deleteNullDir1.removeNullFile(list1); + if (true) { + //return; + } + System.out.println("Begin to call filedown operation..."); + String parentPath = checkcommon.getChoosePath(); + rootPath = parentPath; + if ((parentPath != null) && (parentPath.length() == 0)) { + return; + } else { + if (checkcommon.isExistFiles(parentPath)) { + int value = ConfirmationDialog.post("ʾ","ָĿ¼·ǿգǷ?"); + if(value == ConfirmationDialog.NO){ + return; + } + } + } + writeLogFile(logFileName, "ѡ·Ϊ: " + parentPath); + haveDownDataSet = new ArrayList(); + try { + writeLogFile(logFileName, "ʼ: " + getTime()); + + PackSuccessfulInfo succesfulDataset = new PackSuccessfulInfo(); + succesfulDataset.setIndex(""); + succesfulDataset.setItemID("ID"); + succesfulDataset.setItemRev("汾"); + succesfulDataset.setItemOwner(""); + succesfulDataset.setDataset("ݼ"); + succesfulDataset.setRefFile(""); + successfulInfos.add(succesfulDataset); + + progressbarthread = new ORProgressBarThread("ݼ......", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("..."); + + String currentJob = ""; + if (targetComponent instanceof TCComponentItemRevision) { + currentJob = ((TCComponentItemRevision)targetComponent).getProperty("object_name"); + getDataSetFromItemRevision((TCComponentItemRevision)targetComponent, parentPath, true); + } else if (targetComponent instanceof TCComponentItem) { + currentJob = ((TCComponentItem)targetComponent).getProperty("object_name"); + getDataSetFromItem((TCComponentItem)targetComponent, parentPath); + } else { + int importAll = ConfirmationDialog.post("ʾ","Ƿ񵼳ļ?"); + System.out.println("Ƿ񵼳ļ:"+importAll); + if (targetComponent instanceof TCComponentFolder) { + currentJob = ((TCComponentFolder)targetComponent).getProperty("object_name"); + } else { + if (targetComponent instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) targetComponent; + TCComponentProcess process = task.getProcess(); + if (process != null) { + currentJob = process.toString(); // 000009/H;1-sgitem + } + } + } + getDataSetFromFolder(targetComponent, parentPath, importAll); + } + DeleteNullDir deleteNullDir = new DeleteNullDir(); + List list = deleteNullDir.visitAll(new File(rootPath)); + deleteNullDir.removeNullFile(list); + session.setReadyStatus(); + progressbarthread.setBool(true); + + writeLogFile(logFileName, " "); + writeLogFile(logFileName, "ܽ᣺"); + writeLogFile(logFileName, "ݼ:" + haveDownDataSet.size() + ""); + writeLogFile(logFileName, "δݼ:" + notReleasedDataSetCount + ""); + writeLogFile(logFileName, "Ȩݼ:" + isNotHavePriviligeCount + ""); + writeLogFile(logFileName, "Ҫļ:" + needDownCount + ""); + writeLogFile(logFileName, "ɹļ:" + downDataSetCount + ""); + writeLogFile(logFileName, "ļݼ:" + notExistFiles.size() + ""); + writeLogFile(logFileName, "δɹļ:" + (needDownCount - downDataSetCount) + ""); + + PackResultInfo resultInfo = new PackResultInfo(); + SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd:HHmmss"); + String time = date.format(new Date()); + resultInfo.setTime(time); + resultInfo.setPerson(session.getUser().toString()); + resultInfo.setJob(currentJob); + resultInfo.setExistDataSetCount(haveDownDataSet.size()); + resultInfo.setNeedNum(needDownCount); + resultInfo.setSuccessNum(downDataSetCount); + resultInfo.setNoReleasedNum(notReleasedDataSetCount); + resultInfo.setNoPrivilegelNum(isNotHavePriviligeCount); + resultInfo.setNoReferenceNum(notExistFiles.size()); + resultInfo.setEqualNameNum(haveEqualDataSetCount); + resultInfo.setFailNum((needDownCount - downDataSetCount)); + resultInfo.setFailDownInfo(failDownInfos); + + // ʱ䣺2010-06-15:8890 ˣXXXXXX, ѡ̣Ŀ¼XXXXXXXXXX + // ݼ:80 + // δݼ76 + // Ȩݼ0 + // ļ30 + // ɹļ80 + // ļݼ0 + + // δɹļб + // id 汾 ݼ + String logPath = successfulDir + "/ļ־_" + (new SimpleDateFormat("yyyyMMdd")).format(new Date()) + ".log"; + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "==========================================================================================================================="); + writeSuccessfulLogFile(logPath, "ʱ:" + time + " :" + session.getUser().toString() + " ѡĿ:" + currentJob); + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "ݼ:" + haveDownDataSet.size()); + writeSuccessfulLogFile(logPath, "δݼ:" + notReleasedDataSetCount); + writeSuccessfulLogFile(logPath, "Ȩݼ:" + isNotHavePriviligeCount); + writeSuccessfulLogFile(logPath, "ļ:" + needDownCount); + writeSuccessfulLogFile(logPath, "ɹļ:" + downDataSetCount); + writeSuccessfulLogFile(logPath, "ļݼ:" + notExistFiles.size()); + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "ѳɹļб:"); + writeSuccessfulLogFile(logPath, "---------------------------------------------------------------------------"); + for (int i = 0; i < successfulInfos.size(); i++) { + PackSuccessfulInfo successfulInfo = successfulInfos.get(i); + writeSuccessfulLogFile(logPath, appendSpace(successfulInfo.getIndex().trim(), 5) + appendSpace(successfulInfo.getItemID().trim(), 32) + appendSpace((successfulInfo.getItemRev() == null ? "" : successfulInfo.getItemRev().trim()), 5) + appendSpace(successfulInfo.getItemOwner().trim(), 25) + appendSpace(successfulInfo.getDataset().trim(), 50) + appendSpace(successfulInfo.getRefFile().trim(), 50)); + } + writeSuccessfulLogFile(logPath, " "); + + if (haveDownDataSet.size() == 0) { + new ShowMessageDialog("Ϣʾ", "0ݼ", ""); + return; + } + new ResultDialog(resultInfo, session); + } catch (Exception e) { + session.setReadyStatus(); + if (progressbarthread != null) { + progressbarthread.setBool(true); + } + MessageBox.post("ݵ쳣:" + e.getMessage(), "ERROR", 1); + e.printStackTrace(); + } + } + + /** + * getDataSetFromItemRevision:ͨ汾õݼ + * @param @return 趨ļ + * @param tcRevision + * @param perantPath ļҪ· + * @throws + * @since CodingExampleVer 1.1 + */ + private void getDataSetFromItemRevision(TCComponentItemRevision tcRevision, String parentPath, Boolean isLastRevision) { + if (tcRevision == null) { + return; + } + + try { + tcRevision.refresh(); + + String Uid = tcRevision.getUid(); + //System.out.println("tcRevision.getUid()===========" + Uid); + if (allItemRevisionMap.containsKey(Uid)) { + System.out.println("return"); + return; + } + allItemRevisionMap.put(Uid, tcRevision); + + if (isLastRevision) { + TCComponent tccomps[] = tcRevision.getRelatedComponents("IMAN_specification"); + for (int i = 0; i < tccomps.length; i++) { + if (tccomps[i] instanceof TCComponentDataset) { + datasetFileDown((TCComponentDataset) tccomps[i], parentPath, tcRevision); + } + } + } + + AIFComponentContext[] comps = tcRevision.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); + if ((comp instanceof TCComponentPseudoFolder)) { + System.out.println("property_name:" + comp.getProperty("property_name")); + if (comp.isTypeOf("PseudoFolder")) { + String objectString = comp.getProperty("object_string"); + if (objectString.equalsIgnoreCase("view") || objectString.equalsIgnoreCase("ͼ")) { + continue; + } + getDataSetFromFolder(comp, parentPath, 2); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * getDataSetFromItem:ͨItemõݼ + * @param @return 趨ļ + * @param tcItem + * @param cuurentPath ļҪ· + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void getDataSetFromItem(TCComponentItem tcItem, String parentPath) { + TCComponentItemRevision tcRevision; + try { + tcItem.refresh(); + + String Uid = tcItem.getUid(); + //System.out.println("tcItem.getUid()===========" + Uid); + if (allItemMap.containsKey(Uid)) { + System.out.println("return"); + return; + } + allItemMap.put(Uid, tcItem); + + if (parentPath.endsWith("\\")) { + parentPath = parentPath.substring(0, parentPath.length() - 1); + } + if(tcItem.getProperty("object_name").equals("ɹ")) { + parentPath += "\\" + tcItem.getProperty("object_name"); + } else + parentPath += "\\" + tcItem.getProperty("item_id") +" "+ tcItem.getProperty("object_name"); + File file = new File(parentPath); + if (!file.exists()) { + file.mkdir(); + } + + TCComponentItemRevision tcLastRevision = tcItem.getLatestItemRevision(); + + AIFComponentContext[] comps = tcItem.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); + if ((comp instanceof TCComponentItemRevision)) { + System.out.println("property_name:" + comp.getProperty("object_name")); + tcRevision = (TCComponentItemRevision)comp; + if (tcRevision.getProperty("item_revision_id").equals(tcLastRevision.getProperty("item_revision_id"))) { + getDataSetFromItemRevision(tcLastRevision, parentPath, true); + } else { + getDataSetFromItemRevision(tcRevision, parentPath, false); + } + } + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + /** + * getTargetCom:õݼ + * @param @return 趨ļ + * @param aif + * @param parentPath ļҪ· + * @param importAll importAll=2ҪļУ1ֻǵһļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void getDataSetFromFolder(InterfaceAIFComponent aif, String parentPath, int importAll) { + String Uid = aif.getUid(); + //System.out.println("aif.getUid()===========" + Uid); + if (allComponentMap.containsKey(Uid)) { + System.out.println("return"); + return; + } + allComponentMap.put(Uid, aif); + + //System.out.println("parentPath1=============" + parentPath); + try { + if (parentPath.endsWith("\\")) { + parentPath = parentPath.substring(0, parentPath.length() - 1); + } + if (aif instanceof TCComponentTask) { + parentPath += "\\" + ((TCComponentTask)aif).getProperty("object_name"); + } else if ((aif instanceof TCComponentFolder)) { + parentPath += "\\" + ((TCComponentFolder)aif).getProperty("object_name"); + } else if ((aif instanceof TCComponentPseudoFolder)) { + parentPath += "\\" + ((TCComponentPseudoFolder)aif).getProperty("object_string"); + } + } catch (TCException e) { + e.printStackTrace(); + } + + try { + AIFComponentContext[] getChild = aif.getChildren(); + int count = 0; + if (getChild != null) { + count = getChild.length; + } + //System.out.println("count=============" + count); + for (int i = 0; i < count; i++) { + InterfaceAIFComponent childComponent = getChild[i].getComponent(); + if (childComponent instanceof TCComponentDataset) { + File file = new File(parentPath); + if (!file.exists()) { + file.mkdir(); + } + //System.out.println("parentPath2=============" + parentPath); + datasetFileDown((TCComponentDataset)childComponent, parentPath, null); + } else if (childComponent instanceof TCComponentItemRevision) { + File file = new File(parentPath); + if (!file.exists()) { + file.mkdir(); + } + //System.out.println("parentPath2=============" + parentPath); + getDataSetFromItemRevision((TCComponentItemRevision)childComponent, parentPath, true); + } else if (childComponent instanceof TCComponentItem) { + File file = new File(parentPath); + if (!file.exists()) { + file.mkdir(); + } + //System.out.println("parentPath2=============" + parentPath); + getDataSetFromItem((TCComponentItem)childComponent, parentPath); + } else if (childComponent instanceof TCComponentTask || childComponent instanceof TCComponentFolder || childComponent instanceof TCComponentPseudoFolder) { + if (importAll == 2) { + File file = new File(parentPath); + if (!file.exists()) { + file.mkdir(); + } + System.out.println("parentPath2=============" + parentPath); + getDataSetFromFolder(childComponent, parentPath, 2); + } + } + } + } catch (Exception e) { + session.setReadyStatus(); + progressbarthread.setBool(true); + MessageBox.post("ȡʱ쳣:" + e.getMessage(), "ERROR", 1); + e.printStackTrace(); + } + } + + /** + * datasetFileDown:ݼļ + * @param @return 趨ļ + * @param dataset + * @param fileCurrentPath + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void datasetFileDown(TCComponentDataset dataSet, String fileCurrentPath, TCComponentItemRevision itemRevision) { + try { + dataSet.refresh(); + } catch (TCException e2) { + e2.printStackTrace(); + } + if (haveDownDataSet != null) { + if (haveDownDataSet.contains(dataSet)) { + return; + } + } + + haveDownDataSet.add(dataSet); + PackFailDownInfo dataSetInfo = new PackFailDownInfo(); + try { + String itemID = ""; + String rev = ""; + if (itemRevision != null) { + itemID = itemRevision.getProperty("item_id"); + rev = itemRevision.getProperty("current_revision_id"); + } + String owner = dataSet.getProperty("owning_user"); + dataSetInfo.setOwner(owner); + dataSetInfo.setItemId(itemID); + dataSetInfo.setRev(rev); + dataSetInfo.setDatasetName(dataSet.toString()); + dataSetInfo.setDataSet(dataSet); + dataSetInfo.setItemRev(itemRevision); + } catch (TCException e3) { + writeLogFile(logFileName, e3.getMessage()); + e3.printStackTrace(); + } + + writeLogFile(logFileName, "ݼ:" + dataSet.toString()); + // System.out.println("dataSet............" + dataSet.toString()); + try { + String release = dataSet.getProperty("release_status_list").trim(); + if (release != null) { + if (release.length() == 0) { + notReleasedDataSetCount++; + writeLogFile(logFileName, "δ"); + if (isDownReleased) { + dataSetInfo.setReason("δ"); + failDownInfos.add(dataSetInfo); + writeLogFile(logFileName, ""); + return; + } + } else { + writeLogFile(logFileName, "Ѿ"); + } + } + } catch (TCException e2) { + e2.printStackTrace(); + } + try { + boolean isCanExport = false; + isCanExport = checkAccessPrivilige(session.getUser(), dataSet, "EXPORT"); + if (!isCanExport) { + ++isNotHavePriviligeCount; + dataSetInfo.setReason("ûеȨ"); + failDownInfos.add(dataSetInfo); + writeLogFile(logFileName, "ûеȨ"); + writeLogFile(logFileName, " "); + return; + } else { + writeLogFile(logFileName, "еȨ "); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + TCComponentTcFile tcFile = null; + String fileName = ""; + try { + if ((dataSet.getTcFiles() != null) && (dataSet.getTcFiles().length > 0)) { + for (int i = 0; i < dataSet.getTcFiles().length; i++) { + tcFile = dataSet.getTcFiles()[i]; + if (tcFile == null) { + return; + } + tcFile.refresh(); + fileName = tcFile.getProperty("original_file_name"); + if (fileName != null) { + needDownCount++; + dataSetInfo.setFilePath(fileCurrentPath); + dataSetInfo.setReference_file(fileName); + dataSetInfo.setNeedDown("true"); + String fileType = ""; + String preFileName = ""; + int index = fileName.lastIndexOf("."); + if (index > 0) { + fileType = fileName.substring(index, fileName.length()); + preFileName = fileName.substring(0, index); + } else { + preFileName = fileName; + } + boolean flag = checkcommon.existFile(fileCurrentPath, fileName); + if (flag) { + haveEqualDataSetCount++; + int pos = fileName.indexOf('.'); + if (pos > 0) { + fileName = preFileName + "_" + UtilApi.getTimeNum() + fileType; + } + } + if (fileName.indexOf('/') >= 0) { + fileName = fileName.replace('/', '_'); + } + downCount = 0; + getTCFile(tcFile, fileCurrentPath, fileName, dataSetInfo); + } + } + } else { + dataSetInfo.setReason("ļ"); + failDownInfos.add(dataSetInfo); + notExistFiles.add(dataSet.toString()); + writeLogFile(logFileName, "ļ"); + } + writeLogFile(logFileName, " "); + } catch (Throwable e) { + writeLogFile(logFileName, "ļʱ쳣"); + writeLogFile(logFileName, e.getMessage()); + writeLogFile(logFileName, " "); + e.printStackTrace(); + } + } + + private File getTCFile(TCComponentTcFile tcFile, String fileCurrentPath, String fileName, PackFailDownInfo dataSetInfo) { + ++downCount; + if (downCount == 2) { + writeLogFile(logFileName, "ڶ"); + } + File file = null; + try { + file = tcFile.getFile(fileCurrentPath, fileName); + if (file != null) { + ++downDataSetCount; + writeLogFile(logFileName, "ļ:" + fileName + " " + getTime()); + writeLogFile(logFileName, " "); + // successfulInfos + PackSuccessfulInfo succesfulDataset = new PackSuccessfulInfo(); + succesfulDataset.setIndex(String.valueOf(downDataSetCount)); + succesfulDataset.setItemID(dataSetInfo.getItemId()); + succesfulDataset.setItemRev(dataSetInfo.getRev()); + succesfulDataset.setItemOwner(dataSetInfo.getOwner()); + succesfulDataset.setDataset(dataSetInfo.getDatasetName()); + succesfulDataset.setRefFile(file.getName()); + successfulInfos.add(succesfulDataset); + } else { + writeLogFile(logFileName, "ûеļ"); + } + } catch (Throwable e) { + writeLogFile(logFileName, "ļʱ쳣"); + String exceptionMessage = e.getMessage(); + writeLogFile(logFileName, exceptionMessage); + writeLogFile(logFileName, " "); + e.printStackTrace(); + if (downCount < 2) { + file = getTCFile(tcFile, fileCurrentPath, fileName, dataSetInfo); + } else { + dataSetInfo.setReason(exceptionMessage); + failDownInfos.add(dataSetInfo); + } + } + return file; + } +} diff --git a/src/cn/com/customization/download/DeleteNullDir.java b/src/cn/com/customization/download/DeleteNullDir.java new file mode 100644 index 0000000..79d67c2 --- /dev/null +++ b/src/cn/com/customization/download/DeleteNullDir.java @@ -0,0 +1,51 @@ +package cn.com.customization.download; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * ɾָĿ¼µпļ + * + * @author wxg + * + */ +public class DeleteNullDir { + List list = new ArrayList(); + // õijһĿ¼µļ + public List visitAll(File root) + { + File[] dirs = root.listFiles(); + if (dirs != null) + { + for (int i = 0; i < dirs.length; i++) + { + if (dirs[i].isDirectory()) + { + list.add(dirs[i]); + } + visitAll(dirs[i]); + } + } + return list; + } + /** + * ɾյļ + * @param list + */ + public void removeNullFile(List list) + { + for (int i = list.size() - 1; i >= 0; i--) + { + File temp = list.get(i); + System.out.println("name:" + temp.getPath()); + // Ŀ¼Ϊ + if (temp.isDirectory() && temp.listFiles().length <= 0) + { + System.out.println("delete:" + temp.getPath()); + temp.delete(); + } + } + } +} + diff --git a/src/cn/com/customization/imports/ImportBatchDirectoryCommand.java b/src/cn/com/customization/imports/ImportBatchDirectoryCommand.java new file mode 100644 index 0000000..a37f438 --- /dev/null +++ b/src/cn/com/customization/imports/ImportBatchDirectoryCommand.java @@ -0,0 +1,37 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: BatchDownLoadFileCommand.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2017-5-24 09:40:43 SZ Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.imports; + +import cn.com.customization.imports.importfiles.ImportFile; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCException; + +public class ImportBatchDirectoryCommand extends AbstractAIFCommand { + + public AbstractAIFUIApplication application; + public ImportBatchDirectoryCommand(AbstractAIFUIApplication abstractaifapplication) throws TCException { + application = abstractaifapplication; + execute(); + } + + private void execute() throws TCException { + new Thread() { + public void run() { + new ImportFile(application, true); + } + }.start(); + } + +} diff --git a/src/cn/com/customization/imports/ImportBatchDirectoryHandler.java b/src/cn/com/customization/imports/ImportBatchDirectoryHandler.java new file mode 100644 index 0000000..ebc65d0 --- /dev/null +++ b/src/cn/com/customization/imports/ImportBatchDirectoryHandler.java @@ -0,0 +1,43 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: ImportBatchDirectoryHandler.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2017-5-24 10:40:43 SZ Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.imports; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class ImportBatchDirectoryHandler extends AbstractHandler implements IHandler{ + + /* + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + ImportBatchDirectoryCommand command= new ImportBatchDirectoryCommand(app); + command.executeModal(); + } + catch (TCException e) { + e.printStackTrace(); + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cn/com/customization/imports/ImportBatchFileCommand.java b/src/cn/com/customization/imports/ImportBatchFileCommand.java new file mode 100644 index 0000000..7e2b111 --- /dev/null +++ b/src/cn/com/customization/imports/ImportBatchFileCommand.java @@ -0,0 +1,49 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: ImportBatchFileCommand.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2017-5-24 09:40:43 SZ Ini ʼļ +#======================================================================================================= + */ +package cn.com.customization.imports; + +import cn.com.customization.imports.importfiles.ImportFile; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCException; + +public class ImportBatchFileCommand extends AbstractAIFCommand { + + public AbstractAIFUIApplication application; + + public ImportBatchFileCommand(AbstractAIFUIApplication abstractaifapplication) throws TCException { + application = abstractaifapplication; + execute(); + } + + private void execute() throws TCException { +// System.out.println("--------------------------1"); + //new ImportFile(application, false); +// Display display = Display.getDefault(); +// display.asyncExec(new Runnable(){ +// +// @Override +// public void run() { +// new ImportFile(application, false); +// } +// }); + + new Thread() { + public void run() { +// System.out.println("--------------------------2"); + new ImportFile(application, false); + } + }.start(); + } +} diff --git a/src/cn/com/customization/imports/ImportBatchFileHandler.java b/src/cn/com/customization/imports/ImportBatchFileHandler.java new file mode 100644 index 0000000..a7fda35 --- /dev/null +++ b/src/cn/com/customization/imports/ImportBatchFileHandler.java @@ -0,0 +1,43 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: BatchDownLoadFileHandler.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2017-5-24 09:40:43 SZ Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.imports; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class ImportBatchFileHandler extends AbstractHandler implements IHandler{ + + /* + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + ImportBatchFileCommand command= new ImportBatchFileCommand(app); + command.executeModal(); + } + catch (TCException e) { + e.printStackTrace(); + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cn/com/customization/imports/importfiles/CreateDataSet.java b/src/cn/com/customization/imports/importfiles/CreateDataSet.java new file mode 100644 index 0000000..49e1f4a --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/CreateDataSet.java @@ -0,0 +1,622 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: CreateDataSet.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-18 04:57:58 tyl Ini ʼļ +# 2011-4-21 16:11 liqz Modify ļԭ200Ϊ500 +# 2012-2-28 liqz Modify dwgļͼֽͬform +# 2012-3-27 liqz Modify 2012-2-28޸ĵͬͼֽĴ +#======================================================================================================= + */ +package cn.com.customization.imports.importfiles; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.com.customization.util.GetMessagePromptDialog; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.paste.PasteCommand; +import com.teamcenter.rac.kernel.NamedReferenceContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinition; +import com.teamcenter.rac.kernel.TCComponentDatasetDefinitionType; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class CreateDataSet { + private TCSession session; + private ORProgressBarThread progressbarthread = null; + private AbstractAIFUIApplication app; + private boolean isHaveShowMessage = false; + private int selectFileCount = 0; + private int importFileCount = 0; + private int failImportFileCount = 0; + private boolean isImportFolder = false; + private boolean isError = false; + private Map fileTypeList; + private TCComponent targetRelComponent = null; + + public CreateDataSet(AbstractAIFUIApplication app, boolean isImportFolder, ORProgressBarThread progressbarthread, TCComponent targetRelComponent) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.progressbarthread = progressbarthread; + this.isImportFolder = isImportFolder; + this.targetRelComponent = targetRelComponent; + fileTypeList = new HashMap(); + fileTypeList = new GetAllOptionValue(app).getFileTypeFromOption(); + } + + /** + * getImportFile:õûѡļ + * + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ +// public boolean getImportFile(List filepath, String filter, TCComponent parentCom) { + public boolean getImportFile(List filepath, String filter, TCComponent parentCom,String strRelName) { + List filelist = filepath; + selectFileCount = filelist.size(); + System.out.println("selectFileCount = "+selectFileCount); + if (parentCom != null) { + try { + isError = false; + if (filelist.size() > 0) { + int importNum = GetCommonInfo.getSuccessNum(); + System.out.println("importNum = "+importNum); + for (int i = 0; i < filelist.size(); i++) { + if (importNum + importFileCount >= 500) { + progressbarthread.setBool(true); + session.setReadyStatus(); + isError = true; + MessageBox.post(AIFUtility.getActiveDesktop().getShell(), "ε볬500ļƣֹ", "Ϣʾ", MessageBox.INFORMATION); + return isError; + } + if (!isError) { + isError = false; + createDataSet(filelist.get(i), parentCom,strRelName); + } else { + progressbarthread.setBool(true); + session.setReadyStatus(); + return isError; + } + } + progressbarthread.setBool(true); + session.setReadyStatus(); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + failImportFileCount = selectFileCount - importFileCount; + GetCommonInfo.setNeedNum(selectFileCount + GetCommonInfo.getNeedNum()); + GetCommonInfo.setFailNum(failImportFileCount + GetCommonInfo.getFailNum()); + GetCommonInfo.setSuccessNum(importFileCount + GetCommonInfo.getSuccessNum()); + } + } + return isError; + } + + /** + * createDataSet:ݼ뵽Ӧİ汾 + * + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void createDataSet(String filePath, TCComponent parentCom,String strRelName) { + File file = new File(filePath); + int equalsCount = 0; + boolean isrename = false; + if (file.isFile()) { + String name = file.getName(); + // String strDatasetName = name.substring(0, name.lastIndexOf(".")); + String strDatasetName = name; + byte[] bytestr = strDatasetName.replace(" ", "").getBytes(); + // ݼƹȡǰ128ֽ + if (bytestr.length > 128) { + strDatasetName = new String(bytestr, 0, 128); + } + String suffix = name.substring(name.lastIndexOf(".") + 1); + suffix = suffix.toLowerCase(); + +// List getAllDataSetNames = new GetAllDataSetNames().getDatasetNames(parentCom); + List getAllDataSetNames = null; + if(suffix.equalsIgnoreCase("jt") || suffix.equalsIgnoreCase("jpg")){ + getAllDataSetNames = new GetAllDataSetNames().getDatasetNames(parentCom,"IMAN_Rendering"); + }else{ + getAllDataSetNames = new GetAllDataSetNames().getDatasetNames(parentCom,strRelName); + } + if ((getAllDataSetNames != null) && (getAllDataSetNames.size() > 0)) { + for (int i = 0; i < getAllDataSetNames.size(); i++) { + if (getAllDataSetNames.get(i).equals(strDatasetName)) { + if (equalsCount == 0) { + ++equalsCount; + } else { + ++equalsCount; + } + } + } + } + if ((equalsCount == 0) || (isHaveShowMessage)) { + if (isImportFolder) { +// if (parentCom instanceof TCComponentFolder) { +// addDataSetToFolder((TCComponentFolder) parentCom, strDatasetName, suffix, filePath); + addDataSetToFolder(parentCom, strDatasetName, suffix, filePath,strRelName); +// } + } else { + if (parentCom instanceof TCComponentItemRevision) { + if(suffix.equalsIgnoreCase("jt") || suffix.equalsIgnoreCase("jpg")){ + addDataSetToItemRevision((TCComponentItemRevision) parentCom, strDatasetName, suffix, filePath,fileTypeList,"IMAN_Rendering"); + }else{ + addDataSetToItemRevision((TCComponentItemRevision) parentCom, strDatasetName, suffix, filePath,fileTypeList,"IMAN_specification"); + } + } + } + // ļɾ + if (isrename) { + File renamedFile = new File(filePath); + { + if (renamedFile.exists()) { + renamedFile.delete(); + } + } + } + } else { + isHaveShowMessage = false; + if (equalsCount > 0) { + progressbarthread.setBool(true); + session.setReadyStatus(); + int value = new GetMessagePromptDialog("Ϣʾ", "ͬƵݼ" + strDatasetName + "Ƿ׷ӷʽ?").getValue(); + isHaveShowMessage = true; + if (value == 0) { + progressbarthread = new ORProgressBarThread("ݼ.....", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("ڵ..."); + if (isImportFolder) { + if (parentCom instanceof TCComponentFolder) { + addDataSetToFolder((TCComponentFolder) parentCom, strDatasetName, suffix, filePath,strRelName); + } + } else { + if (parentCom instanceof TCComponentItemRevision) { + if(suffix.equalsIgnoreCase("jt") || suffix.equalsIgnoreCase("jpg")){ + addDataSetToItemRevision((TCComponentItemRevision) parentCom, strDatasetName, suffix, filePath,fileTypeList,"IMAN_Rendering"); + }else{ + addDataSetToItemRevision((TCComponentItemRevision) parentCom, strDatasetName, suffix, filePath,fileTypeList,"IMAN_specification"); + } + } + } + if (isrename) { + File renamedFile = new File(filePath); + { + if (renamedFile.exists()) { + renamedFile.delete(); + } + } + } + } else { + isError = true; + progressbarthread.setBool(true); + session.setReadyStatus(); + return; + } + } + } + } + } + + /** + * createDatasetToRelation:ѡĹϵļ´ݼ + * @param String ļ· + * @param TCComponentItemRevision ϵļڵ item Revision + * @param String ϵļ + * */ + private void createDatasetToRelation(String filePath,TCComponentItemRevision itemRev,String strRelName){ + try { + File file = new File(filePath); + if (file.isFile()) { + String name = file.getName(); + String suffix = name.substring(name.lastIndexOf(".") + 1); + suffix = suffix.toLowerCase(); + + if(suffix.equalsIgnoreCase("dwg")){ + fileTypeList.put(suffix,"DWG"); + } + + String strTaskName = ""; + TCComponent[] processList = itemRev.getReferenceListProperty("process_stage_list"); + if(processList != null){ + if(processList.length >= 2){ + TCComponent taskcomp = processList[processList.length -1]; + strTaskName = taskcomp.getProperty("object_name"); + } + } + + System.out.println("createDatasetToRelation:: strTaskName = " + strTaskName); + SimpleDateFormat df = new SimpleDateFormat( "yyyyMMdd HH:mm"); + String strDatasetName = strTaskName + "_" + session.getUser().getProperty("user_name") +"_" + df.format(new Date()); + addDataSetToItemRevision(itemRev, strDatasetName, suffix, filePath,fileTypeList,strRelName); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + + /** + * addDataSet:ݼ뵽Ӧİ汾 + * + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void addDataSetToItemRevision(TCComponentItemRevision itemRevision, String strDatasetName, String suffix, String filePath,Map fileTypeList,String strRel) { + try { + TCTypeService service = session.getTypeService(); + if (service != null) { + TCComponentDatasetType datasetType = (TCComponentDatasetType) service.getTypeComponent("Dataset"); +// MessageBox.post("suffix="+suffix, "ʾ", MessageBox.INFORMATION); +// MessageBox.post("fileTypeList.get(suffix)="+fileTypeList.get(suffix), "ʾ", MessageBox.INFORMATION); + System.out.println("suffix="+suffix); +// System.out.println("fileTypeList.get(suffix)="+fileTypeList.get(suffix)); + TCComponentDataset tcd = datasetType.create(strDatasetName, "description", fileTypeList.get(suffix)); + String[] arrTargetName = { filePath }; + + String[] dataset = getFileType(datasetType, fileTypeList.get(suffix)); + tcd.setFiles(arrTargetName, dataset); + if(targetRelComponent != null){ + PasteCommand pastecommand = new PasteCommand(new TCComponent[] {tcd},new TCComponent[] {targetRelComponent},app.getDesktop()); + try { + pastecommand.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else{ + itemRevision.add(strRel, tcd); + } + + /*============20120327 liqz ͬٶֳҪε===========*/ +// if(suffix.equalsIgnoreCase("dwg")){ +// String[] arrProp = getPropertyFromOption(itemRevision); +// getDWGProperty(itemRevision, arrProp, filePath); +// } + /*============20120327 liqz ͬٶֳҪε===========*/ + importFileCount++; + } + } catch (TCException e) { + progressbarthread.setBool(true); + session.setReadyStatus(); + if(e.getMessage().contains(" view Dz޸ĵ")){ + MessageBox.post(" view Dz޸ĵģѡϵļִв","ʾ",MessageBox.WARNING); + }else{ + int value = new GetMessagePromptDialog("Ϣʾ", "ʶݼ͵ĵļ" + filePath + "", "Ƿ?").getValue(); + if (value == 0) { + progressbarthread = new ORProgressBarThread("ݼ.....", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("ڵ..."); + } else { + isError = true; + } + e.printStackTrace(); + } + } + } + +// private void addDataSetToFolder(TCComponentFolder folder, String strDatasetName, String suffix, String filePath) { + private void addDataSetToFolder(TCComponent folder, String strDatasetName, String suffix, String filePath,String strRelName) { + try { + Map fileTypeList = new HashMap(); + fileTypeList = new GetAllOptionValue(app).getFileTypeFromOption(); + TCTypeService service = session.getTypeService(); + if (service != null) { + TCComponentDatasetType datasetType = (TCComponentDatasetType) service.getTypeComponent("Dataset"); + TCComponentDataset tcd = datasetType.create(strDatasetName, "description", fileTypeList.get(suffix)); + String[] arrTargetName = { filePath }; + // String[] dataset = { getFileType(datasetType, fileTypeList.get(suffix)) }; + String[] dataset = getFileType(datasetType, fileTypeList.get(suffix)); + tcd.setFiles(arrTargetName, dataset); + + if(strRelName.length() > 0){ + folder.add(strRelName, tcd); + }else{ + folder.add("contents", tcd); + } + importFileCount++; + } + } catch (TCException e) { + progressbarthread.setBool(true); + session.setReadyStatus(); + int value = new GetMessagePromptDialog("Ϣʾ", "ʶݼ͵ĵļ" + filePath + "", "Ƿ?").getValue(); + if (value == 0) { + progressbarthread = new ORProgressBarThread("ݼ.....", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("ڵ..."); + } else { + isError = true; + } + e.printStackTrace(); + } + } + + /** + * getFileType:ݼӦļ + * + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private String[] getFileType(TCComponentDatasetType datasetType, String tctype) { + List typeList = new ArrayList(); + if (tctype.equalsIgnoreCase("CATPart")) { + typeList.add("catpart"); + } else if (tctype.equalsIgnoreCase("CATDrawing")) { + typeList.add("catdrawing"); + } else if (tctype.equalsIgnoreCase("CATProduct")) { + typeList.add("catproduct"); + } else if(tctype.equalsIgnoreCase("MSWordX") || tctype.equalsIgnoreCase("MSWord")){ + typeList.add("word"); + }else if(tctype.equalsIgnoreCase("MSExcelX") || tctype.equalsIgnoreCase("MSExcel")){ + typeList.add("excel"); + }else if(tctype.equalsIgnoreCase("ACADDWG")){ + typeList.add("DWG"); + }else if(tctype.equalsIgnoreCase("DirectModel")){ + typeList.add("JTPART"); + }else { + try { + TCTypeService service = session.getTypeService(); + TCComponentDatasetDefinitionType dsdefType; + dsdefType = (TCComponentDatasetDefinitionType) service.getTypeComponent("DatasetType"); + TCComponentDatasetDefinition definition = dsdefType.find(tctype); + NamedReferenceContext[] contexts = definition.getNamedReferenceContexts(); + + if ((contexts != null) && (contexts.length > 0)) { + for (int m = 0; m < contexts.length; m++) { + //System.out.println("contexts[m].getNamedReference()="+contexts[m].getNamedReference()); + //MessageBox.post("contexts[m]="+contexts[m].getNamedReference(), "ʾ", MessageBox.INFORMATION); + typeList.add(contexts[m].getNamedReference()); + } + } + } catch (TCException e) { + progressbarthread.setBool(true); + session.setReadyStatus(); + e.printStackTrace(); + } + } + String[] types = new String[typeList.size()]; + for (int i = 0; i < typeList.size(); i++) { + types[i] = (String) typeList.get(i); + System.out.println("types[i]="+types[i]); + } + //MessageBox.post("types="+types.toString(), "ʾ", MessageBox.INFORMATION); + System.out.println("types="+types.toString()); + return types; + } + + /** + * getSubmitFile:ļбݵitem Revisionָϵ + * @param List ļб List + * @param TCComponentItemRevision ϵڵitem Revision + * @param String ϵļ + * */ + public boolean getSubmitFile(List filepaths ,TCComponentItemRevision revision,String strRelName){ + List filelist = filepaths; + selectFileCount = filelist.size(); + if (revision != null) { + try { + isError = false; + if (filelist.size() > 0) { + int importNum = GetCommonInfo.getSuccessNum(); + for (int i = 0; i < filelist.size(); i++) { + if (importNum + importFileCount >= 500) { + progressbarthread.setBool(true); + session.setReadyStatus(); + isError = true; + MessageBox.post(AIFUtility.getActiveDesktop().getShell(), "ε볬500ļƣֹ", "Ϣʾ", MessageBox.INFORMATION); + return isError; + } + if (!isError) { + isError = false; + createDatasetToRelation(filelist.get(i),revision,strRelName); + } else { + progressbarthread.setBool(true); + session.setReadyStatus(); + return isError; + } + } + progressbarthread.setBool(true); + session.setReadyStatus(); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + failImportFileCount = selectFileCount - importFileCount; + GetCommonInfo.setNeedNum(selectFileCount + GetCommonInfo.getNeedNum()); + GetCommonInfo.setFailNum(failImportFileCount + GetCommonInfo.getFailNum()); + GetCommonInfo.setSuccessNum(importFileCount + GetCommonInfo.getSuccessNum()); + } + } + return isError; + } + + /** + * getPropertyFromOption:ݵǰѡItemͣѡȡҪͬ + * @param TCComponentItemRevision itemRevision + * @return String[] revisionformԶӦϵ + * */ + @SuppressWarnings("unused") + private String[] getPropertyFromOption(TCComponentItemRevision itemRevision){ + String[] arrOption = itemRevision.getSession().getPreferenceService().getStringValues("Dacastal_AutoCAD_Map"); + if(arrOption == null || arrOption.length == 0){ + return null; + } + + String[] arrProp = new String[2]; + StringBuffer strRevisionProp = new StringBuffer(); + StringBuffer strFormProp = new StringBuffer(); + + String strType = itemRevision.getType(); + for(int i = 0; i < arrOption.length ;i++){ + String strTemp = arrOption[i]; + if(strTemp.startsWith(strType)){ + int index = strTemp.indexOf("."); + if(index > 0 ){ + String strOptionType = strTemp.substring(0,index); + String value = strTemp.substring(index + 1); + + if(strOptionType.equalsIgnoreCase(strType)){ + if(strRevisionProp.length() == 0){ + strRevisionProp.append(value); + }else{ + strRevisionProp.append(",").append(value); + } + }else{ + if(strFormProp.length() == 0){ + strFormProp.append(value); + }else{ + strFormProp.append(",").append(value); + } + } + } + } + } + + System.out.println("strRevisionProp = " + strRevisionProp); + System.out.println("strFormProp = " + strFormProp); + + arrProp[0] = strRevisionProp.toString(); + arrProp[1] = strFormProp.toString(); + return arrProp; + } + + /** + * getDWGProperty::ӦϵȡDWGͼֵֽ + * @param TCComponentItemRevision revision + * @param String[] revisionformԶӦϵ + * @param strFilePath DWGļ· + * */ + @SuppressWarnings("unused") + private void getDWGProperty(TCComponentItemRevision revision,String[] pArrProp,String strFilePath){ + if(pArrProp == null){ + return; + } + HashMap mapRevProp = new HashMap(); + HashMap mapRevFormProp = new HashMap(); + + Runtime rn = Runtime.getRuntime(); + Process p = null; + try { + String str = System.getenv("TPR"); + if (str.endsWith("\\")) { + str = str + "plugins\\"; + } else { + str = str + "\\plugins\\"; + } + str = "\"" + str + "DxfExportExample.exe\"" + " \"" + strFilePath + "\" \"" + pArrProp[0] + "\" \"" + pArrProp[1] + "\""; + System.out.println("getDWGProperty:: str=" + str); + p = rn.exec("cmd /c start exit && " + str); + BufferedReader inputBufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream())); + BufferedReader errorinputBufferedReader = new BufferedReader(new InputStreamReader(p.getErrorStream())); + String line = null; + String errorline = null; + + while ((line = inputBufferedReader.readLine()) != null) { + System.out.println("exeֵ: line = " + line); + if(line.contains(":")){ + String[] arrType = line.split(":"); + if(arrType[0].equalsIgnoreCase("ItemRevision")){ + if(arrType[1].contains(";")){ + String[] arrRevPropValue = arrType[1].split(";"); + for(int i = 0 ; i < arrRevPropValue.length;i++){ + String[] temp = arrRevPropValue[i].split("="); + if(temp[0].equalsIgnoreCase("item_revision_id") || temp[0].equalsIgnoreCase("item_id")){ + continue; + } + if(temp.length == 2){ + mapRevProp.put(temp[0],temp[1]); + }else{ + mapRevProp.put(temp[0],""); + } + } + }else{ + String[] temp = arrType[1].split("="); + if(temp[0].equalsIgnoreCase("item_revision_id") || temp[0].equalsIgnoreCase("item_id")){ + continue; + } + if(temp.length == 2){ + mapRevProp.put(temp[0],temp[1]); + }else{ + mapRevProp.put(temp[0],""); + } + } + }else if(arrType[0].equalsIgnoreCase("ItemRevision Master")){ + if(arrType[1].contains(";")){ + String[] arrRevFormPropValue = arrType[1].split(";"); + for(int i = 0 ; i < arrRevFormPropValue.length;i++){ + String[] temp = arrRevFormPropValue[i].split("="); + if(temp.length == 2){ + mapRevFormProp.put(temp[0],temp[1]); + }else{ + mapRevFormProp.put(temp[0],""); + } + } + }else{ + String[] temp = arrType[1].split("="); + if(temp.length == 2){ + mapRevFormProp.put(temp[0],temp[1]); + }else{ + mapRevFormProp.put(temp[0],""); + } + } + } + } + } + while ((errorline = errorinputBufferedReader.readLine()) != null) { + System.out.println(errorline); + } + if (errorline != null) { + System.out.println("error occur..."); + p.destroy(); + } + // p.waitFor(); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Error to run the exe"); + } + + try { + revision.setProperties(mapRevProp); + TCComponent tccomponent = revision.getRelatedComponent("IMAN_master_form_rev"); + if(tccomponent instanceof TCComponentForm){ + TCComponentForm form = (TCComponentForm) tccomponent; + form.setProperties(mapRevFormProp); + } + } catch (TCException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/customization/imports/importfiles/CreateFolder.java b/src/cn/com/customization/imports/importfiles/CreateFolder.java new file mode 100644 index 0000000..82c273b --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/CreateFolder.java @@ -0,0 +1,39 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: CreateFolder.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-18 04:58:22 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.imports.importfiles; + +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class CreateFolder { + + TCSession session; + + public CreateFolder(TCSession session) { + this.session = session; + } + + public TCComponentFolder createNewFolder(String name, String desc) { + try { + TCComponentFolderType folderType = (TCComponentFolderType) session.getTypeComponent("Folder"); + // TCComponentFolder newFolder = folderType.create(name, desc, + // "Folder"); + return folderType.create(name, desc, "Folder"); + } catch (TCException e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/cn/com/customization/imports/importfiles/GetAllDataSetNames.java b/src/cn/com/customization/imports/importfiles/GetAllDataSetNames.java new file mode 100644 index 0000000..4ce1d84 --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/GetAllDataSetNames.java @@ -0,0 +1,72 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: GetAllDataSetNames.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-18 04:59:11 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.imports.importfiles; + +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; + +public class GetAllDataSetNames { + + /** + * Creates a new instance of GetAllDataSet. + */ + public GetAllDataSetNames() {} + + /** + * getDatasetInfo:õ汾Ѿڵݼ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public List getDatasetNames(TCComponent component,String strRelName) { + List datasetNames = new ArrayList(); + try { + if (component instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) component; + + TCComponent[] datasets = null; + if(strRelName.length() > 0){ + datasets = (TCComponent[]) itemRevision.getRelatedComponents(strRelName); + }else{ + datasets = (TCComponent[]) itemRevision.getRelatedComponents("IMAN_specification"); + } +// TCComponent[] datasets = (TCComponent[]) itemRevision.getRelatedComponents("IMAN_specification"); + for (int j = 0; j < datasets.length; j++) { + if (datasets[j] instanceof TCComponentDataset) { + String name = datasets[j].getProperty("object_name"); + datasetNames.add(name); + } + } + } else if (component instanceof TCComponentFolder) { + TCComponentFolder folder = (TCComponentFolder) component; + TCComponent[] datasets = (TCComponent[]) folder.getRelatedComponents("contents"); + for (int j = 0; j < datasets.length; j++) { + if (datasets[j] instanceof TCComponentDataset) { + String name = datasets[j].getProperty("object_name"); + datasetNames.add(name); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return datasetNames; + } +} diff --git a/src/cn/com/customization/imports/importfiles/GetAllOptionValue.java b/src/cn/com/customization/imports/importfiles/GetAllOptionValue.java new file mode 100644 index 0000000..9afcd22 --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/GetAllOptionValue.java @@ -0,0 +1,82 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: GetAllOptionValue.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-18 04:59:24 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.imports.importfiles; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + +public class GetAllOptionValue { + /** + * Creates a new instance of GetAllOptionValue. + */ + private TCSession session; + + public GetAllOptionValue(AbstractAIFUIApplication app) { + this.session = (TCSession) app.getSession(); + } + + /** + * getFileTypeFromOption:ѡõļ͵Ϣ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public Map getFileTypeFromOption() { + Map fileTypeList = new HashMap(); + String[] values = null; + try { + if (session != null) { + TCPreferenceService ps = session.getPreferenceService(); + if (ps != null) { + values = ps.getStringValues("CUST_dataset_extension_map"); + if (values != null) { + for (int i = 0; i < values.length; i++) { + String tctype = values[i].substring(0, values[i].indexOf(":")); + String filetype = values[i].substring(values[i].indexOf(":") + 1); + fileTypeList.put(filetype.toLowerCase(), tctype); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return fileTypeList; + } + + public List getFileType() { + List filetypelist = new ArrayList(); + Map fileTypelList = new HashMap(); + fileTypelList = getFileTypeFromOption(); + if ((fileTypelList != null) && (fileTypelList.size() > 0)) { + Set set = fileTypelList.keySet(); + Iterator it = set.iterator(); + while (it.hasNext()) { + String key = (String) it.next(); + if ((key != null) && (key.length() > 0)) { + filetypelist.add(key); + } + } + } + return filetypelist; + } +} diff --git a/src/cn/com/customization/imports/importfiles/GetChoosePath.java b/src/cn/com/customization/imports/importfiles/GetChoosePath.java new file mode 100644 index 0000000..43dbdce --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/GetChoosePath.java @@ -0,0 +1,134 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: GetChoosePath.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-18 04:59:35 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.imports.importfiles; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFileChooser; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; + +public class GetChoosePath { + + /** + * Creates a new instance of GetChoosePath. + */ + private List fileTypeList = new ArrayList(); + boolean isImportFolder; + + public GetChoosePath(AbstractAIFUIApplication app, List filterFileTypes, boolean isImportFolder) { + this.fileTypeList = filterFileTypes; + this.isImportFolder = isImportFolder; + } + + /** + * getChoosePath:õûѡ· + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public List getChoosePath() { + List choosePath = new ArrayList(); +// System.out.println("-----------------------------------------------------0"); + String tempPath = System.getProperty("java.io.tmpdir"); + System.out.println("tempPath="+tempPath); + File tempFile = new File(tempPath + "\\batchimportfile.txt"); + JFileChooser jfc = null; + if (!tempFile.exists()) { + try { + tempFile.createNewFile(); + jfc = new JFileChooser(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + if (tempFile.exists()) { + BufferedReader in; + try { + in = new BufferedReader(new InputStreamReader(new FileInputStream(tempFile))); + String line; + try { + line = in.readLine(); + if ((line != null) && (line.length() > 0)) { + File file = new File(line); + if (file.exists()) { + jfc = new JFileChooser(file); + } else { + jfc = new JFileChooser(); + } + } else { + jfc = new JFileChooser(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + } + } + } + jfc.setFileSelectionMode(JFileChooser.CUSTOM_DIALOG); + jfc.setInheritsPopupMenu(true); + jfc.setDialogTitle("ݼ"); + jfc.setMultiSelectionEnabled(true); + + if ((fileTypeList != null) && (fileTypeList.size() > 0)) { + jfc.setFileFilter(new javax.swing.filechooser.FileFilter() { + @Override + public boolean accept(File f) { + if (f.isDirectory()) + return true; + String name = f.getName(); + int p = name.lastIndexOf('.'); + if (p == -1) + return false; + String suffix = name.substring(p + 1).toLowerCase(); + return fileTypeList.contains(suffix); + } + + @Override + public String getDescription() { + return null; + } + }); + } + + int openOrCancel = jfc.showSaveDialog(null); + if (openOrCancel == 0) { + try { + BufferedWriter output; + output = new BufferedWriter(new FileWriter(tempFile)); + output.write(jfc.getSelectedFile().getAbsolutePath()); + output.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + File[] files = jfc.getSelectedFiles(); + for (int i = 0; i < files.length; i++) { + choosePath.add(files[i].getAbsolutePath()); + } + } + return choosePath; + } +} diff --git a/src/cn/com/customization/imports/importfiles/GetCommonInfo.java b/src/cn/com/customization/imports/importfiles/GetCommonInfo.java new file mode 100644 index 0000000..bf2d679 --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/GetCommonInfo.java @@ -0,0 +1,70 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: GetCommonInfo.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-18 04:59:47 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.imports.importfiles; + +public class GetCommonInfo { + + /** + * + */ + public GetCommonInfo() { + + } + + public static int successNum = 0; + public static int failNum = 0; + public static int needNum = 0; + + /** + * @return the needNum + */ + public static synchronized int getNeedNum() { + return needNum; + } + + /** + * @param needNum the needNum to set + */ + public static synchronized void setNeedNum(int needNum) { + GetCommonInfo.needNum = needNum; + } + + /** + * @return the successNum + */ + public static synchronized int getSuccessNum() { + return successNum; + } + + /** + * @param successNum the successNum to set + */ + public static synchronized void setSuccessNum(int num) { + successNum = num; + } + + /** + * @return the failNum + */ + public static synchronized int getFailNum() { + return failNum; + } + + /** + * @param failNum the failNum to set + */ + public static synchronized void setFailNum(int num) { + failNum = num; + } + +} \ No newline at end of file diff --git a/src/cn/com/customization/imports/importfiles/GetTargetComponent.java b/src/cn/com/customization/imports/importfiles/GetTargetComponent.java new file mode 100644 index 0000000..2a09e35 --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/GetTargetComponent.java @@ -0,0 +1,86 @@ +/* +#============================================================================= +# +# copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: GetTargetComponent.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2009-11-23 tianyaling õûѡĶ +# 2012-04-06 liqz ޸ windowsĿ¼ļ롱ܿſαļе +#============================================================================= + */ +package cn.com.customization.imports.importfiles; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.util.MessageBox; + +public class GetTargetComponent { + + /** + * Creates a new instance of GetTargetComponent. + */ + private AbstractAIFUIApplication app; + + public GetTargetComponent(AbstractAIFUIApplication app) { + this.app = app; + } + + /** + * getRootComponent:õûѡĶ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public TCComponentItemRevision getItemRevision() { + if (app.getTargetComponents() != null) { + TCComponentItemRevision itemRevision = null; + TCComponent component = (TCComponent) app.getTargetComponents()[0]; + if (component != null) { + if (component instanceof TCComponentItemRevision) { + try { + itemRevision = (TCComponentItemRevision) component; + // String name = + // itemRevision.getProperty("object_name"); + } + catch (Exception e) { + e.printStackTrace(); + } + } else { + MessageBox.post("ѡһ汾", "Ϣʾ", MessageBox.INFORMATION); + } + } + return itemRevision; + } else { + MessageBox.post("ѡһ汾", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + } + + public TCComponent getSelectedComponent() { + if (app.getTargetComponents() != null) { + TCComponent component = (TCComponent) app.getTargetComponents()[0]; + String strType = component.getType(); + System.out.println("strType = " + strType); + //Modified by liqz on 20120406 ѡαļҲԵ Begin +// if ((component != null) && (component instanceof TCComponentFolder) ) { + if ((component != null) && (component instanceof TCComponentFolder || strType.equals("PseudoFolder")) ) { + //Modified by liqz on 20120406 ѡαļҲԵ End + return component; + } else { + MessageBox.post("ѡһļУ", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + } else { + MessageBox.post("ѡһļУ", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + } + +} diff --git a/src/cn/com/customization/imports/importfiles/ImportFile.java b/src/cn/com/customization/imports/importfiles/ImportFile.java new file mode 100644 index 0000000..589a215 --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/ImportFile.java @@ -0,0 +1,349 @@ +/* +#============================================================================= +# +# copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: ImportFile.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2017-5-24 10:40:43 SZ Ini ʼļ +#============================================================================= + */ +package cn.com.customization.imports.importfiles; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import cn.com.customization.util.ShowMessageDialog; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ImportFile { + /** + * Creates a new instance of ImportFile. + */ + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponent selectedTarget; + private boolean isImportFolder; + private ORProgressBarThread progressbarthread = null; + private int level = 0; + private boolean isError = false; + private TCComponent parentRevision = null; + private TCComponent targetRelComponent = null; + //private boolean isPSEUDOFOLDER = false; + private String strRelName = ""; + + public ImportFile(AbstractAIFUIApplication app, boolean isImportFolder) { + this.app = app; + this.session = (TCSession) (app.getSession()); + this.isImportFolder = isImportFolder; + GetCommonInfo.setNeedNum(0); + GetCommonInfo.setFailNum(0); + GetCommonInfo.setSuccessNum(0); + getTargetComponent(); + session.setReadyStatus(); + } + + public ImportFile(AbstractAIFUIApplication app,TCComponent[] component){ + this.app = app; + this.session = (TCSession) (app.getSession()); + parentRevision = component[0]; + targetRelComponent = component[1]; + GetCommonInfo.setNeedNum(0); + GetCommonInfo.setFailNum(0); + GetCommonInfo.setSuccessNum(0); + submitDataset((TCComponentItemRevision)parentRevision); + session.setReadyStatus(); + } + + /** + * getTargetComponent:õûѡĶ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void getTargetComponent() { + try { + if (isImportFolder) { + selectedTarget = new GetTargetComponent(app).getSelectedComponent(); + if(selectedTarget.getType().equals("PseudoFolder")){ + //isPSEUDOFOLDER = true; + strRelName = selectedTarget.getProperty("property_name"); + AIFComponentContext[] context = selectedTarget.whereReferenced(); + selectedTarget = (TCComponent) context[0].getComponent(); + } + + if (selectedTarget != null) { + boolean isCanRevise = false; + try { + isCanRevise = checkAccessPrivilige(session.getUser(), selectedTarget, "WRITE"); + } + catch (TCException e) { + e.printStackTrace(); + } + if (isCanRevise) { + executeImport(selectedTarget); + } else { + MessageBox.post(AIFUtility.getActiveDesktop().getShell(), "ԵǰĿ¼޸Ȩޣ", "Ϣʾ", MessageBox.INFORMATION); + } + } + } else { + importDatasetToRevision(); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * importDatasetToRevision:ݼ汾 + * */ + private void importDatasetToRevision(){ + boolean isReleased = false; + selectedTarget = new GetTargetComponent(app).getItemRevision(); + if ((selectedTarget != null)) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) selectedTarget; + boolean isWritable = false; + try { + isWritable = checkAccessPrivilige(session.getUser(), itemRevision, "WRITE"); + String itemType = itemRevision.getItem().getProperty("object_type").trim(); + System.out.println("itemType==================" + itemType); + + TCComponent[] arrayOfTCComponent; + try { + TCProperty localTCProperty = itemRevision.getTCProperty("release_status_list"); + arrayOfTCComponent = localTCProperty.getReferenceValueArray(); + if (arrayOfTCComponent.length > 0) { + isReleased = true; + /*=============Added by liqz on 20110420 Begin дȨԿԵ===============*/ + if(!isWritable){ + MessageBox.post(AIFUtility.getActiveDesktop().getShell(), "ǰ汾ѾûдȨޣܽе룡", "Ϣʾ", MessageBox.INFORMATION); + return; + } + /*=============Added by liqz on 20110420 End дȨԿԵ===============*/ + } + } + catch (TCException e) { + e.printStackTrace(); + } + }catch (TCException e2) { + e2.printStackTrace(); + } + + if (!isReleased || isWritable) { + boolean isCreateUser = false; + try { + String currentUser = session.getUser().getUserId(); + String createUser = itemRevision.getProperty("owning_user"); + createUser = (createUser.replace(" ", "")).substring(createUser.indexOf("("), createUser.length() - 2); + if (currentUser.equalsIgnoreCase(createUser)) { + isCreateUser = true; + } + } + catch (TCException e1) { + e1.printStackTrace(); + } + boolean flagPriChild = false; + try { + flagPriChild = checkAccessPrivilige(session.getUser(), itemRevision, "IMPORT"); + } + catch (TCException e) { + e.printStackTrace(); + } + + if(!isWritable){ + MessageBox.post(AIFUtility.getActiveDesktop().getShell(), "㲻иitem汾дȨޣ", "Ϣʾ", MessageBox.INFORMATION); + return; + } +// if ((!flagPriChild) || (!isCreateUser)) { + if (!flagPriChild) { + MessageBox.post(AIFUtility.getActiveDesktop().getShell(), "㲻иitem汾Ȩޣ", "Ϣʾ", MessageBox.INFORMATION); + return; + } else { + executeImport(itemRevision); + } + } + } + } + + /** + * executeImport:ʵֵ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private void executeImport(final TCComponent component) { + if (component != null) { + try { + if (isImportFolder) { + List filepaths = new GetChoosePath(app, new ArrayList(), true).getChoosePath(); + if ((filepaths == null) || (filepaths.size() == 0)) { return; } + progressbarthread = new ORProgressBarThread("ݼ.....", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("ڵ..."); + for (int i = 0; i < filepaths.size(); i++) { + if (!isError) { +// importFolder(new File(filepaths.get(i)), (TCComponentFolder) selectedTarget, 0); + importFolder(new File(filepaths.get(i)), selectedTarget, 0,strRelName); + } else { + break; + } + } + } else { + List filterFileTypes = new GetAllOptionValue(app).getFileType(); + final List filepaths = new GetChoosePath(app, filterFileTypes, false).getChoosePath(); + if ((filepaths == null) || (filepaths.size() == 0)) { return; } + + progressbarthread = new ORProgressBarThread("ݼ.....", "ݵУԵ..."); + progressbarthread.start(); + session.setStatus("ڵ..."); + isError = new CreateDataSet(app, false, progressbarthread, null).getImportFile(filepaths, "no", selectedTarget,""); + } + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + progressbarthread.setBool(true); + session.setReadyStatus(); + int failNum = GetCommonInfo.getFailNum(); + int successNum = GetCommonInfo.getSuccessNum(); + int needNum = GetCommonInfo.getNeedNum(); + if (isError) { + new ShowMessageDialog("Ϣʾ", "ɹ" + successNum + "ļ", ""); + } else { + /*============modified by liqz on 20110421 Ƶ뼶 Begin=================*/ +// if (level > 2) { +// MessageBox.post(AIFUtility.getActiveDesktop().getShell(), "ļг3ƣֹ", "Ϣʾ", MessageBox.INFORMATION); +// } + /*============modified by liqz on 20110421 Ƶ뼶 End=================*/ + if (failNum == 0) { + new ShowMessageDialog("Ϣʾ", "赼" + needNum + "ļ,ɹ" + successNum + "ļ", ""); + } else { + new ShowMessageDialog("Ϣʾ", "赼" + needNum + "ļ,ɹ" + successNum + "ļ", "δɹ" + failNum + "ļ"); + } + } + } + } + } + +// private void importFolder(File file, TCComponentFolder currentFolder, int level) { + private void importFolder(File file, TCComponent currentFolder, int level,String strRelName) { + if (file == null) { return; } + if (file.isDirectory()) { + TCComponentFolder folder = new CreateFolder(session).createNewFolder(file.getName(), ""); + try { + if(level == 0 && strRelName.length() > 0){ + currentFolder.add(strRelName, folder); + }else{ + currentFolder.add("contents", folder); + } + } + catch (TCException e) { + e.printStackTrace(); + } + File[] files = file.listFiles(); + List fileList = new ArrayList(); + List dirList = new ArrayList(); + for (int i = 0; i < files.length; i++) { + File listFile = files[i]; + if (listFile.isFile()) { + fileList.add(listFile.getAbsolutePath()); + } else { + dirList.add(listFile); + } + } + if ((fileList != null) && (fileList.size() > 0)) { + isError = new CreateDataSet(app, true, progressbarthread, null).getImportFile(fileList, "no", folder,""); + if (isError) { return; } + } + if ((dirList != null) && (dirList.size() > 0)) { + level = level + 1; + System.out.println("level========================" + level); + if (this.level < level) { + this.level = level; + } + /*============modified by liqz on 20110421 Ƶ뼶 Begin=================*/ + for (int i = 0; i < dirList.size(); i++) { + currentFolder = folder; + if (!isError) { +// importFolder(dirList.get(i), currentFolder, level); + importFolder(dirList.get(i), currentFolder, level,strRelName); + } else { + return; + } + } + } + } else { + List fileList = new ArrayList(); + fileList.add(file.getAbsolutePath()); + isError = new CreateDataSet(app, true, progressbarthread, null).getImportFile(fileList, "no", currentFolder,strRelName); + if (isError) { return; } + } + } + + /** + * checkAccessPrivilige:ǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } + + + /** + * submitDataset:ִд룩ݼ + * */ + private void submitDataset(TCComponentItemRevision itemRevision){ + try{ + List filterFileTypes = new GetAllOptionValue(app).getFileType(); + List filepaths = new GetChoosePath(app, filterFileTypes, false).getChoosePath(); + if ((filepaths == null) || (filepaths.size() == 0)) { return; } + progressbarthread = new ORProgressBarThread("ύ󸽼.....", "ύУԵ..."); + progressbarthread.start(); + session.setStatus("ύ..."); + CreateDataSet objCreate = new CreateDataSet(app, false, progressbarthread, targetRelComponent); + String strRelName = targetRelComponent.getProperty("property_name"); + objCreate.getSubmitFile(filepaths, itemRevision,strRelName); + }catch(Exception e){ + e.printStackTrace(); + }finally{ + progressbarthread.setBool(true); + session.setReadyStatus(); + int failNum = GetCommonInfo.getFailNum(); + int successNum = GetCommonInfo.getSuccessNum(); + int needNum = GetCommonInfo.getNeedNum(); + if (isError) { + new ShowMessageDialog("Ϣʾ", "ɹύ" + successNum + "ļ", ""); + } else { + if (failNum == 0) { + new ShowMessageDialog("Ϣʾ", "ύ" + needNum + "ļ,ɹύ" + successNum + "ļ", ""); + } else { + new ShowMessageDialog("Ϣʾ", "ύ" + needNum + "ļ,ɹύ" + successNum + "ļ", "δɹ" + failNum + "ļ"); + } + } + } + } +} diff --git a/src/cn/com/customization/imports/importfiles/ORProgressBar.java b/src/cn/com/customization/imports/importfiles/ORProgressBar.java new file mode 100644 index 0000000..d93777b --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/ORProgressBar.java @@ -0,0 +1,180 @@ +/** + * @file ProgressBar.java + * + * @brief Create progress bar + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 25-July-2008 Yanghui this class is used to create + * progress bar. + */ +package cn.com.customization.imports.importfiles; + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.Timer; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; + +/** + * @class ProgressBar + * @brief Create progress bar + * @author Yanghui + */ +@SuppressWarnings("serial") +public class ORProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * @var ProgressBar.progressbar + * @brief JProgressBar + */ + private JProgressBar progressbar; + + /** + * @var ProgressBar.label + * @brief label used to tips + */ + private JLabel label; + + /** + * @var ProgressBar.timer + * @brief timer used to timing operation + */ + private Timer timer; + + /** + * @var ProgressBar.bool + * @brief bool used to flag thread return + */ + private boolean bool = false; + + /** + * @var Progressbar.registry + * @brief Registry + */ + //private Registry registry; + + /** + * @fn public ProgressBar() + * @brief constructor + * @param[in] null + */ + private String showLable = null ; + public String getShowLable() { + return showLable; + } + + public void setShowLable(String showLable) { + this.showLable = showLable; + this.label.setText(showLable); + } + + public ORProgressBar(String showlable) { + super(true); + showLable = showlable; + label = new JLabel(showLable, JLabel.CENTER); + } + + /** + * @fn public void setBool(boolean bool) + * @brief set bool value + * @param[in] bool + * @param[out] null + */ + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * @fn private void initUI() + * @brief createDialog method + * @param[in] null + * @param[out] null + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + //label = new JLabel(showLable, JLabel.CENTER); + progressbar = new JProgressBar(); + progressbar.setOrientation(JProgressBar.HORIZONTAL); + progressbar.setMinimum(0); + progressbar.setMaximum(100); + progressbar.setValue(0); + progressbar.setPreferredSize(new Dimension(200, 15)); + progressbar.setBorderPainted(true); + timer = new Timer(50, (ActionListener) this); + timer.setRepeats(false); + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + TaskThread thread = new TaskThread(this); + thread.start(); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + bool = true; + } + }); + setVisible(true); + } + + /** + * @class TaskThread + * @brief Create progressbar + * + */ + class TaskThread extends Thread { + private ORProgressBar bar; + + public TaskThread(ORProgressBar bar) { + this.bar = bar; + } + + public void run() { + if (bool == false) { + // Set Status is running. + // session.setStatus(registry.getString("export Running")); + } + for (int i = 0; i < i + 1; i++) { + timer.start(); + int value = progressbar.getValue(); + if (value < 100) { + value = value + 5; + progressbar.setValue(value); + } else { + timer.stop(); + progressbar.setValue(0); + } + try { + sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (bool == true) { + bar.setVisible(false); + bar.dispose(); + return; + + } + + } + } + } + + public void actionPerformed(ActionEvent arg0) { + } +} diff --git a/src/cn/com/customization/imports/importfiles/ORProgressBarThread.java b/src/cn/com/customization/imports/importfiles/ORProgressBarThread.java new file mode 100644 index 0000000..348e4a2 --- /dev/null +++ b/src/cn/com/customization/imports/importfiles/ORProgressBarThread.java @@ -0,0 +1,40 @@ +/** + * @file ProgressBarThread.java + * + * @brief control progressBar. + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 08-Auguest-2008 Yanghui this class is used to control + * progress bar. + */ +package cn.com.customization.imports.importfiles; + +/** + * @class ProgressBarThread + * @brief Create progress bar thread + * @author Yanghui + */ +public class ORProgressBarThread extends Thread { + + private ORProgressBar bar; + + private String title; + + public ORProgressBarThread(String title,String showLable) { + this.title = title; + bar = new ORProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + bar.initUI(); + } + + public void setBool(boolean bool) { + bar.setBool(true); + } +} diff --git a/src/cn/com/customization/project/CopyFolderAndAssginToProjectDialog.java b/src/cn/com/customization/project/CopyFolderAndAssginToProjectDialog.java new file mode 100644 index 0000000..8ceb2b7 --- /dev/null +++ b/src/cn/com/customization/project/CopyFolderAndAssginToProjectDialog.java @@ -0,0 +1,450 @@ +/* +#============================================================================= +# +# opyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: CopyFolderAndAssginToProjectDialog.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2017-5-10 Administrator Ini ʼ +#============================================================================= + */ +package cn.com.customization.project; + +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.paste.PasteOperation; +import com.teamcenter.rac.common.create.BOCreateDefinition; +import com.teamcenter.rac.common.create.BOCreateDefinitionFactory; +import com.teamcenter.rac.common.create.CreateInstanceInput; +import com.teamcenter.rac.common.create.ICreateInstanceInput; +import com.teamcenter.rac.common.create.SOAGenericCreateHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.HorizontalLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.VerticalLayout; + +/** + * @author Administrator + */ +@SuppressWarnings({"rawtypes","unchecked"}) +public class CopyFolderAndAssginToProjectDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + TCSession session; + AbstractAIFUIApplication app; + + private JList folderList; + private JList proList; + private JTextField jt2; + private String folderType; + private InterfaceAIFComponent selectTarget; + + public CopyFolderAndAssginToProjectDialog(AbstractAIFUIApplication application, TCSession pSession, + Frame frame, boolean flag, String folderType, InterfaceAIFComponent selectTarget) { + super(frame, flag); // true + session = pSession; + app = application; + this.folderType = folderType; + this.selectTarget = selectTarget; + init(); + } + + private void init() { + setTitle("Ŀϼ"); + JPanel jptop = new JPanel(new HorizontalLayout()); + final JPanel jptopleft = new JPanel(new PropertyLayout(2,2,2,2,2,2)); + final JPanel jptopright = new JPanel(new VerticalLayout()); + Vector folderv = listDCProjTemplFolder(); + folderList = new JList(folderv); + folderList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + jptopleft.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "ѡҪƵļ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("", 0, 12))); // NOI18N + JScrollPane folderscrollPane = new JScrollPane(); + folderscrollPane.setPreferredSize(new Dimension(210,310)); + folderscrollPane.getViewport().add(folderList); + jptopleft.add("1.1.left.center", folderscrollPane); + + Vector prov = listPro("*"); + proList = new JList(prov); + jptopright.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "ָɵĿ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("", 0, 12))); // NOI18N + + proList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + JScrollPane proscrollPane = new JScrollPane(proList); + proscrollPane.setPreferredSize(new Dimension(210,310)); + + final JTextField jt = new JTextField(30); + + jt.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent ke) { + char code = ke.getKeyChar(); + if (code == KeyEvent.VK_ENTER) { + System.out.println("ceshi س" + code + "=====" + KeyEvent.VK_ENTER); + Vector pronewVector = listPro(jt.getText()); + proList.setListData(pronewVector); + } + } + + }); + jptopright.add("top.bind.center.top", jt); + jptopright.add("top.bind.center.top", proscrollPane); + + jptop.add("1.1.center.center.resizable.resizable", jptopleft); + jptop.add("1.2.center.center.resizable.resizable", jptopright); + + JPanel jp1 = new JPanel(new HorizontalLayout()); + jt2 = new JTextField(20); + + jp1.add("left.bind.center.center", new JLabel("´ļ")); + jp1.add("unbound.bind.center.center", jt2); + + JPanel butPanel = new JPanel(new ButtonLayout()); + JButton okbtn = new JButton("ʼ"); + JButton canceltn = new JButton("ȡ"); + butPanel.add(okbtn); + butPanel.add(canceltn); + canceltn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + dispose(); + } + }); + + JPanel jpx = new JPanel(new VerticalLayout()); + jpx.add("top.bind.center.top", jptop); + jpx.add("top.bind.center.top", jp1); + jpx.add("top.bind.center.top", butPanel); + okbtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent actionevent) { + try { + doCopy(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + MouseListener mouseListener = new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + TCComponentProject tcproject = (TCComponentProject) proList.getSelectedValue(); + try { + String proid = tcproject.getStringProperty("project_id"); + jt2.setText(proid); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + }; + proList.addMouseListener(mouseListener); + add(jpx); + setResizable(false); + pack(); + centerToScreen(); + setVisible(true); + } + + /** + * listDCProjTemplFolder:ѯϵͳĿ + */ + public Vector listDCProjTemplFolder() { + Vector result = new Vector(); + try { + String str_key = "object_type"; + String str_value = "YSR8_ProjTemplFolder"; + +// if(folderType.equals("cDC_Projectfolder")){ +// str_value = "cDC_Kprojtemplfolder"; +// } + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find("__findfolder"); + System.out.println("getTextValue===========" + textService.getTextValue(str_key)); + if (null == query) { + MessageBox.post(app.getDesktop().getShell(), "ȴѯfindfolder", "", MessageBox.ERROR); + return null; + } + + querytype.clearCache(); + String as[] = { textService.getTextValue(str_key) }; + String as1[] = new String[1]; + as1[0] = str_value; + query.clearCache(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); // as + // =ѯkey + // ; + // as1 + // =ѯvalue + TCComponentFolder tcfolder = null; + if (list != null) { + int count = list.getListCount(); + System.out.println(" folder coutn " + count); + for (int i = 0; i < count; i++) { + tcfolder = (TCComponentFolder) list.get(i).getComponent(); + result.add(tcfolder); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return result; + } + + /** + * listPro:ȡϵͳеĿ + */ + public Vector listPro(String str_value) { + Vector result = new Vector(); + try { + String str_key = "project_id"; + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find("__findproject"); + if (null == query) { + MessageBox.post(app.getDesktop().getShell(), "ȴѯ__findproject ", "", MessageBox.ERROR); + return null; + } + + querytype.clearCache(); + String as[] = { textService.getTextValue(str_key), textService.getTextValue("is_active")}; + // String as[] = { "project_name" }; + System.out.println("getTextValue===========" + textService.getTextValue(str_key)); + String as1[] = new String[2]; + as1[0] = str_value; + as1[1] = "true"; + query.clearCache(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); // as + // =ѯkey + // ; + // as1 + // =ѯvalue + TCComponentProject tcpro = null; + + if (list != null) { + int count = list.getListCount(); + System.out.println(" pro coutn " + count); + for (int i = 0; i < count; i++) { + tcpro = (TCComponentProject) list.get(i).getComponent(); + result.add(tcpro); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return result; + } + + /** + * pasteNewFolder:Ѷ󿽱ļ + */ + public void pasteNewFolder(TCComponentFolder newFolder, InterfaceAIFComponent pasteTarget) throws Exception { // InterfaceAIFComponent[]pasteTargets + + TCComponentFolder parentcom = (TCComponentFolder)pasteTarget; + InterfaceAIFComponent childcoms = newFolder; + PasteOperation op = new PasteOperation(app,parentcom,childcoms,"contents"); + op.executeOperation(); + } + + /** + * assigntoPro:ѶָɵĿ + */ + public void assigntoPro(TCComponentProject atccomponentproject, TCComponent atccomponent) { + + TCComponentProjectType tccomponentprojecttype; + try { + tccomponentprojecttype = (TCComponentProjectType) session.getTypeComponent("TC_Project"); + tccomponentprojecttype.assignToProject(atccomponentproject, atccomponent); + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * createFolder:ļ + */ + public void createFolder(TCComponentFolder tcf, TCComponentProject tcproject, TCComponentFolder parent) { + try { + AIFComponentContext[] aifcon = tcf.getChildren(); + for (int i = 0; i < aifcon.length; i++) { + String type = aifcon[i].getComponent().getType(); + System.out.println("in getFolderName () the type = " + type); + if (type.equals("Folder")) { + String folderName = aifcon[i].getComponent().getProperty("object_name"); + String folderDescription = ""; + String newFolderType = "Folder"; + TCComponentFolder newFolder = null; + TCComponentFolderType tccomponentfoldertype; + try { + tccomponentfoldertype = (TCComponentFolderType) session.getTypeComponent(newFolderType); + newFolder = tccomponentfoldertype.create(folderName, folderDescription, newFolderType); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + InterfaceAIFComponent pasteTarget = parent; + pasteNewFolder(newFolder, pasteTarget); + assigntoPro(tcproject, newFolder); + + TCComponentFolder tcfolder = (TCComponentFolder) aifcon[i].getComponent(); + createFolder(tcfolder, tcproject, newFolder); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * createFolder:ļ + */ + public void createKSMFolder(TCComponentFolder tcf, TCComponentProject tcproject, TCComponentFolder parent) { + try { + AIFComponentContext[] aifcon = tcf.getChildren(); + for (int i = 0; i < aifcon.length; i++) { + String type = aifcon[i].getComponent().getType(); + System.out.println("in getFolderName () the type = " + type); + if (type.equals("Folder")) { + String folderName = aifcon[i].getComponent().getProperty("object_name"); + TCComponentFolder newFolder = null; + List input = new ArrayList(); + BOCreateDefinition itemDef = (BOCreateDefinition) BOCreateDefinitionFactory.getInstance().getCreateDefinition(session, "cDC_Projectfolder"); + CreateInstanceInput createInput = new CreateInstanceInput(itemDef); + createInput.add("object_name", folderName); + input.add(createInput); + + //SOAGenericCreateHelper helper = new SOAGenericCreateHelper(); + List list1 = SOAGenericCreateHelper.create(session, itemDef, input); + Iterator it = list1.iterator(); + TCComponent component = null; + do { + if (!it.hasNext()) + break; + component = (TCComponent) it.next(); + } while (!(component instanceof TCComponentFolder)); + newFolder = (TCComponentFolder) component; + + InterfaceAIFComponent pasteTarget = parent; + pasteNewFolder(newFolder, pasteTarget); + assigntoPro(tcproject, newFolder); + + TCComponentFolder tcfolder = (TCComponentFolder) aifcon[i].getComponent(); + createKSMFolder(tcfolder, tcproject, newFolder); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * doCopy:¸ + * */ + private boolean doCopy(){ + try { +// InterfaceAIFComponent[] pasteTargets = app.getTargetComponents(); + if(folderList.getSelectedIndex() == -1 || proList.getSelectedIndex() == -1 || jt2.getText().equals("") ){ + MessageBox.post(app.getDesktop().getShell(), "ģļСĿ´ļƶΪգ", "", MessageBox.WARNING); + return false; + } + + TCComponentFolder tcfolder = (TCComponentFolder) folderList.getSelectedValue(); + TCComponentProject tcproject = (TCComponentProject) proList.getSelectedValue(); + + if (selectTarget.equals(tcfolder)) { + MessageBox.post(app.getDesktop().getShell(), "Ŀ겻ͬһļУ", "", MessageBox.WARNING); + return false; + } + System.out.println("jt2 text " + jt2.getText()); + + if(folderType.equals("cDC_Projectfolder")){ + TCComponentFolder newFolder = null; + List input = new ArrayList(); + BOCreateDefinition itemDef = (BOCreateDefinition) BOCreateDefinitionFactory.getInstance().getCreateDefinition(session, "cDC_Projectfolder"); + CreateInstanceInput createInput = new CreateInstanceInput(itemDef); + createInput.add("object_name", jt2.getText()); + input.add(createInput); + + //SOAGenericCreateHelper helper = new SOAGenericCreateHelper(); + List list1 = SOAGenericCreateHelper.create(session, itemDef, input); + Iterator it = list1.iterator(); + TCComponent component = null; + do { + if (!it.hasNext()) + break; + component = (TCComponent) it.next(); + } while (!(component instanceof TCComponentFolder)); + newFolder = (TCComponentFolder) component; + pasteNewFolder(newFolder, selectTarget); + assigntoPro(tcproject, newFolder); + + createKSMFolder(tcfolder, tcproject, newFolder); + + }else{ + TCComponentFolder newFolder = null; + TCComponentFolderType tccomponentfoldertype; + tccomponentfoldertype = (TCComponentFolderType) session.getTypeComponent("Folder"); + newFolder = tccomponentfoldertype.create(jt2.getText(), "", "Folder"); + + session.setStatus("ڸģļĿ¼,Ե..."); + pasteNewFolder(newFolder, selectTarget); + assigntoPro(tcproject, newFolder); + System.out.println("first folder create end "); + createFolder(tcfolder, tcproject, newFolder); + } + System.out.println("actionPerformed end "); + dispose(); + } catch (TCException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + }finally{ + session.setReadyStatus(); + } + return true; + } +} diff --git a/src/cn/com/customization/project/CreateProjectFolderCommand.java b/src/cn/com/customization/project/CreateProjectFolderCommand.java new file mode 100644 index 0000000..7ecb33a --- /dev/null +++ b/src/cn/com/customization/project/CreateProjectFolderCommand.java @@ -0,0 +1,35 @@ +package cn.com.customization.project; + +import javax.swing.SwingUtilities; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateProjectFolderCommand extends AbstractAIFCommand { + AbstractAIFUIApplication app; + TCSession session; + public int i = 0; + + public CreateProjectFolderCommand(AbstractAIFUIApplication abstractaifuiapplication, final String folderType) { + super(); + this.app = abstractaifuiapplication; + session = (TCSession) app.getSession(); + System.out.println("2" + "\nݽString=" + folderType); + final InterfaceAIFComponent[] pasteTargets = app.getTargetComponents(); + if (pasteTargets.length == 1 && pasteTargets[0] instanceof TCComponentFolder) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + app.getDesktop(); + new CopyFolderAndAssginToProjectDialog(app, session, AIFDesktop.getActiveDesktop(), true, folderType, pasteTargets[0]); + } + }); + } else { + MessageBox.post(app.getDesktop().getShell(), "ѡһļУ", "", MessageBox.ERROR); + } + } +} diff --git a/src/cn/com/customization/project/CreateProjectFolderHandler.java b/src/cn/com/customization/project/CreateProjectFolderHandler.java new file mode 100644 index 0000000..d627fb1 --- /dev/null +++ b/src/cn/com/customization/project/CreateProjectFolderHandler.java @@ -0,0 +1,28 @@ +package cn.com.customization.project; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.util.MessageBox; + +public class CreateProjectFolderHandler extends AbstractHandler +{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException + { + AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); + try + { + new CreateProjectFolderCommand(application,"FolderCreatePro"); + } + catch (Exception exception) + { + MessageBox.post(exception, true); + } + + return null; + } +} diff --git a/src/cn/com/customization/purchasing/PurchasingDepartmentSearchCommand.java b/src/cn/com/customization/purchasing/PurchasingDepartmentSearchCommand.java new file mode 100644 index 0000000..20491ec --- /dev/null +++ b/src/cn/com/customization/purchasing/PurchasingDepartmentSearchCommand.java @@ -0,0 +1,14 @@ +package cn.com.customization.purchasing; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class PurchasingDepartmentSearchCommand extends AbstractAIFCommand { + AbstractAIFUIApplication app; + public PurchasingDepartmentSearchCommand(AbstractAIFUIApplication abstractaifuiapplication) { + super(); + this.app = abstractaifuiapplication; + new PurchasingDepartmentSearchDialog(AIFUtility.getActiveDesktop().getFrame(), app); + } +} diff --git a/src/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog.java b/src/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog.java new file mode 100644 index 0000000..840aacb --- /dev/null +++ b/src/cn/com/customization/purchasing/PurchasingDepartmentSearchDialog.java @@ -0,0 +1,299 @@ +package cn.com.customization.purchasing; + +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.PrintWriter; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.apache.log4j.Logger; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; +import cn.com.teamcenter.rac.form.GCSelectionUserCommand; + +/** + * ɹƵѯԻ + * + * @author + */ +@SuppressWarnings({"serial","rawtypes"}) +public class PurchasingDepartmentSearchDialog extends AbstractAIFDialog { + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(PurchasingDepartmentSearchDialog.class); + + private TCSession session; + + private TCComponent tcTargets[]; + + private iTextField txtUserId; + private JComboBox comboBoxType; + + private AbstractAIFApplication app = null; + + public PurchasingDepartmentSearchDialog(Frame parent, AbstractAIFApplication papp) { + super(parent, true); + app = papp; + session = (TCSession) papp.getSession(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + initDialog(); + } + }); + } + + /* + * ʼ + */ + public void initDialog() { + + this.setTitle("ɹƵѯ"); + JPanel mainPanel = new JPanel(new PropertyLayout()); + this.getContentPane().add(mainPanel); + txtUserId = new iTextField(20); + comboBoxType = new JComboBox(new String[]{"ӹȷϵ","ɹȷϵ"}); + + JPanel botPanel = new JPanel(); + botPanel.setLayout(new ButtonLayout(ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 10)); + JButton selsectUserButton = new JButton("ѡ"); + selsectUserButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + action(e); + } + }); + + JButton searchButton = new JButton("ѯ"); + searchButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + action(e); + } + + }); + JLabel jl1 = new JLabel("û:"); + JLabel jl2 = new JLabel(" "); + + try { + txtUserId.setText(session.getUser().getUserId()); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + mainPanel.add("1.1.center.center", jl1); + mainPanel.add("1.2.center.center", txtUserId); + mainPanel.add("1.3.center.center", selsectUserButton); + mainPanel.add("1.4.center.center", jl2); + mainPanel.add("1.5.center.center", comboBoxType); + mainPanel.add("1.6.center.center", searchButton); + this.pack(); + this.centerToScreen(); + this.setVisible(true); + + } + + public void action(ActionEvent e) { + if (logger.isDebugEnabled()) { + logger.debug("actionPerformed(ActionEvent) - start"); //$NON-NLS-1$ + } + try { + if (e.getActionCommand().equals("ѡ")) { + GCSelectionUserCommand selectionUserCmd = new GCSelectionUserCommand(AIFUtility.getCurrentApplication().getDesktop(), session); + selectionUserCmd.setContextBean("ɹƵȷϲѯ",txtUserId); + selectionUserCmd.executeModal(); + } else if (e.getActionCommand().equals("ѯ")) { + + if(!txtUserId.getText().equals("") && comboBoxType.getSelectedItem() != null){ + doSearch(txtUserId.getText(),comboBoxType.getSelectedItem().toString()); + dispose(); + }else{ + MessageBox.post("ѯ.","ʾ",MessageBox.INFORMATION); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + if (logger.isDebugEnabled()) { + logger.debug("actionPerformed(ActionEvent) - end"); //$NON-NLS-1$ + } + } + + private void doSearch(String userId, String taskName){ + System.out.println("userId="+userId); + try { + String str_key = "Type"; + String str_value = "TasksToPerform"; + String str_key2 = "OwningUser"; + String str_value2 = userId; + + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find("__find_user_inbox");//... + querytype.clearCache(); + String as[] = new String[2]; + String as1[] = new String[2]; + as[0] = textService.getTextValue(str_key); + as1[0] = str_value; + as[1] = textService.getTextValue(str_key2); + as1[1] = str_value2; + query.clearCache(); + System.out.println("query " + query); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + + if (list != null) { + String filePath = System.getenv("temp") + "/logger.txt"; + PrintWriter pw = new PrintWriter(filePath); + int count = list.getListCount(); + System.out.println(" folder coutn " + count); + if(taskName.equals("ӹȷϵ")){ + for (int i = 0; i < count; i++) { + TCComponent[] tasks = ((TCComponentFolder) list.get(i).getComponent()).getRelatedComponents("contents"); + for(int ix = 0; ix < tasks.length; ix++){ + String rootTaskName = tasks[ix].getProperty("object_name"); + //System.out.println(rootTaskName); + if(rootTaskName.contains("ӹ") || rootTaskName.contains("ӹȷϵ")){ + TCComponent[] taskAttachments = tasks[ix].getReferenceListProperty("root_target_attachments"); + for(int jy = 0; jy < taskAttachments.length; jy++){ + String attType = taskAttachments[jy].getType(); + //System.out.println(attType); + if(attType.equals("YSR8_ECN2RevisionMaster") || attType.equals("YSR8_ECN4RevisionMaster") ){ + if(!taskAttachments[jy].getProperty("ysr8_PurchFinishDate").equals("")){ + //System.out.println("======ҵ,TXT============="); + pw.print(tasks[ix].getProperty("job_name")+";"+taskAttachments[jy].toString()+"\r\n"); + } + } + } + } + } + } + }else{ + for (int i = 0; i < count; i++) { + TCComponent[] tasks = ((TCComponentFolder) list.get(i).getComponent()).getRelatedComponents("contents"); + for(int ix = 0; ix < tasks.length; ix++){ + String rootTaskName = tasks[ix].getProperty("object_name");//job_name.getReferenceProperty("root_task").getProperty("object_name"); + //System.out.println(rootTaskName); + if(rootTaskName.contains("ɹ") || rootTaskName.contains("ɹȷϵ")){ + TCComponent[] taskAttachments = tasks[ix].getReferenceListProperty("root_target_attachments"); + for(int jy = 0; jy < taskAttachments.length; jy++){ + String attType = taskAttachments[jy].getType(); + //System.out.println(attType); + if(attType.equals("YSR8_ECN1RevisionMaster") || attType.equals("YSR8_ECN3RevisionMaster") ){ + if(!taskAttachments[jy].getProperty("ysr8_PurchFinishDate").equals("")){//creation_date attType.equals("ItemRevision Master") || + //System.out.println("======ҵ,TXT============="); + pw.print(tasks[ix].getProperty("job_name")+";"+taskAttachments[jy].toString()+"\r\n"); + } + } + } + } + } + } + } + pw.flush(); + pw.close(); + Runtime runtime = Runtime.getRuntime(); + runtime.exec("cmd /c "+filePath); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + /* + * ѡеǷ + */ + @SuppressWarnings("unused") + private int checkTargets() { + if (logger.isDebugEnabled()) { + logger.debug("checkTargets() - start"); //$NON-NLS-1$ + } + + int flag = 0; + AIFComponentContext aifcomponentcontext[] = app.getTargetContexts(); + if (aifcomponentcontext != null && aifcomponentcontext.length >= 0) { + tcTargets = new TCComponent[aifcomponentcontext.length]; + for (int i = 0; i < aifcomponentcontext.length; i++) { + tcTargets[i] = (TCComponent) aifcomponentcontext[i].getComponent(); + System.out.println("tcTargets[i]===" + tcTargets[i]); + } + //selectedFolder = (TCComponentFolder) tcTargets[0]; + try { + if (!checkAccessPrivilige(session.getUser(), tcTargets[0], "WRITE")) { + flag = 2; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + flag = 3; + } + + if (logger.isDebugEnabled()) { + logger.debug("checkTargets() - end"); //$NON-NLS-1$ + } + return flag; + } + + /** + * ûָǷijȨ + * + * @param user + * û + * @param comp + * + * @param accessName + * Ȩ + * @return ǷȨ + * @throws TCException + */ + private boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + if (logger.isDebugEnabled()) { + logger.debug("checkAccessPrivilige(TCComponentUser, TCComponent, String) - start"); //$NON-NLS-1$ + } + + if (logger.isInfoEnabled()) { + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - TCComponentUser user=" + user); //$NON-NLS-1$ + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - TCComponentUser comp=" + comp); //$NON-NLS-1$ + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - TCComponentUser accessName=" + accessName); //$NON-NLS-1$ + } + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + if (logger.isInfoEnabled()) { + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - TCAccessControlService accessService=" + accessService); //$NON-NLS-1$ + } + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + if (logger.isInfoEnabled()) { + logger.info("checkAccessPrivilige(TCComponentUser, TCComponent, String) - boolean returnboolean=" + returnboolean); //$NON-NLS-1$ + } + + if (logger.isDebugEnabled()) { + logger.debug("checkAccessPrivilige(TCComponentUser, TCComponent, String) - end"); //$NON-NLS-1$ + } + return returnboolean; + } +} diff --git a/src/cn/com/customization/purchasing/PurchasingDepartmentSearchHandler.java b/src/cn/com/customization/purchasing/PurchasingDepartmentSearchHandler.java new file mode 100644 index 0000000..7717c59 --- /dev/null +++ b/src/cn/com/customization/purchasing/PurchasingDepartmentSearchHandler.java @@ -0,0 +1,21 @@ +package cn.com.customization.purchasing; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +//ɹƵѯ +public class PurchasingDepartmentSearchHandler extends AbstractHandler implements IHandler{ + + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new PurchasingDepartmentSearchCommand(app); + return null; + } + +} diff --git a/src/cn/com/customization/schedule/AbstracModifyDialog.java b/src/cn/com/customization/schedule/AbstracModifyDialog.java new file mode 100644 index 0000000..9036495 --- /dev/null +++ b/src/cn/com/customization/schedule/AbstracModifyDialog.java @@ -0,0 +1,351 @@ +package cn.com.customization.schedule; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +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 AbstracModifyDialog extends JDialog { + // public class AbstracModifyDialog extends AbstractAIFDialog{ + public static final long serialVersionUID = 1L; + public String title; + public AbstractAIFUIApplication app; + public TCSession session; + public JRadioButton radio1; + public JRadioButton radio2; + public JRadioButton radio3; + public JRadioButton radio4; + public JTextField txt; + public String scheduleID; + public String scheduleName; + public TCComponentSchedule schedule; + TCComponent[] tasks = null; + TCComponentScheduleTask sch_summary_task = null; + public String currentRole; + public TCComponentUser currentUser; + public TCComponentUser owningUser; + public JTextField replaceSource; + public JTextField replaceObject; + JCheckBox chkTask ; + JCheckBox chkDelivery; + + boolean isSchedule = false; + boolean isTopSchedule = false; + boolean isTask = false; + boolean isModifyTaskName = true; + boolean isModifyDeliveryName = true; + InterfaceAIFComponent[] targets; + +// private static final Logger logger =Logger.getLogger(AbstracModifyDialog.class); + + public AbstracModifyDialog(AbstractAIFApplication app, String title) { + this.title = title; + this.app = (AbstractAIFUIApplication) app; + session = (TCSession) app.getSession(); + if (getTargetSchedule()) { + initUI(); + } + } + + public void initUI() { + setTitle(" " + title); + JPanel panel = new JPanel(new PropertyLayout()); + panel.add("1.1.left.center", new JLabel(" ")); + panel.add("1.2.left.center", setCenterPanel()); + panel.add("1.3.left.center", new JLabel(" ")); + panel.add("2.1.left.center", new JLabel(" ")); + this.getContentPane().add(panel); + this.setResizable(false); + this.setAlwaysOnTop(true); + pack(); + validate(); + Dimension screen = getToolkit().getScreenSize(); + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); + this.setVisible(true); + } + + private JPanel setCenterPanel() { + JPanel panel1 = new JPanel(new PropertyLayout()); + JTextField idtxt = new JTextField(32); + idtxt.setText(scheduleID); + idtxt.setEnabled(false); + JTextField nametxt = new JTextField(32); + nametxt.setText(scheduleName); + nametxt.setEnabled(false); + + chkTask = new JCheckBox(""); + chkTask.setSelected(true); + chkDelivery = new JCheckBox(""); + chkDelivery.setSelected(true); + + chkTask.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent arg0) { + if(chkTask.isSelected()){ + isModifyTaskName = true; + }else{ + isModifyTaskName = false; + } + } + }); + + chkDelivery.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent arg0) { + if(chkDelivery.isSelected()){ + isModifyDeliveryName = true; + }else{ + isModifyDeliveryName = false; + } + } + + }); + + JPanel panelModify = new JPanel(new FlowLayout()); + panelModify.add(chkTask); + panelModify.add(chkDelivery); + + panel1.add("1.1.left.center", new JLabel(" ")); + panel1.add("2.1.left.center", new JLabel("ʱID")); + panel1.add("2.2.left.center", idtxt); + panel1.add("3.1.left.center", new JLabel("ʱ")); + panel1.add("3.2.left.center", nametxt); + + panel1.add("4.1.left.center", new JLabel("ݣ")); + panel1.add("4.2.left.center", panelModify); + + JPanel panel2 = new JPanel(new PropertyLayout()); +// panel2.setBorder(BorderFactory.createTitledBorder("ķʽ")); + panel2.setBorder(BorderFactory.createTitledBorder("ǰ׺")); + + radio1 = new JRadioButton("ʱID"); + radio2 = new JRadioButton("ʱ"); + radio3 = new JRadioButton("Զı"); + + radio1.setSelected(true); + radio4 = new JRadioButton("滻ı"); + radio1.addActionListener(new buttonListener()); + radio2.addActionListener(new buttonListener()); + radio3.addActionListener(new buttonListener()); + radio4.addActionListener(new buttonListener()); + txt = new JTextField(27); + txt.setEnabled(false); + JPanel txtPanel = new JPanel(); + txtPanel.add(new JLabel("Զı")); + txtPanel.add(txt); + ButtonGroup bg = new ButtonGroup(); + bg.add(radio1); + bg.add(radio2); + bg.add(radio3); + bg.add(radio4); + panel2.add("1.1.left.center", radio1); + + panel2.add("2.1.left.center", radio2); + panel2.add("3.1.left.center", radio3); + panel2.add("4.1.left.center", txtPanel); + + JPanel panel3 = new JPanel(new PropertyLayout()); +// panel3.setBorder(BorderFactory.createTitledBorder("滻")); + replaceSource = new JTextField(28); + replaceObject = new JTextField(28); + replaceSource.setEnabled(false); + replaceObject.setEnabled(false); + panel3.add("1.1.left.center", new JLabel(" ҃ݣ")); + panel3.add("1.2.left.center", replaceSource); + panel3.add("2.1.left.center", new JLabel(" Ϊ")); + panel3.add("2.2.left.center", replaceObject); + + JPanel panePlace = new JPanel(new PropertyLayout()); + panePlace.add("1.1.left.center", radio4); + panePlace.add("2.1.left.center", panel3); + + JPanel panel = new JPanel(new PropertyLayout()); + panel.add("1.1.left.center", panel1); + panel.add("2.1.left.center", panel2); + panel.add("3.1.left.center", panePlace); + panel.add("4.1.center.center", setButtonPanel()); + + return panel; + } + + private JPanel setButtonPanel() { + JPanel panel = new JPanel(new PropertyLayout()); + JButton confirmBtn = new JButton("ȷ"); + JButton cancelBtn = new JButton("ȡ"); +// JButton replaceBtn = new JButton("ȫ滻"); + confirmBtn.addActionListener(new buttonListener()); + cancelBtn.addActionListener(new buttonListener()); +// replaceBtn.addActionListener(new buttonListener()); + + panel.add("1.1.left.center", new JLabel(" ")); + panel.add("2.1.left.center", confirmBtn); + // panel.add("2.2.left.center", replaceBtn); + panel.add("2.2.left.center", cancelBtn); + return panel; + } + + public boolean getTargetSchedule() { + boolean flag = true; + + targets = app.getTargetComponents(); + if(targets == null || targets.length == 0){ + MessageBox.post("ѡʱʱִв", "ʾ", MessageBox.INFORMATION); + return false; + }else{ + for(int i = 0;i < targets.length; i++){ + if(targets[i] instanceof TCComponentSchedule){ + isSchedule = true; + }else if(targets[i] instanceof TCComponentScheduleTask){ + try { + if(((TCComponentScheduleTask)targets[0]).getReferenceProperty("fnd0ParentTask") == null){ + isSchedule = true; + isTopSchedule =true;//˵ʱѡеʱʱʱصȻʱ + }else{ + isTask = true; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + if(isSchedule && isTask){ + MessageBox.post("ѡʱʱִв", "ʾ", MessageBox.INFORMATION); + return false; + } + } + + try { + if(isSchedule && !isTask){ + if(isTopSchedule){ + schedule = (TCComponentSchedule) ((TCComponentScheduleTask)targets[0]).getReferenceProperty("schedule_tag"); + }else{ + schedule = (TCComponentSchedule) targets[0]; + } + }else{ + schedule = (TCComponentSchedule) ((TCComponentScheduleTask)targets[0]).getReferenceProperty("schedule_tag"); + } + + if(isSchedule && !isTask){ + try { + tasks = schedule.getAllTasks(); + } catch (TCException e) { + e.printStackTrace(); + } + }else if(!isSchedule && isTask){ + tasks = new TCComponent[targets.length]; + for(int i = 0; i < targets.length; i++){ + tasks[i] = (TCComponent) targets[i]; + } + } + try { +// sch_summary_task = (TCComponentScheduleTask) schedule.getReferenceProperty("sch_summary_task"); + sch_summary_task = (TCComponentScheduleTask) schedule.getReferenceProperty("fnd0SummaryTask"); + } catch (TCException e) { + e.printStackTrace(); + } + System.out.println("schedule = " + schedule); + + scheduleID = schedule.getProperty("item_id"); + scheduleName = schedule.getProperty("object_name"); + currentUser = session.getUser(); + currentRole = session.getCurrentRole().toString(); + owningUser = (TCComponentUser) schedule.getReferenceProperty("owning_user"); + } catch (TCException e) { + e.printStackTrace(); + } + return flag; + } + + + class buttonListener implements ActionListener { + public void actionPerformed(ActionEvent actionevent) { + Object obj = actionevent.getSource(); + if (obj instanceof JButton) { + JButton button = (JButton) obj; + String buttonName = button.getText(); + if (buttonName.equals("ȡ")) { + cancelAction(); + } else if (buttonName.equals("ȷ")) { + if(!isModifyDeliveryName && !isModifyTaskName){ + MessageBox.post("ѡݣ", "ʾ", MessageBox.INFORMATION); + return; + } + if (radio1.isSelected()) { + confirmAction(0, ""); + } else if (radio2.isSelected()) { + confirmAction(1, ""); + } else if (radio3.isSelected()) { + confirmAction(2, txt.getText()); + } else if (radio4.isSelected()) { + replaceAction(); + } + } + } else { + if (obj instanceof JRadioButton) { + if (radio3.isSelected()) { + txt.setEnabled(true); + replaceSource.setEnabled(false); + replaceObject.setEnabled(false); + replaceSource.setText(""); + replaceObject.setText(""); + } else { + if (radio4.isSelected()) { + replaceSource.setEnabled(true); + replaceObject.setEnabled(true); + } else { + replaceSource.setEnabled(false); + replaceObject.setEnabled(false); + replaceSource.setText(""); + replaceObject.setText(""); + } + txt.setEnabled(false); + txt.setText(""); + } + } + } + } + } + + public String replaceName(String s, String source, String object) { + String newString = ""; + int first = 0; + while (s.indexOf(source) != -1) { + first = s.indexOf(source); + if (first != s.length()) { + newString = newString + s.substring(0, first) + object; + s = s.substring(first + source.length(), s.length()); + } + } + newString = newString + s; + return newString; + } + + public void replaceAction() {} + + public void confirmAction(int index, String txt) {} + + public void cancelAction() {} +} diff --git a/src/cn/com/customization/schedule/BOMTransPlanCommand.java b/src/cn/com/customization/schedule/BOMTransPlanCommand.java new file mode 100644 index 0000000..9ff967d --- /dev/null +++ b/src/cn/com/customization/schedule/BOMTransPlanCommand.java @@ -0,0 +1,44 @@ +package cn.com.customization.schedule; + +import javax.swing.SwingUtilities; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +public class BOMTransPlanCommand extends AbstractAIFCommand { + + private AbstractAIFUIApplication application = null; + + public BOMTransPlanCommand() { + + super(); + + application = AIFUtility.getCurrentApplication(); + + InterfaceAIFComponent selectTarget = application.getTargetComponent(); + if (selectTarget instanceof TCComponentScheduleTask) { + try { + final TCComponentSchedule scheduleTag = (TCComponentSchedule) ((TCComponentScheduleTask) selectTarget).getReferenceProperty("schedule_tag"); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + application.getDesktop(); + new BOMTransPlanDialog(application, AIFDesktop.getActiveDesktop(), scheduleTag); + } + }); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + MessageBox.post(application.getDesktop().getShell(), "ѡһʱִд˹ܣ", "ʾ", MessageBox.INFORMATION); + } + } +} diff --git a/src/cn/com/customization/schedule/BOMTransPlanDialog.java b/src/cn/com/customization/schedule/BOMTransPlanDialog.java new file mode 100644 index 0000000..cdf4d8e --- /dev/null +++ b/src/cn/com/customization/schedule/BOMTransPlanDialog.java @@ -0,0 +1,420 @@ +package cn.com.customization.schedule; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.TCTypeRenderer; +import com.teamcenter.rac.common.lov.LOVComboBox; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentRevisionRule; +import com.teamcenter.rac.kernel.TCComponentRevisionRuleType; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.schedule.commands.reload.ReloadOperation; +import com.teamcenter.rac.schedule.common.tree.ScheduleTreeLine; +import com.teamcenter.rac.schedule.scheduler.componentutils.ScheduleHelper; +import com.teamcenter.rac.schedule.scheduler.componentutils.TaskHelper; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; + +import cn.com.customization.util.UtilApi; +import cn.com.teamcenter.rac.form.GCSelectionUserCommand; + +@SuppressWarnings({"deprecation","rawtypes"}) +public class BOMTransPlanDialog extends AbstractAIFDialog implements WindowListener{ + + private static final long serialVersionUID = 1L; + private TCSession session = null; + private AbstractAIFUIApplication application = null; + private TCComponentSchedule scheduleTag = null; + private ScheduleTreeLine rootscheduleTreeLine = null; + + private JButton addButton; + private JButton removeButton; +// private JComboBox ysr8_TaskUse; + private LOVComboBox ysr8_TaskUse; + private JComboBox workFlowTemp; + private iTextField taskReso; + private JCheckBox isTranOwner; + private JCheckBox isDevi; + + private JTree scheduleTree; + private JTree bomTree; + + //private String strLOVTaskUse = "YSR_Task_Use_LOV"; + private String strLOVWorkFlowTemp = "YSR_Workflow_Template_LOV"; + + public BOMTransPlanDialog(AbstractAIFUIApplication application, Frame frame, TCComponentSchedule scheduleTag) { + super(frame, true); + session = (TCSession) application.getSession(); + this.application = application; + this.scheduleTag = scheduleTag; + init(); + } + + private void init() { + + setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + setTitle("BOMƻ"); + this.addWindowListener(this); + + rootscheduleTreeLine = new ScheduleTreeLine(scheduleTag); + DefaultMutableTreeNode scheduleTop = new DefaultMutableTreeNode(rootscheduleTreeLine); + initTreeTableModel(scheduleTag, scheduleTop); + + DefaultTreeModel scheduleModel = new DefaultTreeModel(scheduleTop); + scheduleTree = new JTree(scheduleModel); + scheduleTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);// һֻѡһڵѡ + scheduleTree.setCellRenderer(new ScheduleDefaultTreeCellRenderer()); + JScrollPane jScrollPane = new JScrollPane(scheduleTree); + jScrollPane.setPreferredSize(new Dimension(300, 400)); + add("1.1.left.center",jScrollPane); + + JPanel centerPanel = new JPanel(); + centerPanel.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + addButton = new JButton("<<<"); + removeButton = new JButton("Ƴ>>>"); + removeButton.setVisible(false); +// ysr8_TaskUse = new JComboBox(); +// UtilApi.getOptionValues(session, ysr8_TaskUse, strLOVTaskUse); + ysr8_TaskUse = new LOVComboBox("YSR8_ScheduleTask01_LOV"); + workFlowTemp = new JComboBox(); + UtilApi.getOptionValues(session, workFlowTemp, strLOVWorkFlowTemp); + taskReso = new iTextField(30); + taskReso.setEditable(false); + taskReso.setToolTipText("˫ѡ"); + final GCSelectionUserCommand selectionUserCmd = new GCSelectionUserCommand(AIFUtility.getCurrentApplication().getDesktop(), session); + taskReso.addMouseListener(new MouseAdapter() { + + public void mouseClicked(MouseEvent mouseevent) { + if (mouseevent.getClickCount() == 2) { + isTranOwner.setSelected(false); + selectionUserCmd.setContextBean(taskReso); + try { + selectionUserCmd.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }); + isTranOwner = new JCheckBox("תִ"); + isTranOwner.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + if(isTranOwner.isSelected()){ + taskReso.setText(""); + } + } + }); + isDevi = new JCheckBox("汾ʱ"); + addButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + addButtonListener(); + } + }); + removeButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + removeButtonListener(); + } + }); + centerPanel.add("1.1.center.center",addButton); + centerPanel.add("2.1.center.center",removeButton); + centerPanel.add("3.1.left.center",new JLabel(" ")); + centerPanel.add("4.1.left.center",new JLabel(";:")); + centerPanel.add("5.1.left.center",ysr8_TaskUse); + centerPanel.add("6.1.left.center",new JLabel("ģ:")); + centerPanel.add("7.1.left.center",workFlowTemp); + centerPanel.add("8.1.left.center",new JLabel(":")); + centerPanel.add("9.1.left.center",taskReso); + centerPanel.add("10.1.left.center",new JLabel(" ")); + centerPanel.add("11.1.left.center",isTranOwner); + //centerPanel.add("12.1.left.center",isDevi); + add("1.2.left.center",centerPanel); + + try { + TCComponent[] projectList = scheduleTag.getReferenceListProperty("project_list"); + if( projectList != null && projectList.length > 0){ + String project_id = projectList[0].getProperty("project_id"); + TCComponentItemType tccomItemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem systemPart = tccomItemType.find(project_id); + if( systemPart != null){ + TCComponentItemRevision systemPartRevision = systemPart.getLatestItemRevision(); + TCComponentBOMLine bomLine=getBOMLine(session, systemPartRevision); + CheckBoxTreeNode itemRevTop = new CheckBoxTreeNode(systemPartRevision); + AIFComponentContext[] childLines = bomLine.getChildren(); + int childCount = bomLine.getChildrenCount(); + for(int ix = 0; ix < childCount; ix++ ){ + TCComponentBOMLine cl = (TCComponentBOMLine)childLines[ix].getComponent(); + String clt = cl.getItemRevision().getType(); + if(clt.equals("YSR8_MachPartsRevision") || clt.equals("YSR8_ElecPartsRevision")){ + CheckBoxTreeNode childTreeNode = new CheckBoxTreeNode(cl.getItemRevision()); + childTreeNode.setQuantity(cl.getProperty("bl_quantity")); + itemRevTop.add(childTreeNode); + } + } + + DefaultTreeModel bomModel = new DefaultTreeModel(itemRevTop); + bomTree = new JTree(bomModel); + bomTree.addMouseListener(new CheckBoxTreeNodeSelectionListener()); + bomTree.setCellRenderer(new CheckBoxTreeCellRenderer()); + JScrollPane jScrollPaneBom = new JScrollPane(bomTree); + jScrollPaneBom.setPreferredSize(new Dimension(300, 400)); + add("1.3.left.center",jScrollPaneBom); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + pack(); + centerToScreen(); + setVisible(true); + } + + private void addButtonListener(){ + if(scheduleTree != null && bomTree != null ){ + DefaultMutableTreeNode scheduleNode = (DefaultMutableTreeNode) scheduleTree.getLastSelectedPathComponent(); + CheckBoxTreeNode bomNode = (CheckBoxTreeNode) bomTree.getModel().getRoot(); + if(scheduleNode != null){ + int bomNodeChildCount = bomNode.getChildCount(); + List systemPartRevisions = new ArrayList(); + Listquantity = new ArrayList(); + for(int ix = 0; ix < bomNodeChildCount; ix++){ + CheckBoxTreeNode bomChildNode = (CheckBoxTreeNode) bomNode.getChildAt(ix); + if(bomChildNode.isSelected){ +// TCComponentItemRevision systemPartRevision = (TCComponentItemRevision) bomChildNode.getUserObject(); +// System.out.println("systemPartRevision = "+systemPartRevision); + systemPartRevisions.add((TCComponentItemRevision) bomChildNode.getUserObject()); + quantity.add(bomChildNode.getQuantity()); + } + } + TCUserService userService = (TCUserService) session.getUserService(); + Object objs[] = new Object[9]; + objs[0] = (TCComponentScheduleTask)((ScheduleTreeLine)scheduleNode.getUserObject()).getUserObject(); + objs[1] = systemPartRevisions.toArray(); + if(ysr8_TaskUse.getSelectedItem() != null ){ + objs[2] = ysr8_TaskUse.getSelectedDisplayString(); + objs[8] = ysr8_TaskUse.getSelectedItem(); + }else{ + objs[2] = ""; + objs[8] = "-1"; + } + if(workFlowTemp.getSelectedItem() != null){ + objs[3] = workFlowTemp.getSelectedItem(); + }else{ + objs[3] = ""; + } + objs[4] = isTranOwner.isSelected(); + objs[5] = isDevi.isSelected(); + objs[6] = quantity.toArray(); + objs[7] = taskReso.getText(); + try { + Object[] reb = (Object[])userService.call("BOM_Trans_Plan", objs); + if( reb != null ){ + int rebCnt = reb.length; + System.out.println("reb.length = "+rebCnt); + ScheduleTreeLine parentTreeLine = (ScheduleTreeLine)scheduleNode.getUserObject(); + for(int ix = 0; ix < rebCnt; ix++ ){ + populateTask(parentTreeLine, (TCComponent)reb[ix], scheduleNode); + } + scheduleTree.repaint(); + scheduleTree.updateUI(); + scheduleTag.refresh(); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + + private void removeButtonListener(){ + + } + + private void initTreeTableModel(TCComponentSchedule scheduleTag, DefaultMutableTreeNode top) { + try { + TCComponent scheduleTask = ScheduleHelper.getScheduleSummaryTask(scheduleTag); + TCProperty tcproperty = scheduleTask.getTCProperty("child_task_taglist"); + TCComponent atccomponent[] = tcproperty.getReferenceValueArray(); + for (int l = 0; l < atccomponent.length; l++) + populateTask(rootscheduleTreeLine, atccomponent[l], top); + + } catch (TCException e) { + e.printStackTrace(); + } + } + + public void populateTask(ScheduleTreeLine parentScheduleTreeLine, TCComponent tccomponent, DefaultMutableTreeNode parentTreeNode) { + if (tccomponent != null) { + ScheduleTreeLine scheduletreeline = new ScheduleTreeLine(tccomponent); + DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode(scheduletreeline); + parentTreeNode.add(treeNode); + parentScheduleTreeLine.add(scheduletreeline); + try { + TCComponent atccomponent[] = TaskHelper.getChildTasks((TCComponentScheduleTask) tccomponent); + for (int i = 0; i < atccomponent.length; i++) + populateTask(scheduletreeline, atccomponent[i], treeNode); + + } catch (TCException tcexception) { + tcexception.printStackTrace(); + } + } + } + + /** + * Զ,ÿڵóɲͬͼ + * @author + * + */ + public class ScheduleDefaultTreeCellRenderer extends DefaultTreeCellRenderer + { + /** + * ID + */ + private static final long serialVersionUID = 1L; + + /** + * дDefaultTreeCellRendererķ + */ + @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()); + } + + //õÿڵTreeNode + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + + this.setIcon(TCTypeRenderer.getIcon(((ScheduleTreeLine)node.getUserObject()).getUserObject())); + + return this; + } + } + public static TCComponentBOMLine getBOMLine(TCSession session, TCComponentItemRevision revision) { + TCComponentBOMLine bomLine = null; + try { + // ȡ汾 + TCComponentRevisionRuleType revRuleType = (TCComponentRevisionRuleType) session.getTypeComponent("RevisionRule"); + TCComponentRevisionRule revRule = revRuleType.getDefaultRule(); + // BOMWindow + TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow window = bomWinType.create(revRule); + window.lock(); + bomLine = window.setWindowTopLine(revision.getItem(), revision, null, null); + window.unlock(); + } catch (TCException e) { + e.printStackTrace(); + } + return bomLine; + } + + @Override + public void windowActivated(WindowEvent arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void windowClosed(WindowEvent arg0) { + // TODO Auto-generated method stub + ReloadOperation reloadoperation = new ReloadOperation(application); + try { + reloadoperation.executeOperation(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void windowClosing(WindowEvent arg0) { + // TODO Auto-generated method stub + } + + @Override + public void windowDeactivated(WindowEvent arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void windowDeiconified(WindowEvent arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void windowIconified(WindowEvent arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void windowOpened(WindowEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/src/cn/com/customization/schedule/BOMTransPlanHandler.java b/src/cn/com/customization/schedule/BOMTransPlanHandler.java new file mode 100644 index 0000000..cee9640 --- /dev/null +++ b/src/cn/com/customization/schedule/BOMTransPlanHandler.java @@ -0,0 +1,25 @@ +package cn.com.customization.schedule; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.util.MessageBox; + +public class BOMTransPlanHandler extends AbstractHandler +{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException + { + try + { + BOMTransPlanCommand cmd = new BOMTransPlanCommand(); + } + catch (Exception exception) + { + MessageBox.post(exception, true); + } + + return null; + } +} diff --git a/src/cn/com/customization/schedule/CheckBoxTreeCellRenderer.java b/src/cn/com/customization/schedule/CheckBoxTreeCellRenderer.java new file mode 100644 index 0000000..c96000f --- /dev/null +++ b/src/cn/com/customization/schedule/CheckBoxTreeCellRenderer.java @@ -0,0 +1,96 @@ +package cn.com.customization.schedule; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; + +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.DefaultMutableTreeNode; +import javax.swing.tree.TreeCellRenderer; + +import com.teamcenter.rac.common.TCTypeRenderer; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.schedule.common.tree.ScheduleTreeLine; + +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.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); +// if(leaf) +// label.setIcon(UIManager.getIcon("Tree.leafIcon")); +// else if(expanded) +// label.setIcon(UIManager.getIcon("Tree.openIcon")); +// else +// label.setIcon(UIManager.getIcon("Tree.closedIcon")); + + //õÿڵTreeNode + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + + label.setIcon(TCTypeRenderer.getIcon((TCComponentItemRevision)node.getUserObject())); + 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/cn/com/customization/schedule/CheckBoxTreeLabel.java b/src/cn/com/customization/schedule/CheckBoxTreeLabel.java new file mode 100644 index 0000000..fc374c5 --- /dev/null +++ b/src/cn/com/customization/schedule/CheckBoxTreeLabel.java @@ -0,0 +1,75 @@ +package cn.com.customization.schedule; + +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; + } +} diff --git a/src/cn/com/customization/schedule/CheckBoxTreeNode.java b/src/cn/com/customization/schedule/CheckBoxTreeNode.java new file mode 100644 index 0000000..a16cca3 --- /dev/null +++ b/src/cn/com/customization/schedule/CheckBoxTreeNode.java @@ -0,0 +1,113 @@ +package cn.com.customization.schedule; + +import javax.swing.tree.DefaultMutableTreeNode; + +public class CheckBoxTreeNode extends DefaultMutableTreeNode +{ + protected boolean isSelected; + private String quantity = ""; + + 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 String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } +} diff --git a/src/cn/com/customization/schedule/CheckBoxTreeNodeSelectionListener.java b/src/cn/com/customization/schedule/CheckBoxTreeNodeSelectionListener.java new file mode 100644 index 0000000..6185786 --- /dev/null +++ b/src/cn/com/customization/schedule/CheckBoxTreeNodeSelectionListener.java @@ -0,0 +1,31 @@ +package cn.com.customization.schedule; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import javax.swing.tree.DefaultTreeModel; + +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) + { + boolean isSelected = !node.isSelected(); + node.setSelected(isSelected); + ((DefaultTreeModel)tree.getModel()).nodeStructureChanged(node); + } + } + } +} \ No newline at end of file diff --git a/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameCommand.java b/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameCommand.java new file mode 100644 index 0000000..99b60cf --- /dev/null +++ b/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameCommand.java @@ -0,0 +1,32 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: ModifyTaskNameCommand.java +#======================================================================================================= +# Date Name Action Description of Change +# 2010-12-2 tyl Ini ʼļ +#======================================================================================================= + */ +package cn.com.customization.schedule; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCException; + +public class ModifyTaskOrDeliveryNameCommand extends AbstractAIFCommand { + public AbstractAIFApplication application; + + public ModifyTaskOrDeliveryNameCommand(AbstractAIFApplication abstractaifapplication) throws TCException { + application = abstractaifapplication; + execute(); + + } + + private void execute() throws TCException { + new ModifyTaskOrDeliveryNameDialog(application,"ʱ򽻸"); + } + +} diff --git a/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameDialog.java b/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameDialog.java new file mode 100644 index 0000000..56b15c8 --- /dev/null +++ b/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameDialog.java @@ -0,0 +1,152 @@ +package cn.com.customization.schedule; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentScheduleDeliverable; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentTaskDeliverable; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +public class ModifyTaskOrDeliveryNameDialog extends AbstracModifyDialog { + + /** + * serialVersionUID:TODOĹܣ + * @since Ver 1.1 + */ + public static final long serialVersionUID = 1L; + + public ModifyTaskOrDeliveryNameDialog(AbstractAIFApplication abstractaifapplication, String title) { + super(abstractaifapplication, title); + } + + public void confirmAction(int index, String txt) { + if (!((currentRole.equalsIgnoreCase("DBA")) || (currentUser.equals(owningUser)))) { + MessageBox.post("ʱ߻DBAû޸ģ", "INFO", MessageBox.ERROR); + return; + } + if(isModifyTaskName){ + modifyTaskName(index, txt, false); + } + if(isModifyDeliveryName){ + modifyDeliveryName(index, txt, false); + } + this.dispose(); + } + + public void modifyTaskName(int index, String txt, boolean isReplace) { + try { + System.out.println("modifyTaskName = " + tasks.length); + for (int i = 0; i < tasks.length; i++) { + TCComponentScheduleTask task = (TCComponentScheduleTask) tasks[i]; + System.out.println("modifyTaskName:: sch_summary_task = " + sch_summary_task); + + if (sch_summary_task != null && !sch_summary_task.equals(task)) { + + String status = task.getTCProperty("fnd0status").getStringValue(); + System.out.println("status = "+status); + //MessageBox.post("status1222222222211111="+status, "INFO", MessageBox.ERROR); + if (status.equals("not_started")||status.equals("δʼ")) { + String taskName = task.getProperty("object_name"); + System.out.println("taskName="+taskName); + if (isReplace) { + taskName = replaceName(taskName, replaceSource.getText(), replaceObject.getText()); + task.setProperty("object_name", taskName); + } else { + switch (index) { + case 0: + System.out.println(" scheduleID + taskName=" +scheduleID + taskName); + task.setProperty("object_name", scheduleID + taskName); + break; + case 1: + task.setProperty("object_name", scheduleName + taskName); + break; + case 2: + task.setProperty("object_name", txt + taskName); + break; + } + } + } + } + } + } + catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * modifyDeliveryName:޸ʱ + * */ + public void modifyDeliveryName(int index, String txt, boolean isReplace) { + try { + System.out.println("modifyDeliveryName = " + tasks.length); + for (int i = 0; i < tasks.length; i++) { + TCComponentScheduleTask task = (TCComponentScheduleTask) tasks[i]; + String status = task.getProperty("status"); + if (status.equals("0")) { +// String taskName = task.getProperty("object_name"); + TCComponent[] deliveries = task.getReferenceListProperty("sch_task_deliverable_list"); + if (deliveries != null) { + for (int m = 0; m < deliveries.length; m++) { + TCComponentTaskDeliverable delivery = (TCComponentTaskDeliverable) deliveries[m]; + + System.out.println("delivery = " + delivery); + TCComponentScheduleDeliverable scheduleDelivery = (TCComponentScheduleDeliverable) delivery.getReferenceProperty("schedule_deliverable"); + TCComponent deliverable_inst = scheduleDelivery.getReferenceProperty("deliverable_inst"); + if (deliverable_inst == null) { + String deliverable_name = scheduleDelivery.getProperty("deliverable_name"); + String strTaskDeliverableName = delivery.getProperty("object_name"); + System.out.println("strTaskDeliverableName[" + i +"] = " + strTaskDeliverableName); + if (isReplace) { + deliverable_name = replaceName(deliverable_name, replaceSource.getText(), replaceObject.getText()); + scheduleDelivery.setProperty("deliverable_name", deliverable_name); + scheduleDelivery.setProperty("object_name", deliverable_name); + + strTaskDeliverableName = replaceName(strTaskDeliverableName, replaceSource.getText(), replaceObject.getText()); + delivery.setProperty("object_name",strTaskDeliverableName); + } else { + switch (index) { + case 0: + scheduleDelivery.setProperty("deliverable_name", scheduleID + deliverable_name); + scheduleDelivery.setProperty("object_name", scheduleID + deliverable_name); + delivery.setProperty("object_name",scheduleID + strTaskDeliverableName); + break; + case 1: + scheduleDelivery.setProperty("deliverable_name", scheduleName + deliverable_name); + scheduleDelivery.setProperty("object_name", scheduleName + deliverable_name); + delivery.setProperty("object_name",scheduleName + strTaskDeliverableName); + break; + case 2: + scheduleDelivery.setProperty("deliverable_name", txt + deliverable_name); + scheduleDelivery.setProperty("object_name", txt + deliverable_name); + delivery.setProperty("object_name",txt + strTaskDeliverableName); + break; + } + } + } + } + } + } + } + } + catch (TCException e) { + e.printStackTrace(); + } + } + + + public void replaceAction() { + if(isModifyTaskName){ + modifyTaskName(-1, "", true); + } + if(isModifyDeliveryName){ + modifyDeliveryName(-1, "", true); + } + this.dispose(); + } + + public void cancelAction() { + this.dispose(); + } +} \ No newline at end of file diff --git a/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameHandler.java b/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameHandler.java new file mode 100644 index 0000000..0b249c6 --- /dev/null +++ b/src/cn/com/customization/schedule/ModifyTaskOrDeliveryNameHandler.java @@ -0,0 +1,39 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: ModifyTaskNameHandler.java +#======================================================================================================= +# Date Name Action Description of Change +# 2010-12-2 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.schedule; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class ModifyTaskOrDeliveryNameHandler extends AbstractHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + ModifyTaskOrDeliveryNameCommand modifyCommand =new ModifyTaskOrDeliveryNameCommand(app); + modifyCommand.executeModal(); + } + catch (TCException e) { + e.printStackTrace(); + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/cn/com/customization/schedule/YSRScheduleTreeTableModel.java b/src/cn/com/customization/schedule/YSRScheduleTreeTableModel.java new file mode 100644 index 0000000..813c7fa --- /dev/null +++ b/src/cn/com/customization/schedule/YSRScheduleTreeTableModel.java @@ -0,0 +1,16 @@ +package cn.com.customization.schedule; + +import com.teamcenter.rac.aif.common.AIFTreeTableModel; +import com.teamcenter.rac.schedule.common.tree.ScheduleTreeLine; + +public class YSRScheduleTreeTableModel extends AIFTreeTableModel { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public YSRScheduleTreeTableModel(ScheduleTreeLine scheduleTreeLine, String []titleNames){ + super(scheduleTreeLine, titleNames); + } +} diff --git a/src/cn/com/customization/schedule/YSRTreeTable.java b/src/cn/com/customization/schedule/YSRTreeTable.java new file mode 100644 index 0000000..5833d2e --- /dev/null +++ b/src/cn/com/customization/schedule/YSRTreeTable.java @@ -0,0 +1,10 @@ +package cn.com.customization.schedule; + +import com.teamcenter.rac.aif.common.AIFTreeTable; + +public class YSRTreeTable extends AIFTreeTable { + + public YSRTreeTable(YSRScheduleTreeTableModel ysrSTTM){ + super(ysrSTTM); + } +} diff --git a/src/cn/com/customization/util/CheckBoxColumnRender.java b/src/cn/com/customization/util/CheckBoxColumnRender.java new file mode 100644 index 0000000..288a92e --- /dev/null +++ b/src/cn/com/customization/util/CheckBoxColumnRender.java @@ -0,0 +1,52 @@ +/* +#============================================================================= +# +# Copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: CheckBoxColumnRender.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz Ini ʼ(From Shaangu) +#============================================================================= +*/ +package cn.com.customization.util; + +import java.awt.Component; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.table.DefaultTableCellRenderer; + +public class CheckBoxColumnRender extends DefaultTableCellRenderer { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * + */ + public CheckBoxColumnRender() { + super(); + } + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + //õͷ + JCheckBox checkBox=new JCheckBox(); +// JTableHeader header = table.getTableHeader(); +// if (header != null) { +// setForeground(header.getForeground()); +// setBackground(header.getBackground()); +// setFont(header.getFont()); +// } + setHorizontalAlignment(JLabel.CENTER); + checkBox.setSelected(Boolean.valueOf(value.toString())); +// (value == null) ? "" : value.toString() + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return checkBox; + } +} diff --git a/src/cn/com/customization/util/ColumnGroup.java b/src/cn/com/customization/util/ColumnGroup.java new file mode 100644 index 0000000..353cbc3 --- /dev/null +++ b/src/cn/com/customization/util/ColumnGroup.java @@ -0,0 +1,197 @@ +package cn.com.customization.util; + +import java.awt.Component; +import java.awt.Dimension; +import java.util.Enumeration; +import java.util.Vector; + +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +public class ColumnGroup { + protected TableCellRenderer renderer; + + protected Vector v; + + protected String text; + + protected int margin = 0; + + public ColumnGroup(String text) { + this(null, text); + } + + public ColumnGroup(TableCellRenderer renderer, String text) { + if (renderer == null) { + this.renderer = new DefaultTableCellRenderer() { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JTableHeader header = table.getTableHeader(); + if (header != null) { + setForeground(header.getForeground()); + setBackground(header.getBackground()); + setFont(header.getFont()); + } + setHorizontalAlignment(JLabel.CENTER); + this.setText((value == null) ? "" : value.toString()); + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return this; + } + }; + } else { + this.renderer = renderer; + } + this.text = text; + v = new Vector(); + } + + /** + * @param obj TableColumn or ColumnGroup + */ + public void add(Object obj) { + if (obj == null) { return; } + v.addElement(obj); + } + + /** + * @param c TableColumn + * @param v ColumnGroups + */ + public Vector getColumnGroups(TableColumn c, Vector g) { + g.addElement(this); + if (v.contains(c)) + return g; + Enumeration enumeration = v.elements(); + while (enumeration.hasMoreElements()) { + Object obj = enumeration.nextElement(); + if (obj instanceof ColumnGroup) { + Vector groups = (Vector) ((ColumnGroup) obj).getColumnGroups(c, (Vector) g.clone()); + if (groups != null) + return groups; + } + } + return null; + } + + public TableCellRenderer getHeaderRenderer() { + return renderer; + } + + public Object getHeaderValue() { + return text; + } + + public int getSize() { + return v == null ? 0 : v.size(); + } + + public Dimension getSize(JTable table) { + Component comp = renderer.getTableCellRendererComponent(table, getHeaderValue(), false, false, -1, -1); + int height = comp.getPreferredSize().height; + int width = 0; + Enumeration enumeration = v.elements(); + while (enumeration.hasMoreElements()) { + Object obj = enumeration.nextElement(); + if (obj instanceof TableColumn) { + TableColumn aColumn = (TableColumn) obj; + width += aColumn.getWidth(); + width += margin; + } else { + width += ((ColumnGroup) obj).getSize(table).width; + } + } + return new Dimension(width, height); + } + + /** + * :(2003-7-14 10:53:26) + * @return java.lang.String + */ + public java.lang.String getText() { + return text; + } + + /** + * бͷɾColumn :(2002-9-25 15:49:00) + */ + public boolean removeColumn(ColumnGroup ptg, TableColumn tc) { + boolean retFlag = false; + if (tc != null) { + for (int i = 0; i < ptg.v.size(); i++) { + Object tmpObj = ptg.v.get(i); + if (tmpObj instanceof ColumnGroup) { + retFlag = removeColumn((ColumnGroup) tmpObj, tc); + // ҵ + if (retFlag) + break; + } else if (tmpObj instanceof TableColumn) { + // жǷҵĶ + if (tmpObj == tc) { + ptg.v.remove(i); + retFlag = true; + break; + } + } + } + } + return retFlag; + } + + /** + * бͷɾColumnGrp ɾtrue,򷵻false; :(2002-9-25 15:49:00) + */ + public boolean removeColumnGrp(ColumnGroup ptg, ColumnGroup tg) { + boolean retFlag = false; + if (tg != null) { + for (int i = 0; i < ptg.v.size(); i++) { + Object tmpObj = ptg.v.get(i); + if (tmpObj instanceof ColumnGroup) { + // жǷҵĶ + if (tmpObj == tg) { + ptg.v.remove(i); + retFlag = true; + break; + } else { + retFlag = removeColumnGrp((ColumnGroup) tmpObj, tg); + // ҵ + if (retFlag) + break; + + } + } else if (tmpObj instanceof TableColumn) { + break; + } + } + } + return retFlag; + } + + public void setColumnMargin(int margin) { + this.margin = margin; + Enumeration enumeration = v.elements(); + while (enumeration.hasMoreElements()) { + Object obj = enumeration.nextElement(); + if (obj instanceof ColumnGroup) { + ((ColumnGroup) obj).setColumnMargin(margin); + } + } + } + + public void setHeaderRenderer(TableCellRenderer renderer) { + if (renderer != null) { + this.renderer = renderer; + } + } + + /** + * :(2003-7-14 10:53:26) + * @param newText java.lang.String + */ + public void setText(java.lang.String newText) { + text = newText; + } +} diff --git a/src/cn/com/customization/util/DataSetFinder.java b/src/cn/com/customization/util/DataSetFinder.java new file mode 100644 index 0000000..496295a --- /dev/null +++ b/src/cn/com/customization/util/DataSetFinder.java @@ -0,0 +1,251 @@ +/* + #======================================================================================================= + # + # Copyright (c) 2007 Origin Enterprise Solution LTD. + # + #======================================================================================================= + # File description: ݼ + #======================================================================================================= + # Date Name Action Description of Change + # 20090301 Matt Shan Ini ݼ + #======================================================================================================= + */ +package cn.com.customization.util; + +import java.io.File; + +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.util.MessageBox; + +public class DataSetFinder { + + private TCSession session = null; + + /** + * ݼ + * @param session ϵͳsession + */ + public DataSetFinder(TCSession pSession) { + queryType = null; + datasetQuery = null; + boolean flag = false; + try { + session = pSession; + its = session.getTextService(); + queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + } + catch (TCException imane) { + imane.printStackTrace(); + imane.dump(); + } + try { + datasetQuery = (TCComponentQuery) queryType.find("ݼ..."); + } + catch (TCException imane) { + imane.printStackTrace(); + imane.dump(); + flag = true; + } + if (datasetQuery == null || flag) { + try { + datasetQuery = (TCComponentQuery) queryType.find(its.getTextValue("DataSet...")); + } + catch (TCException imane) { + imane.printStackTrace(); + imane.dump(); + } + } + } + + /** + * ѯݼ + * @param datasetname ݼ + * @return ݼƲѯݼ + */ + public TCComponentDataset FindDatasetByName(String datasetname, String pOwningUser, String pOwningGroup, String pDatasetType) { + System.out.println("-----------FindDatasetByName"); + try { + //String f_dataset_name[] = { its.getTextValue("Name"), its.getTextValue("OwningUser"), its.getTextValue("OwningGroup"), its.getTextValue("DatasetType") }; + String f_dataset_name[] = new String[4]; + f_dataset_name[0] = its.getTextValue("Name"); + if(f_dataset_name[0] == null){ + f_dataset_name[0] = "Name"; + } + f_dataset_name[1] = its.getTextValue("OwningUser"); + if(f_dataset_name[1] == null){ + f_dataset_name[1] = "Owning User"; + } + f_dataset_name[2] = its.getTextValue("OwningGroup"); + if(f_dataset_name[2] == null){ + f_dataset_name[2] = "Owning Group"; + } + f_dataset_name[3] = its.getTextValue("DatasetType"); + if(f_dataset_name[3] == null){ + f_dataset_name[3] = "Dataset Type"; + } + f_dataset_name_value = new String[4]; + f_dataset_name_value[0] = datasetname; + f_dataset_name_value[1] = pOwningUser; + f_dataset_name_value[2] = pOwningGroup; + f_dataset_name_value[3] = pDatasetType; + com.teamcenter.rac.kernel.TCComponent dataset[] = datasetQuery.execute(f_dataset_name, f_dataset_name_value); + if (dataset == null || dataset.length == 0) { + return null; + } else { + TCComponentDataset dataset0 = (TCComponentDataset) dataset[0]; + TCComponentDataset dataset1 = dataset0.latest(); + return dataset1; + } + } + catch (TCException imane) { + imane.printStackTrace(); + imane.dump(); + return null; + } + } + + /** + * ȡģݼ + * @param datasetname ݼ + * @return ݼƲѯݼ + */ + public TCComponentDataset FindDatasetByName(String datasetname) { + TCComponent[] components = null; + try { + TCComponentItemRevision revision =null; + TCComponentItemType tccomItemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem[]items =tccomItemType.findItems(datasetname); + if(items.length >0){ + revision=items[0].getLatestItemRevision() ; + } + components = revision.getRelatedComponents("IMAN_specification");// ͨϵҶ + for (TCComponent component : components) { + if (component instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) component; + return dataset; + } + } + } catch (TCException e) { + e.printStackTrace(); + return null; + } + return null; + } + + /** + * ݼļָ· + * @param dataset ݼ + * @param nameRef ݼ + * @param filename ļ + * @param dir · + * @return ļ + */ + public File ExportFileToDir(TCComponentDataset dataset, String nameRef, String filename, String dir) { + File exportFile = null; + try { + String workdir = dir; + File tFile = new File(workdir, filename); + if (tFile.exists()) + tFile.delete(); + if (!checkAccessPrivilige(session.getUser(), dataset, "EXPORT")) { + MessageBox.post("ûȨرģļ", "ʾ", MessageBox.WARNING); + return null; + } + TCComponentTcFile files[] = dataset.getTcFiles(); + if (files.length != 1) { + MessageBox.post("鱨ģļǷȷ", "ʾ", MessageBox.WARNING); + return null; + } + for (int i = 0; i < files.length; i++) { + exportFile = files[i].getFile(workdir, filename); + } + return exportFile; + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + private boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } + + /** + * ݼļָ· + * @param dataset ݼ + * @param nameRef ݼ + * @param filename ļ + * @param dir · + * @return ļ + */ + public File ExportFileToDir(TCComponentDataset dataset, String filename, String dir) { + File exportFile = null; + try { + String workdir = dir; + File tFile = new File(workdir, filename); + if (tFile.exists()) + tFile.delete(); + if (!checkAccessPrivilige(session.getUser(), dataset, "EXPORT")) { + MessageBox.post("ûȨرģļ", "ʾ", MessageBox.WARNING); + return null; + } + TCComponentTcFile files[] = dataset.getTcFiles(); + if (files.length != 1) { + MessageBox.post("鱨ģļǷȷ", "ʾ", MessageBox.WARNING); + return null; + } + for (int i = 0; i < files.length; i++) { + exportFile = files[i].getFile(workdir, filename); + } + return exportFile; + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public File ExportFileToDir(TCComponentDataset dataset, String dir) { + File exportFile = null; + try { + String workdir = dir; + if (!checkAccessPrivilige(session.getUser(), dataset, "EXPORT")) { + MessageBox.post("ûȨرģļ", "ʾ", MessageBox.WARNING); + return null; + } + TCComponentTcFile files[] = dataset.getTcFiles(); + if (files.length != 1) { + MessageBox.post("鱨ģļǷȷ", "ʾ", MessageBox.WARNING); + return null; + } + for (int i = 0; i < files.length; i++) { + exportFile = files[i].getFile(workdir); + } + return exportFile; + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + private TCComponentQueryType queryType; + private TCComponentQuery datasetQuery; + private TCTextService its; + private String f_dataset_name_value[]; +} diff --git a/src/cn/com/customization/util/GetAllUserIds.java b/src/cn/com/customization/util/GetAllUserIds.java new file mode 100644 index 0000000..3bd2af7 --- /dev/null +++ b/src/cn/com/customization/util/GetAllUserIds.java @@ -0,0 +1,132 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: GetAllUserIds.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:51:32 tyl Ini ʼļ +#======================================================================================================= + */ +package cn.com.customization.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; + +public class GetAllUserIds { + private AbstractAIFUIApplication pseapp; + /** + * TCжQuery + */ + private String findType = "__WEB_find_user"; + /** + * TCжQueryеûػ + */ + private String str_key = "UserId"; + /** + * TCжQueryбػȡֵ + */ + private String str_value = "*"; + /** + * װûϢ + */ + private List allUsers = null; + private Map userMap; + + public GetAllUserIds(AbstractAIFUIApplication app) { + System.out.println("_______________GetAllUserIds________"); + this.pseapp = app; + userMap = new HashMap(); + allUsers = new ArrayList(); + getAllUser(); + } + + /** + * getAllUser:ͨѯõеû + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public void getAllUser() { + System.out.println("__________getAllUser__________"); + TCSession session = (TCSession) pseapp.getSession(); + InterfaceAIFComponent components[] = null; + TCComponentUser user = null; + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find(findType); + //querytype.clearCache(); + String as[] = { textService.getTextValue(str_key) }; + String as1[] = new String[1]; + as1[0] = str_value; + //query.clearCache(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + System.out.println("list = "+list); + if (list != null) { + int count = list.getListCount(); + System.out.println("count = " + count); + if(count > 0){ + components = new InterfaceAIFComponent[count]; + for (int i = 0; i < count; i++) { + if(list.get(i) != null){ + components[i] = list.get(i).getComponent(); + } + } + } + } else { + System.out.println("__WEB_find_user==null"); + } + } + catch (TCException e) { + e.printStackTrace(); + } + for (int i = 0; i < components.length; i++) { + if (components[i] instanceof TCComponentUser) { + user = (TCComponentUser) components[i]; + try { + String userid = user.getUserId().toString(); + String userName = user.getProperty("user_name"); + userMap.put(userid + "(" + userName + ")", user.toString()); + allUsers.add(userid + "(" + userName + ")"); + } + catch (TCException e) { + e.printStackTrace(); + } + } + } + } + + private static List userIDs = new ArrayList(); + + public static synchronized void setUsers(List users) { + userIDs = users; + } + + public static synchronized List getUsers() { + return userIDs; + } + + public List getAllUsers() { + return allUsers; + } + + public Map getUserMap() { + return userMap; + } +} diff --git a/src/cn/com/customization/util/GetChoosePath.java b/src/cn/com/customization/util/GetChoosePath.java new file mode 100644 index 0000000..e7b02b5 --- /dev/null +++ b/src/cn/com/customization/util/GetChoosePath.java @@ -0,0 +1,100 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: GetChoosePath.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:45:21 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.util; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; + +import javax.swing.JFileChooser; + +public class GetChoosePath { + + public String getPath(String filename) { + String tempPath = System.getProperty("java.io.tmpdir"); + File tempFile = new File(tempPath + filename); + JFileChooser jfc = null; + if (!tempFile.exists()) { + try { + tempFile.createNewFile(); + jfc = new JFileChooser(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + if (tempFile.exists()) { + BufferedReader in; + try { + in = new BufferedReader(new InputStreamReader(new FileInputStream(tempFile))); + String line; + try { + line = in.readLine(); + if ((line != null) && (line.length() > 0)) { + File file = new File(line); + if (file.exists()) { + jfc = new JFileChooser(file); + } else { + jfc = new JFileChooser(); + } + } else { + jfc = new JFileChooser(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + } + } + } + jfc.setFileSelectionMode(JFileChooser.SAVE_DIALOG); + jfc.setInheritsPopupMenu(true); +// jfc.setDialogTitle("..."); + jfc.setMultiSelectionEnabled(false); + + jfc.setFileFilter(new javax.swing.filechooser.FileFilter() { + @Override + public boolean accept(File f) { + if (f.isDirectory()) + return true; + else + return false; + } + + @Override + public String getDescription() { + return null;//дļ + } + }); + + int openOrCancel = jfc.showSaveDialog(null); + if (openOrCancel == 0) { + try { + BufferedWriter output; + output = new BufferedWriter(new FileWriter(tempFile)); + output.write(jfc.getSelectedFile().getAbsolutePath()); + output.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + File file = jfc.getSelectedFile(); + return file.getAbsolutePath(); + } + return ""; + } +} \ No newline at end of file diff --git a/src/cn/com/customization/util/GetCommonInfo.java b/src/cn/com/customization/util/GetCommonInfo.java new file mode 100644 index 0000000..14e0fd8 --- /dev/null +++ b/src/cn/com/customization/util/GetCommonInfo.java @@ -0,0 +1,164 @@ +/* +#============================================================================= +# +# copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: GetCommonInfo.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz õһЩͨϢ(From shangu) +#============================================================================= + */ +package cn.com.customization.util; + +import java.awt.HeadlessException; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; + +import javax.swing.JFileChooser; + +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GetCommonInfo { + private TCSession session; + + public GetCommonInfo(TCSession session) { + this.session = session; + + } + + /** + * getChoosePath:õûѡ· + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public String getChoosePath() { + String tempPath = System.getProperty("java.io.tmpdir"); + String currentPath = ""; + try { + File file1 = new File(tempPath + "\\export.txt"); + JFileChooser jfc = null; + if (file1.exists()) { + BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file1))); + String line = in.readLine(); + if (line != null) { + jfc = new JFileChooser(new File(line)); + } else { + jfc = new JFileChooser(); + } + } else { + jfc = new JFileChooser(); + } + + jfc.setFileSelectionMode(JFileChooser.SAVE_DIALOG); + int openOrCann = jfc.showSaveDialog(null); + if (openOrCann == 1) { + return currentPath; + } + // 洢ûѡ· + File file2 = new File(tempPath + "\\export.txt"); + if (!file2.exists()) { + file2.createNewFile(); + } + try { + BufferedWriter output = new BufferedWriter(new FileWriter(file2)); + output.write(jfc.getSelectedFile().getAbsolutePath()); + output.close(); + currentPath = jfc.getSelectedFile().getAbsolutePath(); + } catch (IOException e) { + e.printStackTrace(); + } + + } catch (HeadlessException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return currentPath; + } + + public boolean isExistFiles(String path) { + boolean flag = false; + File file = new File(path); + if (file.isDirectory()) { + if (file.listFiles().length > 0) { + flag = true; + } + } + return flag; + } + + /** + * existFile:жļǷ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public boolean existFile(String filePath, String fileName) { + boolean exist = false; + try { + if (fileName.indexOf('/') >= 0) { + fileName = fileName.replace('/', '_'); + } + File file = new File(filePath + "\\" + fileName); + System.out.println("filePath_fileName:" + filePath + "\\" + fileName); + if (file.exists()) { + exist = true; + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("ڼļǷڵʱ򣬳ִ", "ERROR", MessageBox.ERROR); + } + return exist; + } + + /** + * ǷѾ + * @param tccomponent + * @return Ƿ񷢲 + */ + public boolean isReleased(TCComponent tccomponent) { + boolean flag = false; + try { + String s = tccomponent.getProperty("release_status_list"); + if (s != null && s.length() > 0) + flag = true; + } catch (TCException tcexception) { + flag = false; + } + return flag; + } + + /** + * existFile:ǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } + +} diff --git a/src/cn/com/customization/util/GetMessageDialog.java b/src/cn/com/customization/util/GetMessageDialog.java new file mode 100644 index 0000000..bfa86f6 --- /dev/null +++ b/src/cn/com/customization/util/GetMessageDialog.java @@ -0,0 +1,91 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: GetMessageDialog.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 04:01:59 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.util; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URL; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Separator; +import com.teamcenter.rac.util.VerticalLayout; + +public class GetMessageDialog extends AbstractAIFDialog { + /** + * serialVersionUID:TODOһ仰ʾʲô + * @since Ver 1.1 + */ + + private static final long serialVersionUID = 1L; + private int value = 0; + private String title = ""; + private String info = ""; + + public GetMessageDialog(String title, String info) { + super(true); + this.title=title; + this.info=info; + this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + } + + public int getValue() { + setPersistentDisplay(true); + setOptimalDisplay(false); + setTitle(title); + JPanel parentPanel; + JPanel itemInfoPanel; + parentPanel = new JPanel(new VerticalLayout(5, 2, 2, 2, 2)); + itemInfoPanel = new JPanel(new PropertyLayout()); + + URL url=this.getClass().getResource("image/info.png"); + JLabel iconLabel=new JLabel(); + iconLabel.setIcon(new ImageIcon(url)); + + itemInfoPanel.add("1.1.left.center",iconLabel); + itemInfoPanel.add("1.2.left.center",new JLabel(info)); + JButton buttonYes = new JButton(""); + buttonYes.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + value = 0; + GetMessageDialog.this.dispose(); + } + }); + JButton buttonNo = new JButton(""); + buttonNo.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + value = 1; + GetMessageDialog.this.dispose(); + } + }); + JPanel panelButton = new JPanel(new FlowLayout()); + panelButton.add(buttonYes); + panelButton.add(buttonNo); + parentPanel.add("top.bin", new Separator()); + parentPanel.add("top.bind.left.top", itemInfoPanel); + parentPanel.add("bottom.nobind.center.top", panelButton); + getContentPane().add(parentPanel); + pack(); + Dimension screen = getToolkit().getScreenSize(); // õĻߴ + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); + setVisible(true); + return value; + } +} \ No newline at end of file diff --git a/src/cn/com/customization/util/GetMessagePromptDialog.java b/src/cn/com/customization/util/GetMessagePromptDialog.java new file mode 100644 index 0000000..9e7d337 --- /dev/null +++ b/src/cn/com/customization/util/GetMessagePromptDialog.java @@ -0,0 +1,106 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: GetMessagePromptDialog.java +#======================================================================================================= +# Date Name Action Description of Change +# 2009-11-13 tyl Ϣʾ +#======================================================================================================= + */ +package cn.com.customization.util; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URL; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.VerticalLayout; + +public class GetMessagePromptDialog extends AbstractAIFDialog { + + /** + * serialVersionUID:TODOһ仰ʾʲô + * @since Ver 1.1 + */ + + private static final long serialVersionUID = 1L; + private String title; + private String info; + private String info2; + private int value = 1; + + /** + * Creates a new instance of PromptDialog. + */ + + public GetMessagePromptDialog(String title, String info) { + super(true); + this.title = title; + this.info = info; + } + + public GetMessagePromptDialog(String title, String info, String info2) { + super(true); + this.title = title; + this.info = info; + this.info2 = info2; + } + + // ؾ + public int getValue() { + setPersistentDisplay(true); + setOptimalDisplay(false); + setTitle(title); + + JPanel parentPanel; + JPanel itemInfoPanel; + parentPanel = new JPanel(new VerticalLayout(5, 2, 2, 2, 2)); + itemInfoPanel = new JPanel(new PropertyLayout()); + URL url = this.getClass().getResource("image/info.png"); + JLabel iconLabel = new JLabel(); + iconLabel.setIcon(new ImageIcon(url)); + + itemInfoPanel.add("1.1.left.center", iconLabel); + itemInfoPanel.add("1.2.left.center", new JLabel(info)); + itemInfoPanel.add("2.1.left.center", new JLabel(" ")); + itemInfoPanel.add("2.2.left.center", new JLabel(info2)); + JButton buttonYes = new JButton(""); + buttonYes.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + value = 0; + GetMessagePromptDialog.this.dispose(); + } + }); + JButton buttonNo = new JButton(""); + buttonNo.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + value = 1; + GetMessagePromptDialog.this.dispose(); + } + }); + JPanel panelButton = new JPanel(new FlowLayout()); + panelButton.add(buttonYes); + panelButton.add(buttonNo); + parentPanel.add("top.bin", new JLabel(" ")); + parentPanel.add("top.bind.left.top", itemInfoPanel); + parentPanel.add("bottom.nobind.center.top", panelButton); + getContentPane().add(parentPanel); + pack(); + Dimension screen = getToolkit().getScreenSize(); // õĻߴ + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); + setVisible(true); + return value; + } + +} diff --git a/src/cn/com/customization/util/GroupableTableHeader.java b/src/cn/com/customization/util/GroupableTableHeader.java new file mode 100644 index 0000000..e45705b --- /dev/null +++ b/src/cn/com/customization/util/GroupableTableHeader.java @@ -0,0 +1,89 @@ +package cn.com.customization.util; + + +import java.util.Enumeration; +import java.util.Vector; + +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + + + +/** + * GroupableTableHeader + * @author flyx + */ + +public class GroupableTableHeader extends JTableHeader { + /** + * + */ + private static final long serialVersionUID = 1L; + private static final String uiClassID = "GroupableTableHeaderUI"; + protected Vector columnGroups = null; + public GroupableTableHeader(TableColumnModel model) { + super(model); + setUI(new GroupableTableHeaderUI()); + setReorderingAllowed(false); + setRequestFocusEnabled(false); + } +public void addColumnGroup(ColumnGroup g) { + if (columnGroups == null) { + columnGroups = new Vector(); + } + columnGroups.addElement(g); +} +/** + * + * :(2001-8-31 15:54:29) + */ +public void clearColumnGroups() { + columnGroups = null; +} +public ColumnGroup[] getColumnGroups() { + ColumnGroup[] retg=null; + if (columnGroups.size()>0) { + retg=new ColumnGroup[columnGroups.size()]; + columnGroups.copyInto(retg); + } + return retg; +} +public Enumeration getColumnGroups(TableColumn col) { + if (columnGroups == null) + return null; + Enumeration enumi = columnGroups.elements(); + while (enumi.hasMoreElements()) { + ColumnGroup cGroup = (ColumnGroup) enumi.nextElement(); + Vector v_ret = (Vector) cGroup.getColumnGroups(col, new Vector()); + if (v_ret != null) { + return v_ret.elements(); + } + } + return null; +} +/** + * Identifies whether or not this component can receive the focus. + * A disabled button, for example, would return false. + * + * @return true if this component can receive the focus + */ +public boolean isFocusTraversable() { + return super.isFocusTraversable() && isRequestFocusEnabled(); +} +public void setColumnMargin() { + if (columnGroups == null) + return; + int columnMargin = getColumnModel().getColumnMargin(); + Enumeration enumi = columnGroups.elements(); + while (enumi.hasMoreElements()) { + ColumnGroup cGroup = (ColumnGroup) enumi.nextElement(); + cGroup.setColumnMargin(columnMargin); + } +} +public void setReorderingAllowed(boolean b) { + reorderingAllowed = b; +} +} + + diff --git a/src/cn/com/customization/util/GroupableTableHeaderUI.java b/src/cn/com/customization/util/GroupableTableHeaderUI.java new file mode 100644 index 0000000..bcd951d --- /dev/null +++ b/src/cn/com/customization/util/GroupableTableHeaderUI.java @@ -0,0 +1,242 @@ +package cn.com.customization.util; + + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicTableHeaderUI; +import javax.swing.table.*; + +/** + * ͷTableHeaderUI + * + * @author flyx + */ +public class GroupableTableHeaderUI extends BasicTableHeaderUI { + private int m_height; + + private Dimension createHeaderSize(long width) { + TableColumnModel columnModel = header.getColumnModel(); + width += columnModel.getColumnMargin() * columnModel.getColumnCount(); + if (width > Integer.MAX_VALUE) { + width = Integer.MAX_VALUE; + } + return new Dimension((int) width, getHeaderHeight()); + } + + /** + * øöͷµĻ(zjb) ݹ :(02-4-8 18:03:56) + * + * @return int + * @param cg + * nc.ui.pub.beans.table.ColumnGroup + */ + private int getColCountUnderColGroup(ColumnGroup cg, int iCount) { + Vector v = cg.v; + for (int i = 0; i < v.size(); i++) { + Object obj = v.elementAt(i); + if (obj instanceof ColumnGroup) + iCount = getColCountUnderColGroup((ColumnGroup) obj, iCount); + else + iCount++; + } + return iCount; + } + + public int getHeaderHeight() { + int height = 0; + TableColumnModel columnModel = header.getColumnModel(); + for (int column = 0; column < columnModel.getColumnCount(); column++) { + TableColumn aColumn = columnModel.getColumn(column); + TableCellRenderer renderer = aColumn.getHeaderRenderer(); + // + if (renderer == null) { + renderer = new DefaultTableCellRenderer() { + public Component getTableCellRendererComponent( + JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + JTableHeader header = table.getTableHeader(); + if (header != null) { + setForeground(header.getForeground()); + setBackground(header.getBackground()); + setFont(header.getFont()); + } + setHorizontalAlignment(JLabel.CENTER); + setText((value == null) ? "" : value.toString()); + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return this; + } + }; + } + // + Component comp = renderer.getTableCellRendererComponent(header + .getTable(), aColumn.getHeaderValue(), false, false, -1, + column); + int cHeight = comp.getPreferredSize().height; + Enumeration enumeration = ((GroupableTableHeader) header) + .getColumnGroups(aColumn); + if (enumeration != null) { + while (enumeration.hasMoreElements()) { + ColumnGroup cGroup = (ColumnGroup) enumeration + .nextElement(); + cHeight += cGroup.getSize(header.getTable()).height; + } + } + height = Math.max(height, cHeight); + } + height = Math.max(height, m_height); + return height; + } + + public Dimension getPreferredSize(JComponent c) { + long width = 0; + Enumeration enumeration = header.getColumnModel().getColumns(); + while (enumeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) enumeration.nextElement(); + width = width + aColumn.getWidth(); + } + + return createHeaderSize(width); + } + + public void paint(Graphics g, JComponent c) { + Rectangle clipBounds = g.getClipBounds(); + if (header.getColumnModel() == null) + return; + ((GroupableTableHeader) header).setColumnMargin(); + int column = 0; + Dimension size = header.getSize(); + Rectangle cellRect = new Rectangle(0, 0, size.width, size.height); + Hashtable h = new Hashtable(); + int columnMargin = header.getColumnModel().getColumnMargin(); + Enumeration enumeration = header.getColumnModel().getColumns(); + while (enumeration.hasMoreElements()) { + cellRect.height = size.height; + cellRect.y = 0; + TableColumn aColumn = (TableColumn) enumeration.nextElement(); + Enumeration cGroups = ((GroupableTableHeader) header) + .getColumnGroups(aColumn); + if (cGroups != null) { + int groupHeight = 0; + while (cGroups.hasMoreElements()) { + ColumnGroup cGroup = (ColumnGroup) cGroups.nextElement(); + Rectangle groupRect = (Rectangle) h.get(cGroup); + if (groupRect == null) { + groupRect = new Rectangle(cellRect); + Dimension d = cGroup.getSize(header.getTable()); + if (!System.getProperty("java.vm.version").startsWith( + "1.2")) { + int iColCount = getColCountUnderColGroup(cGroup, 0); // øöͷµĻ(zjb) + // System.out.println(iColCount); + groupRect.width = d.width - iColCount + * columnMargin; + } else + groupRect.width = d.width; + groupRect.height = d.height; + h.put(cGroup, groupRect); + } + paintCell(g, groupRect, cGroup); + groupHeight += groupRect.height; + cellRect.height = size.height - groupHeight; + cellRect.y = groupHeight; + } + } + if (!System.getProperty("java.vm.version").startsWith("1.2")) + cellRect.width = aColumn.getWidth(); + else + cellRect.width = aColumn.getWidth() + columnMargin; + + if (cellRect.intersects(clipBounds)) { + paintCell(g, cellRect, column); + } + cellRect.x += cellRect.width; + column++; + } + } + + private void paintCell(Graphics g, Rectangle cellRect, int columnIndex) { + TableColumn aColumn = header.getColumnModel().getColumn(columnIndex); + TableCellRenderer renderer = aColumn.getHeaderRenderer(); + // + if (renderer == null) { + renderer = new DefaultTableCellRenderer() { + public Component getTableCellRendererComponent(JTable table, + Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + JTableHeader header = table.getTableHeader(); + if (header != null) { + setForeground(header.getForeground()); + setBackground(header.getBackground()); + setFont(header.getFont()); + } + setHorizontalAlignment(JLabel.CENTER); + setText((value == null) ? "" : value.toString()); + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return this; + } + }; + } + // + // Component component = + // renderer.getTableCellRendererComponent(header.getTable(), + // aColumn.getHeaderValue(), false, false, -1, columnIndex); + // + String headerValue = aColumn.getHeaderValue().toString(); + Component component = renderer.getTableCellRendererComponent(header + .getTable(), headerValue, false, false, -1, columnIndex); + + rendererPane.add(component); + rendererPane.paintComponent(g, component, header, cellRect.x, + cellRect.y, cellRect.width, cellRect.height, true); + } + + private void paintCell(Graphics g, Rectangle cellRect, ColumnGroup cGroup) { + TableCellRenderer renderer = cGroup.getHeaderRenderer(); + // + if (renderer == null) { + renderer = new DefaultTableCellRenderer() { + public Component getTableCellRendererComponent(JTable table, + Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + JTableHeader header = table.getTableHeader(); + if (header != null) { + setForeground(header.getForeground()); + setBackground(header.getBackground()); + setFont(header.getFont()); + } + setHorizontalAlignment(JLabel.CENTER); + setText((value == null) ? "" : value.toString()); + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return this; + } + }; + } + // + // Component component = + // renderer.getTableCellRendererComponent(header.getTable(), + // cGroup.getHeaderValue(), false, false, -1, -1); + // + String headerValue = cGroup.getHeaderValue().toString(); + Component component = renderer.getTableCellRendererComponent(header + .getTable(), headerValue, false, false, -1, -1); + + rendererPane.add(component); + rendererPane.paintComponent(g, component, header, cellRect.x, + cellRect.y, cellRect.width, cellRect.height, true); + } + + public void setHeaderHeight(int iHeight) { + m_height = iHeight; + } +} + + diff --git a/src/cn/com/customization/util/KUtil.java b/src/cn/com/customization/util/KUtil.java new file mode 100644 index 0000000..5ca1ba5 --- /dev/null +++ b/src/cn/com/customization/util/KUtil.java @@ -0,0 +1,54 @@ +package cn.com.customization.util; + +import java.awt.Dimension; +import java.awt.Toolkit; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.commands.open.OpenFormDialog; + +public class KUtil { + public static final int MINWIDTH = 1280; + public static final int MINHEIGHT = 768; + + public static void fitToScreen(AbstractAIFDialog abstractAIFDialog) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + double screenWidth = screenSize.getWidth(); + double screenHeight = screenSize.getHeight(); + Dimension dialogSize = abstractAIFDialog.getSize(); + if (screenWidth < MINWIDTH && dialogSize.getWidth() > screenWidth) { + abstractAIFDialog.setSize(new Dimension((int) Math.floor(screenWidth - 20), (int) Math.floor(dialogSize.getHeight()))); + abstractAIFDialog.setLocation(10, (int) Math.floor(abstractAIFDialog.getLocation().getY())); + } + if (screenHeight < MINHEIGHT && dialogSize.getHeight() > screenHeight) { + abstractAIFDialog.setSize(new Dimension((int) Math.floor(dialogSize.getWidth()), (int) Math.floor(screenHeight - 20))); + abstractAIFDialog.setLocation((int) Math.floor(abstractAIFDialog.getLocation().getX()), 10); + } + /* + * if((screenWidth + * MINWIDTH||dialogSize.getHeight()>MINHEIGHT)) { abstractAIFDialog.setSize(new + * Dimension((int)Math.floor(screenWidth-20),(int)Math.floor(screenHeight-20))); + * abstractAIFDialog.setLocation(10, 10); } + */ + } + + public static void fitToScreen(OpenFormDialog openFormDialog) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + double screenWidth = screenSize.getWidth(); + double screenHeight = screenSize.getHeight(); + Dimension dialogSize = openFormDialog.getSize(); + if (screenWidth < MINWIDTH && dialogSize.getWidth() > screenWidth) { + openFormDialog.setSize(new Dimension((int) Math.floor(screenWidth - 20), (int) Math.floor(dialogSize.getHeight()))); + openFormDialog.setLocation(10, (int) Math.floor(openFormDialog.getLocation().getY())); + } + if (screenHeight < MINHEIGHT && dialogSize.getHeight() > screenHeight) { + openFormDialog.setSize(new Dimension((int) Math.floor(dialogSize.getWidth()), (int) Math.floor(screenHeight - 20))); + openFormDialog.setLocation((int) Math.floor(openFormDialog.getLocation().getX()), 10); + } + /* + * if((screenWidth + * MINWIDTH||dialogSize.getHeight()>MINHEIGHT)) { openFormDialog.setSize(new + * Dimension((int)Math.floor(screenWidth-20),(int)Math.floor(screenHeight-20))); + * openFormDialog.setLocation(10, 10); } + */ + } +} diff --git a/src/cn/com/customization/util/PackFailDownInfo.java b/src/cn/com/customization/util/PackFailDownInfo.java new file mode 100644 index 0000000..09eb5a2 --- /dev/null +++ b/src/cn/com/customization/util/PackFailDownInfo.java @@ -0,0 +1,151 @@ +/* +#============================================================================= +# +# Copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: PackFailDownInfo.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz Ini ʼ(From Shaangu) +#============================================================================= +*/ +package cn.com.customization.util; + +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +public class PackFailDownInfo { + private TCComponentItemRevision itemRev=null; + private String itemId; + private String rev; + private String datasetName; + private String reference_file; + private TCComponentDataset dataSet; + private String filePath=""; + private String reason=""; + private String owner=""; + private String needDown="false"; + /** + * @return the owner + */ + public String getOwner() { + return owner; + } + /** + * @return the itemRev + */ + public TCComponentItemRevision getItemRev() { + return itemRev; + } + /** + * @param itemRev the itemRev to set + */ + public void setItemRev(TCComponentItemRevision itemRev) { + this.itemRev = itemRev; + } + /** + * @param owner the owner to set + */ + public void setOwner(String owner) { + this.owner = owner; + } + /** + * @return the itemId + */ + public String getItemId() { + return itemId; + } + /** + * @param itemId the itemId to set + */ + public void setItemId(String itemId) { + this.itemId = itemId; + } + /** + * @return the rev + */ + public String getRev() { + return rev; + } + /** + * @param rev the rev to set + */ + public void setRev(String rev) { + this.rev = rev; + } + /** + * @return the datasetName + */ + public String getDatasetName() { + return datasetName; + } + /** + * @param datasetName the datasetName to set + */ + public void setDatasetName(String datasetName) { + this.datasetName = datasetName; + } + /** + * @return the reference_file + */ + public String getReference_file() { + return reference_file; + } + /** + * @param reference_file the reference_file to set + */ + public void setReference_file(String reference_file) { + this.reference_file = reference_file; + } + /** + * @return the dataSet + */ + public TCComponentDataset getDataSet() { + return dataSet; + } + /** + * @param dataSet the dataSet to set + */ + public void setDataSet(TCComponentDataset dataSet) { + this.dataSet = dataSet; + } + /** + * @return the filePath + */ + public String getFilePath() { + return filePath; + } + /** + * @param filePath the filePath to set + */ + public void setFilePath(String filePath) { + this.filePath = filePath; + } + /** + * @return the reason + */ + public String getReason() { + return reason; + } + /** + * @param reason the reason to set + */ + public void setReason(String reason) { + this.reason = reason; + } + /** + * @return the needDown + */ + public String getNeedDown() { + return needDown; + } + /** + * @param needDown the needDown to set + */ + public void setNeedDown(String needDown) { + this.needDown = needDown; + } + +} diff --git a/src/cn/com/customization/util/PackResultInfo.java b/src/cn/com/customization/util/PackResultInfo.java new file mode 100644 index 0000000..aafd5e2 --- /dev/null +++ b/src/cn/com/customization/util/PackResultInfo.java @@ -0,0 +1,203 @@ +/* +#============================================================================= +# +# Copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: PackResultInfo.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz Ini ʼ(From Shaangu) +#============================================================================= + */ +package cn.com.customization.util; + +import java.util.List; + +public class PackResultInfo { + + // ʱ䣺2010-06-15:8890 ˣXXXXXX, ѡ̣Ŀ¼XXXXXXXXXX + + private String time = ""; + private String person = ""; + private String job = ""; + private int needNum = 0; + private int successNum = 0; + private int failNum = 0; + private int noReferenceNum = 0; + private int noPrivilegelNum = 0; + private int equalNameNum = 0; + private int noReleasedNum = 0; + private int existDataSetCount = 0; + private List failDownInfo = null; + + /** + * @return the time + */ + public String getTime() { + return time; + } + + /** + * @param time the time to set + */ + public void setTime(String time) { + this.time = time; + } + + /** + * @return the person + */ + public String getPerson() { + return person; + } + + /** + * @param person the person to set + */ + public void setPerson(String person) { + this.person = person; + } + + /** + * @return the job + */ + public String getJob() { + return job; + } + + /** + * @param job the job to set + */ + public void setJob(String job) { + this.job = job; + } + + /** + * @return the needNum + */ + public int getNeedNum() { + return needNum; + } + + /** + * @param needNum the needNum to set + */ + public void setNeedNum(int needNum) { + this.needNum = needNum; + } + + /** + * @return the successNum + */ + public int getSuccessNum() { + return successNum; + } + + /** + * @param successNum the successNum to set + */ + public void setSuccessNum(int successNum) { + this.successNum = successNum; + } + + /** + * @return the failNum + */ + public int getFailNum() { + return failNum; + } + + /** + * @param failNum the failNum to set + */ + public void setFailNum(int failNum) { + this.failNum = failNum; + } + + /** + * @return the noReferenceNum + */ + public int getNoReferenceNum() { + return noReferenceNum; + } + + /** + * @param noReferenceNum the noReferenceNum to set + */ + public void setNoReferenceNum(int noReferenceNum) { + this.noReferenceNum = noReferenceNum; + } + + /** + * @return the noPrivilegelNum + */ + public int getNoPrivilegelNum() { + return noPrivilegelNum; + } + + /** + * @param noPrivilegelNum the noPrivilegelNum to set + */ + public void setNoPrivilegelNum(int noPrivilegelNum) { + this.noPrivilegelNum = noPrivilegelNum; + } + + /** + * @return the equalNameNum + */ + public int getEqualNameNum() { + return equalNameNum; + } + + /** + * @param equalNameNum the equalNameNum to set + */ + public void setEqualNameNum(int equalNameNum) { + this.equalNameNum = equalNameNum; + } + + /** + * @return the noReleasedNum + */ + public int getNoReleasedNum() { + return noReleasedNum; + } + + /** + * @param noReleasedNum the noReleasedNum to set + */ + public void setNoReleasedNum(int noReleasedNum) { + this.noReleasedNum = noReleasedNum; + } + + /** + * @return the failDownInfo + */ + public List getFailDownInfo() { + return failDownInfo; + } + + /** + * @param failDownInfo the failDownInfo to set + */ + public void setFailDownInfo(List failDownInfo) { + this.failDownInfo = failDownInfo; + } + + /** + * @return the existDataSetCount + */ + public int getExistDataSetCount() { + return existDataSetCount; + } + + /** + * @param existDataSetCount the existDataSetCount to set + */ + public void setExistDataSetCount(int existDataSetCount) { + this.existDataSetCount = existDataSetCount; + } + +} diff --git a/src/cn/com/customization/util/PackSuccessfulInfo.java b/src/cn/com/customization/util/PackSuccessfulInfo.java new file mode 100644 index 0000000..d901a9b --- /dev/null +++ b/src/cn/com/customization/util/PackSuccessfulInfo.java @@ -0,0 +1,108 @@ +/* +#============================================================================= +# +# opyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: PackSuccessfulInfo.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz Ini ʼ(From Shaangu) +#============================================================================= + */ +package cn.com.customization.util; + +public class PackSuccessfulInfo { + private String index = ""; + private String itemID = ""; + private String itemRev = ""; + private String itemOwner = ""; + private String dataset = ""; + private String refFile = ""; + + /** + * @return the index + */ + public String getIndex() { + return index; + } + + /** + * @param index the index to set + */ + public void setIndex(String index) { + this.index = index; + } + + /** + * @return the itemID + */ + public String getItemID() { + return itemID; + } + + /** + * @param itemID the itemID to set + */ + public void setItemID(String itemID) { + this.itemID = itemID; + } + + /** + * @return the itemRev + */ + public String getItemRev() { + return itemRev; + } + + /** + * @param itemRev the itemRev to set + */ + public void setItemRev(String itemRev) { + this.itemRev = itemRev; + } + + /** + * @return the itemOwner + */ + public String getItemOwner() { + return itemOwner; + } + + /** + * @param itemOwner the itemOwner to set + */ + public void setItemOwner(String itemOwner) { + this.itemOwner = itemOwner; + } + + /** + * @return the dataset + */ + public String getDataset() { + return dataset; + } + + /** + * @param dataset the dataset to set + */ + public void setDataset(String dataset) { + this.dataset = dataset; + } + + /** + * @return the refFile + */ + public String getRefFile() { + return refFile; + } + + /** + * @param refFile the refFile to set + */ + public void setRefFile(String refFile) { + this.refFile = refFile; + } + +} diff --git a/src/cn/com/customization/util/QueryTaskOpinionTableHead.java b/src/cn/com/customization/util/QueryTaskOpinionTableHead.java new file mode 100644 index 0000000..e6911dc --- /dev/null +++ b/src/cn/com/customization/util/QueryTaskOpinionTableHead.java @@ -0,0 +1,219 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: test.java +#======================================================================================================= +# Date Name Action Description of Change +# 2010-1-6 tyl ޸ +# 2010-4-25 zyn ޸ ʾģʽ޸Ϊʾģʽ +#======================================================================================================= + */ + +package cn.com.customization.util; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.SplitPaneUI; +import javax.swing.plaf.basic.BasicSplitPaneUI; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.teamcenter.rac.util.VerticalLayout; + +//import components.TableDemo; + +public class QueryTaskOpinionTableHead extends JPanel { + /** + * serialVersionUID:TODOĹܣ + * @since Ver 1.1 + */ + private static final long serialVersionUID = 1L; + private Object[][] objArray; // е + private DefaultTableModel dm; + private JTable table; + private JTextArea textarea; +// private String[] headers = { "","", "" , "ǩ","ִ","ύʱ","ע"}; + private String[] headers = { "", "" , "ǩ","ִ","ύʱ","ע"}; + + public QueryTaskOpinionTableHead() { + super(new GridLayout(1, 0)); + } + + // ϱ + public void setTableHeadTestModel(Vector titleArrayTemp) { + dm = new DefaultTableModel(objArray, headers); + table = new JTable(dm); + textarea = new JTextArea(15,35); + textarea.setAutoscrolls(true); + textarea.setLineWrap(true); + textarea.setEditable(false); + textarea.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent mouseEvent) { + textarea.setCursor(new Cursor(Cursor.TEXT_CURSOR)); //TextΪıָ + } + public void mouseExited(MouseEvent mouseEvent) { + textarea.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); //뿪TextָĬ̬ + } + }); + textarea.getCaret().addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + textarea.getCaret().setVisible(true); //ʹtextareaıʾ + } + }); + + GroupableTableHeader header = new GroupableTableHeader(table.getColumnModel()); + + table.setTableHeader(header); +// table.setPreferredScrollableViewportSize(new Dimension(670, 150)); + table.setPreferredScrollableViewportSize(new Dimension(690, 150)); + addListener(); + + JScrollPane scrollPane = new JScrollPane(table); + + JPanel jpane = new JPanel(new BorderLayout()); + jpane.add(new JLabel("ע:"),BorderLayout.NORTH); + jpane.add(textarea,BorderLayout.CENTER); + + JSplitPane splitPane = new JSplitPane(); + splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT); + splitPane.setLeftComponent(scrollPane); + splitPane.setRightComponent(jpane); + splitPane.setDividerLocation(0.6); + splitPane.setEnabled(false); + SplitPaneUI ui = splitPane.getUI(); + if (ui instanceof BasicSplitPaneUI) { + ((BasicSplitPaneUI) ui).getDivider().setBorder(null);//طָ + } + + add(splitPane); + } + + public void setobjArray(Object[][] objArrayTemp) { + objArray = objArrayTemp; + } + + /* + * This method picks good column sizes. If all column heads are wider than + * the column's cells' contents, then you can just use + * column.sizeWidthToFit(). + */ + public void initColumnSizes() { + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + // DefaultTableModel model = (DefaultTableModel) table.getModel(); + TableColumn column = null; + Component comp = null; + int headerWidth = 0; + int cellWidth = 0; + TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); + TableColumnModel colmode = table.getColumnModel(); + int count = colmode.getColumnCount(); + for (int i = 0; i < count; i++) { + column = table.getColumnModel().getColumn(i); + comp = headerRenderer.getTableCellRendererComponent(table, column.getHeaderValue(), false, false, 0, 0); + headerWidth = comp.getPreferredSize().width; +// if (i == 1) { +// cellWidth = 50; +// }else if (i == 2) { +// cellWidth = 50; +// }else if (i == 3) { +// cellWidth = 80; +// }else if (i == 4) { +// cellWidth = 100; +// }else { +// cellWidth = 130; +// } + if (i == 0) { + cellWidth = 180; + }else if (i == 1) { + cellWidth = 75; + }else if (i == 2) { + cellWidth = 75; + }else if (i == 3) { + cellWidth = 100; + }else { + cellWidth = 130; + } + column.setPreferredWidth(Math.max(headerWidth, cellWidth)); + } + } + + public String getUserChoose() { + String cellValue = null; + int selectRows = table.getSelectedRows().length;// ȡûѡе + if (selectRows == 1) { + int selectedRowIndex = table.getSelectedRow(); // ȡûѡ + cellValue = (String) table.getValueAt(selectedRowIndex, 5); + } + return cellValue; + } + + /** + * ӵ¼עϢ + */ + public void addListener(){ + table.addMouseListener(new MouseListener(){ + + public void mouseClicked(MouseEvent e) { + String userComments = getUserChoose(); + String Comments = ""; + if(userComments!=null){ + int len = userComments.split("\t").length; + for(int i = 0;i tableData; + private JButton confirmButton = null; + private String validTypeOption = "origin_batchdown_validtype"; + // origin_showLogFileеֵΪtrue־ļc:\\batchExportDataset.log + private String isShowLogOption = "origin_showLogFile"; + private String logFileName = "c:\\batchExportDataset.log"; + private PackResultInfo resultInfo; + private boolean isDownReleased = false; + private WriteAndCopyFile writeLog; + + private int downDataSetCount = 0; + private int isNotHavePriviligeCount = 0; + private int haveEqualDataSetCount = 0; + private int needDownCount = 0; + private int notReleasedDataSetCount = 0; + private int downCount = 0; + private List haveDownDataSet = new ArrayList(); + private List notExistFiles = new ArrayList(); + private List failDownInfos = new ArrayList(); + + private JLabel existDataSetLb = new JLabel(); + private JLabel needLb = new JLabel(); + private JLabel successLb = new JLabel(); + private JLabel noReleaseLb = new JLabel(); + private JLabel noPrevilegeLb = new JLabel(); + private JLabel noReferenceFileLb = new JLabel(); + private JLabel failLb = new JLabel(); + private List successfulInfos = new ArrayList(); + private String successfulDir = "c:/ugs/log"; + private TCUserService userService = null; + private List logsList = new ArrayList(); + + public ResultDialog(PackResultInfo resultInfo, TCSession session) { + super(true); + this.resultInfo = resultInfo; + this.session = session; + checkcommon = new GetCommonInfo(session); + this.tableData = resultInfo.getFailDownInfo(); + writeLog = new WriteAndCopyFile(); + userService = (TCUserService) session.getUserService(); + + if (isShowLog()) { + File file = new File(logFileName); + if (file.exists()) { + writeLog.writeFile(logFileName, true, "\n"); + } else { + try { + file.createNewFile(); + writeLog.writeFile(logFileName, true, "\n"); + } catch (IOException e) { + e.printStackTrace(); + } + } + } else { + File file = new File(logFileName); + if (file.exists()) { + file.delete(); + } + } + initUI(); + } + + public void initUI() { + // setPersistentDisplay(true); + setOptimalDisplay(false); + this.setTitle("ؽ"); + BorderLayout borderLayout = new BorderLayout(); + JPanel panel = new JPanel(borderLayout); + panel.add(setTopPanel(), BorderLayout.NORTH); +// panel.add(setCenterPanel(), BorderLayout.CENTER); + panel.add(setBottomPanel(), BorderLayout.SOUTH); + getContentPane().add(panel); + Dimension screen = getToolkit().getScreenSize(); + setPreferredSize(new Dimension(400,300)); +// setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); + centerToScreen(); + this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + pack(); + this.setVisible(true); + } + + private JPanel setTopPanel() { + JPanel panel1 = new JPanel(new PropertyLayout()); + JLabel infoLb = new JLabel(" ļͳƣ"); + existDataSetLb.setText(" ݼ" + resultInfo.getExistDataSetCount()); + noReleaseLb.setText(" δݼ:" + resultInfo.getNoReleasedNum()); + noPrevilegeLb.setText(" Ȩݼ:" + resultInfo.getNoPrivilegelNum()); + needLb.setText(" Ҫļ:" + resultInfo.getNeedNum()); + successLb.setText(" ɹļ:" + resultInfo.getSuccessNum()); + noReferenceFileLb.setText(" ļݼ:" + resultInfo.getNoReferenceNum()); + failLb.setText(" δɹļ" + resultInfo.getFailNum()); + + panel1.add("1.1.left.center", new JLabel()); + panel1.add("2.1.left.center", existDataSetLb); + panel1.add("3.1.left.center", noReleaseLb); + panel1.add("4.1.left.center", noPrevilegeLb); + panel1.add("5.1.left.center", needLb); + panel1.add("6.1.left.center", successLb); + panel1.add("7.1.left.center", noReferenceFileLb); + + JPanel panel2 = new JPanel(new PropertyLayout()); + panel2.add("1.1.left.center", new JLabel()); + panel2.add("2.1.left.center", failLb); + + JPanel panel = new JPanel(new PropertyLayout()); + panel.add("1.1.left.center", new JLabel()); + panel.add("2.1.left.center", infoLb); + panel.add("3.1.left.center", panel1); + panel.add("4.1.left.center", panel2); + return panel; + } + + private JPanel setCenterPanel() { + JPanel panel = new JPanel(new PropertyLayout()); + dtm = new ResultTableModel(tableData); + table = new JTable(dtm); + table.setRowHeight(20); + dtm.setTableColumnsWidth(table); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + // нȾ + table.getColumnModel().getColumn(0).setCellRenderer(new TableColumnRender()); + table.getColumnModel().getColumn(7).setCellRenderer(new CheckBoxColumnRender()); + + JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane.setAutoscrolls(true); + scrollPane.setPreferredSize(new Dimension(690, 200)); + panel.add("1.1.left.center", scrollPane); + panel.add("2.1.left.center", new JLabel(" ")); + panel.setBorder(new TitledBorder("")); + return panel; + } + + private JPanel setBottomPanel() { + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setSize(60, 10); + confirmButton = new JButton(""); + confirmButton.addActionListener(new buttonListener()); + JButton exitButton = new JButton("ȡ"); + exitButton.addActionListener(new buttonListener()); + southPanel.add(confirmButton); + southPanel.add(exitButton); + return southPanel; + } + + class buttonListener implements ActionListener { + public void actionPerformed(ActionEvent event) { + String name = ((JButton) event.getSource()).getText(); + if (name.equals("")) { + confirmButtonAction(); + } else { + if (name.equals("ȡ")) { + dispose(); + } + } + } + } + + private void writeSuccessfulLogFile(String fileName, String content) { + content = content + "\n"; + writeLog.writeFile(fileName, true, content); + logsList.add(content); + } + + private void confirmButtonAction() { + System.out.println("tableData.size()......." + tableData.size()); + if (tableData.size() > 0) { + writeLogFile(logFileName, "\n"); + writeLogFile(logFileName, ":\n"); + PackSuccessfulInfo succesfulDataset = new PackSuccessfulInfo(); + succesfulDataset.setIndex(""); + succesfulDataset.setItemID("ID"); + succesfulDataset.setItemRev("汾"); + succesfulDataset.setItemOwner(""); + succesfulDataset.setDataset("ݼ"); + succesfulDataset.setRefFile(""); + successfulInfos.add(succesfulDataset); + + boolean need = false; + for (int i = 0; i < tableData.size(); i++) { + TCComponentDataset dataSet = tableData.get(i).getDataSet(); + String needDown = tableData.get(i).getNeedDown(); + if (needDown.equals("true")) { + need = true; + String filePath = tableData.get(i).getFilePath(); + String itemId = tableData.get(i).getItemId(); + String rev = tableData.get(i).getRev(); + String owner = tableData.get(i).getOwner(); + TCComponentItemRevision itemRevision = tableData.get(i).getItemRev(); + datasetFileDown(itemRevision, dataSet, filePath, itemId, rev, owner); + } + } + + SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd:HHmmss"); + String time = date.format(new Date()); + String logPath = successfulDir + "/¹ļ־_" + (new SimpleDateFormat("yyyyMMdd")).format(new Date()) + ".log"; + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "==========================================================================================================================="); + writeSuccessfulLogFile(logPath, "ʱ:" + time + " :" + resultInfo.getPerson() + " ѡ(Ŀ¼):" + resultInfo.getJob()); + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "ݼ:" + haveDownDataSet.size()); + writeSuccessfulLogFile(logPath, "δݼ:" + notReleasedDataSetCount); + writeSuccessfulLogFile(logPath, "Ȩݼ:" + isNotHavePriviligeCount); + writeSuccessfulLogFile(logPath, "ļ:" + needDownCount); + writeSuccessfulLogFile(logPath, "ɹļ:" + downDataSetCount); + writeSuccessfulLogFile(logPath, "ļݼ:" + notExistFiles.size()); + writeSuccessfulLogFile(logPath, " "); + writeSuccessfulLogFile(logPath, "ѳɹļб:"); + writeSuccessfulLogFile(logPath, "---------------------------------------------------------------------------"); + for (int i = 0; i < successfulInfos.size(); i++) { + PackSuccessfulInfo successfulInfo = successfulInfos.get(i); + writeSuccessfulLogFile(logPath, appendSpace(successfulInfo.getIndex().trim(), 5) + appendSpace(successfulInfo.getItemID().trim(), 32) + appendSpace(successfulInfo.getItemRev().trim(), 5) + appendSpace(successfulInfo.getItemOwner().trim(), 25) + appendSpace(successfulInfo.getDataset().trim(), 50) + appendSpace(successfulInfo.getRefFile().trim(), 50)); + } + writeSuccessfulLogFile(logPath, " "); + // ־ + try { + Object objs[] = new Object[1]; + objs[0] = logsList.toArray(); + userService.call("DatasetDownLog", objs); + } catch (TCException e) { + e.printStackTrace(); + } + + if (need) { + writeLogFile(logFileName, " "); + writeLogFile(logFileName, "ܽ᣺"); + writeLogFile(logFileName, "ݼ:" + haveDownDataSet.size() + ""); + writeLogFile(logFileName, "δݼ:" + notReleasedDataSetCount + ""); + writeLogFile(logFileName, "Ȩݼ:" + isNotHavePriviligeCount + ""); + writeLogFile(logFileName, "Ҫļ:" + needDownCount + ""); + writeLogFile(logFileName, "ɹļ:" + downDataSetCount + ""); + writeLogFile(logFileName, "ļݼ:" + notExistFiles.size() + ""); + writeLogFile(logFileName, "δɹļ:" + (needDownCount - downDataSetCount) + ""); + + resultInfo.setExistDataSetCount(haveDownDataSet.size()); + resultInfo.setNeedNum(needDownCount); + resultInfo.setSuccessNum(downDataSetCount); + resultInfo.setNoReleasedNum(notReleasedDataSetCount); + resultInfo.setNoPrivilegelNum(isNotHavePriviligeCount); + resultInfo.setNoReferenceNum(notExistFiles.size()); + resultInfo.setEqualNameNum(haveEqualDataSetCount); + resultInfo.setFailNum(failDownInfos.size()); + resultInfo.setFailDownInfo(failDownInfos); + updateDialog(); + } else { + MessageBox.post("ûҪصݼ!", "INFO", MessageBox.INFORMATION); + } + } else { + MessageBox.post("ûҪصݼ!", "INFO", MessageBox.INFORMATION); + } + } + + private String appendSpace(String str, int num) { + if (str.length() < num) { + for (int i = UtilApi.length(str) + 1; i <= num; i++) { + str += " "; + } + } + return str; + } + + private void updateDialog() { + existDataSetLb.setText(" ݼ" + resultInfo.getExistDataSetCount()); + noReleaseLb.setText(" δݼ:" + resultInfo.getNoReleasedNum()); + noPrevilegeLb.setText(" Ȩݼ:" + resultInfo.getNoPrivilegelNum()); + needLb.setText(" Ҫļ:" + resultInfo.getNeedNum()); + successLb.setText(" ɹļ:" + resultInfo.getSuccessNum()); + noReferenceFileLb.setText(" ļݼ:" + resultInfo.getNoReferenceNum()); + failLb.setText(" أ" + resultInfo.getFailNum()); + + tableData = resultInfo.getFailDownInfo(); + dtm = new ResultTableModel(tableData); + table.setModel(dtm); + table.setRowHeight(20); + dtm.setTableColumnsWidth(table); + table.getColumnModel().getColumn(0).setCellRenderer(new TableColumnRender()); + table.getColumnModel().getColumn(7).setCellRenderer(new CheckBoxColumnRender()); + dtm.setTableColumnsWidth(table); + + downDataSetCount = 0; + isNotHavePriviligeCount = 0; + haveEqualDataSetCount = 0; + needDownCount = 0; + notReleasedDataSetCount = 0; + downCount = 0; + failDownInfos = new ArrayList(); + haveDownDataSet = new ArrayList(); + notExistFiles = new ArrayList(); + } + + /** + * datasetFileDown:ݼļ + * @param @return 趨ļ + * @param dataset + * @param fileCurrentPath + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + + private void datasetFileDown(TCComponentItemRevision itemRevision, TCComponentDataset dataSet, String currentPath, String itemId, String rev, String owner) { + + try { + dataSet.refresh(); + } catch (TCException e2) { + e2.printStackTrace(); + } + if (haveDownDataSet != null) { + if (haveDownDataSet.contains(dataSet)) { + return; + } + } + String fileCurrentPath = currentPath; + haveDownDataSet.add(dataSet); + writeLogFile(logFileName, "ݼ:" + dataSet.toString()); + System.out.println("dataSet............" + dataSet.toString()); + PackFailDownInfo dataSetInfo = new PackFailDownInfo(); + dataSetInfo.setItemId(itemId); + dataSetInfo.setRev(rev); + dataSetInfo.setDatasetName(dataSet.toString()); + dataSetInfo.setDataSet(dataSet); + dataSetInfo.setOwner(owner); + dataSetInfo.setItemRev(itemRevision); + try { + String release = dataSet.getProperty("release_status_list").trim(); + if (release != null) { + String regex = ".*Released.*"; + Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); + Matcher match = pattern.matcher(release); + boolean find = match.find(); + if (!find) { + notReleasedDataSetCount++; + writeLogFile(logFileName, "δ"); + if (isDownReleased) { + dataSetInfo.setReason("δ"); + failDownInfos.add(dataSetInfo); + writeLogFile(logFileName, ""); + return; + } + } else { + writeLogFile(logFileName, "Ѿ"); + } + } + } catch (TCException e2) { + e2.printStackTrace(); + } + try { + boolean isCanExport = false; + isCanExport = checkAccessPrivilige(session.getUser(), dataSet, "EXPORT"); + if (!isCanExport) { + ++isNotHavePriviligeCount; + dataSetInfo.setReason("ûеȨ"); + failDownInfos.add(dataSetInfo); + writeLogFile(logFileName, "ûеȨ"); + writeLogFile(logFileName, " "); + return; + } else { + writeLogFile(logFileName, "еȨ "); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + TCComponentTcFile tcFile = null; + String fileName = ""; + try { + if ((dataSet.getTcFiles() != null) && (dataSet.getTcFiles().length > 0)) { +// if (itemRevision != null) { +// String revType = itemRevision.getType(); +// if (revType.equals("GGDitem Revision") || revType.equals("HTDitem Revision")) { +// fileCurrentPath = createFile(fileCurrentPath, changePackageName); +// } +// } + + for (int i = 0; i < dataSet.getTcFiles().length; i++) { + tcFile = dataSet.getTcFiles()[i]; + if (tcFile == null) { + return; + } + tcFile.refresh(); + fileName = tcFile.getProperty("original_file_name"); + if (fileName != null) { + needDownCount++; + dataSetInfo.setReference_file(fileName); + dataSetInfo.setFilePath(fileCurrentPath); + dataSetInfo.setNeedDown("true"); + String fileType = ""; + String preFileName = ""; + int index = fileName.lastIndexOf("."); + if (index > 0) { + fileType = fileName.substring(index, fileName.length()); + preFileName = fileName.substring(0, index); + } else { + preFileName = fileName; + } + boolean flag = checkcommon.existFile(fileCurrentPath, fileName); + if (flag) { + haveEqualDataSetCount++; + int pos = fileName.indexOf('.'); + if (pos > 0) { + fileName = preFileName + "_" + UtilApi.getTimeNum() + fileType; + } + } + if (fileName.indexOf('/') >= 0) { + fileName = fileName.replace('/', '_'); + } + downCount = 0; + getTCFile(tcFile, fileCurrentPath, fileName, dataSetInfo); + } + } + } else { + dataSetInfo.setReason("ļ"); + failDownInfos.add(dataSetInfo); + notExistFiles.add(dataSet.toString()); + writeLogFile(logFileName, "ļ"); + } + writeLogFile(logFileName, " "); + } catch (Throwable e) { + writeLogFile(logFileName, "ļʱ쳣"); + writeLogFile(logFileName, e.getMessage()); + writeLogFile(logFileName, " "); + e.printStackTrace(); + } + } + + private File getTCFile(TCComponentTcFile tcFile, String fileCurrentPath, String fileName, PackFailDownInfo dataSetInfo) { + ++downCount; + if (downCount == 2) { + writeLogFile(logFileName, "ڶ"); + } + File file = null; + try { + file = tcFile.getFile(fileCurrentPath, fileName); + if (file != null) { + ++downDataSetCount; + writeLogFile(logFileName, "ļ:" + fileName + " " + getTime()); + writeLogFile(logFileName, " "); + + // successfulInfos + PackSuccessfulInfo succesfulDataset = new PackSuccessfulInfo(); + succesfulDataset.setIndex(String.valueOf(downDataSetCount)); + succesfulDataset.setItemID(dataSetInfo.getItemId()); + succesfulDataset.setItemRev(dataSetInfo.getRev()); + succesfulDataset.setItemOwner(dataSetInfo.getOwner()); + succesfulDataset.setDataset(dataSetInfo.getDatasetName()); + succesfulDataset.setRefFile(file.getName()); + successfulInfos.add(succesfulDataset); + } else { + writeLogFile(logFileName, "ûеļ"); + } + } catch (Throwable e) { + writeLogFile(logFileName, "ļʱ쳣"); + String exceptionMessage = e.getMessage(); + writeLogFile(logFileName, exceptionMessage); + writeLogFile(logFileName, " "); + e.printStackTrace(); + if (downCount < 2) { + file = getTCFile(tcFile, fileCurrentPath, fileName, dataSetInfo); + } else { + dataSetInfo.setReason(exceptionMessage); + failDownInfos.add(dataSetInfo); + } + } + return file; + } + + private void writeLogFile(String fileName, String content) { + if (isShowLog()) { + content = content + "\n"; + writeLog.writeFile(fileName, true, content); + } + } + + public String getTime() { + String strTime = ""; + try { + SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss:SSS"); + strTime = bartDateFormat.format(new Date()); + // System.out.println(strTime); + } catch (Exception e) { + e.printStackTrace(); + } + return strTime; + } + + /** + * checkAccessPrivilige:ûԸComponentǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } + + private boolean isShowLog() { + boolean isShowLog = false; + TCPreferenceService preSer = session.getPreferenceService(); + String value = preSer.getString(4, isShowLogOption).trim(); + if (value.equalsIgnoreCase("true")) { + isShowLog = true; + } + return isShowLog; + } + + public void isDownReleased() { + TCPreferenceService preSer = session.getPreferenceService(); + String type = preSer.getString(4, validTypeOption).trim(); + if (type.equalsIgnoreCase("released")) { + isDownReleased = true; + } + } +} diff --git a/src/cn/com/customization/util/ResultTableModel.java b/src/cn/com/customization/util/ResultTableModel.java new file mode 100644 index 0000000..8c71d5c --- /dev/null +++ b/src/cn/com/customization/util/ResultTableModel.java @@ -0,0 +1,97 @@ +/* +#============================================================================= +# +# Copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: ResultTableModel.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz Ini ʼ(From Shaangu) +#============================================================================= + */ +package cn.com.customization.util; + +import java.util.Enumeration; +import java.util.List; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; + + +public class ResultTableModel extends DefaultTableModel { + + /** + * + */ + private static final long serialVersionUID = 1L; + private static String[] names = { "*", "ID", "汾", "","ݼ", "" ,"ԭ",""}; + + /** + * Creates a new instance of EditBatchProcessLineTableModel. + * @param data + */ + public ResultTableModel(List data) { + super(getData(data), names); + } + + public static Object[][] getData(List data) { + Object[][] datas = new Object[data.size()][]; + for (int i = 0; i < data.size(); i++) { + String[] info = new String[8]; + info[0] = String.valueOf(i + 1); + info[1] = data.get(i).getItemId(); + info[2] = data.get(i).getRev(); + info[3] = data.get(i).getOwner(); + info[4] = data.get(i).getDatasetName(); + info[5] = data.get(i).getReference_file(); + info[6] = data.get(i).getReason(); + info[7] = data.get(i).getNeedDown(); + datas[i] = info; + } + return datas; + } + + @Override + public boolean isCellEditable(int row, int column) { + if (column < 7) { + return false; + } else { + return true; + } + } + + // ݱСп + public void FitTableColumns(JTable myTable) { + JTableHeader header = myTable.getTableHeader(); + int rowCount = myTable.getRowCount(); + Enumeration columns = myTable.getColumnModel().getColumns(); + while (columns.hasMoreElements()) { + TableColumn column = (TableColumn) columns.nextElement(); + int col = header.getColumnModel().getColumnIndex(column.getIdentifier()); + int width = (int) myTable.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(myTable, column.getIdentifier(), false, false, -1, col).getPreferredSize().getWidth(); + for (int row = 0; row < rowCount; row++) { + int preferedWidth = (int) myTable.getCellRenderer(row, col).getTableCellRendererComponent(myTable, myTable.getValueAt(row, col), false, false, row, col).getPreferredSize().getWidth(); + width = Math.max(width, preferedWidth); + } + header.setResizingColumn(column); + column.setWidth(width + myTable.getIntercellSpacing().width); + } + } + + // п + public void setTableColumnsWidth(JTable myTable) { + myTable.getColumnModel().getColumn(0).setPreferredWidth(25); + myTable.getColumnModel().getColumn(1).setPreferredWidth(100); + myTable.getColumnModel().getColumn(2).setPreferredWidth(40); + myTable.getColumnModel().getColumn(3).setPreferredWidth(100); + myTable.getColumnModel().getColumn(4).setPreferredWidth(100); + myTable.getColumnModel().getColumn(5).setPreferredWidth(125); + myTable.getColumnModel().getColumn(6).setPreferredWidth(100); + myTable.getColumnModel().getColumn(7).setPreferredWidth(80); + } + +} diff --git a/src/cn/com/customization/util/ShowMessageDialog.java b/src/cn/com/customization/util/ShowMessageDialog.java new file mode 100644 index 0000000..30838e0 --- /dev/null +++ b/src/cn/com/customization/util/ShowMessageDialog.java @@ -0,0 +1,93 @@ +/* +#============================================================================= +# +# Copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: ShowMessageDialog.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2009-10-30 tyl ʾϢ +# 2010-02-10 tyl Mod Ϣǰٿո +#============================================================================= + */ + +package cn.com.customization.util; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URL; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.VerticalLayout; + +public class ShowMessageDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + private String title = ""; + private String info1 = ""; + private String info2 = ""; + + public ShowMessageDialog(String title, String info1, String info2) { + super(true); + this.title = title; + this.info1 = info1; + this.info2 = info2; + initUI(); + } + + public void initUI() { + setPersistentDisplay(true); + setOptimalDisplay(false); + setTitle(title); + JPanel parentPanel; + JPanel iconPanel = new JPanel(); + JPanel itemInfoPanel1; + JPanel itemInfoPanel2; + parentPanel = new JPanel(new VerticalLayout(5, 2, 2, 2, 2)); + itemInfoPanel2 = new JPanel(new GridLayout(2, 1)); + itemInfoPanel1 = new JPanel(new PropertyLayout()); + + URL url = this.getClass().getResource("image/info.png"); + JLabel iconLabel = new JLabel(); + iconLabel.setIcon(new ImageIcon(url)); + iconPanel.add(iconLabel); + + itemInfoPanel2.add(new JLabel(" " + info1)); + itemInfoPanel2.add(new JLabel(info2)); + + itemInfoPanel1.add("1.1.left.center", iconPanel); + itemInfoPanel1.add("1.2.left.center", itemInfoPanel2); + + JButton buttonYes = new JButton("ȷ"); + buttonYes.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ShowMessageDialog.this.dispose(); + } + }); + JPanel panelButton = new JPanel(new BorderLayout()); + panelButton.setSize(10, 20); + panelButton.add(buttonYes, BorderLayout.CENTER); + + parentPanel.add("top.bin", new JLabel(" ")); + parentPanel.add("top.bind.left.top", itemInfoPanel1); + parentPanel.add("bottom.nobind.center.top", panelButton); + + getContentPane().add(parentPanel); + + pack(); + Dimension screen = getToolkit().getScreenSize(); // õĻߴ + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); + setVisible(true); + } +} diff --git a/src/cn/com/customization/util/TableColorRender.java b/src/cn/com/customization/util/TableColorRender.java new file mode 100644 index 0000000..bdcde5c --- /dev/null +++ b/src/cn/com/customization/util/TableColorRender.java @@ -0,0 +1,54 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: TableColorRender.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:46:31 tyl Ini ʼļ +#======================================================================================================= + */ +package cn.com.customization.util; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; + +public class TableColorRender implements TableCellRenderer { + // + public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer(); + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + Color foreground = table.getForeground(); + Color background = table.getBackground(); + if (isSelected) { + foreground = Color.WHITE; + background = Color.LIGHT_GRAY; + } else { + if (value != null) { + if (((String) value).startsWith("")) { + foreground = Color.RED; + background = Color.WHITE; + } else { + if (((String) value).startsWith("")) { + System.out.println("value============" + value); + foreground = Color.RED; + background = Color.WHITE; + } + } + } + foreground = table.getForeground(); + background = table.getBackground(); + } + renderer.setForeground(foreground); + renderer.setBackground(background); + return renderer; + } +} \ No newline at end of file diff --git a/src/cn/com/customization/util/TableColumnRender.java b/src/cn/com/customization/util/TableColumnRender.java new file mode 100644 index 0000000..c078f1d --- /dev/null +++ b/src/cn/com/customization/util/TableColumnRender.java @@ -0,0 +1,51 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: TableColumnRender.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:50:26 tyl Ini ʼļ +#======================================================================================================= +*/ +package cn.com.customization.util; + +import java.awt.Component; + +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.JTableHeader; + +public class TableColumnRender extends DefaultTableCellRenderer { + + /** + * serialVersionUID:TODOĹܣ + * @since Ver 1.1 + */ + private static final long serialVersionUID = 1L; + + /** + * + */ + public TableColumnRender() { + super(); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + //õͷ + JTableHeader header = table.getTableHeader(); + if (header != null) { + setForeground(header.getForeground()); + setBackground(header.getBackground()); + setFont(header.getFont()); + } + setHorizontalAlignment(JLabel.CENTER); + this.setText((value == null) ? "" : value.toString()); + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return this; + } +} \ No newline at end of file diff --git a/src/cn/com/customization/util/UtilApi.java b/src/cn/com/customization/util/UtilApi.java new file mode 100644 index 0000000..10b2267 --- /dev/null +++ b/src/cn/com/customization/util/UtilApi.java @@ -0,0 +1,918 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: UtilApi.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:56:51 tyl Ini ʼļ +#======================================================================================================= + */ +package cn.com.customization.util; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Toolkit; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + +import javax.swing.JComboBox; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +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.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.util.MessageBox; + +public class UtilApi { + /** + * Logger for this class + */ + private static HashMap loginUserInfoHm = new HashMap(); + + /** + * ϵͳsession + */ + private TCSession session; + + /** + * ͨapi + * @param pseapplication Ӧó + */ + public UtilApi(AbstractAIFUIApplication pseapplication) { + session = (TCSession) pseapplication.getSession(); + } + + /** + * ͨapi + * @param newsession session + */ + public UtilApi(TCSession newsession) { + session = newsession; + } + + private String getDefaultExportDirectory() { + String s = null; + if (s == null || s.length() == 0) { + TCPreferenceService tcpreferenceservice = session.getPreferenceService(); + s = tcpreferenceservice.getString(0, "defaultExportDirectory"); + } + if (s != null) { + s = s.trim(); + if (s.length() == 0) + s = null; + } + return s; + } + + public String getEnv(String name) { + String str = ""; + Iterator it = System.getenv().entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = (Map.Entry) it.next(); + System.out.println("entry-" + entry.getKey() + ":" + entry.getValue()); + if (entry.getKey().toString().equals(name)) { + str = entry.getValue() + ""; + if (!str.endsWith("\\")) { + str = str + "\\"; + } + break; + } + } + return str; + } + + /** + * Enter + */ + public static String ENTER = new String(new byte[] { 13, 10 }, 0); + + /** + * ָָstringתΪvector + * @param msg Դַ + * @param sepStr ָ + * @return vector + */ + public static Vector getVector(String msg, String sepStr) { + System.out.println("***********getVector()"); + System.out.println("msg===" + msg); + System.out.println("sepStr===" + sepStr); + Vector vt = new Vector(); + try { + String tmpStr = null; + boolean flag = false; + int pos = -1; + if (msg == null || msg.trim().length() == 0) { return null; } + if (msg.startsWith(sepStr)) { + msg = msg.substring(1); + } + if (msg.lastIndexOf(sepStr) == msg.length() - 1) { + flag = true; + msg = msg.substring(0, msg.length() - 1); + } + while ((pos = msg.indexOf(sepStr)) > 0) { + try { + tmpStr = msg.substring(0, pos); + vt.addElement(tmpStr); + if (msg.length() > pos + 1) + msg = msg.substring(pos + 1); + } + catch (RuntimeException e) { + break; + } + } + vt.add(msg); + if (flag) + vt.add(""); + } + catch (RuntimeException e) { + e.printStackTrace(); + } + return vt; + } + + /** + * ȡַ + * @param src Դַ + * @return double + */ + public static double getFloatFromStr(String src) { + double d = 0d; + try { + if (src == null || src.length() == 0) { return 0d; } + src = src.trim(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < src.length(); i++) { + if (src.charAt(i) == '.' || src.charAt(i) == '+' || src.charAt(i) == '-') { + sb.append(src.charAt(i)); + } else if (src.charAt(i) >= '0' && src.charAt(i) <= '9') { + sb.append(src.charAt(i)); + } + } + d = Double.parseDouble(sb.toString()); + } + catch (NumberFormatException e) { + e.printStackTrace(); + } + return d; + } + + /** + * getMsgboxLocate:趨λ + * @param @return λ + * @return Point + * @throws + * @since CodingExampleVer 1.1 + */ + public static Point getMsgboxLocate() { + Toolkit kit = Toolkit.getDefaultToolkit(); + Dimension screenSize = kit.getScreenSize(); + int frmLocateWidth = screenSize.width * 2 / 5; + int frmLocateHeight = screenSize.height * 4 / 7; + Point p = new Point(frmLocateWidth, frmLocateHeight); + return p; + } + + /** + * Ϣʾλ + * @param formLocHeigh ǰʼλ + * @return λ + */ + public static Point getMsgboxLocate(double formLocHeigh) { + Toolkit kit = Toolkit.getDefaultToolkit(); + Dimension screenSize = kit.getScreenSize(); + String tmp = formLocHeigh + ""; + if (tmp.indexOf(".") >= 0) { + tmp = tmp.substring(0, tmp.indexOf(".")); + } + int t = Integer.parseInt(tmp); + int frmLocateWidth = screenSize.width * 2 / 5; + int frmLocateHeight = t - 120; + if (frmLocateHeight <= 0) + frmLocateHeight = 0; + Point p = new Point(frmLocateWidth, frmLocateHeight); + return p; + } + + /** + * doubleתΪָСȵ + * @param srcdouble ԭ + * @param length + * @return ָȵ + */ + public static double round(double srcdouble, int length) { + double t = 0d; + try { + t = (double) Math.pow(10, length); + } + catch (RuntimeException e) { + e.printStackTrace(); + } + return (Math.round(srcdouble * t)) / t; + } + + /** + * ֤ѡbomlineǷǵǰû + * @param selectedLine ѡbomline + * @param newsession ϵͳsession + * @return ֤ + */ + public static boolean validateOwnringUser(TCComponentBOMLine selectedLine, TCSession newsession) { + String userName = ""; + String ownerName = ""; + try { + userName = newsession.getUserName(); + userName = "(" + userName + ")"; + + ownerName = selectedLine.getProperty("bl_rev_owning_user"); + } + catch (TCException e) { + e.printStackTrace(); + return false; + } + if (ownerName.indexOf(userName) < 0) { + MessageBox messagebox1 = new MessageBox("ǵǰѡжߣܽд˲", "...", MessageBox.ERROR); + messagebox1.setVisible(true); + return false; + } + return true; + } + + private MessageBox messagebox1; + + /** + * getTimeNum:ʱַ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static String getTimeNum() { + String strTime = ""; + try { + SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + strTime = bartDateFormat.format(new Date()); + System.out.println(strTime); + } + catch (Exception e) { + e.printStackTrace(); + } + return strTime; + } + + /** + * getTimeNum:ʱַ : formatΪyyyyMMddHHmmssSSS + * @param @param format ʽ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static String getTimeNum(String format) { + String strTime = ""; + try { + SimpleDateFormat bartDateFormat = new SimpleDateFormat(format); + strTime = bartDateFormat.format(new Date()); + System.out.println(strTime); + } + catch (Exception e) { + e.printStackTrace(); + } + return strTime; + } + + /** + * øʽʱַ + * @param pDate + * @param pFormat ַʽ + * @return ʽʱַ pFormat=yyyyMMddHHmmssSSS + */ + public static String getFormatTimeNum(Date pDate, String pFormat) { + String strTime = ""; + try { + if (pDate == null) { return ""; } + SimpleDateFormat bartDateFormat = new SimpleDateFormat(pFormat); + strTime = bartDateFormat.format(pDate); + System.out.println(strTime); + } + catch (Exception e) { + e.printStackTrace(); + } + return strTime; + } + + /** + * õǰϵͳjavaʱ· + * @return ǰϵͳjavaʱ· + */ + public static String getJavaTmpDir() { + String filepath = System.getProperty("java.io.tmpdir"); + if (!filepath.endsWith("\\")) { + filepath = filepath + "\\"; + } + System.out.println("getJavaTmpDir() - String filepath=" + filepath); //$NON-NLS-1$ + return filepath; + } + + /** + * getLimLenTxtIgnSomeVt:Թ̶Ȳֿܰĵַ(ַָ),ʸ + * @param src ַ + * @param rowLength + * @param repStr ָ + * @param someStr Եַ + * @param @return 趨ļ + * @return Vector + * @throws + * @since CodingExampleVer 1.1 + */ + public static Vector getLimLenTxtIgnSomeVt(String src, int rowLength, String repStr, String someStr) { + // if (logger.isDebugEnabled()) { + // logger.debug("getLimLenTxtIgnSomeVt(String, int, String, String) - start"); //$NON-NLS-1$ + // } + String ret = ""; + String tmpstr = ""; + Vector v = new Vector(); + Vector vt = new Vector(); + Vector vt1 = new Vector(); + if (src != null || UtilApi.length(src) > 0) { + v = UtilApi.str2vt(src, someStr); + for (int i = 0; i < v.size(); i++) { + tmpstr = v.get(i).toString(); + tmpstr = UtilApi.getLimRowLenText(tmpstr, rowLength, repStr); + tmpstr = UtilApi.nbsp2space(tmpstr); + if (tmpstr.indexOf(repStr) >= 0) { + vt = UtilApi.str2vt(tmpstr, repStr); + for (int j = 0; j < vt.size(); j++) { + vt1.add(vt.get(j).toString()); + } + } else { + vt1.add(tmpstr); + } + } + } + + // if (logger.isDebugEnabled()) { + // logger.debug("getLimLenTxtIgnSomeVt(String, int, String, String) - end"); //$NON-NLS-1$ + // } + return vt1; + } + + /** + * getLimRowLenText:Թ̶Ȳܰĵַ(ַָ) + * @param src ַ + * @param rowLength + * @param repStr ָ + * @param @return ˷ַָ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static String getLimRowLenText(String src, int rowLength, String repStr) { + String ret = ""; + try { + if (src != null || UtilApi.length(src) > 0) { + src = UtilApi.nbsp2space(src); + while (UtilApi.length(src) > 0) { + if (UtilApi.length(src) > rowLength) { + ret += UtilApi.substring(src, 0, rowLength) + repStr; + src = UtilApi.substring(src, rowLength); + } else { + ret += src; + src = ""; + } + } + } + } + catch (Exception e) { + + e.printStackTrace(); + } + String returnString = UtilApi.space2nbsp(ret); + return returnString; + } + + /** + * space2nbsp:ոתΪnbsp + * @param pStr ַ + * @param @return תַ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static String space2nbsp(String pStr) { + if (pStr == null || pStr.length() < 1) + return pStr; + String s1 = ""; + for (int i = 0; i < pStr.length(); i++) + if (pStr.charAt(i) == ' ') + s1 = s1 + " "; + else s1 = s1 + pStr.charAt(i); + return s1; + } + + /** + * substring: ַ + * @param source ַ + * @param iniPos ʼλ + * @param endPos Ϊֹ + * @param @return ַ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static String substring(String source, int iniPos, int endPos) { + String tmpStr = ""; + String tmpStr1 = ""; + String retStr = ""; + int tmpLen = 0; + int len = 0; + try { + len = endPos - iniPos; + if (iniPos >= UtilApi.length(source)) + return ""; + tmpStr = UtilApi.substr(source, iniPos); + tmpLen = tmpStr.length(); + tmpStr1 = source.substring(tmpLen); + if (UtilApi.length(tmpStr1) <= len) + retStr = tmpStr1; + else retStr = UtilApi.substr(tmpStr1, len); + } + catch (Exception e) {} + return retStr; + } + + /* + * ȡһַij,Ӣ,ֲãȡһַλ + * @author patriotlml @param String origin, ԭʼַ @param int len, + * ȡ(һֳȰ2) @return String, صַ(0λõlenλ) + */ + public static String substr(String source, int len) { + String retStr = ""; + if (source == null || source.equals("")) + return ""; + byte[] strByte = new byte[len]; + if (len > UtilApi.length(source)) + return source; + System.arraycopy(source.getBytes(), 0, strByte, 0, len); + int count = 0; + for (int i = 0; i < len; i++) { + int value = (int) strByte[i]; + if (value < 0) { + count++; + } + } + if (count % 2 != 0) { + len = (len == 1) ? ++len : --len; + } + + try { + retStr = new String(strByte, 0, len); + } + catch (Exception e) { + + try { + System.arraycopy(source.getBytes(), 0, strByte, 0, len); + retStr = new String(strByte, 0, len); + } + catch (Exception ex) {} + } + return retStr; + } + + /* + * ȡһַij,Ӣ,ֲãȡһַλ + * @author patriotlml @param String origin, ԭʼַ @param int iniPos, + * ȡַijʼλ @param int len, ȡ(һֳȰ2) @return String, + * صַ(0λõlenλ) + */ + public static String substring(String source, int iniPos) { + String tmpStr = ""; + String tmpStr1 = ""; + String retStr = ""; + int endPos = 0; + try { + endPos = UtilApi.length(source); + tmpStr = UtilApi.substring(source, iniPos, endPos + 1); + } + catch (Exception e) {} + return tmpStr; + } + + /** + * õһַij,ʾij,һֻպijΪ2,ӢַΪ1 + * @param String s ,Ҫõȵַ + * @return int, õַ + */ + public static int length(String s) { + if (s == null) + return 0; + char[] c = s.toCharArray(); + int len = 0; + for (int i = 0; i < c.length; i++) { + len++; + if (!isLetter(c[i])) { + len++; + } + } + return len; + } + + /** + * getLimRowLenTextWithSplitstr: ַ,ù̶ȵַ,滻ַָ + * @param src ַ + * @param rowLength ÿг + * @param repStr 滻ַ + * @param splitStr ָ + * @param @return ַ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static String getLimRowLenTextWithSplitstr(String src, int rowLength, String repStr, String splitStr) { + Vector v = new Vector(); + String retStr = ""; + try { + src = UtilApi.nbsp2space(src); + v = UtilApi.getLimLenTxtIgnSomeVt(src, rowLength, repStr, splitStr); + for (int i = 0; i < v.size(); i++) { + retStr += v.get(i).toString(); + if (i != v.size() - 1) + retStr += repStr; + } + } + catch (Exception e) {} + return retStr; + } + + /** + * nbsp2space:() + * @param s + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static String nbsp2space(String s) { + if (s == null || s.length() < 1) + return s; + String s1 = ""; + if (s.indexOf(" ") >= 0) + s1 = UtilApi.ReplaceAll(s, " ", " "); + else s1 = s; + return s1; + } + + /** + * жһַAscillַַ纺գַ + * @param char c, Ҫжϵַ + * @return boolean, true,Ascillַ + */ + public static boolean isLetter(char c) { + int k = 0x80; + return c / k == 0 ? true : false; + } + + /** + * ReplaceAll:滻ַеضַ + * @param source ַ + * @param regex 滻ַ + * @param replacement 滻ַ + * @param @return 滻ַ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static String ReplaceAll(String source, String regex, String replacement) { + if (source == null) + return ""; + String stmp1 = source; + String stmp2 = ""; + String stmp3 = ""; + int posRegex = stmp1.indexOf(regex); + int regexLen = regex.length(); + while (posRegex >= 0) { + stmp2 = stmp1.substring(0, posRegex); + stmp3 += stmp2 + replacement; + stmp1 = stmp1.substring(posRegex + regexLen); + posRegex = stmp1.indexOf(regex); + } + return stmp3 += stmp1; + } + + /** + * str2vt:ַָָָ,ʸ + * @param source ַ + * @param sepStr ָ + * @param @return ʸ + * @return Vector + * @throws + * @since CodingExampleVer 1.1 + */ + public static Vector str2vt(String source, String sepStr) { + String stmp1 = source; + String stmp2 = ""; + String stmp3 = ""; + Vector vt = new Vector(); + int sepPos = 0; + int sepLen = sepStr.length(); + try { + do { + sepPos = stmp1.indexOf(sepStr); + if (sepPos < 0 || sepLen == 0) { + vt.add(stmp1); + return vt; + } + stmp2 = stmp1.substring(0, sepPos); + vt.add(stmp2); + stmp1 = stmp1.substring(sepPos + sepLen); + } while (stmp1.indexOf(sepStr) >= 0); + vt.add(stmp1); + } + catch (Exception e) {} + return vt; + } + + /** + * str2vt:ַָָָ,ɶάʸ + * @param source ַ + * @param sepStr1 ָһ + * @param sepStr2 ָ + * @param @return ʸ + * @return Vector + * @throws + * @since CodingExampleVer 1.1 + */ + public static Vector str2vt(String source, String sepStr1, String sepStr2) { + + if (source.indexOf(sepStr1) < 0) { return str2vt(source, sepStr2); } + Vector vector = str2vt(source, sepStr1); + Vector vector1 = new Vector(); + for (int i = 0; i < vector.size(); i++) + vector1.addElement(str2vt((String) vector.get(i), sepStr2)); + return vector1; + } + + /** + * str2vt:ַָָָ,άʸ + * @param source ַ + * @param sepStr1 ָһ + * @param sepStr2 ָ + * @param sepStr3 ָ + * @param @return ʸ + * @return Vector + * @throws + * @since CodingExampleVer 1.1 + */ + public static Vector str2vt(String source, String sepStr1, String sepStr2, String sepStr3) { + if (source.indexOf(sepStr1) < 0) { return str2vt(source, sepStr2, sepStr3); } + Vector vector = str2vt(source, sepStr1); + Vector vector1 = new Vector(); + for (int i = 0; i < vector.size(); i++) { + vector1.addElement(str2vt((String) vector.get(i), sepStr2, sepStr3)); + } + return vector1; + } + + /** + * str2vt:ַָָָ,άʸ + * @param source ַ + * @param sepStr1 ָһ + * @param sepStr2 ָ + * @param sepStr3 ָ + * @param sepStr4 ָ + * @param @return ʸ + * @return Vector + * @throws + * @since CodingExampleVer 1.1 + */ + public static Vector str2vt(String source, String sepStr1, String sepStr2, String sepStr3, String sepStr4) { + if (source.indexOf(sepStr1) < 0) { return str2vt(source, sepStr2, sepStr3, sepStr4); } + Vector vector = str2vt(source, sepStr1); + Vector vector1 = new Vector(); + for (int i = 0; i < vector.size(); i++) + vector1.addElement(str2vt((String) vector.get(i), sepStr2, sepStr3, sepStr4)); + return vector1; + } + + /** + * getPreferenceHashMap:ϵͳֵ + * @param session tcsession + * @param scope + * @param pid ѡ + * @param @return 趨ļ + * @return HashMap + * @throws + * @since CodingExampleVer 1.1 + */ + public static String[] getPreference(TCSession session, int scope, String pid) { + try { + String options[] = session.getPreferenceService().getStringArray(scope, pid); + return options; + } + catch (Exception e) { + System.out.println("ûҵѡ:" + pid); + e.printStackTrace(); + return null; + } + + } + + /** + * getPreferenceHashMap:ϵͳֵ + * @param session tcsession + * @param scope + * @param pid ѡ + * @param @return 趨ļ + * @return HashMap + * @throws + * @since CodingExampleVer 1.1 + */ + public static HashMap getPreferenceHashMap(TCSession pSession, int pScope, String pid) { + HashMap hm = new HashMap(); + try { + String[] options = getPreference(pSession, pScope, pid); + if (options == null || options.length == 0) { + System.out.println("processRows(Vector, HashMap) - ************ û" + pid + "ѡ!"); + } + String key = ""; + String value = ""; + for (int i = 0; i < options.length; i++) { + if (options[i].indexOf("=") > 0) { + key = options[i].substring(0, options[i].indexOf("=")); + value = options[i].substring(options[i].indexOf("=") + 1); + hm.put(key, value); + } else { + hm.put("" + i, options[i]); + } + } + } + catch (Exception e) { + e.printStackTrace(); + return null; + } + return hm; + } + + public static InterfaceAIFComponent[] getQueryList(TCSession session, String queryName, String as[], String as1[]) { + System.out.println("begin=====query" + queryName + ""); + InterfaceAIFComponent[] components = null; + // ʹòѯ + try { + components = session.search(queryName, as, as1); + } + catch (Exception e) { + e.printStackTrace(); + MessageBox.post("querying " + queryName + " error" + e.getMessage(), "INFO", MessageBox.INFORMATION); + } + System.out.println("end=====query" + queryName + ""); + return components; + } + + // ======ϵͳѯѯݼ======= + public static TCComponent[] searchComponentCollection(TCSession session, String queryName, String as[], String as1[]) { + TCComponent returnaimancomponent[] = null; + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find(queryName); + querytype.clearCache(); + if(query == null){ + System.out.println("δҵѯ:" + queryName); + return null; + } + int asLen = as.length; + String tValue = ""; + for(int ix = 0; ix < asLen; ix++){ + tValue = textService.getTextValue(as[ix]); + if(tValue != null && !tValue.equals("")){ + as[ix] = tValue; + } + } + TCComponentContextList list = query.getExecuteResultsList(as, as1); + if (list != null && list.getListCount() > 0) { + int count = list.getListCount(); + returnaimancomponent = new TCComponent[count]; + for (int i = 0; i < count; i++) { + AIFComponentContext context = list.get(i); + returnaimancomponent[i] = (TCComponent) context.getComponent(); + } + return returnaimancomponent; + } else { + return null; + } + } + catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + /** + * ضʽַת + * @param str ַ + * @param pattern ַģʽ磺yyyyMdգyyyy-MM-dd + * @return ڶ + * @throws java.text.ParseException + */ + public static Date convertStringToDate(String pattern, String str) { + Date date = null; + try { + if (str.equals("") || str == null) + return date; + + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + date = formatter.parse(str); + } + catch (Exception e) { + e.printStackTrace(); + } + + return date; + } + + private static HashMap msghm = new HashMap(); + + public static synchronized void setMsg(String key, String msg) { + msghm.put(key, msg); + } + + public static synchronized String getMsg(String key) { + String msg = ""; + try { + if (msghm.get(key) == null) { + msg = ""; + } else { + msg = "" + msghm.get(key); + } + } + catch (Exception e) { + e.printStackTrace(); + } + return msg; + } + + /** + * getOptionValues:: ȡѡֵ䵽comboBox + * @param JComboBox + * @param String + * @author liqz + * @since 20111215 + * */ + public static void getOptionValues(TCSession pSession,JComboBox cbo,String strOptionName){ + String[] arrValue= pSession.getPreferenceService().getStringArray(4, strOptionName); + cbo.addItem(""); + for (int i = 0; i < arrValue.length; i++) { + cbo.addItem(arrValue[i]); + } + } + + /** + * getDaysBetween: + * + * @param Date + * + * @param Date + * + * @return int + */ + public static int getDaysBetween(Date dtFormer, Date dtLater) { + GregorianCalendar vFormer = (GregorianCalendar) GregorianCalendar.getInstance(); + GregorianCalendar vLatter = (GregorianCalendar) GregorianCalendar.getInstance(); + + vFormer.setTime(dtFormer); + vLatter.setTime(dtLater); + + vFormer.set(Calendar.MILLISECOND, 0); + vFormer.set(Calendar.SECOND, 0); + vFormer.set(Calendar.MINUTE, 0); + vFormer.set(Calendar.HOUR_OF_DAY, 0); + vLatter.set(Calendar.MILLISECOND, 0); + vLatter.set(Calendar.SECOND, 0); + vLatter.set(Calendar.MINUTE, 0); + vLatter.set(Calendar.HOUR_OF_DAY, 0); + + int iCounter = 0; + while (vFormer.before(vLatter)) { + vFormer.add(Calendar.DATE, 1); + iCounter++; + } + // iCounter = iCounter + 1; + return iCounter; + } +} \ No newline at end of file diff --git a/src/cn/com/customization/util/WriteAndCopyFile.java b/src/cn/com/customization/util/WriteAndCopyFile.java new file mode 100644 index 0000000..ba6b4a1 --- /dev/null +++ b/src/cn/com/customization/util/WriteAndCopyFile.java @@ -0,0 +1,75 @@ +/* +#============================================================================= +# +# copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: WriteAndCopyFile.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2011-4-20 liqz ʵֶļIJ(From Shaangu) +#============================================================================= +*/ +package cn.com.customization.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.FileInputStream; + + +public class WriteAndCopyFile { + + /** + * Creates a new instance of WriteAndCopyFile. + */ + public WriteAndCopyFile() { + + } + + /** + * writeFile:дϢıļ + * @param @param fileName ļȫ· trueӡ + * @param @param append Ƿ񸽼ӵļβ + * @param @param content ļ + * @since CodingExampleVer 1.1 + */ + public void writeFile(String fileName, boolean append, String content) { + FileOutputStream fos; + try { + fos = new FileOutputStream(fileName, append); + fos.write(content.getBytes()); + fos.close(); + } catch (final FileNotFoundException e) { + e.printStackTrace(); + } catch (final IOException e) { + e.printStackTrace(); + } + } + /** + * copyFile:ʵļCopy + * + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public static void copyFile(String src, String dest) throws IOException { + FileInputStream in = new FileInputStream(src); + File file = new File(dest); + if (!file.exists()) + file.createNewFile(); + FileOutputStream out = new FileOutputStream(file); + int c; + byte buffer[] = new byte[1024]; + while ((c = in.read(buffer)) != -1) { + for (int i = 0; i < c; i++) + out.write(buffer[i]); + } + in.close(); + out.close(); + } + +} diff --git a/src/cn/com/customization/util/image/info.png b/src/cn/com/customization/util/image/info.png new file mode 100644 index 0000000..48dd7d0 Binary files /dev/null and b/src/cn/com/customization/util/image/info.png differ diff --git a/src/cn/com/teamcenter/rac/form/GCSelectionUserCommand.java b/src/cn/com/teamcenter/rac/form/GCSelectionUserCommand.java new file mode 100644 index 0000000..6c60e2f --- /dev/null +++ b/src/cn/com/teamcenter/rac/form/GCSelectionUserCommand.java @@ -0,0 +1,66 @@ +package cn.com.teamcenter.rac.form; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.common.organization.OrgObject; +import com.teamcenter.rac.common.organization.OrgSelectionDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.iTextField; + +public class GCSelectionUserCommand extends AbstractAIFCommand implements PropertyChangeListener { + private OrgSelectionDialog orgSelectionDialog; + private iTextField selectPersonText; + + public GCSelectionUserCommand(AIFDesktop desktop, TCSession tcSession) { + orgSelectionDialog = new OrgSelectionDialog(desktop.getFrame(), tcSession, null); + orgSelectionDialog.addPropertyChangeListener(this); + orgSelectionDialog.setOrgTreeSelectionMode(1); + orgSelectionDialog.setSelectionCriteria(false, false, true); + orgSelectionDialog.setShowDetailInfoFlag(false); + orgSelectionDialog.setAlwaysOnTop(true); + setRunnable(orgSelectionDialog); + orgSelectionDialog.setAlwaysOnTop(true); + } + + public void setContextBean(iTextField selectPersonText) { + orgSelectionDialog.setHeaderInfo(null, "ѡ"); + this.selectPersonText = selectPersonText; + } + + public void setContextBean(String title, iTextField selectPersonText) { + orgSelectionDialog.setHeaderInfo(null, title); + this.selectPersonText = selectPersonText; + } + + public void propertyChange(PropertyChangeEvent propertychangeevent) { + String s = propertychangeevent.getPropertyName(); + if(!s.equals("OrgTree Selection Changed")) + { + return; + } + OrgObject aorgobject[] = (OrgObject[])propertychangeevent.getNewValue(); + if(aorgobject == null || aorgobject.length == 0) + { + return; + } + TCComponent selecttionUser = aorgobject[0].getComponent(); + if(!(selecttionUser instanceof TCComponentGroupMember)) { + return; + } + TCComponentGroupMember groupMember = (TCComponentGroupMember)selecttionUser; + try { + //System.out.println("groupMember.getUserId()="+groupMember.getUserId()); + selectPersonText.setText(groupMember.getUser().getProperty("user_name").toString()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} diff --git a/src/cn/com/teamcenter/rac/form/ORTableColorRender.java b/src/cn/com/teamcenter/rac/form/ORTableColorRender.java new file mode 100644 index 0000000..e7b98c3 --- /dev/null +++ b/src/cn/com/teamcenter/rac/form/ORTableColorRender.java @@ -0,0 +1,50 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: TableColorRender.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-11-22 03:46:31 zyn Ini ʼļ +#======================================================================================================= + */ +package cn.com.teamcenter.rac.form; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; + +public class ORTableColorRender implements TableCellRenderer { + // + public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer(); + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value != null&& value instanceof String) { + Color foreground = table.getForeground(); + Color background = table.getBackground(); + + if(column == 1){ + if (((String) value).contains("ڷ")) { + background = Color.YELLOW; + } else if(((String) value).contains("")||((String) value).equals("")) { + background = Color.RED; + } else if(((String) value).contains("ͣ")) { + background = Color.GRAY; + } + } + renderer.setForeground(foreground); + renderer.setBackground(background); + } + + return renderer; + } +} + + diff --git a/src/cn/com/teamcenter/rac/form/YSR8_ProjectForm.java b/src/cn/com/teamcenter/rac/form/YSR8_ProjectForm.java new file mode 100644 index 0000000..25fc247 --- /dev/null +++ b/src/cn/com/teamcenter/rac/form/YSR8_ProjectForm.java @@ -0,0 +1,1875 @@ +package cn.com.teamcenter.rac.form; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.common.organization.OrgTreePanel; +import com.teamcenter.rac.common.organization.OrganizationTree; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.stylesheet.PropertyDateButton; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextArea; +import com.teamcenter.rac.util.iTextField; + +import cn.com.customization.util.KUtil; +import cn.com.customization.util.UtilApi; + +public class YSR8_ProjectForm extends AbstractRendering { + + private static final long serialVersionUID = 1L; + private TCSession session = null; + private TCComponentForm ysr8ProjectForm = null; + private TCComponentSchedule schedule; + private TCComponentProject projectComp; + + private DateButton dateUpdateTime; + private JButton btnUpdateData; + private iTextField ysr8_QuotationNo; // ۵ + private iTextField ysr8_ProjectCode; // + private iTextField ysr8_ProjectName; // Ŀ + private iTextField ysr8_OrderManufacturer; // + private iTextField ysr8_CustomerName; // û + private iTextField ysr8_ProjectCategory; // Ŀ + private iTextField ysr8_Factory; // + private iTextField ysr8_Product; // Ʒ + private iTextField ysr8_Use; // ; + private iTextArea ysr8_ProjectContent; // Ŀ + private iTextField ysr8_FixtrueCount; // о + private iTextField ysr8_AttachCount; // + private iTextField ysr8_GuidCount; // ȫ + private iTextField ysr8_JigCount; // λ + private iTextField ysr8_PositionerCount; // ί + private iTextField ysr8_RobotCount; // + private iTextArea ysr8_RobotModel; // ͺ + private DateButton ysr8_ReceiveDate; // · + private DateButton ysr8_SaleStartDate; // + private DateButton ysr8_StartDate; // ϵͳ + private DateButton ysr8_ContractDate; // ǩͬ + private DateButton ysr8_ActualFactoryDate; // ʵʳʱ + private DateButton ysr8_PlanDeliveryDate; // ʱ䣨֪ͨ + private DateButton ysr8_ActualDeliveryDate; // ʱ䣨ͬ + private DateButton ysr8_ProductionDate; // Ԥʱ + private DateButton ysr8_PlanAcceptance; // ƻ + private DateButton ysr8_FinalAcceptance; // ʵ + + private DefaultTableModel modMilestone; + private DefaultTableModel modKeyTasks; + private DefaultTableModel modMembers; + + private JTable tblProjectMilestone;// Ŀ̱ + private JTable tblProjectKeyTasks; // Ŀؼ + private JTable tblProjectMembers; // ĿԱ + + private iTextField ysr8_ProjectManager; // Ŀ + private iTextField ysr8_Planner; // ƻԱ + private iTextField ysr8_DesignDirector; // + private iTextField ysr8_ElectricDirector; // + private iTextField ysr8_Purcher; // ɹ + private iTextField ysr8_Machiner; // ӹ + private iTextField ysr8_EngineerDebug; // ̵Ա + private iTextField ysr8_ElecDebug; // Ա + private iTextField ysr8_Sales; // ۸ + + private JButton btnAddMember; + private JButton btnRemoveMember; + + private Vector vtProjectAdmin; + // private Vector vtProjectMembers; + private Vector vtProjectMembers; + private Vector vtPrivilegedUsers; + private HashMap hmUserRole; + private String[] arrMilestoneTaskProp; + private String[] arrKeyTaskProp; + private JDialog dlg; + + private Vector allComponents = new Vector(); + private TCFormProperty[] formProperties; + private Hashtable indices = new Hashtable(); + private static SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); + + public YSR8_ProjectForm(TCComponentForm form) throws Exception { + super(form); + // Auto-generated constructor stub + this.ysr8ProjectForm = form; + session = ysr8ProjectForm.getSession(); + + addUIComponents(); + initUI(); + loadRendering(); + + getSchedule(); + getScheduleTasks(); + getMilestoneTaskInfo(); + getKeyTaskInfo(); + loadProjectMember(); + } + + + + @Override + public void displayDialog(AbstractAIFDialog arg0, boolean arg1) { + KUtil.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + + + @Override + public void displayDialog(OpenFormDialog arg0, boolean arg1) { + KUtil.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + + + private void initUI() { + + // JPanel projectBasicInfo = new JPanel(new BorderLayout()); + // projectBasicInfo.add(BorderLayout.NORTH, initProjectBasicInfo()); + // JPanel projectPersonInfo = new JPanel(new BorderLayout()); + + JTabbedPane tabPane = new JTabbedPane(); + tabPane.addTab("ĿϢ", initProjectBasicInfo()); + tabPane.addTab("ĿԱϢ", initProjectPersonInfo()); + + setLayout(new GridLayout()); + add(tabPane); + } + + private JScrollPane initProjectBasicInfo() { + + JPanel paneUpdate = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 0)); + paneUpdate.add("1.1.right.right", new JLabel("ʱ: ")); + paneUpdate.add("1.2.right.right", dateUpdateTime); + paneUpdate.add("1.3.right.right", btnUpdateData); + + JPanel paneBasic = new JPanel(new GridBagLayout()); + GridBagConstraints g4 = new GridBagConstraints(); + g4.insets = new Insets(5, 5, 5, 5); + g4.anchor = GridBagConstraints.WEST; + g4.fill = GridBagConstraints.HORIZONTAL; + + g4.gridx = 0; + g4.gridy = 0; + paneBasic.add(new JLabel("Ŀ:"), g4); + + g4.gridx = 1; + g4.gridy = 0; + g4.gridwidth=3; + paneBasic.add(ysr8_ProjectName, g4); + g4.gridwidth=1; + + g4.gridx = 0; + g4.gridy = 1; + paneBasic.add(new JLabel("Ŀ:"), g4); + + g4.gridx = 1; + g4.gridy = 1; + g4.gridheight = 4; + g4.gridwidth=3; + paneBasic.add(new JScrollPane(ysr8_ProjectContent), g4); + g4.gridwidth=1; + g4.gridheight=1; + + g4.gridwidth = 1; + g4.gridx = 0; + g4.gridy = 5; + paneBasic.add(new JLabel("۵:"), g4); + + g4.gridx = 1; + paneBasic.add(ysr8_QuotationNo, g4); + + g4.gridx = 2; + paneBasic.add(new JLabel(":"), g4); + + g4.gridx = 3; + paneBasic.add(ysr8_ProjectCode, g4); + + g4.gridx = 0; + g4.gridy++; + paneBasic.add(new JLabel(":"), g4); + + g4.gridx = 1; + g4.gridwidth = 3; + paneBasic.add(ysr8_OrderManufacturer, g4); + + g4.gridx = 0; + g4.gridy++; + paneBasic.add(new JLabel("û:"), g4); + + g4.gridx = 1; + g4.gridwidth = 3; + paneBasic.add(ysr8_CustomerName, g4); + + g4.gridwidth = 1; + g4.gridx = 0; + g4.gridy++; + paneBasic.add(new JLabel("Ŀ:"), g4); + + g4.gridx = 1; + paneBasic.add(ysr8_ProjectCategory, g4); + + g4.gridx = 2; + paneBasic.add(new JLabel(":"), g4); + + g4.gridx = 3; + paneBasic.add(ysr8_Factory, g4); + + g4.gridx = 0; + g4.gridy++; + paneBasic.add(new JLabel("Ʒ:"), g4); + + g4.gridx = 1; + paneBasic.add(ysr8_Product, g4); + + g4.gridx = 2; + paneBasic.add(new JLabel(";:"), g4); + + g4.gridx = 3; + paneBasic.add(ysr8_Use, g4); + + + + /*JPanel paneCount = new JPanel(new GridBagLayout()); + GridBagConstraints g3 = new GridBagConstraints(); + g3.insets = new Insets(5, 5, 5, 5); + g3.anchor = GridBagConstraints.WEST; + g3.fill = GridBagConstraints.HORIZONTAL; + + g3.gridwidth = 1; + g3.gridx = 0; + g3.gridy = 0; + paneCount.add(new JLabel("о:"), g3); + + g3.gridx = 1; + g3.gridy = 0; + paneCount.add(ysr8_FixtrueCount, g3); + + g3.gridx = 2; + g3.gridy = 0; + paneCount.add(new JLabel(":"), g3); + + g3.gridx = 3; + g3.gridy = 0; + paneCount.add(ysr8_AttachCount, g3); + + g3.gridx = 4; + g3.gridy = 0; + paneCount.add(new JLabel("ȫ:"), g3); + + g3.gridx = 5; + g3.gridy = 0; + paneCount.add(ysr8_GuidCount, g3); + + g3.gridx = 0; + g3.gridy = 1; + paneCount.add(new JLabel("λ:"), g3); + + g3.gridx = 1; + g3.gridy = 1; + paneCount.add(ysr8_JigCount, g3); + + g3.gridx = 2; + g3.gridy = 1; + paneCount.add(new JLabel("ί:"), g3); + + g3.gridx = 3; + g3.gridy = 1; + paneCount.add(ysr8_PositionerCount, g3); + + g3.gridx = 4; + g3.gridy = 1; + paneCount.add(new JLabel(":"), g3); + + g3.gridx = 5; + g3.gridy = 1; + paneCount.add(ysr8_RobotCount, g3); + + g3.gridx = 0; + g3.gridy = 2; + paneCount.add(new JLabel("ͺ:"), g3); + + g3.gridx = 1; + g3.gridy = 2; + g3.gridheight = 2; + g3.gridwidth=5; + JScrollPane scrollPane = new JScrollPane(ysr8_RobotModel); + scrollPane.setPreferredSize(new Dimension(755, 57)); + paneCount.add(scrollPane, g3); + g3.gridwidth=1;*/ + + JPanel pane1 = new JPanel(new GridBagLayout()); + GridBagConstraints g2 = new GridBagConstraints(); + g2.insets = new Insets(5, 5, 5, 5); + g2.anchor = GridBagConstraints.WEST; + g2.fill = GridBagConstraints.HORIZONTAL; + + g2.gridx = 0; + g2.gridy = 0; + pane1.add(new JLabel("·:"), g2); + + g2.gridx = 1; + g2.gridy = 0; + ysr8_ReceiveDate.setPreferredSize(new Dimension(133, 23)); + pane1.add(ysr8_ReceiveDate, g2); + + g2.gridx = 2; + g2.gridy = 0; + pane1.add(new JLabel(":"), g2); + + g2.gridx = 3; + g2.gridy = 0; + ysr8_SaleStartDate.setPreferredSize(new Dimension(133, 23)); + pane1.add(ysr8_SaleStartDate, g2); + + g2.gridx = 4; + g2.gridy = 0; + pane1.add(new JLabel("ϵͳ:"), g2); + + g2.gridx = 5; + g2.gridy = 0; + ysr8_StartDate.setPreferredSize(new Dimension(133, 23)); + pane1.add(ysr8_StartDate, g2); + + g2.gridx = 6; + g2.gridy = 0; + pane1.add(new JLabel("ǩͬ:"), g2); + + g2.gridx = 7; + g2.gridy = 0; + ysr8_ContractDate.setPreferredSize(new Dimension(132, 23)); + pane1.add(ysr8_ContractDate, g2); + + JPanel pane2 = new JPanel(new GridBagLayout()); + GridBagConstraints g1 = new GridBagConstraints(); + g1.insets = new Insets(5, 5, 5, 5); + g1.anchor = GridBagConstraints.WEST; + g1.fill = GridBagConstraints.HORIZONTAL; + + g1.gridx = 0; + g1.gridy = 0; + pane2.add(new JLabel("ʵʳʱ:"), g1); + + g1.gridx = 1; + g1.gridy = 0; + ysr8_ActualFactoryDate.setPreferredSize(new Dimension(161, 23)); + pane2.add(ysr8_ActualFactoryDate, g1); + + g1.gridx = 2; + g1.gridy = 0; + pane2.add(new JLabel("ʱ䣨֪ͨ:"), g1); + + g1.gridx = 3; + g1.gridy = 0; + ysr8_PlanDeliveryDate.setPreferredSize(new Dimension(161, 23)); + pane2.add(ysr8_PlanDeliveryDate, g1); + + g1.gridx = 4; + g1.gridy = 0; + pane2.add(new JLabel("ʱ䣨ͬ:"), g1); + + g1.gridx = 5; + g1.gridy = 0; + ysr8_ActualDeliveryDate.setPreferredSize(new Dimension(160, 23)); + pane2.add(ysr8_ActualDeliveryDate, g1); + + g1.gridx = 0; + g1.gridy = 1; + pane2.add(new JLabel("Ԥʱ:"), g1); + + g1.gridx = 1; + g1.gridy = 1; + pane2.add(ysr8_ProductionDate, g1); + + g1.gridx = 2; + g1.gridy = 1; + pane2.add(new JLabel("ƻ:"), g1); + + g1.gridx = 3; + g1.gridy = 1; + pane2.add(ysr8_PlanAcceptance, g1); + + g1.gridx = 4; + g1.gridy = 1; + pane2.add(new JLabel("ʵ:"), g1); + + g1.gridx = 5; + g1.gridy = 1; + pane2.add(ysr8_FinalAcceptance, g1); + + // Ŀ̱ + JPanel paneMilestone = new JPanel(new BorderLayout()); + paneMilestone.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Ŀ̱")); + String[] arrMilestoneTitle = new String[] { "̱", "", "ʱ", "ƻʱ", "ʵʱ", "" }; + modMilestone = new DefaultTableModel(new Object[0][6], arrMilestoneTitle) { + + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + tblProjectMilestone = new JTable(modMilestone); + tblProjectMilestone.setDefaultRenderer(Object.class, new ORTableColorRender()); + tblProjectMilestone.setColumnSelectionAllowed(false); + tblProjectMilestone.getTableHeader().setReorderingAllowed(false); + + JScrollPane jspMilestone = new JScrollPane(tblProjectMilestone); + paneMilestone.add(BorderLayout.CENTER, jspMilestone); + paneMilestone.setPreferredSize(new Dimension(835, 150)); + tblProjectMilestone.addMouseListener(new MouseListener() { + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 1) { + for (int i = 0; i <= 5; i++) { + if (i != 1) { + TableColumn column = tblProjectMilestone.getColumnModel().getColumn(i); + column.setCellRenderer(new DefaultTableCellRenderer()); + } + } + } + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + }); + + // Ŀؼ + JPanel paneKeyTasks = new JPanel(new BorderLayout()); + paneKeyTasks.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Ŀؼ")); + String[] arrKeyTasksTitle = new String[] { "Ŀ", "", "ʱ", "״̬", "", "ƻʼʱ", "ƻʱ", "ʵʿʼʱ", "ʵʱ" }; + modKeyTasks = new DefaultTableModel(new Object[0][9], arrKeyTasksTitle) { + + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int row, int column) { + return false; + } + }; + tblProjectKeyTasks = new JTable(modKeyTasks); + tblProjectKeyTasks.setDefaultRenderer(Object.class, new ORTableColorRender()); + tblProjectKeyTasks.getTableHeader().setReorderingAllowed(false); + + JScrollPane jspKeyTasks = new JScrollPane(tblProjectKeyTasks); + paneKeyTasks.add(BorderLayout.CENTER, jspKeyTasks); + paneKeyTasks.setPreferredSize(new Dimension(835, 150)); + tblProjectKeyTasks.addMouseListener(new MouseListener() { + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 1) { + for (int i = 0; i <= 8; i++) { + if (i != 1) { + TableColumn column = tblProjectKeyTasks.getColumnModel().getColumn(i); + column.setCellRenderer(new DefaultTableCellRenderer()); + } + } + } + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + }); + + JPanel paneProjectBasicInfo = new JPanel(); + paneProjectBasicInfo.setLayout(new PropertyLayout()); + //int width=(int) paneBasic.getPreferredSize().getWidth(); + //paneCount.setPreferredSize(new Dimension(width, (int)paneCount.getPreferredSize().getHeight())); + paneProjectBasicInfo.add("1.1.left.center", paneUpdate); + paneProjectBasicInfo.add("2.1.left.center", paneBasic); +// paneProjectBasicInfo.add("3.1.left.center", paneCount); + paneProjectBasicInfo.add("3.1.left.center", pane1); + paneProjectBasicInfo.add("4.1.left.center", pane2); + paneProjectBasicInfo.add("5.1.left.center", paneMilestone); + paneProjectBasicInfo.add("6.1.left.center", paneKeyTasks); + + JScrollPane sMain = new JScrollPane(paneProjectBasicInfo); + return sMain; + } + + private JScrollPane initProjectPersonInfo() { + + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout(10,7,5,5,5,5)); + + topPanel.add("1.1.left.center", new JLabel("Ŀ:")); + topPanel.add("1.2.left.center", ysr8_ProjectManager); + topPanel.add("1.3.left.center", new JLabel("ƻԱ:")); + topPanel.add("1.4.left.center", ysr8_Planner); + topPanel.add("1.5.left.center", new JLabel("е:")); + // hubing 20180615 + topPanel.add("1.6.left.center", ysr8_DesignDirector); + topPanel.add("2.1.left.center", new JLabel(":")); + topPanel.add("2.2.left.center", ysr8_ElectricDirector); + topPanel.add("2.3.left.center", new JLabel("ɹ:")); + topPanel.add("2.4.left.center", ysr8_Purcher); + topPanel.add("2.5.left.center", new JLabel("ӹ:")); + topPanel.add("2.6.left.center", ysr8_Machiner); + topPanel.add("3.1.left.center", new JLabel("̵Ա:")); + topPanel.add("3.2.left.center", ysr8_EngineerDebug); + topPanel.add("3.3.left.center", new JLabel("Ա:")); + topPanel.add("3.4.left.center", ysr8_ElecDebug); + topPanel.add("3.5.left.center", new JLabel("۸:")); + topPanel.add("3.6.left.center", ysr8_Sales); + + String[] arrMemberTitle = new String[] { "Ŀɫ", "֯ɫ", "ĿԱ", "ϵ绰" }; + modMembers = new DefaultTableModel(new Object[0][4], arrMemberTitle) { + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int row, int column) { + return false; + } + }; + tblProjectMembers = new JTable(modMembers); + tblProjectMembers.getTableHeader().setReorderingAllowed(false); + JScrollPane jspMembers = new JScrollPane(tblProjectMembers); + jspMembers.setPreferredSize(new Dimension(946, 300)); + + btnAddMember = new JButton("Ա"); + btnAddMember.setVisible(false); + btnAddMember.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (checkPrivilege()) { + AddMember(); + } + } + }); + btnRemoveMember = new JButton("ƳԱ"); + btnRemoveMember.setVisible(false); + btnRemoveMember.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + if (checkPrivilege()) { + removeMember(); + } + } + }); + JPanel paneButton = new JPanel(new PropertyLayout()); + paneButton.add("1.1.left.center", btnAddMember); + paneButton.add("2.1.left.center", btnRemoveMember); + + JPanel panelMember = new JPanel(new PropertyLayout()); + panelMember.add("1.1.left.center", jspMembers); + panelMember.add("1.2.left.center", paneButton); + + JPanel paneProjectPersonInfo = new JPanel(); + paneProjectPersonInfo.setBorder(new EmptyBorder(5, 5, 5, 5)); + paneProjectPersonInfo.setLayout(new PropertyLayout()); + paneProjectPersonInfo.add("1.1.left.center", topPanel); + paneProjectPersonInfo.add("2.1.left.center", panelMember); + + JScrollPane sMain = new JScrollPane(paneProjectPersonInfo); + return sMain; + } + + @Override + public void loadRendering() throws TCException { + // Auto-generated method stub + try { + this.formProperties = ysr8ProjectForm.getAllFormProperties(); + int length = this.formProperties.length; + int pSize = allComponents.size(); + for (int k = 0; k < length; ++k) { + String propName = this.formProperties[k].getPropertyName().trim(); + // System.out.println("propName="+propName); + for (int i = 0; i < pSize; i++) { + Component component = allComponents.get(i); + String name = component.getName(); + if (component instanceof iTextField) { + iTextField textField = (iTextField) component; + if (propName.equalsIgnoreCase(name)) { + textField.setText(this.formProperties[k].getStringValue()); + indices.put(formProperties[k], textField); + break; + } + } else if (component instanceof JTextArea) { + JTextArea textArea = (JTextArea) component; + if (propName.equalsIgnoreCase(name)) { + textArea.setText(this.formProperties[k].getStringValue()); + indices.put(formProperties[k], textArea); + break; + } + } else if (component instanceof JComboBox) { + JComboBox combox = (JComboBox) component; + if (propName.equalsIgnoreCase(name)) { + combox.setSelectedItem(this.formProperties[k].getStringValue()); + indices.put(formProperties[k], combox); + break; + } + } else if (component instanceof DateButton) { + DateButton btn = (DateButton) component; + if (propName.equalsIgnoreCase(name)) { + btn.setDate(formProperties[k].getDateValue()); + indices.put(formProperties[k], btn); + break; + } + } + } + } + } catch (TCException imanexception) { + throw imanexception; + } + } + + @Override + public void saveRendering() { + // Auto-generated method stub + Enumeration enumeration = this.indices.keys(); + Enumeration enumeration1 = this.indices.elements(); + TCFormProperty[] aimanformproperty = new TCFormProperty[this.indices.size()]; + try { + for (int i = 0; enumeration.hasMoreElements(); i++) { + TCFormProperty imanformproperty = (TCFormProperty) enumeration.nextElement(); + Object component = enumeration1.nextElement(); + //String propName = imanformproperty.getPropertyName(); + if (component instanceof iTextField) { + //setByPass(true); + //System.out.println("ԣ"+imanformproperty.getName()+" = "+((iTextField) component).getText().toString()); + setStringToPropertyValue(imanformproperty, ((iTextField) component).getText().toString()); + //setByPass(false); + } else if (component instanceof JTextArea) { + setStringToPropertyValue(imanformproperty, ((JTextArea) component).getText().toString()); + } else if (component instanceof JComboBox) { + setStringToPropertyValue(imanformproperty, ((JComboBox) component).getSelectedItem().toString()); + } else if (component instanceof DateButton) { + DateButton btn = (DateButton) component; + if (btn.getDate() != null) { + imanformproperty.setDateValue(btn.getDate()); + } else { + imanformproperty.setDateValue(null); + } + } + aimanformproperty[i] = imanformproperty; + } + try { + ysr8ProjectForm.setTCProperties(aimanformproperty); + } catch (Exception exception) { + exception.printStackTrace(); + MessageBox.post(exception); + } + } catch (TCException imane) { + imane.printStackTrace(); + } + + updateProjectMember(); + } + + public static void setByPass(boolean val) throws TCException { + TCUserService userservice = null; + if (userservice == null) { + userservice = ((TCSession) AIFUtility.getCurrentApplication().getSession()).getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { + userservice.call("YSR_set_bypass", obj); + } else { + userservice.call("YSR_close_bypass", obj); + } + } + @Override + public boolean isRenderingModified() { + Enumeration enumeration = this.indices.keys(); + Enumeration enumeration1 = this.indices.elements(); + for (int i = 0; enumeration.hasMoreElements(); i++) { + TCFormProperty imanformproperty = (TCFormProperty) enumeration.nextElement(); + Object component = enumeration1.nextElement(); + if (component instanceof iTextField) { + String strTempValue = ((iTextField) component).getText().toString(); + if (!imanformproperty.getStringValue().equals(strTempValue)) { + return true; + } + } else if (component instanceof iTextArea) { + String strTempValue = ((iTextArea) component).getText().toString(); + if (!imanformproperty.getStringValue().equals(strTempValue)) { + return true; + } + } else if (component instanceof JComboBox) { + String strTempValue = ((JComboBox) component).getSelectedItem().toString(); + if (!imanformproperty.getStringValue().equals(strTempValue)) { + return true; + } + } else if (component instanceof DateButton) { + DateButton btn = (DateButton) component; + if (imanformproperty.getDateValue() != null && btn.getDate() != null) { + if (imanformproperty.getDateValue().getTime() != btn.getDate().getTime()) { + return true; + } + } else if (imanformproperty.getDateValue() != null && btn.getDate() == null) { + return true; + } else if (imanformproperty.getDateValue() == null && btn.getDate() != null) { + return true; + } + } + } + return false; + } + //kk ѡӶɫã; + public String getUserNames(String orgName) { + String[] orgNameSplit = orgName.split(";"); + StringBuilder res=new StringBuilder(); + for (String org : orgNameSplit) { + String val=getPropertyValue2(org); + if(!"".equals(val)) { + res.append(val).append(";"); + } + } + if(res.length()>0) { + res.setLength(res.length()-1); + } + return res.toString(); + } + + public String getPropertyValue2(String orgName) { + String value = ""; + if(orgName==null||"".equals(orgName)) { + return value; + } + //kk ѡдڵȺұ + if("ĿСԱ".equals(orgName)) { + TCComponent[] comps; + try { + comps = schedule.getReferenceListProperty("project_list"); + if (comps != null && comps.length > 0) { + projectComp = (TCComponentProject) comps[0]; + } + if (projectComp == null) { + return value; + } + TCComponentUser[] admins = (TCComponentUser[])projectComp.getTeam().get(1); + StringBuilder valueB = new StringBuilder(); + for (TCComponentUser admin : admins) { + valueB.append(admin.getStringProperty("user_name")).append(";"); + } + if(valueB.length()>0) { + valueB.setLength(valueB.length()-1); + } + value = valueB.toString(); + return value; + } catch (TCException e) { + e.printStackTrace(); + return value; + } + }else if("Ŀ".equals(orgName)) { + TCComponent[] comps; + try { + comps = schedule.getReferenceListProperty("project_list"); + if (comps != null && comps.length > 0) { + projectComp = (TCComponentProject) comps[0]; + } + if (projectComp == null) { + return value; + } + TCComponentUser user=(TCComponentUser) projectComp.getReferenceProperty("owning_user"); + value=user.getStringProperty("user_name"); + return value; + } catch (TCException e) { + e.printStackTrace(); + return value; + } + } + StringBuilder valueB = new StringBuilder(); + int rowCount = tblProjectMembers.getRowCount(); + for (int i = 0; i < rowCount; i++) { + Object orgObj = tblProjectMembers.getModel().getValueAt(i, 1); + Object userNameObj = tblProjectMembers.getModel().getValueAt(i, 2); + String orgStr = orgObj == null ? "" : orgObj.toString(); + String userNameStr = userNameObj == null ? "" : userNameObj.toString(); + if (orgName.equalsIgnoreCase(orgStr)) { + valueB.append(userNameStr).append(";"); + } + } + if(valueB.length()>0) { + valueB.setLength(valueB.length()-1); + } + value = valueB.toString(); + if (value.endsWith(";")) { + value.substring(0, value.length() - 1); + } + + return value; + } + + private void getPropertyValueByPreference() { + ysr8_ProjectManager.setName("ysr8_ProjectManager"); + ysr8_Planner.setName("ysr8_Planner"); + ysr8_EngineerDebug.setName("ysr8_EngineerDebug"); + ysr8_ElecDebug.setName("ysr8_ElecDebug"); + ysr8_Sales.setName("ysr8_Sales"); + ysr8_DesignDirector.setName("ysr8_DesignDirector"); + ysr8_ElectricDirector.setName("ysr8_ElectricDirector"); + ysr8_Purcher.setName("ysr8_Purcher"); + ysr8_Machiner.setName("ysr8_Machiner"); + + TCPreferenceService service = session.getPreferenceService(); + + String[] values = service.getStringValues("YSR_ProjectForm_Personnel"); + if (values == null || values.length < 2) { + return; + } + for (String value : values) { + String[] names = value.split("="); + if (names == null || names.length < 2) { + continue; + } + String propName = names[0]; + String orgName = names[1]; + //System.out.println(propName); + switch (propName) { + case "ysr8_ProjectManager": + ysr8_ProjectManager.setText(getUserNames(orgName)); + break; + case "ysr8_Planner": + ysr8_Planner.setText(getUserNames(orgName)); + break; + case "ysr8_EngineerDebug": + ysr8_EngineerDebug.setText(getUserNames(orgName)); + break; + case "ysr8_ElecDebug": + ysr8_ElecDebug.setText(getUserNames(orgName)); + break; + case "ysr8_Sales": + ysr8_Sales.setText(getUserNames(orgName)); + break; + case "ysr8_DesignDirector": + //System.out.println(getUserNames(orgName)+"@"+orgName); + ysr8_DesignDirector.setText(getUserNames(orgName)); + break; + case "ysr8_ElectricDirector": + ysr8_ElectricDirector.setText(getUserNames(orgName)); + break; + case "ysr8_Purcher": + ysr8_Purcher.setText(getUserNames(orgName)); + break; + case "ysr8_Machiner": + ysr8_Machiner.setText(getUserNames(orgName)); + break; + + } + + } + } + + private void addUIComponents() { + + dateUpdateTime = newDateButton(); + // dateUpdateTime.setPreferredSize(new Dimension(186, 23)); + btnUpdateData = new JButton("ݸ"); // kk Ŀ ĿСԱ + btnUpdateData.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + clearData(); + dateUpdateTime.setDate(new Date()); + boolean isOK = getBasicInfo(); + if (!isOK) { + return; + } + loadProjectMember(); + getScheduleTasks(); + getMilestoneTaskInfo(); + getKeyTaskInfo(); + // + getPropertyValueByPreference(); + } + }); + + ysr8_QuotationNo = new iTextField(30); + ysr8_QuotationNo.setEnabled(false); + ysr8_ProjectCode = new iTextField(30); + ysr8_ProjectCode.setEnabled(false); + ysr8_ProjectName = new iTextField(30); + ysr8_ProjectName.setEnabled(false); + ysr8_OrderManufacturer = new iTextField(30); + ysr8_OrderManufacturer.setEnabled(false); + ysr8_CustomerName = new iTextField(30); + ysr8_CustomerName.setEnabled(false); + + ysr8_ProjectCategory = new iTextField(30); + ysr8_ProjectCategory.setEnabled(false); + ysr8_Factory = new iTextField(30); + ysr8_Factory.setEnabled(false); + ysr8_Product = new iTextField(30); + ysr8_Product.setEnabled(false); + ysr8_Use = new iTextField(30); + ysr8_Use.setEnabled(false); + ysr8_ProjectContent = new iTextArea(7, 60); + ysr8_ProjectContent.setEnabled(false); + + ysr8_FixtrueCount = new iTextField(16); + ysr8_AttachCount = new iTextField(16); + ysr8_GuidCount = new iTextField(16); + ysr8_JigCount = new iTextField(16); + ysr8_PositionerCount = new iTextField(16); + + ysr8_RobotCount = new iTextField(16); + ysr8_RobotModel = new iTextArea(3, 60); + + ysr8_ReceiveDate = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_SaleStartDate = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_StartDate = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_ContractDate = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_ActualFactoryDate = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_PlanDeliveryDate = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_ActualDeliveryDate = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_ProductionDate = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_PlanAcceptance = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + ysr8_FinalAcceptance = new DateButton(new Date(), "yyyy-MM-dd", false, false, false); + + ysr8_ProjectManager = new iTextField(20); + ysr8_ProjectManager.setEnabled(false); + ysr8_Planner = new iTextField(20); + ysr8_Planner.setEnabled(false); + // HUBING 20180615 + ysr8_DesignDirector = new iTextField(20); + ysr8_DesignDirector.setEnabled(false); + ysr8_ElectricDirector = new iTextField(20); + ysr8_ElectricDirector.setEnabled(false); + ysr8_Purcher = new iTextField(20); + ysr8_Purcher.setEnabled(false); + // HUBING 20180615 + final GCSelectionUserCommand selectionUserCmd = new GCSelectionUserCommand(AIFUtility.getCurrentApplication().getDesktop(), session); + /*ysr8_Purcher.setToolTipText("˫ѡ"); + ysr8_Purcher.addMouseListener(new MouseAdapter() { + + public void mouseClicked(MouseEvent mouseevent) { + if (mouseevent.getClickCount() == 2) { + ViewEditHelper editHelp = new ViewEditHelper(session); + boolean checkedOut = editHelp.isCheckedOutByUser(ysr8ProjectForm); + if (checkedOut && isModifiable()) { + selectionUserCmd.setContextBean(ysr8_Purcher); + try { + selectionUserCmd.executeModal(); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + } + } + } + });*/ + ysr8_Machiner = new iTextField(20); + ysr8_Machiner.setEnabled(false); + /*ysr8_Machiner.setToolTipText("˫ѡ"); + ysr8_Machiner.addMouseListener(new MouseAdapter() { + + public void mouseClicked(MouseEvent mouseevent) { + if (mouseevent.getClickCount() == 2) { + ViewEditHelper editHelp = new ViewEditHelper(session); + boolean checkedOut = editHelp.isCheckedOutByUser(ysr8ProjectForm); + if (checkedOut && isModifiable()) { + selectionUserCmd.setContextBean(ysr8_Machiner); + try { + selectionUserCmd.executeModal(); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + } + } + } + });*/ + ysr8_EngineerDebug = new iTextField(20); + ysr8_EngineerDebug.setEnabled(false); + /*ysr8_EngineerDebug.setToolTipText("˫ѡ"); + ysr8_EngineerDebug.addMouseListener(new MouseAdapter() { + + public void mouseClicked(MouseEvent mouseevent) { + if (mouseevent.getClickCount() == 2) { + ViewEditHelper editHelp = new ViewEditHelper(session); + boolean checkedOut = editHelp.isCheckedOutByUser(ysr8ProjectForm); + if (checkedOut && isModifiable()) { + selectionUserCmd.setContextBean(ysr8_EngineerDebug); + try { + selectionUserCmd.executeModal(); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + } + } + } + });*/ + ysr8_ElecDebug = new iTextField(20); + ysr8_ElecDebug.setEnabled(false); + /*ysr8_ElecDebug.setToolTipText("˫ѡ"); + ysr8_ElecDebug.addMouseListener(new MouseAdapter() { + + public void mouseClicked(MouseEvent mouseevent) { + if (mouseevent.getClickCount() == 2) { + ViewEditHelper editHelp = new ViewEditHelper(session); + boolean checkedOut = editHelp.isCheckedOutByUser(ysr8ProjectForm); + if (checkedOut && isModifiable()) { + selectionUserCmd.setContextBean(ysr8_ElecDebug); + try { + selectionUserCmd.executeModal(); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + } + } + } + });*/ + ysr8_Sales = new iTextField(20); + ysr8_Sales.setEnabled(false); + + dateUpdateTime.setName("ysr8_UpdateT"); + ysr8_QuotationNo.setName("ysr8_QuotationNo"); + ysr8_ProjectCode.setName("ysr8_ProjectCode"); + ysr8_ProjectName.setName("ysr8_ProjectName"); + ysr8_OrderManufacturer.setName("ysr8_OrderManufacturer"); + ysr8_CustomerName.setName("ysr8_CustomerName"); + ysr8_ProjectCategory.setName("ysr8_ProjectCategory"); + ysr8_Factory.setName("ysr8_Factory"); + ysr8_Product.setName("ysr8_Product"); + ysr8_Use.setName("ysr8_Use"); + ysr8_ProjectContent.setName("ysr8_ProjectContent"); + ysr8_FixtrueCount.setName("ysr8_FixtrueCount"); + ysr8_AttachCount.setName("ysr8_AttachCount"); + ysr8_GuidCount.setName("ysr8_GuidCount"); + ysr8_JigCount.setName("ysr8_JigCount"); + ysr8_PositionerCount.setName("ysr8_PositionerCount"); + ysr8_RobotCount.setName("ysr8_RobotCount"); + ysr8_RobotModel.setName("ysr8_RobotModel"); + ysr8_ReceiveDate.setName("ysr8_ReceiveDate"); + ysr8_SaleStartDate.setName("ysr8_SaleStartDate"); + ysr8_StartDate.setName("ysr8_StartDate"); + ysr8_ContractDate.setName("ysr8_ContractDate"); + ysr8_ActualFactoryDate.setName("ysr8_ActualFactoryDate"); + ysr8_PlanDeliveryDate.setName("ysr8_PlanDeliveryDate"); + ysr8_ActualDeliveryDate.setName("ysr8_ActualDeliveryDate"); + ysr8_ProductionDate.setName("ysr8_ProductionDate"); + ysr8_PlanAcceptance.setName("ysr8_PlanAcceptance"); + ysr8_FinalAcceptance.setName("ysr8_FinalAcceptance"); + + ysr8_ProjectManager.setName("ysr8_ProjectManager"); + ysr8_Planner.setName("ysr8_Planner"); + // HUBING 20180615 + ysr8_DesignDirector.setName("ysr8_DesignDirector"); + ysr8_ElectricDirector.setName("ysr8_ElectricDirector"); + ysr8_Purcher.setName("ysr8_Purcher"); + ysr8_Machiner.setName("ysr8_Machiner"); + ysr8_EngineerDebug.setName("ysr8_EngineerDebug"); + ysr8_ElecDebug.setName("ysr8_ElecDebug"); + ysr8_Sales.setName("ysr8_Sales"); + + allComponents.add(dateUpdateTime); + allComponents.add(ysr8_QuotationNo); + allComponents.add(ysr8_ProjectCode); + allComponents.add(ysr8_ProjectName); + allComponents.add(ysr8_OrderManufacturer); + allComponents.add(ysr8_CustomerName); + allComponents.add(ysr8_ProjectCategory); + allComponents.add(ysr8_Factory); + allComponents.add(ysr8_Product); + allComponents.add(ysr8_Use); + allComponents.add(ysr8_ProjectContent); + allComponents.add(ysr8_FixtrueCount); + allComponents.add(ysr8_AttachCount); + allComponents.add(ysr8_GuidCount); + allComponents.add(ysr8_JigCount); + allComponents.add(ysr8_PositionerCount); + allComponents.add(ysr8_RobotCount); + allComponents.add(ysr8_RobotModel); + allComponents.add(ysr8_ReceiveDate); + allComponents.add(ysr8_SaleStartDate); + allComponents.add(ysr8_StartDate); + allComponents.add(ysr8_ContractDate); + allComponents.add(ysr8_ActualFactoryDate); + allComponents.add(ysr8_PlanDeliveryDate); + allComponents.add(ysr8_ActualDeliveryDate); + allComponents.add(ysr8_ProductionDate); + allComponents.add(ysr8_PlanAcceptance); + allComponents.add(ysr8_FinalAcceptance); + allComponents.add(ysr8_ProjectManager); + allComponents.add(ysr8_Planner); + // HUBING 20180615 + allComponents.add(ysr8_DesignDirector); + allComponents.add(ysr8_ElectricDirector); + allComponents.add(ysr8_Purcher); + allComponents.add(ysr8_Machiner); + allComponents.add(ysr8_EngineerDebug); + allComponents.add(ysr8_ElecDebug); + allComponents.add(ysr8_Sales); + } + + /** + * getSchedule:: ݱȡʱ + */ + private void getSchedule() { + try { + AIFComponentContext[] context = ysr8ProjectForm.whereReferenced(); + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent() instanceof TCComponentSchedule) { + schedule = (TCComponentSchedule) context[i].getComponent(); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * getScheduleMilestone:: ȡĿ̱͹ؼ + */ + private void getScheduleTasks() { + if (schedule == null) { + return; + } + try { + TCUserService service = session.getUserService(); + Object[] parameters = new Object[] { schedule }; + + long startime = System.currentTimeMillis(); + Object getScheduleTasks = service.call("Get_Schedule_Tasks", parameters); + if (getScheduleTasks == null) { + return; + } + Object taskproperties[] = (Object[]) getScheduleTasks; + // Object taskproperties[] = (Object[]) + // service.call("Get_Schedule_Tasks", parameters); + + int iTotalMaxLen = taskproperties.length; + + // ̱ + int iMilestonMaxLen = Integer.parseInt(taskproperties[iTotalMaxLen - 1].toString()); + + arrMilestoneTaskProp = new String[iMilestonMaxLen]; + + for (int i = 0; i < iMilestonMaxLen; i++) { + arrMilestoneTaskProp[i] = taskproperties[i].toString(); + } + if (iMilestonMaxLen != (iTotalMaxLen - 1)) { + arrKeyTaskProp = new String[iTotalMaxLen - 1 - iMilestonMaxLen]; + for (int i = iMilestonMaxLen; i < iTotalMaxLen - 1; i++) { + arrKeyTaskProp[i - iMilestonMaxLen] = taskproperties[i].toString(); + } + } + long lendTime = System.currentTimeMillis(); + System.out.println("Cȡʱԣʱ" + (lendTime - startime) + ""); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * getMilestoneTaskInfo::ȡĿ̱Ϣ + */ + private void getMilestoneTaskInfo() { + try { + Object[] objData; + for (int i = 0; arrMilestoneTaskProp != null && i < arrMilestoneTaskProp.length; i++) { + String strProperty = arrMilestoneTaskProp[i]; + String[] arrProperties = strProperty.split("&&"); + + // + String strTaskName = arrProperties[0]; + // ƻʱ + Date dtFinish = null; + String strFinishDate = arrProperties[2].equals("N/A") ? "" : arrProperties[2]; + if (!strFinishDate.equals("")) { + dtFinish = format.parse(strFinishDate); + } + + // ʵʱ + Date dtActualFinish = null; + String strActualFinishDate = arrProperties[3].equals("N/A") ? "" : arrProperties[3]; + if (!strActualFinishDate.equals("")) { + dtActualFinish = format.parse(strActualFinishDate); + } + + // + String strDesc = arrProperties[1].equals("N/A") ? "" : arrProperties[1]; + + // + String strPerfor = ""; + long day = 0; + if (strActualFinishDate != "") { + if (dtFinish.after(dtActualFinish)) { + day = UtilApi.getDaysBetween(dtActualFinish, dtFinish); + if (day == 0) { + strPerfor = "׼ʱ"; + } else { + strPerfor = "ǰ"; + } + } else { + day = UtilApi.getDaysBetween(dtFinish, dtActualFinish); + if (day == 0) { + strPerfor = "׼ʱ"; + } else { + day = (-1) * day; + strPerfor = ""; + } + } + } else { + Date nowDate = new Date(); + if (dtFinish.after(nowDate)) { + day = UtilApi.getDaysBetween(nowDate, dtFinish); + if (day == 0) { + strPerfor = ""; + } else if (day <= 15) { + strPerfor = "ڷ"; + } else { + strPerfor = ""; + } + } else { + day = UtilApi.getDaysBetween(dtFinish, nowDate); + strPerfor = ""; + if (day != 0) { + day = (-1) * day; + } + } + } + + // ʱ + String strCountdown = "0"; + if (day != 0) { + strCountdown = day + ""; + } + objData = new Object[] { strTaskName, strPerfor, strCountdown, strFinishDate, strActualFinishDate, strDesc }; + modMilestone.addRow(objData); + } + } catch (ParseException e) { + e.printStackTrace(); + } + } + + /** + * getKeyTaskInfo::ȡĿؼϢ + */ + private void getKeyTaskInfo() { + Object[] objData; + for (int i = 0; arrKeyTaskProp != null && i < arrKeyTaskProp.length; i++) { + String strProperty = arrKeyTaskProp[i]; + String[] arrProperties = strProperty.split("&&"); + + // Ŀ + String strTaskName = arrProperties[0]; + + // ״̬ + String strTaskStatus = arrProperties[2]; + + // + String strDesc = arrProperties[1].equals("N/A") ? "" : arrProperties[1]; + + // ƻʼʱ + String strStartDate = arrProperties[3].equals("N/A") ? "" : arrProperties[3]; + + // ƻʱ + String strFinishDate = arrProperties[5].equals("N/A") ? "" : arrProperties[5]; + + // ʵʿʼʱ + String strActualStartDate = arrProperties[4].equals("N/A") ? "" : arrProperties[4]; + + // ʵʱ + String strActualFinishDate = arrProperties[6].equals("N/A") ? "" : arrProperties[6]; + + // + String strPerfor = ""; + + Date dtActualFinish = null; + Date dtFinish = null; + try { + if (!strActualFinishDate.equals("")) { + dtActualFinish = format.parse(strActualFinishDate); + } + if (!strFinishDate.equals("")) { + dtFinish = format.parse(strFinishDate); + } + } catch (ParseException e) { + e.printStackTrace(); + } + + long day = 0; + Date nowDate = new Date(); + if (dtActualFinish != null) {// + if (dtFinish.after(dtActualFinish)) { + day = UtilApi.getDaysBetween(dtActualFinish, dtFinish); + if (day == 0) { + strPerfor = "׼ʱ"; + } else { + strPerfor = "ǰ"; + } + } else { + day = UtilApi.getDaysBetween(dtFinish, dtActualFinish); + if (day == 0) { + strPerfor = "׼ʱ"; + } else { + day = (-1) * day; + strPerfor = ""; + } + } + } else {// δ + if (dtFinish.after(nowDate)) { + day = UtilApi.getDaysBetween(nowDate, dtFinish); + if (day == 0) { + strPerfor = ""; + } else if (day <= 15) { + strPerfor = "ڷ"; + } else { + strPerfor = ""; + } + } else { + day = UtilApi.getDaysBetween(dtFinish, nowDate); + strPerfor = ""; + if (day != 0) { + day = (-1) * day; + } + } + } + + // ʱ + String strCountDown = "0"; + if (day != 0) { + strCountDown = day + ""; + } + + objData = new Object[] { strTaskName, strPerfor, strCountDown, strTaskStatus, strDesc, strStartDate, strFinishDate, strActualStartDate, strActualFinishDate }; + modKeyTasks.addRow(objData); + } + } + + /** + * checkPrivilege:: 鵱ǰûǷĿԱӡƳĿԱ + * + * @return boolean ǷȨ + */ + private boolean checkPrivilege() { + if (!vtProjectAdmin.contains(session.getUser())) { + MessageBox.post("ĿԱûȨ޹ĿԱ", "", MessageBox.WARNING); + return false; + } + return true; + } + + /** + * loadProjectMember:: ĿԱϢ + */ + private void loadProjectMember() { + try { + if (schedule == null) { + return; + } + + hmUserRole = new HashMap(); + + vtProjectAdmin = new Vector(); + vtProjectMembers = new Vector(); + vtPrivilegedUsers = new Vector(); + List oldvtUser = null; + + TCComponent[] comps = schedule.getReferenceListProperty("project_list"); + if (comps != null && comps.length > 0) { + projectComp = (TCComponentProject) comps[0]; + } + if (projectComp == null) { + return; + } + oldvtUser = projectComp.getTeam(); + // (TCComponentUser[])projectComp.getTeam().get(1) + // System.out.println("oldvtUser = " + oldvtUser); + + TCComponent[] teamMembers = (TCComponent[]) oldvtUser.get(0); + TCComponentUser[] teamAdmin = (TCComponentUser[]) oldvtUser.get(1); + TCComponentUser[] privilegedUsers = (TCComponentUser[]) oldvtUser.get(2); + + for (int ix = 0; ix < teamAdmin.length; ix++) + vtProjectAdmin.add(teamAdmin[ix]); + + for (int ix = 0; ix < privilegedUsers.length; ix++) + vtPrivilegedUsers.add(privilegedUsers[ix]); + + for (int j = 0; j < teamMembers.length; j++) { + TCComponent compUser = teamMembers[j]; + // System.out.println("j = " + j + ":: compUser = " + compUser); + TCComponentUser user = null; + if (compUser instanceof TCComponentGroupMember) { + TCComponentGroupMember tmpGroupMember = (TCComponentGroupMember) compUser; + try { + user = tmpGroupMember.getUser(); + } catch (TCException e) { + e.printStackTrace(); + } + if (vtProjectMembers.contains(tmpGroupMember)) { + continue; + } + vtProjectMembers.add(tmpGroupMember); + hmUserRole.put(user, compUser.toString()); + } else if (compUser instanceof TCComponentGroup) { + TCComponentGroup group = (TCComponentGroup) compUser; + getGroup(group, false); + } + // else if (compUser instanceof TCComponentUser) { + // user = (TCComponentUser) compUser; + // if (vtProjectMembers.contains(user)) { + // continue; + // } + // vtProjectMembers.add(user); + // hmUserRole.put(user, compUser.toString()); + // } + } + + Object[] objData; + for (int i = 0; vtProjectAdmin != null && i < vtProjectAdmin.size(); i++) { + TCComponentUser user = vtProjectAdmin.get(i); + // System.out.println("user = " + user); + String strRoleName = "Ŀ"; + String strGroupName = hmUserRole.get(user); + if (strGroupName == null) { + continue; + } + System.out.println("i = " + i + ":: strGroupName = " + strGroupName); + strGroupName = strGroupName.substring(0, strGroupName.lastIndexOf("/")); + strGroupName = strGroupName.replace(".", "/"); + + String strUserName = user.getProperty("user_name"); + String strPhone = user.getReferenceProperty("person").getProperty("PA10"); + objData = new Object[] { strRoleName, strGroupName, strUserName, strPhone }; + modMembers.addRow(objData); + } + + for (int i = 0; vtProjectMembers != null && i < vtProjectMembers.size(); i++) { + TCComponentUser user = vtProjectMembers.get(i).getUser(); + if (vtProjectAdmin.contains(user)) { + continue; + } + String strRoleName = "ĿԱ"; + String strGroupName = ""; + strGroupName = hmUserRole.get(user); + strGroupName = strGroupName.substring(0, strGroupName.lastIndexOf("/")); + strGroupName = strGroupName.replace(".", "/"); + + String strUserName = user.getProperty("user_name"); + String strPhone = user.getReferenceProperty("person").getProperty("PA10"); + + objData = new Object[] { strRoleName, strGroupName, strUserName, strPhone }; + modMembers.addRow(objData); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * getGroup::õUser + * + * @param TCComponentGroup + * group + */ + private void getGroup(TCComponentGroup group, boolean isAdmin) { + try { + TCComponent[] comprolegroup = group.getRolesAndGroups(); + for (int i = 0; i < comprolegroup.length; i++) { + TCComponent tccomponent = comprolegroup[i]; + if (tccomponent instanceof TCComponentRole) { + getRole((TCComponentRole) tccomponent, group, isAdmin); + continue; + } + if (tccomponent instanceof TCComponentGroup) { + getGroup((TCComponentGroup) tccomponent, isAdmin); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * getRole::roleõUser + * + * @param TCComponentRole + * @param TCComponentGroup + */ + private void getRole(TCComponentRole tccomponentrole, TCComponentGroup tccomponentgroup, boolean isAdmin) { + try { + TCComponentGroupMember atccomponentgroupmember[] = tccomponentrole.getGroupMembers(tccomponentgroup); + for (int i = 0; i < atccomponentgroupmember.length; i++) { + TCComponentUser user = atccomponentgroupmember[i].getUser(); + + if (!isAdmin) { + if (vtProjectMembers.contains(atccomponentgroupmember[i])) { + continue; + } + vtProjectMembers.add(atccomponentgroupmember[i]); + } + hmUserRole.put(user, atccomponentgroupmember[i].toString()); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * AddMember:: Ա + */ + private void AddMember() { + OrgTreePanel org = new OrgTreePanel(session); + final OrganizationTree orgTree = org.getOrgTree(); + orgTree.addMouseListener(new MouseAdapter() { + + public void mouseClicked(MouseEvent mouseevent) { + if (mouseevent.getClickCount() == 2) { + if (orgTree.getSelectedNode() != null && orgTree.getSelectedNode().isLeaf()) { + + String strUserInfo = orgTree.getSelectedNode().getUserObject().toString(); + System.out.println("strUserInfo = " + strUserInfo); + String strGroupName = ""; + String strRoleName = ""; + String strUserName = ""; + if (strUserInfo.contains("/")) { + strGroupName = strUserInfo.substring(0, strUserInfo.lastIndexOf("/")); + strGroupName = strGroupName.replace(".", "/"); + strUserName = strUserInfo.substring(strUserInfo.lastIndexOf("/") + 1); + } else { + Object[] obj = orgTree.getSelectedNode().getUserObjectPath(); + int objLen = obj.length - 2; + for (int i = 1; i < objLen; i++) { + if (strGroupName.length() == 0) { + strGroupName = obj[i].toString(); + } else { + strGroupName = strGroupName + "/" + obj[i]; + } + } + strRoleName = obj[obj.length - 2].toString(); + strUserName = obj[obj.length - 1].toString(); + strUserName = strUserName.substring(0, strUserName.indexOf("(")).trim(); + } + + String strPhone = ""; + try { + String[] attr = new String[1]; + String[] values = new String[1]; + attr[0] = "PersonName"; + values[0] = strUserName; + TCComponent[] comp = UtilApi.searchComponentCollection(session, "__Cust_findUser", attr, values); + TCComponentUser userComp = null; + if (comp != null && comp.length > 0) { + userComp = (TCComponentUser) comp[0]; + strPhone = userComp.getReferenceProperty("person").getProperty("PA10"); + if (!vtProjectMembers.contains(userComp)) { + Object[] objData = new Object[] { "ĿԱ", strGroupName + "/" + strRoleName, strUserName, strPhone }; + modMembers.addRow(objData); + comp = UtilApi.searchComponentCollection(session, "__Cust_GroupMember", new String[] { "user_name", "Group", "Role" }, + new String[] { strUserName, strGroupName, strRoleName }); + if (comp != null && comp.length > 0) { + vtProjectMembers.add((TCComponentGroupMember) comp[0]); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + dlg.setVisible(false); + dlg = null; + } + } + } + }); + + Point point = tblProjectMembers.getLocationOnScreen(); + dlg = new JDialog(); + dlg.setTitle("ѡԱ"); + dlg.add(org); + dlg.setLocation(point.x + 50, point.y - 50); + dlg.setPreferredSize(new Dimension(300, 400)); + dlg.pack(); + dlg.setVisible(true); + } + + /** + * removeMember:: ƳԱ + */ + private void removeMember() { + try { + int[] rows = tblProjectMembers.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.WARNING); + return; + } + + for (int i = 0; i < rows.length; i++) { + String strRoleName = tblProjectMembers.getValueAt(rows[i], 0).toString(); + String strUserName = tblProjectMembers.getValueAt(rows[i], 2).toString(); + if (strRoleName.equals("Ŀ")) { + vtProjectAdmin.remove(rows[i]); + } else if (strRoleName.equals("ĿԱ")) { + for (int j = vtProjectMembers.size() - 1; j >= 0; j--) { + if (vtProjectMembers.get(j).getProperty("user_name").equals(strUserName)) { + vtProjectMembers.remove(j); + } + } + } + modMembers.removeRow(rows[i]); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * updateProjectMember::Ŀû + */ + private void updateProjectMember() { + if (vtProjectMembers == null || vtProjectMembers.size() == 0) { + return; + } + TCComponent[] comp = new TCComponent[vtProjectMembers.size()]; + vtProjectMembers.toArray(comp); + // TCComponentUser[] privilegedUsers = new TCComponentUser[comp.length]; + + // for (int j = 0; j < comp.length; j++) { + // if (comp[j] instanceof TCComponentGroupMember) { + // TCComponentGroupMember tmpGroupMember = (TCComponentGroupMember) + // comp[j]; + // try { + // privilegedUsers[j] = tmpGroupMember.getUser(); + // } catch (TCException e) { + // privilegedUsers[j] = null; + // e.printStackTrace(); + // } + // } else { + // privilegedUsers[j] = (TCComponentUser) comp[j]; + // } + // } + try { + projectComp.modifyTeam(comp, vtProjectAdmin.toArray(new TCComponentUser[vtProjectAdmin.size()]), vtPrivilegedUsers.toArray(new TCComponentUser[vtPrivilegedUsers.size()])); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("deprecation") + private DateButton newDateButton() { + DateButton db = new PropertyDateButton() { + + private static final long serialVersionUID = 1L; + + @Override + public void setEnabled(boolean f) { + super.setEnabled(false); + } + }; + return db; + } + + /** + * clearData::е + */ + private void clearData() { + for (int row = tblProjectKeyTasks.getRowCount() - 1; row >= 0; row--) { + modKeyTasks.removeRow(row); + } + for (int row = tblProjectMembers.getRowCount() - 1; row >= 0; row--) { + modMembers.removeRow(row); + } + for (int row = tblProjectMilestone.getRowCount() - 1; row >= 0; row--) { + modMilestone.removeRow(row); + } + arrMilestoneTaskProp = null; + arrKeyTaskProp = null; + } + + /** + * getBasicInfo::Ŀ֪ͨ汾ȡϢ + * + * @return boolean + **/ + @SuppressWarnings("deprecation") + private boolean getBasicInfo() { + System.out.println("--Ŀ֪ͨ汾ȡϢ--Start"); + try { + if (schedule == null) { + MessageBox.post("ݸñδҵʱ飡", "", MessageBox.WARNING); + return false; + } + // String strScheduleName = schedule.getProperty("object_name"); + // if (strScheduleName.contains("") && + // strScheduleName.contains("")) { + // strProjectNum = + // strScheduleName.substring(strScheduleName.indexOf("") + 1, + // strScheduleName.indexOf("")); + // } + // + // String[] attr = new String[1]; + // String[] values = new String[1]; + // TCTextService textService = session.getTextService(); + // attr[0] = textService.getTextValue("ProjectID"); + // values[0] = strProjectNum; + // + // TCComponent[] components = + // UtilApi.searchComponentCollection(session, "Projects...", attr, + // values); + // if (components == null || components.length == 0) { + // MessageBox.post("δǰĿŵĿ", "ʾ", MessageBox.WARNING); + // return false; + // } + // + // // ȡʱָɵĿ + // TCComponent[] comps = + // schedule.getReferenceListProperty("project_list"); + // if (comps != null && comps.length > 0) { + // for (int i = 0; i < comps.length; i++) { + // if (comps[i] instanceof TCComponentProject + // && comps[i].getProperty("project_id").equals(strProjectNum)) { + // projectComp = (TCComponentProject) comps[i]; + // break; + // } + // } + // } + if (projectComp == null) { + MessageBox.post("ĿδָɵʱУ޷ȡϢ", "ʾ", MessageBox.WARNING); + return false; + } + + // ȡĿ + String strProjectNum = projectComp.getProperty("project_id"); + // ֵ + String strDocId = new StringBuffer(strProjectNum).append("_XMQD").toString(); + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem docItem = itemType.find(strDocId); + TCComponentForm docForm = null; + if (docItem != null) { + AIFComponentContext[] context = docItem.getLatestItemRevision().getRelated("IMAN_master_form_rev"); + if (context != null && context.length > 0) { + for (int index = 0; index < context.length; index++) { + if (context[index].getComponent() instanceof TCComponentForm) { + docForm = (TCComponentForm) context[index].getComponent(); + break; + } + } + } + } + + if (docForm == null) { + MessageBox.post("δȡĿ֪ͨ޷ȡϢ", "ʾ", MessageBox.WARNING); + return false; + } else { + ysr8_QuotationNo.setText(docForm.getProperty("ysr8_QuotationNo")); + ysr8_ProjectCode.setText(docForm.getProperty("ysr8_ProjectCode")); + ysr8_ProjectName.setText(docForm.getProperty("ysr8_ProjectName")); + ysr8_OrderManufacturer.setText(docForm.getProperty("ysr8_OrderManufacturer")); + ysr8_CustomerName.setText(docForm.getProperty("ysr8_CustomerName")); + ysr8_ProjectCategory.setText(docForm.getProperty("ysr8_ProjectCategory")); + ysr8_Factory.setText(docForm.getProperty("ysr8_Factory")); + ysr8_Product.setText(docForm.getProperty("ysr8_Product")); + ysr8_Use.setText(docForm.getProperty("ysr8_Use")); + ysr8_ProjectContent.setText(docForm.getProperty("ysr8_ProjectContent")); + + ysr8_Sales.setText(docForm.getProperty("ysr8_Sales")); + ysr8_ProjectManager.setText(docForm.getProperty("ysr8_ProjectManager")); + ysr8_Planner.setText(docForm.getProperty("ysr8_Planner")); + // HUBING 20180615 + ysr8_DesignDirector.setText(docForm.getProperty("ysr8_DesignDirector")); + ysr8_ElectricDirector.setText(docForm.getProperty("ysr8_ElectricDirector")); + + ysr8_ReceiveDate.setDate(docForm.getDateProperty("ysr8_ReceiveDate")); + ysr8_StartDate.setDate(docForm.getDateProperty("ysr8_StartDate")); + ysr8_ProductionDate.setDate(docForm.getDateProperty("ysr8_ProductionDate")); + ysr8_PlanAcceptance.setDate(docForm.getDateProperty("ysr8_FinalAcceptance")); + } + } catch (TCException e) { + // Auto-generated constructor stub + e.printStackTrace(); + } + System.out.println("--Ŀ֪ͨ汾ȡϢ--End"); + return true; + } +} diff --git a/src/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster.java b/src/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster.java new file mode 100644 index 0000000..4a4aa9f --- /dev/null +++ b/src/cn/com/teamcenter/rac/form/YSR8_QuotationRevisionMaster.java @@ -0,0 +1,1211 @@ +package cn.com.teamcenter.rac.form; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileWriter; +import java.net.URI; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.LinkedHashMap; +import java.util.Vector; +import java.util.logging.Logger; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JViewport; +import javax.swing.table.JTableHeader; +import javax.swing.text.JTextComponent; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.common.lov.LOVComboBox; +import com.teamcenter.rac.conditionalproperties.FormFieldManager; +import com.teamcenter.rac.conditionalproperties.WidgetTypeAdapter; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.stylesheet.AbstractPropertyComponent; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.stylesheet.InterfacePropertyComponent; +import com.teamcenter.rac.stylesheet.InterfaceRendererEvent; +import com.teamcenter.rac.stylesheet.PropertyArray; +import com.teamcenter.rac.stylesheet.PropertyComment; +import com.teamcenter.rac.stylesheet.PropertyLogicalPanel; +import com.teamcenter.rac.stylesheet.PropertyObjectLink; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.iTextField; + +@SuppressWarnings("deprecation") +public class YSR8_QuotationRevisionMaster extends AbstractRendering { + + private static final long serialVersionUID = 1L; + + private TCSession session; + private iTextField ItemID; // + private iTextField ysr8_Sales; //۵ + private iTextField ysr8_OrderManufacturer; // + private iTextField ysr8_CustomerName; //û + private iTextField ysr8_QuotationLevel; //ˮƽ + private iTextField ysr8_Contact; //ϵ + private iTextField ysr8_ContactDept; // + private iTextField ysr8_ContactPosition; //ְ + private iTextField ysr8_ContactPhone; //ϵ绰 + + private DateButton ysr8_RequestedDate; //ϣ + private DateButton ysr8_SysPlanDate; //ʱ + + private iTextField ysr8_ProjectManager; //Ŀ +// private iTextField ysr8_ProjectLevel; //۵ȼ + private JComboBox ysr8_ProjectLevel; + private iTextField ysr8_Ratio; //ϵ + + private iTextField ysr8_SytemName; //ϵͳ +// private iTextField ysr8_ProjectDes; //״̬ + private JComboBox ysr8_QuotationStatus; //״̬ + private JComboBox ysr8_Product; //Ʒ + private JComboBox ysr8_use; //; + private DateButton ysr8_EstimatedDate; //Ԥʱ + private iTextField ysr8_Possibility; // + private DateButton ysr8_ReceiveDate; //ʱ + private DateButton ysr8_FinishedDate; //ʱ +// private DateButton date_released; //ʱ + private iTextField ysr8_OfferAmount; //۽ + private JTextArea ysr8_RobotModelAndNum; //ͺš + private JTextArea ysr8_QuotationRemarks; //ע + +// private JComboBox ysr8_QuotationState; //״̬//lidy20180925 +// private String[] ysr8_Qutation_LOV; +// private String[] ysr8_Qutation2_LOV; +// private String[] ysr8_QuotationStatus_lov; + private HashMap> lovMap = new HashMap<>(); +// private LinkedHashMap lovQuotation2; + + private JButton jBPM = new JButton("BPM۵"); + + TCComponentForm componentForm = null; + TCComponentItem componentItem = null; + private VectorallComponents = new Vector(); + private TCFormProperty[] formProperties; + private Hashtable indices = new Hashtable(); + + public YSR8_QuotationRevisionMaster(TCComponentForm componentForm) throws Exception { + super(componentForm); + this.componentForm = componentForm; + this.session = componentForm.getSession(); + String formName = componentForm.getProperty("object_name"); + try { + TCComponentItemType imancomponentitemtype = (TCComponentItemType) session.getTypeService().getTypeComponent("Item"); + componentItem = imancomponentitemtype.find(formName.substring(0, formName.length()-2)); +// System.out.println(formName.substring(0, formName.length()-2)); + } catch (TCException e) { + e.printStackTrace(); + } + addUIComponents(); + initUI(); + setName(); + loadRendering(); + } + + private void initUI() { + + JPanel paneMain = new JPanel(new GridBagLayout()); + + JPanel paneTop = new JPanel(new GridBagLayout()); + paneTop.setBorder(BorderFactory.createTitledBorder("Ϣ")); + GridBagConstraints g4 = new GridBagConstraints(); + g4.insets = new Insets(5, 5, 5, 5); + g4.anchor = GridBagConstraints.WEST; + g4.fill = GridBagConstraints.HORIZONTAL; + + g4.gridx = 0; + g4.gridy = 0; + g4.gridwidth=1; + paneTop.add(new JLabel(":"), g4); + + g4.gridx = 1; + g4.gridy = 0; + g4.gridwidth=3; + paneTop.add(ItemID, g4); + + g4.gridx = 4; + g4.gridy = 0; + g4.gridwidth=1; + paneTop.add(new JLabel("۵:"), g4); + + g4.gridx = 5; + g4.gridy = 0; + g4.gridwidth=3; + paneTop.add(ysr8_Sales, g4); + + g4.gridx=6; + g4.weightx=1; + paneTop.add(new JLabel(""),g4); + g4.weightx=0; + + g4.gridx = 0; + g4.gridy = 1; + g4.gridwidth=1; + paneTop.add(new JLabel(":"), g4); + + g4.gridx = 1; + g4.gridy = 1; + g4.gridwidth=3; + paneTop.add(ysr8_OrderManufacturer, g4); + + g4.gridx = 4; + g4.gridy = 1; + g4.gridwidth=1; + paneTop.add(new JLabel("û:"), g4); + + g4.gridx = 5; + g4.gridy = 1; + g4.gridwidth=3; + paneTop.add(ysr8_CustomerName, g4); + + g4.gridx = 0; + g4.gridy = 2; + g4.gridwidth=1; + paneTop.add(new JLabel("ˮƽ:"), g4); + + g4.gridx = 1; + g4.gridy = 2; + g4.gridwidth=1; + paneTop.add(ysr8_QuotationLevel, g4); + + g4.gridx = 2; + g4.gridy = 2; + g4.gridwidth=2; + paneTop.add(new JLabel("(ϸԣο)"), g4); + + g4.gridx = 4; + g4.gridy = 2; + g4.gridwidth=1; + paneTop.add(new JLabel("ʱ:"), g4);// + + g4.gridx = 5; + g4.gridwidth=1; + paneTop.add(ysr8_ReceiveDate, g4); + + g4.gridx = 6; + g4.gridy = 2; + g4.gridwidth=1; + paneTop.add(new JLabel("ϣ:"), g4); + + g4.gridx = 7; + g4.gridy = 2; + g4.gridwidth=1; + paneTop.add(ysr8_RequestedDate, g4); + + g4.gridx = 0; + g4.gridy = 3; + g4.gridwidth=1; + paneTop.add(new JLabel("ϵ:"), g4); + + g4.gridx = 1; + g4.gridy = 3; + g4.gridwidth=1; + paneTop.add(ysr8_Contact, g4); + + g4.gridx = 2; + g4.gridy = 3; + g4.gridwidth=1; + paneTop.add(new JLabel(":"), g4); + + g4.gridx = 3; + g4.gridy = 3; + paneTop.add(ysr8_ContactDept, g4); + + g4.gridx = 4; + g4.gridy = 3; + g4.gridwidth=1; + paneTop.add(new JLabel("ְ:"), g4); + + g4.gridx = 5; + g4.gridy = 3; + g4.gridwidth=1; + paneTop.add(ysr8_ContactPosition, g4); + + g4.gridx = 6; + g4.gridy = 3; + paneTop.add(new JLabel("ϵ绰:"), g4); + + g4.gridx = 7; + g4.gridy = 3; + g4.gridwidth=1; + paneTop.add(ysr8_ContactPhone, g4); + + JPanel paneCenter = new JPanel(new GridBagLayout()); + paneCenter.setBorder(BorderFactory.createTitledBorder("ϵͳƿƳд")); + g4.gridx=0; + g4.gridy=0; + g4.gridwidth=1; + paneCenter.add(new JLabel("Ŀ:"),g4); + g4.gridx=1; + g4.gridwidth=2; + paneCenter.add(ysr8_ProjectManager,g4); + g4.gridwidth=1; + g4.gridx=3; + JButton pmButton = new JButton("..."); + pmButton.setPreferredSize(new Dimension(30, 20)); + paneCenter.add(pmButton,g4); + g4.gridwidth=1; + g4.gridx=4; + paneCenter.add(new JLabel("ʱ(ϵͳ):"),g4); + g4.gridwidth=1; + g4.gridx=5; + paneCenter.add( ysr8_SysPlanDate,g4); + g4.gridx=6; + g4.gridwidth=2; + paneCenter.add(new JLabel(""),g4); +// g4.gridx=6; +// paneCenter.add(new JLabel(""),g4); + + g4.gridx=7; + g4.weightx=1; + g4.gridwidth=1; + paneCenter.add(new JLabel(""),g4); + + g4.gridy=1; + g4.gridx=0; + paneCenter.add(new JLabel("۵ȼ:"),g4); + g4.gridx=1; + g4.gridwidth=3; + paneCenter.add(ysr8_ProjectLevel,g4); + g4.gridwidth=1; + g4.gridx=4; + paneCenter.add(new JLabel("ϵ:"),g4); + g4.gridx=5; + paneCenter.add(ysr8_Ratio,g4); + g4.gridx=6;// + paneCenter.add(new JLabel(""),g4); +// g4.gridx=6; +// paneCenter.add( ysr8_QuotationState,g4); + + final GCSelectionUserCommand selectionUserCmd = new GCSelectionUserCommand(AIFUtility.getCurrentApplication().getDesktop(), session); + pmButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + selectionUserCmd.setContextBean(ysr8_ProjectManager); + try { +// dialog.setVisible(false); + selectionUserCmd.executeModal(); +// dialog.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); +// JPanel paneCenter = new JPanel(new GridBagLayout()); +// paneCenter.setBorder(BorderFactory.createTitledBorder(" ")); +// GridBagConstraints g3 = new GridBagConstraints(); +// g3.insets = new Insets(5, 5, 5, 5); +// g3.anchor = GridBagConstraints.WEST; +// g3.fill = GridBagConstraints.HORIZONTAL; +// +// g3.gridx = 0; +// g3.gridy = 0; +// g4.gridwidth=1; +// paneCenter.add(new JLabel("Ŀ:"), g3); +// +// g3.gridx = 1; +// g3.gridy = 0; +// g3.gridwidth=3; +//// paneCenter.add(ysr8_ProjectManager, g3); +// +// JPanel panelPM = new JPanel(new GridBagLayout()); +// GridBagConstraints g16 = new GridBagConstraints(); +// g16.insets = new Insets(0, 5, 0, 5); +// g16.anchor = GridBagConstraints.WEST; +// g16.fill = GridBagConstraints.HORIZONTAL; +// g16.gridx = 0; +// g16.gridy = 0; +// g16.gridwidth=2; +// panelPM.add(ysr8_ProjectManager, g16); +// g16.gridx = 1; +// g16.gridy = 0; +// g16.gridwidth=1; +// JButton iconLabel6 = new JButton("..."); +// panelPM.add(iconLabel6, g16); +// paneCenter.add(panelPM, g3); +// +// g3.gridx = 0; +// g3.gridy = 1; +// g4.gridwidth=1; +// paneCenter.add(new JLabel("۵ȼ:"), g3); +// +// g3.gridx = 1; +// g3.gridy = 1; +// g3.gridwidth=2; +// paneCenter.add(ysr8_ProjectLevel, g3); +// +// g3.gridx = 3; +// g3.gridy = 1; +// g4.gridwidth=1; +// paneCenter.add(new JLabel("ʱ(ϵͳ):"), g3); +// +// g3.gridx = 4; +// g3.gridy = 1; +// g4.gridwidth=1; +// paneCenter.add(ysr8_SysPlanDate, g3); + + JPanel panelBotton = new JPanel(new GridBagLayout()); + panelBotton.setBorder(BorderFactory.createTitledBorder("Ŀд")); + GridBagConstraints g2 = new GridBagConstraints(); + g2.insets = new Insets(5, 5, 5, 5); + g2.anchor = GridBagConstraints.WEST; + g2.fill = GridBagConstraints.HORIZONTAL; + + g2.gridy = 0; + g2.gridx = 0; + g2.gridwidth=1; + panelBotton.add(new JLabel("ϵͳ:"), g2); + + g2.gridx = 1; + g2.gridwidth=3; + panelBotton.add(ysr8_SytemName, g2); + + g2.gridx = 4; + g2.gridwidth=1; +// panelBotton.add(new JLabel("״̬:"), g2);//ysr8_EstimatedDate + panelBotton.add(new JLabel("ͺš:"), g2); + + + g2.gridx = 5; + g2.gridwidth=6; + g2.gridheight=3; + panelBotton.add(ysr8_RobotModelAndNum, g2); +// panelBotton.add(ysr8_QuotationStatus, g2); + + g2.gridx=6; + g2.weightx=1; + panelBotton.add(new JLabel(""),g2); + g2.weightx=0; + +// g2.gridy = 1; +// g2.gridx = 0; +// g2.gridwidth=1; +// panelBotton.add(new JLabel("ʱ:"), g2);// +// +// g2.gridx = 1; +// g2.gridwidth=1; +// panelBotton.add(ysr8_ReceiveDate, g2); + + g2.gridy = 1; + g2.gridx = 0; + g2.gridwidth=1; + g2.gridheight=1; +// panelBotton.add(new JLabel("ʱ:"), g2); + panelBotton.add(new JLabel("״̬:"), g2); + + g2.gridx = 1; + g2.gridwidth=3; +// panelBotton.add(ysr8_FinishedDate, g2); + panelBotton.add(ysr8_QuotationStatus, g2); +// g2.gridx = 4; +// g2.gridwidth=1; +// panelBotton.add(new JLabel(" "), g2); +// g2.gridx = 5; +// g2.gridwidth=1; +// panelBotton.add(new JLabel(" "), g2); + + g2.gridy = 5; + g2.gridx = 0; + g2.gridwidth=1; + g2.gridheight=1; + panelBotton.add(new JLabel("Ʒ:"), g2); + + g2.gridx = 1; + g2.gridwidth=3; + panelBotton.add(ysr8_Product, g2); + + g2.gridx = 4; + g2.gridwidth=1; +// g2.gridheight=1; + panelBotton.add(new JLabel(";:"), g2); + + g2.gridx = 5; + g2.gridwidth=6; + panelBotton.add(ysr8_use, g2); + + g2.gridy = 6; + g2.gridx = 0; + g2.gridwidth=1; + panelBotton.add(new JLabel(":"), g2); + + g2.gridx = 1; + g2.gridwidth=2; + panelBotton.add(ysr8_Possibility, g2); + + g2.gridx = 3; + g2.gridwidth=1; + panelBotton.add(new JLabel("% "), g2); + g2.gridx = 4; + g2.gridwidth=1; + panelBotton.add(new JLabel("Ԥʱ:"), g2); + + g2.gridx = 5; + g2.gridwidth=6; + panelBotton.add(ysr8_EstimatedDate, g2); + + g2.gridy = 7; + g2.gridx = 0; + g2.gridwidth=1; + panelBotton.add(new JLabel("۽(RMB/Ԫ):"), g2); + + g2.gridx = 1; + g2.gridwidth=3; + panelBotton.add(ysr8_OfferAmount, g2); + + g2.gridx = 4; + g2.gridwidth=1; + panelBotton.add(new JLabel("ʱ:"), g2); + + g2.gridx = 5; + g2.gridwidth=6; + panelBotton.add(ysr8_FinishedDate, g2); +// panelBotton.setBackground(Color.WHITE); + + g2.gridy = 8; + g2.gridx = 0; + g2.gridwidth=1; + panelBotton.add(new JLabel("ע:"), g2);//TODO ע + + g2.gridx = 1; + g2.gridwidth=5; + g2.gridheight=2; + panelBotton.add(ysr8_QuotationRemarks, g2); + + + GridBagConstraints g = new GridBagConstraints(); + g.insets = new Insets(5, 5, 5, 5); + g.anchor = GridBagConstraints.WEST; + g.fill = GridBagConstraints.BOTH; + g.gridx=0; + g.gridy=0; + g.weightx=0; + g.weighty=0; + g.gridwidth=2; + paneMain.add( paneTop,g); + g.gridx=1; + g.weightx=1; + paneMain.add(new JLabel(""),g); + g.weightx=0; + + + g.gridx=0; + g.gridy++; + paneMain.add( paneCenter,g); + g.gridy++; + /*JSeparator jSep = new JSeparator(); + jSep.setOrientation(JSeparator.HORIZONTAL); + paneMain.add("3.1.left.center", jSep );*/ + paneMain.add( panelBotton,g); + g.gridy++; + g.gridwidth=1; + paneMain.add(jBPM,g); + g.gridy++; + g.weighty=1; + paneMain.add(new JLabel(""),g); + + jBPM.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent arg0) { + try { + final String urlStr = componentForm.getProperty("ysr8_BPMURL_BJWT"); + if(urlStr != null && !urlStr.equals("")){ +// String str = "cmd /c start iexplore "+urlStr; + try { + URI uri = new URI(urlStr); + Desktop.getDesktop().browse(uri); + } catch (Exception e) { + e.printStackTrace(); + } +// IWorkbenchWindow localIWorkbenchWindow = AIFUtility.getActiveDesktop().getDesktopWindow(); +// final IWorkbenchPage workbenchpage = localIWorkbenchWindow.getActivePage(); +// final BrowserView viewDK = (BrowserView)workbenchpage.findView("com.teamcenter.rac.aifrcp.BrowserView"); +// if(viewDK == null){ +// Display.getDefault().syncExec(new Runnable() { +// public void run() { +// try { +// ((BrowserView) workbenchpage.showView("com.teamcenter.rac.aifrcp.BrowserView")).setUrl(urlStr); +//// viewDK.setUrl(urlStr); +// } catch (PartInitException e) { +// e.printStackTrace(); +// } +// } +// }); +// }else{ +// Display.getDefault().syncExec(new Runnable() { +// +// @Override +// public void run() { +// viewDK.setUrl(urlStr); +// } +// +// }); +// } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + }); + + try { + AIFComponentContext[] YSR8_QuotationRevisions = componentForm.whereReferencedByTypeRelation(new String[] {"YSR8_QuotationRevision"}, new String[] {"IMAN_master_form"}); + if(YSR8_QuotationRevisions != null){ + ItemID.setText(YSR8_QuotationRevisions[0].getComponent().getProperty("item_id")); + } + } catch (TCException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + JScrollPane scPanel = new JScrollPane(); + scPanel.setViewportView(paneMain); + setLayout(new BorderLayout()); + add(BorderLayout.CENTER, scPanel); + + } + private void addUIComponents() { + + ItemID = new iTextField(); + ItemID.setEditable(false); + ItemID.setEnabled(false); + ysr8_Sales = new iTextField(); + ysr8_Sales.setEditable(false); + ysr8_Sales.setEnabled(false); + ysr8_OrderManufacturer = new iTextField(); + ysr8_OrderManufacturer.setEditable(false); + ysr8_OrderManufacturer.setEnabled(false); + ysr8_CustomerName = new iTextField(); + ysr8_CustomerName.setEditable(false); + ysr8_CustomerName.setEnabled(false); + ysr8_QuotationLevel = new iTextField(9); + ysr8_QuotationLevel.setEditable(false); + ysr8_QuotationLevel.setEnabled(false); + ysr8_Contact = new iTextField(); + ysr8_Contact.setEditable(false); + ysr8_Contact.setEnabled(false); + ysr8_ContactDept = new iTextField(9); + ysr8_ContactDept.setEditable(false); + ysr8_ContactDept.setEnabled(false); + ysr8_ContactPosition = new iTextField(); + ysr8_ContactPosition.setEditable(false); + ysr8_ContactPosition.setEnabled(false); + ysr8_ContactPhone = new iTextField(); + ysr8_ContactPhone.setEditable(false); + ysr8_ContactPhone.setEnabled(false); + + ysr8_ProjectManager = new iTextField(20); + ysr8_ProjectManager.setEditable(false); + ysr8_ProjectManager.setEnabled(false); + ysr8_Ratio = new iTextField(); + ysr8_Ratio.setEditable(true); + ysr8_Ratio.setEnabled(true); +// ysr8_ProjectLevel = new iTextField(40); + lovMap.put("ysr8_ProjectLevel", getLOV("ysr8_Qutation_LOV")); + String[] ysr8_Qutation_LOV = new String[lovMap.get("ysr8_ProjectLevel").size()]; + int i = 0; + for(String v : lovMap.get("ysr8_ProjectLevel").keySet()) { + ysr8_Qutation_LOV[i] = v; + i++; + } + ysr8_ProjectLevel = new JComboBox(ysr8_Qutation_LOV); + ysr8_ProjectLevel.setPreferredSize(new Dimension(233, 23)); +// lovMap.put("ysr8_ProjectLevel", getLOV("ysr8_Qutation_LOV")); + +// lovMap.put("ysr8_QuotationState", getLOV("ysr8_Qutation2_LOV")); +// ysr8_Qutation2_LOV = new String[lovMap.get("ysr8_QuotationState").size()]; +// i = 0; +// for(String v : lovMap.get("ysr8_QuotationState").values()) { +// ysr8_Qutation2_LOV[i] = v; +// i++; +// } +// ysr8_QuotationState = new JComboBox(ysr8_Qutation2_LOV); +// ysr8_QuotationState.setPreferredSize(new Dimension(100, 23)); + int g1 = 22; + ysr8_SytemName = new iTextField(g1); +// ysr8_SytemName.setBackground(Color.WHITE); + ysr8_EstimatedDate = new DateButton(null, "yyyy-MM-dd", false, false, false); + ysr8_Possibility = new iTextField(12); +// ysr8_Possibility.setBackground(Color.WHITE); +// ysr8_ProjectDes = new iTextField(31); + String[] ysr8_QuotationStatus_lov = session.getPreferenceService().getStringValues("ysr8_QuotationStatus_lov"); + String[] ysr8_QuotationStatus_lov1 = new String[ysr8_QuotationStatus_lov.length+1]; + ysr8_QuotationStatus_lov1[0] = ""; + for(int i1=1; i1(ysr8_QuotationStatus_lov1); + try { + String ysr8_QuotationStatusVal = componentForm.getProperty("ysr8_QuotationStatus"); + System.out.println("ysr8_QuotationStatusVal:"+ysr8_QuotationStatusVal); + ysr8_QuotationStatus.setSelectedItem(ysr8_QuotationStatusVal); + } catch (TCException e) { + e.printStackTrace(); + } + ysr8_QuotationStatus.setPreferredSize(new Dimension(208, 23)); + ysr8_QuotationStatus.setEditable(true); + ysr8_QuotationStatus.setEnabled(true); + + lovMap.put("ysr8_Product", getLOV("ysr8_Product_LOV")); + String[] ysr8_Product_LOV = new String[lovMap.get("ysr8_Product").size()]; + i = 0; + for(String v : lovMap.get("ysr8_Product").keySet()) { + ysr8_Product_LOV[i] = v; + i++; + } + ysr8_Product = new JComboBox(ysr8_Product_LOV); + ysr8_Product.setPreferredSize(new Dimension(208, 23)); + + lovMap.put("ysr8_use", getLOV("ysr8_Use_LOV")); + String[] ysr8_Use_LOV = new String[lovMap.get("ysr8_use").size()]; + i = 0; + for(String v : lovMap.get("ysr8_use").keySet()) { + ysr8_Use_LOV[i] = v; + i++; + } + ysr8_use = new JComboBox(ysr8_Use_LOV); + ysr8_use.setPreferredSize(new Dimension(208, 23)); + + ysr8_RequestedDate = newDateButton(); + ysr8_SysPlanDate = new DateButton(null, "yyyy-MM-dd", false, false, false); + ysr8_ReceiveDate = newDateButton(); +// ysr8_FinishedDate = new DateButton(null, "yyyy-MM-dd", false, false, false); + ysr8_FinishedDate = newDateButton(); + + ysr8_OfferAmount = new iTextField(g1); + ysr8_OfferAmount.setEditable(false); + ysr8_OfferAmount.setEnabled(false); +// ysr8_OfferAmount.setBackground(Color.WHITE); + ysr8_RobotModelAndNum = new JTextArea(5, 26); +// ysr8_RobotModelAndNum = new iTextArea(); + ysr8_RobotModelAndNum.setRows(3); + ysr8_RobotModelAndNum.setBorder(BorderFactory.createLoweredBevelBorder()); + ysr8_RobotModelAndNum.setLineWrap(true); + ysr8_RobotModelAndNum.setWrapStyleWord(true); + ysr8_RobotModelAndNum.setOpaque(true); +// ysr8_RobotModelAndNum.setBackground(ysr8_Ratio.getBackground()); +// System.out.println("Color:"+ysr8_Ratio.getBackground()); + ysr8_QuotationRemarks = new JTextArea(5, 60);//TODO + ysr8_QuotationRemarks.setRows(3); + ysr8_QuotationRemarks.setBorder(BorderFactory.createLoweredBevelBorder()); + ysr8_QuotationRemarks.setLineWrap(true); + ysr8_QuotationRemarks.setWrapStyleWord(true); + ysr8_QuotationRemarks.setOpaque(true); + + allComponents.add( ysr8_Sales ); + allComponents.add( ysr8_OrderManufacturer ); + allComponents.add( ysr8_CustomerName ); + allComponents.add( ysr8_QuotationLevel ); + allComponents.add( ysr8_Contact ); + allComponents.add( ysr8_ContactDept ); + allComponents.add( ysr8_ContactPosition ); + allComponents.add( ysr8_ContactPhone ); + allComponents.add( ysr8_ProjectManager ); + allComponents.add( ysr8_Ratio ); + allComponents.add( ysr8_ProjectLevel ); +// allComponents.add( ysr8_QuotationState ); + allComponents.add( ysr8_SytemName ); + allComponents.add( ysr8_RequestedDate ); + allComponents.add( ysr8_SysPlanDate ); + allComponents.add( ysr8_ReceiveDate ); + allComponents.add( ysr8_FinishedDate ); + allComponents.add( ysr8_OfferAmount ); + allComponents.add( ysr8_RobotModelAndNum ); +// allComponents.add( ysr8_QuotationRemarks ); +// allComponents.add( ysr8_QuotationStatus ); +// allComponents.add( ysr8_EstimatedDate ); +// allComponents.add( ysr8_Possibility ); + allComponents.add( ysr8_Product ); + allComponents.add( ysr8_use ); + } + + private void setName() { + ysr8_Sales.setName("ysr8_Sales"); + ysr8_OrderManufacturer.setName("ysr8_OrderManufacturer"); + ysr8_CustomerName.setName("ysr8_CustomerName"); + ysr8_QuotationLevel.setName("ysr8_QuotationLevel"); + ysr8_Contact.setName("ysr8_Contact"); + ysr8_ContactDept.setName("ysr8_ContactDept"); + ysr8_ContactPosition.setName("ysr8_ContactPosition"); + ysr8_ContactPhone.setName("ysr8_ContactPhone"); + ysr8_ProjectManager.setName("ysr8_ProjectManager"); + ysr8_Ratio.setName("ysr8_Ratio"); + ysr8_ProjectLevel.setName("ysr8_ProjectLevel"); +// ysr8_QuotationState.setName("ysr8_QuotationState"); + ysr8_SytemName.setName("ysr8_SytemName"); + ysr8_RequestedDate.setName("ysr8_RequestedDate"); + ysr8_SysPlanDate.setName("ysr8_SysPlanDate"); + ysr8_ReceiveDate.setName("ysr8_ReceiveDate"); + ysr8_FinishedDate.setName("ysr8_FinishedDate"); + ysr8_OfferAmount.setName("ysr8_OfferAmount"); + ysr8_RobotModelAndNum.setName("ysr8_RobotModelAndNum"); + + + ysr8_QuotationStatus.setName("ysr8_QuotationStatus"); + ysr8_EstimatedDate.setName("ysr8_EstimatedDate"); + ysr8_Possibility.setName("ysr8_Possibility"); + ysr8_QuotationRemarks.setName("ysr8_QuotationRemarks"); + ysr8_Product.setName("ysr8_Product"); + ysr8_use.setName("ysr8_use"); + } + + @Override + public void loadRendering() throws TCException { + System.out.println("loadForm------------------------start"); + try { + this.formProperties = componentForm.getAllFormProperties(); + int length = this.formProperties.length; + int pSize = allComponents.size(); + for (int k = 0; k < length; ++k) { + String propName = this.formProperties[k].getPropertyName().trim(); + for (int i = 0; i < pSize; i++) { + Component component = allComponents.get(i); + String name = component.getName(); + if (name.equals("ysr8_OfferAmount")) {//lidy20181108۽ǧλָ + iTextField textField = (iTextField) component; + if (propName.equalsIgnoreCase(name)) { + DecimalFormat df = new DecimalFormat(",###,###"); + try { + Double OfferAmount = new Double(this.formProperties[k].getStringValue()); + textField.setText(df.format(OfferAmount)); + } catch(NumberFormatException e) { + textField.setText(this.formProperties[k].getStringValue()); + } + indices.put(formProperties[k], textField); + break; + } + } else + if (component instanceof iTextField) { + iTextField textField = (iTextField) component; + if (propName.equalsIgnoreCase(name)) { + textField.setText(this.formProperties[k].getStringValue()); + indices.put(formProperties[k], textField); + break; + } + } else if (component instanceof JComboBox) { + @SuppressWarnings("rawtypes") + JComboBox combox = (JComboBox) component; + if (propName.equalsIgnoreCase(name)) { +// combox.setSelectedItem(this.formProperties[k].getStringValue()); + System.out.println(component.getName()); + combox.setSelectedItem(componentForm.getProperty(component.getName())); + indices.put(formProperties[k], combox); + break; + } +// } else if (component instanceof LOVComboBox) { +// LOVComboBox combox = (LOVComboBox) component; +// if (propName.equalsIgnoreCase(name)) { +// combox.setSelectedItem(this.formProperties[k].getStringValue()); +//// combox.setSelectedItem(lovMap.get(component.getName()).get(this.formProperties[k].getStringValue())); +// indices.put(formProperties[k], combox); +// break; +// } + } else if(component instanceof DateButton){ + DateButton btn = (DateButton) component; + if(propName.equalsIgnoreCase(name)){ + btn.setDate(formProperties[k].getDateValue()); + indices.put(formProperties[k], btn); + break; + } + }else if (component instanceof JTextArea) { + JTextArea textArea = (JTextArea) component; + if (propName.equalsIgnoreCase(name)) { + textArea.setText(formProperties[k].getStringValue()); + indices.put(formProperties[k], textArea); + break; + } + } + } + } + ysr8_FinishedDate.setDate(componentForm.getDateProperty("ysr8_FinishedDate")); + + ysr8_QuotationStatus.setSelectedItem(componentItem.getProperty("ysr8_QuotationStatus")); + ysr8_EstimatedDate.setDate(componentItem.getDateProperty("ysr8_EstimatedDate")); + ysr8_Possibility.setText(componentItem.getProperty("ysr8_Possibility")); + ysr8_QuotationRemarks.setText(componentItem.getProperty("ysr8_QuotationRemarks")); + } catch (Exception imanexception) { + throw imanexception; + } + if (this.formProperties == null) { + Registry registry = Registry.getRegistry(this); + throw new TCException(registry.getString("failedLoadingFormProperties")); + } + } + + @Override + public void saveRendering() { + FileWriter fos = null; + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + String out = System.getProperty("java.io.tmpdir")+"\\־.txt";//"+sdf.format(new Date())+" + File htmlfile = new File(out); + if(htmlfile.exists()) + htmlfile.delete(); + htmlfile.createNewFile(); + fos = new FileWriter(htmlfile); + fos.write(sdf.format(new Date()) +" saveRendering start\r\n\r\n"); + + Enumeration enumeration = this.indices.keys(); + Enumeration enumeration1 = this.indices.elements(); + TCFormProperty[] aimanformproperty = new TCFormProperty[this.indices.size()]; + + for (int i = 0; enumeration.hasMoreElements(); i++) { + TCFormProperty imanformproperty = (TCFormProperty) enumeration.nextElement(); + Object component = enumeration1.nextElement(); + String propName = imanformproperty.getPropertyName(); + fos.write(sdf.format(new Date()) +" propName:"+propName+"\r\n\r\n"); + if (propName.equals("ysr8_OfferAmount")) {//lidy20181108۽ǧλָ + String strTempValue = ((iTextField) component).getText().toString(); + setStringToPropertyValue(imanformproperty, strTempValue.replace(",", "")); + } else if (component instanceof iTextField) { + String strTempValue = ((iTextField) component).getText().toString(); + setStringToPropertyValue(imanformproperty, strTempValue); + } else if (component instanceof JComboBox) { + //kk 0813 ѡʱĿ쳣 + @SuppressWarnings("rawtypes") + Object sItem = ((JComboBox) component).getSelectedItem(); +// String strTempValue = ""; + String strTempValue = sItem==null?"":sItem.toString(); +// componentForm.setProperty(propName, strTempValue); +// for(Map.Entry lovEntry : lovMap.get(((Component) component).getName()).entrySet()) { +// if(lovEntry.getValue().equals(sItem.toString())) { +// strTempValue = lovEntry.getKey().toString(); +// break; +// } +// } +// String strTempValue = sItem==null?"":sItem.toString();propName + if(lovMap.containsKey(propName)) { + System.out.println("lovMap:"+strTempValue+"~~"+lovMap.get(propName)); + fos.write(sdf.format(new Date()) +" "+propName+"=="+strTempValue+"~~"+lovMap.get(propName)+"\r\n\r\n"); + setStringToPropertyValue(imanformproperty, lovMap.get(propName).get(strTempValue)); + }else + setStringToPropertyValue(imanformproperty, strTempValue); +// } else if (component instanceof LOVComboBox) { +// //kk 0813 ѡʱĿ쳣 +// Object sItem = ((LOVComboBox) component).getSelectedItem(); +// String strTempValue = sItem==null?"":sItem.toString(); +// setStringToPropertyValue(imanformproperty,strTempValue); + } else if (component instanceof DateButton) { + DateButton btn = (DateButton) component; + if (btn.getDate() != null) { + imanformproperty.setDateValue(btn.getDate()); + } else { + imanformproperty.setDateValue(null); + } + } else if (component instanceof JTextArea) { + setStringToPropertyValue(imanformproperty,((JTextArea) component).getText().toString()); + } + aimanformproperty[i] = imanformproperty; + } + System.out.println("Item:"+componentItem); + // lidy20181030Item +// TCUserService userservice = session.getUserService(); +// Object[] obj = new Object[2]; +// obj[0] = "Set_ByPass"; +// obj[1] = "true"; +// userservice.call("YSR8UserService", obj); +//// System.out.println("result:"+result); +// componentItem.lock(); +// componentItem.setStringProperty("ysr8_QuotationStatus", ysr8_QuotationStatus.getSelectedItem().toString()); +// componentItem.setDateProperty("ysr8_EstimatedDate", ysr8_EstimatedDate.getDate()); +// componentItem.setStringProperty("ysr8_Possibility", ysr8_Possibility.getText()); + String params = "", proName = "", ysr8_EstimatedDateVal = ""; + StringBuilder proVal = new StringBuilder("");//TODO + proName = "ysr8_EstimatedDate@@@@ysr8_Possibility@@@@ysr8_QuotationStatus@@@@ysr8_QuotationRemarks"; + ysr8_EstimatedDateVal = ysr8_EstimatedDate.getDate()==null?"":String.format("%tF", ysr8_EstimatedDate.getDate()); + proVal.append(ysr8_EstimatedDateVal).append("@@@@").append(ysr8_Possibility.getText()).append("@@@@"); + proVal.append(ysr8_QuotationStatus.getSelectedItem().toString()).append("@@@@").append(ysr8_QuotationRemarks.getText()); + params = componentItem.getUid() + "^^^^" + proName + "^^^^" + proVal.toString(); + String cmd = "Update_Item_TCProperty"; + Object[] objParams = new Object[2]; + objParams[0] = cmd; + objParams[1] = params; + TCUserService userService = session.getUserService(); + String result = (String) userService.call("YSR8UserService", objParams); + System.out.println("Itemԣ"+result); +// componentItem.save(); +// componentItem.unlock(); +// obj[1] = "false"; +// userservice.call("YSR8UserService", obj); + + try { + componentForm.setTCProperties(aimanformproperty); + } + catch (Exception exception) { + exception.printStackTrace(); + MessageBox.post(exception); + } + } catch (Exception imane) { + imane.printStackTrace(); + }finally { + if(fos!=null) + try { + fos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @SuppressWarnings("rawtypes") + public boolean isRenderingModified() { + Enumeration enumeration = this.indices.keys(); + Enumeration enumeration1 = this.indices.elements(); + for (; enumeration.hasMoreElements(); ) { + TCFormProperty imanformproperty = (TCFormProperty) enumeration.nextElement(); + Object component = enumeration1.nextElement(); +// String propName = imanformproperty.getPropertyName(); + if (imanformproperty.getName().equals("ysr8_OfferAmount")) {//lidy20181108۽ǧλָ + String strTempValue = ((iTextField) component).getText().toString(); + if(!imanformproperty.getStringValue().equals(strTempValue.replace(",", ""))){ + return true; + } + } else + if (component instanceof iTextField) { + String strTempValue = ((iTextField) component).getText().toString(); + if(!imanformproperty.getStringValue().equals(strTempValue)){ + return true; + } + } else if (component instanceof JComboBox) { + Object sItem = ((JComboBox) component).getSelectedItem(); + String strTempValue = sItem==null?"":sItem.toString(); +// System.out.println(strTempValue+"::"+imanformproperty.getStringValue()+"::"+map.get(imanformproperty.getStringValue())); + try{ + if(!strTempValue.equals(componentForm.getProperty(((JComboBox)component).getName()))){ + return true; + } + } catch(TCException e) { + e.printStackTrace(); + } +// } else if (component instanceof LOVComboBox) { +// //kk 0809 ѡʱĿ쳣 +// Object sItem = ((LOVComboBox) component).getSelectedItem(); +// String strTempValue = sItem==null?"":sItem.toString(); +// if(!imanformproperty.getStringValue().equals(strTempValue)){ +// return true; +// } + } else if (component instanceof DateButton) { + DateButton btn = (DateButton) component; + if(imanformproperty.getDateValue() != null && btn.getDate() != null){ + if(imanformproperty.getDateValue().getTime() != btn.getDate().getTime()){ + return true; + } + }else if(imanformproperty.getDateValue() != null && btn.getDate() == null){ + return true; + }else if(imanformproperty.getDateValue() == null && btn.getDate() != null){ + return true; + } + } else if (component instanceof JTextArea) { + String strTempValue = ((JTextArea) component).getText().toString(); + if (!imanformproperty.getStringValue().equals(strTempValue)) { + return true; + } + } + + try { + String sItem = ysr8_QuotationStatus.getSelectedItem().toString(); + if(!componentItem.getProperty("ysr8_QuotationStatus").equals(sItem)) { +// System.out.println("ysr8_QuotationStatus"); + return true; + } + if(ysr8_EstimatedDate.getDate() != null && componentItem.getDateProperty("ysr8_EstimatedDate") != null){ + if(ysr8_EstimatedDate.getDate().getTime()!=(componentItem.getDateProperty("ysr8_EstimatedDate")).getTime()) { + return true; + } + }else if(ysr8_EstimatedDate.getDate() == null && componentItem.getDateProperty("ysr8_EstimatedDate") != null){ + return true; + }else if(ysr8_EstimatedDate.getDate() != null && componentItem.getDateProperty("ysr8_EstimatedDate") == null){ + return true; + } + if(!ysr8_Possibility.getText().equals(componentItem.getProperty("ysr8_Possibility"))) { + return true; + } + if(!ysr8_QuotationRemarks.getText().equals(componentItem.getProperty("ysr8_QuotationRemarks"))) { + return true; + } + } catch (TCException e) { + e.printStackTrace(); + } + } + return false; + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + if(getController() != null) + getController().setFormReadOnly(); + jBPM.setEnabled(true); + if(jBPM.getParent() != null) + jBPM.getParent().setEnabled(true); + if(jBPM.getParent().getParent() != null) + jBPM.getParent().getParent().setEnabled(true); + } + + public void setRenderingReadWrite() + { + setModifiableComponents(this, true); + jBPM.setEnabled(true); + } + + private void setModifiableComponents(java.awt.Component component1, boolean flag) + { + if(component1 == null) + return; + boolean flag1 = flag; + if(flag && (component1 instanceof PropertyComment)) + flag1 = ((PropertyComment)component1).isLabelEditable(); + else + if(flag && (component1 instanceof InterfacePropertyComponent)) + { + String s = ((InterfacePropertyComponent)component1).getProperty(); + try + { + TCPropertyDescriptor tcpropertydescriptor = typeComponent.getPropertyDescriptor(s); + if(tcpropertydescriptor != null) + { + flag1 = tcpropertydescriptor.isEnabled(); + if(component != null) + { + TCProperty tcproperty = component.getTCProperty(s); + boolean flag3 = tcproperty.isEnabled(); + flag1 = flag3; + } + if(isConditionalFieldBehaviorEnabled() && FormFieldManager.isCustomizationEnabled()) + { + boolean flag2 = WidgetTypeAdapter.isInterfacePropertyComponentEnabled((InterfacePropertyComponent)component1); + flag1 = flag1 && flag2; + } + } + } + catch(TCException tcexception) + { + Logger.getLogger("com.teamcenter.rac.stylesheet.AbstractRendering").info(tcexception.getLocalizedMessage()); + } + } + if(!(component1 instanceof JTabbedPane) && !(component1 instanceof JSplitPane) && !(component1 instanceof JPanel) && !(component1 instanceof JLabel) && !(component1 instanceof JScrollPane) && !(component1 instanceof JViewport) && !(component1 instanceof JProgressBar) && !(component1 instanceof JTableHeader)) + if(component1 instanceof JTextComponent) + ((JTextComponent)component1).setEditable(flag1); + else + component1.setEnabled(flag1); + if(component1 instanceof InterfaceRendererEvent) + if(flag1) + ((InterfaceRendererEvent)component1).setReadWrite(); + else + ((InterfaceRendererEvent)component1).setReadOnly(); + if(component1 instanceof PropertyArray) + ((PropertyArray)component1).setModifiable(flag1); + else + if(component1 instanceof PropertyObjectLink) + ((PropertyObjectLink)component1).setModifiable(flag1); + else + if(component1 instanceof PropertyLogicalPanel) + ((PropertyLogicalPanel)component1).setModifiable(flag1); + else + if(component1 instanceof AbstractPropertyComponent) + ((AbstractPropertyComponent)component1).setModifiable(flag1); + else + if(component1 instanceof JScrollPane) + { + JScrollPane jscrollpane = (JScrollPane)component1; + java.awt.Component component2 = jscrollpane.getCorner("LOWER_LEFT_CORNER"); + if(component2 != null) + setModifiableComponents(component2, flag1); + component2 = jscrollpane.getCorner("LOWER_RIGHT_CORNER"); + if(component2 != null) + setModifiableComponents(component2, flag1); + component2 = jscrollpane.getCorner("UPPER_LEFT_CORNER"); + if(component2 != null) + setModifiableComponents(component2, flag1); + component2 = jscrollpane.getCorner("UPPER_RIGHT_CORNER"); + if(component2 != null) + setModifiableComponents(component2, flag1); + setModifiableComponents(((java.awt.Component) (jscrollpane.getViewport())), flag1); + } else + if(component1 instanceof java.awt.Container) + { + java.awt.Component acomponent[] = ((java.awt.Container)component1).getComponents(); + if(acomponent != null) + { + for(int i = 0; i < acomponent.length; i++) + setModifiableComponents(acomponent[i], flag1); + + } + } + } + @SuppressWarnings( "serial" ) + private DateButton newDateButton() { +// DateButton db = new PropertyDateButton() { + DateButton db = new DateButton(null, "yyyy-MM-dd", false, false, false) { + @Override + public void setEnabled(boolean f) { + super.setEnabled(false); + } + }; + return db; + } + private LinkedHashMap getLOV(String lovName){ + LinkedHashMap lovValue = new LinkedHashMap<>(); + lovValue.put("", ""); + TCComponentListOfValuesType lovType; + try { + lovType = (TCComponentListOfValuesType)session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + if(lov.length==0) { + return lovValue; + } + ListOfValuesInfo lovInfo = lov[0].getListOfValues(); + Object[] v1 = lovInfo.getListOfValues(); + String[] v2 = lovInfo.getLOVDisplayValues(); + for(int i=0; i map = lovInfo.getValueTable(); +// for(Object k : map.keySet()) { +// lovValue.put(k.toString(), map.get(k)); +// } + } catch (Exception e) { + e.printStackTrace(); + } + return lovValue; + } + +} diff --git a/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..04ca04b --- /dev/null +++ b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1,2 @@ +YSR8_QuotationRevisionMaster.FORMJAVARENDERING=cn.com.teamcenter.rac.form.YSR8_QuotationRevisionMaster +YSR8_ProjectForm.FORMJAVARENDERING=cn.com.teamcenter.rac.form.YSR8_ProjectForm \ No newline at end of file diff --git a/src/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean.java b/src/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean.java new file mode 100644 index 0000000..33b52bc --- /dev/null +++ b/src/com/teamcenter/rac/viewer/stylesheet/beans/CUSTAutoAssignItemIDPropertyBean.java @@ -0,0 +1,496 @@ +package com.teamcenter.rac.viewer.stylesheet.beans; + +import cn.com.origin.autocode.newitem.newcode.NewCodeItemDialog; +import cn.com.origin.autocodemanager.common.PackCodeDescInfos; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.commands.newitem.NamingRulesHelper; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.services.ISessionService; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.controls.SWTComboBox; +import com.teamcenter.rac.util.controls.TextControl; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.soa.client.model.NamingRule; +import java.util.Map; +import org.apache.log4j.Logger; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; + +// Referenced classes of package com.teamcenter.rac.viewer.stylesheet.beans: +// AbstractPropertyBean, TextfieldPropertyBean, AbstractAutoAssignBean + +public class CUSTAutoAssignItemIDPropertyBean extends AbstractPropertyBean +{ + private class IC_GenerateIDButtonSelectionAdapter extends SelectionAdapter + { + + public void widgetSelected(SelectionEvent selectionevent) + { + try + { + String itemType = getOwningTypeName(m_propDesc); + Composite composite = m_propBean.getControl().getParent().getParent(); + textObject_name = getSession().getTextService().getTextValue(object_name); + textObject_desc = getSession().getTextService().getTextValue(object_desc); + textObject_rev1 = getSession().getTextService().getTextValue(revision_id1); + getNameTextByLabel(composite, object_name); + if(itemNameText == null) + getNameTextByLabel(composite, textObject_name); + getNameTextByLabel(composite, object_desc); + if(itemDescText == null) + getNameTextByLabel(composite, textObject_desc); + getNameTextByLabel(composite, revision_id1); + if(itemRevText == null) + getNameTextByLabel(composite, textObject_rev1); + if(itemRevText == null) + { + getNameTextByLabel(composite, revision_id2); + if(itemRevText == null) + getNameTextByLabel(composite, textObject_rev2); + } + if(m_propBean instanceof TextfieldPropertyBean) + { + TextfieldPropertyBean textfieldPropertyBean = (TextfieldPropertyBean)m_propBean; + itemIDText = textfieldPropertyBean.getTextField(); + } +// itemType = itemType.replace("汾", "").replace("Revision", ""); +// System.out.println("CECAutoAssignItemIDPropertyBean itemType = "+itemType); + PackCodeDescInfos packCodeDescInfos = new PackCodeDescInfos(); +// (new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell(), itemType, packCodeDescInfos)).open(); + (new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell(), "", packCodeDescInfos)).open(); + if(packCodeDescInfos.getGenerateID() != null) + { + itemIDText.setText(packCodeDescInfos.getGenerateID()); + if(itemNameText != null) + itemNameText.setText(packCodeDescInfos.getNameValue()); + //remove and add 2017-10-12 + itemIDText.setEnabled(false); + assignButton.setEnabled(false); +// if(packCodeDescInfos.getCodeRuleName().trim().length() > 0) +// { +// itemIDText.setEnabled(false); +// assignButton.setEnabled(false); +// setCodeInfo(composite.getParent().getParent().getParent(), packCodeDescInfos, null); +// } + //end + } + } + catch(TCException e) + { + e.printStackTrace(); + } + } + + private TCPropertyDescriptor m_propDesc; + private SWTComboBox m_comboBox; + private Button m_sourceObject; + + public IC_GenerateIDButtonSelectionAdapter(TCPropertyDescriptor tcpropertydescriptor, SWTComboBox swtcombobox) + { + super(); + m_propDesc = tcpropertydescriptor; + m_comboBox = swtcombobox; + } + } + + + public CUSTAutoAssignItemIDPropertyBean(FormToolkit formtoolkit, Composite composite, boolean flag, Map map) + { + item_id = "object_name"; + object_name = "object_name"; + object_desc = "object_desc"; + revision_id1 = "item_revision_id"; + revision_id2 = "revision:item_revision_id"; + textObject_name = "object_name"; + textObject_desc = "object_desc"; + textObject_rev1 = "item_revision_id"; + textObject_rev2 = "revision:item_revision_id"; + assignButton = null; + m_localComposite = new Composite(composite, 0); + addDefaultBeanControl(formtoolkit, m_localComposite, flag, map); + } + + protected void addDefaultBeanControl(FormToolkit formtoolkit, Composite composite, boolean flag, Map map) + { + m_propBean = new TextfieldPropertyBean(formtoolkit, composite, flag, map); + setPageAttrib(map); + setControl(m_propBean.getControl()); + m_propBean.addPropertyChangeListener(this); + ((TextfieldPropertyBean)m_propBean).removePropertyChangeListner(); + ((TextfieldPropertyBean)m_propBean).getTextControl().addPropertyChangeListener(this); + } + + private void setPageAttrib(Map map) + { + String s = map == null ? null : (String)map.get("column"); + int i = 32; + if(s != null && s.length() > 0) + try + { + i = Integer.parseInt(s); + } + catch(NumberFormatException numberformatexception) + { + Logger.getLogger(com.teamcenter.rac.viewer.stylesheet.beans.AbstractAutoAssignBean.class).error(numberformatexception.getClass().getName(), numberformatexception); + } + setSize(i); + } + + private void setSize(int i) + { + if(m_propBean instanceof TextfieldPropertyBean) + { + int j = i; + if(j == 0) + j = 32; + int k = j * 5; + GridData griddata = new GridData(4, 16777216, true, true); + griddata.widthHint = k; + ((TextfieldPropertyBean)m_propBean).setLayoutData(griddata); + } + } + + public boolean isPropertyModified(TCProperty tcproperty) + throws Exception + { + return m_propBean.isPropertyModified(tcproperty); + } + + public void setModifiable(boolean flag) + { + m_propBean.setModifiable(flag); + } + + public boolean isMandatory() + { + return m_propBean.isMandatory(); + } + + public Object getEditableValue() + { + return m_propBean.getEditableValue(); + } + + public void load(TCProperty tcproperty) + throws Exception + { + load(tcproperty.getPropertyDescriptor()); + setDirty(false); + } + + public void load(TCPropertyDescriptor tcpropertydescriptor) + throws Exception + { + setLayout(2); + m_propBean.setProperty(getProperty()); + descriptor = tcpropertydescriptor; + NamingRule namingrule = descriptor.getNamingRule(); + if(namingrule != null) + { + String as[] = getNamingRulePatternsWithCounters(tcpropertydescriptor); + String s = getPreferredNamingRulePattern(tcpropertydescriptor); + if(as != null && as.length > 0) + { + m_validationNeeded = true; + addMoreWidgets(tcpropertydescriptor, as, s); + } else + { + setLayout(1); + m_validationNeeded = true; + } + } else + { + setLayout(2); + Button button = getButtonWidget(); + button.setData("RCAF_ID", tcpropertydescriptor.getName()); + assignButton = button; + button.addSelectionListener(new IC_GenerateIDButtonSelectionAdapter(tcpropertydescriptor, null)); + } + m_propBean.load(tcpropertydescriptor); + } + + private void addMoreWidgets(TCPropertyDescriptor tcpropertydescriptor, String as[], String s) + { + setLayout(3); + SWTComboBox swtcombobox = new SWTComboBox(m_localComposite, 2056); + GridData griddata = new GridData(4, 16777216, true, true); + swtcombobox.setLayoutData(griddata); + String as1[]; + int j = (as1 = as).length; + for(int i = 0; i < j; i++) + { + String s1 = as1[i]; + swtcombobox.addItem(s1); + } + + swtcombobox.setAutoCompleteSuggestive(false); + if(s != null && s.length() > 0) + swtcombobox.setSelectedItem(s); + else + swtcombobox.setSelectedIndex(0); + Button button = getButtonWidget(); + button.setData("RCAF_ID", tcpropertydescriptor.getName()); + button.addSelectionListener(new IC_GenerateIDButtonSelectionAdapter(tcpropertydescriptor, swtcombobox)); + } + + private String[] getNamingRulePatternsWithCounters(TCPropertyDescriptor tcpropertydescriptor) + { + DataManagementService datamanagementservice = DataManagementService.getService(getSession()); + com.teamcenter.services.rac.core._2008_06.DataManagement.GetNRPatternsWithCountersResponse getnrpatternswithcountersresponse = null; + com.teamcenter.services.rac.core._2008_06.DataManagement.NRAttachInfo anrattachinfo[] = new com.teamcenter.services.rac.core._2008_06.DataManagement.NRAttachInfo[1]; + anrattachinfo[0] = new com.teamcenter.services.rac.core._2008_06.DataManagement.NRAttachInfo(); + anrattachinfo[0].propName = getProperty(); + anrattachinfo[0].typeName = getOwningTypeName(tcpropertydescriptor); + getnrpatternswithcountersresponse = datamanagementservice.getNRPatternsWithCounters(anrattachinfo); + com.teamcenter.services.rac.core._2008_06.DataManagement.PatternsWithCounters apatternswithcounters[] = getnrpatternswithcountersresponse.patterns; + return apatternswithcounters[0].patternStrings; + } + + protected String getOwningTypeName(TCPropertyDescriptor tcpropertydescriptor) + { + String s = tcpropertydescriptor.getTypeComponent().getOwningType(); + if(s == null || s.isEmpty()) + s = tcpropertydescriptor.getTypeComponent().getTypeName(); + return s; + } + + private String getPreferredNamingRulePattern(TCPropertyDescriptor tcpropertydescriptor) + { + String s = tcpropertydescriptor.getTypeComponent().getOwningType().toString(); + String s1 = s == null || s.isEmpty() ? tcpropertydescriptor.getTypeComponent().toString() : s; + String as[] = { + tcpropertydescriptor.getName() + }; + String as1[] = { + s1 + }; + com.teamcenter.rac.commands.newitem.NamingRule anamingrule[] = NamingRulesHelper.getInstance().getNamingRules(getSession(), as1, as); + return anamingrule[0].getPreferredPattern(); + } + + private Button getButtonWidget() + { + Button button = new Button(m_localComposite, 0); + button.setText(appReg.getString("assignButton.TEXT")); + return button; + } + + public TCSession getSession() + { + TCSession tcsession = null; + try + { + tcsession = (TCSession)Activator.getDefault().getSessionService().getSession("com.teamcenter.rac.kernel.TCSession"); + } + catch(Exception exception) + { + Logger.getLogger(com.teamcenter.rac.viewer.stylesheet.beans.AbstractAutoAssignBean.class).error(exception); + return null; + } + return tcsession; + } + + protected void setLayout(int i) + { + if(m_localComposite != null) + { + GridLayout gridlayout = new GridLayout(i, false); + gridlayout.marginHeight = 0; + gridlayout.marginWidth = 0; + m_localComposite.setLayout(gridlayout); + GridData griddata = new GridData(4, 16777216, true, true); + m_localComposite.setLayoutData(griddata); + } + } + + public TCProperty getPropertyToSave(TCProperty tcproperty) + throws Exception + { + return tcproperty; + } + + public void setUIFValue(Object obj) + { + m_propBean.setUIFValue(obj); + } + + public void setCodeInfo(Composite composite, PackCodeDescInfos packCodeDescInfos, Control next) + { + try + { + Control childrens[] = composite.getChildren(); + for(int i = 0; i < childrens.length; i++) + { + Control child = childrens[i]; + if(child instanceof Label) + { + Label label = (Label)child; + String text = label.getText(); + if(text.equals("cd9_codeDesc:") || text.equals((new StringBuilder(String.valueOf(getSession().getTextService().getTextValue("cd9_codeDesc")))).append(":").toString())) + { + if(next instanceof Text) + { + Text textField = (Text)next; + textField.setText(packCodeDescInfos.getIdDesc()); + textField.setEnabled(false); + } + } else + if(text.equals("cd9_codePattern:") || text.equals((new StringBuilder(String.valueOf(getSession().getTextService().getTextValue("cd9_codePattern")))).append(":").toString())) + { + if(next instanceof Text) + { + Text textField = (Text)next; + textField.setText(packCodeDescInfos.getCodetz()); + textField.setEnabled(false); + } + } else + if(text.equals("cd9_codeRuleName:") || text.equals((new StringBuilder(String.valueOf(getSession().getTextService().getTextValue("cd9_codeRuleName")))).append(":").toString())) + { + if(next instanceof Text) + { + Text textField = (Text)next; + //remove 2017-10-12 +// textField.setText(packCodeDescInfos.getCodeRuleName()); + //end + textField.setEnabled(false); + } + } else + if(text.equals("cd9_codeID:") || text.equals((new StringBuilder(String.valueOf(getSession().getTextService().getTextValue("cd9_codeID")))).append(":").toString())) + { + if(next instanceof Text) + { + Text textField = (Text)next; + textField.setText(packCodeDescInfos.getIdjl()); + textField.setEnabled(false); + } + } else + if(text.equals("cd9_generateID:") || text.equals((new StringBuilder(String.valueOf(getSession().getTextService().getTextValue("cd9_generateID")))).append(":").toString())) + { + if(next instanceof Text) + { + Text textField = (Text)next; + textField.setText(packCodeDescInfos.getGenerateID()); + textField.setEnabled(false); + } + } else + if((text.equals("cd9_codeStyle:") || text.equals((new StringBuilder(String.valueOf(getSession().getTextService().getTextValue("cd9_codeStyle")))).append(":").toString())) && (next instanceof Text)) + { + Text textField = (Text)next; + textField.setText(packCodeDescInfos.getCodeStyle()); + textField.setEnabled(false); + } + } + } + + for(int i = 0; i < childrens.length; i++) + { + Control child = childrens[i]; + Control child2 = null; + if(i + 1 < childrens.length) + child2 = childrens[i + 1]; + if(child instanceof Composite) + setCodeInfo((Composite)child, packCodeDescInfos, child2); + } + + } + catch(TCException e) + { + e.printStackTrace(); + } + } + + public void getNameTextByLabel(Composite composite, String labelName) + { + boolean isEqual = false; + int equalNum = 0; + Control childrens[] = composite.getChildren(); + for(int i = 0; i < childrens.length; i++) + { + Control child = childrens[i]; + if((child instanceof Composite) && !isEqual && isValidLabelByText((Composite)child, labelName)) + { + isEqual = true; + equalNum = i; + } + if(isEqual) + if(labelName.equals(object_name) || labelName.equals(textObject_name)) + { + if((child instanceof Text) && i == equalNum + 1) + { + Text textField = (Text)child; + itemNameText = textField; + return; + } + } else + if(labelName.equals(object_desc) || labelName.equals(textObject_desc)) + { + if((child instanceof Text) && i == equalNum + 1) + { + Text textField = (Text)child; + itemDescText = textField; + return; + } + } else + if((labelName.equals(revision_id1) || labelName.equals(textObject_rev1) || labelName.equals(revision_id2) || labelName.equals(textObject_rev2)) && (child instanceof Text) && i == equalNum + 1) + { + Text textField = (Text)child; + itemRevText = textField; + return; + } + } + + } + + private boolean isValidLabelByText(Composite composite, String labelName) + { + boolean isValid = false; + Control childrens[] = composite.getChildren(); + for(int i = 0; i < childrens.length; i++) + { + Control child = childrens[i]; + if(child instanceof Label) + { + Label label = (Label)child; + String text = label.getText(); + if(text.equals((new StringBuilder(String.valueOf(labelName))).append(":").toString())) + isValid = true; + } + } + + return isValid; + } + + Text itemIDText; + Text itemNameText; + Text itemDescText; + Text itemRevText; + String item_id; + String object_name; + String object_desc; + String revision_id1; + String revision_id2; + String textObject_name; + String textObject_desc; + String textObject_rev1; + String textObject_rev2; + public Button assignButton; + protected AbstractPropertyBean m_propBean; + private Composite m_localComposite; + protected static final Registry appReg = Registry.getRegistry(com.teamcenter.rac.viewer.stylesheet.beans.CUSTAutoAssignItemIDPropertyBean.class); + protected boolean m_validationNeeded; + +} \ No newline at end of file diff --git a/src/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale.properties b/src/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale.properties new file mode 100644 index 0000000..c552968 --- /dev/null +++ b/src/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale.properties @@ -0,0 +1,15 @@ +// @@ +// ================================================== +// Copyright 2011. +// Siemens Product Lifecycle Management Software Inc. +// All Rights Reserved. +// ================================================== +// @@ + +message.PREFIX=Value must match one of the following patterns: +assignButton.TEXT = Assign +sameAsOldId=An existing item is found. +invalidType=Selected Type should be an Item. +invalidID.MESSAGE=Unable to create item - an invalid ID entered! +error.TITLE = New Item ... +mandatoryGCID.TEXT=It is mandatory to enter a value. \ No newline at end of file diff --git a/src/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale_zh_CN.properties b/src/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale_zh_CN.properties new file mode 100644 index 0000000..5695826 --- /dev/null +++ b/src/com/teamcenter/rac/viewer/stylesheet/beans/beans_locale_zh_CN.properties @@ -0,0 +1,15 @@ +// @@ +// ================================================== +// Copyright 2011. +// Siemens Product Lifecycle Management Software Inc. +// All Rights Reserved. +// ================================================== +// @@ + +message.PREFIX=\u503C\u5FC5\u987B\u540C\u4EE5\u4E0B\u4E00\u79CD\u6837\u5F0F\u5339\u914D\uFF1A +assignButton.TEXT = \u6307\u6D3E +sameAsOldId=\u627E\u5230\u73B0\u6709\u96F6\u7EC4\u4EF6\u3002 +invalidType=\u9009\u5B9A\u7684\u7C7B\u578B\u5E94\u4E3A\u96F6\u7EC4\u4EF6\u3002 +invalidID.MESSAGE=\u65E0\u6CD5\u521B\u5EFA\u96F6\u7EC4\u4EF6 - \u8F93\u5165\u7684 ID \u65E0\u6548\uFF01 +error.TITLE = \u65B0\u5EFA\u96F6\u7EC4\u4EF6... +mandatoryGCID.TEXT=\u5F3A\u5236\u8F93\u5165\u503C\u3002 \ No newline at end of file diff --git a/src/cust/com/rac/changename/ChangeNameAction.java b/src/cust/com/rac/changename/ChangeNameAction.java new file mode 100644 index 0000000..48bb123 --- /dev/null +++ b/src/cust/com/rac/changename/ChangeNameAction.java @@ -0,0 +1,19 @@ +package cust.com.rac.changename; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class ChangeNameAction extends AbstractAIFAction { + + public ChangeNameAction(AbstractAIFUIApplication arg0, String arg1) { + super(arg0, arg1); + } + + public void run() { + ChangeNameDialog dialog = new ChangeNameDialog(AIFUtility + .getCurrentApplication().getDesktop().getFrame(), + "", true); + } + +} diff --git a/src/cust/com/rac/changename/ChangeNameDialog.java b/src/cust/com/rac/changename/ChangeNameDialog.java new file mode 100644 index 0000000..b21e5a5 --- /dev/null +++ b/src/cust/com/rac/changename/ChangeNameDialog.java @@ -0,0 +1,93 @@ +package cust.com.rac.changename; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +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 ChangeNameDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + public JTextField srcIdText; + public JTextField newIdText; + public JButton okBtn; + public JButton cancelBtn; + public TCComponent targetComponent; + public String srcName; + public ChangeNameDialog(Frame arg0, String arg1, boolean arg2) { + super(arg0, arg1, arg2); + session=(TCSession) AIFUtility.getCurrentApplication().getSession(); + targetComponent=(TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + try { + srcName=targetComponent.getProperty("object_name"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + initUI(); + setVisible(true); + } + + public void initUI(){ + JPanel panel1 = new JPanel(new PropertyLayout(20,20,20,20,20,20)); + srcIdText=new JTextField(23); + srcIdText.setEditable(false); + srcIdText.setText(srcName); + newIdText=new JTextField(23); + panel1.add("1.1.left",new JLabel("ԭ:")); + panel1.add("1.2.left",srcIdText); + panel1.add("2.1.left",new JLabel("Ϊ:")); + panel1.add("2.2.left",newIdText); + JPanel panel2 = new JPanel(new FlowLayout()); + okBtn = new JButton("ȷ"); + cancelBtn = new JButton("ȡ"); + okBtn.addActionListener(this); + cancelBtn.addActionListener(this); + panel2.add(okBtn); + panel2.add(cancelBtn); + getContentPane().add(BorderLayout.CENTER, panel1); + getContentPane().add(BorderLayout.SOUTH, panel2); + centerToScreen(); + pack(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if(e.getSource() == okBtn){ + String newNameString=newIdText.getText().trim(); + if("".equals(newNameString)){ + MessageBox.post("ĺƣ", "ʾ", 4); + return; + } + try { + targetComponent.setProperty("object_name", newNameString); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + MessageBox.post("ʧܣ", "ʾ", 4); + } + this.setVisible(false); + this.dispose(); + }else if(e.getSource() == cancelBtn){ + this.setVisible(false); + this.dispose(); + } + } + +} + diff --git a/src/cust/com/rac/changename/ChangeNameHandler.java b/src/cust/com/rac/changename/ChangeNameHandler.java new file mode 100644 index 0000000..d30215a --- /dev/null +++ b/src/cust/com/rac/changename/ChangeNameHandler.java @@ -0,0 +1,58 @@ +package cust.com.rac.changename; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class ChangeNameHandler extends AbstractHandler { + /** + * The constructor. + */ + public ChangeNameHandler() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + TCSession session=(TCSession) AIFUtility.getCurrentApplication().getSession(); + TCComponent inter=(TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + try { + TCComponentUser user=session.getUser(); + String userTarget=inter.getProperty("owning_user"); + boolean flag1=false; + System.out.println("=====userTarget==========="+userTarget); + System.out.println("======user.toString()=========="+user.toString()); + if(userTarget.equals(user.toString())){ + flag1=true; + } + boolean flag=session.getCurrentGroup().isDBA(); + if(flag||flag1){ + ChangeNameAction action=new ChangeNameAction(AIFUtility.getCurrentApplication(),""); + new Thread(action).start(); + }else{ + MessageBox.post("ǶߣȨġԱϵ!", "ʾ", 2); + return null; + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } +} + diff --git a/src/cust/com/rac/integration/AccepComHandler.java b/src/cust/com/rac/integration/AccepComHandler.java new file mode 100644 index 0000000..7923a77 --- /dev/null +++ b/src/cust/com/rac/integration/AccepComHandler.java @@ -0,0 +1,48 @@ +package cust.com.rac.integration; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class AccepComHandler extends AbstractHandler{ + + private TCSession tcsession = null; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent aifComponent = app.getTargetComponent(); + tcsession = (TCSession) app.getSession(); + + if(aifComponent == null){ + MessageBox.post("ѡίе汾", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + + if( aifComponent instanceof TCComponentItemRevision){ + TCComponentItemRevision AccepComRevision = (TCComponentItemRevision)aifComponent; + String itemRevType = AccepComRevision.getType(); + if(itemRevType.equals("YSR8_AccepComRevision")){ + String url = tcsession.getPreferenceService().getString(TCPreferenceService.TC_preference_site, "Cust_PLM_To_BPM_URL"); + String msg = InterationOperation.sendAccepComToBPM(AccepComRevision, url); + MessageBox.post(msg, "Ϣʾ", MessageBox.INFORMATION); + }else{ + MessageBox.post("ѡIJίеѡȷļ", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + }else{ + MessageBox.post("ѡίе汾", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + return null; + } + +} diff --git a/src/cust/com/rac/integration/DeliveryApplicationHandler.java b/src/cust/com/rac/integration/DeliveryApplicationHandler.java new file mode 100644 index 0000000..51b0f7e --- /dev/null +++ b/src/cust/com/rac/integration/DeliveryApplicationHandler.java @@ -0,0 +1,48 @@ +package cust.com.rac.integration; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DeliveryApplicationHandler extends AbstractHandler{ + + private TCSession tcsession = null; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent aifComponent = app.getTargetComponent(); + tcsession = (TCSession) app.getSession(); + + if(aifComponent == null){ + MessageBox.post("ѡ񷢻뵥汾", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + + if( aifComponent instanceof TCComponentItemRevision){ + TCComponentItemRevision DeliveryRevision = (TCComponentItemRevision)aifComponent; + String itemRevType = DeliveryRevision.getType(); + if(itemRevType.equals("YSR8_DeliveryRevision")){ + String url = tcsession.getPreferenceService().getString(TCPreferenceService.TC_preference_site, "Cust_PLM_To_BPM_URL"); + String msg = InterationOperation.sendDeliveryApplicationToBPM(DeliveryRevision, url); + MessageBox.post(msg, "Ϣʾ", MessageBox.INFORMATION); + }else{ + MessageBox.post("ѡIJǷ뵥ѡȷļ", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + }else{ + MessageBox.post("ѡ񷢻뵥汾", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + return null; + } + +} diff --git a/src/cust/com/rac/integration/InterationOperation.java b/src/cust/com/rac/integration/InterationOperation.java new file mode 100644 index 0000000..809270d --- /dev/null +++ b/src/cust/com/rac/integration/InterationOperation.java @@ -0,0 +1,838 @@ +package cust.com.rac.integration; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.regex.Pattern; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.XMLWriter; + +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +@SuppressWarnings("deprecation") +public class InterationOperation { + + private static String totalCost = ""; + private static String norobotCost = ""; + private static int startRow = 0; + private static int stepNo = 1; + private static HashMap jqrbt; + private static DecimalFormat df = new DecimalFormat(".00"); + private static String[] stations = new String[] { "", "", "", "", "" }; + + public static String sendProjectPlanToBPM(TCComponentItemRevision itemRevision, String url){ + + String errMsg = ""; + + try { + TCComponentForm masterForm = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev"); +// String itemInfo = XMLDocAPI.createProjectPlanXML(masterForm, itemRevision.getProperty("project_ids"));// lidy20190603ַ + String itemInfo = XMLDocAPI.createProjectPlanXML(masterForm, itemRevision.getProperty("project_ids")) + .replaceAll("%26", "&").replaceAll("%3C", "<").replaceAll("%3E", ">").replaceAll("%27", "'") + .replaceAll("%22", """); + if( !itemInfo.startsWith("Error")){ + System.out.println("deliveryInfo = "+itemInfo); + String subUrl = url + "method=Submit&from_system_id=PLM&process=%e9%a1%b9%e7%9b%ae%e8%bf%9b%e5%ba%a6"; + String requestXML = RequestServer.request(subUrl, itemInfo); + if(!requestXML.startsWith("Error")){ + System.out.println("sendProjectPlanToBPM errMsg = "+requestXML); + errMsg = XMLDocAPI.readXmlErrorMsg(requestXML); + }else{ + errMsg = requestXML; + } + if(errMsg.equals("")){ + TCComponent[] components = itemRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length != 0) { + for (TCComponent comp : components) { + if (comp instanceof TCComponentDataset) { + TCComponentDataset dataSet = (TCComponentDataset)comp; + if ((dataSet.getTcFiles() != null) && (dataSet.getTcFiles().length > 0)) { + TCComponentTcFile tcFile = dataSet.getTcFiles()[0]; + String fileName = tcFile.getProperty("original_file_name"); + File file = tcFile.getFile(System.getenv("temp"), fileName); + if(file != null){ +// subUrl = url + "from_system_id=PLM&process=%e9%a1%b9%e7%9b%ae%e8%bf%9b%e5%ba%a6&taskid=" +// +XMLDocAPI.readXmlTaskID(requestXML);//itemRevision.getProperty("item_id"); + subUrl = "http://192.168.0.69:3378/YZSoft/Attachment/Upload.ashx?from_system_id=PLM&process" + + "=%e9%a1%b9%e7%9b%ae%e8%bf%9b%e5%ba%a6&taskid="+XMLDocAPI.readXmlTaskID(requestXML); + System.out.println("subUrl="+subUrl); + errMsg = RequestServer.sendFile(subUrl, file.getAbsolutePath()); + if(!errMsg.startsWith("Error")){ + System.out.println("sendFileToBPM errMsg = "+errMsg); + errMsg = XMLDocAPI.readXmlErrorMsg(errMsg); + } + } + } + break; + } + } + } + } + if(errMsg.equals("")){ + errMsg = "ݳɹ!"; + } + }else{ + errMsg = itemInfo; + } + } catch (TCException e) { + errMsg = e.getMessage(); + e.printStackTrace(); + } + return errMsg; + } + + public static String sendDeliveryApplicationToBPM(TCComponentItemRevision DeliveryRevision, String url){ + + String errMsg = ""; + + try { + TCComponentForm masterForm = (TCComponentForm) DeliveryRevision.getRelatedComponent("IMAN_master_form_rev"); + String deliveryInfo = XMLDocAPI.createDeliveryApplicationXML(masterForm); + if( !deliveryInfo.startsWith("Error")){ + System.out.println("deliveryInfo = "+deliveryInfo); + url = url + "method=Submit&from_system_id=PLM&process=%e5%8f%91%e8%b4%a7%e7%94%b3%e8%af%b7%e5%8d%95"; + errMsg = RequestServer.request(url, deliveryInfo); + if(!errMsg.startsWith("Error")){ + System.out.println("errMsg = "+errMsg); + errMsg = XMLDocAPI.readXmlErrorMsg(errMsg); + } + if(errMsg.equals("")){ + errMsg = "ݳɹ!"; + } + }else{ + errMsg = deliveryInfo; + } + } catch (TCException e) { + errMsg = e.getMessage(); + e.printStackTrace(); + } + return errMsg; + } + + public static String sendAccepComToBPM(TCComponentItemRevision AccepComRevision, String url){ + + String errMsg = ""; + + try { + TCComponentForm masterForm = (TCComponentForm) AccepComRevision.getRelatedComponent("IMAN_master_form_rev"); + // lidy20190603ַ +// String acceptComInfo = XMLDocAPI.createAcceptComInfoXML(masterForm, AccepComRevision.getProperty("item_id")); + String acceptComInfo = XMLDocAPI.createAcceptComInfoXML(masterForm, AccepComRevision.getProperty("item_id")) + .replaceAll("%26", "&").replaceAll("%3C", "<").replaceAll("%3E", ">").replaceAll("%27", "'") + .replaceAll("%22", """); + if( !acceptComInfo.startsWith("Error")){ + System.out.println("deliveryInfo = "+acceptComInfo); + url = url + "method=Submit&from_system_id=PLM&process=%e9%aa%8c%e6%94%b6%e5%a7%94%e6%89%98"; + errMsg = RequestServer.request(url, acceptComInfo); + if(!errMsg.startsWith("Error")){ + System.out.println("errMsg = "+errMsg); + errMsg = XMLDocAPI.readXmlErrorMsg(errMsg); + } + if(errMsg.equals("")){ + errMsg = "ݳɹ!"; + } + }else{ + errMsg = acceptComInfo; + } + } catch (TCException e) { + errMsg = e.getMessage(); + e.printStackTrace(); + } + return errMsg; + } + + public static String sendQuotationApplicationToBPM(TCSession session, TCComponentItemRevision quotationRevision, String url){ + System.out.println("sendQuotationApplicationToBPM"); + + String errMsg = ""; + jqrbt = new HashMap(); + FileInputStream in = null; + + try { + TCComponentForm masterForm = (TCComponentForm) quotationRevision.getRelatedComponent("IMAN_master_form_rev"); + Date finished = masterForm.getDateProperty("ysr8_FinishedDate");//lidy20181108ڲΪղ + if(finished!=null) { + return "ñɴݣظݣ"; + } + TCComponent quotationMX = null; + TCComponent quotationFA = null; + String tempName = ""; + + String itemID = quotationRevision.getProperty("item_id"); + String version = quotationRevision.getProperty("item_revision_id");//lidy20181106Ӱ汾 + TCComponent[] relatedComs = quotationRevision.getRelatedComponents(); + int cnt = relatedComs.length; + + for(int ix = 0; ix < cnt; ix++){ + tempName = relatedComs[ix].getProperty("object_name"); + if(tempName.startsWith(itemID+"MX")){ + quotationMX = relatedComs[ix]; +// }else if(tempName.equals(itemID+"FA.docx") || tempName.equals(itemID+"FA.doc")){//lidy20180925ݼƼӺ׺ + }else if(tempName.startsWith(itemID+"FA")){//lidy20180925ݼƼӺ׺ + quotationFA = relatedComs[ix]; + } + } + + if(quotationMX != null && quotationMX.getType().equals("MSExcelX")){ + TCComponentDataset dataset = (TCComponentDataset) quotationMX; + if(dataset.getTcFiles() != null){ + File file = dataset.getTcFiles()[0].getFile(System.getenv("temp")); + System.out.println("file:"+file.getPath()); + + in = new FileInputStream(file);// + System.out.println("in"); + XSSFWorkbook wb = new XSSFWorkbook(in); + System.out.println("wb:"+wb.getNumberOfSheets()); + XSSFSheet sheet = wb.getSheetAt(0); + + Document document = DocumentHelper.createDocument(); + Element FormData = document.addElement("FormData"); + +// readBaseInfo(sheet, FormData, itemID, version, masterForm.getProperty("ysr8_Remark")); + System.out.println("readBaseInfo"); + readBaseInfo(sheet, FormData, itemID, version, quotationRevision.getItem().getProperty("ysr8_QuotationRemarks")); + System.out.println("getTotalCostMX"); + getTotalCostMX(sheet, FormData); + System.out.println("getLabourCostMX"); + getLabourCostMX(sheet, FormData); + System.out.println("getWorkStation"); + + int sheetCount = wb.getNumberOfSheets(); + for(int ix = 1; ix < sheetCount; ix++){ + sheet = wb.getSheetAt(ix); + if(isInteger(sheet.getSheetName())){ + getWorkStation(sheet,FormData); + } + } + in.close(); + + XMLWriter xmlWriter = null; + StringWriter stringWrite = new StringWriter(); + + OutputFormat format = OutputFormat.createPrettyPrint(); //תַʽ + format.setEncoding("UTF-8"); + format.setNewlines(true); + + //ַ + xmlWriter = new XMLWriter(stringWrite, format); + xmlWriter.write(document); + xmlWriter.flush(); + xmlWriter.close(); + //lidy20190314ַ +// String msg = stringWrite.toString().replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">") +// .replaceAll("'", "'").replaceAll("\"", """); + String msg = stringWrite.toString().replaceAll("%26", "&").replaceAll("%3C", "<").replaceAll("%3E", ">") + .replaceAll("%27", "'").replaceAll("%22", """); + System.out.println("msg="+msg); + + String subUrl = url + "method=Submit&from_system_id=PLM&process=%e6%8a%a5%e4%bb%b7%e6%b8%85%e5%8d%95%e6%95%b0%e6%8d%ae"; + String requestXML = RequestServer.request(subUrl, msg); + if(!requestXML.startsWith("Error")){ + System.out.println("sendProjectPlanToBPM errMsg = "+requestXML); + errMsg = XMLDocAPI.readXmlErrorMsg(requestXML); + }else{ + errMsg = requestXML; + } + + if(errMsg.equals("")){ + String taskid = XMLDocAPI.readXmlTaskID(requestXML); + subUrl = "http://192.168.0.69:3378/YZSoft/Attachment/Upload.ashx?from_system_id=PLM&process=" + + "%e6%8a%a5%e4%bb%b7%e6%b8%85%e5%8d%95%e6%95%b0%e6%8d%ae&taskid="+taskid; + System.out.println("subUrl="+subUrl); + errMsg = RequestServer.sendFile(subUrl, file.getAbsolutePath()); + if(!errMsg.startsWith("Error")){ + System.out.println("sendFileToBPM errMsg = "+errMsg); + errMsg = XMLDocAPI.readXmlErrorMsg(errMsg); + } + +// if(quotationFA != null && (quotationMX.getType().equals("MSWordX") || quotationMX.getType().equals("MSWord"))){ + if(quotationFA != null){ + dataset = (TCComponentDataset) quotationFA; + if(dataset.getTcFiles() != null){ + file = dataset.getTcFiles()[0].getFile(System.getenv("temp")); + errMsg = RequestServer.sendFile(subUrl, file.getAbsolutePath()); + if(!errMsg.startsWith("Error")){ + System.out.println("sendFileToBPM errMsg = "+errMsg); + errMsg = XMLDocAPI.readXmlErrorMsg(errMsg); + } + } + } + + if(errMsg.equals("")){ + errMsg = "ݳɹ!"; + if(masterForm != null){ + //lidy20181108Ѵݰ汾 + TCComponentItem quotation = quotationRevision.getItem(); + String ysr8_HistoricRev = quotation.getStringProperty("ysr8_HistoricRev"); + if(ysr8_HistoricRev.isEmpty()) { + ysr8_HistoricRev = version; + } else { + ysr8_HistoricRev = ysr8_HistoricRev+","+version; + } + String params = quotation.getUid() + "^^^^ysr8_HistoricRev^^^^" + ysr8_HistoricRev; + String cmd = "Update_Item_TCProperty"; + Object[] objParams = new Object[2]; + objParams[0] = cmd; + objParams[1] = params; + TCUserService userService = session.getUserService(); + String result = (String) userService.call("YSR8UserService", objParams); + System.out.println("Itemԣ"+result); + +// Calendar cal = Calendar.getInstance(); + +// System.out.println("ysr8_FinishedDate:"+cal.getTime()+"--ysr8_OfferAmount:"+totalCost+"--jqrbt:"+jqrbt.size()); + + // 20191029ȡAʱ + if(!version.equals("A")) { + TCComponentForm formA = (TCComponentForm)getItemRevisionFromItem(quotation, "A") + .getRelatedComponent("IMAN_master_form_rev"); + masterForm.setDateProperty("ysr8_FinishedDate", formA.getDateProperty("ysr8_FinishedDate")); + }else + masterForm.setDateProperty("ysr8_FinishedDate", new Date()); + if(totalCost.isEmpty()) + totalCost = "0"; + masterForm.setProperty("ysr8_OfferAmount", totalCost); + StringBuffer robotModelAndNum = new StringBuffer(); + for (String s : jqrbt.keySet()) { + System.out.println(s+""+jqrbt.get(s)); + robotModelAndNum.append(s).append("").append(jqrbt.get(s)).append(";"); + } + System.out.println("key:" + robotModelAndNum); + masterForm.setProperty("ysr8_RobotModelAndNum", robotModelAndNum.toString()); + + masterForm.setProperty("ysr8_NoRobotCost", norobotCost);//TODO + masterForm.setProperty("ysr8_RobotCount", stations[0]); + masterForm.setProperty("ysr8_Positioner", stations[1]); + masterForm.setProperty("ysr8_Fixture", stations[2]); + masterForm.setProperty("ysr8_Grid", stations[3]); + masterForm.setProperty("ysr8_Attachment", stations[4]); + } + } + } + } + } else { + errMsg="δҵȷıϸ"; + } + + } catch (Exception e) { + errMsg = ""+e.getMessage(); + e.printStackTrace(); + }finally { + if(in != null) + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return errMsg; + } + + private static void readBaseInfo(XSSFSheet sheet, Element FormData, String itemID, String version, String remark){ + + String customerName = ""; + String projectName = ""; + String validityPeriod = ""; + String manuCycle = ""; +// String totalCost = ""; + String quotationOrderNo = ""; + String quoteDate = ""; + String approver = ""; + String reviewer = ""; + String creator = ""; + +// sheet.setForceFormulaRecalculation(true); + XSSFRow row = sheet.getRow(5); + if(row != null){ + XSSFCell cell = row.getCell(1); + if(cell != null){ + customerName = cell.getStringCellValue(); + } + cell = row.getCell(6); + if(cell != null){ + quotationOrderNo = cell.getStringCellValue(); + } + } + row = sheet.getRow(6); + if(row != null){ + XSSFCell cell = row.getCell(1); + if(cell != null){ + projectName = cell.getStringCellValue(); + } + cell = row.getCell(6); + if(cell != null){ + //lidy20190301֧ڸʽ + if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC && DateUtil.isCellDateFormatted(cell)) { + quoteDate = String.format("%tF", cell.getDateCellValue()).replaceAll("-0", "-").replaceAll("-", "."); + }else + quoteDate = cell.getStringCellValue(); + } + } + row = sheet.getRow(7); + if(row != null){ + XSSFCell cell = row.getCell(1); + if(cell != null){ + validityPeriod = cell.getStringCellValue(); + } + } + row = sheet.getRow(8); + if(row != null){ + XSSFCell cell = row.getCell(1); + if(cell != null){ + manuCycle = cell.getStringCellValue(); + } + cell = row.getCell(5); + if(cell != null){ + approver = cell.getStringCellValue(); + } + cell = row.getCell(6); + if(cell != null){ + reviewer = cell.getStringCellValue(); + } + cell = row.getCell(7); + if(cell != null){ + creator = cell.getStringCellValue(); + } + } + row = sheet.getRow(9); + if(row != null){ + XSSFCell cell = row.getCell(1); + if(cell != null){ + int type = cell.getCellType(); + if(type==XSSFCell.CELL_TYPE_FORMULA || type==XSSFCell.CELL_TYPE_BLANK) { + totalCost = df.format(cell.getNumericCellValue()); + if(totalCost.equals(".00")) + totalCost = ""; + }else { + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + totalCost = cell.getStringCellValue(); + } + } + } + row = sheet.getRow(10); + if(row != null){ + XSSFCell cell = row.getCell(1); + if(cell != null){ + int type = cell.getCellType(); + if(type==XSSFCell.CELL_TYPE_FORMULA || type==XSSFCell.CELL_TYPE_BLANK) { + norobotCost = df.format(cell.getNumericCellValue()); + if(norobotCost.equals(".00")) + norobotCost = ""; + }else { + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + norobotCost = cell.getStringCellValue(); + } + } + } + +// System.out.println("ͻ="+customerName); +// System.out.println("Ŀ="+projectName); +// System.out.println("Ч="+validityPeriod); +// System.out.println("="+manuCycle); +// System.out.println("ɱܽ="+totalCost); +// System.out.println("ίе="+quotationOrderNo); +// System.out.println("ʱ="+quoteDate); +// System.out.println("׼="+approver); +// System.out.println("="+reviewer); +// System.out.println("="+creator); + + Element home1 = FormData.addElement("Home1"); + home1.addElement("PLMItemID").addText(itemID); + try { + home1.addElement("ysr8_CustomerName").addText(URLEncoder.encode(customerName,"UTF-8")); + home1.addElement("ysr8_ProjectName").addText(URLEncoder.encode(projectName,"UTF-8")); + home1.addElement("ysr8_Version").addText(version); + home1.addElement("ValidityPeriod").addText(URLEncoder.encode(validityPeriod,"UTF-8")); + home1.addElement("ManuCycle").addText(URLEncoder.encode(manuCycle,"UTF-8")); + home1.addElement("TotalCost").addText(URLEncoder.encode(totalCost,"UTF-8")); + home1.addElement("QuotationOrderNo").addText(URLEncoder.encode(quotationOrderNo,"UTF-8")); + home1.addElement("QuoteDate").addText(URLEncoder.encode(quoteDate,"UTF-8")); + home1.addElement("Approver").addText(URLEncoder.encode(approver,"UTF-8")); + home1.addElement("Reviewer").addText(URLEncoder.encode(reviewer,"UTF-8")); + home1.addElement("Creator").addText(URLEncoder.encode(creator,"UTF-8")); + home1.addElement("ysr8_Remark").addText(URLEncoder.encode(remark,"UTF-8")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + private static void getTotalCostMX(XSSFSheet sheet, Element FormData) throws UnsupportedEncodingException{ + + startRow = 11; + XSSFRow row = sheet.getRow(startRow); + while(startRow<20){ + row = sheet.getRow(startRow); + if(row != null){ + XSSFCell cell = row.getCell(0); + if(cell != null){ + if(cell.getStringCellValue().equals("ɱܽϸ")){ + break; + }else{ + startRow++; + } + } + } + } + + if(startRow<20){ + startRow+=3; + } + System.out.println("ɱܽϸstartRow="+startRow); + int[] cols = new int[] { 7, 9 }; + row = sheet.getRow(startRow-1); + XSSFCell cell = row.getCell(5); + if(cell != null && cell.getRichStringCellValue().toString().equals("۸")){//TODO Price + cols = new int[] { 5, 6 }; + } + + String cValue = ""; + row = sheet.getRow(startRow); + while(row != null ){ + cell = row.getCell(1); + if(cell != null){ +// System.out.println(row.getCell(0).getRawValue() + ";"+row.getCell(1).getRichStringCellValue()+";"+row.getCell(2).getRawValue() +// +";"+row.getCell(3).getRawValue()+";"+row.getCell(4).getRawValue()+";"+row.getCell(5).getRawValue() +// +";"+row.getCell(6).getRawValue()); + if(cell.getRichStringCellValue().toString().equals("ϼ")) { + cValue = row.getCell(2).getRawValue(); + stations[0] = cValue==null? "":cValue; + + cValue = row.getCell(3).getRawValue(); + stations[1] = cValue==null? "":cValue; + + cValue = row.getCell(4).getRawValue(); + stations[2] = cValue==null? "":cValue; + + if(cols[0]==7) { + cValue = row.getCell(5).getRawValue(); + stations[3] = cValue==null? "":cValue; + + cValue = row.getCell(6).getRawValue(); + stations[4] = cValue==null? "":cValue; + } + + break; + } + + Element home2 = FormData.addElement("Home2"); + home2.addElement("RelationRowGuid").addText(String.valueOf(stepNo++)); + home2.addElement("RowPrimaryKeys"); + + cValue = row.getCell(0).getRawValue(); + cValue = cValue==null?"":cValue; + home2.addElement("SerialNo").addText(cValue); + + cValue = cell.getRichStringCellValue().toString(); + cValue = cValue==null?"":cValue; + home2.addElement("WorkStationName").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(2).getRawValue(); + cValue = cValue==null?"":cValue; + home2.addElement("RobotSystem").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(3).getRawValue(); + cValue = cValue==null?"":cValue; + home2.addElement("Positioner").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(4).getRawValue(); + cValue = cValue==null?"":cValue; + home2.addElement("Fixture").addText(URLEncoder.encode(cValue,"UTF-8")); + +// cValue = row.getCell(5).getRawValue(); +// cValue = cValue==null?"":cValue; +// home2.addElement("Price").addText(URLEncoder.encode(cValue,"UTF-8")); + cValue = getNum(row.getCell(cols[0])); + home2.addElement("Price").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(cols[1]).getStringCellValue(); + cValue = cValue==null?"":cValue; + home2.addElement("Remark").addText(URLEncoder.encode(cValue,"UTF-8")); + + row = sheet.getRow(++startRow); + + }else{ + break; + } + } + } + + private static void getLabourCostMX(XSSFSheet sheet, Element FormData) throws UnsupportedEncodingException{ + + startRow+= 2; + int rowCount = sheet.getLastRowNum(); + XSSFRow row = sheet.getRow(startRow); + while(startRow"+cValue+";"+cell.getCellType()); + + Element home4 = FormData.addElement("Home4"); + home4.addElement("RelationRowGuid").addText(String.valueOf(stepNo++)); + home4.addElement("RowPrimaryKeys"); + home4.addElement("WorkStationName").addText(URLEncoder.encode(WorkStationName,"UTF-8")); + + cValue = cValue==null?"":cValue; + home4.addElement("SerialNo").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(1).getRichStringCellValue().toString(); + cValue = cValue==null?"":cValue; + home4.addElement("Name").addText(URLEncoder.encode(cValue,"UTF-8")); + isFind = cValue.equals("˱"); + + modelName = row.getCell(2).getRichStringCellValue().toString(); + modelName = modelName==null?"":modelName; + home4.addElement("Model").addText(URLEncoder.encode(modelName,"UTF-8")); + + XSSFCell countCell = row.getCell(3); + if (countCell == null) { + cValue = ""; + } else if (countCell.getCellType()==0) { + double numericValue = countCell.getNumericCellValue(); + // ʽΪλСѧ + System.out.println("numericValue==="+numericValue); + cValue = String.format("%.2f", numericValue); + } else { + cValue = countCell.getStringCellValue(); + } + cValue = cValue == null ? "" : cValue; + + System.out.println("cValue=="+cValue); + + home4.addElement("Count").addText(URLEncoder.encode(cValue, "UTF-8")); + + + + + if( isFind ){ + if(jqrbt.get(modelName) != null){ + jqrbt.put(modelName,jqrbt.get(modelName)+ parseToInt(cValue)); + }else{ + jqrbt.put(modelName, parseToInt(cValue)); + } + } + + cValue = row.getCell(4)==null?"":row.getCell(4).getStringCellValue(); + cValue = cValue==null?"":cValue; + home4.addElement("Unit").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(5)==null?"":row.getCell(5).getRawValue(); + cValue = cValue==null?"":cValue; + home4.addElement("UnitPrice").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(6)==null?"":row.getCell(6).getRawValue(); + cValue = cValue==null?"":cValue; + home4.addElement("DesignFee").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(7)==null?"":row.getCell(7).getRawValue(); + cValue = cValue==null?"":cValue; + home4.addElement("TotalPrice").addText(URLEncoder.encode(cValue,"UTF-8")); + +// System.out.println(sheet.getSheetName()+">"+row.getRowNum()+">"+row.getLastCellNum()); +// System.out.println("cell:"+row.getCell(8)); + cValue = row.getCell(8)==null?"":row.getCell(8).getStringCellValue(); + cValue = cValue==null?"":cValue; + home4.addElement("Brand").addText(URLEncoder.encode(cValue,"UTF-8")); + + cValue = row.getCell(9)==null?"":row.getCell(9).getStringCellValue(); + cValue = cValue==null?"":cValue; + home4.addElement("Remark").addText(URLEncoder.encode(cValue,"UTF-8")); + + } + } + + } + + /* + * жǷΪ + * + * @param str ַ + * + * @return true,򷵻false + */ + + private static boolean isInteger(String str) { + Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); + return pattern.matcher(str).matches(); + } + private static TCComponentItemRevision getItemRevisionFromItem(TCComponentItem item, String rev) throws TCException { + if (item != null) { +// System.out.println("rev-----" + rev); + AIFComponentContext[] contexts = item.getChildren("revision_list"); + if (contexts != null && contexts.length > 0) { + for (int i = 0; i < contexts.length; i++) { + InterfaceAIFComponent component = contexts[i].getComponent(); + if (component instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) component; + if (revision.getProperty("item_revision_id").equals(rev)) { + return (TCComponentItemRevision) revision; + } + } + } + } + } + return null; + } + private static String getNum(XSSFCell cell) { + String cValue = ""; + int type = cell.getCellType(); +// System.out.println("PriceCell:"+type); + if(type==XSSFCell.CELL_TYPE_FORMULA || type==XSSFCell.CELL_TYPE_BLANK) { + cValue = df.format(cell.getNumericCellValue()); + cValue = cValue.equals(".00") ? "":cValue; + }else { + cValue = cell.getRawValue(); + cValue = cValue==null?"":cValue; + } + return cValue; + } + + + public static int parseToInt(String str) { + if (str == null || str.trim().isEmpty()) { + return 0; + } + try { + return (int) Double.parseDouble(str.trim()); + } catch (NumberFormatException e) { + return 0; + } + } +} diff --git a/src/cust/com/rac/integration/ProjectPlanHandler.java b/src/cust/com/rac/integration/ProjectPlanHandler.java new file mode 100644 index 0000000..e9e6f23 --- /dev/null +++ b/src/cust/com/rac/integration/ProjectPlanHandler.java @@ -0,0 +1,75 @@ +package cust.com.rac.integration; + +import java.io.UnsupportedEncodingException; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ProjectPlanHandler extends AbstractHandler{ + + private TCSession tcsession = null; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent aifComponent = app.getTargetComponent(); + tcsession = (TCSession) app.getSession(); + + if(aifComponent == null){ + MessageBox.post("ѡ汾ִд˹ܣ", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + if( aifComponent instanceof TCComponentItemRevision){ + TCComponentItemRevision itemRevision = (TCComponentItemRevision)aifComponent; + String itemRevType = itemRevision.getType(); + + String url = tcsession.getPreferenceService().getString(TCPreferenceService.TC_preference_site, "Cust_PLM_To_BPM_URL"); + + String msg = InterationOperation.sendProjectPlanToBPM(itemRevision, url); + MessageBox.post(msg, "Ϣʾ", MessageBox.INFORMATION); + + }else{ + MessageBox.post("ѡ汾ִд˹ܣ", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + return null; + } + + public Object execute_test(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String url = "http://192.168.0.69:3378/YZSoft/BPM/Services/Post.ashx?method=Submit&from_system_id=PLM&process=%e9%a1%b9%e7%9b%ae%e8%bf%9b%e5%ba%a6"; + String name = ""; + + try { + String xml = ""+ + ""+ + ""+ + ""+ + ""+java.net.URLEncoder.encode(name, "UTF-8")+""+ + "chenxiuli"+ + "2017-09-22 00:00:00"+ + "YSR-1111111"+ + ""+ + ""+ + ""; + String paramsXML = java.net.URLEncoder.encode(xml, "UTF-8"); +// String rs = RequestServer.request(url, xml); + String rs = RequestServer.sendFile(url, "C:\\Ľ鵥.pdf"); + System.out.println("request="+rs); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cust/com/rac/integration/QuotationListHandler.java b/src/cust/com/rac/integration/QuotationListHandler.java new file mode 100644 index 0000000..e7e355b --- /dev/null +++ b/src/cust/com/rac/integration/QuotationListHandler.java @@ -0,0 +1,49 @@ +package cust.com.rac.integration; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class QuotationListHandler extends AbstractHandler{ + + private TCSession tcsession = null; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent aifComponent = app.getTargetComponent(); + tcsession = (TCSession) app.getSession(); + + if(aifComponent == null){ + MessageBox.post("ѡ񱨼汾ִд˹ܣ", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + + if( aifComponent instanceof TCComponentItemRevision){ + TCComponentItemRevision QuotationRevision = (TCComponentItemRevision)aifComponent; + String itemRevType = QuotationRevision.getType(); + if(itemRevType.equals("YSR8_QuotationRevision")){ + @SuppressWarnings("deprecation") + String url = tcsession.getPreferenceService().getString(TCPreferenceService.TC_preference_site, "Cust_PLM_To_BPM_URL"); + String msg = InterationOperation.sendQuotationApplicationToBPM(tcsession, QuotationRevision, url); + MessageBox.post(msg, "Ϣʾ", MessageBox.INFORMATION); + }else{ + MessageBox.post("ѡIJDZѡȷļ", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + }else{ + MessageBox.post("ѡ񱨼汾", "Ϣʾ", MessageBox.INFORMATION); + return null; + } + return null; + } + +} diff --git a/src/cust/com/rac/integration/RequestServer.java b/src/cust/com/rac/integration/RequestServer.java new file mode 100644 index 0000000..59b722f --- /dev/null +++ b/src/cust/com/rac/integration/RequestServer.java @@ -0,0 +1,147 @@ +package cust.com.rac.integration; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.URL; + +public class RequestServer { + + public static String request( String urlStr, String params ){ + String result = ""; + + HttpURLConnection httpCon = getHttpConnection(urlStr); + if(httpCon == null){ + return "Error:BPMʧ!"; + } + try { + PrintWriter printWriter = new PrintWriter(httpCon.getOutputStream()); + printWriter.print(params); + printWriter.flush(); + printWriter.close(); + + InputStream inputStream = httpCon.getInputStream(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int i = 0; + byte []array = new byte[1024]; + while( (i = inputStream.read(array)) != -1){ + out.write(array, 0, i); + } + result = new String(out.toByteArray(),"GBK"); + } catch (IOException e) { + // TODO Auto-generated catch block + result = "Error:"+e.getMessage(); + e.printStackTrace(); + } + return result; + } + + public static String sendFile( String urlStr, String filePathAndName ){ + + String result = ""; + + try { + HttpURLConnection httpCon = getHttpConnection(urlStr); + if(httpCon == null){ + return "Error:BPMʧ!"; + } + + File file = new File(filePathAndName); + if(!file.exists()){ + return "Error:ļ:"+filePathAndName; + } + String boundary = "----------Ef1ae0gL6GI3KM7Ef1ei4KM7cH2ae0"; + + StringBuffer boundaryBefore = new StringBuffer("--").append(boundary).append("\r\n"); + boundaryBefore.append("Content-Disposition: form-data; name=\"Filename\"\r\n\r\n"); + boundaryBefore.append(file.getName()).append("\r\n").append("--").append(boundary).append("\r\n"); + boundaryBefore.append("Content-Disposition: form-data; name=\"Filedata\"; filename=\"").append(file.getName()).append("\"\r\n"); + boundaryBefore.append("Content-Type: application/octet-stream\r\n\r\n"); + + StringBuffer boundaryAfter = new StringBuffer("\r\n--").append(boundary).append("\r\n"); + boundaryAfter.append("Content-Disposition: form-data; name=\"Upload\"\r\n\r\n"); + boundaryAfter.append("Submit Query\r\n").append("--").append(boundary).append("--\r\n"); + + byte[] boundaryBeforeBytes = boundaryBefore.toString().getBytes("UTF-8"); + byte[] boundaryAfterBytes = boundaryAfter.toString().getBytes("UTF-8"); + + FileInputStream fis = new FileInputStream(filePathAndName);// + int blockLen = fis.available(); + System.out.println("blockLen="+blockLen); + byte dataBytes[] = new byte[blockLen]; + fis.read(dataBytes); + fis.close(); + + byte[] postBytes = new byte[boundaryBeforeBytes.length + dataBytes.length + boundaryAfterBytes.length]; + System.arraycopy(boundaryBeforeBytes, 0, postBytes, 0, boundaryBeforeBytes.length); + System.arraycopy(dataBytes, 0, postBytes, boundaryBeforeBytes.length, dataBytes.length); + System.arraycopy(boundaryAfterBytes, 0, postBytes, boundaryBeforeBytes.length + dataBytes.length, boundaryAfterBytes.length); + + httpCon.setRequestProperty("User-Agent", "HttpUploadTester Console Application"); + httpCon.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); + OutputStream ots = httpCon.getOutputStream(); + DataOutputStream dataOut = new DataOutputStream(ots); + dataOut.write(postBytes); + dataOut.flush(); + dataOut.close(); +// PrintWriter printWriter = new PrintWriter(ots); +//// String sendStr = boundaryBefore.append("------test upload file--------").append(boundaryAfter).toString(); +// String sendStr = boundaryBefore.append(dataBytes).append(boundaryAfter).toString(); +// System.out.println("sendStr = "+sendStr); +// printWriter.print(postBytes);//postBytes +// printWriter.flush(); +// printWriter.close(); + + InputStream inputStream = httpCon.getInputStream(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int i = 0; + byte []array = new byte[1024]; + while( (i = inputStream.read(array)) != -1){ + out.write(array, 0, i); + } + result = new String(out.toByteArray(), "UTF-8"); +// System.out.println("result errMsg = "+result); + + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + result = "Error:"+e.getMessage(); + e.printStackTrace(); + }catch (FileNotFoundException e) { + // TODO Auto-generated catch block + result = "Error:"+e.getMessage(); + e.printStackTrace(); + } + catch (IOException e) { + // TODO Auto-generated catch block + result = "Error:"+e.getMessage(); + e.printStackTrace(); + } + return result; + } + public static HttpURLConnection getHttpConnection(String urlStr ){ + HttpURLConnection httpCon = null; + + try { + URL url = new URL(urlStr); + httpCon = (HttpURLConnection)url.openConnection(); + httpCon.setDoInput(true); + httpCon.setDoOutput(true); + httpCon.setUseCaches(false); + httpCon.setDefaultUseCaches(false); + httpCon.setRequestMethod("POST"); + httpCon.setConnectTimeout(30*1000); + httpCon.setReadTimeout(30*1000); + } catch(Exception er){ + er.printStackTrace(); + } + return httpCon; + } +} diff --git a/src/cust/com/rac/integration/UnicodeInputStream.java b/src/cust/com/rac/integration/UnicodeInputStream.java new file mode 100644 index 0000000..53d28e1 --- /dev/null +++ b/src/cust/com/rac/integration/UnicodeInputStream.java @@ -0,0 +1,100 @@ +package cust.com.rac.integration; + +import java.io.*; + +/** + * This inputstream will recognize unicode BOM marks and will skip bytes if + * getEncoding() method is called before any of the read(...) methods. + * + * Usage pattern: String enc = "ISO-8859-1"; // or NULL to use systemdefault + * FileInputStream fis = new FileInputStream(file); UnicodeInputStream uin = new + * UnicodeInputStream(fis, enc); enc = uin.getEncoding(); // check and skip + * possible BOM bytes InputStreamReader in; if (enc == null) in = new + * InputStreamReader(uin); else in = new InputStreamReader(uin, enc); + */ +public class UnicodeInputStream extends InputStream { + PushbackInputStream internalIn; + boolean isInited = false; + String defaultEnc; + String encoding; + + private static final int BOM_SIZE = 4; + + public UnicodeInputStream(InputStream in, String defaultEnc) { + internalIn = new PushbackInputStream(in, BOM_SIZE); + this.defaultEnc = defaultEnc; + } + + public String getDefaultEncoding() { + return defaultEnc; + } + + public String getEncoding() { + if (!isInited) { + try { + init(); + } catch (IOException ex) { + IllegalStateException ise = new IllegalStateException( + "Init method failed."); + ise.initCause(ise); + throw ise; + } + } + return encoding; + } + + /** + * Read-ahead four bytes and check for BOM marks. Extra bytes are unread + * back to the stream, only BOM bytes are skipped. + */ + protected void init() throws IOException { + if (isInited) + return; + + byte bom[] = new byte[BOM_SIZE]; + int n, unread; + n = internalIn.read(bom, 0, bom.length); + + if ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00) + && (bom[2] == (byte) 0xFE) && (bom[3] == (byte) 0xFF)) { + encoding = "UTF-32BE"; + unread = n - 4; + } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE) + && (bom[2] == (byte) 0x00) && (bom[3] == (byte) 0x00)) { + encoding = "UTF-32LE"; + unread = n - 4; + } else if ((bom[0] == (byte) 0xEF) && (bom[1] == (byte) 0xBB) + && (bom[2] == (byte) 0xBF)) { + encoding = "UTF-8"; + unread = n - 3; + } else if ((bom[0] == (byte) 0xFE) && (bom[1] == (byte) 0xFF)) { + encoding = "UTF-16BE"; + unread = n - 2; + } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)) { + encoding = "UTF-16LE"; + unread = n - 2; + } else { + // Unicode BOM mark not found, unread all bytes + encoding = defaultEnc; + unread = n; + } + // System.out.println("read=" + n + ", unread=" + unread); + + if (unread > 0) + internalIn.unread(bom, (n - unread), unread); + + isInited = true; + } + + public void close() throws IOException { + // init(); + isInited = true; + internalIn.close(); + } + + public int read() throws IOException { + // init(); + isInited = true; + return internalIn.read(); + } +} \ No newline at end of file diff --git a/src/cust/com/rac/integration/XMLDocAPI.java b/src/cust/com/rac/integration/XMLDocAPI.java new file mode 100644 index 0000000..df1bf7a --- /dev/null +++ b/src/cust/com/rac/integration/XMLDocAPI.java @@ -0,0 +1,218 @@ +package cust.com.rac.integration; + +import java.io.FileWriter; +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Iterator; + +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.XMLWriter; + +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; + +public class XMLDocAPI { + + public static String createProjectPlanXML(TCComponentForm masterForm, String project_code){ + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + StringBuffer errMsg = new StringBuffer("Error:"); + try { + TCComponentUser appUer = (TCComponentUser)masterForm.getReferenceProperty("owning_user"); + + Document document = DocumentHelper.createDocument(); + Element FormData = document.addElement("FormData"); + Element pm_project_schedule = FormData.addElement("pm_project_schedule"); + pm_project_schedule.addElement("code").addText(""); + pm_project_schedule.addElement("app_user_name").addText(URLEncoder.encode(appUer.getOSUserName(), "UTF-8")); + pm_project_schedule.addElement("app_user_code").addText(appUer.getUserId()); + pm_project_schedule.addElement("app_date").addText(sdf.format(new Date())); + pm_project_schedule.addElement("project_code").addText(project_code); + pm_project_schedule.addElement("attachment").addText(""); + + XMLWriter xmlWriter = null; + StringWriter stringWrite = new StringWriter(); + + OutputFormat format = OutputFormat.createPrettyPrint(); //תַʽ + format.setEncoding("UTF-8"); + format.setNewlines(true); + + //ַ + xmlWriter = new XMLWriter(stringWrite, format); + xmlWriter.write(document); + xmlWriter.flush(); + xmlWriter.close(); + + return stringWrite.toString(); + + } catch (TCException e) { + // TODO Auto-generated catch block + errMsg.append(e.getMessage()); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + errMsg.append(e.getMessage()); + e.printStackTrace(); + } + + return errMsg.toString(); + } + + public static String createDeliveryApplicationXML(TCComponentForm masterForm){ + + StringBuffer errMsg = new StringBuffer("Error:"); + try { + Document document = DocumentHelper.createDocument(); + Element FormData = document.addElement("FormData"); + Element EF_YSR_ProjuctSendApp_M = FormData.addElement("EF_YSR_ProjuctSendApp_M"); + EF_YSR_ProjuctSendApp_M.addElement("ProjectCode").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ProjectCode"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("code").addText(""); + EF_YSR_ProjuctSendApp_M.addElement("ApplicantName").addText(URLEncoder.encode(masterForm.getProperty("ysr8_Applicant"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("ApplicantCode").addText(""); + EF_YSR_ProjuctSendApp_M.addElement("ApplicantDate").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ApplicantDate"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("ProjectName").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ProjectName"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("CustomerName").addText(URLEncoder.encode(masterForm.getProperty("ysr8_CustomerName"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("TimeRequiremente").addText(URLEncoder.encode(masterForm.getProperty("ysr8_TimeRequiremente"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("DeliveryDate").addText(URLEncoder.encode(masterForm.getProperty("ysr8_DeliveryDate"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("Departure").addText(URLEncoder.encode(masterForm.getProperty("ysr8_Departure"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("Receiver").addText(URLEncoder.encode(masterForm.getProperty("ysr8_Receiver"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("ReceiverPhone").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ReceiverPhone"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("ReceiptAddress").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ReceiptAddress"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("SendInstall").addText(URLEncoder.encode(masterForm.getProperty("ysr8_SendInstall"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("DeliveryContent").addText(URLEncoder.encode(masterForm.getProperty("ysr8_DeliveryContent"), "UTF-8")); + EF_YSR_ProjuctSendApp_M.addElement("ysr8_Fininshed").addText(URLEncoder.encode(masterForm.getProperty("ysr8_Fininshed"), "UTF-8")); + +// FileWriter fileWriter = null; + XMLWriter xmlWriter = null; + StringWriter stringWrite = new StringWriter(); + + OutputFormat format = OutputFormat.createPrettyPrint(); //תַʽ + format.setEncoding("UTF-8"); + format.setNewlines(true); + + //ַ + xmlWriter = new XMLWriter(stringWrite, format); + xmlWriter.write(document); + xmlWriter.flush(); + xmlWriter.close(); + + return stringWrite.toString(); + + } catch (TCException e) { + // TODO Auto-generated catch block + errMsg.append(e.getMessage()); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + errMsg.append(e.getMessage()); + e.printStackTrace(); + } + + return errMsg.toString(); + } + + public static String createAcceptComInfoXML(TCComponentForm masterForm, String item_id){ + + StringBuffer errMsg = new StringBuffer("Error:"); + try { + Document document = DocumentHelper.createDocument(); + Element FormData = document.addElement("FormData"); + Element EF_YSR_AcceptClient_M = FormData.addElement("EF_YSR_AcceptClient_M"); + EF_YSR_AcceptClient_M.addElement("code").addText(""); + EF_YSR_AcceptClient_M.addElement("PLMItemID").addText(URLEncoder.encode(item_id, "UTF-8")); + EF_YSR_AcceptClient_M.addElement("ProjectCode").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ProjectCode"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("SendDate").addText(masterForm.getProperty("ysr8_SendDate")); + EF_YSR_AcceptClient_M.addElement("HopeReceiveDate").addText(masterForm.getProperty("ysr8_HopeReceiveDate")); + EF_YSR_AcceptClient_M.addElement("ProjectName").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ProjectName"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("CustomerName").addText(URLEncoder.encode(masterForm.getProperty("ysr8_CustomerName"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("ProjectManager").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ProjectManager"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("Planner").addText(URLEncoder.encode(masterForm.getProperty("ysr8_Planner"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("Sales").addText(URLEncoder.encode(masterForm.getProperty("ysr8_Sales"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("ProductionState").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ProductionState"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("ProductionDate").addText(masterForm.getProperty("ysr8_ProductionDate")); + EF_YSR_AcceptClient_M.addElement("ProjectState").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ProjectState"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("PlanFinishDate").addText(masterForm.getProperty("ysr8_PlanFinishDate")); + EF_YSR_AcceptClient_M.addElement("DocumentState").addText(URLEncoder.encode(masterForm.getProperty("ysr8_DocumentState"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("PlanSendtDate1").addText(masterForm.getProperty("ysr8_PlanSendtDate1")); + EF_YSR_AcceptClient_M.addElement("SpareParts").addText(URLEncoder.encode(masterForm.getProperty("ysr8_SpareParts"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("PlanSendtDate2").addText(masterForm.getProperty("ysr8_PlanSendtDate2")); + EF_YSR_AcceptClient_M.addElement("CustomerState").addText(URLEncoder.encode(masterForm.getProperty("ysr8_CustomerState"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("Reason1").addText(URLEncoder.encode(masterForm.getProperty("ysr8_Reason1"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("ConfirmContent").addText(URLEncoder.encode(masterForm.getProperty("ysr8_ConfirmContent"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("Others").addText(URLEncoder.encode(masterForm.getProperty("ysr8_Others"), "UTF-8")); + EF_YSR_AcceptClient_M.addElement("OtherContent").addText(URLEncoder.encode(masterForm.getProperty("ysr8_OtherContent"), "UTF-8")); + +// FileWriter fileWriter = null; + XMLWriter xmlWriter = null; + StringWriter stringWrite = new StringWriter(); + + OutputFormat format = OutputFormat.createPrettyPrint(); //תַʽ + format.setEncoding("UTF-8"); + format.setNewlines(true); + + //ַ + xmlWriter = new XMLWriter(stringWrite, format); + xmlWriter.write(document); + xmlWriter.flush(); + xmlWriter.close(); + + return stringWrite.toString(); + + } catch (TCException e) { + // TODO Auto-generated catch block + errMsg.append(e.getMessage()); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + errMsg.append(e.getMessage()); + e.printStackTrace(); + } + + return errMsg.toString(); + } + + public static String readXmlErrorMsg(String xmlDoc) { + + String errMsg = ""; + try { + Document doc = DocumentHelper.parseText(xmlDoc); + Element rootElt = doc.getRootElement(); // ȡڵ +// Iterator iter = rootElt.elementIterator("errmsg"); + errMsg = rootElt.elementTextTrim("errmsg"); + System.out.println("errMsg="+errMsg); +// return URLEncoder.encode(errMsg, "UTF-8"); +// return URLEncoder.encode(errMsg, "GBK"); + } catch (DocumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// } catch (UnsupportedEncodingException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + return errMsg; + } + + public static String readXmlTaskID(String xmlDoc) { + + String taskID = ""; + try { + Document doc = DocumentHelper.parseText(xmlDoc); + Element rootElt = doc.getRootElement(); // ȡڵ + taskID = rootElt.elementTextTrim("taskid"); + } catch (DocumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return taskID; + } +} diff --git a/src/cust/com/rac/integration/test.java b/src/cust/com/rac/integration/test.java new file mode 100644 index 0000000..f3ccb4f --- /dev/null +++ b/src/cust/com/rac/integration/test.java @@ -0,0 +1,112 @@ +package cust.com.rac.integration; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.Charset; + +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.XMLWriter; + +public class test { + + public static void main(String[] args) throws UnsupportedEncodingException { + // TODO Auto-generated method stub + +// String xml = ""+ +// ""+ +// "ʧܷشɹؿ"+ +// ""+ +// "ID"+ +// ""; +// String errMsg = XMLDocAPI.readXmlErrorMsg(xml); +// System.out.println(errMsg); + + //createProjectPlanXML(); + String str = "无效的文"; + + // System.out.println(str.getBytes("UTF-8")); + // str = URLEncoder.encode(str, "GBK"); + // System.out.println(str); + // System.out.println(URLEncoder.encode(str, "UTF-8")); + // ByteArrayInputStream in=new ByteArrayInputStream(str.getBytes()); + OutputStream os = System.out; + try { + os.write(str.getBytes()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + String dc = Charset.defaultCharset().name(); + InputStream is = new ByteArrayInputStream(str.getBytes()); + UnicodeInputStream uin = new UnicodeInputStream(is,dc); + BufferedReader br = new BufferedReader(new InputStreamReader(uin)); + String line = br.readLine(); + while(line != null) + { + System.out.println("line="+line); + line = br.readLine(); + } + + + OutputStreamWriter osw = new OutputStreamWriter(os, dc); + osw.write("111="+str); + osw.close(); + os.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + +// System.out.println(str); +// System.out.println(getUnicode(str)); + } + + public static String getUnicode(String source) { + String result = ""; + + for (int i = 0; i < source.length(); i++) { + result += "\\u"+Integer.toHexString((int) source.charAt(i)); + } + + return result; + } + + public static void createProjectPlanXML(){ + Document document = DocumentHelper.createDocument(); + Element FormData = document.addElement("FormData"); + Element pm_project_schedule = FormData.addElement("pm_project_schedule"); + pm_project_schedule.addElement("code").addText("й"); + + XMLWriter xmlWriter = null; + StringWriter stringWrite = new StringWriter(); + + OutputFormat format = OutputFormat.createPrettyPrint(); //תַʽ + format.setEncoding("UTF-8"); + format.setNewlines(true); + + //ַ + xmlWriter = new XMLWriter(stringWrite, format); + try { + xmlWriter.write(document); + xmlWriter.flush(); + xmlWriter.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + System.out.println(stringWrite.toString()) ; + } +} diff --git a/src/cust/com/rac/workflow/ComparatorTask.java b/src/cust/com/rac/workflow/ComparatorTask.java new file mode 100644 index 0000000..2435e46 --- /dev/null +++ b/src/cust/com/rac/workflow/ComparatorTask.java @@ -0,0 +1,139 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: ComparatorTask.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:42:41 tyl Ini ʼļ +#======================================================================================================= + */ +package cust.com.rac.workflow; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Comparator; +import java.util.Date; + +public class ComparatorTask implements Comparator { + private int count = 0; + + public int compare(Object obj1, Object obj2) { + // Object : id$$$processDate1$$$taskDate1$$$taskFinishDate1 + // id$$$processDate1$$$processName$$$previousTaskFinishDate1 + int returnvalue = 0; + if (obj1 instanceof String) { + String str1 = (String) obj1; + String str2 = (String) obj2; + if (str1.indexOf("$$$") > 0) { + count = 0; + getNum(str1); + if (count == 3) { + // String id1 = str1.substring(0, str1.indexOf("$$$")); + String sep1 = str1.substring(str1.indexOf("$$$") + 3); + String processDate1 = sep1.substring(0, sep1.indexOf("$$$")).trim(); + String processName1 = sep1.substring(sep1.indexOf("$$$") + 3, sep1.lastIndexOf("$$$")).trim(); + String taskCreateDate1 = sep1.substring(sep1.lastIndexOf("$$$") + 3).trim(); + + // String id2 = str2.substring(0, str2.indexOf("$$$")); + String sep2 = str2.substring(str2.indexOf("$$$") + 3); + String processDate2 = sep2.substring(0, sep2.indexOf("$$$")).trim(); + String processName2 = sep2.substring(sep2.indexOf("$$$") + 3, sep2.lastIndexOf("$$$")).trim(); + String taskCreateDate2 = sep2.substring(sep2.lastIndexOf("$$$") + 3).trim(); + + // ̴ʱ併ţϲʱ併 + returnvalue = (compareDate(processDate1, processDate2) == 0 ? (compareStr(processName1, processName2) == 0 ? (compareDate(taskCreateDate1, taskCreateDate2)) : compareStr(processName1, processName2)) : compareDate(processDate2, processDate1)); + } + } + } + return returnvalue; + } + + /** + * compareStrString + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public int compareStr(String o1, String o2) { + String s1 = (String) o1; + String s2 = (String) o2; + if ((s1 == null) || (s1.length() == 0) || (s2 == null) || (s2.length() == 0)) { return 0; } + int len1 = s1.length(); + int len2 = s2.length(); + int n = Math.min(len1, len2); + char v1[] = s1.toCharArray(); + char v2[] = s2.toCharArray(); + int pos = 0; + while (n-- != 0) { + char c1 = v1[pos]; + char c2 = v2[pos]; + + if (c1 != c2) { return c1 - c2; } + pos++; + } + return len1 - len2; + } + + public int compareDate(String strDate1, String strDate2) { + SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date1; + try { + date1 = simpleDate.parse(strDate1); + Date date2 = simpleDate.parse(strDate2); + if (date1.getTime() > date2.getTime()) { + return 1; + } else { + if (date1.getTime() == date2.getTime()) { + return 0; + } else { + return -1; + } + } + } + catch (ParseException e) { + e.printStackTrace(); + return 0; + } + } + + public static void main(String[] args) { + new ComparatorTask().compareDate("01-3-2011 11:17", "02-3-2011 11:17"); + } + + /** + * compareIntint + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public int compareInt(Integer o1, Integer o2) { + int val1 = o1.intValue(); + int val2 = o2.intValue(); + return (val1 < val2 ? -1 : (val1 == val2 ? 0 : 1)); + } + + /** + * compareBooleanBoolean + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public int compareBoolean(Boolean o1, Boolean o2) { + return (o1.equals(o2) ? 0 : (o1.booleanValue() == true ? 1 : -1)); + } + + private void getNum(String name) { + if (name.contains("$$$")) { + count++; + getNum(name.substring(name.indexOf("$$$") + 3)); + } else { + return; + } + } +} diff --git a/src/cust/com/rac/workflow/CustAddReleaseHandler.java b/src/cust/com/rac/workflow/CustAddReleaseHandler.java new file mode 100644 index 0000000..3a8c4ba --- /dev/null +++ b/src/cust/com/rac/workflow/CustAddReleaseHandler.java @@ -0,0 +1,73 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: QueryTaskOpinionHandler.java +#======================================================================================================= +# Date time Name Action Description of Change +# +#======================================================================================================= +*/ +package cust.com.rac.workflow; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAttachmentType; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CustAddReleaseHandler extends AbstractHandler implements IHandler{ + + /* + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + TCPreferenceService preSer = session.getPreferenceService(); + String[] value = preSer.getStringArray(4, "Cust_Release_Templates"); + + if(value == null || value.length < 1){ + MessageBox.post("Cust_Release_Templatesòȷ,ϵԱ", "WARNING", 1); + return null; + } + + TCComponentProcessType procType = (TCComponentProcessType) session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTempType = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemp = taskTempType.find(value[0], TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + + InterfaceAIFComponent[] selectComps = app.getTargetComponents(); + if(selectComps.length > 0){ + int[] intArr = new int[selectComps.length]; + TCComponent[] comps = new TCComponent[selectComps.length]; + for (int i = 0; i < intArr.length; i++) { + intArr[i] = TCAttachmentType.TARGET; + comps[i] = (TCComponent) selectComps[i]; + } + procType.create("Զ", "״̬", taskTemp, comps, intArr, null); + MessageBox.post("״̬ɹ", "Info", 0); + }else{ + MessageBox.post("ѡִд˹,лл", "WARNING", 1); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cust/com/rac/workflow/CustRemoveReleaseHandler.java b/src/cust/com/rac/workflow/CustRemoveReleaseHandler.java new file mode 100644 index 0000000..b238edc --- /dev/null +++ b/src/cust/com/rac/workflow/CustRemoveReleaseHandler.java @@ -0,0 +1,73 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: QueryTaskOpinionHandler.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 10:18:54 tyl Ini ʼļ +#======================================================================================================= +*/ +package cust.com.rac.workflow; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAttachmentType; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CustRemoveReleaseHandler extends AbstractHandler implements IHandler{ + + /* + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + TCPreferenceService preSer = session.getPreferenceService(); + String[] value = preSer.getStringArray(4, "Cust_Release_Templates"); + + if(value == null || value.length < 2){ + MessageBox.post("Cust_Release_Templatesòȷ,ϵԱ", "WARNING", 1); + return null; + } + + TCComponentProcessType procType = (TCComponentProcessType) session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTempType = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemp = taskTempType.find(value[1], TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + + InterfaceAIFComponent[] selectComps = app.getTargetComponents(); + if(selectComps.length > 0){ + int[] intArr = new int[selectComps.length]; + TCComponent[] comps = new TCComponent[selectComps.length]; + for (int i = 0; i < intArr.length; i++) { + intArr[i] = TCAttachmentType.TARGET; + comps[i] = (TCComponent) selectComps[i]; + } + procType.create("Զ", "Ƴ״̬", taskTemp, comps, intArr, null); + MessageBox.post("Ƴ״̬ɹ", "Info", 0); + }else{ + MessageBox.post("ѡִд˹,лл", "WARNING", 1); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cust/com/rac/workflow/ExportSearchResult.java b/src/cust/com/rac/workflow/ExportSearchResult.java new file mode 100644 index 0000000..e57b3be --- /dev/null +++ b/src/cust/com/rac/workflow/ExportSearchResult.java @@ -0,0 +1,159 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: ExportSearchResult.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:43:41 tyl Ini ʼļ +#======================================================================================================= +*/ +package cust.com.rac.workflow; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import jxl.Workbook; +import jxl.read.biff.BiffException; +import jxl.write.Label; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; +import jxl.write.biff.RowsExceededException; +import com.teamcenter.rac.util.MessageBox; + +import cust.com.rac.workflow.SearchResultDialog.SearchResults; + +public class ExportSearchResult { + public ExportSearchResult(List tableInfos, PackExcelInfo excelInfo) { + createExcel(tableInfos, excelInfo); + } + + protected void createExcel(List tableInfos, PackExcelInfo excelInfo) { + Workbook workbook = null; + WritableSheet sourceSheet; + WritableWorkbook writeWorkbook; + File file = new File(excelInfo.getTemplateFileName()); + int listsize = tableInfos.size(); + int pageSize = excelInfo.getPageSize(); + List listTemp = new ArrayList(); + try { + workbook = Workbook.getWorkbook(file); + writeWorkbook = Workbook.createWorkbook(new File(excelInfo.getTargetFileName()), workbook); + sourceSheet = writeWorkbook.getSheet(0); + WritableSheet sheet = writeWorkbook.getSheet(0); + + String sourceSheetName = sourceSheet.getName(); + int page = listsize / pageSize; + if (((listsize % pageSize) > 0)) { + page = page + 1; + } + for (int i = 1; i <= page; i++) { + sheet = null; + listTemp = new ArrayList(); + writeWorkbook.copySheet(sourceSheetName, "" + i + "ҳ", i); + sheet = writeWorkbook.getSheet("" + i + "ҳ"); + for (int j = (i - 1) * pageSize; (j < pageSize * (i)) && ((j < listsize)); j++) { + listTemp.add(tableInfos.get(j)); + } + addDataToExcel(sourceSheet, sheet, listTemp, i, excelInfo); + } + writeWorkbook.removeSheet(0); + writeWorkbook.write(); + writeWorkbook.close(); + } catch (BiffException e1) { + e1.printStackTrace(); + } catch (WriteException e1) { + e1.printStackTrace(); + } catch (IOException e1) { + MessageBox.post(":ļǷʹ,ر", "Ϣʾ", MessageBox.INFORMATION); + e1.printStackTrace(); + } + } + + private void addDataToExcel(WritableSheet sourceSheet, WritableSheet sheet, List listTemp, int currentpage, PackExcelInfo excelInfo) { + int row = excelInfo.getInitRow(); + try { + for (row = 0; row < 34; row++) { + for (int col = 0; col < 15; col++) { + if (row >= 4) { + SearchResults result = (SearchResults) listTemp.get(row - 4); + if (result != null) { + if (col == 0) { + insertCell(sourceSheet, sheet, col, row, result.getIndex()); + } else if (col == 1) { + insertCell(sourceSheet, sheet, col, row, result.getTask_name()); + } else if (col == 2) { + insertCell(sourceSheet, sheet, col, row, result.getTask_executor()); + } else if (col == 3) { + insertCell(sourceSheet, sheet, col, row, result.getTask_createDate()); + } else if (col == 4) { + insertCell(sourceSheet, sheet, col, row, result.getTask_finishDate()); + } else if (col == 5) { + insertCell(sourceSheet, sheet, col, row, result.getTask_status()); + } else if (col == 6) { + insertCell(sourceSheet, sheet, col, row, result.getTask_note()); + } else if (col == 7) { + insertCell(sourceSheet, sheet, col, row, result.getTask_type()); + } else if (col == 8) { + insertCell(sourceSheet, sheet, col, row, result.getProcess_executor()); + } else if (col == 9) { + insertCell(sourceSheet, sheet, col, row, result.getProcess_name()); + } else if (col == 10) { + insertCell(sourceSheet, sheet, col, row, result.getProcess_createDate()); + } else if (col == 11) { + insertCell(sourceSheet, sheet, col, row, result.getProcess_finishDate()); + } else if (col == 12) { + insertCell(sourceSheet, sheet, col, row, result.getProcess_lastModeUser()); + } else if (col == 13) { + insertCell(sourceSheet, sheet, col, row, result.getProcess_status()); + } else if (col == 14) { + insertCell(sourceSheet, sheet, col, row, result.getProcess_templateName()); + } + } + } else { + if ((row == 0) && (col == 0)) { + insertCell(sourceSheet, sheet, col, row, excelInfo.getTitle()); + } else + insertCell(sourceSheet, sheet, col, row, ""); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void insertCell(WritableSheet sourceSheet, WritableSheet sheet, int col, int row, String value) { + try { + if ((value.trim().length() == 0) || (value == null)) { + Label lab = new Label(col, row, sourceSheet.getCell(col, row).getContents()); + if (lab != null) { + if (sourceSheet.getCell(col, row) != null) { + if (sourceSheet.getCell(col, row).getCellFormat() != null) { + lab.setCellFormat(sourceSheet.getCell(col, row).getCellFormat()); + } + } + sheet.addCell(lab); + } + } else { + Label lab = new Label(col, row, value); + if (lab != null) { + if (sourceSheet.getCell(col, row) != null) { + if (sourceSheet.getCell(col, row).getCellFormat() != null) { + lab.setCellFormat(sourceSheet.getCell(col, row).getCellFormat()); + } + } + sheet.addCell(lab); + } + } + } catch (RowsExceededException e) { + e.printStackTrace(); + } catch (WriteException e) { + e.printStackTrace(); + } } + } \ No newline at end of file diff --git a/src/cust/com/rac/workflow/PackExcelInfo.java b/src/cust/com/rac/workflow/PackExcelInfo.java new file mode 100644 index 0000000..056bae4 --- /dev/null +++ b/src/cust/com/rac/workflow/PackExcelInfo.java @@ -0,0 +1,122 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: PackExcelInfo.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:45:50 tyl Ini ʼļ +#======================================================================================================= +*/ +package cust.com.rac.workflow; + +public class PackExcelInfo { + private String templateFileName = "c:\\viewTaskTemplate.xls"; + private int pageSize = 30; + private String targetFileName = "c:\\report.xls"; + private int initRow = 0; + private int initColumn = 0; + private int secondePageSize = 0; + private String title = ""; + + /** + * @return the initRow + */ + public int getInitRow() { + return initRow; + } + + /** + * @param initRow the initRow to set + */ + public void setInitRow(int initRow) { + this.initRow = initRow; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the initColumn + */ + public int getInitColumn() { + return initColumn; + } + + /** + * @param initColumn the initColumn to set + */ + public void setInitColumn(int initColumn) { + this.initColumn = initColumn; + } + + /** + * @return the pageSize + */ + public int getPageSize() { + return pageSize; + } + + /** + * @param pageSize the pageSize to set + */ + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + /** + * @return the targetFileName + */ + public String getTargetFileName() { + return targetFileName; + } + + /** + * @param targetFileName the targetFileName to set + */ + public void setTargetFileName(String targetFileName) { + this.targetFileName = targetFileName; + } + + /** + * @return the templateFileName + */ + public String getTemplateFileName() { + return templateFileName; + } + + /** + * @param templateFileName the templateFileName to set + */ + public void setTemplateFileName(String templateFileName) { + this.templateFileName = templateFileName; + } + + /** + * @return the secondePageSize + */ + public int getSecondePageSize() { + return secondePageSize; + } + + /** + * @param secondePageSize the secondePageSize to set + */ + public void setSecondePageSize(int secondePageSize) { + this.secondePageSize = secondePageSize; + } + +} diff --git a/src/cust/com/rac/workflow/QueryTaskOpinionCommand.java b/src/cust/com/rac/workflow/QueryTaskOpinionCommand.java new file mode 100644 index 0000000..095bf5c --- /dev/null +++ b/src/cust/com/rac/workflow/QueryTaskOpinionCommand.java @@ -0,0 +1,32 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: QueryTaskOpinionCommand.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 10:19:09 tyl Ini ʼļ +#======================================================================================================= +*/ +package cust.com.rac.workflow; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCException; + + +public class QueryTaskOpinionCommand extends AbstractAIFCommand { + + public AbstractAIFUIApplication application; + public QueryTaskOpinionCommand(AbstractAIFUIApplication abstractaifapplication) throws TCException { + application = abstractaifapplication; + execute(); + } + + private void execute() throws TCException { + new QueryTaskOpinionOperation(application,""); + } + +} diff --git a/src/cust/com/rac/workflow/QueryTaskOpinionHandler.java b/src/cust/com/rac/workflow/QueryTaskOpinionHandler.java new file mode 100644 index 0000000..3043cad --- /dev/null +++ b/src/cust/com/rac/workflow/QueryTaskOpinionHandler.java @@ -0,0 +1,44 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: QueryTaskOpinionHandler.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 10:18:54 tyl Ini ʼļ +#======================================================================================================= +*/ +package cust.com.rac.workflow; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class QueryTaskOpinionHandler extends AbstractHandler implements IHandler{ + + /* + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + QueryTaskOpinionCommand command= new QueryTaskOpinionCommand(app); + command.executeModal(); + } + catch (TCException e) { + e.printStackTrace(); + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cust/com/rac/workflow/QueryTaskOpinionOperation.java b/src/cust/com/rac/workflow/QueryTaskOpinionOperation.java new file mode 100644 index 0000000..c89c3a2 --- /dev/null +++ b/src/cust/com/rac/workflow/QueryTaskOpinionOperation.java @@ -0,0 +1,1213 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: QueryTaskOpinion.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 10:29:16 tyl Ini ʼļ +# 2011-4-25 10:38:00 zyn ޸ ʾģʽ޸Ϊʾģʽ +# 2011-5-24 12:02:00 zyn add +#======================================================================================================= + */ +package cust.com.rac.workflow; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; + +import cn.com.customization.util.QueryTaskOpinionTableHead; + +import com.fnd0.services.internal.rac.auditmanager.ProcessHistoryManagementService; +import com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFnd0AuditLog; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.UserList; +import com.teamcenter.rac.processhistory.BaseProcessHistoryEntry; +import com.teamcenter.rac.util.MessageBox; + +public class QueryTaskOpinionOperation { + private Vector taskNameVector; + private Vector vector_infor; + private String firstTaskName = ""; + private List RouteTaskList = new ArrayList(); + private List AcknowladgeTaskList = new ArrayList(); + private List reviewTaskList = new ArrayList(); + private List doTaskList = new ArrayList(); + private List conditionTaskList = new ArrayList(); + private List addStatusTaskList = new ArrayList(); + private List smallTitleList = new ArrayList(); + private Vector tableTitleVector; + private String[] doAndConditionTaskTitle = { "ִ", "ʱ", "ע" }; + private String[] firstTaskTitle = { "ִ", "ύʱ", "ע" }; + private String[] auditingTitle = { "ǩ", "ʱ", "ע" }; + private String[] notifyTitle = { "ǩ", "Ͽʱ", "ע" }; + + private List rootProcessHistory; + private List processNames; + + public QueryTaskOpinionOperation(AbstractAIFUIApplication abstractaifuiapplication, String s) { + this.myuiapp = abstractaifuiapplication; + session = (TCSession) this.myuiapp.getSession(); + run(); + } + + //-----------------------------------------------------*-*- + public void readInfo(InterfaceAIFComponent ainterfaceaifcomponent) { + //InterfaceAIFComponent ainterfaceaifcomponent = myuiapp.getTargetComponent(); + if (ainterfaceaifcomponent != null) { + + ProcessHistoryManagementService processhistorymanagementservice = ProcessHistoryManagementService.getService(session); + com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.GetProcessHistoryAuditRecordsResponse getprocesshistoryauditrecordsresponse = processhistorymanagementservice.getProcssHistoryAuditRecords((TCComponent) ainterfaceaifcomponent); + com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct[] = getprocesshistoryauditrecordsresponse.rootProcessHistoryAuditRecords; + //----------------------------------------------------- + rootProcessHistory = new ArrayList(); + processNames = new ArrayList(); + String as1[]; + int j = (as1 = getprocesshistoryauditrecordsresponse.processNames).length; + for(int i = 0; i < j; i++) + { + String s = as1[i]; + //System.out.println("s================"+s); + processNames.add(s); + } + loadProcessHistoryData(aprocesshistoryauditrecordstruct); +// loadProcessHistoryData(aprocesshistoryauditrecordstruct, rootProcessHistory); +// +// System.out.println("rootProcessHistory.size()="+rootProcessHistory.size()); +// TCComponent comp = ((BaseProcessHistoryEntry)rootProcessHistory.get(0)).getComponent(); +// String[] strNames = comp.getPropertyNames(); +// for(int i = 0; i < strNames.length; i++){ +// System.out.println("strNames["+i+"]="+strNames[i]); +// try { +// System.out.println(comp.getProperty(strNames[i])); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + } + } + + private void loadProcessHistoryData(ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct[]) + { + com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct1[]; + int j = (aprocesshistoryauditrecordstruct1 = aprocesshistoryauditrecordstruct).length; + //System.out.println("j="+j); + String templateName = ""; + String taskType = ""; + String taskName = ""; + String endTime = ""; + String result = ""; + String pzUser = ""; + String comment = ""; + String eventType = ""; + boolean isNotFirstGobak = false; + + for(int i = 0; i < j; i++) + { + com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct processhistoryauditrecordstruct = aprocesshistoryauditrecordstruct1[i]; + BaseProcessHistoryEntry baseprocesshistoryentry = new BaseProcessHistoryEntry(); + if(processhistoryauditrecordstruct.auditRecord != null) + { + try { + if(processhistoryauditrecordstruct.auditRecord.getProperty("fnd0EventTypeName").equals("ɾ")){ + continue; + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct2[] = processhistoryauditrecordstruct.childrenAuditRecords; + for(int k = 0; k < aprocesshistoryauditrecordstruct2.length; k++ ){ + int num = 1; + + try { + templateName = aprocesshistoryauditrecordstruct2[k].auditRecord.getProperty("object_name"); + System.out.println("templateName = "+templateName); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct3[] = aprocesshistoryauditrecordstruct2[k].childrenAuditRecords; + for(int m = 0; m < aprocesshistoryauditrecordstruct3.length; m++){ + if(num != 1){ + templateName = ""; + }else{ + num++; + } + try { + taskType = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("object_type"); + if(taskType.equals("EPMOrTask")){ + continue; + } + eventType = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("fnd0EventTypeName"); + if(eventType.equals("˻")){ + if(isNotFirstGobak){ + continue; + }else{ + isNotFirstGobak = true; + if(taskType.equals("EPMDoTask")){ + taskName = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("object_name"); + endTime = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("fnd0LoggedDate"); + //result = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("task_result"); + comment = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("fnd0Comments"); + SignInfo oneSignInfo = new SignInfo(); + oneSignInfo.processName = templateName; + oneSignInfo.num = num++; + oneSignInfo.taskName = taskName; + oneSignInfo.actionTime = endTime; + oneSignInfo.userAction = "Rejected"; + oneSignInfo.userComments = comment; + pzUser = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("fnd0UserId"); + TCComponentUser tccomponentuser = UserList.getUser(session, "(" + pzUser + ")"); + if (tccomponentuser != null) { + pzUser = tccomponentuser.toString(); + oneSignInfo.userName = pzUser; + } + vector_infor.add(oneSignInfo); + }else{ + taskName = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("object_name"); + getComment( aprocesshistoryauditrecordstruct3[m], templateName, taskName ); + } + } + }else{//else if(!eventType.equals("ʼ")) + isNotFirstGobak = false; + if(taskType.equals("EPMDoTask")||taskType.equals("EPMConditionTask")){ + taskName = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("object_name"); + endTime = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("fnd0LoggedDate"); + result = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("task_result"); + comment = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("fnd0Comments"); + SignInfo oneSignInfo = new SignInfo(); + oneSignInfo.processName = templateName; + oneSignInfo.num = num++; + oneSignInfo.taskName = taskName; + oneSignInfo.actionTime = endTime; + oneSignInfo.userAction = result; + oneSignInfo.userComments = comment; + pzUser = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("fnd0UserId"); + TCComponentUser tccomponentuser = UserList.getUser(session, "(" + pzUser + ")"); + if (tccomponentuser != null) { + pzUser = tccomponentuser.toString(); + oneSignInfo.userName = pzUser; + } + System.out.println("oneSignInfotaskName="+taskName+";user="+pzUser+";endTime="+endTime+";result="+result); + vector_infor.add(oneSignInfo); + } +// else if(taskType.equals("EPMRouteTask")){ +// ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct4[] = aprocesshistoryauditrecordstruct3[m].childrenAuditRecords; +// if(aprocesshistoryauditrecordstruct4.length > 0){ +// taskName = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("object_name"); +// getComment( aprocesshistoryauditrecordstruct4[aprocesshistoryauditrecordstruct4.length-1], templateName, taskName ); +// } +// } + else{ + taskName = aprocesshistoryauditrecordstruct3[m].auditRecord.getProperty("object_name"); + getComment( aprocesshistoryauditrecordstruct3[m], templateName, taskName ); +// vector_infor.add(oneSignInfo); + } + } + + System.out.println("taskName="+taskName+";user="+pzUser+";endTime="+endTime+";result="+result); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + } + System.out.println("--------------------------------------------------------------"); + for (int i = 0; i < vector_infor.size(); i++) { + String taskName1 = ((SignInfo) vector_infor.elementAt(i)).taskName.trim(); + String userAction = ((SignInfo) vector_infor.elementAt(i)).userAction; + System.out.println("taskName="+taskName1+";userAction="+userAction); + } + System.out.println("--------------------------------------------------------------"); + } + + private String getComment( ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct, String templateName, String taskName ){ + + String pzUser = ""; + int cnt = 0; +// String taskName = ""; +// try { +// taskName = aprocesshistoryauditrecordstruct.auditRecord.getProperty("object_name"); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + System.out.println("-----------------------------00"); + ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct1[] = aprocesshistoryauditrecordstruct.childrenAuditRecords; + if( aprocesshistoryauditrecordstruct1 != null ){ + System.out.println("aprocesshistoryauditrecordstruct1.length="+aprocesshistoryauditrecordstruct1.length); + if(aprocesshistoryauditrecordstruct1.length > 1){ + try { + TCComponentFnd0AuditLog auditRecord = aprocesshistoryauditrecordstruct1[aprocesshistoryauditrecordstruct1.length - 1].auditRecord; + if(auditRecord.getProperty("fnd0EventTypeName").equals("")){ +// SignInfo oneSignInfo = new SignInfo(); +// oneSignInfo.actionTime = auditRecord.getProperty("fnd0LoggedDate"); +// oneSignInfo.userAction = auditRecord.getProperty("fnd0EventTypeName"); +// oneSignInfo.userComments = auditRecord.getProperty("fnd0Comments"); +// oneSignInfo.processName = templateName; +// oneSignInfo.taskName = taskName; +// pzUser = auditRecord.getProperty("fnd0UserId"); +// TCComponentUser tccomponentuser = UserList.getUser(session, "(" + pzUser + ")"); +// if (tccomponentuser != null) { +// pzUser = tccomponentuser.toString(); +// oneSignInfo.userName = pzUser; +// } +// System.out.println("getCommenttaskName="+taskName+";user="+pzUser+";endTime="+oneSignInfo.actionTime+";result="+oneSignInfo.userAction ); +// vector_infor.add(oneSignInfo); + auditRecord = aprocesshistoryauditrecordstruct.auditRecord; + TCComponent[] valid_signoffs = auditRecord.getReferenceProperty("fnd0Object").getReferenceListProperty("valid_signoffs"); + for(int ix = 0; ix < valid_signoffs.length; ix++ ){ + SignInfo oneSignInfo = new SignInfo(); + oneSignInfo.actionTime = valid_signoffs[ix].getProperty("decision_date"); + oneSignInfo.userAction = valid_signoffs[ix].getProperty("decision"); + if(oneSignInfo.userAction.endsWith("89")){ + oneSignInfo.userAction = "Ͽ"; + } + oneSignInfo.userComments = valid_signoffs[ix].getProperty("comments"); + oneSignInfo.processName = templateName; + oneSignInfo.taskName = taskName; + oneSignInfo.userName = valid_signoffs[ix].getProperty("fnd0Assignee"); + System.out.println("getCommenttaskName="+taskName+";user="+pzUser+";endTime="+oneSignInfo.actionTime+";result="+oneSignInfo.userAction ); + vector_infor.add(oneSignInfo); + } + }else{ + ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct2[] = aprocesshistoryauditrecordstruct1[aprocesshistoryauditrecordstruct1.length - 1].childrenAuditRecords; + for(cnt = 0; cnt < aprocesshistoryauditrecordstruct2.length; cnt++){ + SignInfo oneSignInfo = new SignInfo(); + + oneSignInfo.actionTime = aprocesshistoryauditrecordstruct2[cnt].auditRecord.getProperty("fnd0LoggedDate"); + oneSignInfo.userAction = aprocesshistoryauditrecordstruct2[cnt].auditRecord.getProperty("fnd0EventTypeName"); + oneSignInfo.userComments = aprocesshistoryauditrecordstruct2[cnt].auditRecord.getProperty("fnd0Comments"); + oneSignInfo.processName = templateName; + oneSignInfo.taskName = taskName; + pzUser = aprocesshistoryauditrecordstruct2[cnt].auditRecord.getProperty("fnd0UserId"); + TCComponentUser tccomponentuser = UserList.getUser(session, "(" + pzUser + ")"); + if (tccomponentuser != null) { + pzUser = tccomponentuser.toString(); + oneSignInfo.userName = pzUser; + } + System.out.println("getCommenttaskName="+taskName+";user="+pzUser+";endTime="+oneSignInfo.actionTime+";result="+oneSignInfo.userAction ); + vector_infor.add(oneSignInfo); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } +// else{ +// try { +// comment = aprocesshistoryauditrecordstruct.auditRecord.getProperty("fnd0Comments"); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + + return ""; + } +// private void loadProcessHistoryData(com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct[], List list) +// { +// com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct1[]; +// int j = (aprocesshistoryauditrecordstruct1 = aprocesshistoryauditrecordstruct).length; +// System.out.println("j="+j); +// for(int i = 0; i < j; i++) +// { +// com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct processhistoryauditrecordstruct = aprocesshistoryauditrecordstruct1[i]; +// BaseProcessHistoryEntry baseprocesshistoryentry = new BaseProcessHistoryEntry(); +// if(processhistoryauditrecordstruct.auditRecord != null) +// { +// try { +// System.out.println("1----"+processhistoryauditrecordstruct.auditRecord.getProperty("object_name")); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// baseprocesshistoryentry.setComponent(processhistoryauditrecordstruct.auditRecord); +// list.add(baseprocesshistoryentry); +// ArrayList arraylist = new ArrayList(); +// com.teamcenter.rac.kernel.TCComponentFnd0SecondaryAudit atccomponentfnd0secondaryaudit[] = processhistoryauditrecordstruct.secondaryAuditRecords; +// com.teamcenter.rac.kernel.TCComponentFnd0SecondaryAudit atccomponentfnd0secondaryaudit1[]; +// int l = (atccomponentfnd0secondaryaudit1 = atccomponentfnd0secondaryaudit).length; +// for(int k = 0; k < l; k++) +// { +// com.teamcenter.rac.kernel.TCComponentFnd0SecondaryAudit tccomponentfnd0secondaryaudit = atccomponentfnd0secondaryaudit1[k]; +// baseprocesshistoryentry = new BaseProcessHistoryEntry(); +// baseprocesshistoryentry.setComponent(tccomponentfnd0secondaryaudit); +// arraylist.add(baseprocesshistoryentry); +// try { +// System.out.println("2----"+tccomponentfnd0secondaryaudit.getProperty("object_name")); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// com.fnd0.services.internal.rac.auditmanager._2012_09.ProcessHistoryManagement.ProcessHistoryAuditRecordStruct aprocesshistoryauditrecordstruct2[] = processhistoryauditrecordstruct.childrenAuditRecords; +// loadProcessHistoryData(aprocesshistoryauditrecordstruct2, ((List) (arraylist))); +// baseprocesshistoryentry.setChildEntries(arraylist); +// } +// } +// +// } + + public void run() { + try { + InterfaceAIFComponent ainterfaceaifcomponent[] = myuiapp.getTargetComponents(); + if (ainterfaceaifcomponent != null) { + + if (ainterfaceaifcomponent.length > 1) { + MessageBox messagebox = new MessageBox("ֻѡһ", "ʾ", MessageBox.WARNING); + messagebox.setModal(true); + messagebox.setVisible(true); + return; + } + if (ainterfaceaifcomponent[0] != null) { + if ((ainterfaceaifcomponent[0] instanceof TCComponentItemRevision) || (ainterfaceaifcomponent[0] instanceof TCComponentTask) || + (ainterfaceaifcomponent[0] instanceof TCComponentDataset) || (ainterfaceaifcomponent[0] instanceof TCComponentForm) + || (ainterfaceaifcomponent[0] instanceof TCComponentFolder)) { + // ֻԣ TCComponentItemRevision, TCComponentTask, + // TCComponentDataset, TCComponentForm ⼸ + if (!(ainterfaceaifcomponent[0] instanceof TCComponentTask)) { + TCComponent com = (TCComponent) ainterfaceaifcomponent[0]; + AIFComponentContext[] aif = com.whereReferenced(); + if (aif != null && aif.length > 0) { + List listProcess = new ArrayList(); + for (int j = 0; j < aif.length; j++) { + TCComponent tccomponent = (TCComponent) aif[j].getComponent(); + if (tccomponent instanceof TCComponentTask) { + System.out.println("----"); + System.out.println("object_name="+((TCComponentTask) tccomponent).getProperty("object_name")); + listProcess.add((TCComponentTask) tccomponent); + } + } + if(listProcess.size()>0){ + viewWfInfo(listProcess,ainterfaceaifcomponent[0]); + }else{ + MessageBox messagebox = new MessageBox("ǰ̣", "ʾ", MessageBox.WARNING); + messagebox.setModal(true); + messagebox.setVisible(true); + } + + }else{ + MessageBox messagebox = new MessageBox("ǰ̣", "ʾ", MessageBox.WARNING); + messagebox.setModal(true); + messagebox.setVisible(true); + } + } else { + if (ainterfaceaifcomponent[0] instanceof TCComponentTask) { + viewWfInfo(ainterfaceaifcomponent[0]); + } + } + } else { + MessageBox messagebox = new MessageBox("ѡȷ͵Ķ", "ʾ", MessageBox.WARNING); + messagebox.setModal(true); + messagebox.setVisible(true); + return; + } + } else { + MessageBox messagebox = new MessageBox("ѡ", "ʾ", MessageBox.WARNING); + messagebox.setModal(true); + messagebox.setVisible(true); + return; + } + } + } + catch (Exception exception) { + exception.printStackTrace(); + } + } + + public void viewWfInfo(List listProcess, InterfaceAIFComponent ainterfaceaifcomponent) { + System.out.println("viewWfInfo(List listProcess)...........viewWfInfo"); + taskNameVector = new Vector(); + smallTitleList = new ArrayList(); + tableTitleVector = new Vector(); + Vector fileNameVector = new Vector(); + for(int j=0;j vector_infor = readerFromText(fileNameVector); + vector_infor = new Vector(); + vector_infor = readerFromText(fileNameVector); + readInfo( ainterfaceaifcomponent ); + System.out.println("--------------------------------------------------------------"); + for (int i = 0; i < vector_infor.size(); i++) { + String taskName = ((SignInfo) vector_infor.elementAt(i)).taskName.trim(); + String userAction = ((SignInfo) vector_infor.elementAt(i)).userAction; + System.out.println("taskName="+taskName+";userAction="+userAction); + } + System.out.println("--------------------------------------------------------------"); + Object[][] objData = null; + objData = getDataAuditing(vector_infor, taskNameVector); + QueryTaskOpinionTableHead tableHeadTestPanel = new QueryTaskOpinionTableHead(); + tableHeadTestPanel.setAutoscrolls(true); + //tableHeadTestPanel.settitleArray(smallTitleList); + //ʾģʽ 2011.4.22 + tableHeadTestPanel.setobjArray(objData); + tableHeadTestPanel.setTableHeadTestModel(tableTitleVector); + tableHeadTestPanel.initColumnSizes(); + String processName = null; + try { + processName = listProcess.get(0).getRoot().getProperty("job_name"); + } catch (TCException e) { + e.printStackTrace(); + }// + String processCreator = null; + try { + processCreator = listProcess.get(0).getRoot().getProperty("owning_user"); + } catch (TCException e) { + e.printStackTrace(); + }// ̴ + String processCreateDate = null; + try { + processCreateDate = listProcess.get(0).getRoot().getProperty("creation_date"); + } catch (TCException e) { + e.printStackTrace(); + }// ̴ʱ + JFrame frame = new JFrame("" + processName + " ̴:" + processCreator + " ̴ʱ:" + processCreateDate); + tableHeadTestPanel.setOpaque(true); // content panes + JScrollPane scrollPane = new JScrollPane(tableHeadTestPanel); + scrollPane.setAutoscrolls(true); + frame.setContentPane(scrollPane); + frame.pack(); + frame.setLocation(200, 100); + frame.setVisible(true); + + } + + public void viewWfInfo(InterfaceAIFComponent interfaceaifcomponent_top) { + System.out.println("viewWfInfo(InterfaceAIFComponent interfaceaifcomponent_top)...........viewWfInfo"); + if (interfaceaifcomponent_top instanceof TCComponentTask) { + TCComponentTask tccomponenttask = (TCComponentTask) interfaceaifcomponent_top; + taskNameVector = new Vector(); + smallTitleList = new ArrayList(); + tableTitleVector = new Vector(); + try { + TCComponentTask tccomponent_root_task = tccomponenttask.getRoot(); +// AIFComponentContext[] aif = tccomponent_root_task.getChildren();//remove by -*-*- + AIFComponentContext[] aif = tccomponent_root_task.getChildren("child_tasks"); + for (int i = 0; i < aif.length; i++) { + if (aif[i].getComponent() instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask) aif[i].getComponent(); + if (task.getPrevious() == null) { + firstTaskName = task.toString(); + taskNameVector.add(firstTaskName); + break; + } + } + } + getNextTask(aif); + + String stringInformation = tccomponenttask.getAuditInfo(true);// ˺ֵϵͳúõֵ + + String fileName = "D:\\.txt"; + // ѻõϢдһıļ + writeToText(fileName, stringInformation); + // ȡijһıļϢ +// Vector vector_infor = readerFromText(fileName); + vector_infor = new Vector(); + vector_infor = readerFromText(fileName); + readInfo( tccomponenttask ); + Object[][] objData = null; + objData = getDataAuditing(vector_infor, taskNameVector); + QueryTaskOpinionTableHead tableHeadTestPanel = new QueryTaskOpinionTableHead(); + tableHeadTestPanel.setAutoscrolls(true); + //tableHeadTestPanel.settitleArray(smallTitleList); + //ʾģʽ 2011.4.22 + tableHeadTestPanel.setobjArray(objData); + tableHeadTestPanel.setTableHeadTestModel(tableTitleVector); + tableHeadTestPanel.initColumnSizes(); + String processName = tccomponenttask.getProperty("job_name");// + String processCreator = tccomponenttask.getProperty("owning_user");// ̴ + String processCreateDate = tccomponenttask.getProperty("creation_date");// ̴ʱ + JFrame frame = new JFrame("" + processName + " ̴:" + processCreator + " ̴ʱ:" + processCreateDate); + tableHeadTestPanel.setOpaque(true); // content panes + JScrollPane scrollPane = new JScrollPane(tableHeadTestPanel); + scrollPane.setAutoscrolls(true); + frame.setContentPane(scrollPane); + frame.pack(); + frame.setLocation(200, 100); + frame.setVisible(true); + } + catch (TCException e2) { + e2.printStackTrace(); + } + } else { + MessageBox.post("ѡĶ󲻶ԣѡ", "ʾ", MessageBox.INFORMATION); + } + } + + /* + * ˳αӦ"" + */ + public void getNextTask(AIFComponentContext[] aif) { + for (int i = 0; i < aif.length; i++) { + InterfaceAIFComponent interfaceaifcomponent = aif[i].getComponent(); + //System.out.println("interfaceaifcomponent.getType()"+interfaceaifcomponent.getType()); + if (interfaceaifcomponent instanceof TCComponentTask) { + //System.out.println("---------------getNextTask------------------"); + if ((interfaceaifcomponent.getType().equals("EPMAcknowledgeTask"))) { + AcknowladgeTaskList.add(interfaceaifcomponent.toString()); + if (!taskNameVector.contains(interfaceaifcomponent.toString())) { + taskNameVector.addElement(interfaceaifcomponent.toString()); + } + } + if ((interfaceaifcomponent.getType().equals("EPMReviewTask"))) { + reviewTaskList.add(interfaceaifcomponent.toString()); + if (!taskNameVector.contains(interfaceaifcomponent.toString())) { + taskNameVector.addElement(interfaceaifcomponent.toString()); + } + } + if ((interfaceaifcomponent.getType().equals("EPMDoTask"))) { + doTaskList.add(interfaceaifcomponent.toString()); + if (!taskNameVector.contains(interfaceaifcomponent.toString())) { + taskNameVector.addElement(interfaceaifcomponent.toString()); + } + } + if ((interfaceaifcomponent.getType().equals("EPMConditionTask"))) { + conditionTaskList.add(interfaceaifcomponent.toString()); + if (!taskNameVector.contains(interfaceaifcomponent.toString())) { + taskNameVector.addElement(interfaceaifcomponent.toString()); + } + } + if ((interfaceaifcomponent.getType().equals("EPMAddStatusTask"))) { + addStatusTaskList.add(interfaceaifcomponent.toString()); + if (!taskNameVector.contains(interfaceaifcomponent.toString())) { + taskNameVector.addElement(interfaceaifcomponent.toString()); + } + } + if ((interfaceaifcomponent.getType().equals("EPMRouteTask"))) { + RouteTaskList.add(interfaceaifcomponent.toString()); + if (!taskNameVector.contains(interfaceaifcomponent.toString())) { + taskNameVector.addElement(interfaceaifcomponent.toString()); + } + } + } + } + } + + /* + * + */ + public Object[][] getDataAuditing(Vector vector_infor, Vector taskNameVector1) { + // System.out.println("taskNameVector.............." + taskNameVector); + // System.out.println("vector_infor.............." + + // vector_infor.size()); + int columWidth = 0; + if (vector_infor != null) { + columWidth = 6 + 1; + } + + Object[][] objData = new Object[vector_infor.size() + 1][columWidth]; + if (vector_infor.size() == 0) { + objData = new Object[vector_infor.size() + 1][columWidth]; + tableTitleVector.add(firstTaskName + "()"); + for (int j = 0; j < firstTaskTitle.length; j++) { + smallTitleList.add(firstTaskTitle[j]); + } + } + // + int countNum = 0; + if ((vector_infor != null) && (vector_infor.size() > 0)) { + boolean isRefused = false; + String taskName = ""; + String userAction = ""; + for (int i = 0; i < vector_infor.size(); i++) { + taskName = ((SignInfo) vector_infor.elementAt(i)).taskName.trim(); + userAction = ((SignInfo) vector_infor.elementAt(i)).userAction; + System.out.println("taskName="+taskName+";userAction="+userAction); + //if (taskNameVector.contains(taskName)) { + if (userAction.equals("Completed") || userAction.equalsIgnoreCase("true") || userAction.equalsIgnoreCase("false")||userAction.equals("")) {//userAction.equals("") + if (taskName.equals(firstTaskName.trim())) { + if (!tableTitleVector.contains(firstTaskName + "()")) { + tableTitleVector.add(firstTaskName + "()"); + for (int j = 0; j < firstTaskTitle.length; j++) { + smallTitleList.add(firstTaskTitle[j]); + } + } + isRefused = false; + objData[i][0] = ((SignInfo) vector_infor.elementAt(i)).processName; + objData[i][1] = ((SignInfo) vector_infor.elementAt(i)).taskName; + if(userAction.equals("Completed")) + objData[i][2] = ""; + else if(userAction.equalsIgnoreCase("true")) + objData[i][2] = ""; + else if(userAction.equalsIgnoreCase("false")) + objData[i][2] = ""; + objData[i][3] = ((SignInfo) vector_infor.elementAt(i)).userName; + objData[i][4] = ((SignInfo) vector_infor.elementAt(i)).actionTime; + objData[i][5] = ((SignInfo) vector_infor.elementAt(i)).userComments; + } else { + if ((doTaskList.contains(taskName)) || (conditionTaskList.contains(taskName) || addStatusTaskList.contains(taskName))) { + int col = 0; + if (doTaskList.contains(taskName)) { + if (!tableTitleVector.contains("DOTask" + taskName)) { + tableTitleVector.add("DOTask" + taskName); + for (int j = 0; j < doAndConditionTaskTitle.length; j++) { + smallTitleList.add(doAndConditionTaskTitle[j]); + } + } + col = tableTitleVector.indexOf("DOTask" + taskName); + } else if (conditionTaskList.contains(taskName)) { + if (!tableTitleVector.contains("ConditionTask" + taskName)) { + tableTitleVector.add("ConditionTask"+ taskName); + for (int j = 0; j < doAndConditionTaskTitle.length; j++) { + smallTitleList.add(doAndConditionTaskTitle[j]); + } + } + col = tableTitleVector.indexOf("ConditionTask" + taskName); + } else if (addStatusTaskList.contains(taskName)) { + if (!tableTitleVector.contains("AddStatusTask" + taskName)) { + tableTitleVector.add("AddStatusTask"+ taskName); + for (int j = 0; j < doAndConditionTaskTitle.length; j++) { + smallTitleList.add(doAndConditionTaskTitle[j]); + } + } + col = tableTitleVector.indexOf("AddStatusTask" + taskName); + } + if (isRefused) { + for (int m = col + 1; m < columWidth; m++) { + objData[i][m] = ""; + } + } + + isRefused = false; + objData[i][0] = ((SignInfo) vector_infor.elementAt(i)).processName; + objData[i][1] = ((SignInfo) vector_infor.elementAt(i)).taskName; + if(userAction.equals("Completed")) + objData[i][2] = ""; + else if(userAction.equalsIgnoreCase("true")) + objData[i][2] = ""; + else if(userAction.equalsIgnoreCase("false")) + objData[i][2] = ""; + objData[i][3] = ((SignInfo) vector_infor.elementAt(i)).userName; + objData[i][4] = ((SignInfo) vector_infor.elementAt(i)).actionTime; + objData[i][5] = ((SignInfo) vector_infor.elementAt(i)).userComments; + } + } + } else if ((userAction.equals("Rejected")||userAction.equals("ܾ"))) {//userAction.equals("ܾ") + if ((reviewTaskList.contains(taskName)) || (AcknowladgeTaskList.contains(taskName))) { + if (!tableTitleVector.contains(taskName)) { + tableTitleVector.add(taskName); + for (int j = 0; j < auditingTitle.length; j++) { + smallTitleList.add(auditingTitle[j]); + } + } else { + if (AcknowladgeTaskList.contains(taskName)) { + tableTitleVector.add(taskName); + for (int j = 0; j < notifyTitle.length; j++) { + smallTitleList.add(notifyTitle[j]); + } + } + } + int col = tableTitleVector.indexOf(taskName); + objData[i][0] = ((SignInfo) vector_infor.elementAt(i)).processName; + objData[i][1] = ((SignInfo) vector_infor.elementAt(i)).taskName; + //objData[i][2] = ((SignInfo) vector_infor.elementAt(i)).userAction; + objData[i][2] = "ܾ"; + objData[i][3] = ((SignInfo) vector_infor.elementAt(i)).userName; + objData[i][4] = ((SignInfo) vector_infor.elementAt(i)).actionTime; + objData[i][5] = ((SignInfo) vector_infor.elementAt(i)).userComments; + ++countNum; + isRefused = true; + } + } else if (userAction.equals("Approved")||userAction.equals("׼") || (userAction.equals("Ͽ"))) {//(userAction.equals("׼")) || (userAction.equals("Ͽ")) + if ((reviewTaskList.contains(taskName)) || (AcknowladgeTaskList.contains(taskName)) || RouteTaskList.contains(taskName)) { + if (!tableTitleVector.contains(taskName)) { + if (reviewTaskList.contains(taskName)) { + tableTitleVector.add(taskName); + for (int j = 0; j < auditingTitle.length; j++) { + smallTitleList.add(auditingTitle[j]); + } + } else { + if (AcknowladgeTaskList.contains(taskName)) { + tableTitleVector.add(taskName); + for (int j = 0; j < notifyTitle.length; j++) { + smallTitleList.add(notifyTitle[j]); + } + } + } + } + int col = tableTitleVector.indexOf(taskName); + // ĿģǾܾģк + if (isRefused) { + // ĿģǾܾģк + for (int m = col + 1; m < columWidth; m++) { + objData[i][m] = ""; + } + } + isRefused = false; + objData[i][0] = ((SignInfo) vector_infor.elementAt(i)).processName; + objData[i][1] = ((SignInfo) vector_infor.elementAt(i)).taskName; + //objData[i][2] = ((SignInfo) vector_infor.elementAt(i)).userAction; + objData[i][2] = "׼"; + objData[i][3] = ((SignInfo) vector_infor.elementAt(i)).userName; + objData[i][4] = ((SignInfo) vector_infor.elementAt(i)).actionTime; + objData[i][5] = ((SignInfo) vector_infor.elementAt(i)).userComments; + } + }else if(userAction.equals("") || userAction.equals("skipped")){ + if ( AcknowladgeTaskList.contains(taskName)) { + if (!tableTitleVector.contains(taskName)) { + if (reviewTaskList.contains(taskName)) { + tableTitleVector.add(taskName); + for (int j = 0; j < auditingTitle.length; j++) { + smallTitleList.add(auditingTitle[j]); + } + } else { + if (AcknowladgeTaskList.contains(taskName)) { + tableTitleVector.add(taskName); + for (int j = 0; j < notifyTitle.length; j++) { + smallTitleList.add(notifyTitle[j]); + } + } + } + } + int col = tableTitleVector.indexOf(taskName); + // ĿģǾܾģк + if (isRefused) { + // ĿģǾܾģк + for (int m = col + 1; m < columWidth; m++) { + objData[i][m] = ""; + } + } + isRefused = false; + objData[i][0] = ((SignInfo) vector_infor.elementAt(i)).processName; + objData[i][1] = ((SignInfo) vector_infor.elementAt(i)).taskName; + //objData[i][2] = ((SignInfo) vector_infor.elementAt(i)).userAction; + objData[i][2] = ""; + objData[i][3] = ((SignInfo) vector_infor.elementAt(i)).userName; + objData[i][4] = ((SignInfo) vector_infor.elementAt(i)).actionTime; + objData[i][5] = ((SignInfo) vector_infor.elementAt(i)).userComments; + } + }else{//add by -*-*- + if (!tableTitleVector.contains(taskName)) { + if (reviewTaskList.contains(taskName)) { + tableTitleVector.add(taskName); + for (int j = 0; j < auditingTitle.length; j++) { + smallTitleList.add(auditingTitle[j]); + } + } else { + if (AcknowladgeTaskList.contains(taskName)) { + tableTitleVector.add(taskName); + for (int j = 0; j < notifyTitle.length; j++) { + smallTitleList.add(notifyTitle[j]); + } + } + } + } + int col = tableTitleVector.indexOf(taskName); + // ĿģǾܾģк + if (isRefused) { + // ĿģǾܾģк + for (int m = col + 1; m < columWidth; m++) { + objData[i][m] = ""; + } + } + isRefused = false; + objData[i][0] = ((SignInfo) vector_infor.elementAt(i)).processName; + objData[i][1] = ((SignInfo) vector_infor.elementAt(i)).taskName; + objData[i][2] = ((SignInfo) vector_infor.elementAt(i)).userAction; + //objData[i][2] = "ʼ"; + objData[i][3] = ((SignInfo) vector_infor.elementAt(i)).userName; + objData[i][4] = ((SignInfo) vector_infor.elementAt(i)).actionTime; + objData[i][5] = ((SignInfo) vector_infor.elementAt(i)).userComments; + } + //} + } + } + return objData; + } + + /** + * ַдһıļ(writeToText) *************̴ + */ + public void writeToText(String fileName, String stringInformation) { + PrintWriter pw; + try { + pw = new PrintWriter(new FileWriter(fileName)); + pw.println(stringInformation); + pw.close(); + } + catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * һıļȡϢ(readerFromText) *************̴ + */ + public Vector readerFromText(String fileName) { + System.out.println("readerFromText(String) - start"); //$NON-NLS-1$ + BufferedReader br = null; + Vector vs = new Vector(); + try { + int num = 1; + br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName))); + String strLine = null; + String processName = ""; + while ((strLine = br.readLine()) != null) { + if((strLine.startsWith("ģ"))){ + System.out.println("strLine=="+strLine); + String [] temps = strLine.split(" "); + int y=0; + System.out.println(" temps.length=="+ temps.length); + for (int i = 0; i < temps.length; i++) { + if (temps[i].trim().length() != 0) { + ++y; + if (y == 2) { + processName = temps[i].trim();// + } + } + } + System.out.println("processName=="+processName); + }else if ((strLine.startsWith("")) || (strLine.startsWith("ܾ")) || (strLine.startsWith("׼")) ) {//|| (strLine.startsWith("")) + String[] temp = strLine.split(" "); + int k = 0; + String taskName = ""; + String pzUser = ""; + String pzTime = ""; + + for (int i = 0; i < temp.length; i++) { + if (temp[i].trim().length() != 0) { + ++k; + if (k == 2) { + taskName = temp[i].trim(); + } + if (k == 3) { + pzTime = temp[i].trim(); + } + if (k == 4) { + pzTime = pzTime + " " + temp[i].trim(); + } + if (k == 5) { + pzUser = temp[i].trim(); + break; + } + } + } + + try { + TCComponentUser tccomponentuser1 = UserList.getUser(session, "(" + pzUser + ")"); + if (tccomponentuser1 != null) { + pzUser = tccomponentuser1.toString(); + } + } + catch (TCException e) { + e.printStackTrace(); + } + + SignInfo oneSignInfo = new SignInfo(); + + oneSignInfo.userName = pzUser; + oneSignInfo.actionTime = pzTime; + if(num==1){ + oneSignInfo.processName = processName; + }else{ + oneSignInfo.processName = ""; + } + + if ((strLine.startsWith(""))) { + oneSignInfo.taskName = taskName; + if (taskNameVector.contains(taskName)) { + if (strLine.startsWith("")) { + oneSignInfo.userAction = ""; + if ((!reviewTaskList.contains(taskName)) && (!AcknowladgeTaskList.contains(taskName))) { + br.readLine(); + br.mark(400); + strLine = br.readLine(); + if (!(strLine.startsWith(" ") || strLine.startsWith("\t"))) { + br.reset(); + } else { + String Comments = strLine.trim(); + while((strLine = br.readLine()) != null){ + if(strLine.equals("")){ + break; + }else{ + Comments = Comments + "\t"+strLine.trim(); + } + } + oneSignInfo.userComments = Comments; + } + oneSignInfo.num = num++; + vs.add(oneSignInfo); + } + } + } + } else { + if ((strLine.startsWith("׼"))) { + oneSignInfo.userAction = "׼"; + } else { + oneSignInfo.userAction = "ܾ"; + } + strLine = br.readLine(); + temp = strLine.split(":"); + taskName = temp[1].trim(); + if (taskNameVector.contains(taskName)) { + oneSignInfo.taskName = taskName; + if (AcknowladgeTaskList.contains(taskName)) { + oneSignInfo.userAction = "Ͽ"; + } + br.mark(400); + strLine = br.readLine(); + if (!(strLine.startsWith(" ") || strLine.startsWith("\t"))) { + br.reset(); + } else { + String Comments = strLine.trim(); + while((strLine = br.readLine()) != null){ + if(strLine.equals("")){ + break; + }else{ + Comments = Comments + "\t"+strLine.trim(); + } + } + oneSignInfo.userComments = Comments; + } + oneSignInfo.num = num++; + vs.add(oneSignInfo); + } + } + } + } + br.close(); + } + catch (FileNotFoundException e1) { + e1.printStackTrace(); + } + catch (IOException e2) { + e2.printStackTrace(); + } + System.out.println("readerFromText(String) - end" + vs.size()); //$NON-NLS-1$ + return vs; + } + + + /** + * һıļȡϢ(readerFromText) *************̴ + */ + public Vector readerFromText(Vector fileNameVector) { + System.out.println("readerFromText(String) - start"); //$NON-NLS-1$ + BufferedReader br = null; + Vector vs = new Vector(); + for(int n = 0; n < fileNameVector.size(); n++){ + int num = 1; + try { + br = new BufferedReader(new InputStreamReader(new FileInputStream(fileNameVector.get(n)))); + String strLine = null; + String processName = ""; + while ((strLine = br.readLine()) != null) { + if((strLine.startsWith("ģ"))){ + System.out.println("strLine=="+strLine); + String [] temps = strLine.split(" "); + int y=0; + System.out.println(" temps.length=="+ temps.length); + for (int i = 0; i < temps.length; i++) { + if (temps[i].trim().length() != 0) { + ++y; + if (y == 2) { + processName = temps[i].trim();// + } + } + } + System.out.println("processName=="+processName); + }else + if ((strLine.startsWith("")) || (strLine.startsWith("ܾ")) || (strLine.startsWith("׼"))) { + String[] temp = strLine.split(" "); + int k = 0; + String taskName = ""; + String pzUser = ""; + String pzTime = ""; + + for (int i = 0; i < temp.length; i++) { + if (temp[i].trim().length() != 0) { + ++k; + if (k == 2) { + taskName = temp[i].trim(); + } + if (k == 3) { + pzTime = temp[i].trim(); + } + if (k == 4) { + pzTime = pzTime + " " + temp[i].trim(); + } + if (k == 5) { + pzUser = temp[i].trim(); + break; + } + } + } + + try { + TCComponentUser tccomponentuser1 = UserList.getUser(session, "(" + pzUser + ")"); + if (tccomponentuser1 != null) { + pzUser = tccomponentuser1.toString(); + } + } + catch (TCException e) { + e.printStackTrace(); + } + + SignInfo oneSignInfo = new SignInfo(); + + oneSignInfo.userName = pzUser; + oneSignInfo.actionTime = pzTime; + if(num==1){ + oneSignInfo.processName = processName; + }else{ + oneSignInfo.processName = ""; + } + + + if ((strLine.startsWith(""))) { + oneSignInfo.taskName = taskName; + if (taskNameVector.contains(taskName)) { + if (strLine.startsWith("")) { + oneSignInfo.userAction = ""; + if ((!reviewTaskList.contains(taskName)) && (!AcknowladgeTaskList.contains(taskName))) { + br.readLine(); + br.mark(400); + strLine = br.readLine(); + if (!(strLine.startsWith(" ") || strLine.startsWith("\t"))) { + br.reset(); + } else { + String Comments = strLine.trim(); + while((strLine = br.readLine()) != null){ + if(strLine.equals("")){ + break; + }else{ + Comments = Comments + "\t"+strLine.trim(); + } + } + oneSignInfo.userComments = Comments; + } + oneSignInfo.num = num++; + vs.add(oneSignInfo); + } + } + } + } else { + if ((strLine.startsWith("׼"))) { + oneSignInfo.userAction = "׼"; + } else { + oneSignInfo.userAction = "ܾ"; + } + strLine = br.readLine(); + temp = strLine.split(":"); + taskName = temp[1].trim(); + if (taskNameVector.contains(taskName)) { + oneSignInfo.taskName = taskName; + if (AcknowladgeTaskList.contains(taskName)) { + oneSignInfo.userAction = "Ͽ"; + } + br.mark(400); + strLine = br.readLine(); + if (!(strLine.startsWith(" ") || strLine.startsWith("\t"))) { + br.reset(); + } else { + String Comments = strLine.trim(); + while((strLine = br.readLine()) != null){ + if(strLine.equals("")){ + break; + }else{ + Comments = Comments + "\t"+strLine.trim(); + } + } + oneSignInfo.userComments = Comments; + } + oneSignInfo.num = num++; + vs.add(oneSignInfo); + } + } + } + } + br.close(); + } + catch (FileNotFoundException e1) { + e1.printStackTrace(); + } + catch (IOException e2) { + e2.printStackTrace(); + } + } + + System.out.println("readerFromText(String) - end" + vs.size()); //$NON-NLS-1$ + return vs; + } + + // ȡһıļҪһ̬ + static class SignInfo { + public String processName = ""; + public int num = 0; + public String taskName = ""; + public String userName = ""; + public String userAction = ""; + public String actionTime = ""; + public String userComments = ""; + } + + private TCSession session = null; + private AbstractAIFUIApplication myuiapp; +} diff --git a/src/cust/com/rac/workflow/QueryTaskProcessCommand.java b/src/cust/com/rac/workflow/QueryTaskProcessCommand.java new file mode 100644 index 0000000..cb3f5cc --- /dev/null +++ b/src/cust/com/rac/workflow/QueryTaskProcessCommand.java @@ -0,0 +1,55 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: QueryTaskProcessCommand.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 10:19:35 tyl Ini ʼļ +#======================================================================================================= + */ +package cust.com.rac.workflow; + +import java.util.List; + +import cn.com.customization.util.GetAllUserIds; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCException; + +public class QueryTaskProcessCommand extends AbstractAIFCommand { + + public AbstractAIFUIApplication application; + + public QueryTaskProcessCommand(AbstractAIFUIApplication abstractaifapplication) throws TCException { + application = abstractaifapplication; + execute(); + } + + private void execute() throws TCException { + System.out.println(" QueryTaskProcessCommand "); + GetAllUserIds.setUsers(new GetAllUserIds(application).getAllUsers()); + new Thread() { + public void run() { + while (true) { + try { + List users = GetAllUserIds.getUsers(); + if ((users == null) || (users.size() == 0)) { + System.out.println("--------------1000"); + sleep(20000); + } else { + new SearchTaskDialog(application, "ѯ", false); + break; + } + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }.start(); + } +} diff --git a/src/cust/com/rac/workflow/QueryTaskProcessHandler.java b/src/cust/com/rac/workflow/QueryTaskProcessHandler.java new file mode 100644 index 0000000..f2ba632 --- /dev/null +++ b/src/cust/com/rac/workflow/QueryTaskProcessHandler.java @@ -0,0 +1,46 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: QueryTaskProcessHandler.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 10:19:51 tyl Ini ʼļ +#======================================================================================================= + */ +package cust.com.rac.workflow; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class QueryTaskProcessHandler extends AbstractHandler implements IHandler { + + /* + * @see + * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. + * ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + QueryTaskProcessCommand command = new QueryTaskProcessCommand(app); + command.executeModal(); + + } + catch (TCException e) { + e.printStackTrace(); + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cust/com/rac/workflow/SearchResultDialog.java b/src/cust/com/rac/workflow/SearchResultDialog.java new file mode 100644 index 0000000..34be8e1 --- /dev/null +++ b/src/cust/com/rac/workflow/SearchResultDialog.java @@ -0,0 +1,708 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: SearchResultDialog.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:46:01 tyl Ini ʼļ +#======================================================================================================= + */ +package cust.com.rac.workflow; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.TitledBorder; +import javax.swing.table.JTableHeader; + +import cn.com.customization.util.ColumnGroup; +import cn.com.customization.util.DataSetFinder; +import cn.com.customization.util.GetChoosePath; +import cn.com.customization.util.GetMessageDialog; +import cn.com.customization.util.GroupableTableHeader; +import cn.com.customization.util.TableColorRender; +import cn.com.customization.util.TableColumnRender; +import cn.com.customization.util.UtilApi; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFCommand; +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.commands.open.OpenCommand; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentSignoff; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +import cust.com.rac.workflow.SearchTaskDialog.SearchCondition; + +//public class SearchResultDialog extends AbstractAIFDialog { +public class SearchResultDialog extends JFrame { + private static final long serialVersionUID = 1L; + private List results = new ArrayList(); + private JTable table1; + private SearchResultTableModel dtm1; + private String title = ""; + private TCSession session; + private SearchCondition searchCondition; + private String[] names1 = { "*", "", "ִ", "ϲʱ", "ʱ", "״̬", "ǩע", "", "", "", "ʱ", "һ޸ʱ", "һ޸", "״̬", "ģ" }; + private String[] names2 = { "*", "", "", "", "ʱ", "һ޸ʱ", "һ޸", "״̬" }; + private Map taskMap = new HashMap(); + + private String reportOption = "origin_viewTask_report"; + private String reportPath = "c:"; + private PackExcelInfo excelInfo = new PackExcelInfo(); + private boolean isExceptionSearch; + + public SearchResultDialog(AbstractAIFUIApplication app, List components, SearchCondition searchCondition, boolean isExceptionSearch) { + this.session = (TCSession) app.getSession(); + this.searchCondition = searchCondition; + this.isExceptionSearch = isExceptionSearch; + getResultValue(components); + initUI(); + File file = new File(excelInfo.getTemplateFileName()); + if (file.exists()) { + file.delete(); + } + } + + @SuppressWarnings("deprecation") + private void getResultValue(List components) { + try { + title = (new Date().toLocaleString()) + "_" + session.getUser() + "_ִѯִߣ" + searchCondition.getUsername() + "ʱΣ[" + searchCondition.getCreateDate() + "]_[" + searchCondition.getFinishDate() + "]"; + if (components != null) { + List taskList = new ArrayList(); + List taskIndexList = new ArrayList(); + for (int i = 0; i < components.size(); i++) { + TCComponentTask task = (TCComponentTask) components.get(i); + + if (task != null) { + SearchResults result = new SearchResults(); + if (!isExceptionSearch) { + if (((task.getTaskType()).equalsIgnoreCase("EPMSelectSignoffTask")) || ((task.getTaskType()).equalsIgnoreCase("EPMPerformSignoffTask"))) { + TCComponentSignoff[] sigoffs = task.getValidSignoffs(); + for (int m = 0; m < sigoffs.length; m++) { + String comment = sigoffs[m].getComments(); + result.setTask_note(comment); + result.setTask_executor(sigoffs[m].getProperty("signoff_member")); + result.setTask_finishDate(sigoffs[m].getProperty("decision_date")); + } + } else { + result.setTask_executor(task.getProperty("owning_user")); + result.setTask_finishDate(task.getProperty("last_mod_date")); + result.setTask_note(""); + } + } + + if (((task.getTaskType()).equalsIgnoreCase("EPMSelectSignoffTask")) || ((task.getTaskType()).equalsIgnoreCase("EPMPerformSignoffTask"))) { + task = task.getParent(); + } + if (taskList.contains(task)) { + int taskIndex = taskList.indexOf(task); + taskList.remove(task); + taskIndexList.remove(taskIndex); + } + + result.setTask_name(task.getProperty("object_name")); + if (result.getTask_type().equals("EPMTask")) { + if (result.getTask_status().equals("ѿʼ")) { + result.setTask_name("" + result.getTask_name()); + result.setTask_finishDate(""); + } + } + + Date taskCreateDate = null; + SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + result.setTask(task); + taskCreateDate = task.getDateProperty("creation_date"); + + result.setTask_createDate(task.getProperty("creation_date")); + TCComponentTask previousTask = task.getPrevious(); + if (previousTask != null) { + result.setTask_createDate(previousTask.getProperty("last_mod_date")); + taskCreateDate = previousTask.getDateProperty("last_mod_date"); + } + result.setTask_type(task.getProperty("object_type")); + result.setTask_status(task.getProperty("real_state")); + + if (!result.getTask_status().equals("")) { + result.setTask_finishDate(""); + } + + TCComponentTask rootTask = task.getRoot(); + result.setProcess_name(rootTask.getProperty("job_name")); + result.setProcess_createDate(rootTask.getProperty("creation_date")); + result.setProcess_finishDate(rootTask.getProperty("last_mod_date")); + result.setProcess_lastModeUser(rootTask.getProperty("last_mod_user")); + result.setProcess_executor(rootTask.getProperty("owning_user")); + result.setProcess_status(rootTask.getProperty("real_state")); + result.setProcess_templateName(rootTask.getProperty("task_template")); + // String index = String.valueOf(i + 1) + "$$$" + + // result.getProcess_createDate() + "$$$" + + // result.getTask_createDate() + "$$$" + + // result.getTask_finishDate(); + String index = String.valueOf(i + 1) + "$$$" + simpleDate.format(rootTask.getDateProperty("creation_date")) + "$$$" + result.getProcess_name() + "$$$" + simpleDate.format(taskCreateDate); + taskIndexList.add(index); + taskMap.put(index, result); + } + taskList.add(task); + } + + Collections.sort(taskIndexList, new ComparatorTask()); + for (int i = 0; i < taskIndexList.size(); i++) { + SearchResults result = taskMap.get(taskIndexList.get(i)); + result.setIndex(String.valueOf(i + 1)); + results.add(result); + } + } + } + catch (TCException e) { + e.printStackTrace(); + } + } + + public String getUserByID(String userID) { + try { + TCTypeService service = session.getTypeService(); + TCComponentUserType userType = (TCComponentUserType) service.getTypeComponent("User"); + if (userType.find(userID) != null) { + String user = userType.find(userID).toString(); + return user; + } + } + catch (TCException e1) { + e1.printStackTrace(); + } + return ""; + } + + public void initUI() { + this.setTitle("ѯ"); + ImageIcon image = Registry.getImageIconFromPath("/com/teamcenter/rac/ecmanagement/images/processviewer_16.png"); + this.setIconImage(image.getImage()); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(BorderLayout.NORTH, setTopPanel()); + panel.add(BorderLayout.CENTER, setCenterPanel()); + panel.add(BorderLayout.SOUTH, setBottomPanel()); + getContentPane().add(panel); + // this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + // this.addWindowListener(new WindowAdapter() { + // public void windowClosing(WindowEvent e) { + // dispose(); + // } + // }); + // showDialog(); + pack(); + Dimension screen = getToolkit().getScreenSize(); + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); + this.setVisible(true); + } + + private JPanel setTopPanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.add(new JLabel(" "), BorderLayout.NORTH); + if (!isExceptionSearch) { + panel.add(new JLabel(" " + title), BorderLayout.CENTER); + } + panel.add(new JLabel(" "), BorderLayout.SOUTH); + return panel; + } + + private JPanel setCenterPanel() { + JPanel panel1 = new JPanel(new PropertyLayout()); + panel1.setBorder(new TitledBorder("")); + if (!isExceptionSearch) { + dtm1 = new SearchResultTableModel(names1, results, 0); + table1 = new JTable(dtm1) { + private static final long serialVersionUID = 1L; + + protected JTableHeader createDefaultTableHeader() { + return new GroupableTableHeader(columnModel); + } + }; + GroupableTableHeader header = new GroupableTableHeader(table1.getColumnModel()); + javax.swing.table.TableColumnModel cm = table1.getColumnModel(); + // + ColumnGroup taskCol = new ColumnGroup("Ϣ"); + taskCol.add(cm.getColumn(1)); + taskCol.add(cm.getColumn(2)); + taskCol.add(cm.getColumn(3)); + taskCol.add(cm.getColumn(4)); + taskCol.add(cm.getColumn(5)); + taskCol.add(cm.getColumn(6)); + taskCol.add(cm.getColumn(7)); + header.addColumnGroup(taskCol); + + ColumnGroup processCol = new ColumnGroup("Ϣ"); + processCol.add(cm.getColumn(8)); + processCol.add(cm.getColumn(9)); + processCol.add(cm.getColumn(10)); + processCol.add(cm.getColumn(11)); + processCol.add(cm.getColumn(12)); + processCol.add(cm.getColumn(13)); + processCol.add(cm.getColumn(14)); + header.addColumnGroup(processCol); + table1.setTableHeader(header); + table1.setDefaultRenderer(Object.class, new TableColorRender()); + dtm1.setTableColumnsWidth(table1, 0); + } else { + dtm1 = new SearchResultTableModel(names2, results, 1); + table1 = new JTable(dtm1); + dtm1.setTableColumnsWidth(table1, 1); + } + table1.setRowHeight(20); + table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // нȾ + table1.getColumnModel().getColumn(0).setCellRenderer(new TableColumnRender()); + Dimension screen = getToolkit().getScreenSize(); + JScrollPane scrollPane1 = new JScrollPane(table1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + if (!isExceptionSearch) { + scrollPane1.setPreferredSize(new Dimension((int) (screen.getWidth() * (0.75)), (int) (screen.getHeight() * (0.6)))); + } else { + scrollPane1.setPreferredSize(new Dimension((int) (screen.getWidth() * (0.62)), (int) (screen.getHeight() * (0.5)))); + } + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(new TitledBorder("")); + panel.add(scrollPane1); + return panel; + } + + private JPanel setBottomPanel() { + JPanel southPanel = new JPanel(new FlowLayout()); + // southPanel.setSize(100, 15); + JButton confirmButton = new JButton("鿴"); + JButton exitButton = new JButton(" "); + JButton exportButton = new JButton("Excel"); + confirmButton.addActionListener(new buttonListener()); + exitButton.addActionListener(new buttonListener()); + exportButton.addActionListener(new buttonListener()); + southPanel.add(new JLabel(" ")); + southPanel.add(new JLabel(" ")); + southPanel.add(new JLabel(" ")); + southPanel.add(new JLabel(" ")); + southPanel.add(new JLabel(" ")); + southPanel.add(confirmButton); + if (!isExceptionSearch) { + southPanel.add(exportButton); + } + southPanel.add(exitButton); + return southPanel; + } + + class buttonListener implements ActionListener { + public void actionPerformed(ActionEvent event) { + String name = ((JButton) event.getSource()).getText(); + if (name.equals("鿴")) { + showProcess(); + } else if (name.equals("Excel")) { + exportResult(); + } else if (name.equals(" ")) { + dispose(); + } + } + } + + private void exportResult() { + String dir = new GetChoosePath().getPath("\\viewTask.txt"); + if ((dir != "") || (dir.trim().length() > 0)) { + excelInfo.setTitle(title); + excelInfo.setTemplateFileName(getTemplateFile()); + String times = String.valueOf(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date(System.currentTimeMillis()))); + excelInfo.setTargetFileName(dir + "\\ѯ_" + times + ".xls"); + new ExportSearchResult(results, excelInfo); + openFile(excelInfo.getTargetFileName(), false); + this.setVisible(true); + } + } + + public String getTemplateFile() { + HashMap cfghm = UtilApi.getPreferenceHashMap(session, TCPreferenceService.TC_preference_site, reportOption); + if (cfghm == null) { + MessageBox.post("ûѡ" + reportOption + "!", "INFO", MessageBox.INFORMATION); + return ""; + } + String DatasetOwningUser = (cfghm.get("DatasetOwningUser") + "").trim(); + String DatasetOwningGroup = (cfghm.get("DatasetOwningGroup") + "").trim(); + String DatasetName = (cfghm.get("DatasetName") + "").trim(); + DataSetFinder dataset_finder = new DataSetFinder(session); + TCComponentDataset imancomponentdataset = dataset_finder.FindDatasetByName(DatasetName, DatasetOwningUser, DatasetOwningGroup, "MSExcel"); + System.out.println("imancomponentdataset=========" + imancomponentdataset); + if (imancomponentdataset != null) { + try { + File file1 = new File(reportPath); + if (!file1.exists()) { + file1.createNewFile(); + } + File file = dataset_finder.ExportFileToDir(imancomponentdataset, reportPath); + if (file != null) { + System.out.println("file=========" + file.getAbsolutePath()); + return file.getAbsolutePath(); + } + } + catch (Exception e) { + MessageBox.post("ݼʱ!", "INFO", MessageBox.INFORMATION); + e.printStackTrace(); + } + } else { + MessageBox.post("õġ" + DatasetName + "ݼģ岻!", "INFO", MessageBox.INFORMATION); + } + return ""; + } + + public void openFile(String targetFile, boolean isDir) { + File file = new File(targetFile); + if (file.exists()) { + int value = 0; + if (isDir) { + value = new GetMessageDialog("INFO", "ļѾɣǷĿ¼").getValue(); + // value = + // MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), + // "INFO", "ļѾɣǷĿ¼"); + } else { + // value = + // MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), + // "INFO", "ļѾɣǷ򿪣"); + value = new GetMessageDialog("INFO", "ļѾɣǷ򿪣").getValue(); + } + if (value == 0) { + try { + Runtime runtime = Runtime.getRuntime(); + runtime.exec("cmd /c start exit &&\"" + targetFile + "\" "); + } + catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + private void showProcess() { + int row = table1.getSelectedRow(); + if (row >= 0) { + final SearchResults result = results.get(row); + AIFDesktop localAIFDesktop = AIFUtility.getActiveDesktop(); + + // try { + // ExplorerService exploreService = new ExplorerService(); + // // exploreService.expand(); + // // exploreService.refresh(); + // } + // catch (Exception e1) { + // e1.printStackTrace(); + // } + // String str = "com.teamcenter.rac.explorer.ExplorerApplication"; + // localAIFDesktop.sendToApplication(result.getTask(), str); + + TCComponentTask task = result.getTask(); + try { + AIFComponentContext[] context = task.getChildren(); + InterfaceAIFComponent[] contexts = new InterfaceAIFComponent[] { (InterfaceAIFComponent) context[0].getComponent() }; + try { + System.out.println("task.getName()==" + task.getName()); + } + catch (TCException e1) { + e1.printStackTrace(); + } + AbstractAIFCommand abstractaifcommand = new OpenCommand(localAIFDesktop, contexts); + try { + abstractaifcommand.executeModal(); + } + catch (Exception e1) { + e1.printStackTrace(); + } + } + catch (TCException e1) { + e1.printStackTrace(); + } + + try { + Thread.sleep(500); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + SearchResultDialog.this.setExtendedState(JFrame.ICONIFIED); + } else { + MessageBox.post("ѡҪ鿴̣", "INFO", MessageBox.INFORMATION); + this.setVisible(true); + } + } + + class SearchResults { + private String index = ""; + private String task_name = ""; + private String task_createDate = ""; + private String task_finishDate = ""; + private String task_status = ""; + private String task_executor = ""; + private String task_note = ""; + private String task_type = ""; + + /** + * @return the task_type + */ + public String getTask_type() { + return task_type; + } + + /** + * @param task_type the task_type to set + */ + public void setTask_type(String task_type) { + this.task_type = task_type; + } + + private TCComponentTask task; + + private String process_name; + private String process_createDate; + private String process_finishDate; + private String process_status; + private String process_executor; + private String process_lastModeUser; + private String process_templateName; + + /** + * @return the task + */ + public TCComponentTask getTask() { + return task; + } + + /** + * @return the process_lastModeUser + */ + public String getProcess_lastModeUser() { + return process_lastModeUser; + } + + /** + * @param process_lastModeUser the process_lastModeUser to set + */ + public void setProcess_lastModeUser(String process_lastModeUser) { + this.process_lastModeUser = process_lastModeUser; + } + + /** + * @param task the task to set + */ + public void setTask(TCComponentTask task) { + this.task = task; + } + + /** + * @return the index + */ + public String getIndex() { + return index; + } + + /** + * @param index the index to set + */ + public void setIndex(String index) { + this.index = index; + } + + /** + * @return the task_name + */ + public String getTask_name() { + return task_name; + } + + /** + * @param task_name the task_name to set + */ + public void setTask_name(String task_name) { + this.task_name = task_name; + } + + /** + * @return the task_createDate + */ + public String getTask_createDate() { + return task_createDate; + } + + /** + * @param task_createDate the task_createDate to set + */ + public void setTask_createDate(String task_createDate) { + this.task_createDate = task_createDate; + } + + /** + * @return the task_finishDate + */ + public String getTask_finishDate() { + return task_finishDate; + } + + /** + * @param task_finishDate the task_finishDate to set + */ + public void setTask_finishDate(String task_finishDate) { + this.task_finishDate = task_finishDate; + } + + /** + * @return the task_status + */ + public String getTask_status() { + return task_status; + } + + /** + * @param task_status the task_status to set + */ + public void setTask_status(String task_status) { + this.task_status = task_status; + } + + /** + * @return the task_executor + */ + public String getTask_executor() { + return task_executor; + } + + /** + * @param task_executor the task_executor to set + */ + public void setTask_executor(String task_executor) { + this.task_executor = task_executor; + } + + /** + * @return the task_note + */ + public String getTask_note() { + return task_note; + } + + /** + * @param task_note the task_note to set + */ + public void setTask_note(String task_note) { + this.task_note = task_note; + } + + /** + * @return the process_name + */ + public String getProcess_name() { + return process_name; + } + + /** + * @param process_name the process_name to set + */ + public void setProcess_name(String process_name) { + this.process_name = process_name; + } + + /** + * @return the process_createDate + */ + public String getProcess_createDate() { + return process_createDate; + } + + /** + * @param process_createDate the process_createDate to set + */ + public void setProcess_createDate(String process_createDate) { + this.process_createDate = process_createDate; + } + + /** + * @return the process_finishDate + */ + public String getProcess_finishDate() { + return process_finishDate; + } + + /** + * @param process_finishDate the process_finishDate to set + */ + public void setProcess_finishDate(String process_finishDate) { + this.process_finishDate = process_finishDate; + } + + /** + * @return the process_status + */ + public String getProcess_status() { + return process_status; + } + + /** + * @param process_status the process_status to set + */ + public void setProcess_status(String process_status) { + this.process_status = process_status; + } + + /** + * @return the process_executor + */ + public String getProcess_executor() { + return process_executor; + } + + /** + * @param process_executor the process_executor to set + */ + public void setProcess_executor(String process_executor) { + this.process_executor = process_executor; + } + + /** + * @return the process_templateName + */ + public String getProcess_templateName() { + return process_templateName; + } + + /** + * @param process_templateName the process_templateName to set + */ + public void setProcess_templateName(String process_templateName) { + this.process_templateName = process_templateName; + } + + } +} diff --git a/src/cust/com/rac/workflow/SearchResultTableModel.java b/src/cust/com/rac/workflow/SearchResultTableModel.java new file mode 100644 index 0000000..f969cc0 --- /dev/null +++ b/src/cust/com/rac/workflow/SearchResultTableModel.java @@ -0,0 +1,135 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: SearchResultTableModel.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:46:12 tyl Ini ʼļ +#======================================================================================================= +*/ +package cust.com.rac.workflow; + +import java.util.Enumeration; +import java.util.List; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; + +import cust.com.rac.workflow.SearchResultDialog.SearchResults; + +public class SearchResultTableModel extends DefaultTableModel { + + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance of EditBatchProcessLineTableModel. + * @param data + */ + public SearchResultTableModel(String[] names, List data, int index) { + super(getData(data, index), names); + } + + public static Object[][] getData(List data, int index) { + Object[][] datas = new Object[data.size()][]; + for (int i = 0; i < data.size(); i++) { + if (index == 0) { + String[] info = new String[15]; + info[0] = String.valueOf(i + 1); + info[1] = data.get(i).getTask_name(); + info[2] = data.get(i).getTask_executor(); + info[3] = data.get(i).getTask_createDate(); + info[4] = data.get(i).getTask_finishDate(); + info[5] = data.get(i).getTask_status(); + info[6] = data.get(i).getTask_note(); + info[7] = data.get(i).getTask_type(); + info[8] = data.get(i).getProcess_executor(); + info[9] = data.get(i).getProcess_name(); + info[10] = data.get(i).getProcess_createDate(); + info[11] = data.get(i).getProcess_finishDate(); + info[12] = data.get(i).getProcess_lastModeUser(); + info[13] = data.get(i).getProcess_status(); + info[14] = data.get(i).getProcess_templateName(); + datas[i] = info; + } else { + if (index == 1) { + String[] info = new String[8]; + info[0] = String.valueOf(i + 1); + info[1] = data.get(i).getProcess_executor(); + info[2] = data.get(i).getProcess_name(); + info[3] = data.get(i).getTask_name(); + info[4] = data.get(i).getProcess_createDate(); + info[5] = data.get(i).getProcess_finishDate(); + info[6] = data.get(i).getProcess_lastModeUser(); + info[7] = data.get(i).getProcess_status(); + datas[i] = info; + } + } + } + return datas; + } + + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0) { + return false; + } else { + return true; + } + } + + // п + public void setTableColumnsWidth(JTable myTable, int index) { + if (index == 0) { + myTable.getColumnModel().getColumn(0).setPreferredWidth(30); + myTable.getColumnModel().getColumn(1).setPreferredWidth(80); + myTable.getColumnModel().getColumn(2).setPreferredWidth(80); + myTable.getColumnModel().getColumn(3).setPreferredWidth(80); + myTable.getColumnModel().getColumn(4).setPreferredWidth(80); + myTable.getColumnModel().getColumn(5).setPreferredWidth(60); + myTable.getColumnModel().getColumn(6).setPreferredWidth(60); + myTable.getColumnModel().getColumn(7).setPreferredWidth(60); + myTable.getColumnModel().getColumn(8).setPreferredWidth(80); + myTable.getColumnModel().getColumn(9).setPreferredWidth(80); + myTable.getColumnModel().getColumn(10).setPreferredWidth(80); + myTable.getColumnModel().getColumn(11).setPreferredWidth(80); + myTable.getColumnModel().getColumn(12).setPreferredWidth(80); + myTable.getColumnModel().getColumn(13).setPreferredWidth(50); + myTable.getColumnModel().getColumn(14).setPreferredWidth(80); + } else { + if (index == 1) { + myTable.getColumnModel().getColumn(0).setPreferredWidth(30); + myTable.getColumnModel().getColumn(1).setPreferredWidth(100); + myTable.getColumnModel().getColumn(2).setPreferredWidth(120); + myTable.getColumnModel().getColumn(3).setPreferredWidth(100); + myTable.getColumnModel().getColumn(4).setPreferredWidth(120); + myTable.getColumnModel().getColumn(5).setPreferredWidth(120); + myTable.getColumnModel().getColumn(6).setPreferredWidth(100); + myTable.getColumnModel().getColumn(7).setPreferredWidth(80); + } + } + } + + // п + public void FitTableColumns(JTable myTable) { + JTableHeader header = myTable.getTableHeader(); + // header.getColumnModel().getColumn(0) + int rowCount = myTable.getRowCount(); + Enumeration columns = myTable.getColumnModel().getColumns(); + while (columns.hasMoreElements()) { + TableColumn column = (TableColumn) columns.nextElement(); + int col = header.getColumnModel().getColumnIndex(column.getIdentifier()); + int width = (int) myTable.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(myTable, column.getIdentifier(), false, false, -1, col).getPreferredSize().getWidth(); + for (int row = 0; row < rowCount; row++) { + int preferedWidth = (int) myTable.getCellRenderer(row, col).getTableCellRendererComponent(myTable, myTable.getValueAt(row, col), false, false, row, col).getPreferredSize().getWidth(); + width = Math.max(width, preferedWidth); + } + header.setResizingColumn(column); + column.setWidth(width + myTable.getIntercellSpacing().width); + } + } +} diff --git a/src/cust/com/rac/workflow/SearchTaskDialog.java b/src/cust/com/rac/workflow/SearchTaskDialog.java new file mode 100644 index 0000000..8960677 --- /dev/null +++ b/src/cust/com/rac/workflow/SearchTaskDialog.java @@ -0,0 +1,450 @@ +/* +#======================================================================================================= +# +# Copyright (c) 2007 Origin Enterprise Solution LTD. +# +#======================================================================================================= +# File description: SearchTaskDialog.java +#======================================================================================================= +# Date time Name Action Description of Change +# 2011-1-17 03:46:21 tyl Ini ʼļ +#======================================================================================================= + */ +package cust.com.rac.workflow; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import cn.com.customization.util.GetAllUserIds; +import cn.com.customization.util.UtilApi; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; //import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class SearchTaskDialog extends AbstractAIFDialog { + // public class SearchTaskDialog extends JDialog { + // public class SearchTaskDialog extends JFrame { + private static final long serialVersionUID = 1L; + private JComboBox user_cmb; + private DateButton startTime_jtb; + private DateButton endTime_jtb; + private JCheckBox EPMTask_ck; + private JCheckBox EPMDoTask_ck; + private JCheckBox EPMReviewTask_ck; + private JCheckBox EPMAcknowledgeTask_ck; + private JCheckBox EPMAddStatusTask_ck; + private JCheckBox EPMConditionTask_ck; + private String title; + private AbstractAIFUIApplication app; + private String queryName = "__SearachViewTask"; + private String querySelectSigoff = "__SearchEPMReviewTask"; + private TCSession session; + private boolean isExceptionSearch = false; + // private String serverInfoOption = "origin_serverinfo"; + + public SearchTaskDialog(AbstractAIFUIApplication app, String title, boolean isExceptionSearch) { + super(true); + this.title = title; + this.isExceptionSearch = isExceptionSearch; + this.app = app; + session = (TCSession) app.getSession(); + initUI(); + } + + public void initUI() { + // setPersistentDisplay(false); + // setOptimalDisplay(false); + setTitle(title); + this.setResizable(false); + // this.setAlwaysOnTop(true); + // ImageIcon image = + // Registry.getImageIconFromPath("/com/teamcenter/rac/ecmanagement/images/processviewer_16.png"); + // this.setIconImage(image.getImage()); + JPanel panel = new JPanel(new PropertyLayout()); + panel.add("1.1.left.center", new JLabel(" ")); + if (isExceptionSearch) { + panel.add("1.2.left.center", setSearchExceptionPanel()); + } else { + panel.add("1.2.left.center", setSearchPanel()); + } + panel.add("2.1.left.center", new JLabel(" ")); + this.getContentPane().add(panel); + pack(); + validate(); + Dimension screen = getToolkit().getScreenSize(); + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); + this.setVisible(true); + + // showDialog(); + // Dimension screen = getToolkit().getScreenSize(); + // setLocation((screen.width - getSize().width) / 2, (screen.height - + // getSize().height) / 2); + } + + private JPanel setSearchExceptionPanel() { + startTime_jtb = new DateButton(); + endTime_jtb = new DateButton(); + JPanel panel1 = new JPanel(new PropertyLayout()); + panel1.setBorder(BorderFactory.createTitledBorder("ѯ")); + panel1.add("1.1.left.center", new JLabel(" ")); + panel1.add("2.1.left.center", new JLabel(" ִʱ_ ")); + panel1.add("2.2.left.center", startTime_jtb); + panel1.add("2.3.left.center", new JLabel(" ")); + panel1.add("3.1.left.center", new JLabel(" ִʱ_ֹ ")); + panel1.add("3.2.left.center", endTime_jtb); + panel1.add("4.1.left.center", new JLabel(" ")); + + JPanel panel = new JPanel(new PropertyLayout()); + panel.add("1.1.left.center", panel1); + panel.add("1.2.left.center", setButtonPanel()); + return panel; + } + + private JPanel setSearchPanel() { + user_cmb = new JComboBox(); + user_cmb.setPreferredSize(new Dimension(156, 27)); + startTime_jtb = new DateButton(); + endTime_jtb = new DateButton(); + + java.util.Date myDate = new java.util.Date(); + long myTime = (myDate.getTime() / 1000) - 60 * 60 * 24 * 7; + myDate.setTime(myTime * 1000); + startTime_jtb.setDate(myDate); + new Thread() { + public void run() { + while (true) { + try { + String userRole = session.getPreferenceService().getString(4, "Cust_search_task_role"); + if(session.getCurrentRole().getRoleName().equals(userRole)){ + List users = GetAllUserIds.getUsers(); + Collections.sort(users); + if (users != null) { + for (int i = 0; i < users.size(); i++) { + user_cmb.addItem(users.get(i)); + if (users.get(i).equalsIgnoreCase(session.getUser().getUserId())) { + user_cmb.setSelectedIndex(i); + } + } + user_cmb.setEnabled(true); + break; + } + }else{ + user_cmb.addItem(session.getUser()); + break; + } + } + catch (TCException e) { + e.printStackTrace(); + } + } + } + }.start(); + + JPanel panel1 = new JPanel(new PropertyLayout()); + panel1.setBorder(BorderFactory.createTitledBorder("ѯ")); + panel1.add("1.1.left.center", new JLabel(" ִ ")); + panel1.add("1.2.left.center", user_cmb); + panel1.add("1.3.left.center", new JLabel(" ")); + panel1.add("2.1.left.center", new JLabel(" ִʱ_ ")); + panel1.add("2.2.left.center", startTime_jtb); + panel1.add("2.3.left.center", new JLabel(" ")); + panel1.add("3.1.left.center", new JLabel(" ִʱ_ֹ ")); + panel1.add("3.2.left.center", endTime_jtb); + panel1.add("3.3.left.center", new JLabel(" ")); + + JPanel panel2 = new JPanel(new PropertyLayout()); + panel2.setBorder(BorderFactory.createTitledBorder("ѡѯ")); + EPMTask_ck = new JCheckBox("EPMTask"); + EPMDoTask_ck = new JCheckBox("EPMDoTask"); + EPMReviewTask_ck = new JCheckBox("EPMReviewTask"); + EPMAcknowledgeTask_ck = new JCheckBox("EPMAcknowledgeTask"); + EPMAddStatusTask_ck = new JCheckBox("EPMAddStatusTask"); + EPMConditionTask_ck = new JCheckBox("EPMConditionTask"); + + EPMTask_ck.setSelected(true); + EPMDoTask_ck.setSelected(true); + EPMReviewTask_ck.setSelected(true); + EPMAcknowledgeTask_ck.setSelected(true); + + panel2.add("1.1.left.center", EPMTask_ck); + panel2.add("1.2.left.center", EPMDoTask_ck); + panel2.add("1.3.left.center", new JLabel(" ")); + panel2.add("2.1.left.center", EPMReviewTask_ck); + panel2.add("2.2.left.center", EPMConditionTask_ck); + panel2.add("2.3.left.center", new JLabel(" ")); + panel2.add("3.1.left.center", EPMAcknowledgeTask_ck); + panel2.add("3.2.left.center", EPMAddStatusTask_ck); + + JPanel panel = new JPanel(new PropertyLayout()); + panel.add("1.1.left.center", panel1); + panel.add("2.1.left.center", panel2); + panel.add("2.2.left.center", setButtonPanel()); + return panel; + } + + private JPanel setButtonPanel() { + JPanel panel = new JPanel(new PropertyLayout()); + JButton confirmBtn = new JButton("ȷ"); + JButton cancelBtn = new JButton("ȡ"); + confirmBtn.addActionListener(new buttonListener()); + cancelBtn.addActionListener(new buttonListener()); + + panel.add("1.1.left.center", new JLabel(" ")); + panel.add("2.1.left.center", confirmBtn); + panel.add("3.1.left.center", new JLabel(" ")); + panel.add("4.1.left.center", cancelBtn); + panel.add("5.1.left.center", new JLabel(" ")); + return panel; + } + + class buttonListener implements ActionListener { + public void actionPerformed(ActionEvent actionevent) { + session.setStatus("ڲѯԵ..."); + JButton obj = ((JButton) actionevent.getSource()); + if (obj.getText().equals("ȷ")) { + try { + if (startTime_jtb.getDate() == null) { + MessageBox.post("ִʱ_ԡΪգ", "INFO", MessageBox.INFORMATION); + return; + } + Date endDate = new Date(); + if (endTime_jtb.getDate() != null) { + endDate = endTime_jtb.getDate(); + } + if (startTime_jtb.getDate().compareTo(endDate) >= 0) { + MessageBox.post("ִʱ_ֹӦȡִʱ_ԡ", "INFO", MessageBox.INFORMATION); + return; + } + List components = new ArrayList(); + SearchCondition searchCondition = new SearchCondition(); + String as[] = { "޸ʱ", "޸ʱ", "ID", "", "ModUserID"}; + + SimpleDateFormat fomat = new SimpleDateFormat("dd-M-yyyy HH:ss"); + // fomat = new SimpleDateFormat("dd-M-yyyy HH:ss:mm"); + + String startTime = fomat.format(startTime_jtb.getDate()); + String endTime = fomat.format(endDate); + /* + * windows HashMap cfghm = + * UtilApi.getPreferenceHashMap(session, + * TCPreferenceService.TC_preference_site, + * serverInfoOption); if (cfghm == null) { + * MessageBox.post("ûѡ" + serverInfoOption + "!", + * "INFO", MessageBox.INFORMATION); return; } String + * isWindows = (cfghm.get("isWindowsServer") + "").trim(); + * if (isWindows.equalsIgnoreCase("true")) { startTime = + * startTime_jtb.getDate().toLocaleString(); endTime = + * endDate.toLocaleString(); + * System.out.println("Windows:startTime=========" + + * startTime); System.out.println("Windows:endTime=========" + * + endTime); } + */ +// System.out.println("Windows:startTime=========" + startTime); +// System.out.println("Windows:endTime=========" + endTime); + searchCondition.setCreateDate(startTime); + searchCondition.setFinishDate(endTime); + + if (!isExceptionSearch) { + String user = (user_cmb.getSelectedItem().toString()); + if ((user.length() == 0) || (user == null)) { + MessageBox.post("ûΪգ", "INFO", MessageBox.INFORMATION); + return; + } + if ((!(EPMTask_ck.isSelected())) && (!(EPMDoTask_ck.isSelected())) && (!(EPMReviewTask_ck.isSelected())) && (!(EPMAcknowledgeTask_ck.isSelected())) && (!(EPMAddStatusTask_ck.isSelected()))) { + MessageBox.post("ѡѯͣ", "INFO", MessageBox.INFORMATION); + return; + } + searchCondition.setUsername(user); + user = user.substring(0, user.indexOf("(")).trim(); + List taskList = new ArrayList(); + if (EPMTask_ck.isSelected()) { + taskList.add("EPMTask"); + } + if (EPMDoTask_ck.isSelected()) { + taskList.add("EPMDoTask"); + } + if (EPMReviewTask_ck.isSelected()) { + taskList.add("EPMReviewTask"); + } + if (EPMAcknowledgeTask_ck.isSelected()) { + taskList.add("EPMAcknowledgeTask"); + } + if (EPMAddStatusTask_ck.isSelected()) { + taskList.add("EPMAddStatusTask"); + } + if (EPMConditionTask_ck.isSelected()) { + taskList.add("EPMConditionTask"); + } + + for (int i = 0; i < taskList.size(); i++) { + if (taskList.get(i).equals("EPMTask")) { + String as1[] = { startTime, endTime, user, taskList.get(i).trim(), "*" }; + InterfaceAIFComponent[] components1 = UtilApi.getQueryList((TCSession) app.getSession(), queryName, as, as1); + if (components1 != null) { + for (int m = 0; m < components1.length; m++) { + components.add(components1[m]); + } + } + } else { + if (taskList.get(i).equals("EPMReviewTask")) { + String strID[] = { "memberUser" }; + String as1[] = { user }; + InterfaceAIFComponent[] components1 = UtilApi.getQueryList((TCSession) app.getSession(), querySelectSigoff,strID, as1); + if (components1 != null) { + for (int m = 0; m < components1.length; m++) { + components.add(components1[m]); + } + } + } else { + String as1[] = { startTime, endTime, user, taskList.get(i).trim(), "*"}; + InterfaceAIFComponent[] components1 = UtilApi.getQueryList((TCSession) app.getSession(), queryName, as, as1); + if (components1 != null) { + for (int m = 0; m < components1.length; m++) { + components.add(components1[m]); + } + } + } + } + } + } else { + String as1[] = { startTime, endTime, "*", "EPMTask", "*" }; + InterfaceAIFComponent[] components1 = UtilApi.getQueryList((TCSession) app.getSession(), queryName, as, as1); + if (components1 != null) { + for (int m = 0; m < components1.length; m++) { + TCComponentTask task = (TCComponentTask) components1[m]; + isValidTask(task, components); + } + } + } + if ((components == null) || (components.size() == 0)) { + MessageBox.post("ûзҪļ¼", "INFO", MessageBox.INFORMATION); + } else { + SearchTaskDialog.this.dispose(); + new SearchResultDialog(app, components, searchCondition, isExceptionSearch); + } + } + catch (Exception e) { + e.printStackTrace(); + } + } else { + SearchTaskDialog.this.dispose(); + } + session.setReadyStatus(); + } + } + + private boolean isValidTask(TCComponentTask task, List components) { + try { + TCComponentTask[] children = task.getSubtasks(); + for (int i = 0; i < children.length; i++) { + TCComponentTask childrenTask = children[i]; + String childState = childrenTask.getProperty("real_state"); + if (childState.equals("")) { + TCComponentTask previousTask = childrenTask.getPrevious(); + if (previousTask != null) { + String previousType = previousTask.getProperty("object_type"); + String previousState = previousTask.getProperty("real_state"); + if ((previousState.equals("")) && (!previousType.equals("EPMConditionTask"))) { + components.add(childrenTask); + return false; + } else { + if (!isValidTask(childrenTask, components)) { + components.add(childrenTask); + return false; + } + } + } + } + } + String taskState = task.getProperty("real_state"); + if (taskState.equals("ѿʼ")) { + if ((children != null) && (children.length >= 3)) { + int count = 0; + for (int i = 0; i < children.length; i++) { + TCComponentTask childrenTask = children[i]; + String childState = childrenTask.getProperty("real_state"); + if (childState.equals("ѿʼ")) { + count++; + } + } + if (count == 0) { + components.add(task); + return false; + } + } + } + } + catch (TCException e) { + e.printStackTrace(); + } + return true; + } + + class SearchCondition { + private String username; + private String createDate; + private String finishDate; + + /** + * @return the username + */ + public String getUsername() { + return username; + } + + /** + * @param username the username to set + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * @return the createDate + */ + public String getCreateDate() { + return createDate; + } + + /** + * @param createDate the createDate to set + */ + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + + /** + * @return the finishDate + */ + public String getFinishDate() { + return finishDate; + } + + /** + * @param finishDate the finishDate to set + */ + public void setFinishDate(String finishDate) { + this.finishDate = finishDate; + } + } +} diff --git a/src/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand.java b/src/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand.java new file mode 100644 index 0000000..e1228e3 --- /dev/null +++ b/src/cust/com/rac/workflow/SubmitAttachmentInWorkflowCommand.java @@ -0,0 +1,74 @@ +/* +#============================================================================= +# +# opyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: SubmitAttachmentInWorkflowCommand.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# +#============================================================================= +*/ +package cust.com.rac.workflow; + +import cn.com.customization.imports.importfiles.ImportFile; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +/** + * @author + */ +public class SubmitAttachmentInWorkflowCommand extends AbstractAIFCommand { + + public AbstractAIFUIApplication application; + private TCComponent theTargetComp= null; + private TCComponent parentComp = null; + + public SubmitAttachmentInWorkflowCommand(AbstractAIFUIApplication abstractaifapplication) throws TCException { + application = abstractaifapplication; + execute(); + } + + private void execute() throws TCException { + InterfaceAIFComponent aifComp = application.getTargetComponent(); + if(!(aifComp instanceof TCComponentPseudoFolder)){ + MessageBox.post("ѡitem RevisionµĹϵļִв", "", MessageBox.WARNING); + return; + } + + TCComponent target = (TCComponent) aifComp; + AIFComponentContext[] context = target.whereReferenced(); + for(int i = 0; context != null && i < context.length ;i++ ){ + parentComp = (TCComponent) context[i].getComponent(); + if(parentComp instanceof TCComponentItemRevision){ + String strJobName = parentComp.getProperty("current_job"); + System.out.println("strJobName = " + strJobName); + if(!strJobName.equals("") && !strJobName.equals("ûֵ")){ + theTargetComp = (TCComponent) aifComp; + break; + } + } + } + if(theTargetComp == null){ + MessageBox.post("ѡitem RevisionµĹϵļִв", "", MessageBox.WARNING); + return; + } + new Thread() { + public void run() { + new ImportFile(application,new TCComponent[]{parentComp,theTargetComp}); + } + }.start(); + + + } +} diff --git a/src/cust/com/rac/workflow/SubmitAttachmentInWorkflowHandler.java b/src/cust/com/rac/workflow/SubmitAttachmentInWorkflowHandler.java new file mode 100644 index 0000000..852b52c --- /dev/null +++ b/src/cust/com/rac/workflow/SubmitAttachmentInWorkflowHandler.java @@ -0,0 +1,46 @@ +/* +#============================================================================= +# +# copyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: SubmitAttachmentInWorkflowHandler.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# +#============================================================================= + */ +package cust.com.rac.workflow; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +/** + * @author + */ +public class SubmitAttachmentInWorkflowHandler extends AbstractHandler implements IHandler { + + /* + * @see + * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. + * ExecutionEvent) + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + SubmitAttachmentInWorkflowCommand command = new SubmitAttachmentInWorkflowCommand(app); + command.executeModal(); + } catch (TCException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/cust/com/ysr/Activator.java b/src/cust/com/ysr/Activator.java new file mode 100644 index 0000000..f94eeec --- /dev/null +++ b/src/cust/com/ysr/Activator.java @@ -0,0 +1,47 @@ +package cust.com.ysr; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "cust.com.ysr"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/src/cust/com/ysr/test.java b/src/cust/com/ysr/test.java new file mode 100644 index 0000000..90a0b00 --- /dev/null +++ b/src/cust/com/ysr/test.java @@ -0,0 +1,21 @@ +package cust.com.ysr; + +public class test { + + public static void main(String[] args) { + // TODO Auto-generated method stub + String str ="[ProjectID]_9000"; + System.out.println(str.indexOf("[ProjectID]")); + Object stt = new Object[]{"1","2"}; + Object arr[] = (Object[])stt; + System.out.println(arr[0]); + + String s1="1||2"; + String[] s3 = s1.split("\\|\\|"); + System.out.println("len="+s3.length); + for(String s2:s3){ + System.out.println(s2); + } + } + +} diff --git a/src/ysr/com/teamcenter/BPMTest.java b/src/ysr/com/teamcenter/BPMTest.java new file mode 100644 index 0000000..d7afd67 --- /dev/null +++ b/src/ysr/com/teamcenter/BPMTest.java @@ -0,0 +1,171 @@ +package ysr.com.teamcenter; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class BPMTest { + + public static void main(String[] args) { + // TODO Auto-generated method stub +// sendPStartNotificationToPLM(); +// sendOrderNoticeToPLM(); +// sendTravelOrderToPLM(); + SendDeliveryDateToPLM(); +// SendAccepComToPLM(); + } + + public static void SendAccepComToPLM(){ + String xml = ""+ + ""+ + ""+ + "Ź"+ + "2017-10-06 17:59:06"+//ϣ + ""+ + "ȷϽ"+ + "ԭ"+ + ""+ + "ͻ"+ + "URL"+ + ""+ + ""; + YSRServerService ysrServer = new YSRServerService(); + String rError = ysrServer.getYSRServerPort().sendAccepComToPLM(xml); + System.out.println("rError="+rError); + } + + public static void SendDeliveryDateToPLM(){ + YSRServerService ysrServer = new YSRServerService(); + String rError = ysrServer.getYSRServerPort().sendDeliveryDateToPLM("000108", "2017-10-06 17:59:06"); + System.out.println("rError="+rError); + } + public static void sendQuotationToPLM(){ + String xml = ""+ + ""+ + ""+ + ""+ + "û"+ + "ˮƽ"+ + "19-Apr-2017 01:00:34"+//յ2017-05-06 08:59:06 + "2017-10-06 17:59:06"+//ϣ + "۵"+ + "Ŀ"+ + "۵ȼ"+ + "ʱ"+ + "ϵ"+ + ""+ + "ְ"+ + "ϵ绰"+ + "۽"+ + "URL"+ + ""+ + ""; + YSRServerService ysrServer = new YSRServerService(); + String rError = ysrServer.getYSRServerPort().sendQuotationToPLM(xml); + System.out.println("rError="+rError); + } + + public static void sendPStartNotificationToPLM(){ + String xml = ""+ + ""+ + ""+ + "2017-05-06 08:59:06"+ + "2017-10-06 17:59:06"+ + "а汾"+ + ""+ + ""+ + "10.2"+ + "2"+ + "80"+ + "۵"+ + "ͻ"+ + "û"+ + "Ŀ"+ + "Ԥƺ֧ͬʽ"+ + "2017-11-06 17:59:06"+ + "2018-10-06 17:59:06"+ + "˵"+ + "URL"+ + ""+ + ""; + YSRServerService ysrServer = new YSRServerService(); + String rError = ysrServer.getYSRServerPort().sendPStartNotificationToPLM(xml); + System.out.println("rError="+rError); + } + + public static void sendOrderNoticeToPLM(){ + String xml = ""+ + ""+ + ""+ + ""+ + "2017-05-06 08:59:06"+ + "2017-10-06 17:59:06"+ + "Ӫҵ"+ + "۵"+ + "ͬ"+ + "û"+ + "ͻ"+ + "ʹ"+ + "ҵ"+ + "Ʒ"+ + ";"+ + ""+ + "10"+ + "ջ˾"+ + "˾ַʱ"+ + "ϵ"+ + ""+ + "ע"+ + "URL"+ + ""+ + ""; + YSRServerService ysrServer = new YSRServerService(); + String rError = ysrServer.getYSRServerPort().sendOrderNoticeToPLM(xml); + System.out.println("rError="+rError); + } + + public static void sendTravelOrderToPLM(){ + String xml = ""+ + ""+ + ""+ + "ί"+ + "2017-05-06 08:59:06"+ + "2017-05-10 08:59:06"+ + "2017-06-06 08:59:06"+ + "ͻ"+ + "Ŀ"+ + "ͻַ"+ + "ͻϵ"+ + "ͻ绰"+ + ""+ + "22"+ + "30"+ + "в"+ + "Ա"+ + "ע"+ + "Ƿи"+ + "URL"+ + ""+ + ""; + YSRServerService ysrServer = new YSRServerService(); + String rError = ysrServer.getYSRServerPort().sendTravelOrderToPLM(xml); + System.out.println("rError="+rError); + } + + private void test(){ + SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss",Locale.ENGLISH);// HH:mm:ss + try { + System.out.println(sdf.parse("19-Apr-2017 01:00:34")); +// System.out.println(sdf.parse("1970-02-30 00:00:00").getTime()); + + SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss",Locale.ENGLISH); + String date = dateFormat.format(new Date()); + System.out.println("date="+date); + + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/src/ysr/com/teamcenter/ObjectFactory.class b/src/ysr/com/teamcenter/ObjectFactory.class new file mode 100644 index 0000000..d6e7d26 Binary files /dev/null and b/src/ysr/com/teamcenter/ObjectFactory.class differ diff --git a/src/ysr/com/teamcenter/ObjectFactory.java b/src/ysr/com/teamcenter/ObjectFactory.java new file mode 100644 index 0000000..31d046d --- /dev/null +++ b/src/ysr/com/teamcenter/ObjectFactory.java @@ -0,0 +1,251 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the ysr.com.teamcenter package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _SendPStartNotificationToPLM_QNAME = new QName("http://teamcenter.com.ysr/", "SendPStartNotificationToPLM"); + private final static QName _SendDeliveryDateToPLMResponse_QNAME = new QName("http://teamcenter.com.ysr/", "SendDeliveryDateToPLMResponse"); + private final static QName _SendTravelOrderToPLM_QNAME = new QName("http://teamcenter.com.ysr/", "SendTravelOrderToPLM"); + private final static QName _SendDeliveryDateToPLM_QNAME = new QName("http://teamcenter.com.ysr/", "SendDeliveryDateToPLM"); + private final static QName _SendAccepComToPLM_QNAME = new QName("http://teamcenter.com.ysr/", "SendAccepComToPLM"); + private final static QName _SendAccepComToPLMResponse_QNAME = new QName("http://teamcenter.com.ysr/", "SendAccepComToPLMResponse"); + private final static QName _SendQuotationToPLM_QNAME = new QName("http://teamcenter.com.ysr/", "sendQuotationToPLM"); + private final static QName _SendOrderNoticeToPLM_QNAME = new QName("http://teamcenter.com.ysr/", "SendOrderNoticeToPLM"); + private final static QName _SendOrderNoticeToPLMResponse_QNAME = new QName("http://teamcenter.com.ysr/", "SendOrderNoticeToPLMResponse"); + private final static QName _SendQuotationToPLMResponse_QNAME = new QName("http://teamcenter.com.ysr/", "sendQuotationToPLMResponse"); + private final static QName _SendPStartNotificationToPLMResponse_QNAME = new QName("http://teamcenter.com.ysr/", "SendPStartNotificationToPLMResponse"); + private final static QName _SendTravelOrderToPLMResponse_QNAME = new QName("http://teamcenter.com.ysr/", "SendTravelOrderToPLMResponse"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: ysr.com.teamcenter + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link SendTravelOrderToPLMResponse } + * + */ + public SendTravelOrderToPLMResponse createSendTravelOrderToPLMResponse() { + return new SendTravelOrderToPLMResponse(); + } + + /** + * Create an instance of {@link SendPStartNotificationToPLMResponse } + * + */ + public SendPStartNotificationToPLMResponse createSendPStartNotificationToPLMResponse() { + return new SendPStartNotificationToPLMResponse(); + } + + /** + * Create an instance of {@link SendOrderNoticeToPLM } + * + */ + public SendOrderNoticeToPLM createSendOrderNoticeToPLM() { + return new SendOrderNoticeToPLM(); + } + + /** + * Create an instance of {@link SendOrderNoticeToPLMResponse } + * + */ + public SendOrderNoticeToPLMResponse createSendOrderNoticeToPLMResponse() { + return new SendOrderNoticeToPLMResponse(); + } + + /** + * Create an instance of {@link SendQuotationToPLMResponse } + * + */ + public SendQuotationToPLMResponse createSendQuotationToPLMResponse() { + return new SendQuotationToPLMResponse(); + } + + /** + * Create an instance of {@link SendQuotationToPLM } + * + */ + public SendQuotationToPLM createSendQuotationToPLM() { + return new SendQuotationToPLM(); + } + + /** + * Create an instance of {@link SendAccepComToPLMResponse } + * + */ + public SendAccepComToPLMResponse createSendAccepComToPLMResponse() { + return new SendAccepComToPLMResponse(); + } + + /** + * Create an instance of {@link SendAccepComToPLM } + * + */ + public SendAccepComToPLM createSendAccepComToPLM() { + return new SendAccepComToPLM(); + } + + /** + * Create an instance of {@link SendDeliveryDateToPLM } + * + */ + public SendDeliveryDateToPLM createSendDeliveryDateToPLM() { + return new SendDeliveryDateToPLM(); + } + + /** + * Create an instance of {@link SendDeliveryDateToPLMResponse } + * + */ + public SendDeliveryDateToPLMResponse createSendDeliveryDateToPLMResponse() { + return new SendDeliveryDateToPLMResponse(); + } + + /** + * Create an instance of {@link SendTravelOrderToPLM } + * + */ + public SendTravelOrderToPLM createSendTravelOrderToPLM() { + return new SendTravelOrderToPLM(); + } + + /** + * Create an instance of {@link SendPStartNotificationToPLM } + * + */ + public SendPStartNotificationToPLM createSendPStartNotificationToPLM() { + return new SendPStartNotificationToPLM(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendPStartNotificationToPLM }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendPStartNotificationToPLM") + public JAXBElement createSendPStartNotificationToPLM(SendPStartNotificationToPLM value) { + return new JAXBElement(_SendPStartNotificationToPLM_QNAME, SendPStartNotificationToPLM.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendDeliveryDateToPLMResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendDeliveryDateToPLMResponse") + public JAXBElement createSendDeliveryDateToPLMResponse(SendDeliveryDateToPLMResponse value) { + return new JAXBElement(_SendDeliveryDateToPLMResponse_QNAME, SendDeliveryDateToPLMResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendTravelOrderToPLM }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendTravelOrderToPLM") + public JAXBElement createSendTravelOrderToPLM(SendTravelOrderToPLM value) { + return new JAXBElement(_SendTravelOrderToPLM_QNAME, SendTravelOrderToPLM.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendDeliveryDateToPLM }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendDeliveryDateToPLM") + public JAXBElement createSendDeliveryDateToPLM(SendDeliveryDateToPLM value) { + return new JAXBElement(_SendDeliveryDateToPLM_QNAME, SendDeliveryDateToPLM.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendAccepComToPLM }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendAccepComToPLM") + public JAXBElement createSendAccepComToPLM(SendAccepComToPLM value) { + return new JAXBElement(_SendAccepComToPLM_QNAME, SendAccepComToPLM.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendAccepComToPLMResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendAccepComToPLMResponse") + public JAXBElement createSendAccepComToPLMResponse(SendAccepComToPLMResponse value) { + return new JAXBElement(_SendAccepComToPLMResponse_QNAME, SendAccepComToPLMResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendQuotationToPLM }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "sendQuotationToPLM") + public JAXBElement createSendQuotationToPLM(SendQuotationToPLM value) { + return new JAXBElement(_SendQuotationToPLM_QNAME, SendQuotationToPLM.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendOrderNoticeToPLM }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendOrderNoticeToPLM") + public JAXBElement createSendOrderNoticeToPLM(SendOrderNoticeToPLM value) { + return new JAXBElement(_SendOrderNoticeToPLM_QNAME, SendOrderNoticeToPLM.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendOrderNoticeToPLMResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendOrderNoticeToPLMResponse") + public JAXBElement createSendOrderNoticeToPLMResponse(SendOrderNoticeToPLMResponse value) { + return new JAXBElement(_SendOrderNoticeToPLMResponse_QNAME, SendOrderNoticeToPLMResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendQuotationToPLMResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "sendQuotationToPLMResponse") + public JAXBElement createSendQuotationToPLMResponse(SendQuotationToPLMResponse value) { + return new JAXBElement(_SendQuotationToPLMResponse_QNAME, SendQuotationToPLMResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendPStartNotificationToPLMResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendPStartNotificationToPLMResponse") + public JAXBElement createSendPStartNotificationToPLMResponse(SendPStartNotificationToPLMResponse value) { + return new JAXBElement(_SendPStartNotificationToPLMResponse_QNAME, SendPStartNotificationToPLMResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SendTravelOrderToPLMResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://teamcenter.com.ysr/", name = "SendTravelOrderToPLMResponse") + public JAXBElement createSendTravelOrderToPLMResponse(SendTravelOrderToPLMResponse value) { + return new JAXBElement(_SendTravelOrderToPLMResponse_QNAME, SendTravelOrderToPLMResponse.class, null, value); + } + +} diff --git a/src/ysr/com/teamcenter/SendAccepComToBPM.class b/src/ysr/com/teamcenter/SendAccepComToBPM.class new file mode 100644 index 0000000..e52f6e7 Binary files /dev/null and b/src/ysr/com/teamcenter/SendAccepComToBPM.class differ diff --git a/src/ysr/com/teamcenter/SendAccepComToBPM.java b/src/ysr/com/teamcenter/SendAccepComToBPM.java new file mode 100644 index 0000000..70c84f7 --- /dev/null +++ b/src/ysr/com/teamcenter/SendAccepComToBPM.java @@ -0,0 +1,60 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendAccepComToBPM complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendAccepComToBPM">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendAccepComToBPM", propOrder = { + "arg0" +}) +public class SendAccepComToBPM { + + protected String arg0; + + /** + * ȡarg0Եֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg0() { + return arg0; + } + + /** + * arg0Եֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg0(String value) { + this.arg0 = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendAccepComToBPMResponse.class b/src/ysr/com/teamcenter/SendAccepComToBPMResponse.class new file mode 100644 index 0000000..22ba615 Binary files /dev/null and b/src/ysr/com/teamcenter/SendAccepComToBPMResponse.class differ diff --git a/src/ysr/com/teamcenter/SendAccepComToBPMResponse.java b/src/ysr/com/teamcenter/SendAccepComToBPMResponse.java new file mode 100644 index 0000000..5c52e9a --- /dev/null +++ b/src/ysr/com/teamcenter/SendAccepComToBPMResponse.java @@ -0,0 +1,62 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendAccepComToBPMResponse complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendAccepComToBPMResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendAccepComToBPMResponse", propOrder = { + "_return" +}) +public class SendAccepComToBPMResponse { + + @XmlElement(name = "return") + protected String _return; + + /** + * ȡreturnԵֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturn() { + return _return; + } + + /** + * returnԵֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturn(String value) { + this._return = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendAccepComToPLM.class b/src/ysr/com/teamcenter/SendAccepComToPLM.class new file mode 100644 index 0000000..c7da2b3 Binary files /dev/null and b/src/ysr/com/teamcenter/SendAccepComToPLM.class differ diff --git a/src/ysr/com/teamcenter/SendAccepComToPLM.java b/src/ysr/com/teamcenter/SendAccepComToPLM.java new file mode 100644 index 0000000..0024a43 --- /dev/null +++ b/src/ysr/com/teamcenter/SendAccepComToPLM.java @@ -0,0 +1,60 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendAccepComToPLM complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendAccepComToPLM">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendAccepComToPLM", propOrder = { + "arg0" +}) +public class SendAccepComToPLM { + + protected String arg0; + + /** + * ȡarg0Եֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg0() { + return arg0; + } + + /** + * arg0Եֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg0(String value) { + this.arg0 = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendAccepComToPLMResponse.class b/src/ysr/com/teamcenter/SendAccepComToPLMResponse.class new file mode 100644 index 0000000..04e1549 Binary files /dev/null and b/src/ysr/com/teamcenter/SendAccepComToPLMResponse.class differ diff --git a/src/ysr/com/teamcenter/SendAccepComToPLMResponse.java b/src/ysr/com/teamcenter/SendAccepComToPLMResponse.java new file mode 100644 index 0000000..15bd4bd --- /dev/null +++ b/src/ysr/com/teamcenter/SendAccepComToPLMResponse.java @@ -0,0 +1,62 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendAccepComToPLMResponse complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendAccepComToPLMResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendAccepComToPLMResponse", propOrder = { + "_return" +}) +public class SendAccepComToPLMResponse { + + @XmlElement(name = "return") + protected String _return; + + /** + * ȡreturnԵֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturn() { + return _return; + } + + /** + * returnԵֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturn(String value) { + this._return = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendBPMToPLM.class b/src/ysr/com/teamcenter/SendBPMToPLM.class new file mode 100644 index 0000000..e37253e Binary files /dev/null and b/src/ysr/com/teamcenter/SendBPMToPLM.class differ diff --git a/src/ysr/com/teamcenter/SendBPMToPLMResponse.class b/src/ysr/com/teamcenter/SendBPMToPLMResponse.class new file mode 100644 index 0000000..f3a1707 Binary files /dev/null and b/src/ysr/com/teamcenter/SendBPMToPLMResponse.class differ diff --git a/src/ysr/com/teamcenter/SendDeliveryDateToPLM.class b/src/ysr/com/teamcenter/SendDeliveryDateToPLM.class new file mode 100644 index 0000000..c0b2e29 Binary files /dev/null and b/src/ysr/com/teamcenter/SendDeliveryDateToPLM.class differ diff --git a/src/ysr/com/teamcenter/SendDeliveryDateToPLM.java b/src/ysr/com/teamcenter/SendDeliveryDateToPLM.java new file mode 100644 index 0000000..5fa717e --- /dev/null +++ b/src/ysr/com/teamcenter/SendDeliveryDateToPLM.java @@ -0,0 +1,87 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendDeliveryDateToPLM complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendDeliveryDateToPLM">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendDeliveryDateToPLM", propOrder = { + "arg0", + "arg1" +}) +public class SendDeliveryDateToPLM { + + protected String arg0; + protected String arg1; + + /** + * ȡarg0Եֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg0() { + return arg0; + } + + /** + * arg0Եֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg0(String value) { + this.arg0 = value; + } + + /** + * ȡarg1Եֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg1() { + return arg1; + } + + /** + * arg1Եֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg1(String value) { + this.arg1 = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.class b/src/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.class new file mode 100644 index 0000000..21af296 Binary files /dev/null and b/src/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.class differ diff --git a/src/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.java b/src/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.java new file mode 100644 index 0000000..e6f30f2 --- /dev/null +++ b/src/ysr/com/teamcenter/SendDeliveryDateToPLMResponse.java @@ -0,0 +1,62 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendDeliveryDateToPLMResponse complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendDeliveryDateToPLMResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendDeliveryDateToPLMResponse", propOrder = { + "_return" +}) +public class SendDeliveryDateToPLMResponse { + + @XmlElement(name = "return") + protected String _return; + + /** + * ȡreturnԵֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturn() { + return _return; + } + + /** + * returnԵֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturn(String value) { + this._return = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendOrderNoticeToPLM.class b/src/ysr/com/teamcenter/SendOrderNoticeToPLM.class new file mode 100644 index 0000000..7450a41 Binary files /dev/null and b/src/ysr/com/teamcenter/SendOrderNoticeToPLM.class differ diff --git a/src/ysr/com/teamcenter/SendOrderNoticeToPLM.java b/src/ysr/com/teamcenter/SendOrderNoticeToPLM.java new file mode 100644 index 0000000..f39f816 --- /dev/null +++ b/src/ysr/com/teamcenter/SendOrderNoticeToPLM.java @@ -0,0 +1,60 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendOrderNoticeToPLM complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendOrderNoticeToPLM">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendOrderNoticeToPLM", propOrder = { + "arg0" +}) +public class SendOrderNoticeToPLM { + + protected String arg0; + + /** + * ȡarg0Եֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg0() { + return arg0; + } + + /** + * arg0Եֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg0(String value) { + this.arg0 = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.class b/src/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.class new file mode 100644 index 0000000..b661439 Binary files /dev/null and b/src/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.class differ diff --git a/src/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.java b/src/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.java new file mode 100644 index 0000000..dd13b7f --- /dev/null +++ b/src/ysr/com/teamcenter/SendOrderNoticeToPLMResponse.java @@ -0,0 +1,62 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendOrderNoticeToPLMResponse complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendOrderNoticeToPLMResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendOrderNoticeToPLMResponse", propOrder = { + "_return" +}) +public class SendOrderNoticeToPLMResponse { + + @XmlElement(name = "return") + protected String _return; + + /** + * ȡreturnԵֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturn() { + return _return; + } + + /** + * returnԵֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturn(String value) { + this._return = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendPStartNotificationToPLM.class b/src/ysr/com/teamcenter/SendPStartNotificationToPLM.class new file mode 100644 index 0000000..ce2319a Binary files /dev/null and b/src/ysr/com/teamcenter/SendPStartNotificationToPLM.class differ diff --git a/src/ysr/com/teamcenter/SendPStartNotificationToPLM.java b/src/ysr/com/teamcenter/SendPStartNotificationToPLM.java new file mode 100644 index 0000000..2565fe8 --- /dev/null +++ b/src/ysr/com/teamcenter/SendPStartNotificationToPLM.java @@ -0,0 +1,60 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendPStartNotificationToPLM complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendPStartNotificationToPLM">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendPStartNotificationToPLM", propOrder = { + "arg0" +}) +public class SendPStartNotificationToPLM { + + protected String arg0; + + /** + * ȡarg0Եֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg0() { + return arg0; + } + + /** + * arg0Եֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg0(String value) { + this.arg0 = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.class b/src/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.class new file mode 100644 index 0000000..f8d2dc3 Binary files /dev/null and b/src/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.class differ diff --git a/src/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.java b/src/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.java new file mode 100644 index 0000000..4ab235a --- /dev/null +++ b/src/ysr/com/teamcenter/SendPStartNotificationToPLMResponse.java @@ -0,0 +1,62 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendPStartNotificationToPLMResponse complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendPStartNotificationToPLMResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendPStartNotificationToPLMResponse", propOrder = { + "_return" +}) +public class SendPStartNotificationToPLMResponse { + + @XmlElement(name = "return") + protected String _return; + + /** + * ȡreturnԵֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturn() { + return _return; + } + + /** + * returnԵֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturn(String value) { + this._return = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendQuotationToPLM.class b/src/ysr/com/teamcenter/SendQuotationToPLM.class new file mode 100644 index 0000000..a15b82b Binary files /dev/null and b/src/ysr/com/teamcenter/SendQuotationToPLM.class differ diff --git a/src/ysr/com/teamcenter/SendQuotationToPLM.java b/src/ysr/com/teamcenter/SendQuotationToPLM.java new file mode 100644 index 0000000..5ce0791 --- /dev/null +++ b/src/ysr/com/teamcenter/SendQuotationToPLM.java @@ -0,0 +1,60 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

sendQuotationToPLM complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="sendQuotationToPLM">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "sendQuotationToPLM", propOrder = { + "arg0" +}) +public class SendQuotationToPLM { + + protected String arg0; + + /** + * ȡarg0Եֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg0() { + return arg0; + } + + /** + * arg0Եֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg0(String value) { + this.arg0 = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendQuotationToPLMResponse.class b/src/ysr/com/teamcenter/SendQuotationToPLMResponse.class new file mode 100644 index 0000000..da7707d Binary files /dev/null and b/src/ysr/com/teamcenter/SendQuotationToPLMResponse.class differ diff --git a/src/ysr/com/teamcenter/SendQuotationToPLMResponse.java b/src/ysr/com/teamcenter/SendQuotationToPLMResponse.java new file mode 100644 index 0000000..2db87e6 --- /dev/null +++ b/src/ysr/com/teamcenter/SendQuotationToPLMResponse.java @@ -0,0 +1,62 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

sendQuotationToPLMResponse complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="sendQuotationToPLMResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "sendQuotationToPLMResponse", propOrder = { + "_return" +}) +public class SendQuotationToPLMResponse { + + @XmlElement(name = "return") + protected String _return; + + /** + * ȡreturnԵֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturn() { + return _return; + } + + /** + * returnԵֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturn(String value) { + this._return = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendTravelOrderToPLM.class b/src/ysr/com/teamcenter/SendTravelOrderToPLM.class new file mode 100644 index 0000000..5246704 Binary files /dev/null and b/src/ysr/com/teamcenter/SendTravelOrderToPLM.class differ diff --git a/src/ysr/com/teamcenter/SendTravelOrderToPLM.java b/src/ysr/com/teamcenter/SendTravelOrderToPLM.java new file mode 100644 index 0000000..babb506 --- /dev/null +++ b/src/ysr/com/teamcenter/SendTravelOrderToPLM.java @@ -0,0 +1,60 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendTravelOrderToPLM complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendTravelOrderToPLM">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendTravelOrderToPLM", propOrder = { + "arg0" +}) +public class SendTravelOrderToPLM { + + protected String arg0; + + /** + * ȡarg0Եֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg0() { + return arg0; + } + + /** + * arg0Եֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg0(String value) { + this.arg0 = value; + } + +} diff --git a/src/ysr/com/teamcenter/SendTravelOrderToPLMResponse.class b/src/ysr/com/teamcenter/SendTravelOrderToPLMResponse.class new file mode 100644 index 0000000..62b4808 Binary files /dev/null and b/src/ysr/com/teamcenter/SendTravelOrderToPLMResponse.class differ diff --git a/src/ysr/com/teamcenter/SendTravelOrderToPLMResponse.java b/src/ysr/com/teamcenter/SendTravelOrderToPLMResponse.java new file mode 100644 index 0000000..7e35f32 --- /dev/null +++ b/src/ysr/com/teamcenter/SendTravelOrderToPLMResponse.java @@ -0,0 +1,62 @@ + +package ysr.com.teamcenter; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

SendTravelOrderToPLMResponse complex type Java ࡣ + * + *

ģʽƬָڴеԤݡ + * + *

+ * <complexType name="SendTravelOrderToPLMResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SendTravelOrderToPLMResponse", propOrder = { + "_return" +}) +public class SendTravelOrderToPLMResponse { + + @XmlElement(name = "return") + protected String _return; + + /** + * ȡreturnԵֵ + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturn() { + return _return; + } + + /** + * returnԵֵ + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturn(String value) { + this._return = value; + } + +} diff --git a/src/ysr/com/teamcenter/YSRServerDelegate.class b/src/ysr/com/teamcenter/YSRServerDelegate.class new file mode 100644 index 0000000..767712e Binary files /dev/null and b/src/ysr/com/teamcenter/YSRServerDelegate.class differ diff --git a/src/ysr/com/teamcenter/YSRServerDelegate.java b/src/ysr/com/teamcenter/YSRServerDelegate.java new file mode 100644 index 0000000..ac58f52 --- /dev/null +++ b/src/ysr/com/teamcenter/YSRServerDelegate.java @@ -0,0 +1,120 @@ + +package ysr.com.teamcenter; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.Action; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebService(name = "YSRServerDelegate", targetNamespace = "http://teamcenter.com.ysr/") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface YSRServerDelegate { + + + /** + * + * @param arg0 + * @return + * returns java.lang.String + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "sendQuotationToPLM", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendQuotationToPLM") + @ResponseWrapper(localName = "sendQuotationToPLMResponse", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendQuotationToPLMResponse") + @Action(input = "http://teamcenter.com.ysr/YSRServerDelegate/sendQuotationToPLMRequest", output = "http://teamcenter.com.ysr/YSRServerDelegate/sendQuotationToPLMResponse") + public String sendQuotationToPLM( + @WebParam(name = "arg0", targetNamespace = "") + String arg0); + + /** + * + * @param arg0 + * @return + * returns java.lang.String + */ + @WebMethod(operationName = "SendPStartNotificationToPLM") + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "SendPStartNotificationToPLM", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendPStartNotificationToPLM") + @ResponseWrapper(localName = "SendPStartNotificationToPLMResponse", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendPStartNotificationToPLMResponse") + @Action(input = "http://teamcenter.com.ysr/YSRServerDelegate/SendPStartNotificationToPLMRequest", output = "http://teamcenter.com.ysr/YSRServerDelegate/SendPStartNotificationToPLMResponse") + public String sendPStartNotificationToPLM( + @WebParam(name = "arg0", targetNamespace = "") + String arg0); + + /** + * + * @param arg0 + * @return + * returns java.lang.String + */ + @WebMethod(operationName = "SendOrderNoticeToPLM") + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "SendOrderNoticeToPLM", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendOrderNoticeToPLM") + @ResponseWrapper(localName = "SendOrderNoticeToPLMResponse", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendOrderNoticeToPLMResponse") + @Action(input = "http://teamcenter.com.ysr/YSRServerDelegate/SendOrderNoticeToPLMRequest", output = "http://teamcenter.com.ysr/YSRServerDelegate/SendOrderNoticeToPLMResponse") + public String sendOrderNoticeToPLM( + @WebParam(name = "arg0", targetNamespace = "") + String arg0); + + /** + * + * @param arg0 + * @return + * returns java.lang.String + */ + @WebMethod(operationName = "SendTravelOrderToPLM") + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "SendTravelOrderToPLM", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendTravelOrderToPLM") + @ResponseWrapper(localName = "SendTravelOrderToPLMResponse", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendTravelOrderToPLMResponse") + @Action(input = "http://teamcenter.com.ysr/YSRServerDelegate/SendTravelOrderToPLMRequest", output = "http://teamcenter.com.ysr/YSRServerDelegate/SendTravelOrderToPLMResponse") + public String sendTravelOrderToPLM( + @WebParam(name = "arg0", targetNamespace = "") + String arg0); + + /** + * + * @param arg1 + * @param arg0 + * @return + * returns java.lang.String + */ + @WebMethod(operationName = "SendDeliveryDateToPLM") + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "SendDeliveryDateToPLM", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendDeliveryDateToPLM") + @ResponseWrapper(localName = "SendDeliveryDateToPLMResponse", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendDeliveryDateToPLMResponse") + @Action(input = "http://teamcenter.com.ysr/YSRServerDelegate/SendDeliveryDateToPLMRequest", output = "http://teamcenter.com.ysr/YSRServerDelegate/SendDeliveryDateToPLMResponse") + public String sendDeliveryDateToPLM( + @WebParam(name = "arg0", targetNamespace = "") + String arg0, + @WebParam(name = "arg1", targetNamespace = "") + String arg1); + + /** + * + * @param arg0 + * @return + * returns java.lang.String + */ + @WebMethod(operationName = "SendAccepComToPLM") + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "SendAccepComToPLM", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendAccepComToPLM") + @ResponseWrapper(localName = "SendAccepComToPLMResponse", targetNamespace = "http://teamcenter.com.ysr/", className = "ysr.com.teamcenter.SendAccepComToPLMResponse") + @Action(input = "http://teamcenter.com.ysr/YSRServerDelegate/SendAccepComToPLMRequest", output = "http://teamcenter.com.ysr/YSRServerDelegate/SendAccepComToPLMResponse") + public String sendAccepComToPLM( + @WebParam(name = "arg0", targetNamespace = "") + String arg0); + +} diff --git a/src/ysr/com/teamcenter/YSRServerService.class b/src/ysr/com/teamcenter/YSRServerService.class new file mode 100644 index 0000000..73acce4 Binary files /dev/null and b/src/ysr/com/teamcenter/YSRServerService.class differ diff --git a/src/ysr/com/teamcenter/YSRServerService.java b/src/ysr/com/teamcenter/YSRServerService.java new file mode 100644 index 0000000..a33803f --- /dev/null +++ b/src/ysr/com/teamcenter/YSRServerService.java @@ -0,0 +1,94 @@ + +package ysr.com.teamcenter; + +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebServiceClient(name = "YSRServerService", targetNamespace = "http://teamcenter.com.ysr/", wsdlLocation = "file:/C:/Users/Administrator/Desktop/YSRServerService.wsdl") +public class YSRServerService + extends Service +{ + + private final static URL YSRSERVERSERVICE_WSDL_LOCATION; + private final static WebServiceException YSRSERVERSERVICE_EXCEPTION; + private final static QName YSRSERVERSERVICE_QNAME = new QName("http://teamcenter.com.ysr/", "YSRServerService"); + + static { + URL url = null; + WebServiceException e = null; + try { + url = new URL("file:/C:/Users/Administrator/Desktop/YSRServerService.wsdl"); + } catch (MalformedURLException ex) { + e = new WebServiceException(ex); + } + YSRSERVERSERVICE_WSDL_LOCATION = url; + YSRSERVERSERVICE_EXCEPTION = e; + } + + public YSRServerService() { + super(__getWsdlLocation(), YSRSERVERSERVICE_QNAME); + } + + public YSRServerService(WebServiceFeature... features) { + super(__getWsdlLocation(), YSRSERVERSERVICE_QNAME, features); + } + + public YSRServerService(URL wsdlLocation) { + super(wsdlLocation, YSRSERVERSERVICE_QNAME); + } + + public YSRServerService(URL wsdlLocation, WebServiceFeature... features) { + super(wsdlLocation, YSRSERVERSERVICE_QNAME, features); + } + + public YSRServerService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public YSRServerService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns YSRServerDelegate + */ + @WebEndpoint(name = "YSRServerPort") + public YSRServerDelegate getYSRServerPort() { + return super.getPort(new QName("http://teamcenter.com.ysr/", "YSRServerPort"), YSRServerDelegate.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns YSRServerDelegate + */ + @WebEndpoint(name = "YSRServerPort") + public YSRServerDelegate getYSRServerPort(WebServiceFeature... features) { + return super.getPort(new QName("http://teamcenter.com.ysr/", "YSRServerPort"), YSRServerDelegate.class, features); + } + + private static URL __getWsdlLocation() { + if (YSRSERVERSERVICE_EXCEPTION!= null) { + throw YSRSERVERSERVICE_EXCEPTION; + } + return YSRSERVERSERVICE_WSDL_LOCATION; + } + +} diff --git a/src/ysr/com/teamcenter/package-info.class b/src/ysr/com/teamcenter/package-info.class new file mode 100644 index 0000000..fae14c7 Binary files /dev/null and b/src/ysr/com/teamcenter/package-info.class differ diff --git a/src/ysr/com/teamcenter/package-info.java b/src/ysr/com/teamcenter/package-info.java new file mode 100644 index 0000000..9885e71 --- /dev/null +++ b/src/ysr/com/teamcenter/package-info.java @@ -0,0 +1,2 @@ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://teamcenter.com.ysr/") +package ysr.com.teamcenter;