commit 5d53268c374cded7e63fd57a9497b152486f3408 Author: lijh Date: Wed Apr 9 16:35:33 2025 +0800 20250409 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..b519331 --- /dev/null +++ b/.classpath @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..00a098a --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.ld + + + + + + 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.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..e99de3d --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +encoding//src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeCellRenderer.java=UTF-8 +encoding//src/com/net/connor/ld/plm/ld06/ChangePartDialog.java=GBK +encoding//src/com/net/connor/ld/plm/ld06/DerivedChangeRequestCommand.java=GBK +encoding//src/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog.java=GBK diff --git a/.settings/org.eclipse.core.runtime.prefs b/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000..deae05a --- /dev/null +++ b/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /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.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..df5c368 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,118 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ld +Bundle-SymbolicName: com.connor.ld;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime;bundle-version="3.15.100", + com.teamcenter.rac.pca.kernel;bundle-version="13000.0.0", + com.teamcenter.rac.util;bundle-version="13000.1.0", + com.teamcenter.rac.aifrcp;bundle-version="13000.1.0", + TcSoaCoreRac;bundle-version="13000.1.0", + TcSoaClient;bundle-version="13000.1.0", + com.teamcenter.rac.common;bundle-version="13000.1.0", + com.teamcenter.rac.ui;bundle-version="13000.1.0", + org.eclipse.osgi.services;bundle-version="3.7.100", + org.eclipse.osgi.util;bundle-version="3.5.100", + com.teamcenter.rac.tcapps;bundle-version="13000.1.0", + com.teamcenter.rac.kernel;bundle-version="13000.1.0", + com.teamcenter.rac.workflow.processdesigner;bundle-version="13000.1.0", + k.util;bundle-version="1.0.0" +Automatic-Module-Name: com.connor.ld +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: com.net.connor.ld.plm.form, + com.teamcenter.soa.exceptions +Bundle-ClassPath: axis2_lib/activation-1.1.jar, + axis2_lib/antlr-2.7.7.jar, + axis2_lib/apache-mime4j-core-0.7.2.jar, + axis2_lib/axiom-api-1.2.13.jar, + axis2_lib/axiom-dom-1.2.13.jar, + axis2_lib/axiom-impl-1.2.13.jar, + axis2_lib/axis2-adb-1.6.2.jar, + axis2_lib/axis2-adb-codegen-1.6.2.jar, + axis2_lib/axis2-ant-plugin-1.6.2.jar, + axis2_lib/axis2-clustering-1.6.2.jar, + axis2_lib/axis2-codegen-1.6.2.jar, + axis2_lib/axis2-corba-1.6.2.jar, + axis2_lib/axis2-fastinfoset-1.6.2.jar, + axis2_lib/axis2-java2wsdl-1.6.2.jar, + axis2_lib/axis2-jaxbri-1.6.2.jar, + axis2_lib/axis2-jaxws-1.6.2.jar, + axis2_lib/axis2-jibx-1.6.2.jar, + axis2_lib/axis2-json-1.6.2.jar, + axis2_lib/axis2-kernel-1.6.2.jar, + axis2_lib/axis2-metadata-1.6.2.jar, + axis2_lib/axis2-mtompolicy-1.6.2.jar, + axis2_lib/axis2-saaj-1.6.2.jar, + axis2_lib/axis2-soapmonitor-servlet-1.6.2.jar, + axis2_lib/axis2-spring-1.6.2.jar, + axis2_lib/axis2-transport-http-1.6.2.jar, + axis2_lib/axis2-transport-local-1.6.2.jar, + axis2_lib/axis2-xmlbeans-1.6.2.jar, + axis2_lib/bcel-5.1.jar, + axis2_lib/commons-cli-1.2.jar, + axis2_lib/commons-codec-1.3.jar, + axis2_lib/commons-fileupload-1.2.jar, + axis2_lib/commons-httpclient-3.1.jar, + axis2_lib/commons-io-1.4.jar, + axis2_lib/commons-logging-1.1.1.jar, + axis2_lib/geronimo-annotation_1.0_spec-1.1.jar, + axis2_lib/geronimo-jaxws_2.2_spec-1.0.jar, + axis2_lib/geronimo-jta_1.1_spec-1.1.jar, + axis2_lib/geronimo-saaj_1.3_spec-1.0.1.jar, + axis2_lib/geronimo-stax-api_1.0_spec-1.0.1.jar, + axis2_lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar, + axis2_lib/httpcore-4.0.jar, + axis2_lib/jalopy-1.5rc3.jar, + axis2_lib/jaxb-api-2.1.jar, + axis2_lib/jaxb-impl-2.1.7.jar, + axis2_lib/jaxb-xjc-2.1.7.jar, + axis2_lib/jaxen-1.1.1.jar, + axis2_lib/jaxws-tools-2.1.3.jar, + axis2_lib/jettison-1.0-RC2.jar, + axis2_lib/jibx-bind-1.2.jar, + axis2_lib/jibx-run-1.2.jar, + axis2_lib/jsr311-api-1.0.jar, + axis2_lib/juli-6.0.16.jar, + axis2_lib/log4j-1.2.15.jar, + axis2_lib/mail-1.4.jar, + axis2_lib/mex-1.6.2-impl.jar, + axis2_lib/neethi-3.0.2.jar, + axis2_lib/regexp-1.2.jar, + axis2_lib/tribes-6.0.16.jar, + axis2_lib/woden-api-1.0M9.jar, + axis2_lib/woden-impl-commons-1.0M9.jar, + axis2_lib/woden-impl-dom-1.0M9.jar, + axis2_lib/wsdl4j-1.6.2.jar, + axis2_lib/wstx-asl-3.2.9.jar, + axis2_lib/xalan-2.7.0.jar, + axis2_lib/xml-resolver-1.2.jar, + axis2_lib/xmlbeans-2.3.0.jar, + axis2_lib/XmlSchema-1.4.7.jar, + json_lib/commons-beanutils-1.7.0.jar, + json_lib/commons-collections-3.2.jar, + json_lib/commons-lang-2.4.jar, + json_lib/commons-logging-1.1.jar, + json_lib/ezmorph-1.0.4.jar, + json_lib/jdom.jar, + json_lib/json-lib-2.2.2-jdk15.jar, + json_lib/json-lib-2.2.3-jdk13.jar, + poi_lib/aspose-words-17.4.0-jdk16.jar, + poi_lib/poi-3.17.jar, + poi_lib/poi-examples-3.17.jar, + poi_lib/poi-excelant-3.17.jar, + poi_lib/poi-ooxml-3.17.jar, + poi_lib/poi-ooxml-schemas-3.17.jar, + poi_lib/poi-scratchpad-3.17.jar, + poi_lib/xmlbeans-2.6.0.jar, + poi_lib/commons-collections4-4.1.jar, + special_lib/swingx-1.6.1.jar, + ., + special_lib/sqljdbc4.jar +Export-Package: com.net.connor.ld.plm.form, + com.net.connor.ld.plm.ld01, + com.net.connor.ld.plm.ld02, + com.net.connor.ld.plm.ld03, + com.net.connor.ld.plm.ld04, + com.net.connor.ld.plm.ld05 diff --git a/axis2_lib/XmlSchema-1.4.7.jar b/axis2_lib/XmlSchema-1.4.7.jar new file mode 100644 index 0000000..79251c6 Binary files /dev/null and b/axis2_lib/XmlSchema-1.4.7.jar differ diff --git a/axis2_lib/activation-1.1.jar b/axis2_lib/activation-1.1.jar new file mode 100644 index 0000000..53f82a1 Binary files /dev/null and b/axis2_lib/activation-1.1.jar differ diff --git a/axis2_lib/antlr-2.7.7.jar b/axis2_lib/antlr-2.7.7.jar new file mode 100644 index 0000000..5e5f14b Binary files /dev/null and b/axis2_lib/antlr-2.7.7.jar differ diff --git a/axis2_lib/apache-mime4j-core-0.7.2.jar b/axis2_lib/apache-mime4j-core-0.7.2.jar new file mode 100644 index 0000000..b5c225b Binary files /dev/null and b/axis2_lib/apache-mime4j-core-0.7.2.jar differ diff --git a/axis2_lib/axiom-api-1.2.13.jar b/axis2_lib/axiom-api-1.2.13.jar new file mode 100644 index 0000000..84cb42c Binary files /dev/null and b/axis2_lib/axiom-api-1.2.13.jar differ diff --git a/axis2_lib/axiom-dom-1.2.13.jar b/axis2_lib/axiom-dom-1.2.13.jar new file mode 100644 index 0000000..4890bb2 Binary files /dev/null and b/axis2_lib/axiom-dom-1.2.13.jar differ diff --git a/axis2_lib/axiom-impl-1.2.13.jar b/axis2_lib/axiom-impl-1.2.13.jar new file mode 100644 index 0000000..a959b28 Binary files /dev/null and b/axis2_lib/axiom-impl-1.2.13.jar differ diff --git a/axis2_lib/axis2-adb-1.6.2.jar b/axis2_lib/axis2-adb-1.6.2.jar new file mode 100644 index 0000000..6234fdb Binary files /dev/null and b/axis2_lib/axis2-adb-1.6.2.jar differ diff --git a/axis2_lib/axis2-adb-codegen-1.6.2.jar b/axis2_lib/axis2-adb-codegen-1.6.2.jar new file mode 100644 index 0000000..7d037d4 Binary files /dev/null and b/axis2_lib/axis2-adb-codegen-1.6.2.jar differ diff --git a/axis2_lib/axis2-ant-plugin-1.6.2.jar b/axis2_lib/axis2-ant-plugin-1.6.2.jar new file mode 100644 index 0000000..771b222 Binary files /dev/null and b/axis2_lib/axis2-ant-plugin-1.6.2.jar differ diff --git a/axis2_lib/axis2-clustering-1.6.2.jar b/axis2_lib/axis2-clustering-1.6.2.jar new file mode 100644 index 0000000..e45be99 Binary files /dev/null and b/axis2_lib/axis2-clustering-1.6.2.jar differ diff --git a/axis2_lib/axis2-codegen-1.6.2.jar b/axis2_lib/axis2-codegen-1.6.2.jar new file mode 100644 index 0000000..f742f19 Binary files /dev/null and b/axis2_lib/axis2-codegen-1.6.2.jar differ diff --git a/axis2_lib/axis2-corba-1.6.2.jar b/axis2_lib/axis2-corba-1.6.2.jar new file mode 100644 index 0000000..ee3c78e Binary files /dev/null and b/axis2_lib/axis2-corba-1.6.2.jar differ diff --git a/axis2_lib/axis2-fastinfoset-1.6.2.jar b/axis2_lib/axis2-fastinfoset-1.6.2.jar new file mode 100644 index 0000000..d10c36a Binary files /dev/null and b/axis2_lib/axis2-fastinfoset-1.6.2.jar differ diff --git a/axis2_lib/axis2-java2wsdl-1.6.2.jar b/axis2_lib/axis2-java2wsdl-1.6.2.jar new file mode 100644 index 0000000..0bb869d Binary files /dev/null and b/axis2_lib/axis2-java2wsdl-1.6.2.jar differ diff --git a/axis2_lib/axis2-jaxbri-1.6.2.jar b/axis2_lib/axis2-jaxbri-1.6.2.jar new file mode 100644 index 0000000..616eec9 Binary files /dev/null and b/axis2_lib/axis2-jaxbri-1.6.2.jar differ diff --git a/axis2_lib/axis2-jaxws-1.6.2.jar b/axis2_lib/axis2-jaxws-1.6.2.jar new file mode 100644 index 0000000..064351a Binary files /dev/null and b/axis2_lib/axis2-jaxws-1.6.2.jar differ diff --git a/axis2_lib/axis2-jibx-1.6.2.jar b/axis2_lib/axis2-jibx-1.6.2.jar new file mode 100644 index 0000000..75f9d1a Binary files /dev/null and b/axis2_lib/axis2-jibx-1.6.2.jar differ diff --git a/axis2_lib/axis2-json-1.6.2.jar b/axis2_lib/axis2-json-1.6.2.jar new file mode 100644 index 0000000..edd7936 Binary files /dev/null and b/axis2_lib/axis2-json-1.6.2.jar differ diff --git a/axis2_lib/axis2-kernel-1.6.2.jar b/axis2_lib/axis2-kernel-1.6.2.jar new file mode 100644 index 0000000..3ae5f7a Binary files /dev/null and b/axis2_lib/axis2-kernel-1.6.2.jar differ diff --git a/axis2_lib/axis2-metadata-1.6.2.jar b/axis2_lib/axis2-metadata-1.6.2.jar new file mode 100644 index 0000000..492f1ac Binary files /dev/null and b/axis2_lib/axis2-metadata-1.6.2.jar differ diff --git a/axis2_lib/axis2-mtompolicy-1.6.2.jar b/axis2_lib/axis2-mtompolicy-1.6.2.jar new file mode 100644 index 0000000..561e84a Binary files /dev/null and b/axis2_lib/axis2-mtompolicy-1.6.2.jar differ diff --git a/axis2_lib/axis2-saaj-1.6.2.jar b/axis2_lib/axis2-saaj-1.6.2.jar new file mode 100644 index 0000000..c14531d Binary files /dev/null and b/axis2_lib/axis2-saaj-1.6.2.jar differ diff --git a/axis2_lib/axis2-soapmonitor-servlet-1.6.2.jar b/axis2_lib/axis2-soapmonitor-servlet-1.6.2.jar new file mode 100644 index 0000000..276dac7 Binary files /dev/null and b/axis2_lib/axis2-soapmonitor-servlet-1.6.2.jar differ diff --git a/axis2_lib/axis2-spring-1.6.2.jar b/axis2_lib/axis2-spring-1.6.2.jar new file mode 100644 index 0000000..30b9baa Binary files /dev/null and b/axis2_lib/axis2-spring-1.6.2.jar differ diff --git a/axis2_lib/axis2-transport-http-1.6.2.jar b/axis2_lib/axis2-transport-http-1.6.2.jar new file mode 100644 index 0000000..b1dad78 Binary files /dev/null and b/axis2_lib/axis2-transport-http-1.6.2.jar differ diff --git a/axis2_lib/axis2-transport-local-1.6.2.jar b/axis2_lib/axis2-transport-local-1.6.2.jar new file mode 100644 index 0000000..34a7073 Binary files /dev/null and b/axis2_lib/axis2-transport-local-1.6.2.jar differ diff --git a/axis2_lib/axis2-xmlbeans-1.6.2.jar b/axis2_lib/axis2-xmlbeans-1.6.2.jar new file mode 100644 index 0000000..58fba9b Binary files /dev/null and b/axis2_lib/axis2-xmlbeans-1.6.2.jar differ diff --git a/axis2_lib/bcel-5.1.jar b/axis2_lib/bcel-5.1.jar new file mode 100644 index 0000000..524e375 Binary files /dev/null and b/axis2_lib/bcel-5.1.jar differ diff --git a/axis2_lib/commons-cli-1.2.jar b/axis2_lib/commons-cli-1.2.jar new file mode 100644 index 0000000..ce4b9ff Binary files /dev/null and b/axis2_lib/commons-cli-1.2.jar differ diff --git a/axis2_lib/commons-codec-1.3.jar b/axis2_lib/commons-codec-1.3.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/axis2_lib/commons-codec-1.3.jar differ diff --git a/axis2_lib/commons-fileupload-1.2.jar b/axis2_lib/commons-fileupload-1.2.jar new file mode 100644 index 0000000..12539f5 Binary files /dev/null and b/axis2_lib/commons-fileupload-1.2.jar differ diff --git a/axis2_lib/commons-httpclient-3.1.jar b/axis2_lib/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/axis2_lib/commons-httpclient-3.1.jar differ diff --git a/axis2_lib/commons-io-1.4.jar b/axis2_lib/commons-io-1.4.jar new file mode 100644 index 0000000..133dc6c Binary files /dev/null and b/axis2_lib/commons-io-1.4.jar differ diff --git a/axis2_lib/commons-logging-1.1.1.jar b/axis2_lib/commons-logging-1.1.1.jar new file mode 100644 index 0000000..1deef14 Binary files /dev/null and b/axis2_lib/commons-logging-1.1.1.jar differ diff --git a/axis2_lib/geronimo-annotation_1.0_spec-1.1.jar b/axis2_lib/geronimo-annotation_1.0_spec-1.1.jar new file mode 100644 index 0000000..7a6f529 Binary files /dev/null and b/axis2_lib/geronimo-annotation_1.0_spec-1.1.jar differ diff --git a/axis2_lib/geronimo-jaxws_2.2_spec-1.0.jar b/axis2_lib/geronimo-jaxws_2.2_spec-1.0.jar new file mode 100644 index 0000000..888f839 Binary files /dev/null and b/axis2_lib/geronimo-jaxws_2.2_spec-1.0.jar differ diff --git a/axis2_lib/geronimo-jta_1.1_spec-1.1.jar b/axis2_lib/geronimo-jta_1.1_spec-1.1.jar new file mode 100644 index 0000000..bba9290 Binary files /dev/null and b/axis2_lib/geronimo-jta_1.1_spec-1.1.jar differ diff --git a/axis2_lib/geronimo-saaj_1.3_spec-1.0.1.jar b/axis2_lib/geronimo-saaj_1.3_spec-1.0.1.jar new file mode 100644 index 0000000..b2f6e81 Binary files /dev/null and b/axis2_lib/geronimo-saaj_1.3_spec-1.0.1.jar differ diff --git a/axis2_lib/geronimo-stax-api_1.0_spec-1.0.1.jar b/axis2_lib/geronimo-stax-api_1.0_spec-1.0.1.jar new file mode 100644 index 0000000..ab1ee3b Binary files /dev/null and b/axis2_lib/geronimo-stax-api_1.0_spec-1.0.1.jar differ diff --git a/axis2_lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar b/axis2_lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar new file mode 100644 index 0000000..c8a795a Binary files /dev/null and b/axis2_lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar differ diff --git a/axis2_lib/httpcore-4.0.jar b/axis2_lib/httpcore-4.0.jar new file mode 100644 index 0000000..37eb7d4 Binary files /dev/null and b/axis2_lib/httpcore-4.0.jar differ diff --git a/axis2_lib/jalopy-1.5rc3.jar b/axis2_lib/jalopy-1.5rc3.jar new file mode 100644 index 0000000..fe51ce2 Binary files /dev/null and b/axis2_lib/jalopy-1.5rc3.jar differ diff --git a/axis2_lib/jaxb-api-2.1.jar b/axis2_lib/jaxb-api-2.1.jar new file mode 100644 index 0000000..be3d6dc Binary files /dev/null and b/axis2_lib/jaxb-api-2.1.jar differ diff --git a/axis2_lib/jaxb-impl-2.1.7.jar b/axis2_lib/jaxb-impl-2.1.7.jar new file mode 100644 index 0000000..034c158 Binary files /dev/null and b/axis2_lib/jaxb-impl-2.1.7.jar differ diff --git a/axis2_lib/jaxb-xjc-2.1.7.jar b/axis2_lib/jaxb-xjc-2.1.7.jar new file mode 100644 index 0000000..ba2ec46 Binary files /dev/null and b/axis2_lib/jaxb-xjc-2.1.7.jar differ diff --git a/axis2_lib/jaxen-1.1.1.jar b/axis2_lib/jaxen-1.1.1.jar new file mode 100644 index 0000000..b633631 Binary files /dev/null and b/axis2_lib/jaxen-1.1.1.jar differ diff --git a/axis2_lib/jaxws-tools-2.1.3.jar b/axis2_lib/jaxws-tools-2.1.3.jar new file mode 100644 index 0000000..1006bfd Binary files /dev/null and b/axis2_lib/jaxws-tools-2.1.3.jar differ diff --git a/axis2_lib/jettison-1.0-RC2.jar b/axis2_lib/jettison-1.0-RC2.jar new file mode 100644 index 0000000..3a00ed2 Binary files /dev/null and b/axis2_lib/jettison-1.0-RC2.jar differ diff --git a/axis2_lib/jibx-bind-1.2.jar b/axis2_lib/jibx-bind-1.2.jar new file mode 100644 index 0000000..c8d3887 Binary files /dev/null and b/axis2_lib/jibx-bind-1.2.jar differ diff --git a/axis2_lib/jibx-run-1.2.jar b/axis2_lib/jibx-run-1.2.jar new file mode 100644 index 0000000..6b467d3 Binary files /dev/null and b/axis2_lib/jibx-run-1.2.jar differ diff --git a/axis2_lib/jsr311-api-1.0.jar b/axis2_lib/jsr311-api-1.0.jar new file mode 100644 index 0000000..2bede66 Binary files /dev/null and b/axis2_lib/jsr311-api-1.0.jar differ diff --git a/axis2_lib/juli-6.0.16.jar b/axis2_lib/juli-6.0.16.jar new file mode 100644 index 0000000..c3fe977 Binary files /dev/null and b/axis2_lib/juli-6.0.16.jar differ diff --git a/axis2_lib/log4j-1.2.15.jar b/axis2_lib/log4j-1.2.15.jar new file mode 100644 index 0000000..c930a6a Binary files /dev/null and b/axis2_lib/log4j-1.2.15.jar differ diff --git a/axis2_lib/mail-1.4.jar b/axis2_lib/mail-1.4.jar new file mode 100644 index 0000000..fd4555b Binary files /dev/null and b/axis2_lib/mail-1.4.jar differ diff --git a/axis2_lib/mex-1.6.2-impl.jar b/axis2_lib/mex-1.6.2-impl.jar new file mode 100644 index 0000000..ed67cf3 Binary files /dev/null and b/axis2_lib/mex-1.6.2-impl.jar differ diff --git a/axis2_lib/neethi-3.0.2.jar b/axis2_lib/neethi-3.0.2.jar new file mode 100644 index 0000000..383efde Binary files /dev/null and b/axis2_lib/neethi-3.0.2.jar differ diff --git a/axis2_lib/regexp-1.2.jar b/axis2_lib/regexp-1.2.jar new file mode 100644 index 0000000..713441c Binary files /dev/null and b/axis2_lib/regexp-1.2.jar differ diff --git a/axis2_lib/tribes-6.0.16.jar b/axis2_lib/tribes-6.0.16.jar new file mode 100644 index 0000000..bb85de1 Binary files /dev/null and b/axis2_lib/tribes-6.0.16.jar differ diff --git a/axis2_lib/woden-api-1.0M9.jar b/axis2_lib/woden-api-1.0M9.jar new file mode 100644 index 0000000..3b07e8e Binary files /dev/null and b/axis2_lib/woden-api-1.0M9.jar differ diff --git a/axis2_lib/woden-impl-commons-1.0M9.jar b/axis2_lib/woden-impl-commons-1.0M9.jar new file mode 100644 index 0000000..f99c8d7 Binary files /dev/null and b/axis2_lib/woden-impl-commons-1.0M9.jar differ diff --git a/axis2_lib/woden-impl-dom-1.0M9.jar b/axis2_lib/woden-impl-dom-1.0M9.jar new file mode 100644 index 0000000..0e3fff5 Binary files /dev/null and b/axis2_lib/woden-impl-dom-1.0M9.jar differ diff --git a/axis2_lib/wsdl4j-1.6.2.jar b/axis2_lib/wsdl4j-1.6.2.jar new file mode 100644 index 0000000..b9ffc36 Binary files /dev/null and b/axis2_lib/wsdl4j-1.6.2.jar differ diff --git a/axis2_lib/wstx-asl-3.2.9.jar b/axis2_lib/wstx-asl-3.2.9.jar new file mode 100644 index 0000000..ffdbd1f Binary files /dev/null and b/axis2_lib/wstx-asl-3.2.9.jar differ diff --git a/axis2_lib/xalan-2.7.0.jar b/axis2_lib/xalan-2.7.0.jar new file mode 100644 index 0000000..007be39 Binary files /dev/null and b/axis2_lib/xalan-2.7.0.jar differ diff --git a/axis2_lib/xml-resolver-1.2.jar b/axis2_lib/xml-resolver-1.2.jar new file mode 100644 index 0000000..e535bdc Binary files /dev/null and b/axis2_lib/xml-resolver-1.2.jar differ diff --git a/axis2_lib/xmlbeans-2.3.0.jar b/axis2_lib/xmlbeans-2.3.0.jar new file mode 100644 index 0000000..ccd8163 Binary files /dev/null and b/axis2_lib/xmlbeans-2.3.0.jar differ diff --git a/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeCellRenderer.class b/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeCellRenderer.class new file mode 100644 index 0000000..a4faef3 Binary files /dev/null and b/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeCellRenderer.class differ diff --git a/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeLabel.class b/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeLabel.class new file mode 100644 index 0000000..d4a8dda Binary files /dev/null and b/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeLabel.class differ diff --git a/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNode.class b/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNode.class new file mode 100644 index 0000000..960b2de Binary files /dev/null and b/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNode.class differ diff --git a/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNodeSelectionListener.class b/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNodeSelectionListener.class new file mode 100644 index 0000000..ad49df7 Binary files /dev/null and b/bin/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNodeSelectionListener.class differ diff --git a/bin/cn/net/connor/ld/JCheckBoxTree/DemoMain.class b/bin/cn/net/connor/ld/JCheckBoxTree/DemoMain.class new file mode 100644 index 0000000..ccdd9cd Binary files /dev/null and b/bin/cn/net/connor/ld/JCheckBoxTree/DemoMain.class differ diff --git a/bin/cn/net/connor/ld/plm/Activator.class b/bin/cn/net/connor/ld/plm/Activator.class new file mode 100644 index 0000000..e414fe6 Binary files /dev/null and b/bin/cn/net/connor/ld/plm/Activator.class differ diff --git a/bin/cn/net/connor/ld/plm/DateUtil$FormatEnum.class b/bin/cn/net/connor/ld/plm/DateUtil$FormatEnum.class new file mode 100644 index 0000000..1b51945 Binary files /dev/null and b/bin/cn/net/connor/ld/plm/DateUtil$FormatEnum.class differ diff --git a/bin/cn/net/connor/ld/plm/DateUtil.class b/bin/cn/net/connor/ld/plm/DateUtil.class new file mode 100644 index 0000000..dd7531f Binary files /dev/null and b/bin/cn/net/connor/ld/plm/DateUtil.class differ diff --git a/bin/cn/net/connor/ld/plm/KAction.class b/bin/cn/net/connor/ld/plm/KAction.class new file mode 100644 index 0000000..0467e60 Binary files /dev/null and b/bin/cn/net/connor/ld/plm/KAction.class differ diff --git a/bin/cn/net/connor/ld/plm/KCommand.class b/bin/cn/net/connor/ld/plm/KCommand.class new file mode 100644 index 0000000..34e8d33 Binary files /dev/null and b/bin/cn/net/connor/ld/plm/KCommand.class differ diff --git a/bin/cn/net/connor/ld/plm/KHandler.class b/bin/cn/net/connor/ld/plm/KHandler.class new file mode 100644 index 0000000..3b48ddf Binary files /dev/null and b/bin/cn/net/connor/ld/plm/KHandler.class differ diff --git a/bin/cn/net/connor/ld/plm/KLocale.class b/bin/cn/net/connor/ld/plm/KLocale.class new file mode 100644 index 0000000..299d192 Binary files /dev/null and b/bin/cn/net/connor/ld/plm/KLocale.class differ diff --git a/bin/cn/net/connor/ld/plm/KOperation.class b/bin/cn/net/connor/ld/plm/KOperation.class new file mode 100644 index 0000000..7e5c8bc Binary files /dev/null and b/bin/cn/net/connor/ld/plm/KOperation.class differ diff --git a/bin/cn/net/connor/ld/plm/KOperation2.class b/bin/cn/net/connor/ld/plm/KOperation2.class new file mode 100644 index 0000000..df12346 Binary files /dev/null and b/bin/cn/net/connor/ld/plm/KOperation2.class differ diff --git a/bin/cn/net/connor/ld/plm/KUtil.class b/bin/cn/net/connor/ld/plm/KUtil.class new file mode 100644 index 0000000..c729c8a Binary files /dev/null and b/bin/cn/net/connor/ld/plm/KUtil.class differ diff --git a/bin/cn/net/connor/ld/plm/ProgressBar$1.class b/bin/cn/net/connor/ld/plm/ProgressBar$1.class new file mode 100644 index 0000000..c690e02 Binary files /dev/null and b/bin/cn/net/connor/ld/plm/ProgressBar$1.class differ diff --git a/bin/cn/net/connor/ld/plm/ProgressBar$2.class b/bin/cn/net/connor/ld/plm/ProgressBar$2.class new file mode 100644 index 0000000..3dbead6 Binary files /dev/null and b/bin/cn/net/connor/ld/plm/ProgressBar$2.class differ diff --git a/bin/cn/net/connor/ld/plm/ProgressBar.class b/bin/cn/net/connor/ld/plm/ProgressBar.class new file mode 100644 index 0000000..7904dcd Binary files /dev/null and b/bin/cn/net/connor/ld/plm/ProgressBar.class differ diff --git a/bin/cn/net/connor/ld/plm/k_locale.properties b/bin/cn/net/connor/ld/plm/k_locale.properties new file mode 100644 index 0000000..ac8931f --- /dev/null +++ b/bin/cn/net/connor/ld/plm/k_locale.properties @@ -0,0 +1,58 @@ +# +#Thu Jan 21 10:28:16 CST 2021 +createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25 +project=Project +dsuidinpref.ERROR1=Error dataset uid set in preference\: %s +valuenotinlov.ERROR2=LOV "%s" does not contain value\: %s +writedata=Write Data +querynotexist.ERROR1=Query not exist\: %s +dialoginit.ERROR=Init Error +preferror.ERROR1=Preference error\: %s +norefindataset.ERROR1=Download file from dataset "%s" failed. No ref file. +cancel=Cancel +exeop.STATUS=Execute... +initop.STATUS=Checking Data... +noflowkey.ERROR=Missing key for flow number. +wordfield_pagecount.NAME=\u9875\u6570 +nopropintype.ERROR2=Property is not defined in type "%s"\: %s. +getflowno.ERROR1=Error getting new flow number for key\: %s +formsave.ERRORTITLE=Error Saving Data +wordfield_pageno.NAME=\u9875\u7801 +wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00 +wordfield_totalpagecount.NAME=\u603B\u9875\u6570 +exceltitlenorelateinfo.ERROR=Title row in sheet does not have any relation info. +selectProject=Select Project +proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E +excelnotitle.ERROR=Can't find title row in excel sheet. +loadCompFromUid.Error2=Error loading component "%s", UID \= "%s". +uploadfilewhencheckout.ERROR1=Dataset "%s" is checked out. Upload file failed. +wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00 +nodatainfile.ERROR1=No Data in File\: %s +noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA +notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C +error=Error +mergefile=Merge File... +index=Index +forminit.ERRORTITLE=Error Loading Rendering +ok=OK +wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570 +requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s +functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD +multiuserbyid.ERROR1=Find multiple users by id\: %s +preparedata=Prepare Data +dbconn.ERROR=Connect to database failed. +typenotfound.ERROR1=Type not found\: %s +filenotexist.ERROR1=File not exist\: %s +wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00 +readdata=Read Data +clearcache=Clear Cache +exportsuccess.INFO=Export Complete. +uploadfile=Upload File +propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s +foldernotexist.ERROR1=Folder not exist\: %s +info=Info +wordfield_totalpageno.NAME=\u603B\u9875\u7801 +multiuserbyname.ERROR1=Find multiple users by name\: %s +exportopenfile.INFO=Export complete. Open file? +prefnotconfiged.ERROR1=Prefernce not found\: %s +export=Export diff --git a/bin/cn/net/connor/ld/plm/k_locale_zh_CN.properties b/bin/cn/net/connor/ld/plm/k_locale_zh_CN.properties new file mode 100644 index 0000000..902d489 --- /dev/null +++ b/bin/cn/net/connor/ld/plm/k_locale_zh_CN.properties @@ -0,0 +1,58 @@ +# +#Thu Jan 21 10:28:16 CST 2021 +createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25 +project=\u9879\u76EE +dsuidinpref.ERROR1=\u8BF7\u68C0\u67E5\u9996\u9009\u9879<%s>\uFF0C\u901A\u8FC7\u914D\u7F6EUID\u672A\u627E\u5230\u6570\u636E\u96C6 +valuenotinlov.ERROR2=LOV "%s" \u4E2D\u672A\u5B9A\u4E49\u6570\u503C\uFF1A%s +writedata=\u5199\u5165\u6570\u636E +querynotexist.ERROR1=\u67E5\u8BE2\u4E0D\u5B58\u5728\uFF1A%s +dialoginit.ERROR=\u521D\u59CB\u5316\u5F02\u5E38 +preferror.ERROR1=\u9996\u9009\u9879\u914D\u7F6E\u9519\u8BEF\uFF1A%s +norefindataset.ERROR1=\u4ECE\u6570\u636E\u96C6\u201C%s\u201D\u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25\uFF0C\u6CA1\u6709\u627E\u5230\u5F15\u7528\u6587\u4EF6\u3002 +cancel=\u53D6\u6D88 +exeop.STATUS=\u6B63\u5728\u6267\u884C... +initop.STATUS=\u68C0\u67E5\u6570\u636E... +noflowkey.ERROR=\u6D41\u6C34\u7801\u952E\u503C\u4E0D\u53EF\u4E3A\u7A7A +wordfield_pagecount.NAME=\u9875\u6570 +nopropintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u4E0D\u5B58\u5728\u5C5E\u6027\uFF1A%s +getflowno.ERROR1=\u83B7\u53D6\u6D41\u6C34\u7801\u5931\u8D25\uFF1A%s +formsave.ERRORTITLE=\u4FDD\u5B58\u6570\u636E\u51FA\u9519 +wordfield_pageno.NAME=\u9875\u7801 +wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00 +wordfield_totalpagecount.NAME=\u603B\u9875\u6570 +exceltitlenorelateinfo.ERROR=\u6807\u9898\u884C\u6CA1\u6709\u89E3\u6790\u5230\u6620\u5C04\u5185\u5BB9 +selectProject=\u9009\u62E9\u9879\u76EE +proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E +excelnotitle.ERROR=\u672A\u627E\u5230\u5DE5\u4F5C\u8868\u4E2D\u7684\u6807\u9898\u884C +loadCompFromUid.Error2=\u52A0\u8F7D\u5BF9\u8C61\u201C%s\u201D\u5931\u8D25\uFF0CUID\=\u201C%s\u201D\u3002 +uploadfilewhencheckout.ERROR1=\u6570\u636E\u96C6\u201C%s\u201D\u5DF2\u7B7E\u51FA\uFF0C\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25\u3002\u8BF7\u7B7E\u5165\u540E\u518D\u8FDB\u884C\u64CD\u4F5C\u3002 +wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00 +nodatainfile.ERROR1=\u6587\u4EF6\u4E2D\u6CA1\u6709\u6570\u636E\uFF1A%s +noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA +notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C +error=\u9519\u8BEF +mergefile=\u5408\u5E76\u6587\u4EF6 +index=\u5E8F\u53F7 +forminit.ERRORTITLE=\u521D\u59CB\u5316\u754C\u9762\u5F02\u5E38 +ok=\u786E\u5B9A +wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570 +requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s +functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD +multiuserbyid.ERROR1=\u901A\u8FC7id\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s +preparedata=\u51C6\u5907\u6570\u636E +dbconn.ERROR=\u8FDE\u63A5\u6570\u636E\u5E93\u5931\u8D25\u3002 +typenotfound.ERROR1=\u672A\u627E\u5230\u7C7B\u578B\uFF1A%s +filenotexist.ERROR1=\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A%s +wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00 +readdata=\u8BFB\u53D6\u6570\u636E +clearcache=\u6E05\u7406\u7F13\u5B58 +exportsuccess.INFO=\u5BFC\u51FA\u5B8C\u6210 +uploadfile=\u4E0A\u4F20\u6587\u4EF6 +propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s +foldernotexist.ERROR1=\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\uFF1A%s +info=\u63D0\u793A +wordfield_totalpageno.NAME=\u603B\u9875\u7801 +multiuserbyname.ERROR1=\u901A\u8FC7\u59D3\u540D\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s +exportopenfile.INFO=\u5BFC\u51FA\u5B8C\u6210\uFF0C\u6253\u5F00\u6587\u4EF6\uFF1F +prefnotconfiged.ERROR1=\u672A\u914D\u7F6E\u9996\u9009\u9879\uFF1A%s +export=\u5BFC\u51FA diff --git a/bin/cn/net/connor/ld/plm/test.class b/bin/cn/net/connor/ld/plm/test.class new file mode 100644 index 0000000..ee9da4f Binary files /dev/null and b/bin/cn/net/connor/ld/plm/test.class differ diff --git a/bin/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer$1.class b/bin/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer$1.class new file mode 100644 index 0000000..dc30ca0 Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer$1.class differ diff --git a/bin/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer.class b/bin/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer.class new file mode 100644 index 0000000..f715941 Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer.class differ diff --git a/bin/com/net/connor/ld/plm/bean/FormBean.class b/bin/com/net/connor/ld/plm/bean/FormBean.class new file mode 100644 index 0000000..50fee31 Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/FormBean.class differ diff --git a/bin/com/net/connor/ld/plm/bean/ManageStoredData$1.class b/bin/com/net/connor/ld/plm/bean/ManageStoredData$1.class new file mode 100644 index 0000000..42a8cb5 Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/ManageStoredData$1.class differ diff --git a/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonEditor$1.class b/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonEditor$1.class new file mode 100644 index 0000000..2a23d1b Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonEditor$1.class differ diff --git a/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonEditor.class b/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonEditor.class new file mode 100644 index 0000000..5fb99ef Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonEditor.class differ diff --git a/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonRenderer.class b/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonRenderer.class new file mode 100644 index 0000000..735fe7e Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/ManageStoredData$ButtonRenderer.class differ diff --git a/bin/com/net/connor/ld/plm/bean/ManageStoredData.class b/bin/com/net/connor/ld/plm/bean/ManageStoredData.class new file mode 100644 index 0000000..534dbd4 Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/ManageStoredData.class differ diff --git a/bin/com/net/connor/ld/plm/bean/MyButtonEditor$1.class b/bin/com/net/connor/ld/plm/bean/MyButtonEditor$1.class new file mode 100644 index 0000000..ac24e24 Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/MyButtonEditor$1.class differ diff --git a/bin/com/net/connor/ld/plm/bean/MyButtonEditor.class b/bin/com/net/connor/ld/plm/bean/MyButtonEditor.class new file mode 100644 index 0000000..ae091cb Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/MyButtonEditor.class differ diff --git a/bin/com/net/connor/ld/plm/bean/MyButtonEditor222.class b/bin/com/net/connor/ld/plm/bean/MyButtonEditor222.class new file mode 100644 index 0000000..f1c44dc Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/MyButtonEditor222.class differ diff --git a/bin/com/net/connor/ld/plm/bean/MyButtonRender.class b/bin/com/net/connor/ld/plm/bean/MyButtonRender.class new file mode 100644 index 0000000..f1e5915 Binary files /dev/null and b/bin/com/net/connor/ld/plm/bean/MyButtonRender.class differ diff --git a/bin/com/net/connor/ld/plm/form/CLForm.class b/bin/com/net/connor/ld/plm/form/CLForm.class new file mode 100644 index 0000000..8b3a7ad Binary files /dev/null and b/bin/com/net/connor/ld/plm/form/CLForm.class differ diff --git a/bin/com/net/connor/ld/plm/form/CNForm$1.class b/bin/com/net/connor/ld/plm/form/CNForm$1.class new file mode 100644 index 0000000..b6b5bee Binary files /dev/null and b/bin/com/net/connor/ld/plm/form/CNForm$1.class differ diff --git a/bin/com/net/connor/ld/plm/form/CNForm$2.class b/bin/com/net/connor/ld/plm/form/CNForm$2.class new file mode 100644 index 0000000..4190bf1 Binary files /dev/null and b/bin/com/net/connor/ld/plm/form/CNForm$2.class differ diff --git a/bin/com/net/connor/ld/plm/form/CNForm.class b/bin/com/net/connor/ld/plm/form/CNForm.class new file mode 100644 index 0000000..a8cb442 Binary files /dev/null and b/bin/com/net/connor/ld/plm/form/CNForm.class differ diff --git a/bin/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm$1.class b/bin/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm$1.class new file mode 100644 index 0000000..1e0f836 Binary files /dev/null and b/bin/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm$1.class differ diff --git a/bin/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm.class b/bin/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm.class new file mode 100644 index 0000000..b2bb2e7 Binary files /dev/null and b/bin/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm.class differ diff --git a/bin/com/net/connor/ld/plm/form/TestForm.class b/bin/com/net/connor/ld/plm/form/TestForm.class new file mode 100644 index 0000000..1e89969 Binary files /dev/null and b/bin/com/net/connor/ld/plm/form/TestForm.class differ diff --git a/bin/com/net/connor/ld/plm/ld01/OpenFloderCommand.class b/bin/com/net/connor/ld/plm/ld01/OpenFloderCommand.class new file mode 100644 index 0000000..764acf0 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld01/OpenFloderCommand.class differ diff --git a/bin/com/net/connor/ld/plm/ld01/Test.class b/bin/com/net/connor/ld/plm/ld01/Test.class new file mode 100644 index 0000000..5835802 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld01/Test.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/CreateProjectStructCommand.class b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructCommand.class new file mode 100644 index 0000000..8383df4 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructCommand.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$1.class b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$1.class new file mode 100644 index 0000000..55b7a77 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$2.class b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$2.class new file mode 100644 index 0000000..bcb1f5d Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$2.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$3.class b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$3.class new file mode 100644 index 0000000..3037413 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog$3.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog.class b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog.class new file mode 100644 index 0000000..86a123a Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/CreateProjectStructDialog.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/DbPool.class b/bin/com/net/connor/ld/plm/ld02/DbPool.class new file mode 100644 index 0000000..b51737c Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/DbPool.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$1.class b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$1.class new file mode 100644 index 0000000..2582d3d Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckNode.class b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckNode.class new file mode 100644 index 0000000..38aff34 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckNode.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckRenderer$TreeLabel.class b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckRenderer$TreeLabel.class new file mode 100644 index 0000000..fd823bc Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckRenderer$TreeLabel.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckRenderer.class b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckRenderer.class new file mode 100644 index 0000000..f41dc0a Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree$CheckRenderer.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree.class b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree.class new file mode 100644 index 0000000..7ac355f Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/JCheckBoxTree.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/JTreeTest$1.class b/bin/com/net/connor/ld/plm/ld02/JTreeTest$1.class new file mode 100644 index 0000000..7c69513 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/JTreeTest$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/JTreeTest.class b/bin/com/net/connor/ld/plm/ld02/JTreeTest.class new file mode 100644 index 0000000..4b1394e Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld02/JTreeTest.class differ diff --git a/bin/com/net/connor/ld/plm/ld02/表单表结构sql.txt b/bin/com/net/connor/ld/plm/ld02/表单表结构sql.txt new file mode 100644 index 0000000..20c757a --- /dev/null +++ b/bin/com/net/connor/ld/plm/ld02/表单表结构sql.txt @@ -0,0 +1,30 @@ +CREATE TABLE PFORM_VALUES ( + ClientProductFolderName VARCHAR(100), + ClientProductFolderPUID VARCHAR(100) , + NewProductTaskItem VARCHAR(100), + Assignee VARCHAR(100), + NewProductTaskDescription NVARCHAR(MAX), + Processor VARCHAR(100), + PositionGroup VARCHAR(100), + TaskNature VARCHAR(100), + DifficultyLevel VARCHAR(100), + UrgencyLevelCode VARCHAR(100), + EstimatedBusinessHours VARCHAR(20), + ActualBusinessHours VARCHAR(20), + DueDate DATETIME, + CompletionDate DATETIME, + Remarks NVARCHAR(MAX), + TaskAssignmentDate DATETIME +); + + + + private JTextField cpwjjmcField = new JTextField(15); + private JTextField fprzhField = new JTextField(15); + private JTextField clrField = new JTextField(15); + private JTextField gwzField = new JTextField(15); + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private DateButton TaskassignmentStartButton; + private DateButton TaskassignmentEndButton; + private DateButton CompletionDateStartButton; + private DateButton CompletionDateEndButton; \ No newline at end of file diff --git a/bin/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelCommand.class b/bin/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelCommand.class new file mode 100644 index 0000000..b35056c Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelCommand.class differ diff --git a/bin/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelOperation.class b/bin/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelOperation.class new file mode 100644 index 0000000..f240db6 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelOperation.class differ diff --git a/bin/com/net/connor/ld/plm/ld03/Test.class b/bin/com/net/connor/ld/plm/ld03/Test.class new file mode 100644 index 0000000..ada76e9 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld03/Test.class differ diff --git a/bin/com/net/connor/ld/plm/ld03/WordUtils.class b/bin/com/net/connor/ld/plm/ld03/WordUtils.class new file mode 100644 index 0000000..4c8a637 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld03/WordUtils.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/AutoCompleter.class b/bin/com/net/connor/ld/plm/ld04/AutoCompleter.class new file mode 100644 index 0000000..edb6cfd Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/AutoCompleter.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/ClassPropBean.class b/bin/com/net/connor/ld/plm/ld04/ClassPropBean.class new file mode 100644 index 0000000..8d6d29a Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/ClassPropBean.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/ClassProperty.class b/bin/com/net/connor/ld/plm/ld04/ClassProperty.class new file mode 100644 index 0000000..b0717ad Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/ClassProperty.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/ClassificationProEditHandler.class b/bin/com/net/connor/ld/plm/ld04/ClassificationProEditHandler.class new file mode 100644 index 0000000..3b8eca5 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/ClassificationProEditHandler.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$1$1.class b/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$1$1.class new file mode 100644 index 0000000..2266666 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$1$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$1.class b/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$1.class new file mode 100644 index 0000000..75ce949 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$2.class b/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$2.class new file mode 100644 index 0000000..c5296f0 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog$2.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog.class b/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog.class new file mode 100644 index 0000000..276e9f2 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/EditClassificationDialog.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/JAutoCompleteComboBox.class b/bin/com/net/connor/ld/plm/ld04/JAutoCompleteComboBox.class new file mode 100644 index 0000000..ba981d0 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/JAutoCompleteComboBox.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/JDMethodUtil.class b/bin/com/net/connor/ld/plm/ld04/JDMethodUtil.class new file mode 100644 index 0000000..e39c854 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/JDMethodUtil.class differ diff --git a/bin/com/net/connor/ld/plm/ld04/StringCreateUtil.class b/bin/com/net/connor/ld/plm/ld04/StringCreateUtil.class new file mode 100644 index 0000000..bed8bf5 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld04/StringCreateUtil.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$1.class b/bin/com/net/connor/ld/plm/ld05/CIForm$1.class new file mode 100644 index 0000000..088532f Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$2$1.class b/bin/com/net/connor/ld/plm/ld05/CIForm$2$1.class new file mode 100644 index 0000000..fa8c7ab Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$2$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$2.class b/bin/com/net/connor/ld/plm/ld05/CIForm$2.class new file mode 100644 index 0000000..73e6020 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$2.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$3.class b/bin/com/net/connor/ld/plm/ld05/CIForm$3.class new file mode 100644 index 0000000..a6fd1e4 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$3.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$4.class b/bin/com/net/connor/ld/plm/ld05/CIForm$4.class new file mode 100644 index 0000000..5d7f852 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$4.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$5.class b/bin/com/net/connor/ld/plm/ld05/CIForm$5.class new file mode 100644 index 0000000..c548c6a Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$5.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$6.class b/bin/com/net/connor/ld/plm/ld05/CIForm$6.class new file mode 100644 index 0000000..e8fef90 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$6.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$7.class b/bin/com/net/connor/ld/plm/ld05/CIForm$7.class new file mode 100644 index 0000000..460680e Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$7.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$8.class b/bin/com/net/connor/ld/plm/ld05/CIForm$8.class new file mode 100644 index 0000000..a757b4d Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$8.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$9$1.class b/bin/com/net/connor/ld/plm/ld05/CIForm$9$1.class new file mode 100644 index 0000000..d89bdd8 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$9$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm$9.class b/bin/com/net/connor/ld/plm/ld05/CIForm$9.class new file mode 100644 index 0000000..c0a7024 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm$9.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CIForm.class b/bin/com/net/connor/ld/plm/ld05/CIForm.class new file mode 100644 index 0000000..967823a Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CIForm.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$1.class b/bin/com/net/connor/ld/plm/ld05/CNForm$1.class new file mode 100644 index 0000000..59ba228 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$2$1.class b/bin/com/net/connor/ld/plm/ld05/CNForm$2$1.class new file mode 100644 index 0000000..f411ee7 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$2$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$2.class b/bin/com/net/connor/ld/plm/ld05/CNForm$2.class new file mode 100644 index 0000000..12d1340 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$2.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$3.class b/bin/com/net/connor/ld/plm/ld05/CNForm$3.class new file mode 100644 index 0000000..06776fe Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$3.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$4.class b/bin/com/net/connor/ld/plm/ld05/CNForm$4.class new file mode 100644 index 0000000..0b389fe Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$4.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$5.class b/bin/com/net/connor/ld/plm/ld05/CNForm$5.class new file mode 100644 index 0000000..b2a4a9f Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$5.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$6.class b/bin/com/net/connor/ld/plm/ld05/CNForm$6.class new file mode 100644 index 0000000..bb3f2c8 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$6.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$7.class b/bin/com/net/connor/ld/plm/ld05/CNForm$7.class new file mode 100644 index 0000000..8377c67 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$7.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$8.class b/bin/com/net/connor/ld/plm/ld05/CNForm$8.class new file mode 100644 index 0000000..f172312 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$8.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$9$1.class b/bin/com/net/connor/ld/plm/ld05/CNForm$9$1.class new file mode 100644 index 0000000..dfc00cc Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$9$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm$9.class b/bin/com/net/connor/ld/plm/ld05/CNForm$9.class new file mode 100644 index 0000000..7261856 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm$9.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CNForm.class b/bin/com/net/connor/ld/plm/ld05/CNForm.class new file mode 100644 index 0000000..1ba928a Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CNForm.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CreateCLFormCommand.class b/bin/com/net/connor/ld/plm/ld05/CreateCLFormCommand.class new file mode 100644 index 0000000..d2f95b2 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CreateCLFormCommand.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/CreateCNFormCommand.class b/bin/com/net/connor/ld/plm/ld05/CreateCNFormCommand.class new file mode 100644 index 0000000..a81743d Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/CreateCNFormCommand.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/FormModel.class b/bin/com/net/connor/ld/plm/ld05/FormModel.class new file mode 100644 index 0000000..7de25b0 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/FormModel.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/MyJframe.class b/bin/com/net/connor/ld/plm/ld05/MyJframe.class new file mode 100644 index 0000000..302f062 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/MyJframe.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/OrderNumberComparator.class b/bin/com/net/connor/ld/plm/ld05/OrderNumberComparator.class new file mode 100644 index 0000000..c70c89b Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/OrderNumberComparator.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/TableViewRenderer.class b/bin/com/net/connor/ld/plm/ld05/TableViewRenderer.class new file mode 100644 index 0000000..e1e5abd Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/TableViewRenderer.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/Test.class b/bin/com/net/connor/ld/plm/ld05/Test.class new file mode 100644 index 0000000..96ca95d Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/Test.class differ diff --git a/bin/com/net/connor/ld/plm/ld05/普通模板.xlsx b/bin/com/net/connor/ld/plm/ld05/普通模板.xlsx new file mode 100644 index 0000000..0298837 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld05/普通模板.xlsx differ diff --git a/bin/com/net/connor/ld/plm/ld06/ArrowIcon.class b/bin/com/net/connor/ld/plm/ld06/ArrowIcon.class new file mode 100644 index 0000000..f381a7c Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/ArrowIcon.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$1.class b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$1.class new file mode 100644 index 0000000..7af72c0 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$2.class b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$2.class new file mode 100644 index 0000000..1871ffa Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$2.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$3.class b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$3.class new file mode 100644 index 0000000..4d639e6 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$3.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$4.class b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$4.class new file mode 100644 index 0000000..48f0ba4 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog$4.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/ChangePartDialog.class b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog.class new file mode 100644 index 0000000..0c17640 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/ChangePartDialog.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/ColumnSorter.class b/bin/com/net/connor/ld/plm/ld06/ColumnSorter.class new file mode 100644 index 0000000..bc8ae9f Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/ColumnSorter.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/ControlBean.class b/bin/com/net/connor/ld/plm/ld06/ControlBean.class new file mode 100644 index 0000000..7d9d88c Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/ControlBean.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/DateTest.class b/bin/com/net/connor/ld/plm/ld06/DateTest.class new file mode 100644 index 0000000..57e744b Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/DateTest.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/DerivedChangeNoticeCommand.class b/bin/com/net/connor/ld/plm/ld06/DerivedChangeNoticeCommand.class new file mode 100644 index 0000000..6766ee6 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/DerivedChangeNoticeCommand.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestCommand.class b/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestCommand.class new file mode 100644 index 0000000..d0cd3e1 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestCommand.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog$1.class b/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog$1.class new file mode 100644 index 0000000..c5674b5 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog.class b/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog.class new file mode 100644 index 0000000..d0fe539 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/Main$1.class b/bin/com/net/connor/ld/plm/ld06/Main$1.class new file mode 100644 index 0000000..83c8fba Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/Main$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/Main$2.class b/bin/com/net/connor/ld/plm/ld06/Main$2.class new file mode 100644 index 0000000..5eee347 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/Main$2.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/Main.class b/bin/com/net/connor/ld/plm/ld06/Main.class new file mode 100644 index 0000000..836e109 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/Main.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/TableDemo$1.class b/bin/com/net/connor/ld/plm/ld06/TableDemo$1.class new file mode 100644 index 0000000..fec45f9 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/TableDemo$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/TableDemo.class b/bin/com/net/connor/ld/plm/ld06/TableDemo.class new file mode 100644 index 0000000..5e7af26 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld06/TableDemo.class differ diff --git a/bin/com/net/connor/ld/plm/ld06/old.txt b/bin/com/net/connor/ld/plm/ld06/old.txt new file mode 100644 index 0000000..23d018a --- /dev/null +++ b/bin/com/net/connor/ld/plm/ld06/old.txt @@ -0,0 +1,86 @@ +package com.net.connor.ld.plm.ld06; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Polygon; +import java.util.Comparator; + +import javax.swing.Icon; +import javax.swing.RowSorter; +import javax.swing.RowSorter.SortKey; +import javax.swing.SortOrder; +import javax.swing.table.TableRowSorter; + +import antlr.collections.List; + +public class ArrowIcon implements Icon { + private final SortOrder sortOrder; + private final int size; + private final boolean ascending; + public ArrowIcon(TableRowSorter sorter, int column, boolean ascending) { + this.ascending = ascending; + this.size = 12; + java.util.List sortKeys = sorter.getSortKeys(); + if (sortKeys.size() > 0 && ((RowSorter.SortKey) sortKeys.get(0)).getColumn() == column) { + this.sortOrder = ((RowSorter.SortKey) sortKeys.get(0)).getSortOrder(); + } else { + this.sortOrder = SortOrder.ASCENDING; + } + } + public void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2 = (Graphics2D) g.create(); + g2.translate(x, y); + if (ascending) { + g2.rotate(Math.PI, size / 2.0, size / 2.0); + } + if (sortOrder == SortOrder.ASCENDING) { + g2.draw(createUpTriangle(size)); + } else { + g2.draw(createDownTriangle(size)); + } + g2.dispose(); + } + public int getIconWidth() { + return size; + } + public int getIconHeight() { + return size; + } + private Polygon createUpTriangle(int size) { + Polygon triangle = new Polygon(); + triangle.addPoint(0, size); + triangle.addPoint(size / 2, 0); + triangle.addPoint(size, size); + return triangle; + } + private Polygon createDownTriangle(int size) { + Polygon triangle = new Polygon(); + triangle.addPoint(0, 0); + triangle.addPoint(size, 0); + triangle.addPoint(size / 2, size); + return triangle; + } +} +//表格列排序类 +class ColumnSorter implements Comparator { + private final int col; + private final boolean ascending; + public ColumnSorter(int col, boolean ascending) { + this.col = col; + this.ascending = ascending; + } + @Override + public int compare(Object a, Object b) { + if (a instanceof Comparable && b instanceof Comparable) { + if (ascending) { + return ((Comparable) a).compareTo((Comparable) b); + } else { + return ((Comparable) b).compareTo((Comparable) a); + } + } else { + return 0; + } + } +} + diff --git a/bin/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsHandler.class b/bin/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsHandler.class new file mode 100644 index 0000000..c01d88b Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsHandler.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsOpertion.class b/bin/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsOpertion.class new file mode 100644 index 0000000..91f0db7 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsOpertion.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/CheckBoxNode.class b/bin/com/net/connor/ld/plm/ld07/CheckBoxNode.class new file mode 100644 index 0000000..bc29395 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/CheckBoxNode.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/CheckBoxTreeCellEditor.class b/bin/com/net/connor/ld/plm/ld07/CheckBoxTreeCellEditor.class new file mode 100644 index 0000000..3a3018f Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/CheckBoxTreeCellEditor.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/CheckBoxTreeCellRenderer.class b/bin/com/net/connor/ld/plm/ld07/CheckBoxTreeCellRenderer.class new file mode 100644 index 0000000..d555469 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/CheckBoxTreeCellRenderer.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/JCheckBoxTree.class b/bin/com/net/connor/ld/plm/ld07/JCheckBoxTree.class new file mode 100644 index 0000000..49bbe4c Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/JCheckBoxTree.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/NewJFrame$1.class b/bin/com/net/connor/ld/plm/ld07/NewJFrame$1.class new file mode 100644 index 0000000..6fda012 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/NewJFrame$1.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/NewJFrame$2.class b/bin/com/net/connor/ld/plm/ld07/NewJFrame$2.class new file mode 100644 index 0000000..85f8cb4 Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/NewJFrame$2.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/NewJFrame$3.class b/bin/com/net/connor/ld/plm/ld07/NewJFrame$3.class new file mode 100644 index 0000000..e56111d Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/NewJFrame$3.class differ diff --git a/bin/com/net/connor/ld/plm/ld07/NewJFrame.class b/bin/com/net/connor/ld/plm/ld07/NewJFrame.class new file mode 100644 index 0000000..61a4d9a Binary files /dev/null and b/bin/com/net/connor/ld/plm/ld07/NewJFrame.class differ diff --git a/bin/com/teamcenter/rac/commands/cut/CutCommand.class b/bin/com/teamcenter/rac/commands/cut/CutCommand.class new file mode 100644 index 0000000..615d8d1 Binary files /dev/null and b/bin/com/teamcenter/rac/commands/cut/CutCommand.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..b31b8d6 --- /dev/null +++ b/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1,2 @@ +LD6_CNForm.FORMJAVARENDERING=com.net.connor.ld.plm.ld05.CNForm +LD6_CIForm.FORMJAVARENDERING=com.net.connor.ld.plm.ld05.CIForm \ No newline at end of file diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..6d99887 --- /dev/null +++ b/build.properties @@ -0,0 +1,98 @@ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + icons/,\ + poi_lib/poi-3.17.jar,\ + poi_lib/poi-examples-3.17.jar,\ + poi_lib/poi-excelant-3.17.jar,\ + poi_lib/poi-ooxml-3.17.jar,\ + poi_lib/poi-ooxml-schemas-3.17.jar,\ + poi_lib/poi-scratchpad-3.17.jar,\ + poi_lib/xmlbeans-2.6.0.jar,\ + poi_lib/aspose-words-17.4.0-jdk16.jar,\ + poi_lib/json-lib-2.2.2-jdk15.jar,\ + poi_lib/commons-beanutils-1.7.0.jar,\ + poi_lib/commons-collections-3.2.jar,\ + poi_lib/commons-lang-2.4.jar,\ + poi_lib/commons-logging-1.1.1.jar,\ + poi_lib/ezmorph-1.0.4.jar,\ + axis2_lib/activation-1.1.jar,\ + axis2_lib/antlr-2.7.7.jar,\ + axis2_lib/apache-mime4j-core-0.7.2.jar,\ + axis2_lib/axiom-api-1.2.13.jar,\ + axis2_lib/axiom-dom-1.2.13.jar,\ + axis2_lib/axiom-impl-1.2.13.jar,\ + axis2_lib/axis2-adb-1.6.2.jar,\ + axis2_lib/axis2-adb-codegen-1.6.2.jar,\ + axis2_lib/axis2-ant-plugin-1.6.2.jar,\ + axis2_lib/axis2-clustering-1.6.2.jar,\ + axis2_lib/axis2-codegen-1.6.2.jar,\ + axis2_lib/axis2-corba-1.6.2.jar,\ + axis2_lib/axis2-fastinfoset-1.6.2.jar,\ + axis2_lib/axis2-java2wsdl-1.6.2.jar,\ + axis2_lib/axis2-jaxbri-1.6.2.jar,\ + axis2_lib/axis2-jaxws-1.6.2.jar,\ + axis2_lib/axis2-jibx-1.6.2.jar,\ + axis2_lib/axis2-json-1.6.2.jar,\ + axis2_lib/axis2-kernel-1.6.2.jar,\ + axis2_lib/axis2-metadata-1.6.2.jar,\ + axis2_lib/axis2-mtompolicy-1.6.2.jar,\ + axis2_lib/axis2-saaj-1.6.2.jar,\ + axis2_lib/axis2-soapmonitor-servlet-1.6.2.jar,\ + axis2_lib/axis2-spring-1.6.2.jar,\ + axis2_lib/axis2-transport-http-1.6.2.jar,\ + axis2_lib/axis2-transport-local-1.6.2.jar,\ + axis2_lib/axis2-xmlbeans-1.6.2.jar,\ + axis2_lib/bcel-5.1.jar,\ + axis2_lib/commons-cli-1.2.jar,\ + axis2_lib/commons-codec-1.3.jar,\ + axis2_lib/commons-fileupload-1.2.jar,\ + axis2_lib/commons-httpclient-3.1.jar,\ + axis2_lib/commons-io-1.4.jar,\ + axis2_lib/commons-logging-1.1.1.jar,\ + axis2_lib/geronimo-annotation_1.0_spec-1.1.jar,\ + axis2_lib/geronimo-jaxws_2.2_spec-1.0.jar,\ + axis2_lib/geronimo-jta_1.1_spec-1.1.jar,\ + axis2_lib/geronimo-saaj_1.3_spec-1.0.1.jar,\ + axis2_lib/geronimo-stax-api_1.0_spec-1.0.1.jar,\ + axis2_lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar,\ + axis2_lib/httpcore-4.0.jar,\ + axis2_lib/jalopy-1.5rc3.jar,\ + axis2_lib/jaxb-api-2.1.jar,\ + axis2_lib/jaxb-impl-2.1.7.jar,\ + axis2_lib/jaxb-xjc-2.1.7.jar,\ + axis2_lib/jaxen-1.1.1.jar,\ + axis2_lib/jaxws-tools-2.1.3.jar,\ + axis2_lib/jettison-1.0-RC2.jar,\ + axis2_lib/jibx-bind-1.2.jar,\ + axis2_lib/jibx-run-1.2.jar,\ + axis2_lib/jsr311-api-1.0.jar,\ + axis2_lib/juli-6.0.16.jar,\ + axis2_lib/log4j-1.2.15.jar,\ + axis2_lib/mail-1.4.jar,\ + axis2_lib/mex-1.6.2-impl.jar,\ + axis2_lib/neethi-3.0.2.jar,\ + axis2_lib/regexp-1.2.jar,\ + axis2_lib/tribes-6.0.16.jar,\ + axis2_lib/woden-api-1.0M9.jar,\ + axis2_lib/woden-impl-commons-1.0M9.jar,\ + axis2_lib/woden-impl-dom-1.0M9.jar,\ + axis2_lib/wsdl4j-1.6.2.jar,\ + axis2_lib/wstx-asl-3.2.9.jar,\ + axis2_lib/xalan-2.7.0.jar,\ + axis2_lib/xml-resolver-1.2.jar,\ + axis2_lib/xmlbeans-2.3.0.jar,\ + axis2_lib/XmlSchema-1.4.7.jar,\ + json_lib/commons-beanutils-1.7.0.jar,\ + json_lib/commons-collections-3.2.jar,\ + json_lib/commons-lang-2.4.jar,\ + json_lib/commons-logging-1.1.jar,\ + json_lib/ezmorph-1.0.4.jar,\ + json_lib/jdom.jar,\ + json_lib/json-lib-2.2.2-jdk15.jar,\ + json_lib/json-lib-2.2.3-jdk13.jar,\ + .,\ + poi_lib/commons-collections4-4.1.jar,\ + special_lib/swingx-1.6.1.jar,\ + special_lib/sqljdbc4.jar +source.. = src/ diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/json_lib/commons-beanutils-1.7.0.jar b/json_lib/commons-beanutils-1.7.0.jar new file mode 100644 index 0000000..b1b89c9 Binary files /dev/null and b/json_lib/commons-beanutils-1.7.0.jar differ diff --git a/json_lib/commons-collections-3.2.jar b/json_lib/commons-collections-3.2.jar new file mode 100644 index 0000000..75580be Binary files /dev/null and b/json_lib/commons-collections-3.2.jar differ diff --git a/json_lib/commons-lang-2.4.jar b/json_lib/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/json_lib/commons-lang-2.4.jar differ diff --git a/json_lib/commons-logging-1.1.jar b/json_lib/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/json_lib/commons-logging-1.1.jar differ diff --git a/json_lib/ezmorph-1.0.4.jar b/json_lib/ezmorph-1.0.4.jar new file mode 100644 index 0000000..7625af6 Binary files /dev/null and b/json_lib/ezmorph-1.0.4.jar differ diff --git a/json_lib/jdom.jar b/json_lib/jdom.jar new file mode 100644 index 0000000..65a1b3f Binary files /dev/null and b/json_lib/jdom.jar differ diff --git a/json_lib/json-lib-2.2.2-jdk15.jar b/json_lib/json-lib-2.2.2-jdk15.jar new file mode 100644 index 0000000..27e7c7c Binary files /dev/null and b/json_lib/json-lib-2.2.2-jdk15.jar differ diff --git a/json_lib/json-lib-2.2.3-jdk13.jar b/json_lib/json-lib-2.2.3-jdk13.jar new file mode 100644 index 0000000..a6513db Binary files /dev/null and b/json_lib/json-lib-2.2.3-jdk13.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..fe15ff4 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/poi_lib/aspose-words-17.4.0-jdk16.jar b/poi_lib/aspose-words-17.4.0-jdk16.jar new file mode 100644 index 0000000..e8bd66c Binary files /dev/null and b/poi_lib/aspose-words-17.4.0-jdk16.jar differ diff --git a/poi_lib/commons-collections4-4.1.jar b/poi_lib/commons-collections4-4.1.jar new file mode 100644 index 0000000..43a9413 Binary files /dev/null and b/poi_lib/commons-collections4-4.1.jar differ diff --git a/poi_lib/poi-3.17.jar b/poi_lib/poi-3.17.jar new file mode 100644 index 0000000..353ce76 Binary files /dev/null and b/poi_lib/poi-3.17.jar differ diff --git a/poi_lib/poi-examples-3.17.jar b/poi_lib/poi-examples-3.17.jar new file mode 100644 index 0000000..a923b04 Binary files /dev/null and b/poi_lib/poi-examples-3.17.jar differ diff --git a/poi_lib/poi-excelant-3.17.jar b/poi_lib/poi-excelant-3.17.jar new file mode 100644 index 0000000..da9f5ed Binary files /dev/null and b/poi_lib/poi-excelant-3.17.jar differ diff --git a/poi_lib/poi-ooxml-3.17.jar b/poi_lib/poi-ooxml-3.17.jar new file mode 100644 index 0000000..68086e8 Binary files /dev/null and b/poi_lib/poi-ooxml-3.17.jar differ diff --git a/poi_lib/poi-ooxml-schemas-3.17.jar b/poi_lib/poi-ooxml-schemas-3.17.jar new file mode 100644 index 0000000..2e9b3e7 Binary files /dev/null and b/poi_lib/poi-ooxml-schemas-3.17.jar differ diff --git a/poi_lib/poi-scratchpad-3.17.jar b/poi_lib/poi-scratchpad-3.17.jar new file mode 100644 index 0000000..12ba1f1 Binary files /dev/null and b/poi_lib/poi-scratchpad-3.17.jar differ diff --git a/poi_lib/xmlbeans-2.6.0.jar b/poi_lib/xmlbeans-2.6.0.jar new file mode 100644 index 0000000..d1b6627 Binary files /dev/null and b/poi_lib/xmlbeans-2.6.0.jar differ diff --git a/special_lib/sqljdbc4.jar b/special_lib/sqljdbc4.jar new file mode 100644 index 0000000..d6b7f6d Binary files /dev/null and b/special_lib/sqljdbc4.jar differ diff --git a/special_lib/swingx-1.6.1.jar b/special_lib/swingx-1.6.1.jar new file mode 100644 index 0000000..b0bcc87 Binary files /dev/null and b/special_lib/swingx-1.6.1.jar differ diff --git a/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeCellRenderer.java b/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeCellRenderer.java new file mode 100644 index 0000000..a2bf245 --- /dev/null +++ b/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeCellRenderer.java @@ -0,0 +1,88 @@ +package cn.net.connor.ld.JCheckBoxTree; + +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.TreeCellRenderer; + +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")); + label.setIcon(UIManager.getIcon("Tree.openIcon")); + else if(expanded) + label.setIcon(UIManager.getIcon("Tree.openIcon")); + else + label.setIcon(UIManager.getIcon("Tree.closedIcon")); + + return this; + } + + @Override + public Dimension getPreferredSize() + { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + return new Dimension(dCheck.width + dLabel.width, dCheck.height < dLabel.height ? dLabel.height: dCheck.height); + } + + @Override + public void doLayout() + { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + int yCheck = 0; + int yLabel = 0; + if(dCheck.height < dLabel.height) + yCheck = (dLabel.height - dCheck.height) / 2; + else + yLabel = (dCheck.height - dLabel.height) / 2; + check.setLocation(0, yCheck); + check.setBounds(0, yCheck, dCheck.width, dCheck.height); + label.setLocation(dCheck.width, yLabel); + label.setBounds(dCheck.width, yLabel, dLabel.width, dLabel.height); + } + + @Override + public void setBackground(Color color) + { + if(color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeLabel.java b/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeLabel.java new file mode 100644 index 0000000..dc942e0 --- /dev/null +++ b/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeLabel.java @@ -0,0 +1,75 @@ +package cn.net.connor.ld.JCheckBoxTree; +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/net/connor/ld/JCheckBoxTree/CheckBoxTreeNode.java b/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNode.java new file mode 100644 index 0000000..07631c4 --- /dev/null +++ b/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNode.java @@ -0,0 +1,85 @@ +package cn.net.connor.ld.JCheckBoxTree; + +import javax.swing.tree.DefaultMutableTreeNode; + +public class CheckBoxTreeNode extends DefaultMutableTreeNode { + protected boolean isSelected; + + 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); + */ + } + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNodeSelectionListener.java b/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNodeSelectionListener.java new file mode 100644 index 0000000..5c09be4 --- /dev/null +++ b/src/cn/net/connor/ld/JCheckBoxTree/CheckBoxTreeNodeSelectionListener.java @@ -0,0 +1,31 @@ +package cn.net.connor.ld.JCheckBoxTree; + +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/net/connor/ld/JCheckBoxTree/DemoMain.java b/src/cn/net/connor/ld/JCheckBoxTree/DemoMain.java new file mode 100644 index 0000000..a20d90c --- /dev/null +++ b/src/cn/net/connor/ld/JCheckBoxTree/DemoMain.java @@ -0,0 +1,43 @@ +package cn.net.connor.ld.JCheckBoxTree; +import javax.swing.*; +import javax.swing.tree.DefaultTreeModel; + +public class DemoMain +{ + public static void main(String[] args) + { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + e.printStackTrace(); + } + JFrame frame = new JFrame("CheckBoxTreeDemo"); + frame.setBounds(200, 200, 400, 400); + JTree tree = new JTree(); + CheckBoxTreeNode rootNode = new CheckBoxTreeNode("root"); + CheckBoxTreeNode node1 = new CheckBoxTreeNode("node_1"); + CheckBoxTreeNode node1_1 = new CheckBoxTreeNode("node_1_1"); + CheckBoxTreeNode node1_2 = new CheckBoxTreeNode("node_1_2"); + CheckBoxTreeNode node1_3 = new CheckBoxTreeNode("node_1_3"); + node1.add(node1_1); + node1.add(node1_2); + node1.add(node1_3); + CheckBoxTreeNode node2 = new CheckBoxTreeNode("node_2"); + CheckBoxTreeNode node2_1 = new CheckBoxTreeNode("node_2_1"); + CheckBoxTreeNode node2_2 = new CheckBoxTreeNode("node_2_2"); + node2.add(node2_1); + node2.add(node2_2); + rootNode.add(node1); + rootNode.add(node2); + DefaultTreeModel model = new DefaultTreeModel(rootNode); + tree.addMouseListener(new CheckBoxTreeNodeSelectionListener()); + tree.setModel(model); + tree.setCellRenderer(new CheckBoxTreeCellRenderer()); + JScrollPane scroll = new JScrollPane(tree); + scroll.setBounds(0, 0, 300, 320); + frame.getContentPane().add(scroll); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ld/plm/Activator.java b/src/cn/net/connor/ld/plm/Activator.java new file mode 100644 index 0000000..0dcaaf7 --- /dev/null +++ b/src/cn/net/connor/ld/plm/Activator.java @@ -0,0 +1,44 @@ +package cn.net.connor.ld.plm; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "cn.net.connor.ml.plm"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + 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/cn/net/connor/ld/plm/DateUtil.java b/src/cn/net/connor/ld/plm/DateUtil.java new file mode 100644 index 0000000..6cfe8a1 --- /dev/null +++ b/src/cn/net/connor/ld/plm/DateUtil.java @@ -0,0 +1,603 @@ +package cn.net.connor.ld.plm; + +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.util.Date; + +public class DateUtil { + private static final String HYPHEN = "-"; + private static final String COLON = ":"; + + /* ʱʽ DateTimeFormatter (Java8) */ + enum FormatEnum { + /** + * DateTimeFormatter "yyyy-MM-dd HH:mm:ss" ʱʽ + */ + FORMAT_DATA_TIME(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)), + + /** + * DateTimeFormatter "yyyyMMddHHmmss"ʱʽ + */ + FORMAT_DATA_TIME_NO_SYMBOL(DateTimeFormatter.ofPattern(DATETIME_FORMAT)), + + /** + * DateTimeFormatter "yyyy-MM-dd"ʱʽ + */ + FORMAT_DATE(DateTimeFormatter.ofPattern(DATE_FORMAT)), + + /** + * DateTimeFormatter "HH:mm:ss"ʱʽ + */ + FORMAT_TIME(DateTimeFormatter.ofPattern(TIME_FORMAT)); + + private DateTimeFormatter value; + + FormatEnum(DateTimeFormatter format) { + this.value = format; + } + } + /* ʱʽ DateTimeFormatter (Java8) */ + + /* ʱʽ ַ */ + + /** + * ʱʽ + *
+ * "yyyy" ַ + */ + public static final String YEAR_FORMAT = "yyyy"; + + /** + * µʱʽ + *
+ * "MM" ַ + */ + public static final String MONTH_FORMAT = "MM"; + + /** + * յʱʽ + *
+ * "dd" ַ + */ + public static final String DAY_FORMAT = "dd"; + + /** + * ʱʱʽ + *
+ * "HH" ַ + */ + public static final String HOUR_FORMAT = "HH"; + + /** + * ֵʱʽ + *
+ * "mm" ַ + */ + public static final String MINUTE_FORMAT = "mm"; + + /** + * ʱʽ + *
+ * "ss" ַ + */ + public static final String SECOND_FORMAT = "ss"; + + /** + * --ʱʽ + *
+ * "yyyy-MM-dd" ַ + */ + public static final String DATE_FORMAT = YEAR_FORMAT + HYPHEN + MONTH_FORMAT + HYPHEN + DAY_FORMAT; + + /** + * ʱ::ʱʽ + *
+ * "HH:mm:ss" ַ + */ + public static final String TIME_FORMAT = HOUR_FORMAT + COLON + MINUTE_FORMAT + COLON + SECOND_FORMAT; + + /** + * -- ʱ::ʱʽ + *
+ * "yyyy-MM-dd HH:mm:ss" ַ + */ + public static final String DATE_TIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT; + + /** + * ʱʱʽ޷ţ + *
+ * "yyyyMMddHHmmss" ַ + */ + public static final String DATETIME_FORMAT = YEAR_FORMAT + MONTH_FORMAT + DAY_FORMAT + HOUR_FORMAT + MINUTE_FORMAT + SECOND_FORMAT; + + /* ʱʽ ַ */ + + + + /* ʱ */ + + /** + * ȡ뼶ʱ + */ + public static Long epochSecond() { + return localDateTime().toEpochSecond(ZoneOffset.of("+8")); + } + + /** + * ȡ뼶ʱ + */ + public static Long epochMilli() { + return localDateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); + } + + /* ʱ */ + + + /* ǰʱ */ + + /** + * ȡǰϸʱ䣬like 2018-08-27 17:20:06 + */ + public static String dateTime() { + return localDateTime().format(FormatEnum.FORMAT_DATA_TIME.value); + } + + /** + * ȡǰϸʱ䣬like 20180827172006 + */ + public static String dateTimeNoSymbol() { + return localDateTime().format(FormatEnum.FORMAT_DATA_TIME_NO_SYMBOL.value); + } + + /** + * ȡǰڣlike 2018-08-27 + */ + public static String date() { + return localDate() + ""; + } + + /** + * ȡǰʱ䣬like 17:20:06 + */ + public static String time() { + return localTime().format(FormatEnum.FORMAT_TIME.value); + } + + /** + * ȡǰ + */ + public static Integer year() { + return localDate().getYear(); + } + + /** + * ȡǰ + */ + public static int month() { + return localDate().getMonthValue(); + } + + /** + * ȡǰе + */ + public static Integer dayOfYear() { + return localDate().getDayOfYear(); + } + + /** + * ȡǰе + */ + public static Integer dayOfMonth() { + return localDate().getDayOfMonth(); + } + + /** + * ȡǰе + */ + public static Integer dayOfWeek() { + return localDate().getDayOfWeek().getValue(); + } + + /** + * ȡǰСʱ + */ + public static Integer hour() { + return localTime().getHour(); + } + + /** + * ȡǰ + */ + public static Integer minute() { + return localTime().getMinute(); + } + + /** + * ȡǰ + */ + public static Integer second() { + return localTime().getSecond(); + } + + /* ǰʱ */ + + + + /* δʷʱ */ + + /** + * ȡǰ ǰ + *

+ * + * @param years ǰ + * @param formatEnum ʽ + * @return ǰ ǰ Ӧ ʽ + */ + public static String minusYears(Long years, FormatEnum formatEnum) { + return minusOrPlusYears(-years, formatEnum); + } + + /** + * ȡǰ + *

+ * + * @param years + * @param formatEnum ʽ + * @return ǰ Ӧ ʽ + */ + public static String plusYears(Long years, FormatEnum formatEnum) { + return minusOrPlusYears(years, formatEnum); + } + + /** + * ȡǰµ ǰ + * + * @param months ǰ + * @param formatEnum ʽ + * @return ǰµ ǰ Ӧ ʽ + */ + public static String minusMonths(Long months, FormatEnum formatEnum) { + return minusOrPlusMonths(-months, formatEnum); + } + + /** + * ȡǰµ + * + * @param months + * @param formatEnum ʽ + * @return ǰµ Ӧ ʽ + */ + public static String plusMonths(Long months, FormatEnum formatEnum) { + return minusOrPlusMonths(months, formatEnum); + } + + /** + * ȡǰյ ǰ + * + * @param days ǰ + * @param formatEnum ʽ + * @return ǰյ ǰ Ӧ ʽ + */ + public static String minusDays(Long days, FormatEnum formatEnum) { + return minusOrPlusDays(-days, formatEnum); + } + + /** + * ȡǰյ + * + * @param days + * @param formatEnum ʽ + * @return ǰյ Ӧ ʽ + */ + public static String plusDays(Long days, FormatEnum formatEnum) { + return minusOrPlusDays(days, formatEnum); + } + + /** + * ȡǰڵ ǰ + * + * @param weeks ǰ + * @param formatEnum ʽ + * @return ǰڵ ǰ Ӧ ʽ + */ + public static String minusWeeks(Long weeks, FormatEnum formatEnum) { + return minusOrPlusWeeks(-weeks, formatEnum); + } + + /** + * ȡǰڵ + * + * @param weeks + * @param formatEnum ʽ + * @return ǰڵ Ӧ ʽ + */ + public static String plusWeeks(Long weeks, FormatEnum formatEnum) { + return minusOrPlusWeeks(weeks, formatEnum); + } + + /** + * ȡǰСʱ ǰСʱ + * + * @param hours ǰСʱ + * @param formatEnum ʽ + * @return ǰСʱ ǰСʱ Ӧ ʽ + */ + public static String minusHours(Long hours, FormatEnum formatEnum) { + return minusOrPlusHours(-hours, formatEnum); + } + + /** + * ȡǰСʱ Сʱ + * + * @param hours Сʱ + * @param formatEnum ʽ + * @return ǰСʱ Сʱ Ӧ ʽ + */ + public static String plusHours(Long hours, FormatEnum formatEnum) { + return minusOrPlusHours(hours, formatEnum); + } + + /** + * ȡǰӵ ǰ + * + * @param minutes ǰ + * @param formatEnum ʽ + * @return ǰӵ ǰ Ӧ ʽ + */ + public static String minusMinutes(Long minutes, FormatEnum formatEnum) { + return minusOrPlusMinutes(-minutes, formatEnum); + } + + /** + * ȡǰӵ 󼸷 + * + * @param minutes 󼸷 + * @param formatEnum ʽ + * @return ǰӵ 󼸷 Ӧ ʽ + */ + public static String plusMinutes(Long minutes, FormatEnum formatEnum) { + return minusOrPlusMinutes(minutes, formatEnum); + } + + /** + * ȡǰ ǰ + * + * @param seconds ǰ + * @param formatEnum ʽ + * @return ǰ ǰ Ӧ ʽ + */ + public static String minusSeconds(Long seconds, FormatEnum formatEnum) { + return minusOrPlusSeconds(-seconds, formatEnum); + } + + /** + * ȡǰ ǰ/ + * + * @param seconds + * @param formatEnum ʽ + * @return ǰ Ӧ ʽ + */ + public static String plusSeconds(Long seconds, FormatEnum formatEnum) { + return minusOrPlusSeconds(seconds, formatEnum); + } + + /* δʷʱ */ + + + /* ʱת */ + + /** + * DateתLocalDateTime + *

+ * + * @param date dateʱ + * @return LocalDateTime + */ + public static LocalDateTime toLocalDateTime(Date date) { + return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); + } + + /** + * DateתLocalDate + *

+ * + * @param date dateʱ + * @return LocalDate + */ + public static LocalDate toLocalDate(Date date) { + return toLocalDateTime(date).toLocalDate(); + } + + /** + * DateתLocalTime + *

+ * + * @param date dateʱ + * @return LocalTime + */ + public static LocalTime toLocalTime(Date date) { + return toLocalDateTime(date).toLocalTime(); + } + + /** + * LocalDateTime ת Date + * + * @param localDateTime localDateTime + * @return תDate + */ + public static Date toDate(LocalDateTime localDateTime) { + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + + /** + * LocalDateתDate + * + * @param localDate localDate + * @return תDate + */ + public static Date toDate(LocalDate localDate) { + return toDate(localDate.atStartOfDay()); + } + + /** + * LocalTimeתDate + * + * @param localTime localTime + * @return תDate + */ + public static Date toDate(LocalTime localTime) { + return toDate(LocalDateTime.of(localDate(), localTime)); + } + + /* ʱת */ + + + /* ʱ */ + + /** + * ȡ endDate-startDate ʱ + *
ˣ leigq + *
ʱ䣺 2018-11-07 09:55 + *
+ * + * @param startDate ʼʱ + * @param endDate ʱ + * @return ʱ + */ + public static Long daysInterval(LocalDate startDate, LocalDate endDate) { + return endDate.toEpochDay() - startDate.toEpochDay(); + } + + /** + * ȡ endDate-startDate ʱ + *
ˣ leigq + *
ʱ䣺 2018-11-07 09:55 + *
+ * + * @param startDate ʼʱ + * @param endDate ʱ + * @return ʱ + */ + public static Long daysInterval(String startDate, String endDate) { + return daysInterval(LocalDateTime.parse(endDate, FormatEnum.FORMAT_DATA_TIME.value).toLocalDate(), + LocalDateTime.parse(startDate, FormatEnum.FORMAT_DATA_TIME.value).toLocalDate()); + } + + /** + * ȡ endDate-startDate ʱ + *
ˣ leigq + *
ʱ䣺 2018-11-07 09:55 + *
+ * + * @param startDate ʼʱ + * @param endDate ʱ + * @return ʱ + */ + public static Long daysInterval(LocalDateTime startDate, LocalDateTime endDate) { + return daysInterval(startDate.toLocalDate(), endDate.toLocalDate()); + } + + /* ʱ */ + + /*ֻá*/ + + /** + * ȡ ǰ ǰ/ + *

+ * + * @param yearsToAddOrSubtract 괫ǰ괫 + * @param formatEnum ʽ + * @return ǰǰ/ĶӦ ʽ + */ + private static String minusOrPlusYears(Long yearsToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusYears(yearsToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡ ǰ ǰ/µ + * + * @param monthsToAddOrSubtract ´ǰ´ + * @param formatEnum ʽ + * @return ǰµǰ/µĶӦ ʽ + */ + private static String minusOrPlusMonths(Long monthsToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusMonths(monthsToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡ ǰ ǰ/յ + * + * @param daysToAddOrSubtract մǰմ + * @param formatEnum ʽ + * @return ǰյǰ/յ Ӧ ʽ + */ + private static String minusOrPlusDays(Long daysToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusDays(daysToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡǰڵǰ/ڵ + * + * @param weeksToAddOrSubtract ڴǰڴ + * @param formatEnum ʽ + * @return ǰڵǰ/ڵ Ӧ ʽ + */ + private static String minusOrPlusWeeks(Long weeksToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusWeeks(weeksToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡǰСʱǰСʱ/Сʱ + * + * @param hoursToAddOrSubtract СʱǰСʱ + * @param formatEnum ʽ + * @return ǰСʱǰСʱ/Сʱ Ӧ ʽ + */ + private static String minusOrPlusHours(Long hoursToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusHours(hoursToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡǰӵǰ/󼸷ӵ + * + * @param minutesToAddOrSubtract 󼸷ӴǰӴ + * @param formatEnum ʽ + * @return ǰӵǰ/󼸷ӵ Ӧ ʽ + */ + private static String minusOrPlusMinutes(Long minutesToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusMinutes(minutesToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡǰǰ/ + * + * @param secondsToAddOrSubtract 봫ǰ봫 + * @param formatEnum ʽ + * @return ǰǰ/ Ӧ ʽ + */ + private static String minusOrPlusSeconds(Long secondsToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusSeconds(secondsToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡ LocalDate + */ + private static LocalDate localDate() { + return localDateTime().toLocalDate(); + } + + /** + * ȡ LocalTime + */ + private static LocalTime localTime() { + return localDateTime().toLocalTime(); + } + + /** + * ȡ LocalDateTime + */ + private static LocalDateTime localDateTime() { + return LocalDateTime.now(); + } + +} diff --git a/src/cn/net/connor/ld/plm/KAction.java b/src/cn/net/connor/ld/plm/KAction.java new file mode 100644 index 0000000..fcb40b5 --- /dev/null +++ b/src/cn/net/connor/ld/plm/KAction.java @@ -0,0 +1,37 @@ +package cn.net.connor.ld.plm; + +import java.lang.reflect.Constructor; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.util.MessageBox; + + +public class KAction extends AbstractAIFAction { + + + KAction(AbstractAIFUIApplication app, String string) { + super(app,string); + } + + @Override + public void run() { + try { + int ind = actionName.indexOf('#'); + String action=actionName; + String actionData=""; + if(ind>0) { + action=actionName.substring(0,ind); + actionData=actionName.substring(ind+1); + } + Class c = Class.forName(action); + Constructor constructor = c.getConstructor(AbstractAIFApplication.class, String.class,String.class); + KCommand command = (KCommand) constructor.newInstance(this.application, action, actionData); + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e.toString(),KLocale.getString("error"),MessageBox.ERROR); + } + } +} diff --git a/src/cn/net/connor/ld/plm/KCommand.java b/src/cn/net/connor/ld/plm/KCommand.java new file mode 100644 index 0000000..623135d --- /dev/null +++ b/src/cn/net/connor/ld/plm/KCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.ld.plm; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; + +public abstract class KCommand extends AbstractAIFCommand { + + protected AbstractAIFApplication app; + protected String actionInfo; + + public KCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + this.app = app; + this.actionInfo = actionInfo; + } + +} diff --git a/src/cn/net/connor/ld/plm/KHandler.java b/src/cn/net/connor/ld/plm/KHandler.java new file mode 100644 index 0000000..823590b --- /dev/null +++ b/src/cn/net/connor/ld/plm/KHandler.java @@ -0,0 +1,24 @@ +package cn.net.connor.ld.plm; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * Add following config to MANIFEST.MF + * Eclipse-RegisterBuddy: k.util + * @author Administrator + * + */ +public class KHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new Thread(new KAction(app,arg0.getCommand().getId())).start(); + return null; + } + +} diff --git a/src/cn/net/connor/ld/plm/KLocale.java b/src/cn/net/connor/ld/plm/KLocale.java new file mode 100644 index 0000000..9502ed6 --- /dev/null +++ b/src/cn/net/connor/ld/plm/KLocale.java @@ -0,0 +1,22 @@ +package cn.net.connor.ld.plm; + +import com.teamcenter.rac.util.Registry; + + +public class KLocale { + + public static final Registry reg = Registry.getRegistry(KLocale.class); + + public static String getString(String title) { + if (isEmpty(title)) { + return ""; + } else { + String res = reg.getString(title); + return isEmpty(res) ? title : res; + } + } + + private static boolean isEmpty(String title) { + return title == null || "".equals(title.trim()); + } +} diff --git a/src/cn/net/connor/ld/plm/KOperation.java b/src/cn/net/connor/ld/plm/KOperation.java new file mode 100644 index 0000000..9207e23 --- /dev/null +++ b/src/cn/net/connor/ld/plm/KOperation.java @@ -0,0 +1,52 @@ +package cn.net.connor.ld.plm; + +import java.awt.Dimension; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCSession; + +/* + * do not call executeOperation yourself + * use session.performOperation + */ +public abstract class KOperation extends AbstractAIFOperation { + + protected AbstractAIFApplication app; + protected TCSession session; + public String messageLabel; + + public KOperation(AbstractAIFApplication app, String opName, String messageLabel) { + super(opName, true); + this.app = app; + this.session = (TCSession) app.getSession(); + this.messageLabel = messageLabel;// Ϣ + setSession(session); + } + + public abstract boolean init() throws Exception; + + public abstract void execute() throws Exception; + + @Override + public void executeOperation() { + ProgressBar pb = new ProgressBar(getCurrentDesktop(), new Dimension(250, 50), true); + try { + pb.showDialog(); + pb.setText(messageLabel); + setStatus("Checking Data..."); + if (!init()) { + pb.disposeDialog(); + return; + } + setStatus("Execute..."); + pb.setText(messageLabel); + execute(); + pb.disposeDialog(); + } catch (Exception e) { + pb.disposeDialog(); + KUtil.error(getCurrentDesktop(), "쳣\n" + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/cn/net/connor/ld/plm/KOperation2.java b/src/cn/net/connor/ld/plm/KOperation2.java new file mode 100644 index 0000000..60eea9a --- /dev/null +++ b/src/cn/net/connor/ld/plm/KOperation2.java @@ -0,0 +1,51 @@ +package cn.net.connor.ld.plm; + +import java.awt.Dimension; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCSession; + +/* + * do not call executeOperation yourself + * use session.performOperation + */ +public abstract class KOperation2 extends AbstractAIFOperation { + + protected AbstractAIFApplication app; + protected TCSession session; + protected ProgressBar pb; + + public KOperation2(AbstractAIFApplication app, String opName) { + super(opName, true); + this.app = app; + this.session = (TCSession) app.getSession(); + setSession(session); + } + + public abstract boolean init() throws Exception; + + public abstract void execute() throws Exception; + + @Override + public void executeOperation() { + pb = new ProgressBar(getCurrentDesktop(), new Dimension(250, 50), true); + try { + pb.showDialog(); + setStatus(KLocale.getString("initop.STATUS")); + if (!init()) { + pb.disposeDialog(); + return; + } + setStatus(KLocale.getString("exeop.STATUS")); + execute(); + KUtil.setByPass(false); + pb.disposeDialog(); + } catch (Exception e) { + pb.disposeDialog(); + KUtil.setByPass(false); + KUtil.error(getCurrentDesktop(), "쳣\n" + e); + e.printStackTrace(); + } + } +} diff --git a/src/cn/net/connor/ld/plm/KUtil.java b/src/cn/net/connor/ld/plm/KUtil.java new file mode 100644 index 0000000..b65cfbb --- /dev/null +++ b/src/cn/net/connor/ld/plm/KUtil.java @@ -0,0 +1,2348 @@ +package cn.net.connor.ld.plm; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.Window; +import java.io.BufferedWriter; +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + +import com.net.connor.ld.plm.ld06.ControlBean; +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.lov.view.components.LOVDisplayer; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentManager; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleDeliverable; +import com.teamcenter.rac.kernel.TCComponentTCCalendar; +import com.teamcenter.rac.kernel.TCComponentTaskDeliverable; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCComponentUser; +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.kernel.TCUserService; +import com.teamcenter.rac.schedule.calendar.TCCalendar; +import com.teamcenter.rac.schedule.componentutils.CalendarHelper; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2006_03.DataManagement.Relationship; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedInfo; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedOutput; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedResponse; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; +import com.teamcenter.soa.client.model.LovValue; +import com.teamcenter.soa.client.model.ServiceData; + +@SuppressWarnings("deprecation") +public class KUtil { + + public static final TCSession session; + public static final TCTextService textService; +// public static final Registry REG = Registry.getRegistry(KUtil.class); + public static final ZoneId zoneId = ZoneId.systemDefault(); +// public static final Registry reg = Registry.getRegistry(KUtil.class); + +// public static String getRegString(String title) { +// String res = reg.getString(title); +// if (KUtil.isEmpty(res)) { +// return title; +// } +// return res; +// } + + static { + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + textService = session.getTextService(); + } + + public static void setTCPropertyValue(TCComponent item, String propertyName, Object value) { + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + if (value instanceof Double) { + tcProperty.setDoubleValue((double) value); + } else { + tcProperty.setDoubleValue(Double.parseDouble(value.toString())); + } + break; + case TCProperty.PROP_int: + if (value instanceof Integer) { + tcProperty.setDoubleValue((int) value); + } else { + tcProperty.setDoubleValue(Integer.parseInt(value.toString())); + } + break; + case TCProperty.PROP_string: + tcProperty.setStringValue(value.toString()); + break; + case TCProperty.PROP_date: + if (value instanceof Date) { + tcProperty.setDateValue((Date) value); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + tcProperty.setDateValue(sdf.parse(value.toString())); + } + break; + default: + break; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static Object getTCPropertyValue(TCComponent item, String propertyName) { + Object result = ""; + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + if (tcProperty == null) { + System.out.println("δȡԣ" + propertyName); + return result; + } + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + result = tcProperty.getDoubleValue(); + break; + case TCProperty.PROP_int: + result = tcProperty.getIntValue(); + break; + case TCProperty.PROP_string: + result = tcProperty.getStringValue(); + break; + case TCProperty.PROP_date: + result = tcProperty.getDateValue(); + break; + case TCProperty.PROP_logical: + result = tcProperty.getLogicalValue(); + break; + default: + break; + } + } catch (TCException e) { + e.printStackTrace(); + } + return result; + } + + public static String getCellValue(Cell c) { + if (c == null) { + return ""; + } + String value = ""; + if (c.getCellType() == CellType.NUMERIC.getCode()) { + DecimalFormat df = new DecimalFormat("0"); + String whatYourWant = df.format(c.getNumericCellValue()); + return whatYourWant; + } + switch (c.getCellType()) { + case HSSFCell.CELL_TYPE_NUMERIC:// + value = (c.getNumericCellValue() + "").split("\\.")[0]; + break; + case HSSFCell.CELL_TYPE_STRING:// ַ + value = c.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_BOOLEAN:// boolean + value = c.getBooleanCellValue() + ""; + break; + case HSSFCell.CELL_TYPE_FORMULA:// ʽ + value = c.getCellFormula() + ""; + break; + case HSSFCell.CELL_TYPE_BLANK:// ֵ + value = ""; + break; + case HSSFCell.CELL_TYPE_ERROR: + value = "Ƿַ"; + break; + default: + value = "δ֪"; + break; + } + return value; + } + + /** + * õʵ + * + * @param sheet + * @param flag ҪдݿExcelԪöŸ Excel5еԪ4 + * Ҫ⣬2вҪ⣬flagʹ [0,2,3,4] + * @return + * @throws Exception + * + */ + public static int findRealRows(Sheet sheet, int... flag) throws Exception { + int row_real = 0; + int rows = sheet.getPhysicalNumberOfRows();// ˴ͳд, + try { + + for (int i = 1; i < rows; i++) { + Row row = sheet.getRow(i); + int total = 0; + ArrayList blank = new ArrayList(); + int type = -1; + String s = null; + for (int j : flag) { + if (!(row.getCell(j) == null) && row.getCell(j).getCellType() < 2) { + type = row.getCell(j).getCellType(); + row.getCell(j).setCellType(1); + } + + if (row.getCell(j) == null || row.getCell(j).getStringCellValue().matches("^\\s+$") + || row.getCell(j).getCellType() > 2) { + total++; + + if (!(row.getCell(j) == null) && row.getCell(j).getCellType() < 2) { + row.getCell(j).setCellType(type); + } + blank.add(j); + + } + } + System.out.println(s + ""); + // 4жǿ˵͸÷ + if (total == flag.length) { + + return row_real; + } else if (total == 0) { + row_real++; + + } else { + String h = ""; + for (Integer b : blank) { + + h = h + "" + (b + 1) + "" + " "; + } + throw new Exception("" + (i + 1) + "" + h + "Ϊ"); + } + + } + } catch (NullPointerException e) { + throw new Exception("excelʽ쳣,excelʽȱʧ,Ч!"); + } + return row_real; + } + + public static Workbook getWorkbook(File file) throws Exception { + Workbook workbook = null; + FileInputStream in = new FileInputStream(file); + if (file.getName().endsWith("xlsx")) { + System.out.println("ȡģ:" + file.getName()); + try { + workbook = WorkbookFactory.create(in); + } catch (EOFException e) { + e.printStackTrace(); + } +// workbook = new XSSFWorkbook(in); + } else { + System.out.println("ʽ"); + } + in.close(); + return workbook; + } + + public static void removeEnd(StringBuilder sb, int len) { + if (sb == null || len <= 0) { + return; + } + if (sb.length() >= len) { + sb.setLength(sb.length() - len); + } + } + + public static TCComponent[] getComponentsByItemType(TCComponent comp, String type, String relation) + throws TCException { + TCComponent[] comps1 = comp.getRelatedComponents(relation); + if (comps1 == null || comps1.length < 1) { + return null; + } + ArrayList list = new ArrayList(); + for (TCComponent comp1 : comps1) { + if (comp1.getType().equals(type)) { + list.add(comp1); + } + } + return list.toArray(new TCComponent[] {}); + } + + public static TCComponentContextList objectsInProject(String type, String projId) throws Exception { + if (KUtil.isEmpty(type) || KUtil.isEmpty(projId)) { + return null; + } + String queryName = "Objects in Projects"; + String[] keys = new String[] { KUtil.getText("Type"), KUtil.getText("ProjectID") }; + String[] vals = new String[] { type, projId }; + return KUtil.query(KUtil.session, queryName, keys, vals); + } + + public static TCComponentContextList objectsInProject(String type, String projId, String name) throws Exception { + if (KUtil.isEmpty(type) || KUtil.isEmpty(projId) || KUtil.isEmpty(name)) { + return null; + } + String queryName = "Objects in Projects"; + String[] keys = new String[] { KUtil.getText("Name"), KUtil.getText("Type"), KUtil.getText("ProjectID") }; + String[] vals = new String[] { name, type, projId }; + return KUtil.query(KUtil.session, queryName, keys, vals); + } + + public static boolean checkGMPrivilegeFromPref(String prefName) throws Exception { + boolean validityCanEdit = false; + String validRoles = KUtil.getPrefVal(KUtil.session, prefName); + System.out.println(">> Check GroupMember Priv: " + validRoles); + if (!KUtil.isEmpty(validRoles)) { + List groups = new ArrayList(); + List roles = new ArrayList(); + String[] split = validRoles.split(":"); + for (String string : split) { + if (string.startsWith("G.")) { + groups.add(string.substring(2)); + } else if (string.startsWith("R.")) { + roles.add(string.substring(2)); + } + } + TCComponentUser currentUser = KUtil.session.getUser(); + System.out.println(">> Current User: " + currentUser); + TCComponentGroupMember[] gms = currentUser.getGroupMembers(); + System.out.println(">> Current GroupMembers: " + Arrays.toString(gms)); + int len = KUtil.getLen(gms); + for (int i = 0; i < len; i++) { + TCComponentGroupMember gm = gms[i]; + TCComponentGroup g = gm.getGroup(); + TCComponentRole r = gm.getRole(); + String gName = g.getGroupName(); + String rName = r.getRoleName(); + System.out.println((i + 1) + ". " + gName + " - " + rName); + if (groups.contains(gName) && roles.contains(rName)) { + validityCanEdit = true; + // break; + } + } + } + return validityCanEdit; + } + + public static boolean compare(String str1, String str2) { + if (str1 == null) { + str1 = ""; + } + if (str2 == null) { + str2 = ""; + } + return str1.equals(str2); + } + + public static boolean compare(Object str1, Object str2) { + if (str1 == null) { + return str2 == null; + } + return str1.equals(str2); + } + + public static TCComponentItem createItem(TCComponentItemType itemType, String itemName) throws Exception { + if (itemType == null) { + return null; + } + String id = itemType.getNewID(); + String rev = itemType.getNewRev(null); + return itemType.create(id, rev, itemType.getName(), itemName, "", null); + } + + public static void setByPass(boolean val) { + try { + TCUserService userservice = session.getUserService(); + userservice.call(val ? "CONNOR_open_bypass" : "CONNOR_close_bypass", new Object[] { "" }); + System.out.println(val ? "Open Bypass" : "Close Bypass"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static TCComponentItem createItemBySOA(String itemTypeName, String revTypeName, String revMasterTypeName, + String itemId, String revId, String name, Map stringProps, Map dateProps) + throws Exception { + if (KUtil.isEmpty(itemTypeName) || KUtil.isEmpty(revTypeName) || KUtil.isEmpty(revMasterTypeName)) { + return null; + } + CreateInput revMasterInput = new CreateInput(); + revMasterInput.boName = revMasterTypeName; + if (stringProps != null) { + revMasterInput.stringProps = stringProps; + } + if (dateProps != null) { + revMasterInput.dateProps = dateProps; + } + CreateInput revInput = new CreateInput(); + revInput.boName = revTypeName; + Map revPropMap = new HashMap<>(); + if (!KUtil.isEmpty(revId)) { + revPropMap.put("item_revision_id", revId); + } + revInput.stringProps = revPropMap; + Map revMasterInfoMap = new HashMap<>(); + revMasterInfoMap.put("IMAN_master_form_rev", new CreateInput[] { revMasterInput }); + revInput.compoundCreateInput = revMasterInfoMap; + // create rev + CreateInput itemInput = new CreateInput(); + itemInput.boName = itemTypeName; + Map itemPropMap = new HashMap<>(); + if (!KUtil.isEmpty(itemId)) { + itemPropMap.put("item_id", itemId); + } + if (!KUtil.isEmpty(name)) { + itemPropMap.put("object_name", name); + } + itemInput.stringProps = itemPropMap; + Map revInfoMap = new HashMap<>(); + revInfoMap.put("revision", new CreateInput[] { revInput }); + itemInput.compoundCreateInput = revInfoMap; + // create info + CreateIn cI = new CreateIn(); + cI.clientId = "CreateItem"; + cI.data = itemInput; + // service + DataManagementService service = DataManagementService.getService(session); + // create + CreateResponse resp = service.createObjects(new CreateIn[] { cI }); + throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + if (cOs.length > 0) { + for (TCComponent s : cOs[0].objects) { + if (s instanceof TCComponentItem) { + return (TCComponentItem) s; + } + } + } + return null; + } + + public static TCComponentFolder createFolderBySOA(String folderTypeName, String folderName) throws Exception { + if (KUtil.isEmpty(folderTypeName)) { + return null; + } + CreateInput itemInput = new CreateInput(); + itemInput.boName = folderTypeName; + Map itemPropMap = new HashMap<>(); + itemPropMap.put("object_name", folderName); + itemInput.stringProps = itemPropMap; + // create info + CreateIn cI = new CreateIn(); + cI.clientId = "CreateFolder"; + cI.data = itemInput; + // service + DataManagementService service = DataManagementService.getService(session); + // create + CreateResponse resp = service.createObjects(new CreateIn[] { cI }); + throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + if (cOs.length > 0) { + for (TCComponent s : cOs[0].objects) { + if (s instanceof TCComponentFolder) { + return (TCComponentFolder) s; + } + } + } + return null; + } + + public static void throwServiceDataError(ServiceData serviceData) throws Exception { + if (serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + // System.out.println(errInfo.toString()); + throw new Exception(errInfo.toString()); + } + } + + public static void throwServiceDataError(ServiceData serviceData, String defaultErrorMsg) throws Exception { + if (serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + // System.out.println(errInfo.toString()); + if (KUtil.isEmpty(errInfo.toString())) { + throw new Exception(defaultErrorMsg); + } + throw new Exception(errInfo.toString()); + } + } + + public static Date localDateToDate(LocalDate localDate) { + if (localDate == null) { + return null; + } + ZonedDateTime zdt = localDate.atStartOfDay(zoneId); + Date date = Date.from(zdt.toInstant()); + return date; + } + + public static LocalDate dateToLocalDate(Date date) { + if (date == null) { + return null; + } + Instant instant = date.toInstant(); + LocalDate localDate = instant.atZone(zoneId).toLocalDate(); + return localDate; + } + + public static TCComponent stringToComponent(String uid) throws Exception { + if (KUtil.isEmpty(uid)) { + return null; + } + return session.stringToComponent(uid); + } + + public static String getText(String str) throws Exception { + if (KUtil.isEmpty(str)) { + return str; + } + String res = textService.getTextValue(str); + if (!KUtil.isEmpty(res)) { + return res; + } + return str; + } + + public static void sendTo(TCComponent comp, String perspectiveId) { + if (comp == null) { + return; + } + if (KUtil.isEmpty(perspectiveId)) { + perspectiveId = "com.teamcenter.rac.ui.perspectives.navigatorPerspective"; + } + com.teamcenter.rac.common.Activator.getDefault().openPerspective(perspectiveId); + com.teamcenter.rac.common.Activator.getDefault().openComponents(perspectiveId, new TCComponent[] { comp }); + } + + public static void open(TCComponent comp) { + if (comp == null) { + return; + } + if (comp instanceof TCComponentScheduleDeliverable) { + System.out.println(">> Open Schedule Deliverable: " + comp); + try { + comp = comp.getReferenceProperty("deliverable_inst"); + System.out.println(">> Open Schedule Deliverable Inst: " + comp); + if (comp == null) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } else if (comp instanceof TCComponentTaskDeliverable) { + System.out.println(">> Open Task Deliverable: " + comp); + try { + comp = comp.getReferenceProperty("fnd0DeliverableInstance"); + System.out.println(">> Open Task Deliverable Inst: " + comp); + if (comp == null) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + try { + Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open"); + OpenCommand localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand", + new Object[] { AIFUtility.getActiveDesktop(), comp }); + localOpenCommand.executeModeless(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static JButton getImageBtn(String iconName) { + ImageIcon icon = new ImageIcon(KUtil.class.getResource("/icons/" + iconName)); + JButton btn = new JButton(icon); + btn.setPreferredSize(new Dimension(26, 26)); + btn.setContentAreaFilled(true); + btn.setFocusPainted(false); + btn.setBorderPainted(true); + // btn.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + return btn; + } + + public static void info(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.INFORMATION); + } + + public static void warn(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.WARNING); + } + + public static void error(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.ERROR); + } + + public static void error(Window dialog, String msg, String title) { + MessageBox.post(dialog, msg, title, MessageBox.ERROR); + } + + public static void showScrollDialog(Window dialog, String text, String title) { + if (dialog == null) { + dialog = UIUtilities.getCurrentModalDialog(); + } + JTextArea textArea = new JTextArea(text); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + scrollPane.setPreferredSize(new Dimension(500, 300)); + JOptionPane.showMessageDialog(dialog, scrollPane, title, JOptionPane.INFORMATION_MESSAGE); + } + + public static void showScrollDialogWithExport(Window dialog, String text, String title, String exportFileName) { + if (dialog == null) { + dialog = UIUtilities.getCurrentModalDialog(); + } + JTextArea textArea = new JTextArea(text); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + scrollPane.setPreferredSize(new Dimension(500, 300)); + String yesOption = KLocale.getString("ok"); + String exportOption = KLocale.getString("export"); + int op = JOptionPane.showOptionDialog(dialog, scrollPane, title, JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, null, new String[] { yesOption, exportOption }, yesOption); + if (op == 1) { + System.out.println("Export"); + File saveFile = KUtil.chooseSaveFile(dialog, exportFileName, "txt"); + if (saveFile != null) { + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(saveFile, false)); + writer.write(text); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(dialog, e); + } + } + } + } + + public static void errorSWT(Shell shell, String message, String title) { + showDialog(shell, message, title, SWT.ICON_ERROR); + } + + public static void showDialog(Shell shell, String message, String title, int type) { + org.eclipse.swt.widgets.MessageBox dialog = new org.eclipse.swt.widgets.MessageBox(shell, SWT.OK | type); + dialog.setText(title); + dialog.setMessage(message); + dialog.open(); + } + + public static String[] getPrefVals(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValues(prefName); + } + + public static String getPrefVal(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValue(prefName); + } + + public static String getReg(Registry reg, String name) { + String val = reg.getString(name); + // System.out.println("Read REG: " + name + " = " + val); + return val; + } + +// public static String getReg(String name) { +// return getReg(REG, name); +// } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width) { + newRow(panel, comp, s, width, 0); + } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.weightx = weightx; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void newRow(JDialog panel, Component comp, GridBagConstraints s, int width) { + s.weightx = 0; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void addCol(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.gridx++; + s.gridwidth = width; + s.weightx = weightx; + panel.add(comp, s); + } + + public static TCComponentDataset getDataset(TCComponent rev, String dsType, String dsName, String rel) + throws Exception { + if (rev == null || KUtil.isEmpty(dsName)) { + return null; + } + rev.refresh(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.toString().equals(dsName)) { + return (TCComponentDataset) c; + } + } + return null; + } + + public static List getDatasets(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add((TCComponentDataset) c); + } + } + return res; + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel, String dsNamePrefix) + throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.getProperty("object_name").startsWith(dsNamePrefix)) { + res.add(c); + } + } + return res; + } + + public static List getChildComponentsContainsStr(TCComponent rev, String dsType, String rel, + String dsNameSubStr) throws Exception { + if (rev == null) { + return null; + } + if (dsNameSubStr == null) { + dsNameSubStr = ""; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.getProperty("object_name").contains(dsNameSubStr)) { + res.add(c); + } + } + return res; + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add(c); + } + } + return res; + } + + public static TCComponentFolder getChildFolder(TCComponentFolder folder, String cFolderName) throws Exception { + if (folder == null || cFolderName == null) { + return null; + } + AIFComponentContext[] cc = folder.getChildren(); + int len = KUtil.getLen(cc); + for (int i = 0; i < len; i++) { + InterfaceAIFComponent c = cc[i].getComponent(); + if ((c instanceof TCComponentFolder) && cFolderName.equals(c.getProperty("object_name"))) { + return (TCComponentFolder) c; + } + } + return null; + } + + public static TCComponentDataset uploadFile(TCSession session, TCComponent rev, File newFile, String dsName, + String dsTypeName, String refName, String rel) throws Exception { + TCComponentDataset ds = getDataset(rev, dsTypeName, dsName, rel); + if (ds == null) { + TCComponentDatasetType dsType = (TCComponentDatasetType) session.getTypeComponent(dsTypeName); + ds = dsType.create(dsName, "", dsTypeName); + if (rev != null) { + rev.add(rel, ds); + rev.refresh(); + } + } + setDsFile(ds, refName, newFile); + return ds; + } + + public static void setDsFile(TCComponentDataset ds, String refName, File newFile) throws Exception { + if (ds.isCheckedOut()) { + throw new Exception(String.format(KLocale.getString("uploadfilewhencheckout.ERROR1"), ds.toString())); + } + String[] refs = new String[] { refName }; + String[] files = new String[] { newFile.getAbsolutePath() }; + ds.setFiles(files, refs); + // ds.save(); + ds.refresh(); + } + + public static void setDsFile2(TCComponentDataset ds, String refName, File newFile) throws Exception { + String[] refs = new String[] { refName }; + String[] files = new String[] { newFile.getAbsolutePath() }; + ds.setFiles(files, refs); + // ds.save(); + ds.refresh(); + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + public static int inArray(int target, int[] arr) { + int len = arr == null ? 0 : arr.length; + for (int i = 0; i < len; i++) { + if (target == arr[i]) { + return i; + } + } + return -1; + } + + public static boolean inArray(String str, String arr, String splitter) { + if (KUtil.isEmpty(arr) || KUtil.isEmpty(splitter)) { + return false; + } + if (KUtil.isEmpty(str)) { + return true; + } + return inArray(str, arr.split(splitter)) >= 0; + } + + public static int inArray(String target, String[] arr) { + int len = arr == null ? 0 : arr.length; + for (int i = 0; i < len; i++) { + if (target.equals(arr[i])) { + return i; + } + } + return -1; + } + + public static int getNextColNumber(int currentIndex, int[] skipColIndex, int cols) { + int res = currentIndex; + for (int i = 0; i < cols; i++) { + res++; + if (inArray(res, skipColIndex) >= 0) { + i--; + } + } + return res; + } + + public static List> groupList(List originList, int maxCount, int gap, E gapFiller) { + List> res = new ArrayList>(); + int cnt = originList == null ? 0 : originList.size(); + List list = new ArrayList(); + for (int i = 0; i < cnt; i++) { + list.add(originList.get(i)); + if (i != cnt - 1) {// add gap + for (int j = 0; j < gap; j++) { + list.add(gapFiller); + } + } + } + cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List cList = new ArrayList(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + E item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static List> groupListWithGapAdded(List list, int maxCount, E gapFiller) { + List> res = new ArrayList>(); + int cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List cList = new ArrayList(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + E item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static List>> groupList(List> originList, int maxCount, int gap, + Map gapFiller, String gapKey) { + List>> res = new ArrayList>>(); + int cnt = originList == null ? 0 : originList.size(); + List> list = new ArrayList>(); + boolean addGap = false; + for (int i = 0; i < cnt; i++) { + Map item = originList.get(i); + list.add(item); + if (i != cnt - 1) {// add gap + Map nextItem = originList.get(i + 1); + addGap = KUtil.isEmpty(gapKey) || (nextItem != null && nextItem.containsKey(gapKey)); + for (int j = 0; j < gap; j++) { + if (addGap) { + list.add(gapFiller); + } + } + } + } + cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List> cList = new ArrayList>(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + Map item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static File getFileFromDataset(TCSession session, String dsType, String uid, String prefName) + throws Exception { + TCComponent comp = null; + try { + comp = session.stringToComponent(uid); + } catch (Exception e) { + e.printStackTrace(); + } + if (comp == null) { + throw new Exception(String.format(KLocale.getString("dsuidinpref.ERROR1"), prefName)); + } + String type = comp.getType(); + System.out.println("Dataset: " + comp + "|Type: " + type); + if (!dsType.equals(type)) { + throw new Exception(String.format(KLocale.getString("dsuidinpref.ERROR1"), prefName)); + } + TCComponentDataset tDataset = (TCComponentDataset) comp; + return getDatasetFile(tDataset); + } + + public static File getDatasetFile(TCComponentDataset dataset) throws Exception { + File[] files = dataset.getFiles("", System.getenv("TEMP")); + if (files == null || files.length == 0) { + throw new Exception(String.format(KLocale.getString("norefindataset.ERROR1"), dataset.toString())); + } + System.out.println(">> Download file (" + files.length + "): " + files[0].getAbsolutePath()); + return files[0]; + } + + public static File getDatasetFile(File dir, TCComponentDataset dataset) throws Exception { + if (dir == null || !dir.isDirectory()) { + throw new Exception("Directory not found."); + } + File[] files = dataset.getFiles("", dir.getAbsolutePath()); + if (files == null || files.length == 0) { + throw new Exception(String.format(KLocale.getString("norefindataset.ERROR1"), dataset.toString())); + } + System.out.println(">> Download file (" + files.length + "): " + files[0].getAbsolutePath()); + return files[0]; + } + + public static String[] getStringArrayProp(TCComponentForm form, String propName) throws Exception { + if (form == null) { + return null; + } + TCProperty prop = form.getFormTCProperty(propName); + if (prop == null) { + throw new java.lang.Exception( + String.format(KLocale.getString("nopropintype.ERROR2"), form.getDisplayType(), propName)); + } + return prop.getStringArrayValue(); + } + + public static File chooseDirectory(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static boolean addReleaseStatus(TCSession session, String uid, String status) throws Exception { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[2]; + obj[0] = uid; + obj[1] = status; + Object res = userservice.call("K_add_release_status", obj); + if (res != null && res.toString().equalsIgnoreCase("true")) { + return true; + } + return false; + } + + /** + * ֻԵֵ + * + * @param session + * @param propName + * @param propValue + * @param comp + * @return + * @throws Exception + */ + public static boolean setPropValue(TCSession session, String propName, String propValue, TCComponent comp) + throws Exception { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[3]; + obj[0] = propName; + obj[1] = propValue; + obj[2] = comp; + Object res = userservice.call("Connor_Set_Prop_Value", obj); + if (res != null && res.toString().equalsIgnoreCase("true")) { + return true; + } + return false; + } + + public static File chooseFile(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.xlsx", "xlsx"); + fileChooser.setFileFilter(filter); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File chooseSaveFile(Component parent, String defaultFile) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.xlsx", "xlsx"); + fileChooser.setFileFilter(filter); + fileChooser.setSelectedFile(new File(defaultFile)); + int state = fileChooser.showSaveDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File chooseSaveFile(Component parent, String defaultFile, String ext) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + if (!KUtil.isEmpty(ext)) { + FileNameExtensionFilter filter = new FileNameExtensionFilter("*." + ext, ext); + fileChooser.setFileFilter(filter); + } + fileChooser.setSelectedFile(new File(defaultFile)); + int state = fileChooser.showSaveDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File getNewFile(File folder, String fileName, String ext) { + File file = new File(folder.getAbsolutePath() + "\\" + fileName + "." + ext); + int index = 1; + while (file.exists()) { + file = new File(folder.getAbsolutePath() + "\\" + fileName + "(" + (index++) + ")." + ext); + } + return file; + } + + public static String getDateStr(Date date, String format) { + String res = ""; + try { + SimpleDateFormat sdf = new SimpleDateFormat(format); + res = sdf.format(date); + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public static TCComponentContextList query(TCSession session, String queryName, Map fields) + throws Exception { + String[] keys = fields.keySet().toArray(new String[] {}); + String[] vals = fields.values().toArray(new String[] {}); + return query(session, queryName, keys, vals); + } + + public static TCComponentContextList query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new Exception(String.format(KLocale.getString("querynotexist.ERROR1"), queryName)); + } + queryType.clearCache(); + query.clearCache(); + query.refresh(); + return query.getExecuteResultsList(keys, vals); + } + + public static TCComponent[] query2(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new Exception(String.format(KLocale.getString("querynotexist.ERROR1"), queryName)); + } + queryType.clearCache(); + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + + public static TCComponentContextList combineContext(TCSession session, TCComponentQuery query, + TCComponentContextList... contexts) throws Exception { + Class c = TCComponentContextList.class; + Field f1 = c.getDeclaredField("m_compUids"); + f1.setAccessible(true); + List compUids = new ArrayList<>(); + for (TCComponentContextList cc : contexts) { + String[] u1 = (String[]) f1.get(cc); + System.out.println(Arrays.toString(u1)); + compUids.addAll(Arrays.asList(u1)); + } + Constructor constructor = c.getDeclaredConstructor(TCComponentManager.class, TCComponent.class, + String[].class, String[].class, String.class); + constructor.setAccessible(true); + TCComponentContextList res = (TCComponentContextList) constructor.newInstance(new TCComponentManager(session), + query, compUids.toArray(new String[] {}), null, ""); + return res; + } + + public static int getLen(Object[] arr) { + return arr == null ? 0 : arr.length; + } + + public static String getValueInArray(String[] arr, int index) { + int len = arr == null ? 0 : arr.length; + if (index >= len) { + return ""; + } + return arr[index]; + } + + public static String getValueInArray(String arrStr, int index, String splitter) { + if (KUtil.isEmpty(arrStr)) { + return ""; + } + String[] split = arrStr.split(splitter, -1); + int len = getLen(split); + if (len > index && index >= 0) { + return split[index]; + } + return ""; + } + + public static String getTypeNames(TCSession session, Object[] types) { + int len = types == null ? 0 : types.length; + if (len == 0) { + return ""; + } + String[] names = new String[len]; + for (int i = 0; i < len; i++) { + try { + if ("TC_Project".equals(types[i].toString())) { + names[i] = KLocale.getString("project"); + } else { + names[i] = session.getTypeComponent(types[i].toString()).getDisplayTypeName(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (names[i] == null) { + names[i] = types[i].toString(); + } + } + return Arrays.toString(names); + } + + public static String getTypeName(TCSession session, String type) { + if (KUtil.isEmpty(type)) { + return ""; + } + try { + if ("TC_Project".equals(type)) { + return KLocale.getString("project"); + } else { + return session.getTypeComponent(type).getDisplayTypeName(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return type; + } + + public static boolean isReleased(TCComponent comp) throws Exception { + TCComponent[] status = comp.getReferenceListProperty("release_status_list"); + if (status == null || status.length == 0) { + return false; + } + return true; + } + + public static TCComponentUser getUserFromStr(String str) throws Exception { + System.out.println("Search User: " + str); + if (KUtil.isEmpty(str)) { + return null; + } + int ind1 = str.lastIndexOf('('); + int ind2 = str.lastIndexOf(')'); + TCComponentUser user = null; + if (ind1 > 0 && ind2 > ind1) { + String userId = str.substring(ind1 + 1, ind2); + if (KUtil.isEmpty(userId)) { + System.out.println("No Id between '(' and ')'"); + user = null; + } else { + user = queryUserById(userId); + } + } else { + user = queryUserById(str); + if (user == null) { + user = queryUserByName(str); + } + } + return user; + } + + public static TCComponentUser queryUserById(String userId) throws Exception { + System.out.println("Search User By Id: " + userId); + if (KUtil.isEmpty(userId)) { + return null; + } + String queryName = "Admin - Employee Information"; + String[] keys = new String[] { KUtil.getText("UserId") }; + String[] vals = new String[] { userId }; + TCComponentContextList res = KUtil.query(KUtil.session, queryName, keys, vals); + if (res.getListCount() == 0) { + return null; + } + if (res.getListCount() > 1) { + throw new Exception(String.format(KLocale.getString("multiuserbyid.ERROR1"), userId)); + } + return (TCComponentUser) res.get(0).getComponent(); + } + + public static TCComponentUser queryUserByName(String userName) throws Exception { + System.out.println("Search User By Name: " + userName); + if (KUtil.isEmpty(userName)) { + return null; + } + String queryName = "Admin - Employee Information"; + String[] keys = new String[] { KUtil.getText("PersonName") }; + String[] vals = new String[] { userName }; + TCComponentContextList res = KUtil.query(KUtil.session, queryName, keys, vals); + if (res.getListCount() == 0) { + return null; + } + if (res.getListCount() > 1) { + throw new Exception(String.format(KLocale.getString("multiuserbyname.ERROR1"), userName)); + } + return (TCComponentUser) res.get(0).getComponent(); + } + + public static TCComponent[] getGroupMember(List privMembers) throws Exception { + if (privMembers == null) { + return null; + } + List res = new ArrayList<>(); + for (TCComponentUser user : privMembers) { + TCComponentGroupMember[] gms = user.getGroupMembers(); + int len = KUtil.getLen(gms); + for (int i = 0; i < len; i++) { + TCComponentGroupMember gm = gms[i]; + if (KUtil.isEmpty(gm.toString())) { + continue; + } + /* + * if(!gm.isActive()) { System.out.println("���Ա�ǻ�?"+gm); continue; } + */ + if (!res.contains(gm)) { + System.out.println("Add Group Member: " + gm); + res.add(gm); + } else { + System.out.println("Added: " + gm); + } + } + } + return res.toArray(new TCComponent[] {}); + } + + public static int compareWBS(String wbsCode, String wbsCode2) { + if (KUtil.isEmpty(wbsCode) && KUtil.isEmpty(wbsCode2)) { + return 0; + } + if (KUtil.isEmpty(wbsCode)) { + return -1; + } + if (KUtil.isEmpty(wbsCode2)) { + return 1; + } + String[] a = wbsCode.split("\\."); + String[] b = wbsCode2.split("\\."); + int lenA = a.length; + int lenB = b.length; + for (int i = 0; i < lenA && i < lenB; i++) { + String aa = a[i]; + String bb = b[i]; + int ai = 0; + int bi = 0; + try { + ai = Integer.parseInt(aa); + bi = Integer.parseInt(bb); + } catch (Exception e) { + e.printStackTrace(); + } + if (ai != bi) { + return ai - bi; + } + } + return lenA - lenB; + } + + public static TCComponentListOfValues getLov(String lovName) { + TCComponentListOfValuesType lovType; + try { + lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + if (lov.length > 0) + return lov[0]; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String[] getDynamicLOV(String s) { + TCComponentListOfValues lov = null; + List lovDisplayValueList = new ArrayList<>(); + lovDisplayValueList.add(""); + List lovValueList = new ArrayList<>(); + lov = TCComponentListOfValuesType.findLOVByName(s); + try { + if ("Fnd0ListOfValuesDynamic".equals(lov.getProperty("lov_type"))) { + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = "object_name"; + filter.order = 1; + filter.numberToReturn = 100; + filter.maxResults = 100; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + StringBuffer sb = new StringBuffer(); + sb.append(">>"); + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; + + for (String key : map.keySet()) { + sb.append("UID:" + row.uid + ",key:" + key + "value:" + map.get(key)[0]); + sb.append("\n"); + + lovDisplayValueList.add(map.get(key)[0]); + lovValueList.add(realmap.get(key)[0]); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return lovDisplayValueList.toArray(new String[lovDisplayValueList.size()]); + } + + public static String getLovValue(TCComponentListOfValues lov, String str) throws Exception { + return getLovValue(lov, str, true); + } + + public static String getLovValue(TCComponentListOfValues lov, String str, boolean translate) throws Exception { + if (lov == null || KUtil.isEmpty(str)) { + return str; + } + if (translate) { + String prefName = "LOV_TRANS_" + lov.getStringProperty(TCComponentListOfValues.PROP_LOV_NAME); + String[] prefVals = KUtil.getPrefVals(KUtil.session, prefName); + int len = KUtil.getLen(prefVals); + for (int i = 0; i < len; i++) { + String pref = prefVals[i]; + int ind = pref.indexOf('='); + if (ind > 0) { + String realVal = pref.substring(0, ind); + String disVal = pref.substring(ind + 1); + if (str.equals(realVal) || str.equals(disVal)) { + return realVal; + } + } + } + } + ListOfValuesInfo info = lov.getListOfValues(); + if (info == null) { + return str; + } + List v = info.getValues(); + int size = v == null ? 0 : v.size(); + for (int i = 0; i < size; i++) { + LovValue vv = v.get(i); + String realValue = vv.getValue() == null ? "" : vv.getValue().toString(); + if (str.equals(realValue)) { + return str; + } + String disValue = vv.getDisplayValue(); + if (str.equals(disValue)) { + return realValue; + } + } + throw new Exception(String.format(KLocale.getString("valuenotinlov.ERROR2"), lov.toString(), str)); + } + + public static String getLovDisplayableValue(TCComponentListOfValues lov, String str) throws Exception { + if (lov == null || KUtil.isEmpty(str)) { + return str; + } + ListOfValuesInfo info = lov.getListOfValues(); + if (info == null) { + return str; + } + List v = info.getValues(); + int size = v == null ? 0 : v.size(); + for (int i = 0; i < size; i++) { + LovValue vv = v.get(i); + String realValue = vv.getValue() == null ? "" : vv.getValue().toString(); + if (str.equals(realValue)) { + return vv.getDisplayValue(); + } + String disValue = vv.getDisplayValue(); + if (str.equals(disValue)) { + return str; + } + } + throw new Exception(String.format(KLocale.getString("valuenotinlov.ERROR2"), lov.toString(), str)); + } + + public static void openFile(File file) { + try { + if (file != null && file.exists()) { + Runtime.getRuntime().exec("cmd /c start /b call \"" + file.getAbsolutePath() + "\""); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e); + } + } + + public static void importDataset(TCComponent parent, String rel, File f, String dsType, String refName) + throws Exception { + if (f == null || !f.exists() || KUtil.isEmpty(dsType) || KUtil.isEmpty(refName)) { + return; + } + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent(dsType); + TCComponentDataset dataset = datasetType.create(f.getName(), "", dsType); + String paths[] = { f.getAbsolutePath() }; + String refs[] = { refName }; + dataset.setFiles(paths, refs); + if (parent != null && !KUtil.isEmpty(rel)) { + parent.add(rel, dataset); + } + } + + public static void initPropMap(String propConfig, String value, Map itemPropMap, + Map itemMasterPropMap, Map revPropMap, Map revMasterPropMap) + throws Exception { + initPropMap(propConfig, value, itemPropMap, itemMasterPropMap, revPropMap, revMasterPropMap, null); + } + + public static void initPropMap(String propConfig, String value, Map itemPropMap, + Map itemMasterPropMap, Map revPropMap, Map revMasterPropMap, + Map bomlinePropMap) throws Exception { + if (KUtil.isEmpty(propConfig)) { + return; + } + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + return; + } + Map target; + if ("ITEM".equals(propFrom)) { + target = itemPropMap; + System.out.println(">> ITEM PROP: " + propName + " = " + value); + } else if ("REV".equals(propFrom)) { + System.out.println(">> REV PROP: " + propName + " = " + value); + target = revPropMap; + } else if ("ITEMMASTER".equals(propFrom)) { + System.out.println(">> ITEMMASTER PROP: " + propName + " = " + value); + target = itemMasterPropMap; + } else if ("REVMASTER".equals(propFrom)) { + System.out.println(">> REVMASTER PROP: " + propName + " = " + value); + target = revMasterPropMap; + } else if ("BOMLINE".equals(propFrom)) { + System.out.println(">> BOMLINE PROP: " + propName + " = " + value); + target = bomlinePropMap; + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + if (target == null) { + return; + } + target.put(propName, value); + } + + public static String getMarkedPropValue(String config, Map markedComponents) throws Exception { + return getMarkedPropValue(config, markedComponents, null); + } + + public static String getMarkedPropValue(String config, Map markedComponents, + Map> relatedComponents) throws Exception { + if (markedComponents == null || KUtil.isEmpty(config)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = config.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String defaultValue = ""; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) >= 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.getLen(split) >= 3) { + defaultValue = split[2].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + if (propConfig.contains("\\n")) { + propConfig = propConfig.replace("\\n", "\n"); + } + res.append(propConfig); + continue; + } + if (!markedComponents.containsKey(propFrom)) { + if (propFrom.startsWith("T")) { + return ""; + } + continue; + } + TCComponent comp = markedComponents.get(propFrom); + // λ.-[-ӷ] + int ind = propName.indexOf('-'); + if (ind > 0) { + String tableProp = propName.substring(0, ind).trim(); + String tableRowProp = propName.substring(ind + 1).trim(); + if (!KUtil.isEmpty(tableProp) && !KUtil.isEmpty(tableRowProp)) { + TCProperty prop = comp.getTCProperty(tableProp.trim()); + if (prop == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), + comp.getType(), propName)); + } + String rowSplitter = "#ROW#"; + ind = tableRowProp.indexOf('-'); + if (ind > 0) { + rowSplitter = tableRowProp.substring(ind + 1); + tableRowProp = tableRowProp.substring(0, ind); + } + TCComponent[] tableRows = prop.getReferenceValueArray(); + int rowCnt = KUtil.getLen(tableRows); + String[] value = new String[rowCnt]; + for (int j = 0; j < rowCnt; j++) { + value[j] = tableRows[j].getPropertyDisplayableValue(tableRowProp); + } + res.append(String.join(rowSplitter, value)); + } + continue; + } + TCProperty prop = comp.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), comp.getType(), propName)); + } + String value = prop.getDisplayableValue(); + if ("NAME".equalsIgnoreCase(defaultValue)) { + value = prop.getPropertyDisplayName(); + } else if (value == null || "".equals(value)) { + value = defaultValue; + } + res.append(value); + } + return res.toString(); + } + + public static TCComponent getLatestComponent(List comps) { + int size = comps == null ? 0 : comps.size(); + if (size == 0) { + return null; + } + if (size == 1) { + return comps.get(0); + } + TCComponent res = comps.get(0); + try { + Date maxDate = res.getDateProperty("creation_date"); + for (int i = 1; i < size; i++) { + TCComponent temp = comps.get(i); + Date tempDate = temp.getDateProperty("creation_date"); + if (tempDate.after(maxDate)) { + maxDate = tempDate; + res = temp; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public static TCComponentType[] getComponentTypes(String itemTypeName) throws Exception { + TCComponentItemType itemType = null; + try { + itemType = (TCComponentItemType) session.getTypeComponent(itemTypeName); + } catch (Exception e) { + e.printStackTrace(); + } + if (itemType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName)); + } + TCComponentItemRevisionType revType = itemType.getItemRevisionType(); + if (revType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName + "Revision")); + } + TCComponentType itemMasterType = null; + try { + itemMasterType = session.getTypeComponent(itemTypeName + "Master"); + } catch (Exception e) { + e.printStackTrace(); + } + if (itemMasterType == null) { + try { + itemMasterType = session.getTypeComponent(itemTypeName + " Master"); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (itemMasterType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName + "Master")); + } + TCComponentType revMasterType = null; + try { + revMasterType = session.getTypeComponent(revType.getTypeName() + "Master"); + } catch (Exception e) { + e.printStackTrace(); + } + if (revMasterType == null) { + try { + revMasterType = session.getTypeComponent(revType.getTypeName() + " Master"); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (revMasterType == null) { + throw new Exception( + String.format(KLocale.getString("typenotfound.ERROR1"), revType.getTypeName() + "Master")); + } + return new TCComponentType[] { itemType, revType, itemMasterType, revMasterType }; + } + + public static String getPropertyDisplayName(TCComponentType type, String propName) throws Exception { + if (type == null || KUtil.isEmpty(propName)) { + return propName; + } + TCPropertyDescriptor desc = type.getPropDesc(propName); + if (desc == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), + type.getDisplayTypeName(), propName)); + } + return desc.getDisplayName(); + } + + public static String getConfigPropValue(TCComponentItemRevision rev, String propConfigStr) throws Exception { + if (rev == null || KUtil.isEmpty(propConfigStr)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = propConfigStr.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + res.append(propConfig); + continue; + } + TCComponent target; + if ("ITEM".equals(propFrom)) { + target = rev.getItem(); + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = rev.getItem().getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), target.getType(), propName)); + } + res.append(prop.getStringValue()); + } + return res.toString(); + } + + public static String getConfigPropDisplayableValue(TCComponentItemRevision rev, String propConfigStr) + throws Exception { + if (rev == null || KUtil.isEmpty(propConfigStr)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = propConfigStr.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + res.append(propConfig); + continue; + } + TCComponent target; + if ("ITEM".equals(propFrom)) { + target = rev.getItem(); + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = rev.getItem().getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), target.getType(), propName)); + } + res.append(prop.getDisplayableValue()); + } + return res.toString(); + } + + public static void removeAllParents(DataManagementService dm, TCComponent comp) throws Exception { + comp.refresh(); + System.out.println("Remove from parent: " + comp); + WhereReferencedResponse refResp = dm.whereReferenced(new TCComponent[] { comp }, 1); + KUtil.throwServiceDataError(refResp.serviceData); + int len = KUtil.getLen(refResp.output); + List datas = new ArrayList(); + for (int i = 0; i < len; i++) { + WhereReferencedOutput ref = refResp.output[i]; + int cnt = KUtil.getLen(ref.info); + for (int j = 0; j < cnt; j++) { + WhereReferencedInfo info = ref.info[j]; + Relationship data = new Relationship(); + data.primaryObject = info.referencer; + data.secondaryObject = comp; + data.relationType = info.relation; + System.out.println(">> " + info.relation + " | " + info.referencer); + datas.add(data); + } + } + ServiceData resp = dm.deleteRelations(datas.toArray(new Relationship[] {})); + KUtil.throwServiceDataError(resp); + } + + public static TCComponent newTableRow(DataManagementService dmService, String type, + Map rowStringProps, Map rowDateProps) throws Exception { + CreateIn rowIn = new CreateIn(); + CreateInput rowInput = new CreateInput(); + rowInput.boName = type; + if (rowStringProps != null) { + rowInput.stringProps = rowStringProps; + } + if (rowDateProps != null) { + rowInput.dateProps = rowDateProps; + } + rowIn.data = rowInput; + CreateResponse res = dmService.createObjects(new CreateIn[] { rowIn }); + KUtil.throwServiceDataError(res.serviceData); + if (res.serviceData.sizeOfCreatedObjects() > 0) { + return res.serviceData.getCreatedObject(0); + } + return null; + } + + public static Date addDay(Date day, int cnt) { + if (day == null) { + return null; + } + Calendar c = Calendar.getInstance(); + c.setTime(day); + c.add(Calendar.DATE, cnt); + return c.getTime(); + } + + public static Date calTime(TCCalendar calendar, Date date, int minutes) { + if (calendar == null || date == null) { + return null; + } + int diff = minutes > 0 ? 1 : -1; + if (minutes < 0) { + minutes = -minutes; + } + Calendar c = Calendar.getInstance(); + c.setTime(date); + int counter = 0; + while (counter < minutes) { + counter += calendar.getMinutesOnDay(c); + c.add(Calendar.DATE, diff); + } + return c.getTime(); + } + + public static int getMinutesBetween(TCCalendar calendar, Date start, Date end) { + if (calendar == null || start == null || end == null) { + return 0; + } + Calendar c = Calendar.getInstance(); + c.setTime(start); + int res = 0; + while (c.getTime().before(end)) { + res += calendar.getMinutesOnDay(c); + // System.out.println(calendar.getMinutesOnDay(c)+" > "+c.getTime()); + c.add(Calendar.DATE, 1); + } + return res; + } + + public static TCComponentTCCalendar getScheduleCalendar(TCComponentSchedule schedule) throws Exception { + if (schedule == null) { + return null; + } + return CalendarHelper.getScheduleCalendar(schedule, session); + } + + public static void dealSpecialModelValue(ArrayList specialList, String prefName, String prop, int ind) { + int index = 0; + + try { + String[] prefVals = KUtil.getPrefVals(session, prefName); + String puid = prefVals[ind]; + TCComponent component = session.stringToComponent(puid); + if (component instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) component; + + TCComponent[] tables = form.getReferenceListProperty("ld6_ChangeTable"); + for (int j = 0; j < tables.length; j++) { + + String change = tables[j].getStringProperty(prop); + if (change.equals("")) { + specialList.add(j); + } + } + + } + +// +// Set>> entrySet = map.entrySet(); +// for (Entry> entry : entrySet) { +// ArrayList list = entry.getValue(); +// String value = list.get(2); +// System.out.println("ǰֵΪ" + value); +// if(value != null && value.equals("")) { +// specialList.add(index); +// } +// index++; +// } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * õģֵ + * + * @param map + * @throws Exception + */ +// public static void getModelVale(LinkedHashMap> map,String prefName,int index) throws Exception { +// AbstractAIFApplication application = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) application.getSession(); +// String[] prefVals = KUtil.getPrefVals(session, prefName); +// String puid = prefVals[index]; +// TCComponentDataset component = (TCComponentDataset) session.stringToComponent(puid); +// TCComponentTcFile[] tcFiles = component.getTcFiles(); +// File datasetFile = null; +// String name = ""; +// if (tcFiles != null && tcFiles.length != 0) { +// TCComponentTcFile tcComponentTcFile = tcFiles[0]; +// File fmsFile = tcComponentTcFile.getFmsFile(); +// name = tcComponentTcFile.getStringProperty("original_file_name"); +// datasetFile = new File(System.getenv("TEMP")+"\\"+name); +// FileUtility.copyFile(fmsFile, datasetFile); +// +// } +// XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(datasetFile)); +// XSSFSheet sheet = wb.getSheetAt(0); +// for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { +// XSSFRow row = sheet.getRow(i); +// for (int j = 0; j < 5; j++) { +// XSSFCell cell = row.getCell(j); +// if(cell != null) { +// String cellValue = KUtil.getCellValue(cell); +// if(j == 0 && cellValue.isEmpty()) { +// break; +// } +// if(j == 0 ) { +// if(map.containsKey(cellValue)) { +// break; +// }else { +// map.put(cellValue, null); +// } +// }else { +// String key = KUtil.getCellValue(row.getCell(0)); +// ArrayList arrayList = map.get(key); +// if(arrayList != null) { +// arrayList.add(cellValue); +// }else { +// ArrayList list = new ArrayList(); +// list.add(cellValue); +// map.put(key, list); +// } +// } +// +// } +// } +// } +// wb.close(); +// datasetFile.delete(); +// } + /** + * õģֵ + * + * @param map + * @throws Exception + */ + public static void getModelVale(LinkedHashMap> map, TCComponent forms, + ArrayList specialList, String[] propNames) throws Exception { +// AbstractAIFApplication application = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) application.getSession(); +// String[] prefVals = KUtil.getPrefVals(session, prefName); +// String puid = prefVals[index]; +// TCComponent component = session.stringToComponent(puid); + int t = 1; + if (forms instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) forms; + TCComponent[] tables = form.getReferenceListProperty("ld6_ChangeTable"); + for (int j = 0; j < tables.length; j++) { + ArrayList tableValue = new ArrayList(); + + for (String propName : propNames) { + System.out.println("ǰΪ" + propName); + String prop = tables[j].getTCProperty(propName).getDisplayableValue(); + if (propName.equals("ld6_YNChange") && prop.equals("")) { +// specialList.add(j); + } + tableValue.add(prop == null ? "" : prop.trim()); + } + + map.put(String.valueOf(t), tableValue); +// tableValue + + t = t + 1; + } + + } + + } + + /** + * õlovʵֵʾֵ + * + * @param lovMap + * @param comboBox + * @throws TCException + */ + public static void getLov(HashMap lovMap, String lovName, JComboBox comboBox) + throws TCException { + if (comboBox != null) { + comboBox.addItem(""); + } +// for (LovValue lovV : lovValueList) { +// map.put(lovV.getDisplayValue(), lovV.getStringValue()); +// comboBox.addItem(lovV.getDisplayValue()); +// System.out.println(lovV.getDisplayValue() + "===" + lovV.getStringValue()); +// } + + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(lovName); + if ("Fnd0ListOfValuesDynamic".equals(lov.getProperty("lov_type"))) { + System.out.println("̬lovName=" + lovName); + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + if ("LD6_TecDoc_TypeLOV".equals(lovName)) { + filter.sortPropertyName = "fnd0StringValues"; // lovĺֵ̨ + } else { + filter.sortPropertyName = "object_name"; // lovĺֵ̨ + } + + filter.order = 1; + filter.numberToReturn = 2000; + filter.maxResults = 2000; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + // System.out.println("111==="+result.toString()); + + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; +// for (String key : map.keySet()) { +// System.out.println("key=" + key + ",value=" + map.get(key)[0]); +// } +// for (String key : realmap.keySet()) { +// System.out.println("key2=" + key + ",value2=" + map.get(key)[0]); +// } + String disval = ""; + String val = ""; + String key1 = "object_name";// ʵֵ ʾֵһ + if ("LD6_TecDoc_TypeLOV".equals(lovName)) { + key1 = "fnd0StringValues"; // lovĺֵ̨ + } + // String key2 = "object_desc";// ʾֵڶ + if (map.containsKey(key1)) { + val = realmap.get(key1)[0]; + disval = map.get(key1)[0]; + } + if (!val.equals("")) { + lovMap.put(disval, val); + if (comboBox != null) { + comboBox.addItem(disval); + } + } + + } + + } else { + ListOfValuesInfo info = lov.getListOfValues(); + info.getLOVDisplayValues(); + List lovValueList = info.getValues(); + for (LovValue lovV : lovValueList) { + lovMap.put(lovV.getDisplayValue(), lovV.getStringValue()); + if (comboBox != null) { + comboBox.addItem(lovV.getDisplayValue()); + } + } + } + + } + + public static void dealPref(String[] prefVals, InterfaceAIFComponent targetComponent, + ArrayList beanList, StringBuffer newTypeBuffer) throws Exception { + /** + * LD6_PRRevision/LD6_CR|*[string]Item.item_id=; + * *[string]Item.object_name=;*[string]Rev.ld6_processNum=;*[string]Rev.ld6_productNum=Rev.ld6_proNum + */ + String type = targetComponent.getType(); + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + for (String string : prefVals) { + String[] split = string.split("\\|"); + if (split.length == 2) { + String[] split2 = split[0].split("/"); + if (split2.length == 2 && type.equals(split2[0])) { + // õ + newTypeBuffer.append(split2[1]); + // õĿؼ + String[] split3 = split[1].split(";"); + for (int i = 0; i < split3.length; i++) { + ControlBean bean = new ControlBean(); + if (split3[i].contains("*[")) { + bean.setIfMust(true); + } + String[] split4 = split3[i].split("="); + // жʲô͵ + if (split4[0].contains("boolean")) { + bean.setPropType("boolean"); + } else if (split4[0].contains("date")) { + bean.setPropType("date"); + } else if (split4[0].contains("string:")) { + bean.setPropType("lov"); + } else if (split4[0].contains("string") && !split4[0].contains("string:")) { + bean.setPropType("string"); + } + if (split4.length == 2) { + bean.setDefaultValue(getTCPropertyValue(rev, split4[1], bean)); + } + String[] split5 = split4[0].split("]"); + if (split5.length == 2) { + String[] split6 = split5[1].split("\\."); + bean.setPropTo(split6[0]); + bean.setPropRelName(split6[1]); + bean.setPropName(split6[2]); + if ("lov".equals(bean.getPropType())) { + // õlovlovMap + String[] split7 = split5[0].split(":"); + String lovName = split7[1]; + HashMap lovMap = new LinkedHashMap(); + // JComboBox combox = new JComboBox(); + try { + String desType = newTypeBuffer.toString(); + if ("Rev".equals(bean.getPropTo())) { + desType = desType + "Revision"; + } else if ("Form".equals(bean.getPropTo())) { + desType = desType + "RevisionMaster"; + } + TCComponentType localTCComponentType = session.getTypeComponent(desType); + TCPropertyDescriptor descriptor = localTCComponentType + .getPropertyDescriptor(bean.getPropRelName()); + LOVDisplayer combo = new LOVDisplayer(descriptor); + getLov(lovMap, lovName, null); + bean.setCombox(combo); + } catch (TCException e) { + e.printStackTrace(); + } + bean.setLovMap(lovMap); + // bean.setCombox(combox); + } + } + beanList.add(bean); + } + break; + } + } + } + } + + public static String getTCPropertyValue(TCComponentItemRevision rev, String specialValue, ControlBean bean) { + try { + String[] split = specialValue.split("\\."); + TCComponent center = null; + if (split.length == 2 || split.length == 3) { + switch (split[0]) { + case "Rev": + center = rev; + break; + case "Item": + center = rev.getItem(); + break; + case "Form": + center = rev.getRelatedComponent("IMAN_master_form_rev"); + break; + default: + break; + } + String value = ""; + if ("date".equals(bean.getPropType())) { + System.out.println("ǰʵΪ" + split[1]); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + if (center.getDateProperty(split[1]) != null) { + value = sdf.format(center.getDateProperty(split[1])); + } + } else { + value = center.getStringProperty(split[1]); + } + if (split.length == 3) { + bean.setPropName(split[2]); + } + return value; + } + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } +} diff --git a/src/cn/net/connor/ld/plm/ProgressBar.java b/src/cn/net/connor/ld/plm/ProgressBar.java new file mode 100644 index 0000000..d585a6f --- /dev/null +++ b/src/cn/net/connor/ld/plm/ProgressBar.java @@ -0,0 +1,130 @@ +package cn.net.connor.ld.plm; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.KeyStroke; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; + +@SuppressWarnings("serial") +public class ProgressBar extends AbstractAIFDialog { + + private JLabel messageLabel; + + private JProgressBar progressBar; + + private boolean showBar = false; + + public ProgressBar(AIFDesktop aifDesktop, Dimension dim, boolean showBar) { + super(aifDesktop, false); + this.showBar = showBar; + initUI(dim); + } + + public ProgressBar(AbstractAIFDialog pd, Dimension dimension) { + super(pd, false); + initUI(dimension); + } + + public ProgressBar(Dimension dim, boolean showBar) { + super(false); + this.showBar = showBar; + initUI(dim); + } + + public ProgressBar(AbstractAIFDialog pd, Dimension dimension, boolean showBar) { + super(pd, false); + this.showBar = showBar; + initUI(dimension); + } + + private void initUI(Dimension dim) { + this.setLayout(new BorderLayout(0, 0)); + this.setUndecorated(true); + JPanel main = new JPanel(new GridBagLayout()); + GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0); + main.setBackground(new Color(53, 53, 53)); + if (dim != null) { + this.setPreferredSize(dim); + } else { + this.setPreferredSize(new Dimension(200, 40)); + } + messageLabel = new JLabel(" "); + messageLabel.setForeground(Color.white); + progressBar = new JProgressBar(); + progressBar.setForeground(Color.black); + main.add(messageLabel, s); + s.gridy++; + s.insets = new Insets(0, 5, 2, 5); + if (showBar) { + main.add(progressBar, s); + } + this.add(BorderLayout.CENTER, main); + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + this.getRootPane().registerKeyboardAction(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); + MouseAdapter ma = new MouseAdapter() { + private Point pressPoint = new Point(); + + @Override + public void mousePressed(MouseEvent e) { + pressPoint = e.getPoint(); + } + + @Override + public void mouseReleased(MouseEvent e) { + pressPoint = new Point(); + } + + @Override + public void mouseDragged(MouseEvent e) { + Rectangle r = ProgressBar.this.getBounds(); + setLocation(r.x + (e.getX() - pressPoint.x), r.y + (e.getY() - pressPoint.y)); + } + }; + this.addMouseListener(ma); + this.addMouseMotionListener(ma); + } + + public void setText(String message) { + // System.out.println(message); + messageLabel.setText(message); + } + + public void setText(String txt, int percent) { + setText(txt); + if (percent > progressBar.getMaximum()) { + percent = progressBar.getMaximum(); + } + progressBar.setValue(percent); + } + + public void cancel() { + disposeDialog(); + } + + public void startProgress() { + showDialog(); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ld/plm/k_locale.properties b/src/cn/net/connor/ld/plm/k_locale.properties new file mode 100644 index 0000000..ac8931f --- /dev/null +++ b/src/cn/net/connor/ld/plm/k_locale.properties @@ -0,0 +1,58 @@ +# +#Thu Jan 21 10:28:16 CST 2021 +createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25 +project=Project +dsuidinpref.ERROR1=Error dataset uid set in preference\: %s +valuenotinlov.ERROR2=LOV "%s" does not contain value\: %s +writedata=Write Data +querynotexist.ERROR1=Query not exist\: %s +dialoginit.ERROR=Init Error +preferror.ERROR1=Preference error\: %s +norefindataset.ERROR1=Download file from dataset "%s" failed. No ref file. +cancel=Cancel +exeop.STATUS=Execute... +initop.STATUS=Checking Data... +noflowkey.ERROR=Missing key for flow number. +wordfield_pagecount.NAME=\u9875\u6570 +nopropintype.ERROR2=Property is not defined in type "%s"\: %s. +getflowno.ERROR1=Error getting new flow number for key\: %s +formsave.ERRORTITLE=Error Saving Data +wordfield_pageno.NAME=\u9875\u7801 +wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00 +wordfield_totalpagecount.NAME=\u603B\u9875\u6570 +exceltitlenorelateinfo.ERROR=Title row in sheet does not have any relation info. +selectProject=Select Project +proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E +excelnotitle.ERROR=Can't find title row in excel sheet. +loadCompFromUid.Error2=Error loading component "%s", UID \= "%s". +uploadfilewhencheckout.ERROR1=Dataset "%s" is checked out. Upload file failed. +wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00 +nodatainfile.ERROR1=No Data in File\: %s +noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA +notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C +error=Error +mergefile=Merge File... +index=Index +forminit.ERRORTITLE=Error Loading Rendering +ok=OK +wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570 +requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s +functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD +multiuserbyid.ERROR1=Find multiple users by id\: %s +preparedata=Prepare Data +dbconn.ERROR=Connect to database failed. +typenotfound.ERROR1=Type not found\: %s +filenotexist.ERROR1=File not exist\: %s +wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00 +readdata=Read Data +clearcache=Clear Cache +exportsuccess.INFO=Export Complete. +uploadfile=Upload File +propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s +foldernotexist.ERROR1=Folder not exist\: %s +info=Info +wordfield_totalpageno.NAME=\u603B\u9875\u7801 +multiuserbyname.ERROR1=Find multiple users by name\: %s +exportopenfile.INFO=Export complete. Open file? +prefnotconfiged.ERROR1=Prefernce not found\: %s +export=Export diff --git a/src/cn/net/connor/ld/plm/k_locale_zh_CN.properties b/src/cn/net/connor/ld/plm/k_locale_zh_CN.properties new file mode 100644 index 0000000..902d489 --- /dev/null +++ b/src/cn/net/connor/ld/plm/k_locale_zh_CN.properties @@ -0,0 +1,58 @@ +# +#Thu Jan 21 10:28:16 CST 2021 +createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25 +project=\u9879\u76EE +dsuidinpref.ERROR1=\u8BF7\u68C0\u67E5\u9996\u9009\u9879<%s>\uFF0C\u901A\u8FC7\u914D\u7F6EUID\u672A\u627E\u5230\u6570\u636E\u96C6 +valuenotinlov.ERROR2=LOV "%s" \u4E2D\u672A\u5B9A\u4E49\u6570\u503C\uFF1A%s +writedata=\u5199\u5165\u6570\u636E +querynotexist.ERROR1=\u67E5\u8BE2\u4E0D\u5B58\u5728\uFF1A%s +dialoginit.ERROR=\u521D\u59CB\u5316\u5F02\u5E38 +preferror.ERROR1=\u9996\u9009\u9879\u914D\u7F6E\u9519\u8BEF\uFF1A%s +norefindataset.ERROR1=\u4ECE\u6570\u636E\u96C6\u201C%s\u201D\u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25\uFF0C\u6CA1\u6709\u627E\u5230\u5F15\u7528\u6587\u4EF6\u3002 +cancel=\u53D6\u6D88 +exeop.STATUS=\u6B63\u5728\u6267\u884C... +initop.STATUS=\u68C0\u67E5\u6570\u636E... +noflowkey.ERROR=\u6D41\u6C34\u7801\u952E\u503C\u4E0D\u53EF\u4E3A\u7A7A +wordfield_pagecount.NAME=\u9875\u6570 +nopropintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u4E0D\u5B58\u5728\u5C5E\u6027\uFF1A%s +getflowno.ERROR1=\u83B7\u53D6\u6D41\u6C34\u7801\u5931\u8D25\uFF1A%s +formsave.ERRORTITLE=\u4FDD\u5B58\u6570\u636E\u51FA\u9519 +wordfield_pageno.NAME=\u9875\u7801 +wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00 +wordfield_totalpagecount.NAME=\u603B\u9875\u6570 +exceltitlenorelateinfo.ERROR=\u6807\u9898\u884C\u6CA1\u6709\u89E3\u6790\u5230\u6620\u5C04\u5185\u5BB9 +selectProject=\u9009\u62E9\u9879\u76EE +proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E +excelnotitle.ERROR=\u672A\u627E\u5230\u5DE5\u4F5C\u8868\u4E2D\u7684\u6807\u9898\u884C +loadCompFromUid.Error2=\u52A0\u8F7D\u5BF9\u8C61\u201C%s\u201D\u5931\u8D25\uFF0CUID\=\u201C%s\u201D\u3002 +uploadfilewhencheckout.ERROR1=\u6570\u636E\u96C6\u201C%s\u201D\u5DF2\u7B7E\u51FA\uFF0C\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25\u3002\u8BF7\u7B7E\u5165\u540E\u518D\u8FDB\u884C\u64CD\u4F5C\u3002 +wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00 +nodatainfile.ERROR1=\u6587\u4EF6\u4E2D\u6CA1\u6709\u6570\u636E\uFF1A%s +noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA +notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C +error=\u9519\u8BEF +mergefile=\u5408\u5E76\u6587\u4EF6 +index=\u5E8F\u53F7 +forminit.ERRORTITLE=\u521D\u59CB\u5316\u754C\u9762\u5F02\u5E38 +ok=\u786E\u5B9A +wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570 +requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s +functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD +multiuserbyid.ERROR1=\u901A\u8FC7id\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s +preparedata=\u51C6\u5907\u6570\u636E +dbconn.ERROR=\u8FDE\u63A5\u6570\u636E\u5E93\u5931\u8D25\u3002 +typenotfound.ERROR1=\u672A\u627E\u5230\u7C7B\u578B\uFF1A%s +filenotexist.ERROR1=\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A%s +wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00 +readdata=\u8BFB\u53D6\u6570\u636E +clearcache=\u6E05\u7406\u7F13\u5B58 +exportsuccess.INFO=\u5BFC\u51FA\u5B8C\u6210 +uploadfile=\u4E0A\u4F20\u6587\u4EF6 +propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s +foldernotexist.ERROR1=\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\uFF1A%s +info=\u63D0\u793A +wordfield_totalpageno.NAME=\u603B\u9875\u7801 +multiuserbyname.ERROR1=\u901A\u8FC7\u59D3\u540D\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s +exportopenfile.INFO=\u5BFC\u51FA\u5B8C\u6210\uFF0C\u6253\u5F00\u6587\u4EF6\uFF1F +prefnotconfiged.ERROR1=\u672A\u914D\u7F6E\u9996\u9009\u9879\uFF1A%s +export=\u5BFC\u51FA diff --git a/src/cn/net/connor/ld/plm/test.java b/src/cn/net/connor/ld/plm/test.java new file mode 100644 index 0000000..b3eacb6 --- /dev/null +++ b/src/cn/net/connor/ld/plm/test.java @@ -0,0 +1,15 @@ +package cn.net.connor.ld.plm; + +import java.text.SimpleDateFormat; + +public class test { + + public static void main(String[] args) { + // TODO Auto-generated method stub + String value = null; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + value = sdf.format(""); + System.out.println(value); + } + +} diff --git a/src/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer.java b/src/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer.java new file mode 100644 index 0000000..1faa1a6 --- /dev/null +++ b/src/com/net/connor/ld/plm/bean/CheckBoxTableHeaderRenderer.java @@ -0,0 +1,67 @@ +package com.net.connor.ld.plm.bean; + + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.BorderFactory; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +public class CheckBoxTableHeaderRenderer implements TableCellRenderer{ + + private JTableHeader tableHeader; + private JCheckBox selectBox; + //checkboxڵ + private int IND_BOOLEAN; + //ɫ + private static final Color BG=new Color(53,53,53); + + public CheckBoxTableHeaderRenderer(final JTable table,int IND_BOOLEAN1,JCheckBox check) { + this.tableHeader = table.getTableHeader(); + this.IND_BOOLEAN=IND_BOOLEAN1; + this.selectBox = check; + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // ѡ + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == IND_BOOLEAN) { + boolean value = !selectBox.isSelected(); + selectBox.setSelected(value); + for(int index = 0; index < table.getRowCount(); index ++){ + table.setValueAt(value, index, IND_BOOLEAN); + } + tableHeader.repaint(); + } + } + } + }); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + String valueStr = (String) value; + JLabel label = new JLabel(valueStr); + label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ + selectBox.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ + selectBox.setBorderPainted(true); + JComponent component = (column == IND_BOOLEAN) ? selectBox : label; + component.setOpaque(true); + component.setForeground(Color.WHITE); + component.setBackground(BG); + component.setFont(tableHeader.getFont()); + component.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.WHITE)); + component.setPreferredSize(new Dimension(component.getPreferredSize().width,25)); + return component; + } + +} \ No newline at end of file diff --git a/src/com/net/connor/ld/plm/bean/FormBean.java b/src/com/net/connor/ld/plm/bean/FormBean.java new file mode 100644 index 0000000..c07deda --- /dev/null +++ b/src/com/net/connor/ld/plm/bean/FormBean.java @@ -0,0 +1,143 @@ +package com.net.connor.ld.plm.bean; + +import java.util.ArrayList; + +public class FormBean implements Comparable{ + //public String[] header = {"","","","ǷҪ","","״̬","ע"}; + //{"ld6_SeqNum","ld6_ChangeTaskName" ,"ld6_Task","ld6_YNChange","ld6_ChangePerson","ld6_Changestate","ld6_ChangeRemarks"}; + /** + String[] propNames = new String[] { "ld6_SeqNum", "ld6_ChangeTaskName", "ld6_Task", "ld6_YNChange", + "ld6_ChangePerson", "ld6_taskRequireDesc", "ld6_handleperson", "ld6_Changestate", "ld6_RequireFinishTime", + "ld6_ActualFinishTime", "ld6_ChangeRemarks" }; + + String[] header = new String[] { "", "", "", "ǷҪ", + "", "Ҫ", "", "״̬", "Ҫʱ", + "ʵʱ", "ע" }; + */ + private String num; + private String changeTaskName; + private String task; + private String ynChange; + private String changePerson; + private String taskRequireDesc; + private String handlePerson; + private String changeState; + private String requireFinishTime; + private String actualFinishTime; + private String changeRemarks; + + + public FormBean(ArrayList arrayList) { + this.setNum(arrayList.get(0)); + this.setChangeTaskName(arrayList.get(1)); + this.setTask(arrayList.get(2)); + this.setYnChange(arrayList.get(3)); + this.setChangePerson(arrayList.get(4)); + this.setTaskRequireDesc(arrayList.get(5)); + this.setHandlePerson(arrayList.get(6)); + this.setChangeState(arrayList.get(7)); + this.setRequireFinishTime(arrayList.get(8)); + this.setActualFinishTime(arrayList.get(9)); + this.setChangeRemarks(arrayList.get(10)); + } + + + public String getTaskRequireDesc() { + return taskRequireDesc; + } + + + public void setTaskRequireDesc(String taskRequireDesc) { + this.taskRequireDesc = taskRequireDesc; + } + + + public String getHandlePerson() { + return handlePerson; + } + + + public void setHandlePerson(String handlePerson) { + this.handlePerson = handlePerson; + } + + + public String getRequireFinishTime() { + return requireFinishTime; + } + + + public void setRequireFinishTime(String requireFinishTime) { + this.requireFinishTime = requireFinishTime; + } + + + public String getActualFinishTime() { + return actualFinishTime; + } + + + public void setActualFinishTime(String actualFinishTime) { + this.actualFinishTime = actualFinishTime; + } + + + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } + public String getChangeTaskName() { + return changeTaskName; + } + public void setChangeTaskName(String changeTaskName) { + this.changeTaskName = changeTaskName; + } + public String getTask() { + return task; + } + public void setTask(String task) { + this.task = task; + } + public String getYnChange() { + return ynChange; + } + public void setYnChange(String ynChange) { + this.ynChange = ynChange; + } + public String getChangePerson() { + return changePerson; + } + public void setChangePerson(String changePerson) { + this.changePerson = changePerson; + } + public String getChangeState() { + return changeState; + } + public void setChangeState(String changeState) { + this.changeState = changeState; + } + public String getChangeRemarks() { + return changeRemarks; + } + public void setChangeRemarks(String changeRemarks) { + this.changeRemarks = changeRemarks; + } + @Override + public int compareTo(FormBean o) { + long i = this.getNum().compareTo(o.getNum()); + + if(i > 0){ + return 1; + } + else if(i == 0){ + return 0; + } + else{ + return -1; + } + } + + +} diff --git a/src/com/net/connor/ld/plm/bean/ManageStoredData.java b/src/com/net/connor/ld/plm/bean/ManageStoredData.java new file mode 100644 index 0000000..c433b75 --- /dev/null +++ b/src/com/net/connor/ld/plm/bean/ManageStoredData.java @@ -0,0 +1,257 @@ +package com.net.connor.ld.plm.bean; + +import java.awt.BorderLayout; + +import java.awt.Color; + +import java.awt.Component; + +import java.awt.event.ActionEvent; + +import java.awt.event.ActionListener; + +import java.util.Vector; + +import javax.swing.*; + +import javax.swing.table.DefaultTableModel; + +import javax.swing.table.TableCellRenderer; + +import com.teamcenter.rac.util.DateButton; + + +public class ManageStoredData extends JPanel { + + private DefaultTableModel tableModel; + + private JTable table; + + private final int columnWithoutButton = 5; + + public ManageStoredData() { + + setLayout(null); + + this.setBackground(Color.pink); + + final JScrollPane scrollPane = new JScrollPane(); + + scrollPane.setAutoscrolls(true); + + tableModel = new DefaultTableModel() { + +// ܷ༭ + + public boolean isCellEditable(int row, int column) { + + if (column == 4 || column == 5) + + return true; + + return false; + + } + + }; + + String headName[] = { "", "ļ", "ļС", "޸", + + "", "ɾ" }; + + tableModel.setColumnIdentifiers(headName); + + table = new JTable(tableModel); + + table.getColumn("").setCellRenderer(new ButtonRenderer()); + + table.getColumn("").setCellEditor(new ButtonEditor(new JCheckBox())); + + table.getColumn("ɾ").setCellRenderer(new ButtonRenderer()); + + table.getColumn("ɾ").setCellEditor(new ButtonEditor(new JCheckBox())); + +// бⲻƶ + +// table.getTableHeader().setReorderingAllowed(false); + + table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + scrollPane.setViewportView(table); + +// п,ҵPanelʱпҲӦı仯 + + table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); //пԶ̶ + + table.getColumnModel().getColumn(0).setPreferredWidth(30); + + table.getColumnModel().getColumn(1).setPreferredWidth(120); + + table.getColumnModel().getColumn(2).setPreferredWidth(80); + + table.getColumnModel().getColumn(3).setPreferredWidth(80); + + table.getColumnModel().getColumn(4).setPreferredWidth(70); + + table.getColumnModel().getColumn(5).setPreferredWidth(70); + +// и + + table.setRowHeight(25); + + scrollPane.setBounds(80, 20, 500, 125); + + this.add(scrollPane); + + setVisible(true); + + InitValue(); + + } + + private void InitValue() { + + for (int i = 0; i < 5; i++) { + + Vector vector = new Vector(); + + vector.addElement("1"); + + vector.addElement("Open Close Msg"); + + vector.addElement("do"); + + vector.addElement("2"); + + vector.addElement(""); + + vector.addElement("ɾ"); + + tableModel.getDataVector().add(vector); + + } + + } + + public class ButtonRenderer extends JButton implements TableCellRenderer { + + public ButtonRenderer() { + + setOpaque(true); + + } + + public Component getTableCellRendererComponent(JTable table, + + Object value, boolean isSelected, boolean hasFocus, int row, + + int column) { + + if (isSelected) { + + setForeground(table.getSelectionForeground()); + + setBackground(table.getSelectionBackground()); + + } else { + + setForeground(table.getForeground()); + + setBackground(UIManager.getColor("Button.background")); + + } + + setText((value == null) ? "" : value.toString()); + + return this; + + } + + } + + public class ButtonEditor extends DefaultCellEditor { + + protected JButton button; + + public ButtonEditor(JCheckBox checkBox) { + + super(checkBox); + + button = new JButton(); + + button.setOpaque(true); + + button.addActionListener(new ActionListener() { + + @Override + + public void actionPerformed(ActionEvent arg0) { + + ButtonClick(); + + } + + }); + + } + + @Override + + public Component getTableCellEditorComponent(JTable table1, + + Object value, boolean isSelected, int row, int column) { + + if (isSelected) { + + System.out.println("change column"); + + button.setForeground(table.getSelectionForeground()); + + button.setBackground(table.getSelectionBackground()); + + } else { + + System.out.println("change row"); + + button.setForeground(table.getForeground()); + + button.setBackground(table.getBackground()); + + } + + button.setText(table1.getValueAt(row, column).toString()); + + return button; + + } + +//ȱٴ˷ť󽫻ȡButtonTextֵʾfalse. + + @Override + + public Object getCellEditorValue() { + + return button.getText(); + + } + + protected void ButtonClick() { + +// TODO Auto-generated method stub + + System.out.println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); + + System.out.println(table.getSelectedColumn() + " and " + table.getSelectedRow()); + } + } + public static void main(String[] args) { + JFrame frame = new JFrame(); + frame.setSize(555,666); + ManageStoredData manageStoredData = new ManageStoredData(); + frame.add(manageStoredData); + frame.show(); + + } +} diff --git a/src/com/net/connor/ld/plm/bean/MyButtonEditor.java b/src/com/net/connor/ld/plm/bean/MyButtonEditor.java new file mode 100644 index 0000000..dd9a2b5 --- /dev/null +++ b/src/com/net/connor/ld/plm/bean/MyButtonEditor.java @@ -0,0 +1,113 @@ +package com.net.connor.ld.plm.bean; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.JTextField; + +import org.apache.bcel.generic.NEW; + +import com.teamcenter.rac.kernel.TCComponent; + +public class MyButtonEditor extends DefaultCellEditor { + + /** + * serialVersionUID + */ + private static final long serialVersionUID = -6546334664166791132L; + + private JPanel panel; + + private JButton button; + + private boolean okToModify; + private JTable table; + + private List unableList; + private HashMap tableRowRefList; + + public MyButtonEditor(JTable table) + { + // DefautlCellEditorд˹Ҫһʹõֱnewһɡ + super(new JTextField()); + // õμ༭ + this.setClickCountToStart(1); + + this.button = new JButton("/ѡ"); + this.table = table; + this.okToModify = okToModify; + this.unableList = unableList; + this.tableRowRefList = tableRowRefList; + + this.initButton(); + + this.initPanel(); + + // Ӱť + this.panel.add(this.button); + } + + private void initButton() + { + //this.button = new JButton(); + + // ðťĴСλá + this.button.setBounds(0, 0, 50, 15); + + // Ϊť¼ֻActionListner¼Mouse¼Ч + this.button.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + // ȡ༭¼tableModelsetValue + MyButtonEditor.this.fireEditingCanceled(); + SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + button.setText(dateFormat.format(new Date())); + + // + // Խtable룬ͨgetSelectedRow,getSelectColumnȡǰѡкмȡ + + } + }); + + } + private void initPanel() + { + this.panel = new JPanel(); + // panelʹþԶλbuttonͲԪ + this.panel.setLayout(null); + } + /** + * дı༭һJPanel󼴿ɣҲֱӷһButton󣬵Ԫ + */ + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) + { + // ֻΪťֵɡҲ + //this.button.setText(value == null ? "" : String.valueOf(value)); + if(unableList != null && unableList.contains(Integer.valueOf(row))){ + okToModify = false; + } + return this.button; + } + + /** + * д༭ԪʱȡֵдܻΪťôֵ + */ + @Override + public Object getCellEditorValue() + { + return this.button.getText(); + } +} diff --git a/src/com/net/connor/ld/plm/bean/MyButtonEditor222.java b/src/com/net/connor/ld/plm/bean/MyButtonEditor222.java new file mode 100644 index 0000000..eb02d87 --- /dev/null +++ b/src/com/net/connor/ld/plm/bean/MyButtonEditor222.java @@ -0,0 +1,53 @@ +package com.net.connor.ld.plm.bean; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; + +import javax.swing.DefaultCellEditor; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextField; + +import com.teamcenter.rac.util.DateButton; + + + +public class MyButtonEditor222 extends DefaultCellEditor{ + + private DateButton button; + private String label; + + public MyButtonEditor222() { + super(new JTextField()); + SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + button = new DateButton(dateFormat); + + } + + /* + д༭һťJTable + */ + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + button.setForeground(table.getSelectionForeground()); + + button.setBackground(table.getSelectionBackground()); + System.out.println(); + label = (value == null) ? "" : value.toString(); + System.out.println("=====" + label); + button.setText(label); + return button; + } + + @Override + public Object getCellEditorValue() { + return new String(label); + } + + + +} \ No newline at end of file diff --git a/src/com/net/connor/ld/plm/bean/MyButtonRender.java b/src/com/net/connor/ld/plm/bean/MyButtonRender.java new file mode 100644 index 0000000..ad3a5df --- /dev/null +++ b/src/com/net/connor/ld/plm/bean/MyButtonRender.java @@ -0,0 +1,91 @@ +package com.net.connor.ld.plm.bean; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Insets; +import java.text.SimpleDateFormat; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.border.Border; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; + +import com.teamcenter.rac.util.DateButton; + +public class MyButtonRender implements TableCellRenderer { + + private JPanel panel; + + //private JButton button; + + private JButton button; + + public static final DefaultTableCellRenderer DEFAULT_RENDERER + + = new DefaultTableCellRenderer(); + + public MyButtonRender(String value) { + //this.button = new JButton("/ѡ"); + SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + //this.button = new DateButton(dateFormat); + button = new JButton(); + if(!value.isEmpty()) { + this.button.setText(value); + } + this.initButton(); + this.initPanel(); + // Ӱť + this.panel.add(this.button); + } + + private void initButton() { + // this.button = new JButton(); + // ðťĴСλá + this.button.setBounds(0, 0, 50, 15); + + // ȾӰť¼Dzᴥ + // this.button.addActionListener(new ActionListener() + // { + // + // public void actionPerformed(ActionEvent e) + // { + // // TODO Auto-generated method stub + // } + // }); + + } + + private void initPanel() { + this.panel = new JPanel(); + // panelʹþԶλbuttonͲԪ + this.panel.setLayout(null); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { +// // ֻΪťֵɡҲ汳ȡ +// // this.button.setText(value == null ? "" : String.valueOf(value)); +// if (table.getValueAt(row, 1) != null && !table.getValueAt(row, 1).equals("")) { +// this.button.setContentAreaFilled(false); +// table.getComponentAt(row, column).setBackground(Color.GREEN); +//// DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column) +//// .setBackground(Color.GREEN); +// }else{ +// this.button.setContentAreaFilled(true); +// } + this.button.setForeground(table.getSelectionForeground()); + + this.button.setBackground(table.getSelectionBackground()); + + this.button.setText((value == null) ? "" : value.toString()); + return this.button; + } + +} diff --git a/src/com/net/connor/ld/plm/form/CLForm.java b/src/com/net/connor/ld/plm/form/CLForm.java new file mode 100644 index 0000000..8d99c90 --- /dev/null +++ b/src/com/net/connor/ld/plm/form/CLForm.java @@ -0,0 +1,5 @@ +package com.net.connor.ld.plm.form; + +public class CLForm { + +} diff --git a/src/com/net/connor/ld/plm/form/CNForm.java b/src/com/net/connor/ld/plm/form/CNForm.java new file mode 100644 index 0000000..c17db53 --- /dev/null +++ b/src/com/net/connor/ld/plm/form/CNForm.java @@ -0,0 +1,214 @@ +package com.net.connor.ld.plm.form; +import java.awt.BorderLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.soa.client.model.LovValue; +import k.util.KOrgDialog; + + +@SuppressWarnings("serial") +public class CNForm extends AbstractRendering{ + + public String[] header = {"","","","ǷҪ","","״̬","ע"}; + DefaultTableModel tableModel = null; + private TCComponent form; + String[] propNames = new String[] {"ld6_YNChange","ld6_ChangePerson","ld6_Changestate","ld6_ChangeRemarks"}; + static String ynChangeLovName = "LD6_TecDoc_Type_TLOV"; + static String changeStateLovName = "LD6_TecDoc_Type_TLOV"; + + + public CNForm(TCComponent form) throws Exception { + this.form = form; + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + try { + loadUI(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + private void loadUI() throws FileNotFoundException, IOException, TCException { + this.setLayout(new BorderLayout()); + tableModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0 ||column == 1) { + return false; + } + return true; + } + }; + tableModel.setDataVector(null, header); + JTable table_data = new JTable(tableModel); + table_data.setRowHeight(30); + JComboBox ynChangeComboBox = new JComboBox(); + JComboBox changeStateComboBox = new JComboBox(); + HashMap ynChangeMap = new LinkedHashMap(); + HashMap changeStateMap = new LinkedHashMap(); + getLov(ynChangeMap,ynChangeLovName,ynChangeComboBox); + getLov(changeStateMap,changeStateLovName,changeStateComboBox); + table_data.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(ynChangeComboBox)); + table_data.getColumnModel().getColumn(5).setCellEditor(new DefaultCellEditor(changeStateComboBox)); + LinkedHashMap map = new LinkedHashMap(); + map.put("1", "one"); + map.put("2", "two"); + map.put("3", "three"); + map.put("4", "four"); + map.put("5", "five"); + String[][] values = new String[map.size()][7]; + int index = 0; + //õԭֵ + ArrayList> formList = new ArrayList>(); + getFormValue(formList); + for (int i = 0; i < map.size(); i++) { + for (int j = 0; j < 7; j++) { + switch (j) { + case 0: + values[i][j] = String.valueOf(index); + break; + case 1: + values[i][j] = map.get(String.valueOf(i + 1)); + break; + case 2: + values[i][j] = map.get(String.valueOf(i + 1)); + break; + case 3: + case 4: + case 5: + case 6: + if(i < formList.size()) { + values[i][j] = formList.get(i).get(j - 3); + } + else { + values[i][j] = ""; + } + break; + default: + values[i][j] = ""; + break; + } + } + index++; + tableModel.addRow(values[i]); + } + table_data.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) {// 굥ʱӦ + // õѡееֵ + int r = table_data.getSelectedRow(); + int c = table_data.getSelectedColumn(); + if(c == 4) { + String userString = new KOrgDialog("").getUserString(); + table_data.setValueAt(userString, r, c); + } + } + }); + JScrollPane scroll = new JScrollPane(table_data); + this.add(scroll,BorderLayout.CENTER); + } + + @Override + public void saveRendering() { + try { + List component = new ArrayList(); + DataManagementService service = DataManagementService + .getService((TCSession) AIFUtility.getCurrentApplication().getSession()); + CreateIn[] newIn = new CreateIn[tableModel.getRowCount()]; + for (int i = 0; i < tableModel.getRowCount(); i++) { + CreateIn in = new CreateIn(); + Map propMap = new HashMap(); + for (int j = 0; j < propNames.length; j++) { + propMap.put(propNames[j], + tableModel.getValueAt(i, j + 3) == null ? "" : tableModel.getValueAt(i, j + 3).toString()); + } + in.data.boName = "LD6_TableRow"; + in.data.stringProps = propMap; + newIn[i] = in; + } + try { + CreateResponse response = service.createObjects(newIn); + System.out.println(response.serviceData.sizeOfCreatedObjects()); + if (response.serviceData.sizeOfCreatedObjects() > 0) { + System.out.println("CreateResponse"); + int length = response.serviceData.sizeOfCreatedObjects(); + for (int i = 0; i < length; i++) { + component.add(response.output[i].objects[0]); + } + + } + } catch (Exception e) { + e.printStackTrace(); + } + + form.getTCProperty("ld6_ChangeTable").setReferenceValueArray(component.toArray(new TCComponent[component.size()])); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * õlovʵֵʾֵ + * @param map + * @param comboBox + * @throws TCException + */ + private void getLov(HashMap map,String lovName, JComboBox comboBox) throws TCException { + comboBox.addItem(""); + AbstractAIFApplication application = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) application.getSession(); + TCComponentListOfValuesType lovType; + lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + System.out.println("lov="+lov.length); + ListOfValuesInfo lovInfo = lov[0].getListOfValues(); + List lovValueList = lovInfo.getValues(); + for (LovValue lovV : lovValueList) { + map.put(lovV.getDisplayValue(), lovV.getStringValue()); + comboBox.addItem(lovV.getDisplayValue()); + System.out.println(lovV.getDisplayValue() + "===" + lovV.getStringValue()); + } + } + + private void getFormValue(ArrayList> formList) throws TCException { + TCComponent[] ref; + ref = form.getTCProperty("ld6_ChangeTable").getReferenceValueArray(); + for (int j = 0; j < ref.length; j++) { + ArrayList list = new ArrayList(); + for (int i = 0; i < propNames.length; i++) { + list.add(ref[j].getStringProperty(propNames[i])); + } + formList.add(list); + } + + } +} diff --git a/src/com/net/connor/ld/plm/form/EplanBOMLineForm.java b/src/com/net/connor/ld/plm/form/EplanBOMLineForm.java new file mode 100644 index 0000000..abcf46e --- /dev/null +++ b/src/com/net/connor/ld/plm/form/EplanBOMLineForm.java @@ -0,0 +1,136 @@ +//package com.connor.sfae.forms; +// +//import java.awt.BorderLayout; +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JTable; +//import javax.swing.table.DefaultTableModel; +// +//import com.connor.sfae.beans.Dianqi; +//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.stylesheet.AbstractRendering; +//import com.teamcenter.services.rac.core.DataManagementService; +//import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +//import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +// +//public class EplanBOMLineForm extends AbstractRendering { +// +// TCComponent form; +// Map comps; +// DefaultTableModel model; +// public List dianqi = new ArrayList(); +// String[] propNames = new String[] { "sf6_InstallationLocation", "sf6_Deviceidentifier", "sf6_ItemID", +// "sf6_ObjectName", "sf6_ItemRevisionID", "sf6_OrderNumber", "sf6_ProductGroup", "sf6_PurchasedQuantity", +// "sf6_unit", "sf6_manufacturer", "sf6_PurDivisionOfLabor", "sf6_PurOrderAndVersion" }; +// +// String[] row0 = new String[] { "", "ṹʶ", "豸ʶ", "ItemID", "object_name", "ItemRevisionID", "Order number", +// "ProductGroup", "Ѳɹ", "λ", "", "ɹֹ", "ɹ汾" }; +// +// public EplanBOMLineForm() throws Exception { +// +// } +// +// public EplanBOMLineForm(TCComponent form) throws Exception { +// this.form = form; +// loadRendering(); +// } +// +// public void addData(List dq) throws Exception { +// this.dianqi = dq; +// int index = 0; +// // if (model == null) { +// model = new DefaultTableModel(row0, 0); +// // } +// for (int i = 0; i < dianqi.size(); i++) { +// String[] temp = new String[row0.length]; +// temp[0] = Integer.toString(index++); +// String[] props = { dianqi.get(i).getJieGou(), dianqi.get(i).getSf6_devicetag_withseparator(), +// dianqi.get(i).getItemID(), dianqi.get(i).getObject_name(), dianqi.get(i).getItem_revision_id(), +// dianqi.get(i).getSf6_OrderNo(), dianqi.get(i).getSf6_ProductGroup(), +// String.valueOf(dianqi.get(i).getYiGou()), dianqi.get(i).getBl_uom(), +// dianqi.get(i).getSf6_Manufacturer(), dianqi.get(i).getCaiGou(), dianqi.get(i).getCaiGouId() }; +// for (int j = 0; j < props.length; j++) { +// temp[j + 1] = props[j]; +// } +// System.out.println("ѹ" + dianqi.get(i).getYiGou()); +// if (dianqi.get(i).getYiGou() == 0) +// break; +// model.addRow(temp); +// System.out.println(model.getValueAt(i, 4)); +// } +// saveRendering(); +// System.out.println("modelij" + model.getRowCount()); +// +// } +// +// @Override +// public void loadRendering() throws TCException { +// JTable table = new JTable(model); +//// if (model.getRowCount() > 0) { +//// for (int i = 0; i < 13; i++) { +//// table.getColumn(table.getColumnName(i)).setMinWidth(60); +//// } +//// } +// JPanel panel = new JPanel(); +// JScrollPane pane = new JScrollPane(table); +// panel.add(pane, BorderLayout.CENTER); +// setLayout(new BorderLayout()); +// add(pane, BorderLayout.CENTER); +// } +// +// @Override +// public void saveRendering() { +// try { +// List c = new ArrayList(); +// +// TCComponent[] com = form.getTCProperty("sf6_EplanBOMLineTable").getReferenceValueArray(); +// for (int j = 0; j < com.length; j++) { +// c.add(com[j]); +// } +// System.out.println("cij" + c.size()); +// DataManagementService service = DataManagementService +// .getService((TCSession) AIFUtility.getCurrentApplication().getSession()); +// CreateIn[] newIn = new CreateIn[model.getRowCount()]; +// for (int i = 0; i < model.getRowCount(); i++) { +// CreateIn in = new CreateIn(); +// Map propMap = new HashMap(); +// for (int j = 0; j < propNames.length; j++) { +// propMap.put(propNames[j], +// model.getValueAt(i, j + 1) == null ? "" : model.getValueAt(i, j + 1).toString()); +// } +// // System.out.println("prop:" + propMap); +// in.data.boName = "SF6_EplanTableRow"; +// in.data.stringProps = propMap; +// newIn[i] = in; +// } +// try { +// CreateResponse response = service.createObjects(newIn); +// System.out.println(response.serviceData.sizeOfCreatedObjects()); +// if (response.serviceData.sizeOfCreatedObjects() > 0) { +// System.out.println("CreateResponse"); +// int length = response.serviceData.sizeOfCreatedObjects(); +// for (int i = 0; i < length; i++) { +// c.add(response.output[i].objects[0]); +// } +// +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// form.getTCProperty("sf6_EplanBOMLineTable").setReferenceValueArray(c.toArray(new TCComponent[c.size()])); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +//} diff --git a/src/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm.java b/src/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm.java new file mode 100644 index 0000000..e4eaf4b --- /dev/null +++ b/src/com/net/connor/ld/plm/form/HG8_ImpactObjetRevisionForm.java @@ -0,0 +1,148 @@ +package com.net.connor.ld.plm.form; + +import java.awt.BorderLayout; + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; + +public class HG8_ImpactObjetRevisionForm extends AbstractRendering { + + TCComponent tempRev=null; + String[] hg8_TempDMNSource1=null; + String[] hg8_MateCode1=null; + String[] hg8_DrawNo1=null; + String[] hg8_ObjName1=null; + String[] hg8_Objrevision1=null; + String[] hg8_MateCode2=null; + String[] hg8_DrawNo2=null; + String[] hg8_ObjName2=null; + String[] hg8_Objrevision2=null; + String[] hg8_Objonower2=null; + String[] hg8_FindPath=null; + String[] hg8_ProjLeader=null; + String[] hg8_IsChange=null; + String[] hg8_TempDMNSource2=null; + DefaultTableModel tableModel=null; + public String[] HEADER; + + public HG8_ImpactObjetRevisionForm(TCComponent arg0) throws Exception { + super(arg0); + tempRev = arg0.getReferenceProperty("item_revision"); + System.out.println(tempRev.getProperty("item_id")); + HEADER = new String[] { "򣩸ĵ", "","ͼ","", "ǰ汾", "Ӱ", "Ӱͼ", "Ӱ", "Ӱ汾", "Ӱ", "·", "Ŀ","Ƿͬ޸","ĵ" }; + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + hg8_TempDMNSource1 = tempRev.getTCProperty("hg8_TempDMNSource1").getStringArrayValue(); + hg8_MateCode1 = tempRev.getTCProperty("hg8_MateCode1").getStringArrayValue(); + hg8_DrawNo1 = tempRev.getTCProperty("hg8_DrawNo1").getStringArrayValue(); + hg8_ObjName1 = tempRev.getTCProperty("hg8_ObjName1").getStringArrayValue(); + hg8_Objrevision1 = tempRev.getTCProperty("hg8_Objrevision1").getStringArrayValue(); + hg8_MateCode2 = tempRev.getTCProperty("hg8_MateCode2").getStringArrayValue(); + hg8_DrawNo2 = tempRev.getTCProperty("hg8_DrawNo2").getStringArrayValue(); + hg8_ObjName2 = tempRev.getTCProperty("hg8_ObjName2").getStringArrayValue(); + hg8_Objrevision2 = tempRev.getTCProperty("hg8_Objrevision2").getStringArrayValue(); + hg8_Objonower2 = tempRev.getTCProperty("hg8_Objonower2").getStringArrayValue(); + hg8_FindPath = tempRev.getTCProperty("hg8_FindPath").getStringArrayValue(); + hg8_ProjLeader = tempRev.getTCProperty("hg8_ProjLeader").getStringArrayValue(); + hg8_IsChange = tempRev.getTCProperty("hg8_IsChange").getStringArrayValue(); + hg8_TempDMNSource2 = tempRev.getTCProperty("hg8_TempDMNSource2").getStringArrayValue(); + initPanel(); + } + + private void initPanel() { + setLayout(new BorderLayout()); + tableModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 12 ||column == 13) { + return true; + } + return false; + } + }; + tableModel.setDataVector(null, HEADER); + JTable table_data = new JTable(tableModel); + table_data.setRowHeight(30); + JComboBox comboBox = new JComboBox(); + comboBox.addItem(""); + comboBox.addItem(""); + table_data.getColumnModel().getColumn(12).setCellEditor(new DefaultCellEditor(comboBox)); + if(hg8_TempDMNSource1!=null && hg8_TempDMNSource1.length>0) { + String[] values = new String[14]; + for(int i=0;iindex) { + return array[index]; + }else { + return ""; + } + } + + @Override + public void saveRendering() { + try { +// tempRev.getTCProperty("hg8_TempDMNSource1").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_MateCode1").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_DrawNo1").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_ObjName1").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_Objrevision1").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_MateCode2").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_DrawNo2").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_ObjName2").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_Objrevision2").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_Objonower2").setStringValueArray( strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_FindPath").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); +// tempRev.getTCProperty("hg8_ProjLeader").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 0)); + tempRev.getTCProperty("hg8_IsChange").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 12)); + tempRev.getTCProperty("hg8_TempDMNSource2").setStringValueArray(strToArray(tableModel, 0, tableModel.getRowCount(), 13)); + } catch (TCException e) { + e.printStackTrace(); + } + + } + + // Գ + private String[] strToArray(DefaultTableModel model, int startRow, int endRow, int col) { + String[] str = new String[endRow - startRow]; + for (int i = 0; i < endRow - startRow; i++) { + str[i] = getCellValue(model, startRow + i, col); + } + return str; + } + + // õеֵ + private String getCellValue(DefaultTableModel model, int row, int col) { + return model.getValueAt(row, col) == null ? "" : model.getValueAt(row, col).toString(); + } +} diff --git a/src/com/net/connor/ld/plm/form/TestForm.java b/src/com/net/connor/ld/plm/form/TestForm.java new file mode 100644 index 0000000..74e61f4 --- /dev/null +++ b/src/com/net/connor/ld/plm/form/TestForm.java @@ -0,0 +1,47 @@ +package com.net.connor.ld.plm.form; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; + +import k.KFormStyle; +import k.util.KOrgDialog; +import k.util.KUtil; + +@SuppressWarnings("serial") +public class TestForm extends AbstractRendering{ + + public TestForm(TCComponent arg0) throws Exception { + super(arg0); + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + System.out.println("niuma"); + + } + + @Override + public void saveRendering() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/net/connor/ld/plm/ld01/OpenFloderCommand.java b/src/com/net/connor/ld/plm/ld01/OpenFloderCommand.java new file mode 100644 index 0000000..b564669 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld01/OpenFloderCommand.java @@ -0,0 +1,34 @@ +package com.net.connor.ld.plm.ld01; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import cn.net.connor.ld.plm.KCommand; +import cn.net.connor.ld.plm.KUtil; + +public class OpenFloderCommand extends KCommand { + + public OpenFloderCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + TCSession session = (TCSession) app.getSession(); + String preName = "Connor_ProjectManagerFolder"; + try { + String prefVal = KUtil.getPrefVal(session, preName); + if (prefVal == null) { + MessageBox.post("ѡ " + preName + " ڻֵΪ", "ʾ ", MessageBox.INFORMATION); + return; + } + com.teamcenter.rac.common.Activator.getDefault() + .openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective"); + com.teamcenter.rac.common.Activator.getDefault().openComponents( + "com.teamcenter.rac.ui.perspectives.navigatorPerspective", + new InterfaceAIFComponent[] { session.stringToComponent(prefVal) }); + + } catch (Exception e) { + MessageBox.post(e.toString(), "쳣", MessageBox.ERROR); + e.printStackTrace(); + } + } + +} diff --git a/src/com/net/connor/ld/plm/ld01/Test.java b/src/com/net/connor/ld/plm/ld01/Test.java new file mode 100644 index 0000000..c2fbbe1 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld01/Test.java @@ -0,0 +1,100 @@ +package com.net.connor.ld.plm.ld01; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.soa.exceptions.NotLoadedException; + +import cn.net.connor.ld.plm.KUtil; + +public class Test extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + TCComponentItem child = (TCComponentItem) targetComponent; + try { + System.out.println(child.getStringProperty("object_type")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// TCComponentBOMWindowType bomWindowType; +// try { +// bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); +// TCComponentBOMWindow bomWindow = bomWindowType.create(null); +// for (int i = 0; i < 2; i++) { +// TCComponent[] search; +// if(i == 0) { +// search = session.search(" ID", new String[] {" ID"}, new String[] {"000588"}); +// } +// else { +// search = session.search(" ID", new String[] {" ID"}, new String[] {"000589"}); +// } +// TCComponentItem item = (TCComponentItem) search[0]; +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, item.getLatestItemRevision(), null,null); +// topline.add(child, child.getLatestItemRevision(), null, false, ""); +// bomWindow.save(); +// } +// bomWindow.close(); +// } catch (Exception e) { +// e.printStackTrace(); +// } + +// try { +// System.out.println(); +// TCProperty table = com.getTCProperty("ld6_table"); +// TCComponent[] valueArray = table.getReferenceValueArray(); +// for (TCComponent tableValue : valueArray) { +// System.out.println(tableValue.getPropertyDisplayableValue("ld6_customerPartNum")); +// System.out.println(tableValue.getPropertyDisplayableValue("ld6_customerPartVer")); +// System.out.println(tableValue.getPropertyDisplayableValue("ld6_customerDrawNum")); +// System.out.println(tableValue.getPropertyDisplayableValue("ld6_customerDrawVer")); +// System.out.println(tableValue.getPropertyDisplayableValue("ld6_customerPartName")); +// System.out.println(tableValue.getPropertyDisplayableValue("ld6_type")); +// } +// System.out.println(); +// } catch (TCException | NotLoadedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + +// try { +// folderType = (TCComponentFolderType) session.getTypeComponent("LD6_CusProdFolder"); +// TCComponentFolder folder = folderType.create("", "", "LD6_CusProdFolder"); +// TCComponentFolder folder = KUtil.createFolderBySOA(folderType.getTypeName(), ""); +// ((TCComponent) targetComponent).add("contents", folder); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + return null; + } + +} diff --git a/src/com/net/connor/ld/plm/ld02/CreateProjectStructCommand.java b/src/com/net/connor/ld/plm/ld02/CreateProjectStructCommand.java new file mode 100644 index 0000000..7b0e303 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld02/CreateProjectStructCommand.java @@ -0,0 +1,25 @@ +package com.net.connor.ld.plm.ld02; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ld.plm.KCommand; + +public class CreateProjectStructCommand extends KCommand{ + + public CreateProjectStructCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + InterfaceAIFComponent folder = app.getTargetComponent(); + if(folder instanceof TCComponentFolder) { + this.setRunnable(new CreateProjectStructDialog(app)); + } + else { + MessageBox.post("ѡһͻļУ", "ʾ ", MessageBox.INFORMATION); + } + + } + +} diff --git a/src/com/net/connor/ld/plm/ld02/CreateProjectStructDialog.java b/src/com/net/connor/ld/plm/ld02/CreateProjectStructDialog.java new file mode 100644 index 0000000..a149b4f --- /dev/null +++ b/src/com/net/connor/ld/plm/ld02/CreateProjectStructDialog.java @@ -0,0 +1,370 @@ +package com.net.connor.ld.plm.ld02; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.UIManager; +import javax.swing.tree.DefaultTreeModel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ld.JCheckBoxTree.CheckBoxTreeCellRenderer; +import cn.net.connor.ld.JCheckBoxTree.CheckBoxTreeNode; +import cn.net.connor.ld.JCheckBoxTree.CheckBoxTreeNodeSelectionListener; +import cn.net.connor.ld.plm.KUtil; + + +@SuppressWarnings("serial") +public class CreateProjectStructDialog extends AbstractAIFDialog{ + private static ArrayList dateConnList = new ArrayList(); + protected TCSession session; + private TCComponent target; + private JLabel modelLabel; + private JComboBox modelBox; + private JTextField nameField; + private JLabel nameLabel; + private JTree jtree; + private JButton okButton; + private JButton celButton; + private HashMap preMap = new HashMap(); + + public static final String preName = "Connor_FolderTemp"; + + public CreateProjectStructDialog(AbstractAIFApplication app) { + super(false); + this.session = (TCSession) app.getSession(); + this.target = (TCComponent) app.getTargetComponent(); + } + + @Override + public void run() { + try { + initUI(); + //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void initUI() throws Exception { + this.setTitle("ģ崴ļ"); + Dimension dim = new Dimension(950, 600); + this.setPreferredSize(new Dimension(1000, 600)); + this.setMinimumSize(dim); + this.setLayout(new BorderLayout()); + modelLabel = new JLabel("ģ壺"); + modelBox = new JComboBox(); + modelBox.setPreferredSize(new Dimension(200,30)); + String[] prefVals = KUtil.getPrefVals(session, preName); + if(prefVals == null) { + MessageBox.post("ѡ " + preName + " ڻֵΪ", "ʾ ", MessageBox.INFORMATION); + return; + } + else { + for(String prefVal : prefVals) { + if(prefVal.contains("=")) { + String[] split = prefVal.split("="); + modelBox.addItem(split[0]); + preMap.put(split[0], split[1]); + } + } + } + nameLabel = new JLabel("Ʒͼţ"); + nameField = new JTextField(); + nameField.setPreferredSize(new Dimension(200,30)); + JPanel topPanel = new JPanel(); + topPanel.add(modelLabel); + topPanel.add(modelBox); + topPanel.add(nameLabel); + topPanel.add(nameField); + + //String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"; + //String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; + String lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel"; + UIManager.setLookAndFeel(lookAndFeel); + + jtree = new JTree(); + initTree(jtree); + JScrollPane centerPane = new JScrollPane(jtree); + + JPanel buttonPanel = new JPanel(); + okButton = new JButton(""); + celButton = new JButton("ȡ"); + buttonPanel.add(okButton); + buttonPanel.add(celButton); + + this.add(BorderLayout.NORTH,topPanel); + this.add(BorderLayout.CENTER,centerPane); + this.add(BorderLayout.SOUTH,buttonPanel); + + addListeners(); + showDialog(); + } + + /** + * + * @param tree + */ + private void initTree(JTree tree){ + String puid = preMap.get(modelBox.getSelectedItem()); + TCComponent component; + try { + component = session.stringToComponent(puid); + if(component == null || !(component instanceof TCComponentFolder)) { + MessageBox.post(puid + " puidTCвڶ߸puidӦIJǡļС", "쳣", MessageBox.ERROR); + return; + } + else { + CheckBoxTreeNode rootNode = new CheckBoxTreeNode(component.getStringProperty("object_name")); + buildTree(component,rootNode); + DefaultTreeModel model = new DefaultTreeModel(rootNode); + tree.addMouseListener(new CheckBoxTreeNodeSelectionListener()); + tree.setModel(model); + tree.setCellRenderer(new CheckBoxTreeCellRenderer()); + //չнڵ㲢ѡ + for (int i = 0; i < tree.getRowCount(); i++) { + tree.expandRow(i); + } + rootNode.setSelected(true); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * ݹ鴴ӽڵ + * @param component + * @param rootNode + * @throws TCException + */ + private void buildTree(TCComponent component, CheckBoxTreeNode rootNode) throws TCException { + TCComponent[] relatedComponent = component.getRelatedComponents("contents"); + if(relatedComponent != null) { + for (TCComponent child : relatedComponent) { + CheckBoxTreeNode childNode = new CheckBoxTreeNode(child.getStringProperty("object_name")); + rootNode.add(childNode); + buildTree(child,childNode); + } + } + + } + + /** + * ݹ½ļнṹ + * @param root ڵ + * @param folder ڵɵļ + * @param folderType + * @throws Exception + */ + private void createFolderStruct(CheckBoxTreeNode root, TCComponentFolder parentFolder, + TCComponentFolderType folderType,boolean ifTop) throws Exception { + if(root.isSelected()) { + if(ifTop) { + for (int i = 0; i < root.getChildCount(); i++) { + CheckBoxTreeNode child = (CheckBoxTreeNode) root.getChildAt(i); + createFolderStruct(child,parentFolder,folderType,false); + } + } + else { + TCComponentFolder folder = KUtil.createFolderBySOA(folderType.getTypeName(), root.toString()); + parentFolder.add("contents", folder); + for (int i = 0; i < root.getChildCount(); i++) { + CheckBoxTreeNode child = (CheckBoxTreeNode) root.getChildAt(i); + createFolderStruct(child,folder,folderType,false); + } + } + } + + } + + /** + * ѡǷ + * + * @param preferenceValue ѡֵ + * @param preferenceName ѡ + * @return ûþͷfalse + */ + private boolean getMessageInfo(String[] preferenceValue, String preferenceName) { + if (preferenceValue == null || preferenceValue.length == 0) { + MessageBox.post("֪ͨԱѡ" + preferenceName + "Ƿ", "", MessageBox.INFORMATION); + return false; + } + return true; + } + + + private void addListeners() { + this.celButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + this.okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String name = nameField.getText(); + + + + if (name.isEmpty()) { + MessageBox.post("дƷͼţ", "ʾ ", MessageBox.INFORMATION); + } else { + TCComponentFolderType folderType; + try { + + KUtil.setByPass(true); + folderType = (TCComponentFolderType) session.getTypeComponent("LD6_CusProdFolder"); + TCComponentFolder folder = KUtil.createFolderBySOA(folderType.getTypeName(), name); + + //TCComponentFolder folder = folderType.create(name, "", "LD6_CusProdFolder"); + target.add("contents", folder); + CheckBoxTreeNode root = (CheckBoxTreeNode) jtree.getModel().getRoot(); + createFolderStruct(root,folder,(TCComponentFolderType) session.getTypeComponent("LD6_ProjMaFolder"),true); + + //20240524߼3.5.1 ԭܡĿ-ĿṹУܣͻƷļдɹ + //½ƷĬֵصͻƷļ + // ȡݿϢ + String[] value2 = session.getPreferenceService().getStringValues("LD_dbinfo2"); + if (value2 == null || value2.length == 0) { + MessageBox.post("ѡLD_dbinfo顣", "ʾ", 2); + return; + } else { + Collections.addAll(dateConnList, value2); + } + + //ȡfolderƺuid + String folderName = folder.getStringProperty("object_name"); + //String folderUid = folder.getUid(); + //Ĭֵѡȡ + String[] form_defoult_value = session.getPreferenceService().getStringValues("LD6_NewProdForm_defoult_value"); + String[] newProductTaskItem = form_defoult_value[0].split("-");//Ʒ + String[] assignee = form_defoult_value[1].split("-");// + //String[] positionGroup = form_defoult_value[2].split("-");//λ + String[] dueDate = form_defoult_value[2].split("=");//Ҫʱ + + //String[] dueDate = form_defoult_value[0].split("-");//Ҫʱ + if(newProductTaskItem != null && newProductTaskItem.length == 15 && assignee != null && assignee.length == 15 && dueDate.length == 15) { + //ļ + TCComponentFormType formTyep = (TCComponentFormType) session.getTypeComponent("LD6_NewProdForm"); + TCComponentForm form = formTyep.create("Ա", "", "LD6_NewProdForm"); + folder.add("contents", form); + String formUid = form.getUid(); + String folderUid = folder.getUid(); + String p_folder = ""; + //ȡļϲļ + AIFComponentContext[] whereReferenced = folder.whereReferenced(); + for (AIFComponentContext context : whereReferenced) { + // if (context.getComponent().getType().equals("Folder")) { + TCComponent projectFolder = (TCComponent) context.getComponent(); + p_folder = projectFolder.getStringProperty("object_name"); + // } + } + Connection conn = getConn(); + // MES:дݿ + String insertSql = "INSERT INTO LD6_NewProdForm_VALUES (ClientProductFolderName,ClientProductFolderPUID,NewProductTaskItem,Assignee,FormUid,CustomerName,DueDate) VALUES (?, ?, ?, ?, ?, ? , ?)"; + + for (int i = 0; i < newProductTaskItem.length; i++) { + //ӱݵݿ + try (PreparedStatement stmt = conn.prepareStatement(insertSql)) { + stmt.setString(1, folderName); + stmt.setString(2, folderUid); + stmt.setString(3, newProductTaskItem[i]); + stmt.setString(4, assignee[i]); + stmt.setString(5, formUid); + stmt.setString(6, p_folder); + Date date = getDueDate(dueDate[i]); + stmt.setDate(7, date); + // ִв + stmt.executeUpdate(); + System.out.println("ɹ"); + } catch (SQLException e1) { + e1.printStackTrace(); + } + } + + }else { + MessageBox.post("ѡ ld_form_defoult_value òȷ", "ʾ ", MessageBox.INFORMATION); + } + + KUtil.setByPass(false); + disposeDialog(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + }); + this.modelBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent event) { + if(event.getStateChange() == ItemEvent.SELECTED) { + //ˢ + jtree.setModel(null); + initTree(jtree); + }else if(event.getStateChange() == ItemEvent.DESELECTED){ + + } + } + }); + } + + protected Date getDueDate(String string) { + String[] split = string.split("-"); + if(split != null && split.length == 3) { + LocalDate localDate = LocalDate.of(Integer.parseInt(split[0]), Integer.parseInt(split[2]), Integer.parseInt(split[2])); + + // תΪjava.sql.Date + Date sqlDate = Date.valueOf(localDate); + return sqlDate; + }else { + return null ; + } + + + } + + // ȡݿ + public static Connection getConn() { + Connection conn = null; + try { + conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return conn; + } + +} diff --git a/src/com/net/connor/ld/plm/ld02/DbPool.java b/src/com/net/connor/ld/plm/ld02/DbPool.java new file mode 100644 index 0000000..a64eeb3 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld02/DbPool.java @@ -0,0 +1,250 @@ +package com.net.connor.ld.plm.ld02; + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +public class DbPool { + + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + private static DbPool instance = null; + + public static synchronized Connection getConnection(String url, String name) { + if (instance == null) { + instance = new DbPool(); + } + return instance._getConnection(url, name); + } + + private Connection _getConnection(String url, String name) { + try { + String sDBDriver = null; + String sConnection = null; + String sUser = null; + String sPassword = null; + Properties p = new Properties(); +// InputStream is = getClass().getResourceAsStream( +// "/sqlconn.properties"); +// p.load(is); + sDBDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; + sConnection = "jdbc:sqlserver://" + url + ":1433; DatabaseName=" + name;// p.getProperty("Connection", "2"); + sUser = "infodba";// p.getProperty("User", ""); + sPassword = "infodba";// p.getProperty("Password", ""); + + if (sDBDriver == null || sConnection == null || sUser == null || sPassword == null) { + + System.out.println("ݿѡǷȷ"); + + } + + Class.forName(sDBDriver); + connection = DriverManager.getConnection(sConnection, sUser, sPassword); + return connection; + } catch (Exception se) { + System.out.println(se); + } + return null; + } + + public final static ResultSet read(String sql, Object[] argments) throws SQLException { + return DbPool.rs = DbPool.getPs(argments, sql).executeQuery(); + } + + /** + * õStatement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) throws SQLException { + return getPs(sql, argments); + } + + /** + * õStatement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) throws SQLException { + DbPool.ps = DbPool.connection.prepareStatement(sql); + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + DbPool.ps.setObject(i + 1, argments[i]); + } + } + return DbPool.ps; + } + + /** + * ѯ + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + + public static void executeUpdateSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + // System.out.println("sql===" + sql); + int i = st.executeUpdate(sql); + } catch (SQLException e) { + System.out.println(e.getMessage()); + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + // connection.close(); + } + + } + + public static void executeDeleteSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + // System.out.println("sql===" + sql); + st.executeUpdate(sql); + connection.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + connection.close(); + } + + } + + /** + * + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + + /** + * ޸(ɾնҪô˷˴쳣رճConnectionΪĶ) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + i = DbPool.getPs(argments, sql).executeUpdate(); + DbPool.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(DbPool.rs, DbPool.ps); + } + return i; + } + + public static ResultSet executeSelectSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + // System.out.println("sql===" + sql); + rs = st.executeQuery(sql); + // conn.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } + return rs; + + } + + /** + * ͷԴ + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * ͷԴ + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * ͷԴ + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * ͷԴ + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * ͷԴ + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * ͷԴ(Ĭϲ) + */ + public final static void free() { + free(DbPool.rs, DbPool.ps); + } + + /** + * ͷԴ(ȫͷ) + */ + public final static void freeAll() { + free(DbPool.rs, DbPool.ps, DbPool.connection); + } + + /** + * ͷԴ(ҲҪȫͷ) + */ + public final static void free(ResultSet resultSet, Statement statement, Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/com/net/connor/ld/plm/ld02/JCheckBoxTree.java b/src/com/net/connor/ld/plm/ld02/JCheckBoxTree.java new file mode 100644 index 0000000..dea7832 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld02/JCheckBoxTree.java @@ -0,0 +1,290 @@ +package com.net.connor.ld.plm.ld02; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Enumeration; + +import javax.swing.Icon; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +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.DefaultTreeModel; +import javax.swing.tree.TreeCellRenderer; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; + +public class JCheckBoxTree extends JTree { + + public static void main(String[] args) { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); +// String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"; +// UIManager.setLookAndFeel(lookAndFeel); +// String lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel"; +// UIManager.setLookAndFeel(lookAndFeel); + } catch (Exception e) { + e.printStackTrace(); + } + CheckNode root = new CheckNode("Root"); + CheckNode child1 = new CheckNode("child1"); + CheckNode child2 = new CheckNode("child2"); + child2.add(new CheckNode("child3")); + child1.add(new CheckNode("child4")); + root.add(child1); + root.add(child2); + JCheckBoxTree boxTree = new JCheckBoxTree(root); + JFrame frame = new JFrame(); + frame.add(boxTree); + frame.setVisible(true); + frame.setSize(300, 400); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + + private static final long serialVersionUID = 1L; + public JCheckBoxTree(CheckNode checkNode) { + super(checkNode); + this.setCellRenderer(new CheckRenderer()); + this.setShowsRootHandles(true); + this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION ); + this.putClientProperty("JTree.lineStyle", "Angled"); + this.addLister(this); + } + /*** + * ӵ¼ʹѡиڵʱ + * ӽڵҲѡ + * @param tree + */ + private void addLister(final JTree tree) { + this.addMouseListener(new MouseAdapter(){ + + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + int row = tree.getRowForLocation(e.getX(),e.getY()); + TreePath path = tree.getPathForRow(row); + if (path != null) { + CheckNode node = (CheckNode) path.getLastPathComponent(); + node.setSelected(!node.isSelected); + if(node.getSelectionMode()== CheckNode.DIG_IN_SELECTION) + { + if(node.isSelected) + { + tree.expandPath(path); + }else{ + if(!node.isRoot()) + { + tree.collapsePath(path); + } + } + } + //Ӧ¼ + ((DefaultTreeModel) tree.getModel()).nodeChanged(node); + tree.revalidate(); + tree.repaint(); + } + } + + }); + } + + private class CheckRenderer extends JPanel implements TreeCellRenderer { + private static final long serialVersionUID = 1L; + + protected JCheckBox check; + + protected TreeLabel label; + + public CheckRenderer() { + setLayout(null); + add(check = new JCheckBox()); + add(label = new TreeLabel()); + check.setBackground(UIManager.getColor("Tree.textBackground")); + label.setForeground(UIManager.getColor("Tree.textForeground")); + } + + /** + * ıĽڵΪJLabelJChekBox + */ + public Component getTreeCellRendererComponent(JTree tree, Object value, + boolean isSelected, boolean expanded, boolean leaf, int row, + boolean hasFocus) { + String stringValue = tree.convertValueToText(value, isSelected,expanded, leaf, row, hasFocus); + setEnabled(tree.isEnabled()); + check.setSelected(((CheckNode) value).isSelected()); + label.setFont(tree.getFont()); + label.setText(stringValue); + label.setSelected(isSelected); + label.setFocus(hasFocus); + if (leaf) { + //label.setIcon(UIManager.getIcon("Tree.leafIcon")); + label.setIcon(null);//leafǰͼƬȥ + } else if (expanded) { + label.setIcon(UIManager.getIcon("Tree.openIcon")); + } else { + label.setIcon(UIManager.getIcon("Tree.closedIcon")); + } + return this; + } + + public Dimension getPreferredSize() { + Dimension d_check = check.getPreferredSize(); + Dimension d_label = label.getPreferredSize(); + return new Dimension(d_check.width + d_label.width, + (d_check.height < d_label.height ? d_label.height + : d_check.height)); + } + + public void doLayout() { + Dimension d_check = check.getPreferredSize(); + Dimension d_label = label.getPreferredSize(); + int y_check = 0; + int y_label = 0; + if (d_check.height < d_label.height) { + y_check = (d_label.height - d_check.height) / 2; + } else { + y_label = (d_check.height - d_label.height) / 2; + } + check.setLocation(0, y_check); + check.setBounds(0, y_check, d_check.width, d_check.height); + label.setLocation(d_check.width, y_label); + label.setBounds(d_check.width, y_label, d_label.width, + d_label.height); + } + + public void setBackground(Color color) { + if (color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } + + private class TreeLabel extends JLabel { + private static final long serialVersionUID = 1L; + + private boolean isSelected; + + private boolean hasFocus; + + public TreeLabel() { + } + + public void setBackground(Color color) { + if (color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } + + 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 currentI = getIcon(); + if (currentI != null) { + imageOffset = currentI.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); + } + + 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; + } + } + } + + public static class CheckNode extends DefaultMutableTreeNode { + + private static final long serialVersionUID = 1L; + + public final static int SINGLE_SELECTION = 0; + + public final static int DIG_IN_SELECTION = 4; + + protected int selectionMode; + + protected boolean isSelected; + + public CheckNode() { + this(null); + } + + public CheckNode(Object userObject) { + this(userObject, true, false); + } + + public CheckNode(Object userObject, boolean allowsChildren, + boolean isSelected) { + super(userObject, allowsChildren); + this.isSelected = isSelected; + setSelectionMode(DIG_IN_SELECTION); + } + + public void setSelectionMode(int mode) { + selectionMode = mode; + } + + public int getSelectionMode() { + return selectionMode; + } + + /** + * ѡиڵʱҲѡӽڵ + * @param isSelected + */ + @SuppressWarnings("unchecked") + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + if ((selectionMode == DIG_IN_SELECTION) && (children != null)) { + Enumeration e = children.elements(); + while (e.hasMoreElements()) { + CheckNode node = (CheckNode) e.nextElement(); + node.setSelected(isSelected); + } + } + } + + public boolean isSelected() { + return isSelected; + } + } +} \ No newline at end of file diff --git a/src/com/net/connor/ld/plm/ld02/JTreeTest.java b/src/com/net/connor/ld/plm/ld02/JTreeTest.java new file mode 100644 index 0000000..c1f1259 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld02/JTreeTest.java @@ -0,0 +1,81 @@ +package com.net.connor.ld.plm.ld02; +import javax.swing.*; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import java.awt.*; +public class JTreeTest { + public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + JFrame jf = new JFrame("Դ"); + jf.setSize(300, 300); + jf.setLocationRelativeTo(null); + jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(new BorderLayout()); + + // ڵ + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("й"); + + // ڵ + DefaultMutableTreeNode gdNode = new DefaultMutableTreeNode("㶫"); + DefaultMutableTreeNode fjNode = new DefaultMutableTreeNode(""); + DefaultMutableTreeNode shNode = new DefaultMutableTreeNode("Ϻ"); + DefaultMutableTreeNode twNode = new DefaultMutableTreeNode("̨"); + + // ѶڵΪӽڵӵڵ + rootNode.add(gdNode); + rootNode.add(fjNode); + rootNode.add(shNode); + rootNode.add(twNode); + + // ڵ + DefaultMutableTreeNode gzNode = new DefaultMutableTreeNode(""); + DefaultMutableTreeNode szNode = new DefaultMutableTreeNode(""); + + DefaultMutableTreeNode fzNode = new DefaultMutableTreeNode(""); + DefaultMutableTreeNode xmNode = new DefaultMutableTreeNode(""); + + DefaultMutableTreeNode tbNode = new DefaultMutableTreeNode("̨"); + DefaultMutableTreeNode gxNode = new DefaultMutableTreeNode(""); + DefaultMutableTreeNode jlNode = new DefaultMutableTreeNode("¡"); + + // ڵΪӽڵӵӦĶڵ + gdNode.add(gzNode); + gdNode.add(szNode); + + fjNode.add(fzNode); + fjNode.add(xmNode); + + twNode.add(tbNode); + twNode.add(gxNode); + twNode.add(jlNode); + + // ʹøڵ㴴 + JTree tree = new JTree(rootNode); + + // ʾڵ + tree.setShowsRootHandles(true); + + // ڵɱ༭ + tree.setEditable(true); + + // ýڵѡм + tree.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + System.out.println("ǰѡеĽڵ: " + e.getPath()); + } + }); + + // 壬ΪڵչҪܴĿռʾҪһ + JScrollPane scrollPane = new JScrollPane(tree); + + // ӹ嵽 + panel.add(scrollPane, BorderLayout.CENTER); + + // ô岢ʾ + jf.setContentPane(panel); + jf.setVisible(true); + } +} diff --git a/src/com/net/connor/ld/plm/ld02/表单表结构sql.txt b/src/com/net/connor/ld/plm/ld02/表单表结构sql.txt new file mode 100644 index 0000000..20c757a --- /dev/null +++ b/src/com/net/connor/ld/plm/ld02/表单表结构sql.txt @@ -0,0 +1,30 @@ +CREATE TABLE PFORM_VALUES ( + ClientProductFolderName VARCHAR(100), + ClientProductFolderPUID VARCHAR(100) , + NewProductTaskItem VARCHAR(100), + Assignee VARCHAR(100), + NewProductTaskDescription NVARCHAR(MAX), + Processor VARCHAR(100), + PositionGroup VARCHAR(100), + TaskNature VARCHAR(100), + DifficultyLevel VARCHAR(100), + UrgencyLevelCode VARCHAR(100), + EstimatedBusinessHours VARCHAR(20), + ActualBusinessHours VARCHAR(20), + DueDate DATETIME, + CompletionDate DATETIME, + Remarks NVARCHAR(MAX), + TaskAssignmentDate DATETIME +); + + + + private JTextField cpwjjmcField = new JTextField(15); + private JTextField fprzhField = new JTextField(15); + private JTextField clrField = new JTextField(15); + private JTextField gwzField = new JTextField(15); + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private DateButton TaskassignmentStartButton; + private DateButton TaskassignmentEndButton; + private DateButton CompletionDateStartButton; + private DateButton CompletionDateEndButton; \ No newline at end of file diff --git a/src/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelCommand.java b/src/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelCommand.java new file mode 100644 index 0000000..8c51b1d --- /dev/null +++ b/src/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelCommand.java @@ -0,0 +1,67 @@ +package com.net.connor.ld.plm.ld03; + +import java.io.File; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ld.plm.KCommand; +import cn.net.connor.ld.plm.KUtil; + +public class PropertyToWordOrExcelCommand extends KCommand{ + + final String preName = "Connor_WordExcel_Report_ItemType"; + + public PropertyToWordOrExcelCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + TCSession session = (TCSession) app.getSession(); + this.setRunnable(new PropertyToWordOrExcelOperation(app, "ȡ汾ԵWord Excel")); +// InterfaceAIFComponent targetComponent = app.getTargetComponent(); +// TCComponentItemRevision revision = (TCComponentItemRevision) targetComponent; +// try { +// String[] prefVals = KUtil.getPrefVals(session, preName); +// if(prefVals == null || prefVals.length == 0) { +// KUtil.info(AIFDesktop.getActiveDesktop(), preName + "ѡδãϵԱ"); +// return ; +// } +// String relatioin = prefVals[0]; +// TCComponent[] relatedComponents = revision.getRelatedComponents(relatioin); +// if(relatedComponents == null || relatedComponents.length == 0) { +// KUtil.info(AIFDesktop.getActiveDesktop(), "ѡж " + relatioin + " ϵûݼ"); +// return ; +// } +// for (TCComponent tcComponent : relatedComponents) { +// if (tcComponent instanceof TCComponentDataset) { +// TCComponentDataset dataset = (TCComponentDataset) tcComponent; +// File datasetFile = KUtil.getDatasetFile(dataset); +// System.out.println(); +// String type = tcComponent.getType(); +// switch (type) { +// case "MSExcel": +// +// break; +// case "MSExcelX": +// +// break; +// case "MSWord": +// +// break; +// case "MSWordX": +// +// break; +// } +// } +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + } + +} diff --git a/src/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelOperation.java b/src/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelOperation.java new file mode 100644 index 0000000..085a1ac --- /dev/null +++ b/src/com/net/connor/ld/plm/ld03/PropertyToWordOrExcelOperation.java @@ -0,0 +1,289 @@ +package com.net.connor.ld.plm.ld03; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFName; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.aspose.words.Bookmark; +import com.aspose.words.Document; +import com.aspose.words.SaveFormat; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +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.TCProperty; +import com.teamcenter.rac.util.FileUtility; + +import cn.net.connor.ld.plm.KOperation; +import cn.net.connor.ld.plm.KUtil; + +public class PropertyToWordOrExcelOperation extends KOperation { + + public PropertyToWordOrExcelOperation(AbstractAIFApplication app, String opName) { + super(app, opName, "ִС"); + } + + final String preName = "Connor_WordExcel_Report_ItemType"; + + @Override + public boolean init() throws Exception { + new Thread().sleep(1000); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + TCComponentItemRevision revision = (TCComponentItemRevision) targetComponent; + String[] prefVals = KUtil.getPrefVals(session, preName); + if(prefVals == null || prefVals.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), preName + "ѡδãϵԱ"); + return false; + } + String relatioin = prefVals[0]; + TCComponent[] relatedComponents = revision.getRelatedComponents(relatioin); + if(relatedComponents == null || relatedComponents.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡж " + relatioin + " ϵûݼ"); + return false; + } + //ѡ + HashMap nameMap = new HashMap();//ݼƺͶ(item,rev,revMaster) + if(prefVals.length >= 2) { + for (int i = 1; i < prefVals.length; i++) { + //Item.object_name=object_name + String[] split = prefVals[i].split("="); + nameMap.put(split[1],split[0]); + } + } + for (TCComponent tcComponent : relatedComponents) { + if (tcComponent instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) tcComponent; + File datasetFile = KUtil.getDatasetFile(dataset); + String type = tcComponent.getType(); + String datasetType = ""; + String newPath = ""; + if("MSExcel".equals(type) || "MSExcelX".equals(type) || "MSWord".equals(type) || "MSWordX".equals(type)) { + switch (type) { + case "MSExcel": + datasetType = "excel"; + newPath = dealExcel(datasetFile,revision,nameMap); + break; + case "MSExcelX": + datasetType = "excel"; + newPath = dealExcelX(datasetFile,revision,nameMap); + break; + case "MSWord": + datasetType = "word"; + newPath = dealWord2(datasetFile,revision,nameMap,"doc"); + break; + case "MSWordX": + datasetType = "word"; + newPath = dealWord2(datasetFile,revision,nameMap,"docx"); + break; + } + //ݼµ + dataset.setFiles(new String[] {newPath}, new String[] {datasetType}); + } + } + } + KUtil.info(AIFDesktop.getActiveDesktop(), "ȡ汾ԵWord Excelִ"); + return true; + } + + @Override + public void execute() throws Exception { + + } + + private String dealExcel(File datasetFile, TCComponentItemRevision revision, HashMap nameMap) throws IOException, TCException { + FileInputStream is = new FileInputStream(datasetFile); + HSSFWorkbook workbook = new HSSFWorkbook(is); + List allNames = workbook.getAllNames(); + for (HSSFName hssfName : allNames) { + String name = hssfName.getNameName(); + //ƹѡ + if (nameMap.containsKey(name)) { + CellReference cellReference = new CellReference(hssfName.getRefersToFormula()); + HSSFSheet sheet = workbook.getSheet(cellReference.getSheetName()); + HSSFRow row = sheet.getRow(cellReference.getRow()); + HSSFCell cell = row.getCell(cellReference.getCol()); + String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(name)); + System.out.println("Ϊ" + cellReference.getRow() + "====" + "Ϊ" + cellReference.getCol() + "====" + + "ֵΪ " + preConfigValue); + if(cell == null) { + cell = row.createCell(cellReference.getCol()); + } + cell.setCellValue(preConfigValue); + + } + } + is.close(); + FileOutputStream os = new FileOutputStream(datasetFile); + workbook.write(os); + workbook.close(); + return datasetFile.getAbsolutePath(); + } + + private String dealExcelX(File datasetFile, TCComponentItemRevision revision, HashMap nameMap) throws IOException, TCException { + FileInputStream is = new FileInputStream(datasetFile); + XSSFWorkbook workbook = new XSSFWorkbook(is); + List allNames = workbook.getAllNames(); + for (XSSFName xssfName : allNames) { + String name = xssfName.getNameName(); + //ƹѡ + if (nameMap.containsKey(name)) { + CellReference cellReference = new CellReference(xssfName.getRefersToFormula()); + XSSFSheet sheet = workbook.getSheet(cellReference.getSheetName()); + XSSFRow row = sheet.getRow(cellReference.getRow()); + XSSFCell cell = row.getCell(cellReference.getCol()); + String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(name)); + System.out.println("Ϊ" + cellReference.getRow() + "====" + "Ϊ" + cellReference.getCol() + "====" + + "ֵΪ " + preConfigValue); + if(cell == null) { + cell = row.createCell(cellReference.getCol()); + cell.setCellValue(preConfigValue); + } + else { + cell.setCellValue(preConfigValue); + } + } + } + is.close(); + FileOutputStream os = new FileOutputStream(datasetFile); + workbook.write(os); + workbook.close(); + return datasetFile.getAbsolutePath(); + } + + private String dealWord(File datasetFile, TCComponentItemRevision revision, HashMap nameMap,String type) throws IOException, TCException { + String path = datasetFile.getAbsolutePath(); + InputStream inputStream = Files.newInputStream(Paths.get(path)); + Map dataMap = new HashMap<>(); + for(String key : nameMap.keySet()) { + String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(key)); + dataMap.put(key, preConfigValue); + } + String newPath = ""; + if(type.equals("doc")) { + newPath = path.replace(".doc", "temp.doc"); + WordUtils.replaceBookmarksByDoc(inputStream, Files.newOutputStream(Paths.get(newPath)), dataMap); + } + else if(type.equals("docx")) { + newPath = path.replace(".docx", "temp.docx"); + WordUtils.replaceBookmarksByDocx(inputStream, Files.newOutputStream(Paths.get(newPath)), dataMap); + } + return newPath; + } + + private String dealWord2(File datasetFile, TCComponentItemRevision revision, HashMap nameMap,String type) throws FileNotFoundException, Exception { + String path = datasetFile.getAbsolutePath(); + Document document2 = new Document(new FileInputStream(path)); + OutputStream outputStream = null; + String newPath = path.replace(".doc", "temp.doc"); + outputStream = new FileOutputStream(newPath); + Map dataMap = new HashMap<>(); + for(String key : nameMap.keySet()) { + String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(key)); + dataMap.put(key, preConfigValue); + } + for (Bookmark bookmark : document2.getRange().getBookmarks()) { + String bookmarkName = bookmark.getName(); + System.out.println("ǩ"+bookmarkName); + if(dataMap.containsKey(bookmarkName)) + { + System.out.println(""); + bookmark.setText(dataMap.get(bookmarkName)); + } + } + if(type.equals("doc")) { + document2.save(outputStream, SaveFormat.DOC); + }else if(type.equals("docx")) { + document2.save(outputStream, SaveFormat.DOCX); + } + return newPath; + } + + /** + * õѡС=߶Ӧֵ + * @param revision + * @param nameMap + * @param value + * @return + * @throws TCException + */ + private String getPreConfigValue(TCComponentItemRevision revision, HashMap nameMap,String value) throws TCException { + String[] split = value.split("\\."); + String cellValue = ""; + TCProperty property = null; + if(split.length == 2) { + switch (split[0]) { + case "Item": + property = revision.getItem().getTCProperty(split[1]); + break; + case "Rev": + property = revision.getTCProperty(split[1]); + break; + case "RevMaster": + property = revision.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[1]); + break; + default: + break; + } + } + //ȡϵļµ + else if(split.length == 3) { + String relation = split[0]; + TCComponent relatedComponent = revision.getRelatedComponent(relation); + TCComponentItemRevision centerRev = null; + if(relatedComponent instanceof TCComponentItemRevision) { + centerRev = (TCComponentItemRevision) relatedComponent; + }else if(relatedComponent instanceof TCComponentItem) { + centerRev = ((TCComponentItem) relatedComponent).getLatestItemRevision(); + } + if(centerRev != null) { + switch (split[1]) { + case "Item": + property = centerRev.getItem().getTCProperty(split[2]); + break; + case "Rev": + property = centerRev.getTCProperty(split[2]); + break; + case "RevMaster": + property = centerRev.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[2]); + break; + default: + break; + } + } + } + if(property == null) { + return ""; + } + else { + cellValue = property.getDisplayValue(); + return cellValue; + } + } +} diff --git a/src/com/net/connor/ld/plm/ld03/Test.java b/src/com/net/connor/ld/plm/ld03/Test.java new file mode 100644 index 0000000..20f24da --- /dev/null +++ b/src/com/net/connor/ld/plm/ld03/Test.java @@ -0,0 +1,68 @@ +package com.net.connor.ld.plm.ld03; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.poi.hssf.usermodel.HSSFName; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.aspose.words.Bookmark; +import com.aspose.words.Document; +import com.aspose.words.SaveFormat; + +public class Test { + public static void main(String[] args) { + try { +// FileInputStream is = new FileInputStream("C:\\Users\\Administrator\\Desktop\\ļ\\2.xls"); +// // ȡļ +// HSSFWorkbook workbook = new HSSFWorkbook(is); +// List allNames = workbook.getAllNames(); +// System.out.println("allNames = " + allNames); +// String cellReference = allNames.get(0).getRefersToFormula(); +// workbook.close(); +// is.close(); + +// FileInputStream is2 = new FileInputStream("C:\\Users\\Administrator\\Desktop\\ļ\\1.xlsx"); +// // ȡļ +// XSSFWorkbook workbook2 = new XSSFWorkbook(is2); +// List allNames2 = workbook2.getAllNames(); +// +// workbook2.close(); +// is2.close(); + + FileInputStream is = new FileInputStream("C:\\Users\\Administrator\\Desktop\\workexcel\\1.docx"); + // ȡļ + XSSFWorkbook workbook = new XSSFWorkbook(is); + File datasetFile = new File("C:\\Users\\Administrator\\Desktop\\workexcel\\1.docx"); + String path = datasetFile.getAbsolutePath(); + Document document2 = new Document(new FileInputStream(path)); + OutputStream outputStream = null; + String newPath = path.replace(".doc", "temp.doc"); + outputStream = new FileOutputStream(newPath); + Map dataMap = new HashMap<>(); + dataMap.put("one", "one"); + dataMap.put("two", "two"); + for (Bookmark bookmark : document2.getRange().getBookmarks()) { + String bookmarkName = bookmark.getName(); + System.out.println("ǩ"+bookmarkName); + if(dataMap.containsKey(bookmarkName)) + { + System.out.println(""); + bookmark.setText(dataMap.get(bookmarkName)); + } + } + document2.save(outputStream, SaveFormat.DOC); + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/net/connor/ld/plm/ld03/WordUtils.java b/src/com/net/connor/ld/plm/ld03/WordUtils.java new file mode 100644 index 0000000..79d5a8c --- /dev/null +++ b/src/com/net/connor/ld/plm/ld03/WordUtils.java @@ -0,0 +1,168 @@ +package com.net.connor.ld.plm.ld03; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.poi.hwpf.HWPFDocument; +import org.apache.poi.hwpf.usermodel.Bookmark; +import org.apache.poi.hwpf.usermodel.Bookmarks; +import org.apache.poi.hwpf.usermodel.Range; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFRun; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; +import org.w3c.dom.Node; + +public class WordUtils { + + public static final String RUN_NODE_NAME = "w:r"; + public static final String TEXT_NODE_NAME = "w:t"; + public static final String BOOKMARK_START_TAG = "w:bookmarkStart"; + public static final String BOOKMARK_END_TAG = "w:bookmarkEnd"; + public static final String BOOKMARK_ID_ATTR_NAME = "w:id"; + public static final String STYLE_NODE_NAME = "w:rPr"; + + public static void main(String[] args) throws IOException { + // 滻ļе bookmark + InputStream inputStream3 = Files.newInputStream(Paths.get("C:\\Users\\Administrator\\Desktop\\ļ\\22.doc")); + Map dataMap = new HashMap<>(); + dataMap.put("one", "oneoneoneoneone"); + dataMap.put("two", "twotwotwotwo"); + dataMap.put("three", "ceshi"); + replaceBookmarksByDoc(inputStream3, Files.newOutputStream(Paths.get("C:\\Users\\Administrator\\Desktop\\ļ\\33.doc")), dataMap); + } + + /** + * ȡ doc ļеǩ + * + * @param inputStream + * @throws IOException + */ + public static void getBookmarksByDoc(InputStream inputStream) throws IOException { + HWPFDocument wordDoc = new HWPFDocument(inputStream); + + Bookmarks bookmarks = wordDoc.getBookmarks(); + + for (int b = 0; b < bookmarks.getBookmarksCount(); b++) { + Bookmark bookmark = bookmarks.getBookmark(b); + String bookMarkText = new Range(bookmark.getStart(), bookmark.getEnd(), wordDoc).text(); + + System.out.println("[" + bookmark.getStart() + "; " + + bookmark.getEnd() + "]: " + bookmark.getName() + " = " + bookMarkText); + } + + } + + /** + * ȡ docx ļеǩ + * + * @param inputStream + * @throws IOException + */ + public static void getBookmarksByDocx(InputStream inputStream) throws IOException { + XWPFDocument docx = new XWPFDocument(inputStream); + + List paragraphList = docx.getParagraphs(); + for (XWPFParagraph xwpfParagraph : paragraphList) { + CTP ctp = xwpfParagraph.getCTP(); + + for (int dwI = 0; dwI < ctp.sizeOfBookmarkStartArray(); dwI++) { + CTBookmark bookmark = ctp.getBookmarkStartArray(dwI); + String bookmarkName = bookmark.getName(); + + // Ϊ docx Ľṹxmlʽ doc ĵоstartendֵλһbookmarkֵΧ + // Ҫȡ docx ĵbookmarkݣҪ bookmarkStart ڵ㿪ʼνxml + // nodeValue ֵƴӣֱȡһΪ bookmarkEnd ĽڵΪֹ + // getBookmarkTextContent() һûʵֵķҪʵ + // String bookmarkTextContent = getBookmarkTextContent(bookmark); + + System.out.println(bookmarkName); + } + } + } + + + /** + * docx ļǩ滻 + * + * @param inputStream + * @param outputStream + * @param dataMap + * @throws IOException + */ + public static void replaceBookmarksByDocx(InputStream inputStream, OutputStream outputStream, Map dataMap) throws IOException { + XWPFDocument document = new XWPFDocument(inputStream).getXWPFDocument(); + List paragraphList = document.getParagraphs(); + for (XWPFParagraph xwpfParagraph : paragraphList) { + CTP ctp = xwpfParagraph.getCTP(); + + for (int dwI = 0; dwI < ctp.sizeOfBookmarkStartArray(); dwI++) { + CTBookmark bookmark = ctp.getBookmarkStartArray(dwI); + if (dataMap.containsKey(bookmark.getName())) { + + XWPFRun run = xwpfParagraph.createRun(); + run.setText(dataMap.get(bookmark.getName())); + + Node firstNode = bookmark.getDomNode(); + Node nextNode = firstNode.getNextSibling(); + while (nextNode != null) { + // ѭҽ + String nodeName = nextNode.getNodeName(); + if (nodeName.equals(BOOKMARK_END_TAG)) { + break; + } + + // ɾмķǽڵ㣬ɾԭǩ + Node delNode = nextNode; + nextNode = nextNode.getNextSibling(); + + ctp.getDomNode().removeChild(delNode); + } + + if (nextNode == null) { + // ʼҲʶģǩǰ + ctp.getDomNode().insertBefore(run.getCTR().getDomNode(), firstNode); + } else { + // ҵӵ֮ǰдbookmarkм + ctp.getDomNode().insertBefore(run.getCTR().getDomNode(), nextNode); + } + } + } + } + + document.write(outputStream); + document.close(); + } + + + /** + * doc ļǩ滻 + * + * @param inputStream + * @param outputStream + * @param dataMap + * @throws IOException + */ + public static void replaceBookmarksByDoc(InputStream inputStream, OutputStream outputStream, + Map dataMap) throws IOException { + HWPFDocument document = new HWPFDocument(inputStream); + Bookmarks bookmarks = document.getBookmarks(); + for (int dwI = 0; dwI < bookmarks.getBookmarksCount(); dwI++) { + Bookmark bookmark = bookmarks.getBookmark(dwI); + if (dataMap.containsKey(bookmark.getName())) { + Range range = new Range(bookmark.getStart(), bookmark.getEnd(), document); + range.replaceText(dataMap.get(bookmark.getName()), false); + } + } + document.write(outputStream); + } +} + + diff --git a/src/com/net/connor/ld/plm/ld04/ClassPropBean.java b/src/com/net/connor/ld/plm/ld04/ClassPropBean.java new file mode 100644 index 0000000..bfac4e9 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld04/ClassPropBean.java @@ -0,0 +1,44 @@ +package com.net.connor.ld.plm.ld04; + +public class ClassPropBean { + private String id; + private String name; + private String value; + + public ClassPropBean(String id, String name, String value) { + super(); + this.id = id; + this.name = name; + this.value = value; + } + + public String getId() { + return id; + } + + @Override + public String toString() { + return name; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/com/net/connor/ld/plm/ld04/ClassProperty.java b/src/com/net/connor/ld/plm/ld04/ClassProperty.java new file mode 100644 index 0000000..61e169a --- /dev/null +++ b/src/com/net/connor/ld/plm/ld04/ClassProperty.java @@ -0,0 +1,42 @@ +package com.net.connor.ld.plm.ld04; + +/** + * @copyRight 㽭տƼ޹˾ + * @author E-mail:hub@connor.net.cn + * @date ʱ䣺2017-7-3 11:47:03 + * @version v1.0 + * @parameter + * @since + * @return + */ + +public class ClassProperty { + private int propertyID; + private String value; + + public ClassProperty() { + + } + + public ClassProperty(int propertyID, String value) { + this.propertyID = propertyID; + this.value = value; + } + + public int getPropertyID() { + return propertyID; + } + + public void setPropertyID(int propertyID) { + this.propertyID = propertyID; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/com/net/connor/ld/plm/ld04/ClassificationProEditHandler.java b/src/com/net/connor/ld/plm/ld04/ClassificationProEditHandler.java new file mode 100644 index 0000000..6ef00d0 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld04/ClassificationProEditHandler.java @@ -0,0 +1,24 @@ +package com.net.connor.ld.plm.ld04; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; + +public class ClassificationProEditHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + try { + new Thread(new EditClassificationDialog(app)).start(); + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/com/net/connor/ld/plm/ld04/EditClassificationDialog.java b/src/com/net/connor/ld/plm/ld04/EditClassificationDialog.java new file mode 100644 index 0000000..c687c05 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld04/EditClassificationDialog.java @@ -0,0 +1,433 @@ +package com.net.connor.ld.plm.ld04; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassService; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; +import net.sf.json.JSONArray; + +/** + * ޸ķ + */ +public class EditClassificationDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private TCComponent target; + private Map propMap; + private TCClassificationService myService; + final EditClassificationDialog DIALOG = this; + private TCComponentItemRevision rev; + private int[] ids; + private String[] values; + private String[] names; + private boolean finished; + private ICSPropertyDescription[] desc; + + public EditClassificationDialog(AbstractAIFApplication app) throws TCException { + this.app = app; + this.session = (TCSession) app.getSession(); + this.myService = session.getClassificationService(); + this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + System.out.println(target.getType()); + System.out.println(target instanceof TCComponentItemRevision ? "" : ""); + + if (target instanceof TCComponentItemRevision) { + try { + rev = (TCComponentItemRevision) target; + boolean isAccess = session.getTCAccessControlService().checkPrivilege(rev, "WRITE"); + if (!isAccess) { + JOptionPane.showMessageDialog(this, "ûа汾޸ȨޣϵϵͳԱ", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + initUI(); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + MessageBox.post("ѡ汾", "", MessageBox.ERROR); + } + } + + /** + * ȡLOVʾֵ + * @param icsD + * @return + */ + public static String getClassDisplayableValue(ICSPropertyDescription icsD) { + String result = ""; + ICSKeyLov lov = icsD.getFormat().getKeyLov(); + if (lov != null) { + String[] keys = lov.getKeys(); + for (String key : keys) { + result = lov.getValueOfKey(key); + return result; + } + } + return result; + } + + private void initUI() { + this.setTitle("޸ķ"); + + JPanel rootPanel = new JPanel(); + rootPanel.setLayout(null); + rootPanel.setPreferredSize(new Dimension(600, 350)); + + Map displayMap = new LinkedHashMap(); + propMap = new HashMap(); + + try { + if (rev.getClassificationClass() != null && !"".equals(rev.getClassificationClass())) { + try { + rev.refresh(); + System.out.println("rev.getClassificationClass()=" + rev.getClassificationClass()); + TCComponentICO ico = rev.getClassificationObjects()[0]; + ICSProperty[] props = ico.getICSProperties(true); + desc = ico.getICSPropertyDescriptors(); + for (int i = 0; i < props.length; i++) { +// System.out.println(props[i].getId() + "===>" + props[i].getValue());// 30101===> + // desc.getName=Type and size series ǷԵ||| desc.getId=30101ǷID +// System.out.println("desc.getName=" + desc[i].getName() + " desc.getId=" + desc[i].getId()); + displayMap.put(props[i], desc[i]); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + this.disposeDialog(); + MessageBox.post("ǰ汾δ", "", MessageBox.ERROR); + return; + } + } catch (TCException e) { + e.printStackTrace(); + } + + if (displayMap.size() == 0) { + return; + } + + JPanel content = new JPanel(); + content.setLayout(null); + content.setPreferredSize(new Dimension(600, displayMap.size() * (25 + 10))); + + int num = 0; + // ͨȡеķԣȻ + for (Entry entry : displayMap.entrySet()) { + JLabel label = new JLabel(entry.getValue().getName() + ""); + label.setBounds(10, num * 35 + 10, 100, 25); + + ICSKeyLov lov = entry.getValue().getFormat().getKeyLov(); +// ArrayList list = new ArrayList<>(); + if (lov != null) { + String[] keys = lov.getKeys(); + JAutoCompleteComboBox combo = new JAutoCompleteComboBox(); +// JComboBox combo = new JComboBox(); + combo.addItem(new ClassPropBean("", "", "")); + for (String key : keys) { + combo.addItem(new ClassPropBean(key, lov.getValueOfKey(key), "")); + } + + String v = entry.getKey().getValue(); + for (int i = 0; i < combo.getItemCount(); i++) { + if (v.equals(((ClassPropBean) combo.getItemAt(i)).getId())) { + combo.setSelectedIndex(i); + break; + } + } +// combo.setSelectedItem(v); +// if (!Arrays.asList(lov.getDisplayValues()).contains(v)) { +// combo.addItem(v); +// combo.setSelectedItem(v); +// } + + combo.setBounds(130, num * 35 + 10, 350, 25); + + propMap.put(entry.getValue().getName(), combo); + content.add(combo); + } else { + JTextField text = new JTextField(entry.getKey().getValue()); + text.setBounds(130, num * 35 + 10, 350, 25); + propMap.put(entry.getValue().getName(), text); + content.add(text); + } + + content.add(label); + + num++; + } + + JButton okBtn = new JButton("ȷ"); + okBtn.setBounds(40, 310, 100, 25); + okBtn.setSelected(true); + okBtn.addActionListener(ok()); + JButton cancelBtn = new JButton("ȡ"); + cancelBtn.setBounds(160, 310, 100, 25); + cancelBtn.addActionListener(cancel()); + + JScrollPane jsp = new JScrollPane(content); + jsp.getVerticalScrollBar().setUnitIncrement(16); + jsp.setBounds(0, 0, 600, 300); + jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + rootPanel.add(jsp); + rootPanel.add(okBtn); + rootPanel.add(cancelBtn); + this.add(rootPanel); + this.pack(); + this.centerToScreen(); + this.setAutoRequestFocus(true); +// this.setResizable(false); + this.setAlwaysOnTop(true); + this.showDialog(); + } + + private ActionListener ok() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ((JButton) e.getSource()).setEnabled(false); + rev = (TCComponentItemRevision) target; + + new Thread(new Runnable() { + + @Override + public void run() { + int i = 1; + while (!DIALOG.finished) { + try { + DIALOG.setTitle("޸ķ " + StringCreateUtil.createPoint(i++ % 3)); + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }).start(); + + EditClassificationDialog.this.setAlwaysOnTop(false); + if (saveClassification(rev)) { + MessageBox.post("޸ķԳɹ", "", MessageBox.ERROR); + EditClassificationDialog.this.disposeDialog(); + } else { + MessageBox.post("޸ķʧܣ", "", MessageBox.ERROR); + } + + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + DIALOG.disposeDialog(); + } + }; + } + + @SuppressWarnings("unchecked") + private boolean saveClassification(TCComponentItemRevision rev) { + + try { + TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] status = form.getRelatedComponents("release_status_list"); + for (TCComponent comp : status) { + if (comp.getProperty("object_name").contains("ʽ")) { + JOptionPane.showMessageDialog(this, "汾ʽ޸ķ", "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + } + TCComponentICO[] icoS = rev.getClassificationObjects(); + System.out.println("======>ȡķ:" + icoS.length); + String classID = rev.getClassificationClass(); + if (icoS == null || icoS.length == 0) { + return false; + } + for (int i = 0; i < icoS.length; i++) { + List propList = new ArrayList<>(); + TCComponentICO ico = icoS[i]; + ICSPropertyDescription[] desc = ico.getICSPropertyDescriptors(); + ICSProperty[] oldICSProps = ico.getICSProperties(true); + ids = new int[oldICSProps.length]; + values = new String[oldICSProps.length]; + names = new String[oldICSProps.length]; + for (int j = 0; j < oldICSProps.length; j++) { + ids[j] = oldICSProps[j].getId(); + if (propMap.get(desc[j].getName()) instanceof JComboBox) { + ClassPropBean bean = (ClassPropBean) ((JComboBox) propMap.get(desc[j].getName())).getSelectedItem(); + String str = bean.getId(); + values[j] = " ".equals(str) ? "" : str; + } else { + values[j] = ((JTextField) propMap.get(desc[j].getName())).getText(); + } + names[j] = desc[j].getName(); + ClassProperty prop = new ClassProperty(ids[j], values[j]); + propList.add(prop); + } + String json = objectToJson(propList); + System.out.println("classID=" + classID); + System.out.println("json=" + json); + System.out.println("ɾ..."); + try { + deleteClass(getICO(rev, classID).getUid()); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("ͷ..."); + if (sendToClass(rev.getUid(), classID, json)) { + return true; + } else { + return false; + } + } + } catch (TCException e1) { + e1.printStackTrace(); + JOptionPane.showMessageDialog(null, e1, "", JOptionPane.ERROR_MESSAGE); + return false; + } + return true; + } + + private TCComponentICO getICO(TCComponentItemRevision rev, String classId) throws Exception { + if (rev == null || classId.equals("")) { + return null; + } + TCComponentICO[] icos = rev.getClassificationObjects(); + System.out.println(rev + " -> Ѵڷࣺ" + Arrays.toString(icos)); + int len = icos.length; + if (len == 0) { + return null; + } + TCClassificationService classService = session.getClassificationService(); + for (int i = 0; i < len; i++) { + TCComponentICO ico = icos[i]; + classService.loadICOs(new String[] { ico.getUid() }, ""); + if (ico.getClassId() == null || ico.getClassId().equals("")) { + throw new Exception("쳣ϵԱ"); + } + if (classId.equals(ico.getClassId())) { + return ico; + } + } + return null; + } + + public void deleteClass(String icoPuid) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session);// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(icoPuid); + + method.addChild(value); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public boolean sendToClass(String wsoPUID, String classID, String json) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session); + // "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { +// MessageBox.post("ͷʧܣ", "", MessageBox.ERROR); + e.printStackTrace(); + return false; + } + return true; + + } + + public static String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// javaתΪjson + str = json.toString();// jsonתΪַ + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("JSON =>" + str); + return str; + } +} diff --git a/src/com/net/connor/ld/plm/ld04/JAutoCompleteComboBox.java b/src/com/net/connor/ld/plm/ld04/JAutoCompleteComboBox.java new file mode 100644 index 0000000..35059e0 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld04/JAutoCompleteComboBox.java @@ -0,0 +1,160 @@ +package com.net.connor.ld.plm.ld04; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +@SuppressWarnings({ "serial", "rawtypes", "unchecked" }) +public class JAutoCompleteComboBox extends JComboBox { + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} + +@SuppressWarnings({"rawtypes"}) +class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + @SuppressWarnings("unused") + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + // || ch == KeyEvent.VK_DELETE) + // return; + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + } + + @SuppressWarnings({ "unchecked", "unused" }) + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + @SuppressWarnings("unchecked") + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + // v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/src/com/net/connor/ld/plm/ld04/JDMethodUtil.java b/src/com/net/connor/ld/plm/ld04/JDMethodUtil.java new file mode 100644 index 0000000..2dd1b2d --- /dev/null +++ b/src/com/net/connor/ld/plm/ld04/JDMethodUtil.java @@ -0,0 +1,47 @@ +package com.net.connor.ld.plm.ld04; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class JDMethodUtil { + + public static TCPreferenceService service; + public static TCUserService userservice; + + /** + * + * + * @param prefName + * @return + */ + public static String getPrefStr(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /** + * + * + * @param prefName + * @return + */ + public static String[] getPrefStrArray(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + service.getStringValues(prefName); + service.getStringValue(prefName); + if (strs == null) { + strs = new String[] { "" }; + } + return strs; + } +} diff --git a/src/com/net/connor/ld/plm/ld04/StringCreateUtil.java b/src/com/net/connor/ld/plm/ld04/StringCreateUtil.java new file mode 100644 index 0000000..4b4d747 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld04/StringCreateUtil.java @@ -0,0 +1,21 @@ +package com.net.connor.ld.plm.ld04; + +public class StringCreateUtil { + public static String createBlank(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append(" "); + num--; + } + return sb.toString(); + } + + public static String createPoint(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append("."); + num--; + } + return sb.toString(); + } +} diff --git a/src/com/net/connor/ld/plm/ld05/CIForm.java b/src/com/net/connor/ld/plm/ld05/CIForm.java new file mode 100644 index 0000000..12cdd0f --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/CIForm.java @@ -0,0 +1,653 @@ +package com.net.connor.ld.plm.ld05; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +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.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.EventObject; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.mail.Flags.Flag; +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.PlainDocument; + +import org.jdesktop.swingx.renderer.DefaultTableRenderer; +import org.jdesktop.swingx.renderer.FormatStringValue; +import org.jdesktop.swingx.renderer.StringValue; +import org.jdesktop.swingx.table.DatePickerCellEditor; + +import com.net.connor.ld.plm.bean.FormBean; +import com.net.connor.ld.plm.bean.MyButtonEditor; +import com.net.connor.ld.plm.bean.MyButtonEditor222; +import com.net.connor.ld.plm.bean.MyButtonRender; +import com.net.connor.ld.plm.form.CLForm; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.ICommandListener; +import com.teamcenter.rac.aif.ICommandListenerEvent; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.DataManagementService; + +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.soaictstubs.ICCTAccessControlService; + +import cn.net.connor.ld.plm.KUtil; +import k.util.KOrgDialog; + + +@SuppressWarnings("serial") +public class CIForm extends AbstractRendering implements FormModel{ + private OpenFormDialog lastDialog; + private Map> displayColumn = new HashMap>(); + private Map personMap = new HashMap(); + private List hideList = new ArrayList(); + private Boolean flag = true; + + DefaultTableModel tableModel = null; + private TCComponent form; + +// static String ynChangeLovName = "LD6_TecDoc_Type_TLOV"; +// static String changeStateLovName = "LD6_TecDoc_Type_TLOV"; + + private JButton saveButton; + private JButton displayButton; + + public CIForm(TCComponent form) throws Exception { + super(); + this.form = form; + loadRendering(); + + } + + + @Override + public void loadRendering() throws TCException { + try { + form.okToCheckout(); + getdata(); + loadUI(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + private void refreshUI(Component component) { + SwingUtilities.updateComponentTreeUI(component); + component.invalidate(); + component.validate(); + component.repaint(); + } + public void getdata() throws Exception { + //ȡ + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String prefName = "Connor_FormModel";//ݺ͸ģ + String[] prefVals = KUtil.getPrefVals(session, prefName); + String puid = prefVals[1]; + TCComponent component = session.stringToComponent(puid); + if(component instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) component; + //ȡ˵ֵŶӦ + TCComponent[] referenceListProperty = form.getReferenceListProperty("ld6_ChangeTable"); + for(TCComponent comp : referenceListProperty) { + String key = comp.getProperty("ld6_SeqNum"); + String value = comp.getProperty("ld6_ChangePerson"); + personMap.put(key, value); + } + } + } + + private void loadUI() throws Exception { + this.setLayout(new BorderLayout()); + LinkedHashMap> map = new LinkedHashMap>(); + + ArrayList specialList = new ArrayList(); + + KUtil.getModelVale(map,form,null,propNames); + + KUtil.dealSpecialModelValue(specialList,prefName,"ld6_YNChange",1); + tableModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0 || column == 1 || column == 2) { + return false; + }else if(specialList.contains(row) && column == 3) { + return false; + } + return true; + } + }; + tableModel.setDataVector(null, header); + JTable table_data = new JTable(tableModel); + JComboBox ynChangeComboBox = new JComboBox(); + JComboBox changeStateComboBox = new JComboBox(); + HashMap ynChangeMap = new LinkedHashMap(); + HashMap changeStateMap = new LinkedHashMap(); + KUtil.getLov(ynChangeMap,ynChangeLovName,ynChangeComboBox); + KUtil.getLov(changeStateMap,changeStateLovName,changeStateComboBox); + table_data.getColumnModel().getColumn(YNCHANGE_INDEX).setCellEditor(new DefaultCellEditor(ynChangeComboBox)); + table_data.getColumnModel().getColumn(CHANGE_STATE_INDEX).setCellEditor(new DefaultCellEditor(changeStateComboBox)); + + //DatePicker + StringValue sv = new FormatStringValue(sdf); + TableCellRenderer r = new DefaultTableRenderer(sv); + table_data.getColumnModel().getColumn(REQUIRE_FINISH_TIME_INDEX).setCellEditor(new DatePickerCellEditor(sdf)); + table_data.getColumnModel().getColumn(REQUIRE_FINISH_TIME_INDEX).setCellRenderer(r); + table_data.getColumnModel().getColumn(ACTUAL_FINISH_TIME_INDEX).setCellEditor(new DatePickerCellEditor(sdf)); + table_data.getColumnModel().getColumn(ACTUAL_FINISH_TIME_INDEX).setCellRenderer(r); + //п + table_data.getColumnModel().getColumn(0).setPreferredWidth(10); + table_data.getColumnModel().getColumn(1).setPreferredWidth(60); + table_data.getColumnModel().getColumn(2).setPreferredWidth(180); + table_data.getColumnModel().getColumn(3).setPreferredWidth(40); + table_data.getColumnModel().getColumn(4).setPreferredWidth(80); + table_data.getColumnModel().getColumn(5).setPreferredWidth(80); + table_data.getColumnModel().getColumn(6).setPreferredWidth(80); + //õԭֵ + String[][] values = new String[map.size()][propNames.length]; + System.out.println("map ===>"+map.toString()); + //õҪ + ArrayList beanList = new ArrayList(); + for (Entry> entry : map.entrySet()) { + ArrayList arrayList = entry.getValue(); + FormBean bean = new FormBean(arrayList); + beanList.add(bean); + } + Collections.sort(beanList); + //תΪҪݣŵtableModel + for (int i = 0; i < beanList.size(); i++) { + FormBean formBean = beanList.get(i); + for (int j = 0; j < propNames.length; j++) { + switch (j) { + case 0: + values[i][j] = formBean.getNum(); + break; + case 1: + values[i][j] = formBean.getChangeTaskName(); + break; + case 2: + values[i][j] = formBean.getTask(); + break; + case 3: + values[i][j] = formBean.getYnChange(); + break; + case 4: + values[i][j] = formBean.getChangePerson(); + break; + case 5: + values[i][j] = formBean.getTaskRequireDesc(); + break; + case 6: + values[i][j] = formBean.getHandlePerson(); + break; + case 7: + values[i][j] = formBean.getChangeState(); + break; + case 8: + values[i][j] = formBean.getRequireFinishTime(); + break; + case 9: + values[i][j] = formBean.getActualFinishTime(); + break; + case 10: + values[i][j] = formBean.getChangeRemarks(); + break; + default: + values[i][j] = ""; + break; + } + } + tableModel.addRow(values[i]); + } + table_data.setSurrendersFocusOnKeystroke(true); + AbstractAIFApplication app1 = AIFUtility.getCurrentApplication(); + TCSession session1 = (TCSession) app1.getSession(); + String[] value1 = session1.getPreferenceService().getStringValues("LD_CNCIFormRemarks_Config"); + + int remarkWidth = Integer.parseInt(value1[0]); + int maxRemarkLength = Integer.parseInt(value1[1]); + //ñעп + table_data.getColumnModel().getColumn(CHANGE_REMARKS_INDEX).setPreferredWidth(remarkWidth); + //ӱעеı༭ͼ + table_data.getColumnModel().getColumn(CHANGE_REMARKS_INDEX).setCellEditor(new DefaultCellEditor(new JTextField()) { + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + final JTextField editor = (JTextField) super.getTableCellEditorComponent(table, value, isSelected, row, column); + editor.setDocument(new PlainDocument() { + public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { + if (editor.getText().length() + str.length() <= maxRemarkLength) { + super.insertString(offs, str, a); + } else { + MessageBox.post("ַ", "ʾ", MessageBox.INFORMATION); + } + } + }); + return editor; + } + }); + //ӱעеȾ + table_data.getColumnModel().getColumn(CHANGE_REMARKS_INDEX).setCellRenderer(new DefaultTableCellRenderer() { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JTextArea renderer = new JTextArea(); + renderer.setText(value == null ? "" : value.toString()); + renderer.setLineWrap(true); + renderer.setWrapStyleWord(true); + return renderer; + } + }); + table_data.getColumnModel().getColumn(CHANGE_REMARKS_INDEX).setCellEditor(new DefaultCellEditor(new JTextField()) { + private JTextArea editor; + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + editor = new JTextArea(); + editor.setText(value == null ? "" : value.toString()); + editor.setLineWrap(true); + editor.setWrapStyleWord(true); + return editor; + } + @Override + public boolean isCellEditable(EventObject e) { + if (e instanceof MouseEvent) { + return ((MouseEvent)e).getClickCount() >= 2; + } + return super.isCellEditable(e); + } + @Override + public Object getCellEditorValue() { + String text = editor.getText(); + editor.setRows(1); // ༭ĸ߶ȵΪи߶ + return text; + } + // ʡ + }); + + + + + + //ѡֵӰУȡѡֵõMap<,صб>; + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String[] value = session.getPreferenceService().getStringValues("LD_CNCIFormAttribute_Hide"); + if(value!=null && value.length>0) { + Map> hideMap = new HashMap>(); + for (int i = 0; i < value.length; i++) { + List attrList = new ArrayList(); + System.out.println(value[i]); + String[] split = value[i].split(":"); + if(split.length>1) { + String types = split[0]; + System.out.println("type:"+types); + String[] split2 = split[1].split(","); + for(int j=0;j> entry : hideMap.entrySet()) { + String key = entry.getKey(); + //ָkey + String[] split1 = key.split("-"); + String formType = split1[0]; + System.out.println("formType:"+formType); + String tableType = split1[1]; + System.out.println("tableType"+tableType); + String stringProperty = form.getStringProperty("object_type"); + System.out.println("ѡб"+stringProperty); + if(formType.equals(form.getStringProperty("object_type"))) { + TCComponent[] tables = form.getReferenceListProperty(tableType); + if(tables!=null) { + //ҵkeyֵӦ + List value2 = entry.getValue(); + for (int i = 0; i < value2.size(); i++) { + String str = value2.get(i); + int index = Arrays.binarySearch(propNames, str); + System.out.println("index"+index); + hideList.add(index); + // + hideColumn(table_data, index); + } + } + } + } + }else { + System.out.println("ѡΪջ򲻴"); + } + + table_data.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) {// 굥ʱӦ + // õѡееֵ + int r = table_data.getSelectedRow(); + int c = table_data.getSelectedColumn(); + if(c == CHANGE_PERSON_INDEX) { + String userString = new KOrgDialog("").getUserString(); + String condition = table_data.getValueAt( r, YNCHANGE_INDEX).toString(); + System.err.println("ǰֵΪ" + condition + "======" + userString); + if(condition.equals("") && !userString.isEmpty()) { + table_data.setValueAt(userString, r, c); + } + } + } + }); + tableModel.addTableModelListener(new TableModelListener(){ + @Override + public void tableChanged(TableModelEvent e) { + if (e.getType() == TableModelEvent.UPDATE) { + // ҵ߼ + if (e.getColumn() == YNCHANGE_INDEX) { + String newvalue = table_data.getValueAt(e.getLastRow(), e.getColumn()).toString(); + if (newvalue.equals("")) { + table_data.setValueAt("", e.getLastRow(), CHANGE_PERSON_INDEX); + }else { + String id = table_data.getValueAt(table_data.getSelectedRow(),0).toString(); + table_data.setValueAt(personMap.get(id), e.getLastRow(), CHANGE_PERSON_INDEX); + } + } + else if(e.getColumn() == REQUIRE_FINISH_TIME_INDEX) { + String newvalue = table_data.getValueAt(e.getFirstRow(), e.getColumn()).toString(); + System.out.println(newvalue); + //table_data.setValueAt(newvalue, e.getLastRow(), REQUIRE_FINISH_TIME_INDEX); + } + } + + } + }); + table_data.setDefaultRenderer(Object.class, new TableViewRenderer()); + JScrollPane scroll = new JScrollPane(table_data); + + saveButton = new JButton(""); + saveButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg) { + save(); + } + }); + + displayButton = new JButton("ʾ"); + displayButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg) { + if(flag) { + //ʾصУmap + for (Map.Entry>entry : displayColumn.entrySet()) { + Integer key = entry.getKey(); + List val = entry.getValue(); + TableColumn col = table_data.getColumnModel().getColumn(key); // ȡҪص + //ʾ + col.setMinWidth(val.get(0)); // СΪ0 + col.setMaxWidth(val.get(1)); // Ϊ0 + col.setWidth(val.get(2)); // õǰΪ0 + col.setPreferredWidth(val.get(3)); // ѡΪ0 + } + //ı䰴ť + displayButton.setText(""); + flag = false; + }else { + //ʾص + for(int index : hideList) { + hideColumn(table_data, index); + } + //ı䰴ť + displayButton.setText("ʾ"); + flag = true; + } + + + } + }); + JPanel panel = new JPanel(); + panel.add(saveButton); + panel.add(displayButton); + this.add(scroll,BorderLayout.CENTER); + this.add(panel,BorderLayout.SOUTH); + this.setVisible(true); + // + new Thread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + do { + + if(CIForm.this.getParent()!=null)break; + else + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }while(true); + String tempstr = CIForm.this.getParent().getParent().getParent().getParent().getParent()!=null?CIForm.this.getParent().getParent().getParent().getParent().getParent().getClass().toString():""; + + if(!"".equals(tempstr)) { + System.out.println("tempstr:"+tempstr); + if(tempstr.equals("class com.teamcenter.rac.commands.open.OpenFormDialog")) { + lastDialog = (OpenFormDialog) CIForm.this.getParent().getParent().getParent().getParent().getParent(); + Container container = CIForm.this.getParent().getParent().getParent().getParent(); + final JFrame frame = new JFrame(); + frame.add(container); + frame.setExtendedState(JFrame.MAXIMIZED_BOTH); + frame.pack(); + // ʾǰ + //frame.setAlwaysOnTop(true); + frame.setVisible(true); + + lastDialog.setVisible(false); + + lastDialog.addWindowListener(new WindowListener() { + + @Override + public void windowOpened(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowIconified(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowDeiconified(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowDeactivated(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowClosing(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowClosed(WindowEvent e) { + // TODO Auto-generated method stub + System.out.println("ڹر"); + frame.dispose(); + } + + @Override + public void windowActivated(WindowEvent e) { + // TODO Auto-generated method stub + + } + }); + } +// else if(tempstr.equals("class javax.swing.JFrame")) { +// JFrame frame = (JFrame) QuickChangeForm.this.getParent().getParent().getParent().getParent().getParent(); +// Container container = QuickChangeForm.this.getParent().getParent().getParent().getParent(); +// lastDialog.add(container); +// frame.dispose(); +// } + } + + + }}).start(); + } + + @Override + public void saveRendering() { + save(); + } + + public void hideColumn (JTable table,int column) { + TableColumn col = table.getColumnModel().getColumn(column); // ȡҪص + + //ȡӰе + List displayList = new ArrayList(); + int minWidth = col.getMinWidth(); + int maxWidth = col.getMaxWidth(); + int width2 = col.getWidth(); + int preferredWidth = col.getPreferredWidth(); + displayList.add(minWidth); + displayList.add(maxWidth); + displayList.add(width2); + displayList.add(preferredWidth); + displayColumn.put(column, displayList); + //Ӱ + col.setMinWidth(0); // СΪ0 + col.setMaxWidth(0); // Ϊ0 + col.setWidth(0); // õǰΪ0 + col.setPreferredWidth(0); // ѡΪ0 + } + + public void save() { + try { + List component = new ArrayList(); + int err = 0; + StringBuilder sb = new StringBuilder(); + DataManagementService service = DataManagementService + .getService((TCSession) AIFUtility.getCurrentApplication().getSession()); + CreateIn[] newIn = new CreateIn[tableModel.getRowCount()]; + for (int i = 0; i < tableModel.getRowCount(); i++) { + CreateIn in = new CreateIn(); + Map propMap = new HashMap(); + Map propDateMap = new HashMap(); + for (int j = 0; j < propNames.length; j++) { + if("ld6_YNChange".equals(propNames[j])) { + String val = tableModel.getValueAt(i, j).toString(); + if(val.isEmpty()) { + err++; + if("".equals(sb.toString())) { + sb.append(i+1); + }else { + sb.append(""); + sb.append(i+1); + } + break; + } + if("".equals(val)) { + String user = tableModel.getValueAt(i, j + 1).toString(); + if("".equals(user.trim())) { + err++; + if("".equals(sb.toString())) { + sb.append(i+1); + }else { + sb.append(""); + sb.append(i+1); + } + break; + } + } + } + if(j == REQUIRE_FINISH_TIME_INDEX || j == ACTUAL_FINISH_TIME_INDEX) { + Calendar cal = Calendar.getInstance(); + String value = tableModel.getValueAt(i, j) == null ? "" : tableModel.getValueAt(i, j).toString(); + if(!value.isEmpty()) { + if(value.contains("CST")) { + cal.setTime(cst.parse(value)); + propDateMap.put(propNames[j],cal); + }else { + cal.setTime(sdf.parse(value)); + propDateMap.put(propNames[j],cal); + } + } + }else { + propMap.put(propNames[j],tableModel.getValueAt(i, j) == null ? "" : tableModel.getValueAt(i, j).toString()); + } + + } + System.out.println(propMap); + in.data.boName = "LD6_TableRow"; + in.data.stringProps = propMap; + in.data.dateProps = propDateMap; + newIn[i] = in; + } + + if(err > 0) { + MessageBox.post(""+sb.toString()+"δָ˻ǷҪֵΪ,д󱣴","ʾ",MessageBox.INFORMATION); + }else { + CreateResponse response = service.createObjects(newIn); + System.out.println(response.serviceData.sizeOfCreatedObjects()); + if (response.serviceData.sizeOfCreatedObjects() > 0) { + System.out.println("CreateResponse"); + int length = response.serviceData.sizeOfCreatedObjects(); + for (int i = 0; i < length; i++) { + component.add(response.output[i].objects[0]); + } + } + form.getTCProperty("ld6_ChangeTable").setReferenceValueArray(component.toArray(new TCComponent[component.size()])); + MessageBox.post("ɹ","ʾ",MessageBox.INFORMATION); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} diff --git a/src/com/net/connor/ld/plm/ld05/CNForm.java b/src/com/net/connor/ld/plm/ld05/CNForm.java new file mode 100644 index 0000000..beee447 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/CNForm.java @@ -0,0 +1,631 @@ +package com.net.connor.ld.plm.ld05; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Toolkit; +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.Arrays; +import java.util.Calendar; +import java.util.Collections; +import java.util.EventObject; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.PlainDocument; + +import org.apache.poi.xssf.eventusermodel.examples.FromHowTo; +import org.jdesktop.swingx.renderer.DefaultTableRenderer; +import org.jdesktop.swingx.renderer.FormatStringValue; +import org.jdesktop.swingx.renderer.StringValue; +import org.jdesktop.swingx.table.DatePickerCellEditor; + +import com.net.connor.ld.plm.bean.FormBean; +import com.net.connor.ld.plm.bean.MyButtonRender; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.ICommandListener; +import com.teamcenter.rac.aif.ICommandListenerEvent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.commands.open.OpenFormPanel; +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2007_01.DataManagement.GetDatasetCreationRelatedInfoResponse; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; + +import cn.net.connor.ld.plm.KUtil; +import k.util.KOrgDialog; + + +@SuppressWarnings("serial") +public class CNForm extends AbstractRendering implements FormModel{ + private OpenFormDialog lastDialog; + private Map> displayColumn = new HashMap>(); + private Map personMap = new HashMap(); + private List hideList = new ArrayList(); + private Boolean flag = true; + DefaultTableModel tableModel = null; + private TCComponent form; + + public CNForm(TCComponent form) throws Exception { + super(); + this.form = form; + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + try { + form.okToCheckout(); + getdata(); + loadUI(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + public void getdata() throws Exception { + //ȡ + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String prefName = "Connor_FormModel";//ݺ͸ģ + String[] prefVals = KUtil.getPrefVals(session, prefName); + String puid = prefVals[0]; + TCComponent component = session.stringToComponent(puid); + if(component instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) component; + //ȡ˵ֵŶӦ + TCComponent[] referenceListProperty = form.getReferenceListProperty("ld6_ChangeTable"); + for(TCComponent comp : referenceListProperty) { + String key = comp.getProperty("ld6_SeqNum"); + String value = comp.getProperty("ld6_ChangePerson"); + personMap.put(key, value); + } + } + } + private void loadUI() throws Exception { + this.setLayout(new BorderLayout()); + LinkedHashMap> map = new LinkedHashMap>(); + ArrayList specialList = new ArrayList(); + KUtil.getModelVale(map,form,null,propNames); + KUtil.dealSpecialModelValue(specialList,prefName,"ld6_YNChange",0); + //شǷҪġ ΪǡʱõԪܱ༭ĬֵΪ + tableModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0 || column == 1 || column == 2) { + return false; + }else if(specialList.contains(row) && column == 3) { + return false; + } + return true; + } + }; + tableModel.setDataVector(null, header); + JTable table_data = new JTable(tableModel); + JComboBox ynChangeComboBox = new JComboBox(); + JComboBox changeStateComboBox = new JComboBox(); + HashMap ynChangeMap = new LinkedHashMap(); + HashMap changeStateMap = new LinkedHashMap(); + KUtil.getLov(ynChangeMap,ynChangeLovName,ynChangeComboBox); + KUtil.getLov(changeStateMap,changeStateLovName,changeStateComboBox); + table_data.getColumnModel().getColumn(YNCHANGE_INDEX).setCellEditor(new DefaultCellEditor(ynChangeComboBox)); + table_data.getColumnModel().getColumn(CHANGE_STATE_INDEX).setCellEditor(new DefaultCellEditor(changeStateComboBox)); + //DatePicker + + StringValue sv = new FormatStringValue(df); + TableCellRenderer r = new DefaultTableRenderer(sv); + table_data.getColumnModel().getColumn(REQUIRE_FINISH_TIME_INDEX).setCellEditor(new DatePickerCellEditor(df)); + table_data.getColumnModel().getColumn(REQUIRE_FINISH_TIME_INDEX).setCellRenderer(r); + table_data.getColumnModel().getColumn(ACTUAL_FINISH_TIME_INDEX).setCellEditor(new DatePickerCellEditor(df)); + table_data.getColumnModel().getColumn(ACTUAL_FINISH_TIME_INDEX).setCellRenderer(r); + //п + table_data.getColumnModel().getColumn(0).setPreferredWidth(10); + table_data.getColumnModel().getColumn(1).setPreferredWidth(60); + table_data.getColumnModel().getColumn(2).setPreferredWidth(180); + table_data.getColumnModel().getColumn(3).setPreferredWidth(40); + table_data.getColumnModel().getColumn(4).setPreferredWidth(80); + table_data.getColumnModel().getColumn(5).setPreferredWidth(80); + table_data.getColumnModel().getColumn(6).setPreferredWidth(80); + + String[][] values = new String[map.size()][propNames.length]; + //õԭֵ + System.out.println("map ===>"+map.toString()); +// ArrayList> formList = new ArrayList>(); +// getFormValue(formList); + //õҪ + ArrayList beanList = new ArrayList(); + for (Entry> entry : map.entrySet()) { + ArrayList arrayList = entry.getValue(); + FormBean bean = new FormBean(arrayList); + beanList.add(bean); + } + Collections.sort(beanList); + //תΪҪݣŵtableModel + for (int i = 0; i < beanList.size(); i++) { + FormBean formBean = beanList.get(i); + for (int j = 0; j < propNames.length; j++) { + switch (j) { + case 0: + values[i][j] = formBean.getNum(); + break; + case 1: + values[i][j] = formBean.getChangeTaskName(); + break; + case 2: + values[i][j] = formBean.getTask(); + break; + case 3: + values[i][j] = formBean.getYnChange(); + break; + case 4: + values[i][j] = formBean.getChangePerson(); + break; + case 5: + values[i][j] = formBean.getTaskRequireDesc(); + break; + case 6: + values[i][j] = formBean.getHandlePerson(); + break; + case 7: + values[i][j] = formBean.getChangeState(); + break; + case 8: + values[i][j] = formBean.getRequireFinishTime(); + break; + case 9: + values[i][j] = formBean.getActualFinishTime(); + break; + case 10: + values[i][j] = formBean.getChangeRemarks(); + break; + default: + values[i][j] = ""; + break; + } + } + tableModel.addRow(values[i]); + } + table_data.setSurrendersFocusOnKeystroke(true); + + AbstractAIFApplication app1 = AIFUtility.getCurrentApplication(); + TCSession session1 = (TCSession) app1.getSession(); + String[] value1 = session1.getPreferenceService().getStringValues("LD_CNCIFormRemarks_Config"); + + int remarkWidth = Integer.parseInt(value1[0]); + int maxRemarkLength = Integer.parseInt(value1[1]); + + //ñעп + table_data.getColumnModel().getColumn(CHANGE_REMARKS_INDEX).setPreferredWidth(remarkWidth); + //ӱעеı༭ͼ + table_data.getColumnModel().getColumn(CHANGE_REMARKS_INDEX).setCellEditor(new DefaultCellEditor(new JTextField()) { + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + final JTextField editor = (JTextField) super.getTableCellEditorComponent(table, value, isSelected, row, column); + editor.setDocument(new PlainDocument() { + public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { + if (editor.getText().length() + str.length() <= maxRemarkLength) { + super.insertString(offs, str, a); + } else { + MessageBox.post("ַ", "ʾ", MessageBox.INFORMATION); + } + } + }); + return editor; + } + }); + //ӱעеȾ + table_data.getColumnModel().getColumn(CHANGE_REMARKS_INDEX).setCellRenderer(new DefaultTableCellRenderer() { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JTextArea renderer = new JTextArea(); + renderer.setText(value == null ? "" : value.toString()); + renderer.setLineWrap(true); + renderer.setWrapStyleWord(true); + return renderer; + } + }); + table_data.getColumnModel().getColumn(CHANGE_REMARKS_INDEX).setCellEditor(new DefaultCellEditor(new JTextField()) { + private JTextArea editor; + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + editor = new JTextArea(); + editor.setText(value == null ? "" : value.toString()); + editor.setLineWrap(true); + editor.setWrapStyleWord(true); + return editor; + } + @Override + public boolean isCellEditable(EventObject e) { + if (e instanceof MouseEvent) { + return ((MouseEvent)e).getClickCount() >= 2; + } + return super.isCellEditable(e); + } + @Override + public Object getCellEditorValue() { + String text = editor.getText(); + editor.setRows(1); // ༭ĸ߶ȵΪи߶ + return text; + } + // ʡ + }); + + + //ѡֵӰУȡѡֵõMap<,صб>; + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String[] value = session.getPreferenceService().getStringValues("LD_CNCIFormAttribute_Hide"); + if(value!=null && value.length>0) { + Map> hideMap = new HashMap>(); + for (int i = 0; i < value.length; i++) { + List attrList = new ArrayList(); + System.out.println(value[i]); + String[] split = value[i].split(":"); + if(split.length>1) { + String types = split[0]; + System.out.println("type:"+types); + String[] split2 = split[1].split(","); + for(int j=0;j> entry : hideMap.entrySet()) { + String key = entry.getKey(); + //ָkey + String[] split1 = key.split("-"); + String formType = split1[0]; + System.out.println("formType:"+formType); + String tableType = split1[1]; + System.out.println("tableType"+tableType); + String stringProperty = form.getStringProperty("object_type"); + System.out.println("ѡб"+stringProperty); + if(formType.equals(form.getStringProperty("object_type"))) { + TCComponent[] tables = form.getReferenceListProperty(tableType); + if(tables!=null) { + //ҵkeyֵӦ + List value2 = entry.getValue(); + for (int i = 0; i < value2.size(); i++) { + String str = value2.get(i); + int index = Arrays.binarySearch(propNames, str); + System.out.println("index"+index); + hideList.add(index); + // + hideColumn(table_data, index); + } + } + } + } + }else { + System.out.println("ѡΪջ򲻴"); + } + table_data.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) {// 굥ʱӦ + // õѡееֵ + int r = table_data.getSelectedRow(); + int c = table_data.getSelectedColumn(); + if(c == CHANGE_PERSON_INDEX) { + String userString = new KOrgDialog("").getUserString(); + String condition = table_data.getValueAt( r, YNCHANGE_INDEX).toString(); + System.err.println("ǰֵΪ" + condition + "======" + userString); + if(condition.equals("") && !userString.isEmpty()) { + table_data.setValueAt(userString, r, c); + } + } + } + }); + tableModel.addTableModelListener(new TableModelListener(){ + @Override + public void tableChanged(TableModelEvent e) { + if(e.getType() == TableModelEvent.UPDATE){ + //ҵ߼ + if(e.getColumn() == YNCHANGE_INDEX){ + String newvalue = table_data.getValueAt(e.getLastRow(),e.getColumn()).toString(); + if(newvalue.equals("")) { + table_data.setValueAt("", e.getLastRow(), CHANGE_PERSON_INDEX); + }else { + String id = table_data.getValueAt(table_data.getSelectedRow(),0).toString(); + table_data.setValueAt(personMap.get(id), e.getLastRow(), CHANGE_PERSON_INDEX); + } + } + } + + } + }); + + table_data.setDefaultRenderer(Object.class, new TableViewRenderer()); + JScrollPane scroll = new JScrollPane(table_data); + JButton saveButton = new JButton(""); + saveButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + save(); + } + }); + JButton displayButton = new JButton("ʾ"); + displayButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg) { + if(flag) { + //ʾصУmap + for (Map.Entry>entry : displayColumn.entrySet()) { + Integer key = entry.getKey(); + List val = entry.getValue(); + TableColumn col = table_data.getColumnModel().getColumn(key); // ȡҪص + //ʾ + col.setMinWidth(val.get(0)); // СΪ0 + col.setMaxWidth(val.get(1)); // Ϊ0 + col.setWidth(val.get(2)); // õǰΪ0 + col.setPreferredWidth(val.get(3)); // ѡΪ0 + } + //ı䰴ť + displayButton.setText(""); + flag = false; + }else { + //ʾص + for(int index : hideList) { + hideColumn(table_data, index); + } + //ı䰴ť + displayButton.setText("ʾ"); + flag = true; + } + + } + }); + JPanel panel = new JPanel(); + panel.add(saveButton); + panel.add(displayButton); + this.add(scroll,BorderLayout.CENTER); + this.add(panel,BorderLayout.SOUTH); + this.setVisible(true); + // + new Thread(new Runnable() { + @Override + public void run() { + // TODO Auto-generated method stub + do { + + if(CNForm.this.getParent()!=null)break; + else + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }while(true); + String tempstr = CNForm.this.getParent().getParent().getParent().getParent().getParent()!=null?CNForm.this.getParent().getParent().getParent().getParent().getParent().getClass().toString():""; + + if(!"".equals(tempstr)) { + System.out.println("tempstr:"+tempstr); + if(tempstr.equals("class com.teamcenter.rac.commands.open.OpenFormDialog")) { + lastDialog = (OpenFormDialog) CNForm.this.getParent().getParent().getParent().getParent().getParent(); + + Container container = CNForm.this.getParent().getParent().getParent().getParent(); + final JFrame frame = new JFrame(); + frame.add(container); + frame.setExtendedState(JFrame.MAXIMIZED_BOTH); + frame.pack(); + // ʾǰ + //frame.setAlwaysOnTop(true); + + frame.setVisible(true); + lastDialog.setVisible(false); + + + + lastDialog.addWindowListener(new WindowListener() { + + @Override + public void windowOpened(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowIconified(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowDeiconified(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowDeactivated(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowClosing(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowClosed(WindowEvent e) { + // TODO Auto-generated method stub + System.out.println("ڹر"); + frame.dispose(); + } + + @Override + public void windowActivated(WindowEvent e) { + // TODO Auto-generated method stub + + } + }); + } +// else if(tempstr.equals("class javax.swing.JFrame")) { +// JFrame frame = (JFrame) QuickChangeForm.this.getParent().getParent().getParent().getParent().getParent(); +// Container container = QuickChangeForm.this.getParent().getParent().getParent().getParent(); +// lastDialog.add(container); +// frame.dispose(); +// } + } + + + }}).start(); + } + + public void hideColumn (JTable table,int column) { + TableColumn col = table.getColumnModel().getColumn(column); // ȡҪص + + //ȡӰе + List displayList = new ArrayList(); + int minWidth = col.getMinWidth(); + int maxWidth = col.getMaxWidth(); + int width2 = col.getWidth(); + int preferredWidth = col.getPreferredWidth(); + displayList.add(minWidth); + displayList.add(maxWidth); + displayList.add(width2); + displayList.add(preferredWidth); + displayColumn.put(column, displayList); + //Ӱ + col.setMinWidth(0); // СΪ0 + col.setMaxWidth(0); // Ϊ0 + col.setWidth(0); // õǰΪ0 + col.setPreferredWidth(0); // ѡΪ0 + } + + @Override + public void saveRendering() { + save(); + } + + public void save() { + try { + List component = new ArrayList(); + int err = 0; + StringBuilder sb = new StringBuilder(); + DataManagementService service = DataManagementService + .getService((TCSession) AIFUtility.getCurrentApplication().getSession()); + CreateIn[] newIn = new CreateIn[tableModel.getRowCount()]; + for (int i = 0; i < tableModel.getRowCount(); i++) { + CreateIn in = new CreateIn(); + Map propMap = new HashMap(); + Map propDateMap = new HashMap(); + for (int j = 0; j < propNames.length; j++) { + if("ld6_YNChange".equals(propNames[j])) { + String val = tableModel.getValueAt(i, j).toString(); + if(val.isEmpty()) { + err++; + if("".equals(sb.toString())) { + sb.append(i+1); + }else { + sb.append(""); + sb.append(i+1); + } + break; + } + if("".equals(val)) { + String user = tableModel.getValueAt(i, j + 1).toString(); + if("".equals(user.trim())) { + err++; + if("".equals(sb.toString())) { + sb.append(i+1); + }else { + sb.append(""); + sb.append(i+1); + } + break; + } + } + } + if(j == REQUIRE_FINISH_TIME_INDEX || j == ACTUAL_FINISH_TIME_INDEX) { + Calendar cal = Calendar.getInstance(); + String value = tableModel.getValueAt(i, j) == null ? "" : tableModel.getValueAt(i, j).toString(); + if(!value.isEmpty()) { + if(value.contains("CST")) { + cal.setTime(cst.parse(value)); + propDateMap.put(propNames[j],cal); + }else { + cal.setTime(sdf.parse(value)); + propDateMap.put(propNames[j],cal); + } + } + }else { + propMap.put(propNames[j],tableModel.getValueAt(i, j) == null ? "" : tableModel.getValueAt(i, j).toString()); + } + + } + System.out.println(propMap); + in.data.boName = "LD6_TableRow"; + in.data.stringProps = propMap; + in.data.dateProps = propDateMap; + newIn[i] = in; + } + if(err > 0) { + MessageBox.post(""+sb.toString()+"δָ˻ǷҪֵΪ,д󱣴","ʾ",MessageBox.INFORMATION); + return; + }else { + CreateResponse response = service.createObjects(newIn); + System.out.println(response.serviceData.sizeOfCreatedObjects()); + if (response.serviceData.sizeOfCreatedObjects() > 0) { + System.out.println("CreateResponse"); + int length = response.serviceData.sizeOfCreatedObjects(); + for (int i = 0; i < length; i++) { + component.add(response.output[i].objects[0]); + } + } + form.getTCProperty("ld6_ChangeTable").setReferenceValueArray(component.toArray(new TCComponent[component.size()])); + MessageBox.post("ɹ","ʾ",MessageBox.INFORMATION); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + +} diff --git a/src/com/net/connor/ld/plm/ld05/CreateCLFormCommand.java b/src/com/net/connor/ld/plm/ld05/CreateCLFormCommand.java new file mode 100644 index 0000000..e62e191 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/CreateCLFormCommand.java @@ -0,0 +1,76 @@ +package com.net.connor.ld.plm.ld05; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ld.plm.KCommand; +import cn.net.connor.ld.plm.KUtil; + +public class CreateCLFormCommand extends KCommand{ + + public CreateCLFormCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + TCSession session = (TCSession) app.getSession(); + try { + TCComponentItemRevision revision = null; + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(!targetComponent.getType().equals("LD6_CRRevision")) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ汾"); + return; + } + else { + revision = (TCComponentItemRevision) targetComponent; + } + String prefName = "Connor_FormModel";//ݺ͸ģ + try { + String[] prefVals = KUtil.getPrefVals(session, prefName); + String puid = prefVals[1]; + TCComponent component = session.stringToComponent(puid); + if(component instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) component; + TCComponentForm saveAs = form.saveAs(null); + //ǷҪһиΪ񣬽һ + TCComponent[] referenceListProperty = saveAs.getReferenceListProperty("ld6_ChangeTable"); + for(TCComponent comp : referenceListProperty) { + comp.setProperty("ld6_YNChange",""); + comp.setProperty("ld6_ChangePerson",""); + } + if(saveAs != null) { + try { + revision.add("LD6_WorkFRelation", saveAs); + MessageBox.post( "ɹ", "ʾ", MessageBox.INFORMATION); + } catch (TCException e) { + // TODO: handle exception + + if(e.getMessage().contains("")) { + MessageBox.post( e.getMessage() , "ʾ", MessageBox.INFORMATION); + } + System.out.println(e.getMessage()); + } + + } + + } +// TCComponentForm newform = formType.create("ش", "", "LD6_CIForm"); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/net/connor/ld/plm/ld05/CreateCNFormCommand.java b/src/com/net/connor/ld/plm/ld05/CreateCNFormCommand.java new file mode 100644 index 0000000..53b2981 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/CreateCNFormCommand.java @@ -0,0 +1,85 @@ +package com.net.connor.ld.plm.ld05; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ld.plm.KCommand; +import cn.net.connor.ld.plm.KUtil; + +public class CreateCNFormCommand extends KCommand{ + + public CreateCNFormCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + TCSession session = (TCSession) app.getSession(); + TCComponentFormType formType; + try { + TCComponentItemRevision revision = null; + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(!targetComponent.getType().equals("LD6_CRRevision")) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ汾"); + return; + } + else { + revision = (TCComponentItemRevision) targetComponent; + } + try { + String prefName = "Connor_FormModel";//ݺ͸ģ + String[] prefVals = KUtil.getPrefVals(session, prefName); + String puid = prefVals[0]; + TCComponent component = session.stringToComponent(puid); + if(component instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) component; + TCComponentForm saveAs = form.saveAs(null); + + + + //ǷҪһиΪ񣬽һ + TCComponent[] referenceListProperty = saveAs.getReferenceListProperty("ld6_ChangeTable"); + for(TCComponent comp : referenceListProperty) { + comp.setProperty("ld6_YNChange",""); + comp.setProperty("ld6_ChangePerson",""); + } + if(saveAs != null) { + try { + revision.add("LD6_WorkFRelation", saveAs); + MessageBox.post( "ɹ", "ʾ", MessageBox.INFORMATION); + } catch (TCException e) { + // TODO: handle exception + + if(e.getMessage().contains("")) { + MessageBox.post( e.getMessage() , "ʾ", MessageBox.INFORMATION); + } + System.out.println(e.getMessage()); + } + + } + + } +// TCComponentForm newform = formType.create("ش", "", "LD6_CIForm"); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// formType = (TCComponentFormType) session.getTypeComponent("LD6_CNForm"); +// TCComponentForm newform = formType.create("ͨ", "", "LD6_CNForm"); +// if(newform != null) { +// revision.add("LD6_WorkFRelation", newform); +// MessageBox.post( "ɹ", "ʾ", MessageBox.INFORMATION); +// } + } catch (Exception e) { + e.printStackTrace(); + } + + } + +} diff --git a/src/com/net/connor/ld/plm/ld05/FormModel.java b/src/com/net/connor/ld/plm/ld05/FormModel.java new file mode 100644 index 0000000..4549502 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/FormModel.java @@ -0,0 +1,41 @@ +package com.net.connor.ld.plm.ld05; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Locale; + +public interface FormModel { +// String[] header = {"","","","ǷҪ","","״̬","ע"}; +// String[] propNames = new String[] +// {"ld6_SeqNum","ld6_ChangeTaskName" ,"ld6_Task","ld6_YNChange","ld6_ChangePerson","ld6_Changestate","ld6_ChangeRemarks"}; + String[] propNames = new String[] { "ld6_SeqNum", "ld6_ChangeTaskName", "ld6_Task", "ld6_YNChange", + "ld6_ChangePerson", "ld6_taskRequireDesc", "ld6_handlePerson", "ld6_Changestate", "ld6_RequireFinshTime", + "ld6_ActualFinishTime", "ld6_ChangeRemarks" }; + + String[] header = new String[] { "", "", "", "ǷҪ", + "", "Ҫ", "", "״̬", "Ҫʱ", + "ʵʱ", "ע" }; + + int SEQ_NUM_INDEX = 0; + int CHANGE_TASK_NAME_INDEX = 1; + int TASK_INDEX = 2; + int YNCHANGE_INDEX = 3; + int CHANGE_PERSON_INDEX = 4; + int TASK_REQUIRE_DESC_INDEX = 5; + int HANDLE_PERSON_INDEX = 6; + int CHANGE_STATE_INDEX = 7; + int REQUIRE_FINISH_TIME_INDEX = 8; + int ACTUAL_FINISH_TIME_INDEX = 9; + int CHANGE_REMARKS_INDEX = 10; + + String ynChangeLovName = "LD6_YN_DLOV"; + String changeStateLovName = "LD6_Changestate_DLOV"; + + String prefName = "Connor_FormModel";//ݺ͸ģ + + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + + DateFormat cst = new SimpleDateFormat("EEE MMM dd HH:mm:ss 'CST' yyyy", Locale.US); +} diff --git a/src/com/net/connor/ld/plm/ld05/MyJframe.java b/src/com/net/connor/ld/plm/ld05/MyJframe.java new file mode 100644 index 0000000..e199abc --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/MyJframe.java @@ -0,0 +1,29 @@ +package com.net.connor.ld.plm.ld05; + +import javax.swing.JFrame; + +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; + +public class MyJframe extends AbstractRendering{ + private JFrame jFrame; + + public MyJframe() throws Exception { + super(); + new JFrame(); + // TODO Auto-generated constructor stub + } + + @Override + public void loadRendering() throws TCException { + // TODO Auto-generated method stub + + } + + @Override + public void saveRendering() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/net/connor/ld/plm/ld05/OrderNumberComparator.java b/src/com/net/connor/ld/plm/ld05/OrderNumberComparator.java new file mode 100644 index 0000000..0998406 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/OrderNumberComparator.java @@ -0,0 +1,12 @@ +package com.net.connor.ld.plm.ld05; + +import java.util.Comparator; + +public class OrderNumberComparator implements Comparator{ + + public int compare(Object o1, Object o2) { + int i = (Integer) o1 - (Integer) o2; + return i; + } + +} \ No newline at end of file diff --git a/src/com/net/connor/ld/plm/ld05/TableViewRenderer.java b/src/com/net/connor/ld/plm/ld05/TableViewRenderer.java new file mode 100644 index 0000000..082e09b --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/TableViewRenderer.java @@ -0,0 +1,49 @@ +package com.net.connor.ld.plm.ld05; + +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.table.TableCellRenderer; + +public class TableViewRenderer extends JTextArea implements TableCellRenderer +{ + public TableViewRenderer() + { + setLineWrap(true); //JTextAreaԶз + setWrapStyleWord(true); + setOpaque(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // 㵱еѸ߶ + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + if (table.getRowHeight(row) != maxPreferredHeight) { // Ϲæ +// if(row == 1) { +// table.setRowHeight(row, 55); +// } +// else if(row == 2) { +// table.setRowHeight(row, 70); +// } +// else if(row == 5) { +// table.setRowHeight(row, 130); +// } +// else if(row == 7) { +// table.setRowHeight(row, 70); +// } +// else { +// table.setRowHeight(row, maxPreferredHeight); +// } + table.setRowHeight(row, maxPreferredHeight); + } + + setText(value == null ? "" : value.toString()); + return this; + } + } \ No newline at end of file diff --git a/src/com/net/connor/ld/plm/ld05/Test.java b/src/com/net/connor/ld/plm/ld05/Test.java new file mode 100644 index 0000000..036faec --- /dev/null +++ b/src/com/net/connor/ld/plm/ld05/Test.java @@ -0,0 +1,136 @@ +package com.net.connor.ld.plm.ld05; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; +import java.util.Vector; + +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import com.teamcenter.rac.common.CalendarPanel; +import com.teamcenter.rac.common.CalendarPanel.DateButton; +import com.teamcenter.rac.common.Messages; +import com.teamcenter.rac.util.date.DateTextFieldViewer; +import com.teamcenter.rac.util.date.DateTextViewer; +import com.teamcenter.rac.util.date.DateTimeViewer; + +import cn.net.connor.ld.plm.DateUtil; +import javafx.scene.control.TableView; + +public class Test { + public static void main(String[] args) throws ParseException { +// WordInsertPicture wordObj = WordInsertPicture.getInstance(); + // wordObj.addWaterMark("c://pngpict//ϰ´ͼ.docx","c://pngpict//shuiyinImage.png"); +// wordObj.addWaterMark("C:\\Users\\caib\\Desktop\\test\\test.doc", +// "C:\\Users\\caib\\Desktop\\test\\a.png"); + +// wordObj.xlsToPdf("C:\\Users\\caib\\Desktop\\test\\test.xls", +// "C:\\Users\\caib\\Desktop\\test\\ok.pdf"); +// WordInsertPicture.excel2PDF("C:\\Users\\admin\\Desktop\\test\\ģ.xlsx", "C:\\Users\\admin\\Desktop\\test\\ok.pdf"); +// wordObj.word2PDF("C:\\Users\\caib\\Desktop\\test\\rcp.docx", +// "C:\\Users\\caib\\Desktop\\test\\okks.pdf"); + +// String inputPath = args[0]; +// String outPath = args[1]; +// if(inputPath.endsWith("doc")||inputPath.endsWith("docx")){ +// wordObj.word2PDF(inputPath, outPath); +// } +// else if(inputPath.endsWith("xls")||inputPath.endsWith("xlsx")){ +// wordObj.excel2PDF(inputPath, outPath); +// } + +// String path = "C:\\Users\\cbang\\Desktop\\\\SubstMacros-MSWord.wsf"; +// String[] paras = new String[] {"C:\\Users\\cbang\\Desktop\\\\2.doc","C:\\Users\\cbang\\Desktop\\\\33.pdf"}; +// runWsf(path,paras); + +// String path1 = "C:\\Users\\cbang\\Desktop\\SCRIPT_DIR\\SubstMacros-MSExcel.wsf"; +// String[] paras1 = +// new String[] {"C:\\Users\\cbang\\Desktop\\SCRIPT_DIR\\1.xls", +// "C:\\Users\\cbang\\Desktop\\SCRIPT_DIR\\2.dat", +// "C:\\Users\\cbang\\Desktop\\SCRIPT_DIR\\44.pdf"}; +// runWsf(path1,paras1); + +// String s = "D:\\new_tcserver\\FMS_CACHE\\ssss.xls"; +// System.out.println(s.substring(0, s.lastIndexOf("\\")) + "\\as.xls"); + + + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm"); + String dateStr = "2021-8-19 17:22"; + LocalDateTime date = LocalDateTime.parse(dateStr, fmt); + LocalDateTime plusDays = date.plusDays(22); + System.err.println(plusDays.getDayOfMonth()); + System.out.println(date.getMonthValue()); + + System.out.println(fmt.parse("2022-9-30 00:00")); + + String s = "Thu Jul 22 23:58:32 CST 2013"; + DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss 'CST' yyyy", Locale.US); + DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + System.out.println(sdf.format(df.parse(s))); + + Messages.getString("projectName.LABEL"); + } + + public static void runWsf(String wsfPath, String[] paras) + { + try { + Vector cmdVector = new Vector(); + cmdVector.add("wscript"); + cmdVector.add(wsfPath); + for (String para : paras) { + cmdVector.add(para); + } + String[] cmd = (String[])cmdVector.toArray(new String[cmdVector.size()]); + for (int i = 0; i < cmd.length; i++) { + + System.out.println(cmd[i]); + } + Runtime runtime = Runtime.getRuntime(); + Process process = runtime.exec(cmd); + process.waitFor(); + } + catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static String getFileFromClass(Class class1, String fileName, String path) throws Exception { + String filePath = (new StringBuilder(String.valueOf(path))).append("\\").append(fileName).toString(); + System.out.println(filePath); + File file = new File(filePath); + if(file.exists()) + file.delete(); + file.createNewFile(); + InputStream inputStream = class1.getResourceAsStream(fileName); + //inputStream = new FileInputStream(getJarPath(fileName)); + OutputStream os = new FileOutputStream(filePath); + int readLen = 0; + byte buf[] = new byte[102400]; + while((readLen = inputStream.read(buf)) != -1) { + os.write(buf, 0, readLen); + } + + os.flush(); + inputStream.close(); + os.close(); + return filePath; + } +} + diff --git a/src/com/net/connor/ld/plm/ld05/普通模板.xlsx b/src/com/net/connor/ld/plm/ld05/普通模板.xlsx new file mode 100644 index 0000000..0298837 Binary files /dev/null and b/src/com/net/connor/ld/plm/ld05/普通模板.xlsx differ diff --git a/src/com/net/connor/ld/plm/ld06/ArrowIcon.java b/src/com/net/connor/ld/plm/ld06/ArrowIcon.java new file mode 100644 index 0000000..50e6a3f --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/ArrowIcon.java @@ -0,0 +1,86 @@ +package com.net.connor.ld.plm.ld06; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Polygon; +import java.util.Comparator; + +import javax.swing.Icon; +import javax.swing.RowSorter; +import javax.swing.RowSorter.SortKey; +import javax.swing.SortOrder; +import javax.swing.table.TableRowSorter; + +import antlr.collections.List; + +public class ArrowIcon implements Icon { + private final SortOrder sortOrder; + private final int size; + private final boolean ascending; + public ArrowIcon(TableRowSorter sorter, int column, boolean ascending) { + this.ascending = ascending; + this.size = 12; + java.util.List sortKeys = sorter.getSortKeys(); + if (sortKeys.size() > 0 && ((RowSorter.SortKey) sortKeys.get(0)).getColumn() == column) { + this.sortOrder = ((RowSorter.SortKey) sortKeys.get(0)).getSortOrder(); + } else { + this.sortOrder = SortOrder.ASCENDING; + } + } + public void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2 = (Graphics2D) g.create(); + g2.translate(x, y); + if (ascending) { + g2.rotate(Math.PI, size / 2.0, size / 2.0); + } + if (sortOrder == SortOrder.ASCENDING) { + g2.draw(createUpTriangle(size)); + } else { + g2.draw(createDownTriangle(size)); + } + g2.dispose(); + } + public int getIconWidth() { + return size; + } + public int getIconHeight() { + return size; + } + private Polygon createUpTriangle(int size) { + Polygon triangle = new Polygon(); + triangle.addPoint(0, size); + triangle.addPoint(size / 2, 0); + triangle.addPoint(size, size); + return triangle; + } + private Polygon createDownTriangle(int size) { + Polygon triangle = new Polygon(); + triangle.addPoint(0, 0); + triangle.addPoint(size, 0); + triangle.addPoint(size / 2, size); + return triangle; + } +} +// +class ColumnSorter implements Comparator { + private final int col; + private final boolean ascending; + public ColumnSorter(int col, boolean ascending) { + this.col = col; + this.ascending = ascending; + } + @Override + public int compare(Object a, Object b) { + if (a instanceof Comparable && b instanceof Comparable) { + if (ascending) { + return ((Comparable) a).compareTo((Comparable) b); + } else { + return ((Comparable) b).compareTo((Comparable) a); + } + } else { + return 0; + } + } +} + diff --git a/src/com/net/connor/ld/plm/ld06/ChangePartDialog.java b/src/com/net/connor/ld/plm/ld06/ChangePartDialog.java new file mode 100644 index 0000000..579943e --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/ChangePartDialog.java @@ -0,0 +1,291 @@ +package com.net.connor.ld.plm.ld06; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.beans.PropertyChangeEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.RowSorterEvent; +import javax.swing.event.RowSorterListener; +import javax.swing.event.TableColumnModelEvent; +import javax.swing.event.TableColumnModelListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.net.connor.ld.plm.bean.CheckBoxTableHeaderRenderer; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.services.rac.core._2011_06.DataManagement.SaveAsOut; + +public class ChangePartDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private ArrayList beanList; + private StringBuffer newType; + private TCComponentItemRevision tarRev; + private DefaultTableModel tableModel; + private JTable table; + private HashSet idSet = new HashSet(); + private HashSet editSet = new HashSet(); + private ArrayList> dataList = new ArrayList>(); + // ͷ + private Object[] columnNames = { "", "", "Ƿ񴴽", "ID", "", "ͻ", "ͻ汾", "ͻͼֽ", "ͻͼֽ汾" }; + private Object[][] rowData; + // еϼ + private ArrayList partList = new ArrayList(); + //忪Map + private Map flagMap = new HashMap(); + + private JRadioButton radioBtn01; + private JRadioButton radioBtn02; + private JButton createButton; + private boolean isUpdating = false; // һ־λжǷڸ± + + public ChangePartDialog(AbstractAIFApplication app, ArrayList beanList, StringBuffer newType, + TCComponentItemRevision tarRev) { + super(false); + this.app = app; + this.beanList = beanList; + this.newType = newType; + this.tarRev = tarRev; + getData(); + init(); + } + + private void init() {this.setTitle("϶"); + this.setPreferredSize(new Dimension(920, 500)); + DefaultTableModel tableModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0 && editSet.contains(row)) { + return true; + } + return false; + } + @Override + public Class getColumnClass(int column) { + if (column == 0) { + return Boolean.class; + } + if (column == 1) { + return Integer.class; + } + return super.getColumnClass(column); + } + }; + tableModel.setDataVector(null, columnNames); + for (Object[] objects : rowData) { + tableModel.addRow(objects); + } + table = new JTable(tableModel); + JCheckBox t_checkBox = new JCheckBox(); + t_checkBox.setSelected(false); + table.getTableHeader().setDefaultRenderer(new CheckBoxTableHeaderRenderer(table, 0, t_checkBox)); + table.getColumnModel().getColumn(0).setPreferredWidth(20); + table.getColumnModel().getColumn(1).setPreferredWidth(40); + table.getColumnModel().getColumn(2).setPreferredWidth(80); + table.getColumnModel().getColumn(3).setPreferredWidth(80); + table.getColumnModel().getColumn(4).setPreferredWidth(280); + table.getColumnModel().getColumn(5).setPreferredWidth(80); + table.getColumnModel().getColumn(6).setPreferredWidth(80); + table.getColumnModel().getColumn(7).setPreferredWidth(80); + table.getColumnModel().getColumn(8).setPreferredWidth(80); + // ѡť + radioBtn01 = new JRadioButton("ѡеϣÿһECN"); + radioBtn02 = new JRadioButton("ѡеϣֻһECN"); + // ť飬ѡťӵ + ButtonGroup btnGroup = new ButtonGroup(); + btnGroup.add(radioBtn01); + btnGroup.add(radioBtn02); + radioBtn01.setSelected(true); + createButton = new JButton(""); + createButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int rowCnt = table.getRowCount(); + ArrayList needList = new ArrayList(); + + for (int i = 0; i < rowCnt; i++) { + if ((boolean) table.getValueAt(i, 0)) { + String keyId = table.getValueAt(i, 3).toString(); + needList.add(flagMap.get(keyId)); + } + } + System.out.println(needList.toString()); + int status = 0; + if (radioBtn01.isSelected()) { + status = 1; + } else if (radioBtn02.isSelected()) { + status = 2; + } + if (needList.size() == 0) { + status = 0; + } + + new DerivedChangeRequestDialog(app, beanList, newType, tarRev, needList, status,""); + disposeDialog(); + } + }); + JPanel panel = new JPanel(); + panel.add(radioBtn01); + panel.add(radioBtn02); + panel.add(createButton); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER, new JScrollPane(table)); + this.add("South", panel); + // Ϊÿһ + TableRowSorter sorter = new TableRowSorter<>(tableModel); + for (int i = 0; i < tableModel.getColumnCount(); i++) { + if (i != 0 && i != 1) { + sorter.setSortable(i, true); + } + } + table.setRowSorter(sorter); + // Ĭϰյ8 + sorter.toggleSortOrder(5); + int rowCount = table.getRowCount(); + for (int i = 0; i < rowCount; i++) { + table.setValueAt(i + 1, i, 1); + } + table.getColumnModel().getColumn(0).setCellRenderer(table.getDefaultRenderer(Boolean.class)); + table.getColumnModel().getColumn(0).setCellEditor(table.getDefaultEditor(Boolean.class)); + // 3. ڱļУһиѡѡ״̬仯¼ȡǰѡек͵ڰеֵ + + table.getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + if (!isUpdating && e.getColumn() == 0) { // һ + isUpdating = true; // ־λΪ true + int row = e.getFirstRow(); + Boolean selected = (Boolean) tableModel.getValueAt(row, 0); + Object value = tableModel.getValueAt(row, 5); + // 4. ģеڰеݣҵ͵ǰеڰֵͬУЩеĵһΪǰеһݵֵ + for (int i = 0; i < tableModel.getRowCount(); i++) { + if(!"".equals(tableModel.getValueAt(i, 2))) { + if (tableModel.getValueAt(i, 5).equals(value)) { + tableModel.setValueAt(selected, i, 0); + } + } + } + isUpdating = false; // ־λΪ false + } + } + }); + // ¸µڶŵ˳ + sorter.addRowSorterListener(new RowSorterListener() { + @Override + public void sorterChanged(RowSorterEvent e) { + int rowCount = table.getRowCount(); + for (int i = 0; i < rowCount; i++) { + table.setValueAt(i + 1, i, 1); + } + } + }); + + // this.pack(); + // this.setLocationRelativeTo(null); + // this.setVisible(true); + showDialog(); +} + + /** + * õе + */ + private void getData() { + try { + getAllId(); + TCComponent[] referenceListProperty = tarRev.getReferenceListProperty("LD6_ChangePartInfo"); + int index = 1; + for (int i = 0; i < referenceListProperty.length; i++) { + String type = referenceListProperty[i].getType(); + System.out.println("ǰΪ: " + type); + if (type.equals("LD6_ProductRevision") || type.equals("LD6_MachinesPRevision")) { + ArrayList list = new ArrayList(); + String num = String.valueOf(index); + list.add(false); + list.add(num); + if (idSet.contains(referenceListProperty[i].getStringProperty("item_id"))) { + list.add(""); + } else { + editSet.add(index - 1); + list.add(""); + } + list.add(referenceListProperty[i].getStringProperty("item_id")); + list.add(referenceListProperty[i].getStringProperty("ld6_materialDesc")); + list.add(referenceListProperty[i].getStringProperty("ld6_clientPartNum")); + list.add(referenceListProperty[i].getStringProperty("ld6_clientPartRev")); + list.add(referenceListProperty[i].getStringProperty("ld6_clientDrawNum")); + list.add(referenceListProperty[i].getStringProperty("ld6_clientDrawRev")); + index++; + dataList.add(list); + partList.add((TCComponentItemRevision) referenceListProperty[i]); + flagMap.put(referenceListProperty[i].getStringProperty("item_id"),(TCComponentItemRevision) referenceListProperty[i]); + } + } + rowData = new Object[dataList.size()][9]; + for (int i = 0; i < dataList.size(); i++) { + for (int j = 0; j < 9; j++) { + rowData[i][j] = dataList.get(i).get(j); + } + } + + } catch (TCException e) { + e.printStackTrace(); + } + + } + + /** + * õECR¡ECN/ECRECN¡϶󡿹ϵеID + * + * @throws TCException + */ + private void getAllId() throws TCException { + TCComponent[] ecns = tarRev.getReferenceListProperty("CMImplementedBy"); + for (int i = 0; i < ecns.length; i++) { + if (ecns[i].getType().equals("LD6_CNRevision")) { + TCComponent[] referenceListProperty = ecns[i].getReferenceListProperty("LD6_ChangePartInfo"); + for (int j = 0; j < referenceListProperty.length; j++) { + String type = referenceListProperty[j].getType(); + if (type.equals("LD6_ProductRevision") || type.equals("LD6_MachinesPRevision")) { + String id = referenceListProperty[j].getStringProperty("item_id"); + idSet.add(id); + } + } + } + } + + } +} diff --git a/src/com/net/connor/ld/plm/ld06/ControlBean.java b/src/com/net/connor/ld/plm/ld06/ControlBean.java new file mode 100644 index 0000000..c5d7cb0 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/ControlBean.java @@ -0,0 +1,95 @@ +package com.net.connor.ld.plm.ld06; + +import java.util.HashMap; + +import com.teamcenter.rac.common.lov.view.components.LOVDisplayer; + +public class ControlBean { + private String propName; + private String propRelName; + private String defaultValue = ""; + private String propType; + private HashMap lovMap; + private String propTo; // дItem/Rev/Form + // private JComboBox combox; + private boolean ifMust = false; + private LOVDisplayer combox; + + public LOVDisplayer getCombox() { + return combox; + } + + public void setCombox(LOVDisplayer combox) { + this.combox = combox; + } + + public boolean isIfMust() { + return ifMust; + } + + public void setIfMust(boolean ifMust) { + this.ifMust = ifMust; + } + +// public JComboBox getCombox() { +// return combox; +// } +// public void setCombox(JComboBox combox) { +// this.combox = combox; +// } + public String getPropTo() { + return propTo; + } + + public void setPropTo(String propTo) { + this.propTo = propTo; + } + + public HashMap getLovMap() { + return lovMap; + } + + public void setLovMap(HashMap lovMap) { + this.lovMap = lovMap; + } + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + public String getPropRelName() { + return propRelName; + } + + public void setPropRelName(String propRelName) { + this.propRelName = propRelName; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getPropType() { + return propType; + } + + public void setPropType(String propType) { + this.propType = propType; + } + + @Override + public String toString() { + return "ControlBean [propName=" + propName + ", propRelName=" + propRelName + ", defaultValue=" + defaultValue + + ", propType=" + propType + ", lovMap=" + lovMap + ", propTo=" + propTo + ", ifMust=" + ifMust + + ", combox=" + combox + "]"; + } + +} diff --git a/src/com/net/connor/ld/plm/ld06/DateTest.java b/src/com/net/connor/ld/plm/ld06/DateTest.java new file mode 100644 index 0000000..90d517c --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/DateTest.java @@ -0,0 +1,18 @@ +package com.net.connor.ld.plm.ld06; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class DateTest { + public static void main(String[] args) { + String ssString = "sss.sss"; + String[] split = ssString.split("\\."); + System.out.println(split.length); + String takeeffect = ""; + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm"); + //LocalDateTime createDate = LocalDateTime.parse(create, fmt); + LocalDateTime takeeffectDate = LocalDateTime.parse(takeeffect, fmt); + + } + +} diff --git a/src/com/net/connor/ld/plm/ld06/DerivedChangeNoticeCommand.java b/src/com/net/connor/ld/plm/ld06/DerivedChangeNoticeCommand.java new file mode 100644 index 0000000..2ac0f42 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/DerivedChangeNoticeCommand.java @@ -0,0 +1,59 @@ +package com.net.connor.ld.plm.ld06; + +import java.util.ArrayList; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ld.plm.KCommand; +import cn.net.connor.ld.plm.KUtil; + +public class DerivedChangeNoticeCommand extends KCommand { + + public DerivedChangeNoticeCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + TCSession session = (TCSession) app.getSession(); + String preName = "Connor_Derive_CN"; + try { + String[] prefVals = KUtil.getPrefVals(session, preName); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + StringBuffer newType = new StringBuffer(); + if (prefVals == null) { + MessageBox.post(preName + "ѡδ", "ʾ", MessageBox.INFORMATION); + return; + } + ArrayList beanList = new ArrayList(); + KUtil.dealPref(prefVals, targetComponent, beanList, newType); + for (ControlBean bean : beanList) { + System.out.println("beanList" + bean.toString()); + } + if (newType.toString().isEmpty()) { + MessageBox.post(preName + "ѡ󣬲½Ķ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beanList.size() == 0) { + MessageBox.post(preName + "ѡ󣬲ѡж͵", "ʾ", MessageBox.INFORMATION); + return; + } + // ⱨ + if (targetComponent.getType().equals("LD6_PRRevision")) { + this.setRunnable(new DerivedChangeRequestDialog(app, beanList, newType, + (TCComponentItemRevision) targetComponent)); + } + // ECR + else if (targetComponent.getType().equals("LD6_CRRevision")) { + this.setRunnable( + new ChangePartDialog(app, beanList, newType, (TCComponentItemRevision) targetComponent)); + } + // new + // DerivedChangeRequestDialog(app,beanList,newType,(TCComponentItemRevision)targetComponent); + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/net/connor/ld/plm/ld06/DerivedChangeRequestCommand.java b/src/com/net/connor/ld/plm/ld06/DerivedChangeRequestCommand.java new file mode 100644 index 0000000..96e9e26 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/DerivedChangeRequestCommand.java @@ -0,0 +1,48 @@ +package com.net.connor.ld.plm.ld06; + +import java.util.ArrayList; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ld.plm.KCommand; +import cn.net.connor.ld.plm.KUtil; + +public class DerivedChangeRequestCommand extends KCommand { + + public DerivedChangeRequestCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + TCSession session = (TCSession) app.getSession(); + String preName = "Connor_Derive_CR"; + try { + String[] prefVals = KUtil.getPrefVals(session, preName); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + StringBuffer newType = new StringBuffer(); + if (prefVals == null) { + MessageBox.post(preName + "ѡδ", "ʾ", MessageBox.INFORMATION); + return; + } + ArrayList beanList = new ArrayList(); + KUtil.dealPref(prefVals, targetComponent, beanList, newType); + System.out.println("newType:" + newType); + if (newType.toString().isEmpty()) { + MessageBox.post(preName + "ѡ󣬲½Ķ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beanList.size() == 0) { + MessageBox.post(preName + "ѡ󣬲ѡж͵", "ʾ", MessageBox.INFORMATION); + return; + } + // new + // DerivedChangeRequestDialog(app,beanList,newType,(TCComponentItemRevision)targetComponent); + this.setRunnable( + new DerivedChangeRequestDialog(app, beanList, newType, (TCComponentItemRevision) targetComponent)); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog.java b/src/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog.java new file mode 100644 index 0000000..160d734 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/DerivedChangeRequestDialog.java @@ -0,0 +1,717 @@ +package com.net.connor.ld.plm.ld06; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.border.LineBorder; + +import com.aspose.words.FieldAutoNumLgl; +import com.aspose.words.Revision; +import com.net.connor.ld.plm.ld05.FormModel; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.lov.view.components.LOVDisplayer; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.soa.exceptions.NotLoadedException; + +import cn.net.connor.ld.plm.KUtil; + +@SuppressWarnings("serial") +public class DerivedChangeRequestDialog extends AbstractAIFDialog implements ActionListener, FormModel { + private static final TCComponent TCComponentForm = null; + protected TCSession session; + private ArrayList beanList; + private String newType; + private JPanel centerPanel; + private JButton okButton; + private JButton celButton; + private TCComponentItemRevision getRev; + private Boolean flag = true; + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private TCComponentItemRevision tarRev; + // ʵֵ + private HashMap beanMap = new HashMap(); + // ѡеϼ + private ArrayList partList = new ArrayList(); + // ѡϵķʽ1Ϊÿһ2Ϊֻһ + private int dealWay = 0; + private String selectId; + // + private Map stringMap = new HashMap(); + private Map dateMap = new HashMap(); + + public DerivedChangeRequestDialog(AbstractAIFApplication app, ArrayList beanList, StringBuffer newType, + TCComponentItemRevision tarRev) { + super(false); + this.session = (TCSession) app.getSession(); + this.beanList = beanList; + this.newType = newType.toString(); + this.tarRev = tarRev; + } + + public DerivedChangeRequestDialog(AbstractAIFApplication app, ArrayList beanList, StringBuffer newType, + TCComponentItemRevision tarRev, ArrayList partList, int dealWay,String selectId) { + super(false); + this.session = (TCSession) app.getSession(); + this.beanList = beanList; + this.newType = newType.toString(); + this.tarRev = tarRev; + this.partList = partList; + this.dealWay = dealWay; + this.selectId = selectId; + run(); + } + + @Override + public void run() { + initUI(); + + } + + private void initUI() { + setPreferredSize(new Dimension(630, 888)); + centerPanel = new JPanel(new PropertyLayout()); + JLabel label1 = new JLabel(" "); + centerPanel.add("1.1.center", label1); + for (int i = 0; i < beanList.size(); i++) { + int row = i + 2; + ControlBean bean = beanList.get(i); + beanMap.put(bean.getPropRelName(), bean); + String labelValue = bean.getPropName(); + if (bean.isIfMust()) { + labelValue = bean.getPropName() + "()"; + } + JLabel oneLabel = new JLabel(" "); + centerPanel.add(row + ".1.center", oneLabel); + JLabel label = new JLabel(labelValue); + label.setPreferredSize(new Dimension(200, 40)); + centerPanel.add(row + ".2.center", label); + + if (bean.getPropType().equals("lov")) { + LOVDisplayer combox = bean.getCombox(); + combox.setName(bean.getPropRelName()); + combox.setPreferredSize(new Dimension(350, 25)); + System.out.println("ĬֵΪ" + bean.getDefaultValue()); + combox.setSelectedValue(bean.getDefaultValue()); + centerPanel.add(row + ".3.center", combox); + } else if (bean.getPropType().equals("string")) { + if ("object_name".equals(bean.getPropRelName()) || "object_desc".equals(bean.getPropRelName())) { + JTextArea area = new JTextArea(bean.getDefaultValue()); + area.setName(bean.getPropRelName()); + area.setPreferredSize(new Dimension(350, 50)); + area.setBorder(new LineBorder(new java.awt.Color(127, 157, 185), 1, false)); + centerPanel.add(row + ".3.center", area); + } else { + JTextField field = new JTextField(bean.getDefaultValue()); + field.setName(bean.getPropRelName()); + field.setPreferredSize(new Dimension(350, 25)); + centerPanel.add(row + ".3.center", field); + } + } else if (bean.getPropType().equals("boolean")) { + JComboBox combox = new JComboBox(); + combox.addItem(""); + combox.addItem(""); + combox.setPreferredSize(new Dimension(350, 25)); + centerPanel.add(row + ".3.center", combox); + } else if (bean.getPropType().equals("date")) { + DateButton dateButton = new DateButton(sdf); + dateButton.setName(bean.getPropRelName()); + dateButton.setText(bean.getDefaultValue()); + dateButton.setPreferredSize(new Dimension(350, 25)); + centerPanel.add(row + ".3.center", dateButton); + } + } +// LOVDisplayer year_categoryCombo = null; +// TCProperty prop; +// try { +// prop = tarRev.getTCProperty("ld6_emergencyLevel"); +// TCPropertyDescriptor descriptor = prop.getPropertyDescriptor(); +// year_categoryCombo = new LOVDisplayer(descriptor); +// //String projectYear = Utilities.getStringForArray(Utilities.getArray(year_categoryCombo.getSelectedValue()),""); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// JLabel oneLabel = new JLabel(" "); +// centerPanel.add(beanList.size() + 2 + ".1.center",oneLabel); +// JLabel label = new JLabel("ݣ"); +// label.setPreferredSize(new Dimension(120,40)); +// centerPanel.add(beanList.size() + 2 + ".2.center",label); +// centerPanel.add(beanList.size() + 2 + ".3.center",year_categoryCombo); + + JScrollPane jsp = new JScrollPane(centerPanel); + + okButton = new JButton(""); + okButton.addActionListener(this); + celButton = new JButton("ȡ"); + celButton.addActionListener(this); + JPanel buttonPanel = new JPanel(); + buttonPanel.add(okButton); + buttonPanel.add(celButton); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER, jsp); + this.add(BorderLayout.SOUTH, buttonPanel); + showDialog(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + if (arg0.getSource() == this.celButton) { + this.dispose(); + } else if (arg0.getSource() == this.okButton) { + new Thread() { + @Override + public void run() { + try { + long time1 = System.nanoTime(); + KUtil.setByPass(true); + System.out.println("dealWay========================"+dealWay); + if (dealWay == 1) { + for (TCComponentItemRevision part : partList) { + System.out.println("ţ" + part.getStringProperty("ld6_clientPartNum")); + TCComponentItemRevision rev = createItem(part.getStringProperty("ld6_clientPartNum")); + if (rev == null) { + return; + } else { + if(flag) { + rev.setStringProperty("ld6_clientName", part.getStringProperty("ld6_clientName")); + rev.setStringProperty("ld6_partName", part.getStringProperty("object_name")); + } + rev.add("LD6_ChangePartInfo", part); + } + } + } else if (dealWay == 2) { + TCComponentItemRevision rev = null; + if(partList.size() > 0) { + System.out.println("ţ" + partList.get(0).getStringProperty("ld6_clientPartNum")); + rev = createItem(partList.get(0).getStringProperty("ld6_clientPartNum")); + } + if (rev == null) { + return; + } else { + for (TCComponentItemRevision part : partList) { + rev.add("LD6_ChangePartInfo", part); + } + } + } else if (dealWay == 0) { + TCComponentItemRevision rev = createItem(""); + if (rev == null) { + return; + } + } + KUtil.setByPass(false); + long time2 = System.nanoTime(); + System.out.println("ʱ(ms) " + (time2 - time1) / 1000000); + MessageBox.post("ɹ,¶newstuffļ", "ʾ", MessageBox.INFORMATION); + disposeDialog(); + } catch (Exception e) { + MessageBox.post(e.getMessage(), "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + } + } + }.start(); + } + } + + /** + * жϱǷд + * + * @param errorBuffer + * @param valueMap + * @param objectDesc + * @param itemId + */ + private void judgeMust(StringBuffer errorBuffer, HashMap valueMap) { + for (Entry entry : beanMap.entrySet()) { + String name = entry.getKey(); + ControlBean bean = entry.getValue(); + System.out.println("ǰֶΪ" + name + "======ǰǷΪ" + bean.isIfMust()); + + if (bean.isIfMust()) { + String propValue = valueMap.get(name); + System.out.println("ǰֶΪ" + name + "======ǰֶεֵΪ" + propValue); + if("ld6_applicantDate".equalsIgnoreCase(name)) { + DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date date = null; + Calendar cal = Calendar.getInstance(); + try { + date = fmt.parse(propValue); + cal.setTime(date); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + dateMap.put("ld6_applicantDate",cal); + }if("ld6_applicantDepartment".equalsIgnoreCase(name)) { + stringMap.put(name, propValue); + } + if (propValue == null || propValue.isEmpty() || "δڡ".equals(propValue)) { + errorBuffer.append(bean.getPropName() + ","); + } + } + } + valueMap.remove("item_id"); + valueMap.remove("object_desc"); + valueMap.remove("ld6_clientPartNum"); + } + + /** + * + * + * @throws TCException + * @throws ServiceException + * @throws ParseException + * @throws NotLoadedException + */ + private TCComponentItemRevision createItem(String partNum) + throws TCException, ServiceException, ParseException, NotLoadedException { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(newType); + HashMap valueMap = new HashMap(); + int componentCount = centerPanel.getComponentCount(); + String itemId = itemType.getNewID(); + // String itemId = null; + String objectDesc = null; + String objectName = null; + for (int i = 0; i < componentCount; i++) { + Component component = centerPanel.getComponent(i); + if (component instanceof JTextField) { + JTextField filed = (JTextField) component; + valueMap.put(filed.getName(), filed.getText()); + + } else if (component instanceof LOVDisplayer) { + LOVDisplayer combox = (LOVDisplayer) component; + valueMap.put(combox.getName(), combox.getSelectedValue().toString()); + } else if (component instanceof DateButton) { + DateButton date = (DateButton) component; + valueMap.put(date.getName(), date.getText()); + } else if (component instanceof JTextArea) { + JTextArea area = (JTextArea) component; + if (area.getName().equals("object_desc")) { + objectDesc = area.getText(); + } else { + objectName = area.getText(); + valueMap.put(area.getName(), area.getText()); + } + } + } + StringBuffer errorBuffer = new StringBuffer(); + valueMap.put("item_id", itemId); + valueMap.put("object_desc", objectDesc); + judgeMust(errorBuffer, valueMap); + if (!errorBuffer.toString().isEmpty()) { + MessageBox.post(errorBuffer.toString() + " Щδ", "ʾ", MessageBox.INFORMATION); + return null; + } + Map itemMaps = new HashMap(); + Map revMaps = new HashMap(); + itemMaps.put("item_id", itemId); + itemMaps.put("object_desc", objectDesc); + // revMaps.put("object_name", partNum + objectName); + // ޸3.7 + revMaps.put("object_name", objectName); + revMaps.put("ld6_clientPartNum", partNum); + + //޸3.31 + if(partList.size()==0) { + System.out.println(""); + flag = false; + String clientName = tarRev.getStringProperty("ld6_clientName"); + String objectstring = tarRev.getStringProperty("object_name"); + partNum = tarRev.getStringProperty("ld6_clientPartNum"); + revMaps.put("ld6_clientPartNum", partNum); + revMaps.put("ld6_clientName", clientName); + revMaps.put("ld6_partName", objectstring); + } + // ld6_clientName ͻ + //object_name ld6_partName + System.out.println("newType:" + newType); + TCComponent createMaterialBySOA = createMaterialBySOA(newType, itemMaps, revMaps,valueMap); + if (createMaterialBySOA == null) { + MessageBox.post("ʧ", "ʾ", MessageBox.INFORMATION); + return null; + } + TCComponentItem newItem = (TCComponentItem) createMaterialBySOA; + + TCComponentItemRevision latestItemRevision = newItem.getLatestItemRevision(); + // ŵnewstuff + TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); + newStuffFolder.add("contents", newItem); + try { + tarRev.add("CMImplementedBy", latestItemRevision); + } catch (TCException e) { + // TODO Auto-generated catch block + } + + // id汾ͣƣ + // TCComponentItem newItem = itemType.create(itemId,"",newType ,"", "niuma", + // null); + // TCComponentItemRevision latestItemRevision = newItem.getLatestItemRevision(); + // tarRev.add("CMImplementedBy", latestItemRevision); + // + for (Entry entry : valueMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + ControlBean controlBean = beanMap.get(key); + TCComponent center = null; + if ("Item".equals(controlBean.getPropTo())) { + center = newItem; + } else if ("Rev".equals(controlBean.getPropTo())) { + center = latestItemRevision; + } else if ("Form".equals(controlBean.getPropTo())) { + center = latestItemRevision.getRelatedComponent("IMAN_master_form_rev"); + } + if ("boolean".equals(controlBean.getPropType())) { + if ("".equals(value)) { + center.setLogicalProperty(key, true); + } else if ("".equals(value)) { + center.setLogicalProperty(key, false); + } + } else if ("date".equals(controlBean.getPropType())) { + if (!value.isEmpty() && !"δڡ".equals(value)) { + center.setDateProperty(key, sdf.parse(value)); + } + } else if ("string".equals(controlBean.getPropType())) { + if (!value.isEmpty()) { + center.setStringProperty(key, value); + } + } else if ("lov".equals(controlBean.getPropType())) { + center.setStringProperty(key, controlBean.getLovMap().get(value)); + } + } + System.out.println("ʼתƹϵļµĶ"); + TCComponent[] re1 = tarRev.getRelatedComponents("CMHasProblemItem"); + if (re1 != null && re1.length > 0) { + latestItemRevision.add("CMHasProblemItem", re1); + } + TCComponent[] re2 = tarRev.getRelatedComponents("CMReferences"); + if (re2 != null && re2.length > 0) { + latestItemRevision.add("CMReferences", re2); + } + String type = tarRev.getType(); + if (!"LD6_PRRevision".equals(type)) { + TCComponent[] re3 = tarRev.getRelatedComponents("LD6_WorkFRelation"); + TCComponent[] newforms = new TCComponent[re3.length]; + for(int a = 0;a < re3.length; a++ ) { + TCComponentForm form = (TCComponentForm) re3[a]; + TCComponentForm saveAs = form.saveAs(re3[a].getStringProperty("object_name")); + newforms[a] = saveAs; + } + if (newforms != null && newforms.length > 0) { +// latestItemRevision.saveAsItem(objectName, type) + latestItemRevision.add("LD6_WorkFRelation", newforms); + } + TCComponent[] re4 = tarRev.getRelatedComponents("CMHasImpactedItem"); + if (re4 != null && re4.length > 0) { + latestItemRevision.add("CMHasImpactedItem", re4); + } + } + // ECN(ˢġҪʱ䡯), + if ("LD6_CN".equals(newType) && "LD6_CRRevision".equals(type)) { + // ѡCRCNʱҪECR汾¹淶ϵµݼ渱ECN汾淶ϵ + TCComponent[] relatedComponents = tarRev.getRelatedComponents("IMAN_specification"); + if (relatedComponents != null && relatedComponents.length > 0) { + for (TCComponent tcComponent : relatedComponents) { + TCComponentDataset dataset = (TCComponentDataset) tcComponent; + TCComponentDataset newDataset = dataset.saveAs(dataset.getStringProperty("object_name")); +// newDataset.getRelatedComponent("ref_list"). +// setProperty("original_file_name", newDataset.getStringProperty("object_name")); + latestItemRevision.add("IMAN_specification", newDataset); + } + + } + + String create = latestItemRevision.getTCProperty("creation_date").getDisplayableValue(); + String takeeffect = latestItemRevision.getTCProperty("ld6_takeEffectTime").getDisplayableValue(); + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm"); + LocalDateTime createDate = LocalDateTime.parse(create, fmt); + if (!"".equals(takeeffect) && takeeffect != null) { + LocalDateTime takeeffectDate = LocalDateTime.parse(takeeffect, fmt); + String min = ""; + String max = ""; + if (Math.min(createDate.getDayOfYear() + 1, takeeffectDate.getDayOfYear()) == takeeffectDate + .getDayOfYear()) { + min = takeeffect; + } else { + min = fmt.format(createDate.plusDays(1)); + } + if (Math.max(LocalDateTime.parse(min, fmt).getDayOfYear(), + takeeffectDate.getDayOfYear() - 3) == takeeffectDate.getDayOfYear() - 3) { + max = fmt.format(takeeffectDate.minusDays(3)); + } else { + max = min; + } + TCComponent[] relatedComponents2 = tarRev.getRelatedComponents("LD6_WorkFRelation"); + TCComponent[] newforms = new TCComponent[relatedComponents2.length]; + TCComponent[] forms = new TCComponent[relatedComponents2.length]; + forms = relatedComponents2; + if (forms != null && forms.length > 0) { + for (int h=0;h component = new ArrayList(); + TCProperty table = saveAsForm.getTCProperty("ld6_ChangeTable"); + TCComponent[] valueArray = table.getReferenceValueArray(); + DataManagementService service = DataManagementService + .getService((TCSession) AIFUtility.getCurrentApplication().getSession()); + CreateIn[] newIn = new CreateIn[valueArray.length]; + System.out.println("ǰеݵΪ" + valueArray.length); + for (int index = 0; index < valueArray.length; index++) { + TCComponent tableValue = valueArray[index]; + CreateIn in = new CreateIn(); + Map propMap = new HashMap(); + Map propDateMap = new HashMap(); + // ǷҪΪ""ʱҪʱΪա + boolean ifChange = true; + for (int j = 0; j < propNames.length; j++) { + if (j == YNCHANGE_INDEX) { + String propertyDisplayableValue = tableValue + .getPropertyDisplayableValue(propNames[j]); + if ("".equals(propertyDisplayableValue)) { + ifChange = false; + } + } + if (j == REQUIRE_FINISH_TIME_INDEX && ifChange) { + Calendar cal = Calendar.getInstance(); + switch (index) { + case 0: + case 1: + case 3: + case 4: + LocalDateTime one = LocalDateTime.parse(min, fmt); + cal.set(one.getYear(), one.getMonthValue() - 1, one.getDayOfMonth(), 00, 00, + 59); + propDateMap.put(propNames[j], cal); + break; + case 5: + LocalDateTime two = LocalDateTime.parse(max, fmt); + cal.set(two.getYear(), two.getMonthValue() - 1, two.getDayOfMonth(), 00, 00, + 59); + propDateMap.put(propNames[j], cal); + break; + case 6: + LocalDateTime two2 = LocalDateTime.parse(max, fmt); + cal.set(two2.getYear(), two2.getMonthValue() - 1, two2.getDayOfMonth(), 00, 00, + 59); + propDateMap.put(propNames[j], cal); + break; + case 11: + LocalDateTime one2 = LocalDateTime.parse(min, fmt); + cal.set(one2.getYear(), one2.getMonthValue() - 1, one2.getDayOfMonth(), 00, 00, + 59); + propDateMap.put(propNames[j], cal); + break; + case 12: + LocalDateTime two3 = LocalDateTime.parse(max, fmt); + cal.set(two3.getYear(), two3.getMonthValue() - 1, two3.getDayOfMonth(), 00, 00, + 59); + propDateMap.put(propNames[j], cal); + break; + default: + cal.set(takeeffectDate.getYear(), takeeffectDate.getMonthValue() - 1, + takeeffectDate.getDayOfMonth(), 00, 00, 59); + propDateMap.put(propNames[j], cal); + break; + } + } else { + String propertyDisplayableValue = tableValue + .getPropertyDisplayableValue(propNames[j]); + propMap.put(propNames[j], propertyDisplayableValue); + } + } + // CreateIn in = new CreateIn(); + in.data.boName = "LD6_TableRow"; + in.data.stringProps = propMap; + in.data.dateProps = propDateMap; + newIn[index] = in; + } + CreateResponse response = service.createObjects(newIn); + System.out.println(response.serviceData.sizeOfCreatedObjects()); + if (response.serviceData.sizeOfCreatedObjects() > 0) { + System.out.println("CreateResponse"); + int length = response.serviceData.sizeOfCreatedObjects(); + for (int i = 0; i < length; i++) { + TCComponent tcComponent = response.output[i].objects[0]; + component.add(tcComponent); + } + } + TCComponent[] array = component.toArray(new TCComponent[component.size()]); + saveAsForm.getTCProperty("ld6_ChangeTable").setReferenceValueArray(array); + newforms[h] = saveAsForm; + } + } + try { + latestItemRevision.remove("LD6_WorkFRelation", relatedComponents2); + } catch (TCException e) { + } + latestItemRevision.setRelated("LD6_WorkFRelation", newforms); + //618 + String ECRID = tarRev.getStringProperty("item_id"); + String stringProperty2 = newItem.getStringProperty("object_name"); + newItem.setStringProperty("object_name", ECRID+stringProperty2); + latestItemRevision.setStringProperty("object_name", ECRID+stringProperty2); + } + return latestItemRevision; + } + return latestItemRevision; + } + + /** + * + * @param itemTypeCom + * @param itemPropMaps + * @param revMaps 汾 + * @return ¶ + * @throws TCException + * @throws ServiceException + * @throws ParseException + */ + private TCComponent createMaterialBySOA(String itemTypeCom, Map itemPropMaps, + Map revMaps,HashMap valueMap) throws TCException, ServiceException, ParseException { + System.out.println(itemTypeCom); + Map itemboole = new HashMap(); + Map itemdate = new HashMap(); + Map revboole = new HashMap(); + Map revdate = new HashMap(); + for (Entry entry : valueMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + ControlBean controlBean = beanMap.get(key); + + if ("Item".equals(controlBean.getPropTo())) { + if ("boolean".equals(controlBean.getPropType())) { + if ("".equals(value)) { + itemboole.put(key, true); + } else if ("".equals(value)) { + itemboole.put(key, false); + } + } else if ("date".equals(controlBean.getPropType())) { + if (!value.isEmpty() && !"δڡ".equals(value)) { + Date parse = sdf.parse(value); + Calendar cal = Calendar.getInstance(); + cal.setTime(parse); + itemdate.put(key, cal); + } + } else if ("string".equals(controlBean.getPropType())) { + if (!value.isEmpty()) { + itemPropMaps.put(key, value); + } + } else if ("lov".equals(controlBean.getPropType())) { + String string = controlBean.getLovMap().get(value); + itemPropMaps.put(key, string); + } + } else if ("Rev".equals(controlBean.getPropTo())) { + if ("boolean".equals(controlBean.getPropType())) { + if ("".equals(value)) { + revboole.put(key, true); + } else if ("".equals(value)) { + revboole.put(key, false); + } + } else if ("date".equals(controlBean.getPropType())) { + if (!value.isEmpty() && !"δڡ".equals(value)) { + Date parse = sdf.parse(value); + Calendar cal = Calendar.getInstance(); + cal.setTime(parse); + revdate.put(key, cal); + } + } else if ("string".equals(controlBean.getPropType())) { + if (!value.isEmpty()) { + revMaps.put(key, value); + } + } else if ("lov".equals(controlBean.getPropType())) { + String string = controlBean.getLovMap().get(value); + revMaps.put(key, string); + } + } + + } + for (Map.Entry entry : itemPropMaps.entrySet()) { + System.out.println("itemPropMaps: key = " + entry.getKey() + ", value = " + entry.getValue()); + } + for (Map.Entry entry : revMaps.entrySet()) { + System.out.println("revMaps: key = " + entry.getKey() + ", value = " + entry.getValue()); + } + DataManagementService dmService = DataManagementService.getService(session); + CreateInput revInput = new CreateInput(); + revInput.boName = itemTypeCom + "Revision"; + revInput.stringProps = revMaps; + revInput.dateProps = revdate; + revInput.boolProps = revboole; + CreateInput itemInput = new CreateInput(); + itemInput.boName = itemTypeCom; + itemInput.stringProps = itemPropMaps; + itemInput.dateProps = itemdate; + itemInput.boolProps = itemboole; + HashMap revInfoMap = new HashMap(); + revInfoMap.put("revision", new CreateInput[] { revInput }); + itemInput.compoundCreateInput = revInfoMap; + CreateIn createin = new CreateIn(); + createin.clientId = "CreateItem"; + createin.data = itemInput; + com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse createresponse; + createresponse = dmService.createObjects(new CreateIn[] { createin }); + if (createresponse.serviceData.sizeOfPartialErrors() > 0) { + System.out.println("create item failed"); + for (int i = 0; i < createresponse.serviceData.sizeOfPartialErrors(); i++) { + String[] messages = createresponse.serviceData.getPartialError(0).getMessages(); + for(int j=0;j 0) { + comp = cOs[0].objects[0]; + System.out.println("Ķ:" + comp); + return comp; + } + return null; + } +} diff --git a/src/com/net/connor/ld/plm/ld06/Main.java b/src/com/net/connor/ld/plm/ld06/Main.java new file mode 100644 index 0000000..f7e8246 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/Main.java @@ -0,0 +1,94 @@ +package com.net.connor.ld.plm.ld06; + + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; + +import com.net.connor.ld.plm.bean.CheckBoxTableHeaderRenderer; + +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashSet; +import java.util.Vector; + +public class Main { + + public static void main(String[] args) { + JFrame jf = new JFrame("Դ"); + jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + // 壬ʹñ߽粼 + JPanel panel = new JPanel(new BorderLayout()); + HashSet idSet = new HashSet(); + idSet.add(2); + // ͷ + Object[] columnNames = {"","", "", "ѧ", "Ӣ", "ܷ"}; + DefaultTableModel tableModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0 && !idSet.contains(row)) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int column) { + if (column == 0) { + return Boolean.class; + } + if (column == 1) { + return Integer.class; + } + return super.getColumnClass(column); + } + + }; + tableModel.setDataVector(null, columnNames); + // + Object[][] rowData = { + {false,"", 80, 80, 80, 240}, + {false,"", 70, 80, 90, 240}, + {false,"Sue", 70, 70, 70, 210}, + {false,"Jane", 80, 70, 60, 210}, + {false,"Joe", 80, 70, 60, 210} + }; + for (Object[] objects : rowData) { + tableModel.addRow(objects); + } + + // һָ ͷ + JTable table = new JTable(tableModel); + JCheckBox t_checkBox = new JCheckBox(); + t_checkBox.setSelected(false); + table.getTableHeader().setDefaultRenderer(new CheckBoxTableHeaderRenderer(table, 0, t_checkBox)); + table.addMouseListener(new MouseAdapter() { + public void mousePressed ( MouseEvent e ) { + if ( SwingUtilities.isRightMouseButton ( e ) ) { + int[] rowIndex = table.getSelectedRows(); + for (int i = 0; i < rowData.length; i++) { + System.out.println("ǰѡеΪ" + rowIndex[i]); + } + } + } + }); + + // ͷ ӵʹͨмӱʱͷ Ҫֿӣ + panel.add(table.getTableHeader(), BorderLayout.NORTH); + // ӵ + panel.add(table, BorderLayout.CENTER); + + jf.setContentPane(panel); + jf.pack(); + jf.setLocationRelativeTo(null); + jf.setVisible(true); + } + +} + diff --git a/src/com/net/connor/ld/plm/ld06/TableDemo.java b/src/com/net/connor/ld/plm/ld06/TableDemo.java new file mode 100644 index 0000000..02b520f --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/TableDemo.java @@ -0,0 +1,87 @@ +package com.net.connor.ld.plm.ld06; + + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Vector; + +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +import javafx.scene.control.TableColumn; + +public class TableDemo extends JFrame{ + static JTable table; + public TableDemo() { + + setSize(600, 600); + setLocationRelativeTo(null); + + /**/ + DefaultTableModel model = new DefaultTableModel(); + model.addColumn("",new Vector()); + model.addColumn("", new Vector()); + model.addColumn("", new Vector()); + model.addColumn("Ƿѡ", new Vector()); + + table = new JTable(model); + JScrollPane jp = new JScrollPane(table); + for(int i = 0;i < 20 ;i ++) { + model.addRow(new Vector()); + } + + + JTableHeader head = table.getTableHeader(); + //ñͷĴС + head.setPreferredSize(new Dimension(head.getWidth(),30)); + //ñͷС + head.setFont(new Font("",Font.BOLD,16)); + //ñп + table.setRowHeight(30); + //ñС + table.setFont(new Font("",Font.ROMAN_BASELINE,13)); + /*ñеݾ*/ + DefaultTableCellRenderer renderer=new DefaultTableCellRenderer(); + renderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER); + table.setDefaultRenderer(Object.class, renderer); + + /*帴ѡ*/ + JCheckBox box = new JCheckBox(); + + /*getColumn()ӦĵڼӸѡ*/ + table.getColumnModel().getColumn(3).setCellRenderer(new TableCellRenderer() { + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus,int row, int column) { + + + /*õѡѡбȾ*/ + box.setSelected(isSelected); + + /*øѡڵԪо*/ + box.setHorizontalAlignment((int) 0.5f); + + return box; + } + + }); + + this.add(jp); + setVisible(true); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + } + public static void main(String[] args) { + TableDemo t = new TableDemo(); + } +} \ No newline at end of file diff --git a/src/com/net/connor/ld/plm/ld06/old.txt b/src/com/net/connor/ld/plm/ld06/old.txt new file mode 100644 index 0000000..23d018a --- /dev/null +++ b/src/com/net/connor/ld/plm/ld06/old.txt @@ -0,0 +1,86 @@ +package com.net.connor.ld.plm.ld06; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Polygon; +import java.util.Comparator; + +import javax.swing.Icon; +import javax.swing.RowSorter; +import javax.swing.RowSorter.SortKey; +import javax.swing.SortOrder; +import javax.swing.table.TableRowSorter; + +import antlr.collections.List; + +public class ArrowIcon implements Icon { + private final SortOrder sortOrder; + private final int size; + private final boolean ascending; + public ArrowIcon(TableRowSorter sorter, int column, boolean ascending) { + this.ascending = ascending; + this.size = 12; + java.util.List sortKeys = sorter.getSortKeys(); + if (sortKeys.size() > 0 && ((RowSorter.SortKey) sortKeys.get(0)).getColumn() == column) { + this.sortOrder = ((RowSorter.SortKey) sortKeys.get(0)).getSortOrder(); + } else { + this.sortOrder = SortOrder.ASCENDING; + } + } + public void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2 = (Graphics2D) g.create(); + g2.translate(x, y); + if (ascending) { + g2.rotate(Math.PI, size / 2.0, size / 2.0); + } + if (sortOrder == SortOrder.ASCENDING) { + g2.draw(createUpTriangle(size)); + } else { + g2.draw(createDownTriangle(size)); + } + g2.dispose(); + } + public int getIconWidth() { + return size; + } + public int getIconHeight() { + return size; + } + private Polygon createUpTriangle(int size) { + Polygon triangle = new Polygon(); + triangle.addPoint(0, size); + triangle.addPoint(size / 2, 0); + triangle.addPoint(size, size); + return triangle; + } + private Polygon createDownTriangle(int size) { + Polygon triangle = new Polygon(); + triangle.addPoint(0, 0); + triangle.addPoint(size, 0); + triangle.addPoint(size / 2, size); + return triangle; + } +} +//表格列排序类 +class ColumnSorter implements Comparator { + private final int col; + private final boolean ascending; + public ColumnSorter(int col, boolean ascending) { + this.col = col; + this.ascending = ascending; + } + @Override + public int compare(Object a, Object b) { + if (a instanceof Comparable && b instanceof Comparable) { + if (ascending) { + return ((Comparable) a).compareTo((Comparable) b); + } else { + return ((Comparable) b).compareTo((Comparable) a); + } + } else { + return 0; + } + } +} + diff --git a/src/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsHandler.java b/src/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsHandler.java new file mode 100644 index 0000000..cd54ef4 --- /dev/null +++ b/src/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsHandler.java @@ -0,0 +1,63 @@ +package com.net.connor.ld.plm.ld07; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.concurrent.ExecutionException; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.MessageContext; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ChangeOfWorkStepsHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) { + + // ȡǰϵͳ + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + // ȡtcǰѡIJ + InterfaceAIFComponent target = app.getTargetComponent(); + if (target instanceof TCComponentBOMLine) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) target; + TCSession session = bomLine.getSession(); + //ȡѡֵ + String[] value = session.getPreferenceService().getStringValues("LD_GBFYCFG"); + if(value==null) { + MessageBox.post("ѡLD_GBFYCFG", "ʾ", MessageBox.ERROR); + return null; + } + try { + String typeString = bomLine.getItem().getStringProperty("object_type"); + if (new ArrayList<>(Arrays.asList(value)).contains(typeString)) { + TCComponentBOMLine topBOMLine = bomLine.window().getTopBOMLine(); + if (bomLine.getProperty("object_string") == topBOMLine.getProperty("object_string")) { + ChangeOfWorkStepsOpertion changeOfWorkStepsOpertion = new ChangeOfWorkStepsOpertion(session,bomLine,arg0); + session.queueOperation(changeOfWorkStepsOpertion); + } else { + MessageBox.post("ѡжBOM,ִв!!!", "ʾ", MessageBox.INFORMATION); + return null; + } + } else { + MessageBox.post("ѡBOM", "ʾ", MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + e.printStackTrace(); + } + } else { + MessageBox.post("ѡBOM,ִв!!!", "ʾ", MessageBox.INFORMATION); + } + return null; + } + +} diff --git a/src/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsOpertion.java b/src/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsOpertion.java new file mode 100644 index 0000000..a58cffb --- /dev/null +++ b/src/com/net/connor/ld/plm/ld07/ChangeOfWorkStepsOpertion.java @@ -0,0 +1,28 @@ +package com.net.connor.ld.plm.ld07; + +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCSession; + +public class ChangeOfWorkStepsOpertion extends AbstractAIFOperation{ + private TCSession session; + private TCComponentBOMLine bomLine; + private ExecutionEvent arg0; + + public ChangeOfWorkStepsOpertion(TCSession session, TCComponentBOMLine bomLine, ExecutionEvent arg0) { + // TODO Auto-generated constructor stub + this.session = session; + this.bomLine = bomLine; + this.arg0 = arg0; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + NewJFrame newJFrame = new NewJFrame(session,bomLine,arg0); + newJFrame.init(); + } + +} diff --git a/src/com/net/connor/ld/plm/ld07/NewJFrame.java b/src/com/net/connor/ld/plm/ld07/NewJFrame.java new file mode 100644 index 0000000..af7114c --- /dev/null +++ b/src/com/net/connor/ld/plm/ld07/NewJFrame.java @@ -0,0 +1,745 @@ +package com.net.connor.ld.plm.ld07; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.AbstractButton; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JRootPane; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellEditor; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.xml.transform.Source; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOPWindow; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUtilization; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.internal.rac.core.DataManagementService; + +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.rac.core._2008_06.DataManagement; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; + + +/** + * + * @author hcj + */ +public class NewJFrame extends JFrame { + + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JTextField jTextField2; + private javax.swing.JTextField jTextField4; + private javax.swing.JTree jTree1; + private javax.swing.JTree jTree2; + private TCSession session; + private TCComponentBOMLine bomLine; + private ArrayList serchList = new ArrayList(); + private ArrayList queryList = new ArrayList(); + private ArrayList attrList = new ArrayList(); + private Map dateMap = new LinkedHashMap(); + Map dateMap2 = new LinkedHashMap(); + private String serchName; + private ExecutionEvent arg0; + + public NewJFrame(TCSession session,TCComponentBOMLine bomLine, ExecutionEvent arg0) throws TCException { + this.session = session; + this.bomLine = bomLine; + this.arg0 = arg0; + getdata(bomLine); + initComponents(); + } + + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + MessageBox.post("ûвѯ", "", MessageBox.ERROR); + return null; + } + } + + + private void getdata(TCComponentBOMLine bomLine) throws TCException { + // TODO Auto-generated method stub + //ȡѯ + String[] search = session.getPreferenceService().getStringValues("Connor_GBFY_Search"); + if(search!=null&&search.length>0) { + for(int i=0;i(Arrays.asList(attrs)); + //ȡǰJtree + TCComponentItemRevision geTcComponentItemRevision = bomLine.getItemRevision(); + String root = geTcComponentItemRevision.getStringProperty("object_string"); + AIFComponentContext[] childrens = bomLine.getChildren(); + for (AIFComponentContext aifComponentContext : childrens) { + TCComponentBOMLine line = (TCComponentBOMLine) aifComponentContext.getComponent(); + TCComponentItemRevision rev = line.getItemRevision(); + String id = rev.getStringProperty("item_id"); + String valueName = rev.getStringProperty("object_string"); + dateMap.put(id, valueName); + } + jTree1 = new JTree(); + jTree1 = createJTreeFromMap(root,dateMap); + } + + public static JTree createJTreeFromMap(String root,Map map) { + + DefaultMutableTreeNode root1 = new DefaultMutableTreeNode(root); + for (String key : map.keySet()) { + DefaultMutableTreeNode node = new DefaultMutableTreeNode(key); + node.setUserObject(map.get(key)); + root1.add(node); + } + JCheckBoxTree tree = new JCheckBoxTree(root1); + return tree; + } + + + + + private void initComponents() { + this.setTitle(""); + this.setDefaultCloseOperation(2); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + // λ + int x = (int) ((screenSize.getWidth())-1500); + int y = (int) ((screenSize.getHeight())-700); + // ôλ + setLocation(x, y); + setResizable(false); + + JRootPane rootPane = this.getRootPane(); + rootPane.putClientProperty("Windows.alpha", new Float(0.5f)); + rootPane.putClientProperty("Windows.useWindowDecorations", false); + + jScrollPane1 = new javax.swing.JScrollPane(); + jPanel1 = new javax.swing.JPanel(); + jButton1 = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jTextField2 = new javax.swing.JTextField(); + jButton2 = new javax.swing.JButton(); + jTextField4 = new javax.swing.JTextField(); + jPanel4 = new javax.swing.JPanel(); + jScrollPane3 = new javax.swing.JScrollPane(); + jPanel3 = new javax.swing.JPanel(); + jScrollPane2 = new javax.swing.JScrollPane(); + jButton3 = new javax.swing.JButton(); + + jPanel1.setBackground(new java.awt.Color(240, 240, 240)); + + jButton1.setText(">>"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + try { + try { + try { + jButton1ActionPerformed(evt); + } catch (PartInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } catch (ServiceException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + + jPanel2.setBackground(new java.awt.Color(255, 255, 255)); + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("·")); + jPanel2.setToolTipText("·"); + + jLabel1.setText(queryList.get(0)); + + jLabel2.setText(queryList.get(1)); + + jButton2.setText("ѯ"); + + jButton2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + System.out.println("ʼѯ"); + // ȡid + String id = jTextField4.getText(); + System.out.println("id:"+id); + + String rev = jTextField2.getText(); + System.out.println("rev:"+rev); + if(id.contains("*")||rev.contains("*")) { + MessageBox.post("ѯвͨ", "ʾ", MessageBox.ERROR); + } + String[] keys = new String[] {serchList.get(0),serchList.get(1)}; + //òѯidֵ + String[] values = new String[] {id,rev}; + //òѯķ + if(id!=null||!"".equals(id)) { + System.out.println("ʼѯ"); + System.out.println("serchName:"+serchName); + System.out.println("ؼ֣"+Arrays.toString(keys)); + System.out.println("ֵ"+Arrays.toString(values)); + List comps = queryObject(serchName, keys, values); + //ȡѯ + TCComponent component = comps.get(0); + try { + System.out.println("ѯ"+component.getProperty("object_string")); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + //͵bom + if(component instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) component; + TCComponentBOPWindowType typeComponent; + String root = null; + try { + typeComponent = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow"); + TCComponentBOPWindow create = (TCComponentBOPWindow) typeComponent.create(null); + TCComponentBOMLine setWindowTopLine = create.setWindowTopLine(revision.getItem(), null, null, null); + + //ȡǰJtree + TCComponentItemRevision geTcComponentItemRevision = setWindowTopLine.getItemRevision(); + root = geTcComponentItemRevision.getStringProperty("object_string"); + AIFComponentContext[] childrens = setWindowTopLine.getChildren(); + for (AIFComponentContext aifComponentContext : childrens) { + TCComponentBOMLine line = (TCComponentBOMLine) aifComponentContext.getComponent(); + TCComponentItemRevision rev1 = line.getItemRevision(); + String id1 = rev1.getStringProperty("item_id"); + String valueName = rev1.getStringProperty("object_string"); + dateMap2.put(id1, valueName); + } + } catch (TCException e1) { + MessageBox.post("ѯϵԱ", "ʾ", MessageBox.ERROR); + } + System.out.println("ʼȡJtree"); + jTree2 = new JTree(); + jTree2 = createJTreeFromMap(root,dateMap2); + jTree2.setShowsRootHandles(true); + System.out.println("Jtree"); + jScrollPane3.setViewportView(jTree2); + System.out.println("ˢ"); + jScrollPane3.revalidate(); + jScrollPane3.repaint(); + + + } + }else { + MessageBox.post("ѯΪ", "ʾ", MessageBox.ERROR); + } + + } + }); + + + jPanel4.setBackground(new java.awt.Color(255, 255, 255)); + + //jTree2.setShowsRootHandles(true); + //jScrollPane3.setViewportView(jTree2); + jScrollPane3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jScrollPane3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane3) + .addContainerGap()) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(9, 9, 9) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE) + .addGap(18, 18, 18) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(7, 7, 7) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jLabel2) + .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton2) + .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel3.setBackground(new java.awt.Color(255, 255, 255)); + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("ǰ·")); + jPanel3.setToolTipText("ǰ·"); + + jTree1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jTree1.setShowsRootHandles(true); + jScrollPane2.setViewportView(jTree1); + jScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jScrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGap(22, 22, 22) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 421, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(57, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jButton3.setText("ȡ"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap(20, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jButton3)) + .addGap(16, 16, 16)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(44, 44, 44) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(256, 256, 256) + .addComponent(jButton1))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButton3) + .addGap(14, 14, 14)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + } + + public TCComponentFolder createFolderBySOA(TCSession session,String tyeString,Map daMap) throws ServiceException { + + com.teamcenter.services.rac.core.DataManagementService service = com.teamcenter.services.rac.core.DataManagementService.getService(session); + CreateIn[] input=new CreateIn[1]; + input[0]=new CreateIn(); + input[0].clientId="Test"; + DataManagement.CreateInput createInput=new DataManagement.CreateInput(); + + Map stringProps = daMap; + createInput.boName=tyeString; + createInput.stringProps=stringProps; + + input[0].data=createInput; + + CreateResponse createObjects = service.createObjects(input); + com.teamcenter.rac.kernel.ServiceData serviceData = createObjects.serviceData; + if(serviceData.sizeOfPartialErrors()>0) { + System.out.println(serviceData.getPartialError(0).getMessages()[0]); + } + + if(serviceData.sizeOfCreatedObjects()>0) { + TCComponent createdObject = serviceData.getCreatedObject(0); + return (TCComponentFolder)createdObject; + } + return null; + } + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) throws TCException, ServiceException, PartInitException { + // TODO add your handling code here: + //ȡJtreeжӦIDIDҶ󣬸ļԼֵ + System.out.println("ȡJtreeжӦIDIDҶ󣬸ļԼֵ"); + List rightId = getKeyFromSelectedNode(jTree2); + List leftId = getKeyFromSelectedNode(jTree1); + //òѯ + String[] keys = new String[] {" ID"}; + //òѯidֵ + String[] values = new String[] {rightId.get(0)}; + //òѯķ + System.out.println("ʼѯߵĹ"); + System.out.println("ʼѯ"); + System.out.println("ؼ֣"+Arrays.toString(keys)); + System.out.println("ֵ"+Arrays.toString(values)); + List comps = queryObject("...",keys,values); + TCComponent tcComponent = comps.get(0); + if(tcComponent instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) tcComponent; + TCComponent[] referenceListProperty = item.getReferenceListProperty("revision_list"); + System.out.println("ȡ汾"+(Integer.valueOf(rightId.get(1))-1)); + TCComponent getrev = referenceListProperty[Integer.valueOf(rightId.get(1))-1]; + if(getrev instanceof TCComponentItemRevision) { + System.out.println("ѯˣʼѯļ"); + TCComponentItemRevision crev = (TCComponentItemRevision) getrev; + AIFComponentContext[] children = crev.getChildren(); + for (AIFComponentContext aifComponentContext : children) { + TCComponent component = (TCComponent)aifComponentContext.getComponent(); + String stringProperty = component.getStringProperty("object_type"); + if("MEActivity".equals(stringProperty)) { + System.out.println("ѯˣʼѯļ"); + if(component instanceof TCComponentFolder) { + TCComponentFolder folder = (TCComponentFolder) component; + //ȡֵ + ArrayList folderList = new ArrayList(); + AIFComponentContext[] children2 = folder.getChildren(); + System.out.println("ʼļ渳ֵ"); + for(int i=children2.length-1;i>=0;i--) { + TCComponent component2 = (TCComponent)children2[i].getComponent(); + if(component2 instanceof TCComponentFolder) { + String folderType = ((TCComponentFolder)component2).getType(); + //ȡļ + Map getattrMap = new HashMap(); + for(int j=0;j comps1 = queryObject("...",keys1,values1); + TCComponent tcComponent1 = comps1.get(0); + if(tcComponent1 instanceof TCComponentItem) { + System.out.println("ѯұߵ"); + TCComponentItem item1 = (TCComponentItem) tcComponent1; + TCComponent[] referenceListProperty1 = item1.getReferenceListProperty("revision_list"); + System.out.println("ȡ汾"+(Integer.valueOf(leftId.get(1))-1)); + TCComponent getrev1 = referenceListProperty1[Integer.valueOf(leftId.get(1))-1]; + if(getrev1 instanceof TCComponentItemRevision) { + TCComponentItemRevision crev1 = (TCComponentItemRevision) getrev1; + AIFComponentContext[] children1 = crev1.getChildren(); + for (AIFComponentContext aifComponentContext1 : children1) { + TCComponent component1 = (TCComponent)aifComponentContext1.getComponent(); + String stringProperty1 = component1.getStringProperty("object_type"); + if("MEActivity".equals(stringProperty1)) { + System.out.println("ȡļ"+(Integer.valueOf(leftId.get(1))-1)); + if(component1 instanceof TCComponentFolder) { + TCComponentFolder folder1 = (TCComponentFolder) component1; + //ļӹ + AIFComponentContext[] children3 = folder1.getChildren(); + for(AIFComponentContext foContext : children3) { + TCComponent component2 = (TCComponent)foContext.getComponent(); + component2.delete(); + } + //ѭӹ + System.out.println("ѭӹ"+(Integer.valueOf(leftId.get(1))-1)); + for(TCComponentFolder getFolder : folderList) { + folder1.add("contents",getFolder); + } + } + } + } + } + } + } + + } + } + } + } + String viewId = "cn.net.connor.std.processedit.meopviewfx.MEOPEditView"; //ȡձ༭ + IWorkbenchPart iworkbenchpart = HandlerUtil.getActivePart(arg0); + IViewPart iviewpart = (IViewPart) iworkbenchpart; + IWorkbenchPage iworkbenchpage = iviewpart.getSite().getPage(); + IViewReference viewRef = iworkbenchpage.findViewReference(viewId); + if (viewRef != null) { + IViewPart viewPart = viewRef.getView(false); + if (viewPart != null) { + // dispose all child controls to clear the cache + Control[] children = viewPart.getSite().getShell().getChildren(); + for (Control child : children) { + child.dispose(); + } + super.dispose(); + // hide and show the view to refresh it + + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(viewPart); + viewPart.dispose(); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(viewId); + } + } else { + // handle the case where the view does not exist + System.out.println("ȡ༭ʧ"); + } + + + MessageBox.post("óɹ", "ʾ", MessageBox.INFORMATION); + } + public List getKeyFromSelectedNode(JTree tree) { + DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + String nodeValue = selectedNode.getUserObject().toString(); + ArrayList idAndRev = new ArrayList(); + if(nodeValue!=null) { + String[] split1 = nodeValue.split(";"); + String[] split = split1[0].split("\\/"); // ʹת\ת/ + String id = split[0]; + String rev = split[1]; + idAndRev.add(id); + idAndRev.add(rev); + return idAndRev; + + } + return null; + } + + /** + * @param args the command line arguments + */ + public void init() { +// try { +// for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { +// if ("Nimbus".equals(info.getName())) { +// javax.swing.UIManager.setLookAndFeel(info.getClassName()); +// break; +// } +// } +// } catch (ClassNotFoundException ex) { +// java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); +// } catch (InstantiationException ex) { +// java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); +// } catch (IllegalAccessException ex) { +// java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); +// } catch (javax.swing.UnsupportedLookAndFeelException ex) { +// java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); +// } + + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + try { + new NewJFrame(session,bomLine,arg0).setVisible(true); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + } + + +} +class JCheckBoxTree extends JTree { + private static final long serialVersionUID = 1L; + public JCheckBoxTree(DefaultMutableTreeNode root) { + super(root); + setCellRenderer(new CheckBoxTreeCellRenderer()); + setCellEditor(new CheckBoxTreeCellEditor(this, new DefaultTreeCellRenderer())); + setEditable(true); + } +} +//һڵ״̬Ķ +class CheckBoxNode { + private String text; + private boolean checked; + public CheckBoxNode(String text, boolean checked) { + this.text = text; + this.checked = checked; + } + public String getText() { + return text; + } + public boolean isChecked() { + return checked; + } + public void setChecked(boolean checked) { + this.checked = checked; + } +} +//ѡڵȾ +class CheckBoxTreeCellRenderer extends DefaultTreeCellRenderer { + private static final long serialVersionUID = 1L; + @Override + public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean exp, boolean leaf, int row, boolean hasFocus) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + Object userObject = node.getUserObject(); + if (userObject instanceof CheckBoxNode) { + CheckBoxNode checkBoxNode = (CheckBoxNode) userObject; + JCheckBox checkBox = new JCheckBox(); + checkBox.setSelected(checkBoxNode.isChecked()); + checkBox.setText(checkBoxNode.getText()); + checkBox.setOpaque(false); + checkBox.setEnabled(tree.isEnabled()); + return checkBox; + } + return super.getTreeCellRendererComponent(tree, value, sel, exp, leaf, row, hasFocus); + } +} +//ѡڵı༭ +class CheckBoxTreeCellEditor extends DefaultTreeCellEditor { + private static final long serialVersionUID = 1L; + public CheckBoxTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer) { + super(tree, renderer); + } + @Override + public java.awt.Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + Object userObject = node.getUserObject(); + if (userObject instanceof CheckBoxNode) { + CheckBoxNode checkBoxNode = (CheckBoxNode) userObject; + JCheckBox checkBox = new JCheckBox(); + checkBox.setSelected(checkBoxNode.isChecked()); + checkBox.setText(checkBoxNode.getText()); + checkBox.setOpaque(false); + checkBox.setEnabled(tree.isEnabled()); + return checkBox; + } + return super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row); + } +} + + diff --git a/src/com/teamcenter/rac/commands/cut/CutCommand.java b/src/com/teamcenter/rac/commands/cut/CutCommand.java new file mode 100644 index 0000000..06180bb --- /dev/null +++ b/src/com/teamcenter/rac/commands/cut/CutCommand.java @@ -0,0 +1,196 @@ +package com.teamcenter.rac.commands.cut; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.TCUtilities; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMViewRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTaskState; +import com.teamcenter.rac.kernel.bom.BOMMarkupHelper; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.Utilities; +import java.awt.Frame; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +public class CutCommand extends AbstractAIFCommand { + private Frame parent; + + private ArrayList parentsWithNoAccess = new ArrayList(); + + public CutCommand() {} + + public CutCommand(AIFComponentContext[] paramArrayOfAIFComponentContext, Frame paramFrame, Boolean paramBoolean1, Boolean paramBoolean2) { + this.parent = paramFrame; + AIFComponentContext[] arrayOfAIFComponentContext = checkInput(this.parent, paramArrayOfAIFComponentContext); + if (arrayOfAIFComponentContext != null) { + boolean bool = showConfirmation(arrayOfAIFComponentContext); + setRunnable(new CutDialog(arrayOfAIFComponentContext, this.parent, bool, paramBoolean2.booleanValue())); + } + } + + public CutCommand(AIFComponentContext[] paramArrayOfAIFComponentContext, Boolean paramBoolean1, Boolean paramBoolean2) { + AIFComponentContext[] arrayOfAIFComponentContext = checkInput(null, paramArrayOfAIFComponentContext); + if (arrayOfAIFComponentContext != null) { + boolean bool = showConfirmation(arrayOfAIFComponentContext); + setRunnable(new CutDialog(arrayOfAIFComponentContext, bool, paramBoolean2.booleanValue())); + } + } + + public CutCommand(AIFComponentContext paramAIFComponentContext, Frame paramFrame, Boolean paramBoolean1, Boolean paramBoolean2) { this(new AIFComponentContext[] { paramAIFComponentContext }, paramFrame, paramBoolean1, paramBoolean2); } + + public CutCommand(AIFComponentContext paramAIFComponentContext, Boolean paramBoolean1, Boolean paramBoolean2) { this(new AIFComponentContext[] { paramAIFComponentContext }, paramBoolean1, paramBoolean2); } + + public CutCommand(AIFComponentContext[] paramArrayOfAIFComponentContext, Boolean paramBoolean1, Boolean paramBoolean2, Boolean paramBoolean3) { + AIFComponentContext[] arrayOfAIFComponentContext = checkInput(null, paramArrayOfAIFComponentContext); + if (arrayOfAIFComponentContext != null && paramBoolean1.booleanValue()) { + boolean bool = showConfirmation(arrayOfAIFComponentContext); + setRunnable(new CutDialog(arrayOfAIFComponentContext, bool, paramBoolean3.booleanValue())); + } + } + + public CutCommand(AIFComponentContext paramAIFComponentContext, Boolean paramBoolean1, Boolean paramBoolean2, Boolean paramBoolean3) { this(new AIFComponentContext[] { paramAIFComponentContext }, paramBoolean1, paramBoolean2, paramBoolean3); } + + protected AIFComponentContext[] checkInput(Frame paramFrame, AIFComponentContext[] paramArrayOfAIFComponentContext) { + Registry registry = Registry.getRegistry(this); + ArrayList arrayList = new ArrayList(); + if (paramArrayOfAIFComponentContext == null || paramArrayOfAIFComponentContext.length == 0) { + MessageBox.post(paramFrame, registry.getString("noSelection"), registry.getString("error.TITLE"), 4); + return null; + } + boolean bool = false; + InterfaceAIFComponent interfaceAIFComponent = paramArrayOfAIFComponentContext[0].getComponent(); + if (interfaceAIFComponent instanceof TCComponentBOMViewRevision || interfaceAIFComponent instanceof com.teamcenter.rac.kernel.TCComponentBOMView) { + TCPreferenceService tCPreferenceService = ((TCSession)interfaceAIFComponent.getSession()).getPreferenceService(); + if (tCPreferenceService != null && tCPreferenceService.isDefinitionExistForPreference("PS_allow_cut_in_pseudofolder") && tCPreferenceService.getLogicalValue("PS_allow_cut_in_pseudofolder").booleanValue()) + bool = true; + } + String str = "User_Inbox"; + int i = paramArrayOfAIFComponentContext.length; + for (byte b = 0; b < i; b++) { + InterfaceAIFComponent interfaceAIFComponent1 = paramArrayOfAIFComponentContext[b].getParentComponent(); + InterfaceAIFComponent interfaceAIFComponent2 = paramArrayOfAIFComponentContext[b].getComponent(); + if (interfaceAIFComponent2 == null) { + MessageBox.post(paramFrame, registry.getString("invalidSelection"), registry.getString("error.TITLE"), 4); + return null; + } + /* + * ѡConnor_NoCut,վ㡢ֵֵΪԶļʵֵ + * LD6_CusProdFolder LD6_ProjectFolder LD6_ProjMaFolder ԸѡõĶμв + */ + TCPreferenceService tCPreferenceService = ((TCSession)interfaceAIFComponent.getSession()).getPreferenceService(); + String[] values = tCPreferenceService.getStringValues("Connor_NoCut"); + List list = Arrays.asList(values); + if(list.contains(interfaceAIFComponent2.getType())) { + MessageBox.post(paramFrame, "ܶԸ͵ļнмв", registry.getString("error.TITLE"),4); + return null; + } + + if (interfaceAIFComponent2 instanceof TCComponentBOMViewRevision && (interfaceAIFComponent1 instanceof TCComponentItemRevision || (interfaceAIFComponent1 instanceof com.teamcenter.rac.kernel.TCComponentPseudoFolder && !bool)) && paramArrayOfAIFComponentContext[b].getContext() != null && paramArrayOfAIFComponentContext[b].getContext().toString().equals("structure_revisions")) { + MessageBox.post(paramFrame, registry.getString("invalidSelectionBOMViewRev"), registry.getString("error.TITLE"), 4); + return null; + } + if (interfaceAIFComponent2 instanceof com.teamcenter.rac.kernel.TCComponentBOMView && (interfaceAIFComponent1 instanceof com.teamcenter.rac.kernel.TCComponentItem || (interfaceAIFComponent1 instanceof com.teamcenter.rac.kernel.TCComponentPseudoFolder && !bool)) && paramArrayOfAIFComponentContext[b].getContext() != null && paramArrayOfAIFComponentContext[b].getContext().toString().equals("bom_view_tags")) { + MessageBox.post(paramFrame, registry.getString("invalidSelectionBOMView"), registry.getString("error.TITLE"), 4); + return null; + } + if (interfaceAIFComponent2 instanceof com.teamcenter.rac.kernel.TCComponentPseudoFolder) { + MessageBox.post(paramFrame, String.valueOf(Utilities.trimString(registry.getString("invalidSelection"), ".")) + " -- " + interfaceAIFComponent2 + ".", registry.getString("command.TITLE"), 4); + return null; + } + if (interfaceAIFComponent2 instanceof com.teamcenter.rac.kernel.TCComponentAssemblyArrangement && interfaceAIFComponent1 != null && interfaceAIFComponent1 instanceof TCComponentBOMViewRevision && paramArrayOfAIFComponentContext[b].getContext() != null && (paramArrayOfAIFComponentContext[b].getContext().toString().equals("TC_Arrangement") || paramArrayOfAIFComponentContext[b].getContext().toString().equals("TC_DefaultArrangement") || paramArrayOfAIFComponentContext[b].getContext().toString().equals("Fnd0AsSavedArrangement"))) { + MessageBox.post(paramFrame, registry.getString("invalidSelectionAssemblyArrangement"), registry.getString("error.TITLE"), 4); + return null; + } + if (interfaceAIFComponent2 instanceof com.teamcenter.rac.kernel.TCComponentIDCLine && interfaceAIFComponent1 instanceof com.teamcenter.rac.kernel.TCComponentIDCLine) { + MessageBox.post(paramFrame, registry.getString("invalidSelection"), registry.getString("command.TITLE"), 1); + return null; + } + if (interfaceAIFComponent2 instanceof TCComponentBOMLine) { + if (!BOMMarkupHelper.allowStructureEdit(AIFUtility.getActiveDesktop().getShell(), (TCComponentBOMLine)interfaceAIFComponent2)) + return null; + try { + TCComponentBOMViewRevision tCComponentBOMViewRevision = ((TCComponentBOMLine)interfaceAIFComponent1).getBOMViewRevision(); + if (tCComponentBOMViewRevision != null && !tCComponentBOMViewRevision.okToModify()) { + if (!this.parentsWithNoAccess.contains(tCComponentBOMViewRevision)) + this.parentsWithNoAccess.add(tCComponentBOMViewRevision); + continue; + } + } catch (TCException tCException) { + tCException.printStackTrace(); + } + } else if (interfaceAIFComponent2 instanceof com.teamcenter.rac.kernel.TCComponentTaskInBox) { + TCComponent tCComponent = (TCComponent)paramArrayOfAIFComponentContext[b].getParentComponent(); + if (tCComponent instanceof com.teamcenter.rac.kernel.TCComponentTaskInBox || tCComponent.getType().equals(str)) { + MessageBox.post(paramFrame, String.valueOf(Utilities.trimString(registry.getString("invalidSelection"), ".")) + " -- " + interfaceAIFComponent2 + ".", registry.getString("command.TITLE"), 4); + return null; + } + } else if (interfaceAIFComponent1 instanceof com.teamcenter.rac.kernel.TCComponentTaskInBox) { + boolean bool1 = true; + if (interfaceAIFComponent2 instanceof TCComponentTask) + try { + if (((TCComponentTask)interfaceAIFComponent2).getState() == TCTaskState.COMPLETED) + bool1 = false; + } catch (TCException tCException) {} + if (bool1) { + MessageBox.post(paramFrame, String.valueOf(Utilities.trimString(registry.getString("invalidSelection"), ".")) + " -- " + interfaceAIFComponent2 + ".", registry.getString("command.TITLE"), 4); + return null; + } + } else if (interfaceAIFComponent2.getType().equals(str)) { + TCComponent tCComponent = (TCComponent)paramArrayOfAIFComponentContext[b].getParentComponent(); + if (tCComponent == null) { + MessageBox.post(paramFrame, String.valueOf(Utilities.trimString(registry.getString("invalidSelection"), ".")) + " -- " + interfaceAIFComponent2 + ".", registry.getString("command.TITLE"), 4); + return null; + } + } + if (interfaceAIFComponent2 instanceof com.teamcenter.rac.kernel.TCComponentArchitecture && interfaceAIFComponent1 instanceof TCComponentItemRevision && paramArrayOfAIFComponentContext[b].getContext().equals(TCUtilities.ARCHITECTURE_RELATION)) { + try { + TCComponentItemRevision tCComponentItemRevision = (TCComponentItemRevision)paramArrayOfAIFComponentContext[b].getParentComponent(); + TCComponentItemRevision[] arrayOfTCComponentItemRevision = TCUtilities.getAllContextRevisions(tCComponentItemRevision, null); + Utilities.addElements(arrayList, AIFComponentContext.getContexts(arrayOfTCComponentItemRevision, paramArrayOfAIFComponentContext[b].getComponent(), paramArrayOfAIFComponentContext[b].getContext()), true); + } catch (TCException tCException) {} + } else { + arrayList.add(paramArrayOfAIFComponentContext[b]); + } + continue; + } + if (this.parentsWithNoAccess.size() > 0) { + StringBuffer stringBuffer = new StringBuffer(); + String str1 = ", "; + for (byte b1 = 0; b1 < this.parentsWithNoAccess.size(); b1++) { + if (b1 == this.parentsWithNoAccess.size() - 1) + str1 = ""; + stringBuffer.append(this.parentsWithNoAccess.get(b1)); + stringBuffer.append(str1); + } + MessageBox.post(paramFrame, String.valueOf(MessageFormat.format(registry.getString("inaccessibleBOMViewRev"), new Object[] { stringBuffer.toString() })) + " " + registry.getString("acessDenied"), registry.getString("error.TITLE"), 4); + } + return arrayList.isEmpty() ? null : (AIFComponentContext[])arrayList.toArray(new AIFComponentContext[arrayList.size()]); + } + + private boolean showConfirmation(AIFComponentContext[] paramArrayOfAIFComponentContext) { + if (paramArrayOfAIFComponentContext == null) + return true; + Registry registry = Registry.getRegistry(this); + int i = registry.getInt("confirmationLimit", 10); + return (paramArrayOfAIFComponentContext.length > i); + } +} + + +/* Location: D:\Siemens\Teamcenter13\portal\plugins\com.teamcenter.rac.common_13000.1.0.jar!/com/teamcenter/rac/commands/cut/CutCommand.class + * Java compiler version: 8 (52.0) + * JD-Core Version: 1.0.7 + */ \ No newline at end of file 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..b31b8d6 --- /dev/null +++ b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1,2 @@ +LD6_CNForm.FORMJAVARENDERING=com.net.connor.ld.plm.ld05.CNForm +LD6_CIForm.FORMJAVARENDERING=com.net.connor.ld.plm.ld05.CIForm \ No newline at end of file