commit f2610238ef7950f22732e84cc0bfa76b6bbcb48a Author: lijh Date: Tue Mar 10 16:39:32 2026 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..539560a --- /dev/null +++ b/.classpath @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..9077712 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.wf.plm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..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..74b8334 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,140 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.connor.wf.plm; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.connor.wf.plm.Activator +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.aifrcp;bundle-version="11000.2.0", + com.teamcenter.rac.kernel;bundle-version="11000.2.0", + com.teamcenter.rac.util;bundle-version="11000.2.0", + com.teamcenter.rac.common;bundle-version="11000.2.0", + com.teamcenter.rac.tcapps;bundle-version="11000.2.0", + com.teamcenter.rac.schedule;bundle-version="11000.2.0", + com.teamcenter.rac.ui.commands;bundle-version="11000.2.0", + com.teamcenter.rac.project;bundle-version="11000.2.0", + TcSoaCoreRac;bundle-version="11000.2.0", + com.teamcenter.rac.ui;bundle-version="11000.2.0", + org.eclipse.ui.forms;bundle-version="3.5.200", + com.connor.getNumber;bundle-version="1.0.0", + org.apache.poi.39;bundle-version="3.9.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ActivationPolicy: lazy +Export-Package: com.connor.wf.plm, + com.connor.wf.plm.handlers, + com.connor.wf.plm.table, + com.connor.wf.plm.util, + com.connor.wf.plm.wf001, + com.connor.wf.plm.wf002, + com.connor.wf.plm.wf007, + com.connor.wf.plm.wf008, + com.connor.wf.plm.wf009, + com.connor.wf.plm.wf010, + com.connor.wf.plm.wf011, + com.connor.wf.plm.wf012, + com.connor.wf.plm.wf013, + com.connor.wf.plm.wf015, + com.connor.wf.plm.wf016, + com.connor.wf.plm.wf017, + com.connor.wf.plm.wf020, + com.connor.wf.plm.wf022, + com.connor.wf.plm.wf023, + com.connor.wf.plm.wf024, + com.connor.wf.plm.wf037, + com.connor.wf.plm.wf038, + com.connor.wf.plm.wf046, + com.connor.wf.plm.wf050, + com.connor.wf.plm.wf051, + com.connor.wf.plm.wf052, + com.connor.wf.plm.wf053, + com.connor.wf.plm.wf057, + com.connor.wf.plm.wf058, + com.connor.wf.plm.wf059, + com.connor.wf.plm.wf060, + com.connor.wf.plm.wf061, + com.teamcenter.rac.form, + com.teamcenter.rac.schedule +Bundle-ClassPath: ., + lib/activation-1.1.jar, + lib/antlr-2.7.7.jar, + lib/apache-mime4j-core-0.7.2.jar, + lib/axiom-api-1.2.13.jar, + lib/axiom-dom-1.2.13.jar, + lib/axiom-impl-1.2.13.jar, + lib/axis2-adb-1.6.2.jar, + lib/axis2-adb-codegen-1.6.2.jar, + lib/axis2-ant-plugin-1.6.2.jar, + lib/axis2-clustering-1.6.2.jar, + lib/axis2-codegen-1.6.2.jar, + lib/axis2-corba-1.6.2.jar, + lib/axis2-fastinfoset-1.6.2.jar, + lib/axis2-java2wsdl-1.6.2.jar, + lib/axis2-jaxbri-1.6.2.jar, + lib/axis2-jaxws-1.6.2.jar, + lib/axis2-jibx-1.6.2.jar, + lib/axis2-json-1.6.2.jar, + lib/axis2-kernel-1.6.2.jar, + lib/axis2-metadata-1.6.2.jar, + lib/axis2-mtompolicy-1.6.2.jar, + lib/axis2-saaj-1.6.2.jar, + lib/axis2-soapmonitor-servlet-1.6.2.jar, + lib/axis2-spring-1.6.2.jar, + lib/axis2-transport-http-1.6.2.jar, + lib/axis2-transport-local-1.6.2.jar, + lib/axis2-xmlbeans-1.6.2.jar, + lib/bcel-5.1.jar, + lib/commons-beanutils-1.7.0.jar, + lib/commons-cli-1.2.jar, + lib/commons-codec-1.3.jar, + lib/commons-collections-3.2.jar, + lib/commons-fileupload-1.2.jar, + lib/commons-httpclient-3.1.jar, + lib/commons-io-1.4.jar, + lib/commons-lang-2.4.jar, + lib/commons-logging-1.1.1.jar, + lib/commons-logging-1.1.jar, + lib/ezmorph-1.0.4.jar, + lib/geronimo-annotation_1.0_spec-1.1.jar, + lib/geronimo-jaxws_2.2_spec-1.0.jar, + lib/geronimo-jta_1.1_spec-1.1.jar, + lib/geronimo-saaj_1.3_spec-1.0.1.jar, + lib/geronimo-stax-api_1.0_spec-1.0.1.jar, + lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar, + lib/httpcore-4.0.jar, + lib/itext-2.0.3.jar, + lib/iText-5.0.2.jar, + lib/iTextAsian.jar, + lib/jalopy-1.5rc3.jar, + lib/jaxb-api-2.1.jar, + lib/jaxb-impl-2.1.7.jar, + lib/jaxb-xjc-2.1.7.jar, + lib/jaxws-tools-2.1.3.jar, + lib/jdom.jar, + lib/jettison-1.0-RC2.jar, + lib/jibx-bind-1.2.jar, + lib/jibx-run-1.2.jar, + lib/json-lib-2.2.2-jdk15.jar, + lib/json-lib-2.2.3-jdk13.jar, + lib/jsr311-api-1.0.jar, + lib/juli-6.0.16.jar, + lib/log4j-1.2.15.jar, + lib/mail-1.4.jar, + lib/mex-1.6.2-impl.jar, + lib/neethi-3.0.2.jar, + lib/ojdbc6.jar, + lib/regexp-1.2.jar, + lib/tribes-6.0.16.jar, + lib/woden-api-1.0M9.jar, + lib/woden-impl-commons-1.0M9.jar, + lib/woden-impl-dom-1.0M9.jar, + lib/wsdl4j-1.6.2.jar, + lib/wstx-asl-3.2.9.jar, + lib/xalan-2.7.0.jar, + lib/xml-resolver-1.2.jar, + lib/xmlbeans-2.3.0.jar, + lib/XmlSchema-1.4.7.jar, + lib/dom4j-1.6.1.jar, + lib/jaxen-1.1.6.jar +Import-Package: com.teamcenter.services.loose.projectmanagement diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..c2d9872 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +/com/ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..608524d --- /dev/null +++ b/build.properties @@ -0,0 +1,86 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + lib/activation-1.1.jar,\ + lib/antlr-2.7.7.jar,\ + lib/apache-mime4j-core-0.7.2.jar,\ + lib/axiom-api-1.2.13.jar,\ + lib/axiom-dom-1.2.13.jar,\ + lib/axiom-impl-1.2.13.jar,\ + lib/axis2-adb-1.6.2.jar,\ + lib/axis2-adb-codegen-1.6.2.jar,\ + lib/axis2-ant-plugin-1.6.2.jar,\ + lib/axis2-clustering-1.6.2.jar,\ + lib/axis2-codegen-1.6.2.jar,\ + lib/axis2-corba-1.6.2.jar,\ + lib/axis2-fastinfoset-1.6.2.jar,\ + lib/axis2-java2wsdl-1.6.2.jar,\ + lib/axis2-jaxbri-1.6.2.jar,\ + lib/axis2-jaxws-1.6.2.jar,\ + lib/axis2-jibx-1.6.2.jar,\ + lib/axis2-json-1.6.2.jar,\ + lib/axis2-kernel-1.6.2.jar,\ + lib/axis2-metadata-1.6.2.jar,\ + lib/axis2-mtompolicy-1.6.2.jar,\ + lib/axis2-saaj-1.6.2.jar,\ + lib/axis2-soapmonitor-servlet-1.6.2.jar,\ + lib/axis2-spring-1.6.2.jar,\ + lib/axis2-transport-http-1.6.2.jar,\ + lib/axis2-transport-local-1.6.2.jar,\ + lib/axis2-xmlbeans-1.6.2.jar,\ + lib/bcel-5.1.jar,\ + lib/commons-beanutils-1.7.0.jar,\ + lib/commons-cli-1.2.jar,\ + lib/commons-codec-1.3.jar,\ + lib/commons-collections-3.2.jar,\ + lib/commons-fileupload-1.2.jar,\ + lib/commons-httpclient-3.1.jar,\ + lib/commons-io-1.4.jar,\ + lib/commons-lang-2.4.jar,\ + lib/commons-logging-1.1.1.jar,\ + lib/commons-logging-1.1.jar,\ + lib/ezmorph-1.0.4.jar,\ + lib/geronimo-annotation_1.0_spec-1.1.jar,\ + lib/geronimo-jaxws_2.2_spec-1.0.jar,\ + lib/geronimo-jta_1.1_spec-1.1.jar,\ + lib/geronimo-saaj_1.3_spec-1.0.1.jar,\ + lib/geronimo-stax-api_1.0_spec-1.0.1.jar,\ + lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar,\ + lib/httpcore-4.0.jar,\ + lib/itext-2.0.3.jar,\ + lib/iText-5.0.2.jar,\ + lib/iTextAsian.jar,\ + lib/jalopy-1.5rc3.jar,\ + lib/jaxb-api-2.1.jar,\ + lib/jaxb-impl-2.1.7.jar,\ + lib/jaxb-xjc-2.1.7.jar,\ + lib/jaxws-tools-2.1.3.jar,\ + lib/jdom.jar,\ + lib/jettison-1.0-RC2.jar,\ + lib/jibx-bind-1.2.jar,\ + lib/jibx-run-1.2.jar,\ + lib/json-lib-2.2.2-jdk15.jar,\ + lib/json-lib-2.2.3-jdk13.jar,\ + lib/jsr311-api-1.0.jar,\ + lib/juli-6.0.16.jar,\ + lib/log4j-1.2.15.jar,\ + lib/mail-1.4.jar,\ + lib/mex-1.6.2-impl.jar,\ + lib/neethi-3.0.2.jar,\ + lib/ojdbc6.jar,\ + lib/regexp-1.2.jar,\ + lib/tribes-6.0.16.jar,\ + lib/woden-api-1.0M9.jar,\ + lib/woden-impl-commons-1.0M9.jar,\ + lib/woden-impl-dom-1.0M9.jar,\ + lib/wsdl4j-1.6.2.jar,\ + lib/wstx-asl-3.2.9.jar,\ + lib/xalan-2.7.0.jar,\ + lib/xml-resolver-1.2.jar,\ + lib/xmlbeans-2.3.0.jar,\ + lib/XmlSchema-1.4.7.jar,\ + lib/dom4j-1.6.1.jar,\ + lib/jaxen-1.1.6.jar diff --git a/icons/sample.gif b/icons/sample.gif new file mode 100644 index 0000000..34fb3c9 Binary files /dev/null and b/icons/sample.gif differ diff --git a/lib/XmlSchema-1.4.7.jar b/lib/XmlSchema-1.4.7.jar new file mode 100644 index 0000000..79251c6 Binary files /dev/null and b/lib/XmlSchema-1.4.7.jar differ diff --git a/lib/activation-1.1.jar b/lib/activation-1.1.jar new file mode 100644 index 0000000..53f82a1 Binary files /dev/null and b/lib/activation-1.1.jar differ diff --git a/lib/antlr-2.7.7.jar b/lib/antlr-2.7.7.jar new file mode 100644 index 0000000..5e5f14b Binary files /dev/null and b/lib/antlr-2.7.7.jar differ diff --git a/lib/apache-commons-codec-1.4.jar b/lib/apache-commons-codec-1.4.jar new file mode 100644 index 0000000..422c42b Binary files /dev/null and b/lib/apache-commons-codec-1.4.jar differ diff --git a/lib/apache-mime4j-core-0.7.2.jar b/lib/apache-mime4j-core-0.7.2.jar new file mode 100644 index 0000000..b5c225b Binary files /dev/null and b/lib/apache-mime4j-core-0.7.2.jar differ diff --git a/lib/axiom-api-1.2.13.jar b/lib/axiom-api-1.2.13.jar new file mode 100644 index 0000000..84cb42c Binary files /dev/null and b/lib/axiom-api-1.2.13.jar differ diff --git a/lib/axiom-dom-1.2.13.jar b/lib/axiom-dom-1.2.13.jar new file mode 100644 index 0000000..4890bb2 Binary files /dev/null and b/lib/axiom-dom-1.2.13.jar differ diff --git a/lib/axiom-impl-1.2.13.jar b/lib/axiom-impl-1.2.13.jar new file mode 100644 index 0000000..a959b28 Binary files /dev/null and b/lib/axiom-impl-1.2.13.jar differ diff --git a/lib/axis2-adb-1.6.2.jar b/lib/axis2-adb-1.6.2.jar new file mode 100644 index 0000000..6234fdb Binary files /dev/null and b/lib/axis2-adb-1.6.2.jar differ diff --git a/lib/axis2-adb-codegen-1.6.2.jar b/lib/axis2-adb-codegen-1.6.2.jar new file mode 100644 index 0000000..7d037d4 Binary files /dev/null and b/lib/axis2-adb-codegen-1.6.2.jar differ diff --git a/lib/axis2-ant-plugin-1.6.2.jar b/lib/axis2-ant-plugin-1.6.2.jar new file mode 100644 index 0000000..771b222 Binary files /dev/null and b/lib/axis2-ant-plugin-1.6.2.jar differ diff --git a/lib/axis2-clustering-1.6.2.jar b/lib/axis2-clustering-1.6.2.jar new file mode 100644 index 0000000..e45be99 Binary files /dev/null and b/lib/axis2-clustering-1.6.2.jar differ diff --git a/lib/axis2-codegen-1.6.2.jar b/lib/axis2-codegen-1.6.2.jar new file mode 100644 index 0000000..f742f19 Binary files /dev/null and b/lib/axis2-codegen-1.6.2.jar differ diff --git a/lib/axis2-corba-1.6.2.jar b/lib/axis2-corba-1.6.2.jar new file mode 100644 index 0000000..ee3c78e Binary files /dev/null and b/lib/axis2-corba-1.6.2.jar differ diff --git a/lib/axis2-fastinfoset-1.6.2.jar b/lib/axis2-fastinfoset-1.6.2.jar new file mode 100644 index 0000000..d10c36a Binary files /dev/null and b/lib/axis2-fastinfoset-1.6.2.jar differ diff --git a/lib/axis2-java2wsdl-1.6.2.jar b/lib/axis2-java2wsdl-1.6.2.jar new file mode 100644 index 0000000..0bb869d Binary files /dev/null and b/lib/axis2-java2wsdl-1.6.2.jar differ diff --git a/lib/axis2-jaxbri-1.6.2.jar b/lib/axis2-jaxbri-1.6.2.jar new file mode 100644 index 0000000..616eec9 Binary files /dev/null and b/lib/axis2-jaxbri-1.6.2.jar differ diff --git a/lib/axis2-jaxws-1.6.2.jar b/lib/axis2-jaxws-1.6.2.jar new file mode 100644 index 0000000..064351a Binary files /dev/null and b/lib/axis2-jaxws-1.6.2.jar differ diff --git a/lib/axis2-jibx-1.6.2.jar b/lib/axis2-jibx-1.6.2.jar new file mode 100644 index 0000000..75f9d1a Binary files /dev/null and b/lib/axis2-jibx-1.6.2.jar differ diff --git a/lib/axis2-json-1.6.2.jar b/lib/axis2-json-1.6.2.jar new file mode 100644 index 0000000..edd7936 Binary files /dev/null and b/lib/axis2-json-1.6.2.jar differ diff --git a/lib/axis2-kernel-1.6.2.jar b/lib/axis2-kernel-1.6.2.jar new file mode 100644 index 0000000..3ae5f7a Binary files /dev/null and b/lib/axis2-kernel-1.6.2.jar differ diff --git a/lib/axis2-metadata-1.6.2.jar b/lib/axis2-metadata-1.6.2.jar new file mode 100644 index 0000000..492f1ac Binary files /dev/null and b/lib/axis2-metadata-1.6.2.jar differ diff --git a/lib/axis2-mtompolicy-1.6.2.jar b/lib/axis2-mtompolicy-1.6.2.jar new file mode 100644 index 0000000..561e84a Binary files /dev/null and b/lib/axis2-mtompolicy-1.6.2.jar differ diff --git a/lib/axis2-saaj-1.6.2.jar b/lib/axis2-saaj-1.6.2.jar new file mode 100644 index 0000000..c14531d Binary files /dev/null and b/lib/axis2-saaj-1.6.2.jar differ diff --git a/lib/axis2-soapmonitor-servlet-1.6.2.jar b/lib/axis2-soapmonitor-servlet-1.6.2.jar new file mode 100644 index 0000000..276dac7 Binary files /dev/null and b/lib/axis2-soapmonitor-servlet-1.6.2.jar differ diff --git a/lib/axis2-spring-1.6.2.jar b/lib/axis2-spring-1.6.2.jar new file mode 100644 index 0000000..30b9baa Binary files /dev/null and b/lib/axis2-spring-1.6.2.jar differ diff --git a/lib/axis2-transport-http-1.6.2.jar b/lib/axis2-transport-http-1.6.2.jar new file mode 100644 index 0000000..b1dad78 Binary files /dev/null and b/lib/axis2-transport-http-1.6.2.jar differ diff --git a/lib/axis2-transport-local-1.6.2.jar b/lib/axis2-transport-local-1.6.2.jar new file mode 100644 index 0000000..34a7073 Binary files /dev/null and b/lib/axis2-transport-local-1.6.2.jar differ diff --git a/lib/axis2-xmlbeans-1.6.2.jar b/lib/axis2-xmlbeans-1.6.2.jar new file mode 100644 index 0000000..58fba9b Binary files /dev/null and b/lib/axis2-xmlbeans-1.6.2.jar differ diff --git a/lib/bcel-5.1.jar b/lib/bcel-5.1.jar new file mode 100644 index 0000000..524e375 Binary files /dev/null and b/lib/bcel-5.1.jar differ diff --git a/lib/commons-beanutils-1.7.0.jar b/lib/commons-beanutils-1.7.0.jar new file mode 100644 index 0000000..b1b89c9 Binary files /dev/null and b/lib/commons-beanutils-1.7.0.jar differ diff --git a/lib/commons-cli-1.2.jar b/lib/commons-cli-1.2.jar new file mode 100644 index 0000000..ce4b9ff Binary files /dev/null and b/lib/commons-cli-1.2.jar differ diff --git a/lib/commons-codec-1.3.jar b/lib/commons-codec-1.3.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/lib/commons-codec-1.3.jar differ diff --git a/lib/commons-collections-3.2.jar b/lib/commons-collections-3.2.jar new file mode 100644 index 0000000..75580be Binary files /dev/null and b/lib/commons-collections-3.2.jar differ diff --git a/lib/commons-fileupload-1.2.jar b/lib/commons-fileupload-1.2.jar new file mode 100644 index 0000000..12539f5 Binary files /dev/null and b/lib/commons-fileupload-1.2.jar differ diff --git a/lib/commons-httpclient-3.1.jar b/lib/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/lib/commons-httpclient-3.1.jar differ diff --git a/lib/commons-io-1.4.jar b/lib/commons-io-1.4.jar new file mode 100644 index 0000000..133dc6c Binary files /dev/null and b/lib/commons-io-1.4.jar differ diff --git a/lib/commons-lang-2.4.jar b/lib/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/lib/commons-lang-2.4.jar differ diff --git a/lib/commons-logging-1.1.1.jar b/lib/commons-logging-1.1.1.jar new file mode 100644 index 0000000..1deef14 Binary files /dev/null and b/lib/commons-logging-1.1.1.jar differ diff --git a/lib/commons-logging-1.1.jar b/lib/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/lib/commons-logging-1.1.jar differ diff --git a/lib/dom4j-1.6.1.jar b/lib/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/lib/dom4j-1.6.1.jar differ diff --git a/lib/ezmorph-1.0.4.jar b/lib/ezmorph-1.0.4.jar new file mode 100644 index 0000000..7625af6 Binary files /dev/null and b/lib/ezmorph-1.0.4.jar differ diff --git a/lib/geronimo-annotation_1.0_spec-1.1.jar b/lib/geronimo-annotation_1.0_spec-1.1.jar new file mode 100644 index 0000000..7a6f529 Binary files /dev/null and b/lib/geronimo-annotation_1.0_spec-1.1.jar differ diff --git a/lib/geronimo-jaxws_2.2_spec-1.0.jar b/lib/geronimo-jaxws_2.2_spec-1.0.jar new file mode 100644 index 0000000..888f839 Binary files /dev/null and b/lib/geronimo-jaxws_2.2_spec-1.0.jar differ diff --git a/lib/geronimo-jta_1.1_spec-1.1.jar b/lib/geronimo-jta_1.1_spec-1.1.jar new file mode 100644 index 0000000..bba9290 Binary files /dev/null and b/lib/geronimo-jta_1.1_spec-1.1.jar differ diff --git a/lib/geronimo-saaj_1.3_spec-1.0.1.jar b/lib/geronimo-saaj_1.3_spec-1.0.1.jar new file mode 100644 index 0000000..b2f6e81 Binary files /dev/null and b/lib/geronimo-saaj_1.3_spec-1.0.1.jar differ diff --git a/lib/geronimo-stax-api_1.0_spec-1.0.1.jar b/lib/geronimo-stax-api_1.0_spec-1.0.1.jar new file mode 100644 index 0000000..ab1ee3b Binary files /dev/null and b/lib/geronimo-stax-api_1.0_spec-1.0.1.jar differ diff --git a/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar b/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar new file mode 100644 index 0000000..c8a795a Binary files /dev/null and b/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar differ diff --git a/lib/httpcore-4.0.jar b/lib/httpcore-4.0.jar new file mode 100644 index 0000000..37eb7d4 Binary files /dev/null and b/lib/httpcore-4.0.jar differ diff --git a/lib/iText-5.0.2.jar b/lib/iText-5.0.2.jar new file mode 100644 index 0000000..ed95653 Binary files /dev/null and b/lib/iText-5.0.2.jar differ diff --git a/lib/iTextAsian.jar b/lib/iTextAsian.jar new file mode 100644 index 0000000..3fa2157 Binary files /dev/null and b/lib/iTextAsian.jar differ diff --git a/lib/itext-2.0.3.jar b/lib/itext-2.0.3.jar new file mode 100644 index 0000000..9c6179d Binary files /dev/null and b/lib/itext-2.0.3.jar differ diff --git a/lib/jalopy-1.5rc3.jar b/lib/jalopy-1.5rc3.jar new file mode 100644 index 0000000..fe51ce2 Binary files /dev/null and b/lib/jalopy-1.5rc3.jar differ diff --git a/lib/jaxb-api-2.1.jar b/lib/jaxb-api-2.1.jar new file mode 100644 index 0000000..be3d6dc Binary files /dev/null and b/lib/jaxb-api-2.1.jar differ diff --git a/lib/jaxb-impl-2.1.7.jar b/lib/jaxb-impl-2.1.7.jar new file mode 100644 index 0000000..034c158 Binary files /dev/null and b/lib/jaxb-impl-2.1.7.jar differ diff --git a/lib/jaxb-xjc-2.1.7.jar b/lib/jaxb-xjc-2.1.7.jar new file mode 100644 index 0000000..ba2ec46 Binary files /dev/null and b/lib/jaxb-xjc-2.1.7.jar differ diff --git a/lib/jaxen-1.1.6.jar b/lib/jaxen-1.1.6.jar new file mode 100644 index 0000000..52f47a4 Binary files /dev/null and b/lib/jaxen-1.1.6.jar differ diff --git a/lib/jaxws-tools-2.1.3.jar b/lib/jaxws-tools-2.1.3.jar new file mode 100644 index 0000000..1006bfd Binary files /dev/null and b/lib/jaxws-tools-2.1.3.jar differ diff --git a/lib/jdom.jar b/lib/jdom.jar new file mode 100644 index 0000000..65a1b3f Binary files /dev/null and b/lib/jdom.jar differ diff --git a/lib/jettison-1.0-RC2.jar b/lib/jettison-1.0-RC2.jar new file mode 100644 index 0000000..3a00ed2 Binary files /dev/null and b/lib/jettison-1.0-RC2.jar differ diff --git a/lib/jibx-bind-1.2.jar b/lib/jibx-bind-1.2.jar new file mode 100644 index 0000000..c8d3887 Binary files /dev/null and b/lib/jibx-bind-1.2.jar differ diff --git a/lib/jibx-run-1.2.jar b/lib/jibx-run-1.2.jar new file mode 100644 index 0000000..6b467d3 Binary files /dev/null and b/lib/jibx-run-1.2.jar differ diff --git a/lib/json-lib-2.2.2-jdk15.jar b/lib/json-lib-2.2.2-jdk15.jar new file mode 100644 index 0000000..27e7c7c Binary files /dev/null and b/lib/json-lib-2.2.2-jdk15.jar differ diff --git a/lib/json-lib-2.2.3-jdk13.jar b/lib/json-lib-2.2.3-jdk13.jar new file mode 100644 index 0000000..a6513db Binary files /dev/null and b/lib/json-lib-2.2.3-jdk13.jar differ diff --git a/lib/jsr311-api-1.0.jar b/lib/jsr311-api-1.0.jar new file mode 100644 index 0000000..2bede66 Binary files /dev/null and b/lib/jsr311-api-1.0.jar differ diff --git a/lib/juli-6.0.16.jar b/lib/juli-6.0.16.jar new file mode 100644 index 0000000..c3fe977 Binary files /dev/null and b/lib/juli-6.0.16.jar differ diff --git a/lib/log4j-1.2.15.jar b/lib/log4j-1.2.15.jar new file mode 100644 index 0000000..c930a6a Binary files /dev/null and b/lib/log4j-1.2.15.jar differ diff --git a/lib/mail-1.4.jar b/lib/mail-1.4.jar new file mode 100644 index 0000000..fd4555b Binary files /dev/null and b/lib/mail-1.4.jar differ diff --git a/lib/mex-1.6.2-impl.jar b/lib/mex-1.6.2-impl.jar new file mode 100644 index 0000000..ed67cf3 Binary files /dev/null and b/lib/mex-1.6.2-impl.jar differ diff --git a/lib/neethi-3.0.2.jar b/lib/neethi-3.0.2.jar new file mode 100644 index 0000000..383efde Binary files /dev/null and b/lib/neethi-3.0.2.jar differ diff --git a/lib/ojdbc6.jar b/lib/ojdbc6.jar new file mode 100644 index 0000000..ec3d6f1 Binary files /dev/null and b/lib/ojdbc6.jar differ diff --git a/lib/regexp-1.2.jar b/lib/regexp-1.2.jar new file mode 100644 index 0000000..713441c Binary files /dev/null and b/lib/regexp-1.2.jar differ diff --git a/lib/tribes-6.0.16.jar b/lib/tribes-6.0.16.jar new file mode 100644 index 0000000..bb85de1 Binary files /dev/null and b/lib/tribes-6.0.16.jar differ diff --git a/lib/woden-api-1.0M9.jar b/lib/woden-api-1.0M9.jar new file mode 100644 index 0000000..3b07e8e Binary files /dev/null and b/lib/woden-api-1.0M9.jar differ diff --git a/lib/woden-impl-commons-1.0M9.jar b/lib/woden-impl-commons-1.0M9.jar new file mode 100644 index 0000000..f99c8d7 Binary files /dev/null and b/lib/woden-impl-commons-1.0M9.jar differ diff --git a/lib/woden-impl-dom-1.0M9.jar b/lib/woden-impl-dom-1.0M9.jar new file mode 100644 index 0000000..0e3fff5 Binary files /dev/null and b/lib/woden-impl-dom-1.0M9.jar differ diff --git a/lib/wsdl4j-1.6.2.jar b/lib/wsdl4j-1.6.2.jar new file mode 100644 index 0000000..b9ffc36 Binary files /dev/null and b/lib/wsdl4j-1.6.2.jar differ diff --git a/lib/wstx-asl-3.2.9.jar b/lib/wstx-asl-3.2.9.jar new file mode 100644 index 0000000..ffdbd1f Binary files /dev/null and b/lib/wstx-asl-3.2.9.jar differ diff --git a/lib/xalan-2.7.0.jar b/lib/xalan-2.7.0.jar new file mode 100644 index 0000000..007be39 Binary files /dev/null and b/lib/xalan-2.7.0.jar differ diff --git a/lib/xml-resolver-1.2.jar b/lib/xml-resolver-1.2.jar new file mode 100644 index 0000000..e535bdc Binary files /dev/null and b/lib/xml-resolver-1.2.jar differ diff --git a/lib/xmlbeans-2.3.0.jar b/lib/xmlbeans-2.3.0.jar new file mode 100644 index 0000000..ccd8163 Binary files /dev/null and b/lib/xmlbeans-2.3.0.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..ef1af3e --- /dev/null +++ b/plugin.xml @@ -0,0 +1,1853 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/connor/wf/plm/Activator.java b/src/com/connor/wf/plm/Activator.java new file mode 100644 index 0000000..a9bb5cb --- /dev/null +++ b/src/com/connor/wf/plm/Activator.java @@ -0,0 +1,61 @@ +package com.connor.wf.plm; + +import org.eclipse.jface.resource.ImageDescriptor; +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 = "com.connor.wf.plm"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/src/com/connor/wf/plm/Wf000Handler.java b/src/com/connor/wf/plm/Wf000Handler.java new file mode 100644 index 0000000..3c40231 --- /dev/null +++ b/src/com/connor/wf/plm/Wf000Handler.java @@ -0,0 +1,112 @@ +package com.connor.wf.plm; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchPage; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +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.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.util.PlatformHelper; + +/** + * :Wf000Handler + * : + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf000Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + /** + * + * һ߳ʾ贰ڡ + * @param pz + * @return + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + IWorkbenchPage iworkbenchpage = PlatformHelper.getCurrentPage(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session=(TCSession) app.getSession(); + TCClassificationService classificationService = session.getClassificationService(); + try { + ICSAdminClass c = classificationService.newICSAdminClass(); + + ICSSearchResult[] searchs = classificationService.searchICOs("ICM010601", null, 0); + String icoUid = searchs[0].getIcoUid(); + TCComponentICO ico = (TCComponentICO) session.stringToComponent(icoUid); + ICSProperty[] icss = ico.getICSProperties(true); + for (int i = 0; i < icss.length; i++) { + String value = icss[i].getValue(); + System.out.println("value================="+value); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + try { + TCComponentProjectType type=(TCComponentProjectType) session.getTypeComponent("TC_Project"); + TCComponentProject tccomponentproject = type.find("P00001"); + System.out.println("tccomponentproject="+tccomponentproject); + iworkbenchpage.showView("com.teamcenter.rac.project.ProjectDefinitionView", null, 2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + +// com.teamcenter.rac.aif.kernel.InterfaceAIFComponent ainterfaceaifcomponent[] = SelectionHelper.getTargetComponents(HandlerUtil.getCurrentSelection(arg0)); +// if(ainterfaceaifcomponent.length > 1) +// { +// MessageBox.post(Messages.getString("multiprogramSelected"), Messages.getString("programNotSelected.TITLE"), 1); +// return null; +// } +// TCComponentProject tccomponentproject = (TCComponentProject)AdapterUtil.getAdapter(ainterfaceaifcomponent[0], com.teamcenter.rac.kernel.TCComponentProject.class); +// if(tccomponentproject != null) +// try +// { +// if(tccomponentproject.getLogicalProperty("use_program_security")) +// { +// IWorkbenchPage iworkbenchpage = PlatformHelper.getCurrentPage(); +// if(iworkbenchpage != null) +// { +// iworkbenchpage.showView("com.teamcenter.rac.project.ProjectDefinitionView", null, 2); +// ProjectDefinitionView projectdefinitionview = ProjectDefinitionView.getProjectDefViewInstance(); +// projectdefinitionview.clearOperation(); +// projectdefinitionview.setParentProgram(tccomponentproject.getProperty("project_id")); +// projectdefinitionview.setProjectButton(); +// ProgramTreeFilter programtreefilter = new ProgramTreeFilter(tccomponentproject, 3); +// projectdefinitionview.getProjectTeamManager().getAvailableTreeViewer().addFilter(programtreefilter); +// projectdefinitionview.getProjectTeamManager().setParentProject(tccomponentproject); +// } +// } else +// { +// MessageBox.post(Messages.getString("programNotSelected"), Messages.getString("programNotSelected.TITLE"), 1); +// } +// } +// catch(TCException tcexception) +// { +// Logger.getLogger("com.teamcenter.rac.project.handlers.CreateChildProjectHandler").error(tcexception.getLocalizedMessage(), tcexception); +// } +// catch(PartInitException partinitexception) +// { +// Logger.getLogger("com.teamcenter.rac.project.handlers.CreateChildProjectHandler").error(partinitexception.getLocalizedMessage(), partinitexception); +// } +// else +// MessageBox.post(Messages.getString("programNotSelected"), Messages.getString("programNotSelected.TITLE"), 1); + return null; + } + +} diff --git a/src/com/connor/wf/plm/handlers/SampleHandler.java b/src/com/connor/wf/plm/handlers/SampleHandler.java new file mode 100644 index 0000000..4b13e9c --- /dev/null +++ b/src/com/connor/wf/plm/handlers/SampleHandler.java @@ -0,0 +1,34 @@ +package com.connor.wf.plm.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class SampleHandler extends AbstractHandler { + /** + * The constructor. + */ + public SampleHandler() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); + MessageDialog.openInformation( + window.getShell(), + "Plm", + "Hello, Eclipse world"); + return null; + } +} diff --git a/src/com/connor/wf/plm/table/ButtonEditor.java b/src/com/connor/wf/plm/table/ButtonEditor.java new file mode 100644 index 0000000..62e891c --- /dev/null +++ b/src/com/connor/wf/plm/table/ButtonEditor.java @@ -0,0 +1,44 @@ +package com.connor.wf.plm.table; + +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.JButton; +import javax.swing.JCheckBox; +import javax.swing.JOptionPane; +import javax.swing.JTable; + +import com.teamcenter.rac.util.DateButton; + +public class ButtonEditor extends DefaultCellEditor { + protected DateButton button; + private String label; + private boolean isPushed; + + public ButtonEditor(JCheckBox checkBox) { + super(checkBox); + button = new DateButton(); + + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (isSelected) { + button.setForeground(table.getSelectionForeground()); + button.setBackground(table.getSelectionBackground()); + } else { + button.setForeground(table.getForeground()); + button.setBackground(table.getBackground()); + } + + return button; + } + + public Object getCellEditorValue() { + SimpleDateFormat format=new SimpleDateFormat("20YYMMdd"); + return format.format(button.getDate()); + } + +} \ No newline at end of file diff --git a/src/com/connor/wf/plm/table/CTMap.java b/src/com/connor/wf/plm/table/CTMap.java new file mode 100644 index 0000000..752a2d2 --- /dev/null +++ b/src/com/connor/wf/plm/table/CTMap.java @@ -0,0 +1,207 @@ +package com.connor.wf.plm.table; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Point; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + + @Override + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + @Override + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) { + return true; + } + return false; + } + + + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + + public void insertRow(int row) { + Vector rowData = new Vector(getColumnCount()); + + dataVector.insertElementAt(rowData, row); + System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + + int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + } + } + } + span = newSpan; + rowSize = span.length; + } + + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size()-1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount()-1; i++) { + + ((Vector)dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/src/com/connor/wf/plm/table/CTUI.java b/src/com/connor/wf/plm/table/CTUI.java new file mode 100644 index 0000000..ba58e62 --- /dev/null +++ b/src/com/connor/wf/plm/table/CTUI.java @@ -0,0 +1,94 @@ +package com.connor.wf.plm.table; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c){ + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = table.getColumnModel().getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = table.rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = table.getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, table.getRowHeight() + table.getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) table.getModel(); + int numColumns = table.getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = table.getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = table.getRowMargin(); + int spacingWidth = table.getColumnModel().getColumnMargin(); + + Color c = g.getColor(); + g.setColor(table.getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + spacingHeight / 2, cellRect.width - spacingWidth, + cellRect.height - spacingHeight); + + if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { + Component component = table.getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = table.getCellRenderer(row, column); + Component component = table.prepareRenderer(renderer, row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, + true); + } + } +} \ No newline at end of file diff --git a/src/com/connor/wf/plm/table/CTable.java b/src/com/connor/wf/plm/table/CTable.java new file mode 100644 index 0000000..f787aa9 --- /dev/null +++ b/src/com/connor/wf/plm/table/CTable.java @@ -0,0 +1,145 @@ +package com.connor.wf.plm.table; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +public class CTable extends JTable { + Map map; + public CTable(TableModel model) { + super(model); + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + map=new HashMap(); + } + public String getToolTipText(MouseEvent e) { + int row=this.rowAtPoint(e.getPoint()); + int col=this.columnAtPoint(e.getPoint()); + String tiptextString=null; + if(row>-1 && col>-1){ + Object value=this.getValueAt(row, col); + if(null!=value && !"".equals(value)) + tiptextString=value.toString();//ʾԪ + } + return tiptextString; + } + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if ((row < 0) || (column < 0) || (getRowCount() <= row) || (getColumnCount() <= column)) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth() + columnMargin; + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + spacing.height / 2, + cellFrame.width - spacing.width, cellFrame.height - spacing.height); + } + return cellFrame; + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height); + } + public void setCombo(int row,int col,TableCellEditor ce){ + map.put(new Point(row,col), ce); + } + public TableCellEditor getCellEditor(int row, int column){ + Point point = new Point(row,column); + if(map.containsKey(point)){ + return map.get(point); + }else{ + return super.getCellEditor(row, column); + } + } + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } +} \ No newline at end of file diff --git a/src/com/connor/wf/plm/table/CTest.java b/src/com/connor/wf/plm/table/CTest.java new file mode 100644 index 0000000..d413882 --- /dev/null +++ b/src/com/connor/wf/plm/table/CTest.java @@ -0,0 +1,49 @@ +package com.connor.wf.plm.table; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.plaf.basic.BasicTableUI; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class CTest { + static int[] rows; + static JScrollPane pane; + + public static void main(String args[]) { + JFrame dialog = new JFrame("Table with cell spanning"); + final CTMap map = new CTMap(5,5); + final CTable table = new CTable(map); + table.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + pane = new JScrollPane(table); + JButton button = new JButton("add"); + table.setShowGrid(false); + //final JDialog dialog = new JDialog(); + dialog.setPreferredSize(new Dimension(500,500)); + dialog.setLayout(new BorderLayout()); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + table.setRowHeight(2,50); + table.revalidate(); + table.repaint(); + map.combine(new int[]{0,1,2,3}, new int[]{1}); + } + }); + dialog.add(pane, BorderLayout.CENTER); + dialog.add(button, BorderLayout.SOUTH); + + dialog.show(); + } +} \ No newline at end of file diff --git a/src/com/connor/wf/plm/table/CellSpan.java b/src/com/connor/wf/plm/table/CellSpan.java new file mode 100644 index 0000000..27e4adc --- /dev/null +++ b/src/com/connor/wf/plm/table/CellSpan.java @@ -0,0 +1,14 @@ +package com.connor.wf.plm.table; + +interface CellSpan { + public final int ROW = 0; + public final int COLUMN = 1; + + public int[] getSpan(int row, int column); + public void setSpan(int[] span, int row, int column); + + public boolean isVisible(int row, int column); + + public void combine(int[] rows, int[] columns); + +} \ No newline at end of file diff --git a/src/com/connor/wf/plm/table/TableCellTextAreaRenderer.java b/src/com/connor/wf/plm/table/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..0409720 --- /dev/null +++ b/src/com/connor/wf/plm/table/TableCellTextAreaRenderer.java @@ -0,0 +1,72 @@ +package com.connor.wf.plm.table; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.BorderFactory; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.table.TableCellRenderer; + +public class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + public TableCellTextAreaRenderer() { + setLineWrap(true); + setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + setBackground(Color.white); + setForeground(Color.black); + if(isSelected){ + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // Ϲæ + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + +// @Override +// public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, +// int row, int column) { +// // TODO Auto-generated method stub +// int maxPreferredHeight = 0; +// for (int i = 0; i < table.getColumnCount(); i++) { +// setText("" + table.getValueAt(row, i)); +// setSize(table.getColumnModel().getColumn(column).getWidth(), 0); +// maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); +// } +// setBorder(BorderFactory.createLineBorder(Color.white)); +// setBackground(Color.white); +// setForeground(Color.black); +// if(isSelected){ +// setBackground(new Color(0, 120, 215)); +// setForeground(Color.white); +// } +// String val=(String) table.getValueAt(row, column); +// int w=0; +// if(val!=null){ +// w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); +// } +// if(w!=0){ +// //System.out.println("height:"+table.getRowHeight()*(w+1)); +// table.setRowHeight(row,table.getRowHeight()*(w+1)); +// } +// +// +// setText(value == null ? "" : value.toString()); +// return this; +// } +} \ No newline at end of file diff --git a/src/com/connor/wf/plm/table/TempTest.java b/src/com/connor/wf/plm/table/TempTest.java new file mode 100644 index 0000000..629682f --- /dev/null +++ b/src/com/connor/wf/plm/table/TempTest.java @@ -0,0 +1,57 @@ +package com.connor.wf.plm.table; + +import java.awt.BorderLayout; + +import javax.swing.JButton; +import javax.swing.JDialog; + +public class TempTest { + public static void main(String[] args) { +// String temp="";; +// String[] name=new String[]{"DZʧЧģʽͺ","СԹͼ","ʼƷ嵥","Ƽƻ","СԲƷ֤","ԭϿ","Ϣ","Ӧ̻ϵ","ԭϽϼ","Ӧ̳۱","ԭת׶","Ŀ˼·ܽ","䷽","С","Լⵥ","ɿĿ֤","Сɫ¼","С鹤ռ¼","ݱ","ɿ֤","ʵܽᱨ","С鹤յ","С鰲żƻ","Ʒоܱ","뵥","ԲƷ֤","עܹռ¼","ϼⱨ","Ŀ¼","ǰԤжƻ","ͻϹռ¼","ͻܽ","СԽ׶"}; +// String t=""; +// String te=""; +// String[] name2=new String[]{"ԭ嵥","Ʒ嵥","BOM","ԲƷ֤","","ͼ","嵥","PFMEA","ʼоƻ","ȷϼƻ","ƽƻ","տ","²Ʒ","̼¼ܽ","Ŀ","Թ֤","ʼо","ƽ","","ܽᱨ","ɿ֤","֤","ⱨ","Ŀ¼","ǰԤжƻ","ͻϹռ¼","ͻܽ","Խ׶"}; +// String[] name3=new String[]{"ԿƼƻ","տ","PSW","̼¼ܽ","Ŀ","PFMEA","ͼ","ԹŻƻ","ԹŻܽ","ͻʹȶԷ","ԭȶԷ","ƷȶԷ","ȶԷ","Խ׶"}; +// for(int i=0;i screenSize.height) { + frameSize.height = screenSize.height; + } + if (frameSize.width > screenSize.width) { + frameSize.width = screenSize.width; + } + + super.setLocation( + (screenSize.width - frameSize.width) / 2, + (screenSize.height - frameSize.height) / 2 + ); + } + + public Calendar getCalendar() { + return calendar; + } + + public String getCalendarByDate(String tag) { + + StringBuffer strRet = new StringBuffer(); + if (calendar != null) { + oldYear = calendar.get(Calendar.YEAR); + oldMonth = calendar.get(Calendar.MONTH)+1; + oldDate = calendar.get(Calendar.DATE); + + strRet.append(oldYear); + strRet.append(tag); + if (oldMonth < 10) + strRet.append("0" + oldMonth); + else + strRet.append(oldMonth); + strRet.append(tag); + if (oldDate < 10) + strRet.append("0" + oldDate); + else + strRet.append(oldDate); + + return strRet.toString(); + } + return null; + } + + public Date getCalendarByDate() { + if (calendar != null) + return calendar.getTime(); + return null; + } + //ʼpanel + private void initComponent() { + oldYear = calendar.get(Calendar.YEAR); + oldMonth = calendar.get(Calendar.MONTH); + oldDate = calendar.get(Calendar.DATE); + // this.setBorder(new TitledBorder("Date")); + this.getContentPane().setLayout(new BorderLayout()); + setNorthPanel(); + setCenterPanel(); + setSouthPanel(); + eventListenter(); + setData(); + } + //Ĭϵʱ伴Ϊǰʱ + private void setData() { + + year = calendar.get(Calendar.YEAR); + month = calendar.get(Calendar.MONTH); + date = calendar.get(Calendar.DATE); + comboBoxMonth.setSelectedIndex(month); + spinnerYear.setValue(new Integer(year)); + } + + private void eventListenter() { + + spinnerYear.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + year = Integer.parseInt(String.valueOf(spinnerYear.getValue())); + refreshTable(); + } + }); + + comboBoxMonth.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + month = comboBoxMonth.getSelectedIndex(); + refreshTable(); + } + }); + + table.getSelectionModel().addListSelectionListener( + new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) { + if (table.getSelectedRow()>-1&&table.getSelectedColumn()>-1) { + date = Integer.parseInt( + String.valueOf( + table.getValueAt( + table.getSelectedRow(), + table.getSelectedColumn() + ) + ) + ); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month); + calendar.set(Calendar.DATE, date); + } + } + } + ); + + AbstractAction right = (new AbstractAction() { + private static final long serialVersionUID = -3429888240127305492L; + public void actionPerformed(ActionEvent e) { + if (table.getColumnCount() == table.getSelectedColumn() + 1) { + table.changeSelection( + table.getSelectedRow() + 1, + 0, + false, + false + ); + } else { + table.changeSelection( + table.getSelectedRow(), + table.getSelectedColumn() + 1, + false, + false + ); + } + } + }); + + AbstractAction left = (new AbstractAction() { + private static final long serialVersionUID = -2487040789339112435L; + public void actionPerformed(ActionEvent e) { + if (0 > table.getSelectedColumn() - 1) { + table.changeSelection( + table.getSelectedRow() - 1, + table.getColumnCount() - 1, + false, + false + ); + } else { + table.changeSelection( + table.getSelectedRow(), + table.getSelectedColumn() - 1, + false, + false + ); + } + } + }); + + InputMap inputMap = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0); + table.getActionMap().put(inputMap.get(keyStroke), right); + keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0); + table.getActionMap().put(inputMap.get(keyStroke), left); + okButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + calendar.set( + Calendar.YEAR, + Integer.parseInt( + String.valueOf(spinnerYear.getValue()) + ) + ); + calendar.set( + Calendar.MONTH, + comboBoxMonth.getSelectedIndex() + ); + calendar.set( + Calendar.DATE, + Integer.parseInt( + String.valueOf( + table.getValueAt( + table.getSelectedRow(), + table.getSelectedColumn() + ) + ) + ) + ); + + oldYear = calendar.get(Calendar.YEAR); + oldMonth = calendar.get(Calendar.MONTH); + oldDate = calendar.get(Calendar.DATE); + selecttime = CalendarPanel.this.getCalendarByDate(); +// TableWithRowHead tw = new TableWithRowHead(twrh,selecttime,bo); + SimpleDateFormat sdf =new SimpleDateFormat("YYYY-M-d HH:MM"); + text.setText(sdf.format(selecttime)); + setVisible(false); + } + + }); + + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + /* + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + calendar = null; + super.windowClosing(e); + } + }); + */ + + } + + private void refreshTable() { + for (int i = tableModel.getRowCount() - 1; i > 0; i--) { + tableModel.removeRow(i); + } + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month); + int maxDate = calendar.getActualMaximum(Calendar.DATE); + calendar.set(Calendar.DATE, 1); + int startDay = calendar.get(Calendar.DAY_OF_WEEK); + for (int i = 0; i < 6; i++) { + tableModel.addRow(new Object[7]); + } + int selectRow = -1; + int selectColumn = -1; + for (int i = 0; i < maxDate; i++) { + int m = (int) ((startDay - 1) / 7) + 1; + int n = (startDay - 1) % 7; + tableModel.setValueAt(String.valueOf(i + 1), m, n); + startDay = startDay + 1; + if (date != -1 && date == i + 1) { + selectRow = m; + selectColumn = n; + } + } + table.changeSelection(selectRow, selectColumn, false, false); + } + + + + private void setSouthPanel() { + + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.RIGHT)); + okButton = new JButton("OK"); + panel.add(okButton); + cancelButton = new JButton("Cancel"); + panel.add(cancelButton); + this.getContentPane().add(panel, BorderLayout.SOUTH); + } + + + private void setCenterPanel() { + + table = new JTable2(); + tableModel = new JTableModel2(); + tableModel.setColumnIdentifiers(days); + tableModel.addRow(days); + table.setModel(tableModel); + for (int i = 0; i < 7; i++) { + table.getColumnModel().getColumn(i).setCellRenderer( + new DefaultTableCellRenderer2() + ); + } + this.getContentPane().add(table, BorderLayout.CENTER); + } + + private void setNorthPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + comboBoxMonth = new JComboBox(); + for (int i = 0; i < months.length; i++) { + comboBoxMonth.addItem(months[i]); + } + comboBoxMonth.setSelectedIndex(-1); + panel.add(comboBoxMonth); + RolloverSpinnerListModel numberModel = new RolloverSpinnerListModel( + 1980, 1980, 2099, 1); + spinnerYear = new JSpinner(numberModel); + JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor( + spinnerYear, ""); + spinnerYear.setEditor(numberEditor); + panel.add(spinnerYear); + this.getContentPane().add(panel, BorderLayout.NORTH); + } + + public static void main(String[] args) { + + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(EXIT_ON_CLOSE); + CalendarPanel calendarPanel = new CalendarPanel(frame); + // frame.getContentPane().add(calendarPanel, BorderLayout.CENTER); + // calendarPanel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + calendarPanel.setVisible(true); + } + + protected void validateTree() { + + super.validateTree(); + if (flag) { + table.requestFocus(); + flag = false; + } + } +} + +class RolloverSpinnerListModel extends SpinnerNumberModel { + + private static final long serialVersionUID = 7366455425120197392L; + + public RolloverSpinnerListModel( + int value, + int minimum, + int maximum, + int stepSize + ) { + super(value, minimum, maximum, stepSize); + } + + public Object getNextValue() { + + Object returnValue = super.getNextValue(); + if (returnValue == null) { + returnValue = super.getMinimum(); + } + return returnValue; + } + + public Object getPreviousValue() { + + Object returnValue = super.getPreviousValue(); + if (returnValue == null) { + returnValue = super.getMaximum(); + } + return returnValue; + } +} + +class JTable2 extends JTable { + + private static final long serialVersionUID = 2092799354481792367L; + + public JTable2() { + this.getTableHeader().setReorderingAllowed(false); + this.getTableHeader().setResizingAllowed(false); + this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + this.setCellSelectionEnabled(true); + this.setGridColor(Color.white); + } + + public void changeSelection( + int rowIndex, + int columnIndex, + boolean toggle, + boolean extend + ) { + + if (this.getValueAt(rowIndex, columnIndex) == null) { + return; + } + + if (rowIndex == 0) { + return; + } + super.changeSelection(rowIndex, columnIndex, toggle, extend); + } + + public void repaint(int x, int y, int width, int height) { + + super.repaint(x, y, width, height); + if (height > 0) { + makeTableRowHeight(); + } + } + + protected void validateTree() { + super.validateTree(); + makeTableRowHeight(); + } + + private void makeTableRowHeight() { + + int rowHeight = (int) ((this.getHeight() / 7) * 0.6); + if (rowHeight > 0) { + this.setRowHeight(0, rowHeight); + } + + rowHeight = (int) ((this.getHeight() - rowHeight) / 6); + if (rowHeight > 0) { + for (int i = 1; i < 8; i++) { + this.setRowHeight(i, rowHeight); + } + } + } +} + + + +class JTableModel2 extends DefaultTableModel { + + private static final long serialVersionUID = 3655520869200784738L; + public boolean isCellEditable(int row, int column) { + return false; + } +} + +class DefaultTableCellRenderer2 extends DefaultTableCellRenderer { + + private static final long serialVersionUID = -8779549993366848535L; + public Component getTableCellRendererComponent( + JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column + ) { + Component component = + super.getTableCellRendererComponent( + table, + value, + isSelected, + hasFocus, + row, + column + ); + + this.setHorizontalAlignment(SwingConstants.CENTER); + + if (row == 0) { + component.setBackground( + UIManager.getColor("Table.focusCellForeground") + ); + + component.setForeground( + UIManager.getColor("Table.focusCellBackground") + ); + return component; + } else { + if (isSelected) { + component.setBackground( + UIManager.getColor("Table.focusCellForeground") + ); + component.setForeground( + UIManager.getColor("Table.focusCellBackground") + ); + } else { + component.setBackground( + UIManager.getColor("Table.focusCellBackground") + ); + component.setForeground( + UIManager.getColor("Table.focusCellForeground") + ); + } + + if (column == 0 || column == 6) { + component.setForeground(Color.red); + } + } + return component; + } +} + + diff --git a/src/com/connor/wf/plm/util/ClassAttributeBean.java b/src/com/connor/wf/plm/util/ClassAttributeBean.java new file mode 100644 index 0000000..c054608 --- /dev/null +++ b/src/com/connor/wf/plm/util/ClassAttributeBean.java @@ -0,0 +1,56 @@ +package com.connor.wf.plm.util; + +import java.util.Map; + +public class ClassAttributeBean { + private int id;//id + private String name;// + private boolean islov;//Ƿlov + private int type;// + private Map lov;//lovʾֵ(key),ʵֵ(val) + private String val;//ֵ + + public String getVal() { + return val; + } + public void setVal(String val) { + this.val = val; + } + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public boolean isIslov() { + return islov; + } + public void setIslov(boolean islov) { + this.islov = islov; + } + public int getType() { + return type; + } + public void setType(int type) { + this.type = type; + } + + public Map getLov() { + return lov; + } + public void setLov(Map lov) { + this.lov = lov; + } + @Override + public String toString() { + return "ClassAttributeBean [id=" + id + ", name=" + name + ", islov=" + + islov + ", type=" + type + "]"; + } + +} diff --git a/src/com/connor/wf/plm/util/ClassProperty.java b/src/com/connor/wf/plm/util/ClassProperty.java new file mode 100644 index 0000000..391fe6c --- /dev/null +++ b/src/com/connor/wf/plm/util/ClassProperty.java @@ -0,0 +1,42 @@ +package com.connor.wf.plm.util; + +/** + * @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/connor/wf/plm/util/CodeBean.java b/src/com/connor/wf/plm/util/CodeBean.java new file mode 100644 index 0000000..37402dd --- /dev/null +++ b/src/com/connor/wf/plm/util/CodeBean.java @@ -0,0 +1,97 @@ +package com.connor.wf.plm.util; + +import java.util.List; + +/** + * ʵ + * @author zl + * + */ +public class CodeBean { + private String type; // + private List names; // + private String name; // + private List codes; // + private String code; //ǰ׺ + private String min; //ˮСֵ + private String max; //ˮֵ + private String num; //ˮλ(0ʾ) 5λΪ00000 + private String end; //׺ + private String classID; //id + private CopyPropsBean copyPropBean;//Ҫͬ(->) + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public List getNames() { + return names; + } + public void setNames(List names) { + this.names = names; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public List getCodes() { + return codes; + } + public void setCodes(List codes) { + this.codes = codes; + } + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + public String getMin() { + return min; + } + public void setMin(String min) { + this.min = min; + } + public String getMax() { + return max; + } + public void setMax(String max) { + this.max = max; + } + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } + public String getEnd() { + return end; + } + public void setEnd(String end) { + this.end = end; + } + public String getClassID() { + return classID; + } + public void setClassID(String classID) { + this.classID = classID; + } + + public CopyPropsBean getCopyPropBean() { + return copyPropBean; + } + public void setCopyPropBean(CopyPropsBean copyPropBean) { + this.copyPropBean = copyPropBean; + } + @Override + public String toString() { + return "CodeBean [type=" + type + ", names=" + names + ", name=" + name + + ", codes=" + codes + ", code=" + code + ", min=" + min + + ", max=" + max + ", num=" + num + ", end=" + end + + ", classID=" + classID + "]"; + } + +} diff --git a/src/com/connor/wf/plm/util/CopyPropsBean.java b/src/com/connor/wf/plm/util/CopyPropsBean.java new file mode 100644 index 0000000..5dc510b --- /dev/null +++ b/src/com/connor/wf/plm/util/CopyPropsBean.java @@ -0,0 +1,26 @@ +package com.connor.wf.plm.util; + +import java.util.List; + +/** + * ͬ + * @author zl + * + */ +public class CopyPropsBean { + private String type; //WF2_finPartRevision + private List props;//REV.object_desc=FORM.wf3_oldmaterial ... + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public List getProps() { + return props; + } + public void setProps(List props) { + this.props = props; + } + +} diff --git a/src/com/connor/wf/plm/util/DataBaseControl.java b/src/com/connor/wf/plm/util/DataBaseControl.java new file mode 100644 index 0000000..fb6ccb9 --- /dev/null +++ b/src/com/connor/wf/plm/util/DataBaseControl.java @@ -0,0 +1,474 @@ +package com.connor.wf.plm.util; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DataBaseControl { + + /** ************************ݿ:*********************************** */ + /** + * kelsen .... + */ + Connection conn; + + ResultSet rs; + + PreparedStatement pstmt; + + Statement stmt; + + String strSQLQuery; + + public String str_Information = ""; + + private String strDriver = "oracle.jdbc.driver.OracleDriver"; + private String strUrl = ""; + private String strUserName = ""; + private String strPassword = ""; + + /** + * + */ + public DataBaseControl(String strDriver, String strUrl, String strUserName, + String strPassword) { + // this.strDriver ="oracle.jdbc.driver.OracleDriver";// + // this.strUrl = "jdbc:oracle:thin:@127.0.0.1:1521:tc";//· + // this.strUserName = "infodba";//ݿû + // this.strPassword = "infodba";//ݿ + + + this.strDriver = strDriver; // "oracle.jdbc.driver.OracleDriver";// + this.strUrl = strUrl; // "jdbc:oracle:thin:@127.0.0.1:1521:tceng";//· + this.strUserName = strUserName; // "infodba";//ݿû + this.strPassword = strPassword; // "infodba";//ݿ + + // + try { + Class.forName(strDriver);// ͨڴ + } catch (ClassNotFoundException cnfe) { + cnfe.printStackTrace(); + } + // try { + // Class.forName("org.objectweb.rmijdbc.Driver").newInstance(); + // } catch (InstantiationException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } catch (IllegalAccessException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } catch (ClassNotFoundException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + } + + /** + * + */ + public DataBaseControl(TCSession session) { + + String[] stringArray = session.getPreferenceService().getStringArray(4, + "WF2_SQL_Connect"); + if (stringArray != null && stringArray.length == 3) { + strUrl = "jdbc:oracle:thin:@" + stringArray[0]; + strUserName = stringArray[1]; + strPassword = stringArray[2]; + } else { + MessageBox.post("δWF2_SQL_Connectѡ޷Ϣ!", "", + MessageBox.ERROR); + } + + // + try { + Class.forName(strDriver);// ͨڴ + } catch (ClassNotFoundException cnfe) { + cnfe.printStackTrace(); + } + + } + + /** + * + * + * @param strSQLQuery + */ + public void dbModify(String strSQLQuery) { + + openDataBase(); + + try { + stmt = conn.createStatement(); + stmt.executeUpdate(strSQLQuery); + } catch (SQLException sqle2) { + sqle2.printStackTrace(); + } + + closeDataBase(); + } + + /** + * ѯ + * + * @param strSQLQuery + * @return + */ + public ResultSet dbQuery(String strSQLQuery) { + ResultSet rs_result = null; + if (conn == null) + openDataBase(); + try { + stmt = conn.createStatement(); + rs_result = stmt.executeQuery(strSQLQuery); + + } catch (SQLException sqle2) { + sqle2.printStackTrace(); + } + return rs_result; + } + + /** + * ѯ2 + * + * @param strSQLQuery + * @return + */ + public ResultSet dbQuery2(String strSQLQuery, Object[] strs) { + ResultSet rs_result = null; + if (conn == null) + openDataBase(); + try { + // stmt = conn.createStatement(); + PreparedStatement ps = conn.prepareStatement(strSQLQuery); + for (int i = 0; i < strs.length; i++) { + ps.setObject(i + 1, strs[i]); + } + rs_result = ps.executeQuery(); + + } catch (SQLException sqle2) { + sqle2.printStackTrace(); + } + return rs_result; + } + + /** + * 2 + * + * @param strSQLQuery + */ + public void dbModify2(String strSQLQuery, Object[] strs) { + + openDataBase(); + + try { + // stmt = conn.createStatement(); + PreparedStatement ps = conn.prepareStatement(strSQLQuery); + for (int i = 0; i < strs.length; i++) { + ps.setObject(i + 1, strs[i]); + } + ps.executeUpdate(); + } catch (SQLException sqle2) { + sqle2.printStackTrace(); + } + + closeDataBase(); + } + + /** + * + * + */ + public void openDataBase() { + try { + // this.strUrl="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.29)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=tcprod)))"; + if (conn == null || conn.isClosed()) + conn = DriverManager.getConnection(strUrl, strUserName, + strPassword); + } catch (SQLException sqle) { + sqle.printStackTrace(); + MessageBox.post("ݿӴ" + sqle.getMessage(), "", 1); + } + } + + /** + * رݿ + * + */ + public void closeDataBase() { + try { + if (rs != null) { + try { + rs.close(); + } catch (SQLException sqlec) { + sqlec.printStackTrace(); + } + } + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException sqlec) { + sqlec.printStackTrace(); + } + } + if (conn != null && !conn.isClosed()) { + try { + conn.close(); + } catch (SQLException sqlecon) { + sqlecon.printStackTrace(); + } + + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 䴫ݿвѯ ѯõĽÿһ¼װһHashMap,keyԱֶ + * ѯ¼VectorжٸHasnMapԪ + * + * @param strSQLQuery + * @return + * @author xuk + */ + public Vector orgQuery(String strSQLQuery) { + openDataBase(); + Vector v_result = new Vector(); + try { + ResultSet rs_get = dbQuery(strSQLQuery); + // System.out.println("RS_GET:"+rs_get); + if (rs_get != null) { + ResultSetMetaData metaData = rs_get.getMetaData(); + + int i_ColumnCount = metaData.getColumnCount(); + // System.out.println("i_ColumnCount:"+i_ColumnCount); + while (rs_get.next()) { + // System.out.println("BJZJ2"+rs_get.getString("BJZJ2"));; + HashMap hm_unit = new HashMap(); + for (int i = 1; i <= i_ColumnCount; i++) { + hm_unit.put(metaData.getColumnName(i), + rs_get.getString(i)); + // System.out.println("metaData.getColumnName(i):"+metaData.getColumnName(i)); + // System.out.println("rs_get.getString(i):"+rs_get.getString(i)); + } + v_result.add(hm_unit); + } + } else { + str_Information = "" + strSQLQuery + "" + "ѯĽΪ\n"; + } + } catch (Exception e) { + e.printStackTrace(); + } + return v_result; + } + + /** + * ˮ + * + * @param type + * ˮ + * @param prefix + * ǰ׺ + * @param col + * ˮλ 4λ"0000" + * @return + * @throws Exception + */ + public String getNewCode(String type, String prefix, String col) + throws Exception { + openDataBase(); + String query = "select PREFIX,LSH from PLM_LSH where PLMTYPE= ? and PREFIX= ?"; + // ѯidݿе + ResultSet rs = dbQuery2(query, new Object[] { type, prefix }); + String lshstr = col; + String pre = ""; + String lsh = ""; + if (rs.next()) { + pre = rs.getString(1); + lsh = rs.getString(2); + System.out.println("sspre=" + pre); + System.out.println("sslsh=" + lsh); + if ("".equals(lsh)) { + throw new Exception("ˮΪգ"); + } + int ls = Integer.parseInt(lsh) + 1;// µˮ + lshstr = ls + ""; + if (col != null) { + DecimalFormat df = new DecimalFormat(col); + lshstr = df.format(ls); + } + String upin = "update PLM_LSH set LSH= ? where PLMTYPE= ? and PREFIX= ? "; + dbModify2(upin, new Object[] { lshstr, type, prefix }); + } else { + String upin = "insert into PLM_LSH(PLMTYPE,PREFIX,LSH) values ( ? , ? , ? )"; + dbModify2(upin, new Object[] { type, prefix, lshstr }); + + } + + closeDataBase(); + String newId = prefix + lshstr; + + return newId; + + } + + + /** + * ˮ + * + * @param type + * ˮ + * @param prefix + * ǰ׺ + * @param col + * ˮλ 4λ"0000" + * @return + * @throws Exception + */ + public String getNewCode(String type,CodeBean selCodeBean) + throws Exception { + String prefix = selCodeBean.getCode(); + String col = selCodeBean.getNum(); + String min = selCodeBean.getMin(); + String max = selCodeBean.getMax(); + openDataBase(); + String query = "select PREFIX,LSH from PLM_LSH where PLMTYPE= ? and PREFIX= ?"; + // ѯidݿе + ResultSet rs = dbQuery2(query, new Object[] { type, prefix }); + String lshstr = col; + String pre = ""; + String lsh = ""; + if (rs.next()) { + pre = rs.getString(1); + lsh = rs.getString(2); + System.out.println("sspre=" + pre); + System.out.println("sslsh=" + lsh); + if ("".equals(lsh)) { + throw new Exception("ˮΪգ"); + } + int ls = Integer.parseInt(lsh) + 1;// µˮ + int minls = Integer.parseInt(min); + int maxls = Integer.parseInt(max); + if (minls>ls) { + ls=minls; + } + if (ls>maxls) { + System.out.println(":ˮѳֵ"); + return "MAXERR"; + } + lshstr = ls + ""; + if (col != null) { + DecimalFormat df = new DecimalFormat(col); + lshstr = df.format(ls); + } + String upin = "update PLM_LSH set LSH= ? where PLMTYPE= ? and PREFIX= ? "; + dbModify2(upin, new Object[] { lshstr, type, prefix }); + } else { + if (col != null) { + int minls = Integer.parseInt(min); + DecimalFormat df = new DecimalFormat(col); + lshstr = df.format(minls); + } + String upin = "insert into PLM_LSH(PLMTYPE,PREFIX,LSH) values ( ? , ? , ? )"; + dbModify2(upin, new Object[] { type, prefix, lshstr }); + + } + + closeDataBase(); + String newId = prefix + lshstr; + + return newId; + + } + + + + /** + * ģ» + * @param v3 + * @param v16 + * @param time + * @param user + * @throws Exception + */ + public void setSqlConn(String v3, String v16, String time, String user) + throws Exception { + openDataBase(); +// WF_MJID varchar2(200),-- +// WF_YXJ varchar2(200),--» +// WF_DATE varchar2(200),--ϴ +// WF_USER varchar2(200),--ϴԱ + String query = "select WF_MJID from WF_MJ_XJ_T where WF_MJID = ? "; + // ѯidݿе + ResultSet rs = dbQuery2(query, new Object[] {v3}); + String wfmjid = ""; + if (rs.next()) { + System.out.println(""); + wfmjid = rs.getString(1); + System.out.println("wfmjid=" + wfmjid); + String upup = "UPDATE WF_MJ_XJ_T set WF_YXJ = ? ,WF_DATE= ?, WF_USER = ? WHERE WF_MJID = ? "; + dbModify2(upup, new Object[] {v16, time, user ,v3}); + + } else { + System.out.println(""); + System.out.println("wfmjid=" + v3); + String upin = "insert into WF_MJ_XJ_T(WF_MJID,WF_YXJ,WF_DATE,WF_USER) values ( ?,? , ? , ? )"; + dbModify2(upin, new Object[] {v3, v16, time, user}); + + } + + closeDataBase(); + + return ; + + } + + + /** + * + * + * @param args + */ + public static void main(String args[]) { + try { + + String str_DataBaseDriver = "oracle.jdbc.driver.OracleDriver"; + String str_URL = "jdbc:oracle:thin:@localhost:1521:tc11"; + String str_UserName = "infodba"; + String str_Password = "infodba"; + DataBaseControl dbc = new DataBaseControl(str_DataBaseDriver, + str_URL, str_UserName, str_Password); + // dbc.openDataBase(); + System.out.println("ӳɹ"); + // dbc.stmt = dbc.conn.createStatement(); + // String sql = "select * from PLM_LSH"; + // Vector rs_result = dbc.orgQuery(sql); + // for (int i = 0; i < rs_result.size(); i++) { + // HashMap map = (HashMap) + // rs_result.get(i); + // + // for (Map.Entry entry: map.entrySet()) { + // System.out.println(entry.getKey()+"---"+entry.getValue()); + // } + // } + String newid = dbc.getNewCode("PLMITEMID", "pz", "0000"); + System.out.println(newid); + // dbc.closeDataBase(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/wf/plm/util/ExcelUtil.java b/src/com/connor/wf/plm/util/ExcelUtil.java new file mode 100644 index 0000000..56096fe --- /dev/null +++ b/src/com/connor/wf/plm/util/ExcelUtil.java @@ -0,0 +1,268 @@ +package com.connor.wf.plm.util; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.swing.JOptionPane; + +import org.apache.poi.ddf.EscherBSERecord; +import org.apache.poi.ddf.EscherBitmapBlip; +import org.apache.poi.hssf.model.InternalWorkbook; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +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.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.hssf.util.HSSFCellUtil; + +/** + * Excelд + * */ +public class ExcelUtil { +/** + * ܣHSSFSheet + * @param wb HSSFWorkbook + * @param sheetName String + * @return HSSFSheet +*/ + public static HSSFSheet createSheet(HSSFWorkbook wb,String sheetName){ + HSSFSheet sheet=wb.createSheet(sheetName); + sheet.setDefaultColumnWidth(12); + sheet.setGridsPrinted(false); + sheet.setDisplayGridlines(false); + return sheet; + } + +/** + * ܣHSSFRow + * @param sheet HSSFSheet + * @param rowNum int + * @param height int + * @return HSSFRow +*/ + public static HSSFRow createRow(HSSFSheet sheet,int rowNum,int height){ + HSSFRow row=sheet.createRow(rowNum); + row.setHeight((short)height); + return row; + } + + public static HSSFCell createCell0(HSSFRow row,int cellNum){ + HSSFCell cell=row.createCell(cellNum); + return cell; + } + +/** + * ܣCELL + * @param row HSSFRow + * @param cellNum int + * @param style HSSFStyle + * @return HSSFCell +*/ + public static HSSFCell createCell(HSSFRow row,int cellNum,CellStyle style){ + HSSFCell cell=row.createCell(cellNum); + cell.setCellStyle(style); + return cell; + } + +/** + * ܣCellStyleʽ + * @param wb HSSFWorkbook + * @param backgroundColor ɫ + * @param foregroundColor ǰɫ + * @param font + * @return CellStyle +*/ + public static CellStyle createCellStyle(HSSFWorkbook wb,short backgroundColor,short foregroundColor,short halign,Font font){ + CellStyle cs=wb.createCellStyle(); + cs.setAlignment(CellStyle.ALIGN_CENTER);//halign + cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + cs.setFillBackgroundColor(backgroundColor); + cs.setFillForegroundColor(foregroundColor); + cs.setFillPattern(CellStyle.SOLID_FOREGROUND); + cs.setFont(font); + return cs; + } + +/** + * ܣ߿CellStyleʽ + * @param wb HSSFWorkbook + * @param backgroundColor ɫ + * @param foregroundColor ǰɫ + * @param font + * @return CellStyle +*/ + public static CellStyle createBorderCellStyle(HSSFWorkbook wb,short backgroundColor,short foregroundColor,short halign,Font font){ + CellStyle cs=wb.createCellStyle(); + cs.setAlignment(halign); + cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + cs.setFillBackgroundColor(backgroundColor); + cs.setFillForegroundColor(foregroundColor); + cs.setFillPattern(CellStyle.SOLID_FOREGROUND); + cs.setFont(font); + cs.setBorderLeft(CellStyle.BORDER_DASHED); + cs.setBorderRight(CellStyle.BORDER_DASHED); + cs.setBorderTop(CellStyle.BORDER_DASHED); + cs.setBorderBottom(CellStyle.BORDER_DASHED); + return cs; + } + +/** + * ܣже뵽Excelñʽ +*/ + public static void writeArrayToExcel(HSSFSheet sheet,int rows,int cells,Object [][]value){ + Row row[]=new HSSFRow[rows]; + Cell cell[]=new HSSFCell[cells]; + for(int i=0;i codeBeanList; + + public GetCodeBean(TCSession session){ + ParseXML xml=new ParseXML(); + File file=xml.getSXX("WF2_Code_Xml", session); + bean = xml.parseXMLCode(file); + } + + /** + * ñ + * @param names :Ʒ& + * @return + */ + public CodeBean getCodebean(String names){ + codeBeanList = bean.getCodeBeanList(); + CodeBean selCodeBean=null; + for (int i = 0; i < codeBeanList.size(); i++) { + CodeBean codeBean = codeBeanList.get(i); + String codename=codeBean.getName(); + if (codename.equals(names)) { + selCodeBean=codeBean; + break; + } + } + return selCodeBean; + } + + /** + * ò˵㼶ṹ + * @param name :Ʒ + * @return + */ + public MenuBean getMenuBean(String name){ + + Map menuMap = bean.getMenuMap(); + MenuBean menuBean=null; + if (menuMap.containsKey(name)) { + menuBean = menuMap.get(name); + }else{ + MessageBox.post("δҵ͵ĶϢϵԱ","",MessageBox.ERROR); + } + + return menuBean; + } +} diff --git a/src/com/connor/wf/plm/util/MenuBean.java b/src/com/connor/wf/plm/util/MenuBean.java new file mode 100644 index 0000000..85a1a07 --- /dev/null +++ b/src/com/connor/wf/plm/util/MenuBean.java @@ -0,0 +1,31 @@ +package com.connor.wf.plm.util; + +import java.util.List; + +/** + * ˵ʵ + * @author zl + * + */ +public class MenuBean { + private String name; //ǰ˵ + private List list; //Ӳ˵ + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public List getList() { + return list; + } + public void setList(List list) { + this.list = list; + } + @Override + public String toString() { + return "{ MenuBean --" + name + " " + list + "}"; + } + + +} diff --git a/src/com/connor/wf/plm/util/MenuCodeBean.java b/src/com/connor/wf/plm/util/MenuCodeBean.java new file mode 100644 index 0000000..5624922 --- /dev/null +++ b/src/com/connor/wf/plm/util/MenuCodeBean.java @@ -0,0 +1,27 @@ +package com.connor.wf.plm.util; + +import java.util.List; +import java.util.Map; + +/** + * ˵ù + * @author zl + * + */ +public class MenuCodeBean { + private Map menuMap; //˵ + private List codeBeanList;// + public Map getMenuMap() { + return menuMap; + } + public void setMenuMap(Map menuMap) { + this.menuMap = menuMap; + } + public List getCodeBeanList() { + return codeBeanList; + } + public void setCodeBeanList(List codeBeanList) { + this.codeBeanList = codeBeanList; + } + +} diff --git a/src/com/connor/wf/plm/util/ParseXML.java b/src/com/connor/wf/plm/util/ParseXML.java new file mode 100644 index 0000000..16cd11a --- /dev/null +++ b/src/com/connor/wf/plm/util/ParseXML.java @@ -0,0 +1,278 @@ +package com.connor.wf.plm.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.dom4j.Document; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * xml + * @author zl + * + */ +public class ParseXML { + + /** + * XML + * + * @param file + * @return + */ + public List parseXML(File file) { + List partList = new ArrayList(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("part");// partǩ + while (iter.hasNext()) { + PartBean partbean = new PartBean(); + List propList = new ArrayList(); + Element recordEle = (Element) iter.next(); + String itemtype = recordEle.attributeValue("type"); + System.out.println("itemtype=" + itemtype); + Iterator iter2 = recordEle.elementIterator("compontent");// compontentǩ + while (iter2.hasNext()) { + Element recordEle2 = (Element) iter2.next(); + String type = recordEle2.attributeValue("type"); + String compententType = recordEle2 + .attributeValue("compententType"); + Iterator iter3 = recordEle2.elementIterator("property");// propertyǩ + while (iter3.hasNext()) { + PropBean propbean = new PropBean(); + Element recordEle3 = (Element) iter3.next(); + String realName = recordEle3.attributeValue("realName"); + String displayName = recordEle3 + .attributeValue("displayName"); + String propertyType = recordEle3 + .attributeValue("propertyType"); + String defaultValue = recordEle3 + .attributeValue("defaultValue"); + String isMust = recordEle3.attributeValue("isMust"); + String isLov = recordEle3.attributeValue("isLov"); + String lovName = recordEle3.attributeValue("lovName"); + String isMutiLov = recordEle3 + .attributeValue("isMutiLov"); + propbean.setType(type); + propbean.setCompententType(compententType); + propbean.setRealName(realName); + propbean.setDisplayName(displayName); + propbean.setPropertyType(propertyType); + propbean.setDefaultValue(defaultValue); + propbean.setIsMust(isMust); + propbean.setIsLov(isLov); + propbean.setLovName(lovName); + propbean.setIsMutiLov(isMutiLov); + propList.add(propbean); + // System.out.println(propbean); + } + } + + partbean.setPropList(propList); + partbean.setType(itemtype); + partList.add(partbean); + } + } catch (Exception e) { + e.printStackTrace(); + } + return partList; + } + + /** + * XML + * @param file + */ + public MenuCodeBean parseXMLCode(File file) { + MenuCodeBean bean =new MenuCodeBean(); + List codeList = new ArrayList(); + Map menuMap =new HashMap(); + try { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(file); + Element root = document.getRootElement(); + Iterator iter = root.elementIterator("largeclass");// partǩ + while (iter.hasNext()) { + MenuBean menuBean=new MenuBean(); + Element recordEle = (Element) iter.next(); + String type = recordEle.attributeValue("type"); + String name = recordEle.attributeValue("name"); + String code = recordEle.attributeValue("code"); + List namelist = new ArrayList<>(); + namelist.add(name); + List codelist = new ArrayList<>(); + codelist.add(code); + System.out.println("itemtype=" + type); + Iterator iter2 = recordEle.elementIterator("subclass");// subclassǩ + menuBean.setName(name); + menuBean.setList(new ArrayList()); + getCode(iter2, codeList, type, namelist, codelist,menuBean); + menuMap.put(name, menuBean); + System.out.println("-------"+menuBean); + } + + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println(codeList); + bean.setCodeBeanList(codeList); + bean.setMenuMap(menuMap); + return bean; + } + + /** + * ݹxml + * + * @param iter2 + * @param codeList + * @param futype + * @param namelist1 + * @param codelist1 + */ + private void getCode(Iterator iter2, List codeList, + String futype, List namelist1, List codelist1,MenuBean menuBean) { + while (iter2.hasNext()) { + MenuBean zimenuBean=new MenuBean(); + Element recordEle2 = (Element) iter2.next(); + String type = recordEle2.attributeValue("type"); + String name = recordEle2.attributeValue("name"); + String code = recordEle2.attributeValue("code"); + List namelist = new ArrayList<>(); + List codelist = new ArrayList<>(); + for (int i = 0; i < namelist1.size(); i++) { + namelist.add(namelist1.get(i)); + } + for (int i = 0; i < codelist1.size(); i++) { + codelist.add(codelist1.get(i)); + } + namelist.add(name); + codelist.add(code); + zimenuBean.setName(name); + zimenuBean.setList(new ArrayList()); + List list=menuBean.getList(); + list.add(zimenuBean); + //System.out.println(list); + menuBean.setList(list); + if (type != null && type.toUpperCase().equals("S")) { + CodeBean codebean = new CodeBean(); + String min = recordEle2.attributeValue("min"); + String max = recordEle2.attributeValue("max"); + String num = recordEle2.attributeValue("num"); + String end = recordEle2.attributeValue("end"); + String classid = recordEle2.attributeValue("class"); + String allname = ""; + for (int i = 0; i < namelist.size(); i++) { + if (i != 0) { + allname = allname + "&"; + } + allname = allname + namelist.get(i); + } + String allcode = ""; + for (int i = 0; i < codelist.size(); i++) { + allcode = allcode + codelist.get(i); + } + + Iterator iterprops = recordEle2.elementIterator("props"); + if (iterprops.hasNext()) { + CopyPropsBean copyPropBean=new CopyPropsBean(); + Element recordEle3 = (Element) iterprops.next(); + String seltype = recordEle3.attributeValue("type"); + Iterator iterprop = recordEle3.elementIterator("prop"); + List listprop=new ArrayList(); + while (iterprop.hasNext()) { + Element recordEle4 = (Element) iterprop.next(); + String type1 = recordEle4.attributeValue("type1"); + String type2 = recordEle4.attributeValue("type2"); + String name1 = recordEle4.attributeValue("name1"); + String name2 = recordEle4.attributeValue("name2"); + String str=type1+"."+name1+"="+type2+"."+name2; + listprop.add(str); + } + copyPropBean.setType(seltype); + copyPropBean.setProps(listprop); + codebean.setCopyPropBean(copyPropBean); + } + codebean.setType(futype); + codebean.setName(allname); + codebean.setNames(namelist); + codebean.setCodes(codelist); + codebean.setCode(allcode); + codebean.setMin(min); + codebean.setMax(max); + codebean.setNum(num); + codebean.setEnd(end); + codebean.setClassID(classid); + // System.out.println(codebean); + codeList.add(codebean); + } else { + Iterator iter3 = recordEle2.elementIterator("subclass"); + if (iter3.hasNext()) { + getCode(iter3, codeList, futype, namelist, codelist,zimenuBean); + } + } + + } + } + + /** + * ͨѡUidļ + * @param pernaem ѡ + * @param session session + * @return + */ + public File getSXX(String pernaem,TCSession session) { + TCPreferenceService pref = session.getPreferenceService(); + String puid = pref.getStringValue(pernaem);// ѡpuid + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session + .stringToComponent(puid); + if (dataset == null) { + return null; + } + TCComponentTcFile[] file = dataset.getTcFiles(); + if (file.length == 0 || file.length != 1) { + MessageBox.post("ݼûõļļ࣬飡", "WARNING", + MessageBox.WARNING); + return null; + } else { + File fmsFile = file[0].getFmsFile(); + return fmsFile; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + MessageBox.post("δҵѡ["+pernaem+"]ѡô", "", + MessageBox.ERROR); + return null; + } + return null; + } + +// /** +// * +// * @param args +// */ +// public static void main(String[] args) { +// // TODO Auto-generated method stub +// File file = new File("D:\\1.xml"); +// File file2 = new File("D:\\2.xml"); +// ParseXML t = new ParseXML(); +// // t.parseXML(file); +// t.parseXMLCode(file2); +// } +} diff --git a/src/com/connor/wf/plm/util/PartBean.java b/src/com/connor/wf/plm/util/PartBean.java new file mode 100644 index 0000000..33d296e --- /dev/null +++ b/src/com/connor/wf/plm/util/PartBean.java @@ -0,0 +1,25 @@ +package com.connor.wf.plm.util; + +import java.util.List; +/** + * ¼xmlõĶ + * @author zl + * + */ +public class PartBean { + private String type;//part + private List propList;//Զ + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public List getPropList() { + return propList; + } + public void setPropList(List propList) { + this.propList = propList; + } + +} diff --git a/src/com/connor/wf/plm/util/ProgressBar.java b/src/com/connor/wf/plm/util/ProgressBar.java new file mode 100644 index 0000000..c497349 --- /dev/null +++ b/src/com/connor/wf/plm/util/ProgressBar.java @@ -0,0 +1,171 @@ +/** + * @file ProgressBar.java + * + * @brief Create progress bar + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 25-July-2008 Yanghui this class is used to create + * progress bar. + */ +package com.connor.wf.plm.util; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.Timer; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +/** + * @class ProgressBar + * @brief Create progress bar + * @author Yanghui + */ +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * @var ProgressBar.progressbar + * @brief JProgressBar + */ + private JProgressBar progressbar; + + /** + * @var ProgressBar.label + * @brief label used to tips + */ + private JLabel label; + + /** + * @var ProgressBar.timer + * @brief timer used to timing operation + */ + private Timer timer; + + /** + * @var ProgressBar.bool + * @brief bool used to flag thread return + */ + private boolean bool = false; + + /** + * @var Progressbar.registry + * @brief Registry + */ + private Registry registry; + + /** + * @fn public ProgressBar() + * @brief constructor + * @param[in] null + */ + private String showLable = null ; + public ProgressBar(String showlable) { + super(true); + showLable = showlable; + this.setAlwaysOnTop(true); + } + + /** + * @fn public void setBool(boolean bool) + * @brief set bool value + * @param[in] bool + * @param[out] null + */ + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * @fn private void initUI() + * @brief createDialog method + * @param[in] null + * @param[out] null + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + this.label = new JLabel(showLable, JLabel.CENTER); + this.progressbar = new JProgressBar(); + this.progressbar.setOrientation(JProgressBar.HORIZONTAL); + this.progressbar.setMinimum(0); + this.progressbar.setMaximum(100); + this.progressbar.setValue(0); + this.progressbar.setPreferredSize(new Dimension(200, 15)); + this.progressbar.setBorderPainted(true); + this.timer = new Timer(50, (ActionListener) this); + this.timer.setRepeats(false); + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + TaskThread thread = new TaskThread(this); + thread.start(); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + bool = true; + } + }); + this.setVisible(true); + } + + /** + * @class TaskThread + * @brief Create progressbar + * + */ + class TaskThread extends Thread { + private ProgressBar bar; + + public TaskThread(ProgressBar bar) { + this.bar = bar; + } + + public void run() { + if (bool == false) { + // Set Status is running. + // session.setStatus(registry.getString("export Running")); + } + for (int i = 0; i < i + 1; i++) { + timer.start(); + int value = progressbar.getValue(); + if (value < 100) { + value = value + 5; + progressbar.setValue(value); + } else { + timer.stop(); + progressbar.setValue(0); + } + try { + sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (bool == true) { + bar.setVisible(false); + bar.dispose(); + return; + + } + + } + } + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/src/com/connor/wf/plm/util/ProgressBarThread.java b/src/com/connor/wf/plm/util/ProgressBarThread.java new file mode 100644 index 0000000..78ba4af --- /dev/null +++ b/src/com/connor/wf/plm/util/ProgressBarThread.java @@ -0,0 +1,41 @@ +/** + * @file ProgressBarThread.java + * + * @brief control progressBar. + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 08-Auguest-2008 Yanghui this class is used to control + * progress bar. + */ +package com.connor.wf.plm.util; + +/** + * @class ProgressBarThread + * @brief Create progress bar thread + * @author Yanghui + */ +public class ProgressBarThread extends Thread { + + private ProgressBar bar; + + private String title; + + public ProgressBarThread(String title,String showLable) { + this.title = title; + bar = new ProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + bar.initUI(); + } + + public void setBool(boolean bool) { + bar.setBool(true); + bar.setAlwaysOnTop(true); + } +} diff --git a/src/com/connor/wf/plm/util/PropBean.java b/src/com/connor/wf/plm/util/PropBean.java new file mode 100644 index 0000000..6bc730f --- /dev/null +++ b/src/com/connor/wf/plm/util/PropBean.java @@ -0,0 +1,88 @@ +package com.connor.wf.plm.util; +/** + * + * @author zl + * + */ +public class PropBean { + private String type;//[I]Item[IM]ItemMaster[R]ItemRevision[RM]ItemRevisionMaster + private String compententType;//ʵ + private String realName;//Եʵ + private String displayName;//Եʾ + private String propertyType;//Ե [string]ַ[integer]Ρ[date]ڡ[boolean] + private String defaultValue;//ԵĬֵ + private String isMust;//Ƿ [true][false]DZ + private String isLov;//Ƿlov [true]lov[false]ûйlov + private String lovName;//LOV LOVдLOV + private String isMutiLov;//LOV [true]lov[false]ûйlov + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getCompententType() { + return compententType; + } + public void setCompententType(String compententType) { + this.compententType = compententType; + } + public String getRealName() { + return realName; + } + public void setRealName(String realName) { + this.realName = realName; + } + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + public String getPropertyType() { + return propertyType; + } + public void setPropertyType(String propertyType) { + this.propertyType = propertyType; + } + public String getDefaultValue() { + return defaultValue; + } + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + public String getIsMust() { + return isMust; + } + public void setIsMust(String isMust) { + this.isMust = isMust; + } + public String getIsLov() { + return isLov; + } + public void setIsLov(String isLov) { + this.isLov = isLov; + } + public String getLovName() { + return lovName; + } + public void setLovName(String lovName) { + this.lovName = lovName; + } + public String getIsMutiLov() { + return isMutiLov; + } + public void setIsMutiLov(String isMutiLov) { + this.isMutiLov = isMutiLov; + } + @Override + public String toString() { + return "PropBean [type=" + type + ", compententType=" + compententType + + ", realName=" + realName + ", displayName=" + displayName + + ", propertyType=" + propertyType + ", defaultValue=" + + defaultValue + ", isMust=" + isMust + ", isLov=" + isLov + + ", lovName=" + lovName + ", isMutiLov=" + isMutiLov + "]"; + } + + +} diff --git a/src/com/connor/wf/plm/util/RealBean.java b/src/com/connor/wf/plm/util/RealBean.java new file mode 100644 index 0000000..a0b120c --- /dev/null +++ b/src/com/connor/wf/plm/util/RealBean.java @@ -0,0 +1,40 @@ +package com.connor.wf.plm.util; + +public class RealBean { + private String hzm; + private String daType; + private String toolType; + private String realname; + public String getHzm() { + return hzm; + } + public void setHzm(String hzm) { + this.hzm = hzm; + } + public String getDaType() { + return daType; + } + public void setDaType(String daType) { + this.daType = daType; + } + public String getToolType() { + return toolType; + } + public void setToolType(String toolType) { + this.toolType = toolType; + } + + public String getRealname() { + return realname; + } + public void setRealname(String realname) { + this.realname = realname; + } + @Override + public String toString() { + return "RealBean [hzm=" + hzm + ", daType=" + daType + ", toolType=" + + toolType + ", realname=" + realname + "]"; + } + + +} diff --git a/src/com/connor/wf/plm/util/SoaServerUtil.java b/src/com/connor/wf/plm/util/SoaServerUtil.java new file mode 100644 index 0000000..3fa1955 --- /dev/null +++ b/src/com/connor/wf/plm/util/SoaServerUtil.java @@ -0,0 +1,234 @@ +package com.connor.wf.plm.util; + +import java.util.List; + +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 org.apache.axis2.transport.http.HTTPConstants; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +import net.sf.json.JSONArray; + +/** + * ͷUtil + * @author 61666 + * + */ +public class SoaServerUtil { + + public static void sendToClass(String wsoPUID, String classID, String json, String url) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "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) { + e.printStackTrace(); + } + + } + + // public static void main(String[] args) { + // deleteClass("1111", ""); + // } + // ɾʱ + public static void deleteClass(String icoPUID, String url) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";//TODO + // ѡAutocode_SendClassServer_URL + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL");//TODO + // ѡAutocode_SendClassServer_URL + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + opts.setProperty(HTTPConstants.CHUNKED, "false"); + 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); + // 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) { + e.printStackTrace(); + } + + } + + 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; + } + + public static void grantReadPrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); + TCComponentUser user = type.find(account); + + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); + openByPass(tcSession); + accessControlService.grantPrivilege(tempItem, user, as2); + closeByPass(tcSession); + + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } else { + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + public static void grantWritePrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); + + TCComponentUser user = type.find(account); + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ", "WRITE", "DELETE" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); + openByPass(tcSession); + accessControlService.grantPrivilege(tempItem, user, as2); + closeByPass(tcSession); + + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } else { + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_close_bypass", obj); + +// session.getUserService().call("Connor_set_bypass", new Object[]{});//bypass +// session.getUserService().call("Connor_close_bypass", new Object[]{});//bypass + } + +} diff --git a/src/com/connor/wf/plm/util/Test.java b/src/com/connor/wf/plm/util/Test.java new file mode 100644 index 0000000..52653e4 --- /dev/null +++ b/src/com/connor/wf/plm/util/Test.java @@ -0,0 +1,10 @@ +package com.connor.wf.plm.util; + +public class Test { + + public static void main(String[] args) { + // TODO Auto-generated method stub + SoaServerUtil.deleteClass("", "http://192.168.244.131:8090/ErpWebService.asmx?WSDL"); + } + +} diff --git a/src/com/connor/wf/plm/wf001/Wf001Handler.java b/src/com/connor/wf/plm/wf001/Wf001Handler.java new file mode 100644 index 0000000..daacb94 --- /dev/null +++ b/src/com/connor/wf/plm/wf001/Wf001Handler.java @@ -0,0 +1,314 @@ +package com.connor.wf.plm.wf001; + +import java.util.ArrayList; +import java.util.List; + + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.SelectionHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.services.ISessionService; +import com.teamcenter.rac.ui.commands.Messages; +import com.teamcenter.rac.ui.commands.RACUICommandsActivator; +import com.teamcenter.rac.ui.commands.create.bo.NewBOModel; +import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard; +import com.teamcenter.rac.util.OSGIUtil; +import com.teamcenter.rac.util.SWTUIUtilities; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog; +import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper; + +/** + * TC9ϰ汾½󣨰ļСµswtĽ com.teamcenter.rac.ui.commands.handlers + * + * + * @author hub + * + */ +public class Wf001Handler extends AbstractHandler implements + IExecutableExtension { + private String opType = ""; + + private class CreateNewBOSWTDialog implements Runnable { + + public void run() { + NewBOWizard newbowizard = (NewBOWizard) getWizard(); + if (newbowizard == null) + newbowizard = new NewBOWizard(wizardId); + newbowizard.setBOModel(m_boModel); + newbowizard.setWindowTitle(getWizardTitle()); + newbowizard.setRevisionFlag(m_boModel.getRevisionFlag()); + newbowizard.setDefaultType(m_type); + Shell shell = UIUtilities.getCurrentModalShell(); + dialog = new BaseExternalWizardDialog(m_shell, newbowizard); + dialog.create(); + newbowizard.retrievePersistedDialogSettings(dialog); + newbowizard.setWizardDialog(dialog); + UIUtilities.setCurrentModalShell(dialog.getShell()); + dialog.open(); + dialog = null; + + InterfaceAIFComponent[] compS = m_boModel.getTargetArray(); + + if (compS != null && compS.length != 0) { + System.out.println(" length =" + compS.length); + if (compS[0] instanceof TCComponentItem) { + + System.out.println("ITEM"); + } else if (compS[0] instanceof TCComponentFolder) { + + System.out.println("FOLDER"); + } + TCComponent compT = (TCComponent) compS[0]; + try { + System.out.println("object_name =>" + + compT.getStringProperty("object_name")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + System.out.println(" null "); + } + + System.out.println("=====>"); + List contextList = m_boModel.getCompContext(); + if (contextList != null) { + for (AIFComponentContext context : contextList) { + InterfaceAIFComponent comp = context.getComponent(); + try { + System.out.println(">" + + ((TCComponent) comp) + .getStringProperty("object_name")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + } + System.out.println("=====>"); + m_boModel = null; + + UIUtilities.setCurrentModalShell(shell); + + System.out.println("dialog ==> " + opType + " | " + m_type); + } + + private final Shell m_shell; + private final String m_type; + final Wf001Handler this$0; + + private CreateNewBOSWTDialog(Shell shell, String s) { + super(); + this$0 = Wf001Handler.this; + + m_shell = shell; + m_type = s; + } + + CreateNewBOSWTDialog(Shell shell, String s, + CreateNewBOSWTDialog createnewboswtdialog) { + this(shell, s); + } + + } + + public Object execute(ExecutionEvent executionevent) + throws ExecutionException { + + opType = executionevent.getCommand().getId(); + if("WF2_phsRvwForm1".equals(opType)){ + opType = "WF2_phsRvwForm"; + } + if("WF2_procFlow1".equals(opType)){ + opType = "WF2_procFlow"; + } + if("WF2_machDimCP1".equals(opType)){ + opType = "WF2_machDimCP"; + } + + if (executionevent == null) + throw new IllegalArgumentException("Event can't be null"); + + boolean flag = false; + if (executionevent.getParameters() != null + && executionevent.getParameters().containsKey("selection")) { + Object obj = executionevent.getParameters().get("selection"); + if (obj instanceof InterfaceAIFComponent[]) { + selectedCmps = (InterfaceAIFComponent[]) obj; + m_currentSelection = new StructuredSelection(selectedCmps); + flag = true; + } + } + if (!flag) { + m_currentSelection = HandlerUtil + .getCurrentSelection(executionevent); + selectedCmps = SelectionHelper + .getTargetComponents(m_currentSelection); + } + m_boModel = getBOModel(); + launchWizard(executionevent); + return null; + } + + public void setInitializationData( + IConfigurationElement iconfigurationelement, String s, Object obj) + throws CoreException { + } + + protected NewBOModel getBOModel() { + if (m_boModel == null) + m_boModel = new NewBOModel(this); + return m_boModel; + } + + public Wizard getWizard() { + if (wizardId == null || wizardId.length() == 0) + wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard"; + return WizardExtensionHelper.getWizard(wizardId); + } + + public String getWizardTitle() { + return Messages.getString("wizard.TITLE"); + } + + public void launchWizard() { + launchWizard(null); + } + + public void launchWizard(ExecutionEvent executionevent) { + String s = this.opType; + initWizardModel(executionevent); + // if (executionevent != null) + // s = (String) executionevent.getParameters().get("objectType"); + AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); + Shell shell = aifdesktop.getShell(); + if (shell != null) + SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, s, null)); + } + + protected void initWizardModel(ExecutionEvent executionevent) { + boolean flag = false; + Object obj = null; + ISessionService isessionservice = (ISessionService) OSGIUtil + .getService(RACUICommandsActivator.getDefault(), + com.teamcenter.rac.services.ISessionService.class); + try { + session = (TCSession) isessionservice + .getSession(com.teamcenter.rac.kernel.TCSession.class + .getName()); + } catch (Exception _ex) { + session = (TCSession) AIFUtility.getDefaultSession(); + } + m_boModel.setSession(session); + m_boModel.reInitializeTransientData(); + m_boModel.setFrame(AIFUtility.getActiveDesktop()); + if (executionevent != null) { + if (executionevent.getParameters().containsKey("revisionFlag")) + flag = ((Boolean) executionevent.getParameters().get( + "revisionFlag")).booleanValue(); + if (executionevent.getParameters().containsKey("pasteRelation")) { + String s = (String) executionevent.getParameters().get( + "pasteRelation"); + if (s != null) { + String as[] = null; + as = s.split(","); + m_boModel.setRelType(as[0]); + m_boModel.setPreAssignedRelType(as); + } + } + if (executionevent.getParameters().containsKey("parentComponents")) { + InterfaceAIFComponent ainterfaceaifcomponent[] = (InterfaceAIFComponent[]) executionevent + .getParameters().get("parentComponents"); + m_boModel.setTargetArray(ainterfaceaifcomponent); + } else { + m_boModel.setTargetArray(selectedCmps); + } + if(executionevent.getParameters().containsKey("relOtherTypeInfo")) + { + String s1 = (String)executionevent.getParameters().get("relOtherTypeInfo"); + if(s1 != null) + { + String as1[] = s1.split(","); + ArrayList arraylist = new ArrayList(); + ArrayList arraylist1 = new ArrayList(); + String as2[]; + int j = (as2 = as1).length; + for(int i = 0; i < j; i++) + { + String s2 = as2[i]; + s2 = s2.trim(); + int k = s2.indexOf("."); + arraylist.add(s2.substring(0, k)); + arraylist1.add(s2.substring(k + 1, s2.length())); + } + + m_boModel.setPreAssignedRelTypesForAllSubTypes(arraylist, arraylist1); + } + } else + { + m_boModel.setAllowUserToSelectRelation(useDefaultRelations()); + } + } else { + m_boModel.setTargetArray(selectedCmps); + } + m_boModel.setRevisionFlag(flag); + AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); + Shell shell = aifdesktop.getShell(); + m_boModel.setShell(shell); + m_boModel.setCurrentSelection(m_currentSelection); + } + + protected boolean useDefaultRelations() + { + return true; + } + + protected void readDisplayParameters(NewBOWizard newbowizard, + WizardDialog wizarddialog) { + newbowizard.retrievePersistedDialogSettings(wizarddialog); + } + + protected InterfaceAIFComponent selectedCmps[]; + protected ISelection m_currentSelection; + protected String wizardId; + protected WizardDialog dialog; + /** + * @deprecated Field session is deprecated + */ + @Deprecated + protected TCSession session; + protected NewBOModel m_boModel; +} + +/* + * DECOMPILATION REPORT + * + * Decompiled from: + * F:\Teamcenter11ENV\JAVA\rac\plugins\com.teamcenter.rac.ui.commands_11000 + * .2.0.jar Total time: 72 ms Jad reported messages/errors: Exit status: 0 + * Caught exceptions: + */ \ No newline at end of file diff --git a/src/com/connor/wf/plm/wf001/Wf001ScheduleHandler.java b/src/com/connor/wf/plm/wf001/Wf001ScheduleHandler.java new file mode 100644 index 0000000..f2a54b4 --- /dev/null +++ b/src/com/connor/wf/plm/wf001/Wf001ScheduleHandler.java @@ -0,0 +1,133 @@ +package com.connor.wf.plm.wf001; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectSmartFolder; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.schedule.commands.newschedule.NewScheduleHandler; +import com.teamcenter.rac.schedule.plugin.Activator; +import com.teamcenter.rac.schedule.project.scheduling.ModelFactory; +import com.teamcenter.rac.schedule.project.scheduling.ScheduleModel; +import com.teamcenter.rac.schedule.project.scheduling.ScheduleShiftContainer; +import com.teamcenter.rac.schedule.project.scheduling.SchedulingException; +import com.teamcenter.rac.schedule.project.sharedUtils.TimeZoneCalUtil; +import com.teamcenter.rac.schedule.soainterface.CopyScheduleRunner; +import com.teamcenter.rac.schedule.wizardpages.SchedulePageModel; +import com.teamcenter.rac.services.ISessionService; +import com.teamcenter.rac.ui.commands.handlers.NewBOHandler; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import java.text.MessageFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.*; + +public class Wf001ScheduleHandler extends NewBOHandler { + + private TCSession session; + + public Wf001ScheduleHandler() { + } + + public static SchedulePageModel getScheduleModel() { + if (scheduleModel == null) + scheduleModel = new SchedulePageModel(); + return scheduleModel; + } + + public Object execute(ExecutionEvent executionevent) + throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp == null) { + MessageBox.post("ѡĿִд!!", "", MessageBox.ERROR); + return null; + } + if (targetComp instanceof TCComponentFolder) { + + scheduleModel = null; + wizardId = "com.teamcenter.rac.schedule.commands.newschedule.GenericScheduleWizard"; + TCSession tcsession = (TCSession) Activator.getDefault() + .getSessionService().getDefaultSession(); + TCPreferenceService tcpreferenceservice = tcsession + .getPreferenceService(); + String s = tcpreferenceservice.getString(4, "SiteTimeZone", "null"); + IWorkbench iworkbench = PlatformUI.getWorkbench(); + IWorkbenchWindow iworkbenchwindow = iworkbench + .getActiveWorkbenchWindow(); + Shell shell = iworkbenchwindow.getShell(); + if ("null".equals(s) || s == null) { + MessageDialog.openInformation(shell, + textRegistry.getString("tzNotSet.TITLE"), + textRegistry.getString("tzNotSet.MSG")); + return Boolean.valueOf(false); + } + if (!TimeZoneCalUtil.testTimeZoneID(s)) { + String s1 = textRegistry.getString("tzInvalid.MSG"); + s1 = MessageFormat.format(s1, new Object[] { s }); + MessageDialog.openInformation(shell, + textRegistry.getString("tzInvalid.TITLE"), s1); + return Boolean.valueOf(false); + } else { + return super.execute(executionevent); + } +// +// } else +// + + +// if (targetComp.getType().equals("TC_Project")) { +// +// CreateScheduleOperation operation = new CreateScheduleOperation(targetComp,session); +// session.queueOperation(operation); +// +// return null; +// } else { +// MessageBox.post("ѡĿִд!!", "", MessageBox.ERROR); +// return null; + } + return null; + } + + + + public String getWizardTitle() { + Registry registry = Registry.getRegistry(NewScheduleHandler.class); + return registry.getString("dialog.TITLE"); + } + + private static SchedulePageModel scheduleModel = null; + private final Registry textRegistry = Registry + .getRegistry("com.teamcenter.rac.schedule.schedule"); + + + + + +} + +/* + * DECOMPILATION REPORT + * + * Decompiled from: + * D:\Teamcenter_4Sh\OTW11\rac\plugins\com.teamcenter.rac.schedule_11000.2.0.jar + * Total time: 1083 ms Jad reported messages/errors: Exit status: 0 Caught + * exceptions: + */ \ No newline at end of file diff --git a/src/com/connor/wf/plm/wf002/Wf002Dialog.java b/src/com/connor/wf/plm/wf002/Wf002Dialog.java new file mode 100644 index 0000000..5d62fe5 --- /dev/null +++ b/src/com/connor/wf/plm/wf002/Wf002Dialog.java @@ -0,0 +1,114 @@ +package com.connor.wf.plm.wf002; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.eclipse.ui.PlatformUI; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; +/** + * :Wf002Dialog + * :... + * :2019-02-025 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf002Dialog extends AbstractAIFDialog{ + private AbstractAIFUIApplication app; + private TCSession session; + private String name; + private String id; + public Wf002Dialog( AbstractAIFUIApplication app) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.name = null; + this.id = "P00001"; + } + + public void run() { + initUI(); + } + /** + * + * ʼڡ + */ + private void initUI(){ + this.setLayout(new BorderLayout()); + this.setTitle("Ŀ"); + this.setPreferredSize(new Dimension(500, 340)); + this.setResizable(false);// ɱ䶯ڴС + JPanel mainPanel = new JPanel(new PropertyLayout()); + JPanel topPanel = new JPanel(new PropertyLayout()); + JLabel numberLabel = new JLabel(" Ŀ:"); + JTextField numberField = new JTextField(12); + numberField.setText(id); + JLabel nameLabel = new JLabel(" Ŀ:"); + JTextField nameField = new JTextField(12); + name = nameField.getText(); + JLabel label = new JLabel(" "); + JLabel topLabel = new JLabel(); + topPanel.add("1.1.left.top", topLabel); + topPanel.add("2.1.left.top", topLabel); + topPanel.add("3.1.left.top", topLabel); + topPanel.add("4.1.left.top", topLabel); + topPanel.add("5.1.left.top", topLabel); + topPanel.add("6.1.left.top", numberLabel); + topPanel.add("6.2.left.top", numberField); + topPanel.add("6.3.left.top", label); + topPanel.add("7.1.left.top", topLabel); + topPanel.add("8.1.left.top", topLabel); + topPanel.add("9.1.left.top", topLabel); + topPanel.add("10.1.left.top", topLabel); + topPanel.add("11.1.left.top", topLabel); + topPanel.add("12.1.left.top", nameLabel); + topPanel.add("12.2.left.top", nameField); + topPanel.add("12.3.left.top", label); + topPanel.add("13.1.left.top", topLabel); + topPanel.add("14.1.left.top", topLabel); + topPanel.add("15.1.left.top", topLabel); + topPanel.add("16.1.left.top", topLabel); + JButton okBtn = new JButton("ȷ"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + Wf002Operation operation = new Wf002Operation(app,name,id); + session.queueOperation(operation); + } + }); + JButton celBtn = new JButton("ȡ"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + JPanel centerPanel = new JPanel(new FlowLayout()); + centerPanel.add(okBtn); + centerPanel.add(celBtn); + JPanel southPanel = new JPanel(new PropertyLayout()); + southPanel.add("1.1.left.top", topLabel); + southPanel.add("2.1.left.top", topLabel); + southPanel.add("3.1.left.top", topLabel); + mainPanel.add("1.1.center.top",topPanel); + mainPanel.add("2.1.center.top",centerPanel); + mainPanel.add("3.1.center.top",southPanel); + this.add(mainPanel, BorderLayout.CENTER); + this.centerToScreen(); + this.showDialog(); + } + +} diff --git a/src/com/connor/wf/plm/wf002/Wf002Handler.java b/src/com/connor/wf/plm/wf002/Wf002Handler.java new file mode 100644 index 0000000..bd7be5f --- /dev/null +++ b/src/com/connor/wf/plm/wf002/Wf002Handler.java @@ -0,0 +1,33 @@ +package com.connor.wf.plm.wf002; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +/** + * :Wf002Handler + * :... + * :2019-02-025 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf002Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + /** + * + * һ߳ʾ贰ڡ + * @param pz + * @return + */ + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + Wf002Dialog dialog = new Wf002Dialog(app); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf002/Wf002Operation.java b/src/com/connor/wf/plm/wf002/Wf002Operation.java new file mode 100644 index 0000000..fe64aa6 --- /dev/null +++ b/src/com/connor/wf/plm/wf002/Wf002Operation.java @@ -0,0 +1,72 @@ +package com.connor.wf.plm.wf002; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf002Operation + * :ĿźƴĿ + * :2019-02-25 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf002Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private String name; + private String id; + public Wf002Operation(AbstractAIFUIApplication app, String name,String id) { + this.app = app; + this.name = name; + this.id = id; + this.session = (TCSession) app.getSession(); + } + + public void executeOperation() throws Exception { + String [] nameKeys = new String[]{"Ŀ"}; + String [] nameValues = new String[]{name}; + String [] idKeys = new String[]{"Ŀ ID"}; + String [] idValues = new String[]{id}; + Boolean flag1 = null; + Boolean flag2 = null; + flag1 = queryObject("Ŀ...",nameKeys,nameValues); + flag2 = queryObject("Ŀ...",idKeys,idValues); + } + /** + * + * ݲѯϵͳǷиĿ + * @param + * queryName : ϵͳжӦIJѯ + * keys : ϵͳжӦIJѯ + * values ѯӦֵ + * ֵ + * һжϣжǷִг + */ + public Boolean queryObject(String queryName ,String[] keys,String[] values) throws TCException{ + Boolean flag = true; + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName);//Ŀ.. + if(query == null){ + MessageBox.post("ûҵѯ:"+queryName,"",MessageBox.ERROR); + } + TCComponent[] compoents = query.execute(keys, values); + if(compoents != null){ + MessageBox.post("ĿѴ","ʾ",MessageBox.INFORMATION); + flag = false; + } + return flag; + } + +} diff --git a/src/com/connor/wf/plm/wf007/Wf007Dialog.java b/src/com/connor/wf/plm/wf007/Wf007Dialog.java new file mode 100644 index 0000000..3282f8a --- /dev/null +++ b/src/com/connor/wf/plm/wf007/Wf007Dialog.java @@ -0,0 +1,177 @@ +package com.connor.wf.plm.wf007; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.connor.wf.plm.wf002.Wf002Operation; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCPropertyService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +/** + * :Wf007Dialog + * : ƷͼĴ + * :2019-02-25 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf007Dialog extends AbstractAIFDialog{ + private AbstractAIFUIApplication app; + private TCComponentFolder targetComponent; + private String customerName; + private String classID; + private TCSession session; + private TCPreferenceService service; + private JComboBox comboBox; + private JComboBox mBcomboBox; + private Map map=new HashMap<>(); + private Map mapclass=new HashMap<>(); + private Map map1; + private String uid; + private String pictureMB; + + public Wf007Dialog(AbstractAIFUIApplication app,InterfaceAIFComponent targetComponent) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.targetComponent = (TCComponentFolder) targetComponent; + } + public void run(){ + System.out.println("Wf007Dialog.run()"); + initUI(); + } + public void initUI(){ + this.setLayout(new PropertyLayout()); + this.setTitle("Ʒͼ"); + this.setPreferredSize(new Dimension(280, 200)); + this.setResizable(false);// ɱ䶯ڴС + + JPanel centerPanel = new JPanel(new PropertyLayout()); + centerPanel.setPreferredSize(new Dimension(280, 80)); + JLabel nameLable = new JLabel(" ͻ:"); + nameLable.setFont(new Font("", Font.PLAIN, 15)); + comboBox = new JComboBox(); + String[] values = new String[]{}; + List khlist=new ArrayList<>(); + try { + String lovname=service.getStringValue("WF2_customerName_lov");//"WF2_customer_lov" + System.out.println("lovname="+lovname); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovname); + System.out.println("lov="+lov.length); + if(lov.length > 0){ + ListOfValuesInfo value = lov[0].getListOfValues(); + values = value.getStringListOfValues(); + for (int i = 0; i < values.length; i++) { + String disval = value.getDisplayableValue(values[i]); + khlist.add(disval); + map.put(disval, values[i]); + } + + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + String[] names = service.getStringValues("WF2_CustomerName_ID"); + mapclass = new HashMap(); + for (int i = 0; i < names.length; i++) { + String[] vals = names[i].split("="); + mapclass.put(vals[0], vals[1]); + } + for (int i = 0; i < khlist.size(); i++) { + comboBox.addItem(khlist.get(i)); + } + JLabel nameLable1 = new JLabel(" ͼֽģ:"); + nameLable1.setFont(new Font("", Font.PLAIN, 15)); + mBcomboBox = new JComboBox(); + String[] values1 = service.getStringValues("WF2_Picture_MB"); + if (values1 == null || values1.length <= 0) { + + MessageBox.post("ѡWF2_Picture_MBδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + String[] mbs = new String[values1.length]; + map1 = new HashMap(); + for (int i = 0; i < values1.length; i++) { + String[] vals = values1[i].split("="); + mbs[i] = vals[0]; + map1.put(vals[0],vals[1]); + } + for (int i = 0; i < mbs.length; i++) { + mBcomboBox.addItem(mbs[i]); + } + + centerPanel.add("1.1.center.top",nameLable); + centerPanel.add("1.2.center.top",comboBox); + centerPanel.add("2.1.center.top",nameLable1); + centerPanel.add("2.2.center.top",mBcomboBox); + JPanel southPanel = new JPanel(new FlowLayout()); + southPanel.setPreferredSize(new Dimension(250, 80)); + JButton okBtn = new JButton("ȷ"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + customerName = (String) comboBox.getSelectedItem(); + String khname=""; + if (map.containsKey(customerName)) { + khname=map.get(customerName); + } + if (mapclass.containsKey(customerName)) { + classID=mapclass.get(customerName); + }else { + MessageBox.post("ѡWF2_CustomerName_IDδõǰͻķID,ϵԱ!!","", MessageBox.ERROR); + return; + } + classID = mapclass.get(customerName); + pictureMB = (String) mBcomboBox.getSelectedItem(); + uid = map1.get(pictureMB); + System.out.println("1==========================="+uid); +; Wf007Operation operation = new Wf007Operation(app,targetComponent,khname,classID,uid); + session.queueOperation(operation); + disposeDialog(); + } + }); + JButton celBtn = new JButton("ȡ"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + this.add("1.1.center.top",new JLabel(" ")); + this.add("2.1.center.top",centerPanel); + this.add("3.1.center.top",southPanel); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); + } +} diff --git a/src/com/connor/wf/plm/wf007/Wf007Handler.java b/src/com/connor/wf/plm/wf007/Wf007Handler.java new file mode 100644 index 0000000..b245d61 --- /dev/null +++ b/src/com/connor/wf/plm/wf007/Wf007Handler.java @@ -0,0 +1,74 @@ +package com.connor.wf.plm.wf007; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf007Handler + * : ƷͼHandler + * :2019-02-25 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf007Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private TCSession session; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent != null){ + if(targetComponent instanceof TCComponentFolder){ + TCComponent[] projects = null ; + try { + TCComponent[] tcs = ((TCComponentFolder) targetComponent) + .getTCProperty("fnd0StartedWorkflowTasks") + .getReferenceValueArray(); + if(tcs == null || tcs.length <= 0){ + MessageBox.post("ѡļû£","ʾ",MessageBox.INFORMATION); + return null; + } + TCComponent[] tasks = tcs[0].getTCProperty( + "fnd0RootScheduleTask").getReferenceValueArray(); + if (tasks != null && tasks.length > 0) { + TCComponent schedule = tasks[0].getTCProperty( + "schedule_tag").getReferenceValue(); + projects = schedule.getTCProperty("project_list") + .getReferenceValueArray(); + }else{ + MessageBox.post("ѡļûʱ£","ʾ",MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(projects == null || projects.length <= 0){ + MessageBox.post("ѡļвĿµĽļУ","ʾ",MessageBox.INFORMATION); + return null; + } + Wf007Dialog dialog = new Wf007Dialog(app,targetComponent); + new Thread(dialog).start(); + }else{ + MessageBox.post("ѡ񽻸ļУ","ʾ",MessageBox.INFORMATION); + } + }else{ + MessageBox.post("ѡ񽻸ļУ","ʾ",MessageBox.INFORMATION); + + } + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf007/Wf007Operation.java b/src/com/connor/wf/plm/wf007/Wf007Operation.java new file mode 100644 index 0000000..34db0d4 --- /dev/null +++ b/src/com/connor/wf/plm/wf007/Wf007Operation.java @@ -0,0 +1,299 @@ +package com.connor.wf.plm.wf007; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +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.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf007Operation + * : ½Ʒͼ + * :2019-02-25 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf007Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentFolder targetComp; + private String customerName; + private String classID; + private TCPreferenceService service; + private String url = ""; + private Integer[] classKeys; + private String[] classVals; + private String uid; + public Wf007Operation(AbstractAIFUIApplication app, + TCComponentFolder targetComp,String customerName,String classID,String uid) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.targetComp = targetComp; + this.customerName = customerName; + this.classID = classID; + this.uid = uid; + } + + @Override + public void executeOperation() throws Exception { + TCComponent[] projects = getProject(targetComp); + if(projects == null){ + MessageBox.post("ûжӦĿ","",MessageBox.ERROR); + return; + } + for (TCComponent project : projects) { + if(!"TC_Project".equals(project.getType())){ + MessageBox.post("Ŀ","",MessageBox.ERROR); + return; + } + } + String projectID = projects[0].getStringProperty("project_id"); + String carType = projects[0].getStringProperty("wf2_vehPlatform"); + String rimWidth = projects[0].getStringProperty("wf2_rimWidth"); + String rimDiameter = projects[0].getStringProperty("wf2_rimDiameter"); + + + String CPTID = "T"+projectID; + String name = "Ʒͼ"; + TCComponentItem CPTItem = null; + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("WF2_2DprodDraw"); + if(typeComponent.find(CPTID) != null){ + MessageBox.post("ʧ,ͲƷͼѾڣ","ʾ",MessageBox.INFORMATION); + return; + } + String revID = typeComponent.getNewRev(null); + try { + CPTItem = createItem(CPTID,revID,name); + if(CPTItem == null){ + MessageBox.post("ʧ","ʾ",MessageBox.INFORMATION); + return; + } + targetComp.add("contents", CPTItem); + TCComponentItemRevision rev = CPTItem.getLatestItemRevision(); +// TCComponentDataset dataset = createDataset(CPTID); +// rev.add("IMAN_specification", dataset); + TCComponentDataset mbDataset = createDataset(uid,rev); + rev.add("WF2_proddraw",mbDataset);//ݼϵ + MessageBox.post("ɹ","ɹ",MessageBox.INFORMATION); + } catch (Exception e) { + MessageBox.post("쳣\n"+e.getLocalizedMessage(),"",MessageBox.ERROR); + e.printStackTrace(); + } + TCComponentItemRevisionType revType = (TCComponentItemRevisionType) session.getTypeComponent("WF2_2DprodDrawRevision"); + TCComponentItemRevision rev = revType.findRevision(CPTID, revID); + TCComponentForm form = (TCComponentForm) rev.getRelatedComponent("IMAN_master_form_rev"); + form.setStringProperty("wf2_customer", customerName); + TCProperty rimWidthProperty = form.getTCProperty("wf2_rimWidth"); + TCProperty rimDiameterProperty = form.getTCProperty("wf2_rimDiameter"); + rimWidth = getValues(rimWidthProperty,rimWidth); + rimDiameter = getValues(rimDiameterProperty,rimDiameter); + System.out.println("rimWidth==========================="+rimWidth); + System.out.println("rimDiameter==========================="+rimDiameter); + form.setStringProperty("wf2_vehicle", carType); + form.setStringProperty("wf2_rimWidth", rimWidth); + form.setStringProperty("wf2_rimDiameter", rimDiameter); + + classKeys = new Integer[]{}; + classVals = new String[]{}; + sendObjToClassficationByWebService(classID, rev, + classKeys, classVals);//ͷ + System.out.println("ͷ"); + + } + /** + * + * ݲƷͼ + * @param + * CPTID ƷͼID + * revID Ʒͼ汾 + * name Ʒͼ + * ֵ + * شIJƷͼ + */ + private TCComponentItem createItem(String CPTID, String revID,String name) { + TCComponentItem CPTItem = null; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("WF2_2DprodDraw"); + CPTItem = typeComponent.create(CPTID, revID,"WF2_2DprodDraw", name, "",null); + } catch (TCException e) { + e.printStackTrace(); + } + return CPTItem; + } + + /** + * + * ݲѯҵϵͳжӦĿ + * @param + * targetComp Ŀļ + * ֵ + * ϵͳеĿ + */ + private TCComponent[] getProject(TCComponentFolder targetComp){ + TCComponent[] projects = null; + TCComponent[] tcs = null; + TCComponent[] tasks = null; + try { + tcs = targetComp.getTCProperty("fnd0StartedWorkflowTasks") + .getReferenceValueArray(); + if(tcs != null){ + + tasks = tcs[0].getTCProperty( + "fnd0RootScheduleTask").getReferenceValueArray(); + }else{ + MessageBox.post("ļû߹̣","ʾ",MessageBox.INFORMATION); + } + if (tasks != null && tasks.length > 0) { + TCComponent schedule = tasks[0].getTCProperty( + "schedule_tag").getReferenceValue(); + projects = schedule.getTCProperty("project_list") + .getReferenceValueArray(); + }else{ + MessageBox.post("ûʱ","ʾ",MessageBox.INFORMATION); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return projects; + } + /** + * + * ݲѲƷͼ͵С + * @param + * class_id ʵID + * rev Ʒͼ汾 + * keys ΨһID + * vals ԶӦֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + service = session.getPreferenceService(); + url = service + .getStringValue("Autocode_SendClassServer_URL"); + System.out.println("url=" + url); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } + /** + * + * ݲģļݼ + * @param + * CPTID Ҫݼid + * ֵ + * شģݼ + */ + private TCComponentDataset createDataset( + String CPTID) { + TCComponentDataset mbDataset = null; + String type = "CATPart"; + String name = CPTID+"/A"; + try { + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + mbDataset = datasetType.create(name, "", type); + } catch (TCException e) { + e.printStackTrace(); + } + return mbDataset; + } + /** + * + * ݲģļݼ + * @param + * uid Ҫϴģݼuid + * newRev : °汾 + * ֵ + * شģݼ + */ + private TCComponentDataset createDataset( + String uid,TCComponentItemRevision rev) { + TCComponentDataset dataset = null; + TCComponentDataset mbDataset = null; + //String[] path = new String[1]; + //String[] ref_type = new String[1]; + System.out.println("==================="+uid); + try { + TCComponentDataset comp = (TCComponentDataset) session.stringToComponent(uid); + String name = rev.getStringProperty("item_id")+"/"+rev.getStringProperty("item_revision_id"); + mbDataset=comp.saveAs(name); +// if(comp instanceof TCComponentDataset){ +// dataset = (TCComponentDataset) comp; +// String type = dataset.getType(); +// System.out.println("type=====" + type); +// String name = rev.getStringProperty("item_id")+"/"+rev.getStringProperty("item_revision_id"); +// File[] files = dataset.getFiles(""); +// TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); +// mbDataset = datasetType.create(name, "", type); +// path[0] = files[0].getAbsolutePath(); +// ref_type[0] = "WF2_zwCad"; +// mbDataset.setFiles(path, ref_type); +// } + + } catch (TCException e) { + e.printStackTrace(); + } + return mbDataset; + } + + /** + * 洢LOVֵ + */ + private String getValues(TCProperty property,String value) { + TCComponentListOfValues lov = property.getLOV(); + String trueValue = ""; + try { + String[] strs = lov.getListOfValues().getStringListOfValues(); + for (String str : strs) { + String al = lov.getListOfValues().getDisplayableValue(str); + if(al.equals(value)) { + trueValue = str; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return trueValue; + } +} diff --git a/src/com/connor/wf/plm/wf007/Wf007_2CHandler.java b/src/com/connor/wf/plm/wf007/Wf007_2CHandler.java new file mode 100644 index 0000000..51bb5d0 --- /dev/null +++ b/src/com/connor/wf/plm/wf007/Wf007_2CHandler.java @@ -0,0 +1,72 @@ +package com.connor.wf.plm.wf007; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf007Handler + * : ƷͼHandler + * : + * Ա zl + * + */ +public class Wf007_2CHandler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private TCSession session; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent != null){ + if(targetComponent instanceof TCComponentFolder){ + TCComponent[] projects = null ; + try { + TCComponent[] tcs = ((TCComponentFolder) targetComponent) + .getTCProperty("fnd0StartedWorkflowTasks") + .getReferenceValueArray(); + if(tcs == null || tcs.length <= 0){ + MessageBox.post("ѡļû£","ʾ",MessageBox.INFORMATION); + return null; + } + TCComponent[] tasks = tcs[0].getTCProperty( + "fnd0RootScheduleTask").getReferenceValueArray(); + if (tasks != null && tasks.length > 0) { + TCComponent schedule = tasks[0].getTCProperty( + "schedule_tag").getReferenceValue(); + projects = schedule.getTCProperty("project_list") + .getReferenceValueArray(); + }else{ + MessageBox.post("ѡļûʱ£","ʾ",MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(projects == null || projects.length <= 0){ + MessageBox.post("ѡļвĿµĽļУ","ʾ",MessageBox.INFORMATION); + return null; + } + Wf007_2COperation operation = new Wf007_2COperation(app,(TCComponentFolder)targetComponent); + session.queueOperation(operation); + }else{ + MessageBox.post("ѡ񽻸ļУ","ʾ",MessageBox.INFORMATION); + } + }else{ + MessageBox.post("ѡ񽻸ļУ","ʾ",MessageBox.INFORMATION); + + } + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf007/Wf007_2COperation.java b/src/com/connor/wf/plm/wf007/Wf007_2COperation.java new file mode 100644 index 0000000..38c725f --- /dev/null +++ b/src/com/connor/wf/plm/wf007/Wf007_2COperation.java @@ -0,0 +1,119 @@ +package com.connor.wf.plm.wf007; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf007_2COperation extends AbstractAIFOperation { + private TCSession session; + private TCComponentFolder targetComp; + + public Wf007_2COperation(AbstractAIFUIApplication app, + TCComponentFolder targetComp) { + this.session = (TCSession) app.getSession(); + this.targetComp = targetComp; + } + + @Override + public void executeOperation() throws Exception { + TCComponent[] projects = getProject(targetComp); + if (projects == null) { + MessageBox.post("ûжӦĿ", "", MessageBox.ERROR); + return; + } + for (TCComponent project : projects) { + if (!"TC_Project".equals(project.getType())) { + MessageBox.post("Ŀ", "", MessageBox.ERROR); + return; + } + } + String projectID = projects[0].getStringProperty("project_id"); + String CPTID = "T" + projectID + "_2C"; + String name = "ύͻͼ"; + TCComponentItem CPTItem = null; + TCComponentItemType typeComponent = (TCComponentItemType) session + .getTypeComponent("WF2_subCstmDraw"); + if (typeComponent.find(CPTID) != null) { + MessageBox + .post("ʧ,IDύͻͼѾڣ", "ʾ", MessageBox.INFORMATION); + return; + } + String revID = typeComponent.getNewRev(null); + try { + CPTItem = createItem(CPTID, revID, name); + if (CPTItem == null) { + MessageBox.post("ʧ", "ʾ", MessageBox.INFORMATION); + return; + } + targetComp.add("contents", CPTItem); + + MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + } catch (Exception e) { + MessageBox.post("쳣\n" + e.getLocalizedMessage(), "", + MessageBox.ERROR); + e.printStackTrace(); + } + + } + + /** + * ݲƷͼ + * + * @param CPTID + * ƷͼID revID Ʒͼ汾 name Ʒͼ ֵ شIJƷͼ + */ + private TCComponentItem createItem(String CPTID, String revID, String name) { + TCComponentItem CPTItem = null; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session + .getTypeComponent("WF2_subCstmDraw"); + CPTItem = typeComponent.create(CPTID, revID, "WF2_subCstmDraw", + name, "", null); + } catch (TCException e) { + e.printStackTrace(); + } + return CPTItem; + } + + /** + * ݲѯҵϵͳжӦĿ + * + * @param targetComp + * Ŀļ ֵ ϵͳеĿ + */ + private TCComponent[] getProject(TCComponentFolder targetComp) { + TCComponent[] projects = null; + TCComponent[] tcs = null; + TCComponent[] tasks = null; + try { + tcs = targetComp.getTCProperty("fnd0StartedWorkflowTasks") + .getReferenceValueArray(); + if (tcs != null) { + + tasks = tcs[0].getTCProperty("fnd0RootScheduleTask") + .getReferenceValueArray(); + } else { + MessageBox.post("ļû߹̣", "ʾ", MessageBox.INFORMATION); + } + if (tasks != null && tasks.length > 0) { + TCComponent schedule = tasks[0].getTCProperty("schedule_tag") + .getReferenceValue(); + projects = schedule.getTCProperty("project_list") + .getReferenceValueArray(); + } else { + MessageBox.post("ûʱ", "ʾ", MessageBox.INFORMATION); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return projects; + } + +} diff --git a/src/com/connor/wf/plm/wf008/Wf008Dialog.java b/src/com/connor/wf/plm/wf008/Wf008Dialog.java new file mode 100644 index 0000000..14ef31b --- /dev/null +++ b/src/com/connor/wf/plm/wf008/Wf008Dialog.java @@ -0,0 +1,124 @@ +package com.connor.wf.plm.wf008; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.connor.wf.plm.wf007.Wf007Operation; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +/** + * :Wf008Dialog + * : ½Ʒͼ󴰿 + * :2019-02-26 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf008Dialog extends AbstractAIFDialog{ + private AbstractAIFUIApplication app; + private String pictureMB; + private TCSession session; + private TCComponentItemRevision targetComponent; + private TCPreferenceService service; + private JComboBox comboBox; + private Map map; + private String uid; + + public Wf008Dialog(AbstractAIFUIApplication app,InterfaceAIFComponent targetComponent) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.targetComponent = (TCComponentItemRevision) targetComponent; + this.pictureMB = null; + this.comboBox = null; + this.map = null; + this.uid = null; + } + public void run(){ + initUI(); + } + public void initUI(){ + this.setLayout(new BorderLayout()); + this.setTitle("Ʒͼ޶"); + this.setPreferredSize(new Dimension(200, 160)); + this.setResizable(false);// ɱ䶯ڴС + JPanel mainPanel = new JPanel(new PropertyLayout()); + JPanel topPanel = new JPanel(new PropertyLayout()); + JLabel jLabel = new JLabel(""); + topPanel.add("1.1.left.top",jLabel); + topPanel.add("2.1.left.top",jLabel); + topPanel.add("3.1.left.top",jLabel); + topPanel.add("4.1.left.top",jLabel); + JPanel centerPanel = new JPanel(new FlowLayout()); + JLabel nameLable = new JLabel(" ͼֽģ:"); + comboBox = new JComboBox(); + String[] values = service.getStringValues("WF2_Picture_MB"); + if (values == null || values.length <= 0) { + + MessageBox.post("ѡWF2_Picture_MBδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + String[] mbs = new String[values.length]; + map = new HashMap(); + for (int i = 0; i < values.length; i++) { + String[] vals = values[i].split("="); + mbs[i] = vals[0]; + map.put(vals[0],vals[1]); + } + for (int i = 0; i < mbs.length; i++) { + comboBox.addItem(mbs[i]); + } + centerPanel.add(nameLable); + centerPanel.add(comboBox); + JPanel southPanel = new JPanel(new FlowLayout()); + JButton okBtn = new JButton("ȷ"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + pictureMB = (String) comboBox.getSelectedItem(); + uid = map.get(pictureMB); + Wf008Operation operation = new Wf008Operation(app,targetComponent,uid); + session.queueOperation(operation); + disposeDialog(); + } + }); + JButton celBtn = new JButton("ȡ"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + mainPanel.add("1.1.center.top",topPanel); + mainPanel.add("2.1.center.top",centerPanel); + mainPanel.add("3.1.center.top",topPanel); + mainPanel.add("4.1.center.top",southPanel); + this.add(mainPanel, BorderLayout.CENTER); + + + + + this.centerToScreen(); + this.showDialog(); + } +} diff --git a/src/com/connor/wf/plm/wf008/Wf008Handler.java b/src/com/connor/wf/plm/wf008/Wf008Handler.java new file mode 100644 index 0000000..57d7240 --- /dev/null +++ b/src/com/connor/wf/plm/wf008/Wf008Handler.java @@ -0,0 +1,43 @@ +package com.connor.wf.plm.wf008; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf008Handler + * : Ʒͼ޶ + * :2019-02-26 + * Ա + * + * ޸ ޸ ޸ + * 2019-04 XXXX ȡù + */ +public class Wf008Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private TCSession session; + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent != null){ + if(targetComponent.getType().equals("WF2_2DprodDrawRevision")){ + Wf008Dialog dialog = new Wf008Dialog(app,targetComponent); + new Thread(dialog).start(); + return null; + }else{ + MessageBox.post("ѡƷͼ汾","ʾ",MessageBox.INFORMATION); + return null; + } + }else{ + MessageBox.post("ѡƷͼ汾","ʾ",MessageBox.INFORMATION); + } + return null; + } +} diff --git a/src/com/connor/wf/plm/wf008/Wf008Operation.java b/src/com/connor/wf/plm/wf008/Wf008Operation.java new file mode 100644 index 0000000..5eab32f --- /dev/null +++ b/src/com/connor/wf/plm/wf008/Wf008Operation.java @@ -0,0 +1,175 @@ +package com.connor.wf.plm.wf008; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf008Operation + * : Ʒͼ޶ + * :2019-02-26 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf008Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentItemRevision targetComponent; + private String uid; + public Wf008Operation(AbstractAIFUIApplication app, + TCComponentItemRevision targetComponent, String uid) { + this.app = app; + this.session = (TCSession) app.getSession(); + this.targetComponent = targetComponent; + this.uid = uid; + } + @Override + public void executeOperation() throws Exception { + saveAsNewRev(targetComponent,uid); + } + /** + * + * ݲ޶Ʒͼ + * @param + * targetComponent Ҫ޶IJƷͼ汾 + * uid Ҫϴģݼuid + */ + private void saveAsNewRev(TCComponentItemRevision targetComponent, + String uid) { + List uGDataset = new ArrayList(); + List jTDataset = new ArrayList(); + List cATPartDataset = new ArrayList();; + try { + TCComponentItemRevision newRev = targetComponent.saveAs(targetComponent.getItem() + .getNewRev()); + System.out.println("newRev============" + newRev); + TCComponent[] properties = targetComponent.getReferenceListProperty("IMAN_specification"); + TCComponent[] properties1 = targetComponent.getReferenceListProperty("IMAN_Rendering"); + TCComponent[] newProperties = newRev.getReferenceListProperty("IMAN_specification"); + TCComponent[] newProperties1 = newRev.getReferenceListProperty("IMAN_Rendering"); + if(newProperties != null){ + for (TCComponent property : newProperties) { + if(property instanceof TCComponentDataset){ + String type = property.getType(); + if(type.equals("CATPart")||type.equals("UGMASTER")){ + TCComponent[] tcs = new TCComponent[1]; + tcs[0] = property; + newRev.cutOperation("IMAN_specification", tcs); + property.delete(); + } + } + } + } + if(newProperties1 != null){ + for (TCComponent property : newProperties1) { + if(property instanceof TCComponentDataset){ + String type = property.getType(); + if(type.equals("DirectModel")){ + TCComponent[] tcs = new TCComponent[1]; + tcs[0] = property; + newRev.cutOperation("IMAN_Rendering", tcs); + property.delete(); + } + } + } + } + if(properties != null){ + for (TCComponent property : properties) { + if(property instanceof TCComponentDataset){ + String type = property.getType(); + System.out.println("======================"+type); + if(type.equals("UGMASTER")){ + uGDataset.add((TCComponentDataset) property); + continue; + } + if(type.equals("CATPart")){ + cATPartDataset.add((TCComponentDataset) property); + continue; + } + } + } + } + if(properties1 != null){ + for (TCComponent property : properties1) { + if(property instanceof TCComponentDataset){ + String type = property.getType(); + System.out.println("1========================="+type); + if(type.equals("DirectModel")){ + jTDataset.add((TCComponentDataset) property); + continue; + } + } + } + } + + if(uGDataset != null && uGDataset.size()>0){ + + newRev.add("IMAN_specification",uGDataset); + } + if(cATPartDataset != null && cATPartDataset.size()>0){ + + newRev.add("IMAN_specification",cATPartDataset); + } + if(jTDataset != null && jTDataset.size()>0){ + + newRev.add("IMAN_specification",jTDataset); + } + + TCComponentDataset mbDataset = createDataset(uid,newRev); + newRev.add("IMAN_specification",mbDataset); + + MessageBox.post("޶!!","",MessageBox.INFORMATION); + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("޶ʧ:"+e.getMessage(),"",MessageBox.ERROR); + } + } + /** + * + * ݲģļݼ + * @param + * uid Ҫϴģݼuid + * newRev : °汾 + * ֵ + * شģݼ + */ + private TCComponentDataset createDataset( + String uid,TCComponentItemRevision newRev) { + TCComponentDataset dataset = null; + TCComponentDataset mbDataset = null; + String[] path = new String[1]; + String[] ref_type = new String[1]; + try { + TCComponent comp = session.stringToComponent(uid); + if(comp instanceof TCComponentDataset){ + dataset = (TCComponentDataset) comp; + String type = dataset.getType(); + System.out.println("type=====" + type); + String name = newRev.getStringProperty("item_id")+"/"+newRev.getStringProperty("item_revision_id"); + File[] files = dataset.getFiles(""); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + mbDataset = datasetType.create(name, "", type); + path[0] = files[0].getAbsolutePath(); + ref_type[0] = "WF2_zwCad"; + mbDataset.setFiles(path, ref_type); + } + + } catch (TCException e) { + e.printStackTrace(); + } + return mbDataset; + } +} diff --git a/src/com/connor/wf/plm/wf009/CreateMoldDialog.java b/src/com/connor/wf/plm/wf009/CreateMoldDialog.java new file mode 100644 index 0000000..0f1ae7f --- /dev/null +++ b/src/com/connor/wf/plm/wf009/CreateMoldDialog.java @@ -0,0 +1,422 @@ +package com.connor.wf.plm.wf009; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.CodeBean; +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.GetCodeBean; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; + +/** + * :CreateBomDialog + * :ģߴdialog + * :2019-02-27 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ + +public class CreateMoldDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + private InterfaceAIFComponent[] targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + public CreateMoldDialog(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponents(); + init(); + } + private void init() { + + + final TCComponent itemR = (TCComponent)targetComponents[0]; + //1.жǷѡƷͼ汾ģ߳Ʒ + + if(!itemR.getTypeComponent().toString().equals("WF2_2DprodDrawRevision")) { + System.out.println(itemR.getTypeComponent()); + MessageBox.post("ѡƷͼİ汾ģ", "ʾϢ",MessageBox.INFORMATION); + }else if(itemR.getTypeComponent().toString().equals("WF2_2DprodDrawRevision")) { + //2.ѡƷİ汾ʱ + + + this.setTitle("ģߴ"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(280, 130)); + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + //ģо + final iTextField MouldCore_TextField = new iTextField(); + final JLabel jl = new JLabel(); + jl.setText("ģо"); + MouldCore_TextField.setPreferredSize(new Dimension(180, 20)); + + + panel.add("1.1.right.center.preferred.preferred",jl); + panel.add("1.2.left.center.perferred.perferred",MouldCore_TextField); + + + + + //ť 뵽ָ + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.center.top.preferred.preferred", panel); + this.add("2.1.center.top.preferred.preferred", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + //ȷťʱIJ + + ok_Button.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent ae) { + + //2.ģļ + try { + TCComponentItemRevision itemRevision = (TCComponentItemRevision)itemR; + TCComponent[] folder =itemRevision.getRelatedComponents("WF2_moldRe"); + //3.ģ߻ȡʱȡ̨ģ߳ƷıдģߺΪģ߶ + //жfolderǷΪ + if(folder.length==0|folder==null) { + + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + //String classid=selCodeBean.getClassID(); + + System.out.println(newID); + //ƴģߵid + String moldId=""; + if(MouldCore_TextField.getText().trim().length()==0) { + moldId = newID; + + }else { + moldId = newID+".M"+MouldCore_TextField.getText().trim(); + } + + //ȡѡIJƷͼϢ + + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + System.out.println(tcR.getStringProperty("current_id")); + String wf2_ET=tcR.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_ET"); + + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+"1#"; + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + item.getLatestItemRevision().getReferenceListProperty("IMAN_master_form_rev")[0].setStringProperty("wf2_coreOffset", wf2_ET); + + setDataset(item.getLatestItemRevision()); + //ӲƷͼģ֮Ĺϵ + itemRevision.add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + // + + }else { + //ģļдģߵʱжģоǷֵͬ + //1.жûģо ûģоidͬ + + Integer maxNum=0; + + //ģߵ ȡһֵΪģоֵ + String isOccupy="false"; + String moldHeart = ""; + Integer sameNum=0; + Integer Num; + for (TCComponent tcComponent : folder) { + String moldid = tcComponent.getStringProperty("current_id"); + String moldName = tcComponent.getStringProperty("object_name"); + moldHeart = moldid.substring(moldid.length()-2, moldid.length()); + //maxNumΪģ + if(moldName!=null && !moldName.equals("")) { + if(moldName.substring(moldName.length()-3,moldName.length()-2).equals("-")) { + Num =Integer.valueOf(moldName.substring(moldName.length()-2,moldName.length()-1)); + }else { + Num =Integer.valueOf(moldName.substring(moldName.length()-3,moldName.length()-1)); + } + + if(Num>maxNum) { + maxNum=Num; + } + + } + System.out.println(moldid.substring(moldid.length()-2,moldid.length())); + if(moldid.substring(moldid.length()-2,moldid.length())=="M1"|moldid.substring(moldid.length()-2,moldid.length()).equals("M1")) { + sameNum=sameNum+1; + + } + if(moldHeart.equals("M"+MouldCore_TextField.getText().trim())) { + //յֵͬ isOccupy Ϊtrue + isOccupy ="true"; + } + + } + + + if(MouldCore_TextField.getText().trim().length()==0) { + //ȡµid жĿģ+1 + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + + String moldId = newID; + + + //ģ߶ + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + String wf2_ET =tcR.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_ET"); + + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(maxNum+1)+"#"; + + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + item.getLatestItemRevision().getReferenceListProperty("IMAN_master_form_rev")[0].setStringProperty("wf2_coreOffset", wf2_ET); + + setDataset(item.getLatestItemRevision()); + //ӲƷͼģ֮Ĺϵ + itemRevision.add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + + + + }else { + + //һͬ id++ ģ+1 + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + + String moldId = newID+".M"+MouldCore_TextField.getText().trim(); + + + + //ģ߶ + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + String wf2_ET=tcR.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_ET"); + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(maxNum+1)+"#"; + + + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + item.getLatestItemRevision().getReferenceListProperty("IMAN_master_form_rev")[0].setStringProperty("wf2_coreOffset", wf2_ET); + //wf2_coreOffset + + setDataset(item.getLatestItemRevision()); + //ӲƷͼģ֮Ĺϵ + itemRevision.add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + + + + + + } + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + e.printStackTrace(); + } + } + }); + + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + } + } + + + private void closeDialog() { + disposeDialog(); + setVisible(false); +} + /** + * ͷ + * + * @param class_id + * id + * @param rev + * 汾 + * @param keys + * id + * @param vals + * ֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + + /** + * ģ + * @param rev + */ + private void setDataset(TCComponentItemRevision rev){ + + try { + String id = rev.getProperty("item_id"); + String revid = rev.getProperty("item_revision_id"); + String uid = session.getPreferenceService().getStringValue("WF2_mold_Dataset");//ѡuid + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(uid); + TCComponentDataset newData = dataset.saveAs(id+ "/" + revid); + rev.add("IMAN_specification", newData); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + +} diff --git a/src/com/connor/wf/plm/wf009/CreateMoldDialogs.java b/src/com/connor/wf/plm/wf009/CreateMoldDialogs.java new file mode 100644 index 0000000..dd158bc --- /dev/null +++ b/src/com/connor/wf/plm/wf009/CreateMoldDialogs.java @@ -0,0 +1,865 @@ +package com.connor.wf.plm.wf009; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.CodeBean; +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.GetCodeBean; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; + +/** + * :CreateBomDialog + * :ģߴdialog + * :2019-02-27 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ + +public class CreateMoldDialogs extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + private InterfaceAIFComponent[] targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + public CreateMoldDialogs(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponents(); + init(); + } + private void init() { + + + final TCComponent itemR = (TCComponent)targetComponents[0]; + //1.жǷѡƷͼ汾ģ߳Ʒ + + if(!itemR.getTypeComponent().toString().equals("WF2_2DprodDrawRevision")&!itemR.getTypeComponent().toString().equals("WF2_mold")) { + System.out.println(itemR.getTypeComponent()); + MessageBox.post("ѡƷͼİ汾ģ߶ģ", "ʾϢ",MessageBox.INFORMATION); + }else if(itemR.getTypeComponent().toString().equals("WF2_2DprodDrawRevision")) { + //2.ѡƷİ汾ʱ + + + this.setTitle("ģߴ"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(280, 130)); + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + //ģо + final iTextField MouldCore_TextField = new iTextField(); + final JLabel jl = new JLabel(); + jl.setText("ģо"); + MouldCore_TextField.setPreferredSize(new Dimension(180, 20)); + + + panel.add("1.1.right.center.preferred.preferred",jl); + panel.add("1.2.left.center.perferred.perferred",MouldCore_TextField); + + + + + //ť 뵽ָ + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.center.top.preferred.preferred", panel); + this.add("2.1.center.top.preferred.preferred", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + //ȷťʱIJ + + ok_Button.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent ae) { + + //2.ģļ + try { + TCComponentItemRevision itemRevision = (TCComponentItemRevision)itemR; + TCComponent[] folder =itemRevision.getRelatedComponents("WF2_moldRe"); + //3.ģ߻ȡʱȡ̨ģ߳ƷıдģߺΪģ߶ + //жfolderǷΪ + if(folder.length==0|folder==null) { + + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + //String classid=selCodeBean.getClassID(); + + System.out.println(newID); + //ƴģߵid + String moldId=""; + if(MouldCore_TextField.getText().trim().length()==0) { + moldId = newID; + + }else { + moldId = newID+".M"+MouldCore_TextField.getText().trim(); + } + + //ȡѡIJƷͼϢ + + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + System.out.println(tcR.getStringProperty("current_id")); + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+"1"; + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + + //ӲƷͼģ֮Ĺϵ + itemRevision.add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + // + + }else { + //ģļдģߵʱжģоǷֵͬ + //1.жûģо ûģоidͬ + + Integer maxNum=0; + + //ģߵ ȡһֵΪģоֵ + String isOccupy="false"; + String moldHeart = ""; + Integer sameNum=0; + Integer Num; + for (TCComponent tcComponent : folder) { + String moldid = tcComponent.getStringProperty("current_id"); + String moldName = tcComponent.getStringProperty("object_name"); + moldHeart = moldid.substring(moldid.length()-2, moldid.length()); + //maxNumΪģ + if(moldName!=null && !moldName.equals("")) { + if(moldName.substring(moldName.length()-2,moldName.length()-1).equals("-")) { + Num =Integer.valueOf(moldName.substring(moldName.length()-1,moldName.length())); + }else { + Num =Integer.valueOf(moldName.substring(moldName.length()-2,moldName.length())); + } + + if(Num>maxNum) { + maxNum=Num; + } + + } + System.out.println(moldid.substring(moldid.length()-2,moldid.length())); + if(moldid.substring(moldid.length()-2,moldid.length())=="M1"|moldid.substring(moldid.length()-2,moldid.length()).equals("M1")) { + sameNum=sameNum+1; + + } + if(moldHeart.equals("M"+MouldCore_TextField.getText().trim())) { + //յֵͬ isOccupy Ϊtrue + isOccupy ="true"; + } + + } + + + if(MouldCore_TextField.getText().trim().length()==0) { + //ȡµid жĿģ+1 + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + + String moldId = newID; + + + //ģ߶ + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(maxNum+1); + + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + + //ӲƷͼģ֮Ĺϵ + itemRevision.add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + + + + + + + }else { + //Ϊ 12 ģоʱ + //жǷֵ1ģоģ + //1ʱ 1 23456 ʾϢ ͬ1ģоѡģ߽д + //ѭSameNumֵڻ2ʱͬģоģ + + if(sameNum>=2) { + //1ģоʱ ֵΪ1 idӿģ+1 Ϊ1 ʾ + if(MouldCore_TextField.getText().trim().equals("1")) { + + //һͬ id++ ģ+1 + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + + String moldId = newID+".M"+MouldCore_TextField.getText().trim(); + + + + //ģ߶ + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(maxNum+1); + + + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + + //ӲƷͼģ֮Ĺϵ + itemRevision.add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + + }else { + //2ϵ1ʱģо2ϵģоʾѡģ߱ģߴ + MessageBox.post("1ģоģߣѡ1ģоģ߶д", "ʾϢ",MessageBox.INFORMATION); + + } + + }else { + //ʱжǷģоֵ + //sameNum=1 + //1ģоʱ ֵΪ1 idӿģ+1 Ϊ1 ʾ + if(MouldCore_TextField.getText().trim().equals("1")) { + + //һͬ id++ ģ+1 + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + + String moldId = newID+".M"+MouldCore_TextField.getText().trim(); + + + + //ģ߶ + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(maxNum+1); + + + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + + //ӲƷͼģ֮Ĺϵ + itemRevision.add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + + }else { + //2345ģоʱжisOccupyǷΪtruetrueʱģоid ģ+1 + + if(isOccupy=="true") { + //ʱжǷģоֵ + //sameNum=1 + //1ģоʱ ֵΪ1 idӿģ+1 Ϊ1 ʾ + + + //һͬ id++ ģ+1 + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + + //idΪȡNewid ƴ M+ģо + String moldId = newID+".M"+MouldCore_TextField.getText().trim(); + + + + //ģ߶ + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(maxNum+1); + + + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + + //ӲƷͼģ֮Ĺϵ + itemRevision.add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + + }else { + //ͬidǰ׺ģͬ + + //ͬ½һģоΪֵģ + + //˴idΪȡԭģ߶id + String newID = ""; + if(folder[0].getStringProperty("current_id").length()==10) { + newID = folder[0].getStringProperty("current_id"); + }else { + newID = folder[0].getStringProperty("current_id").substring(0, folder[0].getStringProperty("current_id").length()-3); + + } + //String classid=selCodeBean.getClassID(); + System.out.println(newID); + //ƴģߵid + String moldId=""; + + //ģоֵжϵõnewID ǷҪȡ ûģоIJҪƴӡģоƴ .M+ģо + if(MouldCore_TextField.getText().trim().length()==0) { + moldId=newID; + }else { + moldId = newID+".M"+MouldCore_TextField.getText().trim(); + } + + //ģ߶ + TCComponent tcR = (TCComponent)targetComponents[0]; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+folder[0].getStringProperty("object_name").substring(folder[0].getStringProperty("object_name").length()-1, folder[0].getStringProperty("object_name").length()); + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + itemRevision.add("WF2_moldRe", item); + + + + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + + closeDialog(); + + + } + + + } + + + } + + } + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + }else { + //ѡģߵʱť + this.setTitle("ģߴ"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(280, 130)); + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + //ģо + final iTextField MouldCore_TextField = new iTextField(); + final JLabel jl = new JLabel(); + jl.setText("ģо"); + MouldCore_TextField.setPreferredSize(new Dimension(180, 20)); + + + panel.add("1.1.right.center.preferred.preferred",jl); + panel.add("1.2.left.center.perferred.perferred",MouldCore_TextField); + + + //ť 뵽ָ + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.center.top.preferred.preferred", panel); + this.add("2.1.center.top.preferred.preferred", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + + ok_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + + + //2.ģļ + try { + TCComponentItem itemRevision = (TCComponentItem)itemR; + + // ҵѡеģ߶ӦIJƷͼ汾 + final AIFComponentContext[] a= itemRevision.whereReferencedByTypeRelation(new String[] {"WF2_2DprodDrawRevision"}, new String[] {"WF2_moldRe"}); + + + TCComponent[] folder =((TCComponent) a[0].getComponent()).getRelatedComponents("WF2_moldRe"); + + //1.жûģо ûģоidͬ + + Integer maxNum=0; + + //ģߵ ȡһֵΪģоֵ + String isOccupy="false"; + String moldHeart = ""; + Integer Num =0; + for (TCComponent tcComponent : folder) { + String moldid = tcComponent.getStringProperty("current_id"); + String moldName = tcComponent.getStringProperty("object_name"); + moldHeart = moldid.substring(moldid.length()-2, moldid.length()); + //maxNumΪģ + if(moldName!=null && !moldName.equals("")) { + + //жϿģλ λ10λ + if(moldName.substring(moldName.length()-2,moldName.length()-1).equals("-")) { + Num =Integer.valueOf(moldName.substring(moldName.length()-1,moldName.length())); + }else { + Num =Integer.valueOf(moldName.substring(moldName.length()-2,moldName.length())); + } + + if(Num>maxNum) { + maxNum=Num; + } + + } + if(moldHeart.equals("M"+MouldCore_TextField.getText().trim())) { + //յֵͬ isOccupy Ϊtrue + isOccupy ="true"; + } + + } + + //жǷΪգΪյʱidΪ»ȡģ+1 + + if(MouldCore_TextField.getText().trim().length()==0) { + //ȡµid жĿģ+1 + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + + String moldId = newID; + + + //ģ߶ + TCComponent tcR = ((TCComponent) a[0].getComponent()); + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(maxNum+1); + + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + + //ӲƷͼģ֮Ĺϵ + ((TCComponent) a[0].getComponent()).add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + + + + + + + }else { + //Ϊ1234жǷ + + + + + if(isOccupy=="true") { + //ʱжǷģоֵ + + + //һͬ id++ ģ+1 + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + DataBaseControl data=new DataBaseControl(session); + //ȡеģid + String newID = data.getNewCode("PLMCODE", selCodeBean); + + String moldId = newID+".M"+MouldCore_TextField.getText().trim(); + + + + //ģ߶ + TCComponent tcR = ((TCComponent) a[0].getComponent()); + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(maxNum+1); + + + + //ģ߶ + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + + //ӲƷͼģ֮Ĺϵ + ((TCComponent) a[0].getComponent()).add("WF2_moldRe", item); + + + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + closeDialog(); + + }else { + //ͬidǰ׺ģͬ + + //ͬ½һģоΪֵģ + + //˴idΪȡԭģ߶id + String newID = ""; + if(itemR.getStringProperty("current_id").length()==10) { + newID = itemR.getStringProperty("current_id"); + }else { + newID = itemR.getStringProperty("current_id").substring(0, itemR.getStringProperty("current_id").length()-3); + + } + //String classid=selCodeBean.getClassID(); + System.out.println(newID); + //ƴģߵid + String moldId=""; + if(MouldCore_TextField.getText().trim().length()==0) { + moldId=newID; + }else { + moldId = newID+".M"+MouldCore_TextField.getText().trim(); + } + + //ģ߶ + TCComponent tcR = ((TCComponent) a[0].getComponent()); + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + String projectNum = tcR.getStringProperty("current_id").substring(tcR.getStringProperty("current_id").length()-5,tcR.getStringProperty("current_id").length()); + String moldNum = itemR.getStringProperty("object_name").substring(itemR.getStringProperty("object_name").length()-1,itemR.getStringProperty("object_name").length()); + + String moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+(moldNum); + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + ((TCComponent) a[0].getComponent()).add("WF2_moldRe", item); + + + + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + + closeDialog(); + + + } + + } + + + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }); + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + + } + } + + + private void closeDialog() { + disposeDialog(); + setVisible(false); +} + /** + * ͷ + * + * @param class_id + * id + * @param rev + * 汾 + * @param keys + * id + * @param vals + * ֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + + + +} diff --git a/src/com/connor/wf/plm/wf009/CreateMolddrawDialog.java b/src/com/connor/wf/plm/wf009/CreateMolddrawDialog.java new file mode 100644 index 0000000..2a58bac --- /dev/null +++ b/src/com/connor/wf/plm/wf009/CreateMolddrawDialog.java @@ -0,0 +1,361 @@ +package com.connor.wf.plm.wf009; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.CodeBean; +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.GetCodeBean; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; + +/** + * :CreateBomDialog + * :ģߴdialog + * :2019-02-27 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ + +public class CreateMolddrawDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + private InterfaceAIFComponent[] targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + public CreateMolddrawDialog(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponents(); + init(); + } + private void init() { + + + final TCComponent itemR = (TCComponent)targetComponents[0]; + //1.жǷѡƷͼ汾ģ߳Ʒ + + if(!itemR.getTypeComponent().toString().equals("WF2_mold")&!itemR.getTypeComponent().toString().equals("WF2_mold")) { + System.out.println(itemR.getTypeComponent()); + MessageBox.post("ģ߶ģ", "ʾϢ",MessageBox.INFORMATION); + }else { + //ѡģߵʱť + this.setTitle("ģߴ"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(280, 130)); + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + //ģо + final iTextField MouldCore_TextField = new iTextField(); + final JLabel jl = new JLabel(); + jl.setText("ģо"); + MouldCore_TextField.setPreferredSize(new Dimension(180, 20)); + + + panel.add("1.1.right.center.preferred.preferred",jl); + panel.add("1.2.left.center.perferred.perferred",MouldCore_TextField); + + + //ť 뵽ָ + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.center.top.preferred.preferred", panel); + this.add("2.1.center.top.preferred.preferred", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + + ok_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + + + //2.ģļ + try { + TCComponentItem itemRevision = (TCComponentItem)itemR; + + // ҵѡеģ߶ӦIJƷͼ汾 + final AIFComponentContext[] a= itemRevision.whereReferencedByTypeRelation(new String[] {"WF2_2DprodDrawRevision"}, new String[] {"WF2_moldRe"}); + + + TCComponent[] folder =((TCComponent) a[0].getComponent()).getRelatedComponents("WF2_moldRe"); + + //1.жûģо ûģоidͬ + + Integer maxNum=0; + + //ģߵ ȡһֵΪģоֵ + String isOccupy="false"; + String moldHeart = ""; + Integer Num =0; + for (TCComponent tcComponent : folder) { + String moldid = tcComponent.getStringProperty("current_id"); + String moldName = tcComponent.getStringProperty("object_name"); + moldHeart = moldid.substring(moldid.length()-2, moldid.length()); + String MNum = itemR.getStringProperty("current_id").substring(0, 10)+".M"+MouldCore_TextField.getText().trim(); + //maxNumΪģ + if(moldName!=null && !moldName.equals("")) { + + //жϿģλ λ10λ + if(moldName.substring(moldName.length()-3,moldName.length()-2).equals("-")) { + Num =Integer.valueOf(moldName.substring(moldName.length()-2,moldName.length()-1)); + }else { + Num =Integer.valueOf(moldName.substring(moldName.length()-3,moldName.length()-1)); + } + + if(Num>maxNum) { + maxNum=Num; + } + + } + if(MNum.equals(moldid)) { + isOccupy = "true"; + } + +// +// if(moldHeart.equals("M"+MouldCore_TextField.getText().trim())) { +// //յֵͬ isOccupy Ϊtrue +// isOccupy ="true"; +// } + + } + + //жǷΪգΪյʱidΪ»ȡģ+1 + + if(MouldCore_TextField.getText().trim().length()==0) { + //ΪյʱʾϢ + MessageBox.post("Ϊ,ģо", + "", MessageBox.ERROR); + }else { + //Ϊյʱ жĿеģоǷڣ򱨴ʾϢ + + //жisOccupyǷΪtrue2345ģоʱжisOccupyǷΪtruetrueʱģоid + + //ѡеidж + + // String MNum = itemR.getStringProperty("current_id").substring(0, 10)+"M"+MouldCore_TextField.getText().trim(); + + if(isOccupy.equals("true")) { + MessageBox.post("ģӦĴģоѾڣ", + "", MessageBox.ERROR); + + }else { + + + //ͬidǰ׺ģͬ + + //ͬ½һģоΪֵģ + + //˴idΪȡԭģ߶id + String newID = ""; + if(itemR.getStringProperty("current_id").length()==10) { + newID =itemR.getStringProperty("current_id"); + }else { + newID = itemR.getStringProperty("current_id").substring(0, itemR.getStringProperty("current_id").length()-3); + } + //String classid=selCodeBean.getClassID(); + System.out.println(newID); + //ƴģߵid + String moldId=""; + + //ģоֵжϵõnewID ǷҪȡ ûģоIJҪƴӡģоƴ .M+ģо + if(MouldCore_TextField.getText().trim().length()==0) { + moldId=newID; + }else { + moldId = newID+".M"+MouldCore_TextField.getText().trim(); + } + + //ģ߶ + TCComponent tcR = ((TCComponent) a[0].getComponent());; + String wf2_spoke=tcR.getStringProperty("wf2_spoke_rev"); + String wf2_rimDiameter = tcR.getStringProperty("wf2_rimDiameter_rev"); + String wf2_rimWidth = tcR.getStringProperty("wf2_rimWidth_rev"); + + String projectNum = itemR.getStringProperty("current_id").substring(itemR.getStringProperty("current_id").length()-5,itemR.getStringProperty("current_id").length()); + + + + //ģ + //жϿģ λ Ӷı + //λʱ + String numName = itemR.getStringProperty("object_name"); + String moldName = numName; +// if(numName.substring(numName.length()-3,numName.length()-2).equals("-")) { +// moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+itemR.getStringProperty("object_name").substring(itemR.getStringProperty("object_name").length()-2, itemR.getStringProperty("object_name").length()-1)+"#"; +// +// }else { +// moldName = wf2_spoke+projectNum+wf2_rimDiameter+wf2_rimWidth+"-"+itemR.getStringProperty("object_name").substring(itemR.getStringProperty("object_name").length()-3, itemR.getStringProperty("object_name").length()-1)+"#"; +// +// } + + + + + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mold"); + + TCComponentItem item = ccomponentitemtype.create(moldId,"A","WF2_mold",moldName,"",null); + + ((TCComponent) a[0].getComponent()).add("WF2_moldRe", item); + + setDataset(item.getLatestItemRevision()); + + GetCodeBean getcode=new GetCodeBean(session); + CodeBean selCodeBean=getcode.getCodebean("ģ&ģ"); + + //͵ + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + sendObjToClassficationByWebService(classid, + item.getLatestItemRevision(), new Integer[] {}, + new String[] {}); + } else { + System.out.println("δҵ͵ķid,"); + } + + closeDialog(); + + + + + + + + } + + } + + + + + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + e.printStackTrace(); + } + + } + }); + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + + } + } + + + private void closeDialog() { + disposeDialog(); + setVisible(false); +} + /** + * ͷ + * + * @param class_id + * id + * @param rev + * 汾 + * @param keys + * id + * @param vals + * ֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + + /** + * ģ + * @param rev + */ + private void setDataset(TCComponentItemRevision rev){ + + try { + String id = rev.getProperty("item_id"); + String revid = rev.getProperty("item_revision_id"); + String uid = session.getPreferenceService().getStringValue("WF2_mold_Dataset");//ѡuid RYex9yO7JsmraC + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(uid); + TCComponentDataset newData = dataset.saveAs(id+ "/" + revid); + rev.add("IMAN_specification", newData); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/wf/plm/wf009/Wf009_01Handler.java b/src/com/connor/wf/plm/wf009/Wf009_01Handler.java new file mode 100644 index 0000000..306120e --- /dev/null +++ b/src/com/connor/wf/plm/wf009/Wf009_01Handler.java @@ -0,0 +1,32 @@ +package com.connor.wf.plm.wf009; + +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; + +/** + * :Wf009_01Handler + * :... + * :2019-02-27 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class Wf009_01Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + CreateMoldDialog createMoldDialog = new CreateMoldDialog(app); + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf009/Wf009_02Handler.java b/src/com/connor/wf/plm/wf009/Wf009_02Handler.java new file mode 100644 index 0000000..1708f00 --- /dev/null +++ b/src/com/connor/wf/plm/wf009/Wf009_02Handler.java @@ -0,0 +1,32 @@ +package com.connor.wf.plm.wf009; + +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; + +/** + * :Wf009_02Handler + * :... + * :2019-02-27 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class Wf009_02Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + CreateMolddrawDialog createMolddrawDialog = new CreateMolddrawDialog(app); + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf010/CreateProcessDrawDialog.java b/src/com/connor/wf/plm/wf010/CreateProcessDrawDialog.java new file mode 100644 index 0000000..58d44fc --- /dev/null +++ b/src/com/connor/wf/plm/wf010/CreateProcessDrawDialog.java @@ -0,0 +1,249 @@ +package com.connor.wf.plm.wf010; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JRadioButton; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; +/** + * :Wf010Handler + * :ͼ + * :2019-02-28 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class CreateProcessDrawDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private InterfaceAIFComponent targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + private String jjgtuid=""; + public CreateProcessDrawDialog(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponent(); + getuid(); + init(); + } + + /** + * ݼuid + */ + private void getuid() { + // TODO Auto-generated method stub + TCPreferenceService pref = session.getPreferenceService(); + jjgtuid = pref.getStringValue("WF2_processDraw_PUID");// ѡpuid + if (jjgtuid==null||jjgtuid.equals("")) { + System.out.println("δҵѡWF2_processDraw_PUID"); + } + + } + + private void init() { + + if (targetComponents==null) { + MessageBox.post("ѡƷͼ汾", "ʾϢ",MessageBox.INFORMATION); + return; + } + + TCComponent itemR = (TCComponent)targetComponents; + //1.жǷѡƷͼ汾 + + if(!itemR.getType().equals("WF2_2DprodDrawRevision")) { + System.out.println(itemR.getType()); + MessageBox.post("ѡƷͼ汾", "ʾϢ",MessageBox.INFORMATION); + }else { + + + + this.setTitle("ͼ"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(280, 200)); + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + final JRadioButton button = new JRadioButton("ëͼ"); + final JRadioButton button2 = new JRadioButton("ӹͼ"); + final JRadioButton button3 = new JRadioButton("ȫߴͼ"); + final ButtonGroup group = new ButtonGroup(); + group.add(button); + group.add(button2); + group.add(button3); + group.setSelected(button.getModel(), true); + + //ģо + final iTextField MouldCore_TextField = new iTextField(); + + MouldCore_TextField.setPreferredSize(new Dimension(180, 20)); + + + panel.add("1.1.left.left.preferred.preferred",button); + panel.add("2.1.left.left.perferred.perferred",button2); + panel.add("3.1.left.left.perferred.perferred",button3); + + + //ť 뵽ָ + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.left.left.preferred.preferred", panel); + this.add("2.1.left.left.preferred.preferred", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + ok_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + + System.out.println(group.getElements()); + System.out.println(group.getSelection()); + //ûѡ ӦĹͼ + if(group.isSelected(button.getModel())) { + //1)ëͼ + try { + //1.ȡƷͼid Ϊȡѡеĵλid + TCComponentItem item = ((TCComponentItemRevision)targetComponents).getItem(); + System.out.println(item.getStringProperty("current_id")); + //2.ƷͼidëͼӦġ.Mƴ + String WoolMap = item.getStringProperty("current_id")+".M"; + + //3.ëͼ + TCComponentItemType tccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_processDraw"); + String itemId = WoolMap; + TCComponentItem newWoolMap = tccomponentitemtype.create(itemId,"A","WF2_processDraw","ëͼ","",null); + TCComponentItemRevision rev = newWoolMap.getLatestItemRevision(); + String idstr = rev.getTCProperty("item_id").getStringValue(); + String revidstr = rev.getTCProperty("item_revision_id").getStringValue(); + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(jjgtuid); + TCComponentDataset newData = dataset.saveAs(idstr+ "/" + revidstr); + rev.add("IMAN_specification", newData); + + //4.newstuffļ´ӦëͼĹϵ +// TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); +// newStuffFolder.add("contents", newWoolMap); + System.out.println("==================׼ҵϵļ"); + ((TCComponentItemRevision)targetComponents).add("WF2_modelDraw", newWoolMap); + MessageBox.post("ëͼɹ", "ʾϢ",MessageBox.INFORMATION); + closeDialog(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post("ëͼʧܣIDѾռ", "ʾϢ",MessageBox.INFORMATION); + e.printStackTrace(); + } + + }else if(group.isSelected(button2.getModel())) { + //2)ӹͼ + try { + //1.ȡƷͼid Ϊȡѡеĵλid + TCComponent item = ((TCComponentItemRevision)targetComponents).getItem(); + System.out.println(item.getStringProperty("item_id")); + //2.ƷͼidӹͼӦġ.Mƴ + String WoolMap = item.getStringProperty("item_id")+".J"; + + //3.ӹͼ + TCComponentItemType tccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_processDraw"); + String itemId = WoolMap; + TCComponentItem newWoolMap = tccomponentitemtype.create(itemId,"A","WF2_processDraw","ӹͼ","",null); + TCComponentItemRevision rev = newWoolMap.getLatestItemRevision(); + String idstr = rev.getTCProperty("item_id").getStringValue(); + String revidstr = rev.getTCProperty("item_revision_id").getStringValue(); + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(jjgtuid); + TCComponentDataset newData = dataset.saveAs(idstr+ "/" + revidstr); + rev.add("IMAN_specification", newData); + + //4.newstuffļ´ӦĻӹͼĹϵ + //TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); + ((TCComponentItemRevision)targetComponents).add("WF2_machingDraw", newWoolMap); + + MessageBox.post("ӹͼɹ", "ʾϢ",MessageBox.INFORMATION); + closeDialog(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post("ӹͼʧܣIDѾռ", "ʾϢ",MessageBox.INFORMATION); + e.printStackTrace(); + } + + }else if(group.isSelected(button3.getModel())) { + //3)ȫߴͼ + try { + //1.ȡƷͼid Ϊȡѡеĵλid + TCComponent item = ((TCComponentItemRevision)targetComponents).getItem(); + System.out.println(item.getStringProperty("item_id")); + //2.ƷͼidȫߴͼӦġ.Mƴ + String WoolMap = item.getStringProperty("item_id")+".Q"; + + //3.ȫߴͼ + TCComponentItemType tccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_processDraw"); + String itemId = WoolMap; + TCComponentItem newWoolMap = tccomponentitemtype.create(itemId,"A","WF2_processDraw","ȫߴͼ","",null); + + + //4.newstuffļ´ӦȫߴͼĹϵ + TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); + newStuffFolder.add("contents", newWoolMap); + MessageBox.post("ȫߴͼɹ", "ʾϢ",MessageBox.INFORMATION); + closeDialog(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post("ȫߴͼʧܣIDѾռ", "ʾϢ",MessageBox.INFORMATION); + e.printStackTrace(); + } + + } + + } + }); + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + + } + + } + private void closeDialog() { + disposeDialog(); + setVisible(false); +} +} + diff --git a/src/com/connor/wf/plm/wf010/Wf010Handler.java b/src/com/connor/wf/plm/wf010/Wf010Handler.java new file mode 100644 index 0000000..c436948 --- /dev/null +++ b/src/com/connor/wf/plm/wf010/Wf010Handler.java @@ -0,0 +1,32 @@ +package com.connor.wf.plm.wf010; + +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; + +/** + * :Wf010Handler + * :ͼ + * :2019-02-28 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ + +public class Wf010Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + CreateProcessDrawDialog createProcessDrawDialog = new CreateProcessDrawDialog(app); + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf011/CreateSubPartDrawDialog.java b/src/com/connor/wf/plm/wf011/CreateSubPartDrawDialog.java new file mode 100644 index 0000000..536cb94 --- /dev/null +++ b/src/com/connor/wf/plm/wf011/CreateSubPartDrawDialog.java @@ -0,0 +1,305 @@ +package com.connor.wf.plm.wf011; + +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.util.HashMap; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; +/** + * :CreateSubPartDrawDialog + * :ģͼ + * :2019-02-28 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class CreateSubPartDrawDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private InterfaceAIFComponent[] targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + public CreateSubPartDrawDialog(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponents(); + init(); + } + private void init() { + + //жǷΪģ߶ + TCComponent itemR = (TCComponent)targetComponents[0]; + if(!itemR.getTypeComponent().toString().equals("WF2_mold")) { + System.out.println(itemR.getTypeComponent()); + MessageBox.post("ѡģ߶󴴽ģͼ", "ʾϢ",MessageBox.INFORMATION); + }else { + + this.setTitle("ģͼ"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(280, 200)); + + final iTextField itemName_TextField = new iTextField(); + final iTextField mold_TextField = new iTextField(); + + + itemName_TextField.setPreferredSize(new Dimension(180, 20)); + mold_TextField.setPreferredSize(new Dimension(180, 20)); + + //ģͼģ ļУڻȡļеģƼ + + //˴Ҫ޸ģѡӶõIJ˵ + + try { + String str =""; + String [] strings = {}; //˵Ϣ + String strr=""; + String templateName=""; + final HashMap map = new HashMap(); + // TCComponentFolder tcFolder=(TCComponentFolder)session.stringToComponent("wbTxDlZzJsmraC"); + // ͨѡȡģģstring + String[] mdPartTemplate =session.getPreferenceService().getStringValues("WF2_mdPartTemplate"); + for (String string : mdPartTemplate) { + strr=string.split(",")[0]; + templateName=string.split(",")[1]; + map.put(strr, templateName); + str=str+strr+","; + } + + strings = str.toString().split(","); + + final JComboBox jComboBox = new JComboBox<>(strings); //˵ + jComboBox.addItemListener(new ItemListener() { //ѡ˵ļ + + @Override + public void itemStateChanged(ItemEvent e) { + //ͨѡ uidϣӶõuid + + } + + }); + + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + + + + panel.add("1.1.right.center.preferred.preferred",new JLabel("")); + panel.add("1.2.left.center.preferred.preferred",itemName_TextField); + + panel.add("2.1.right.center.preferred.preferred",new JLabel("ͼֽģ")); + panel.add("2.2.left.center.preferred.preferred",jComboBox); + + //ģо + final iTextField MouldCore_TextField = new iTextField(); + + MouldCore_TextField.setPreferredSize(new Dimension(180, 20)); + + + + + //ť 뵽ָ + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.left.left.preferred.preferred", panel); + this.add("2.1.left.left.preferred.preferred", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + ok_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + + //1.õģ߶ + TCComponentItem mold = (TCComponentItem)targetComponents[0]; + try { + //1.ȡǰģߵid + String moldId= mold.getStringProperty("current_id"); + //2.Ƿڵǰģߵ ΪͬidģǷ + String num = "1"; + String moldsonId = moldId+"-01"; + String isMax="false"; + + while(isMax.equals("false")) { + + if(Integer.valueOf(num)<10) { + TCComponent[] moldson=session.search("...", new String[] { " ID" }, new String[] {moldId+"-0"+num}); + + if(moldson==null || (moldson!=null&&moldson.length==0)){ + num=String.valueOf(Integer.parseInt(num)-1); + isMax="true"; + }else{ + num=String.valueOf(Integer.parseInt(num)+1); + } + + }else { + TCComponent[] moldson=session.search("...", new String[] { " ID" }, new String[] {moldId+"-"+num}); + + if(moldson==null || (moldson!=null&&moldson.length==0)){ + num=String.valueOf(Integer.parseInt(num)-1); + isMax="true"; + }else{ + num=String.valueOf(Integer.parseInt(num)+1); + } + } + + } + String zero=""; + if(Integer.valueOf(num)<10) { + zero="-0"; + }else { + zero="-"; + } + TCComponent[] moldson=session.search("...", new String[] { " ID" }, new String[] {moldId+zero+(num)}); + + //ģڣģ + if(moldson == null) { + + //3.ģ + TCComponentItemType tccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mdPart"); + String itemId = moldsonId; + TCComponentItem newMoldSon = tccomponentitemtype.create(itemId,"A","WF2_mdPart",itemName_TextField.getText().trim(),"",null); + + + //ѡеģͼֽģ帴Ƶ汾 + String uuid=jComboBox.getSelectedItem().toString(); + TCComponentDataset dataset2=(TCComponentDataset)session.stringToComponent(map.get(uuid)); + + TCComponentDataset dataset=dataset2.saveAs(itemName_TextField.getText().trim()); + + newMoldSon.getLatestItemRevision().add("IMAN_specification", dataset); + + + + //4.ʼļ´ӦģĹϵ + TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); + newStuffFolder.add("contents", newMoldSon); + closeDialog(); + MessageBox.post("ɹ,newStuffļ²鿴", "ʾϢ",MessageBox.INFORMATION); + }else { + + if(Integer.valueOf(num)<10) { + zero="-0"; + }else { + zero="-"; + } + num=String.valueOf(Integer.valueOf(num)+1); + System.out.println(moldId); + + + TCComponentItemType tccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_mdPart"); + if(Integer.valueOf(num)<10) { + String itemId = moldId+"-0"+num; + TCComponentItem newMoldSon = tccomponentitemtype.create(itemId,"A","WF2_mdPart",itemName_TextField.getText().trim(),"",null); + //selectedItemReminder=A3X4_Z + //ѡеģͼֽģ帴Ƶ汾 + + //õҪģuid + String uuid=jComboBox.getSelectedItem().toString(); + TCComponentDataset dataset2=(TCComponentDataset)session.stringToComponent(map.get(uuid)); + TCComponentDataset dataset=dataset2.saveAs(itemName_TextField.getText().trim()); + newMoldSon.getLatestItemRevision().add("IMAN_specification", dataset); + + + //4.ʼļ´ӦȫߴͼĹϵ + TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); + newStuffFolder.add("contents", newMoldSon); + closeDialog(); + MessageBox.post("ɹ,newStuffļ²鿴", "ʾϢ",MessageBox.INFORMATION); + + }else { + String itemId = moldId+"-"+num; + TCComponentItem newMoldSon = tccomponentitemtype.create(itemId,"A","WF2_mdPart",itemName_TextField.getText().trim(),"",null); + + + //ѡеģͼֽģ帴Ƶ汾 + String uuid=jComboBox.getSelectedItem().toString(); + TCComponentDataset dataset2=(TCComponentDataset)session.stringToComponent(map.get(uuid)); + TCComponentDataset dataset=dataset2.saveAs(itemName_TextField.getText().trim()); + newMoldSon.getLatestItemRevision().add("IMAN_specification", dataset); + + + + + //4.ʼļ´ӦģĹϵ + TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder(); + newStuffFolder.add("contents", newMoldSon); + closeDialog(); + MessageBox.post("ɹ,newStuffļ²鿴", "ʾϢ",MessageBox.INFORMATION); + + } + + + + } + + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + }); + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }} + private void closeDialog() { + disposeDialog(); + setVisible(false); +} + +} diff --git a/src/com/connor/wf/plm/wf011/Wf011Handler.java b/src/com/connor/wf/plm/wf011/Wf011Handler.java new file mode 100644 index 0000000..380003b --- /dev/null +++ b/src/com/connor/wf/plm/wf011/Wf011Handler.java @@ -0,0 +1,30 @@ +package com.connor.wf.plm.wf011; + +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; +/** + * :Wf010Handler + * :ģͼ + * :2019-02-28 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class Wf011Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + CreateSubPartDrawDialog createSubPartDrawDialog = new CreateSubPartDrawDialog(app); + + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf012/Wf012Dialog.java b/src/com/connor/wf/plm/wf012/Wf012Dialog.java new file mode 100644 index 0000000..9e03dc3 --- /dev/null +++ b/src/com/connor/wf/plm/wf012/Wf012Dialog.java @@ -0,0 +1,568 @@ +package com.connor.wf.plm.wf012; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.math.BigDecimal; +import java.util.ArrayList; +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.JTextField; + +import org.eclipse.swt.internal.Library; + +import com.connor.wf.plm.util.ClassAttributeBean; +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.ParseXML; +import com.connor.wf.plm.util.PartBean; +import com.connor.wf.plm.util.PropBean; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf012Dialog extends AbstractAIFDialog{ + private TCComponentItemRevision target; + private AbstractAIFUIApplication app; + private TCSession session; + private TCPreferenceService service; + private Map map; + private JComboBox comb; + private List> values; + private Map map3; + private Map map2; + private JLabel[] labels1; + private JLabel[] labels; + private List propList; + private TCComponentItem item; + private String url = ""; + private String icoPUID; + private String className; + private List classList; + private JScrollPane scr1; + private JScrollPane scr2; + public Wf012Dialog(AbstractAIFUIApplication app, InterfaceAIFComponent target) { + this.app = app; + this.target = (TCComponentItemRevision) target; + this.session = (TCSession) app.getSession(); + this.service = session.getPreferenceService(); + this.map = new HashMap(); + this.map3 = new HashMap(); + this.comb = null; + this.values = new ArrayList>(); + this.labels = null; + this.labels1 = null; + this.propList = null; + this.item = null; + this.url = service.getStringValue("Autocode_SendClassServer_URL"); + this.icoPUID = ""; + this.className = ""; + this.classList = null; + } + public void run(){ + initUI(); + } + /** + * ҳ + */ + private void initUI() { + + this.setTitle("޸"); + this.setPreferredSize(new Dimension(630, 400)); + JPanel master2 = new JPanel(new PropertyLayout());// Խ + // JPanel class1=new JPanel(new PropertyLayout());//Խ + JPanel class2 = new JPanel(new PropertyLayout());// Խ + + scr1 = new JScrollPane(master2); + scr2 = new JScrollPane(class2); + scr1.setPreferredSize(new Dimension(293, 300)); + + scr2.setPreferredSize(new Dimension(293, 300)); + JPanel masterJpanel = new JPanel(new PropertyLayout());// Խ + JPanel classJpanel = new JPanel(new PropertyLayout());// Խ + JPanel attJpanel = new JPanel(new PropertyLayout());// Խ + JPanel jbutJpanel = new JPanel(new PropertyLayout());// ť + + JLabel jb1 = new JLabel(""); + JLabel jb2 = new JLabel(""); + + + + + String uid = service.getStringValue("WF2_PraseXML_Path"); + if (uid == null || uid.equals("")) { + + MessageBox.post("ѡWF2_PraseXML_Pathδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + TCComponentDataset dataset = null; + File[] files = null; + + classList = new ArrayList(); + PropBean prop = new PropBean(); + + List partList = new ArrayList(); + ParseXML parse = new ParseXML(); + try { + item = target.getItem(); + TCComponent comp = session.stringToComponent(uid); + if(comp instanceof TCComponentDataset){ + dataset = (TCComponentDataset) comp; + files = dataset.getFiles(""); + } + } catch (TCException e) { + e.printStackTrace(); + } + String path = files[0].getAbsolutePath(); + File file = new File(path); + partList = parse.parseXML(file); + for (PartBean partBean : partList) { + if(partBean.getType().equals(item.getType())){ + propList = partBean.getPropList(); + break; + } + } + if(propList == null || propList.size()<=0){ + MessageBox.post("δø϶ļ","ʾ",MessageBox.INFORMATION); + return; + } + labels = new JLabel[propList.size()]; + for(int i = 0;i (); + comb.setEditable(true); + comb.setSize(new Dimension(60,40)); + try { + if("I".equals(type)){ + TCProperty property = item.getTCProperty(prop.getRealName()); + String value = property.getStringValue(); + getValues(property,value); + }else if("IM".equals(type)){ + TCComponentForm form = (TCComponentForm) item.getReferenceListProperty("IMAN_master_form_rev")[0]; + TCProperty property = form.getTCProperty(prop.getRealName()); + String value = property.getStringValue(); + getValues(property,value); + }else if("R".equals(type)){ + TCProperty property = target.getTCProperty(prop.getRealName()); + String value = property.getStringValue(); + getValues(property,value); + }else{ + TCComponentForm form = (TCComponentForm) target.getReferenceListProperty("IMAN_master_form_rev")[0]; + TCProperty property = form.getTCProperty(prop.getRealName()); + String value = property.getStringValue(); + getValues(property,value); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + master2.add((i+1)+".2.center.top", comb); + }else{ + JTextField field = new JTextField(12); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + master2.add((i+1)+".2.center.top", field); + try { + if("I".equals(type)){ + field.setText(item.getStringProperty(prop.getRealName())); + }else if("IM".equals(type)){ + TCComponentForm form = (TCComponentForm) item.getReferenceListProperty("IMAN_master_form_rev")[0]; + field.setText(form.getStringProperty(prop.getRealName())); + }else if("R".equals(type)){ + field.setText(target.getStringProperty(prop.getRealName())); + }else{ + TCComponentForm form = (TCComponentForm) target.getReferenceListProperty("IMAN_master_form_rev")[0]; + field.setText(form.getStringProperty(prop.getRealName())); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + try { + className = target.getClassificationClass(); + TCComponentICO[] icos = target.getClassificationObjects(); + if(icos == null || icos.length <= 0){ + MessageBox.post("ûз͵࣬뷢ͣ","ʾ",MessageBox.INFORMATION); + return; + } + icoPUID = icos[0].getUid(); + Map claMap = new HashMap(); + if(icos != null && icos.length>0){ + ICSProperty[] icss = icos[0].getICSProperties(true); + for (ICSProperty ics : icss) { + claMap.put(ics.getId(), ics.getValue()); + } + } + TCClassificationService classificationService = session.getClassificationService(); + ICSAdminClass c = classificationService.newICSAdminClass(); + c.load(className); + ICSAdminClassAttribute[] icsAttrS = c.getAttributes(); + if (icsAttrS != null) { + for (ICSAdminClassAttribute attr : icsAttrS) { + ClassAttributeBean bean = new ClassAttributeBean(); + if (attr.isReferenceAttribute()) {// + continue; + } + if (attr.isReference()) { + continue; + } + int propID = attr.getAttributeId(); + bean.setId(propID); + String propDisName = attr.getName(); + bean.setName(propDisName); + + int attrType = attr.getFormat1().getType(); + bean.setType(attrType); + + if (claMap != null + && claMap.containsKey(propID)) { + bean.setVal(claMap.get(propID)); + } else { + bean.setVal(""); + } + + ICSKeyLov lov1 = attr.getFormat1().getKeyLov(); + lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1); + if (lov1 != null) { + bean.setIslov(true); + String[] keys = lov1.getKeys(); + Map map1 = new HashMap(); + for (String key : keys) { + String value = lov1.getValueOfKey(key); + map1.put(value, key);// <ʾֵ,ʵֵ> + if(key.equals(bean.getVal())&&(!bean.getVal().equals(""))){ + bean.setVal(value); + } + } + bean.setLov(map1); + } else { + bean.setIslov(false); + } + + classList.add(bean); + + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + labels1 = new JLabel[classList.size()]; + for (int i = 0; i(); + comb.setEditable(true); + comb.setSize(new Dimension(60,40)); + comb.addItem(""); + for (Entry entry : bean.getLov().entrySet()) { + comb.addItem(entry.getKey()); + } + map2 = new HashMap(); + map2.put("JComboBox", comb); + values.add(map2); + class2.add((i+1)+".2.center.top", comb); + if(bean.getVal() != null && bean.getVal()!=""){ + comb.setSelectedItem(bean.getVal()); + } + + }else{ + JTextField field = new JTextField(12); + map2 = new HashMap(); + map2.put("JTextField", field); + values.add(map2); + class2.add((i+1)+".2.center.top", field); + if(bean.getVal() != null && bean.getVal()!=""){ + field.setText(bean.getVal()); + } + } + } + + String type = target.getType(); + JButton jisuanBtn = null; + if("WF2_finPartRevision".equals(type)){ + jisuanBtn = new JButton("ر"); + + jisuanBtn.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e) { + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type1 = entry.getKey(); + if(type1.equals("JComboBox")){ + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + }else{ + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + String zaihe = ""; + String lilunwight = ""; + int j = 0; + for(int i=0;i map4 = values.get(j); + if(map4.containsKey("JTextField")){ + JTextField field = (JTextField) (map4.get("JTextField")); + field.setText(finString); + } + + }else{ + setAlwaysOnTop(false); + MessageBox.post("غֵֵδд", "ʾ", MessageBox.INFORMATION); + setAlwaysOnTop(true); + return; + } + } + }); + } + JButton okBtn = new JButton("ȷ"); + okBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + List vals = new ArrayList(); + for (Map value : values) { + for (Map.Entry entry : value.entrySet()) { + String type = entry.getKey(); + if(type.equals("JComboBox")){ + JComboBox comb1 = (JComboBox) entry.getValue(); + String val = (String) comb1.getSelectedItem(); + vals.add(val); + }else{ + JTextField field1 = (JTextField) entry.getValue(); + String val = field1.getText(); + vals.add(val); + } + } + } + int i = 0; + for(;i(); + map2.put("JComboBox", comb); + values.add(map2); + } catch (TCException e) { + e.printStackTrace(); + } + } + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/wf/plm/wf012/Wf012Handler.java b/src/com/connor/wf/plm/wf012/Wf012Handler.java new file mode 100644 index 0000000..09e1c03 --- /dev/null +++ b/src/com/connor/wf/plm/wf012/Wf012Handler.java @@ -0,0 +1,71 @@ +package com.connor.wf.plm.wf012; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf012Handler + * : Ա༭ + * :2019-02-27 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf012Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + private String[] types; + private Boolean flag; + public Object execute(ExecutionEvent arg0) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + target = app.getTargetComponent(); + flag = false; + types = new String[]{"WF2_finPartRevision","WF2_semiFinPartRevision","WF2_rawMaterialRevision", + "WF2_procResourceRevision","WF2_moldRevision","WF2_mdPartRevision","WF2_subpartRevision","WF2_pkgMaterialRevision", + "WF2_2DprodDrawRevision","WF2_pkgDrawRevision","WF2_subPartDrawRevision","WF2_processDrawRevision"}; + + String targetType = null; + TCComponentItemRevision rev = null; + if(target instanceof TCComponentItemRevision){ + rev = (TCComponentItemRevision) target; + try { + TCComponent[] status = rev.getReferenceListProperty("release_status_list"); + if(status == null || status.length > 0){ + MessageBox.post("Ҫ޸ĵѷ棡", "ʾ", MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + e.printStackTrace(); + } + targetType = rev.getType(); + }else{ + MessageBox.post("ѡ汾", "ʾ", MessageBox.INFORMATION); + return null; + } + + for (String type : types) { + if(type.equals(targetType)){ + flag = true; + break; + } + + } + if(flag){ + Wf012Dialog dialog = new Wf012Dialog(app,target); + new Thread(dialog).start(); + }else{ + MessageBox.post("ѡIJϻͼֽİ汾ѡ", "ʾ", MessageBox.INFORMATION); + } + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf013/Wf013AIFDialog.java b/src/com/connor/wf/plm/wf013/Wf013AIFDialog.java new file mode 100644 index 0000000..9641933 --- /dev/null +++ b/src/com/connor/wf/plm/wf013/Wf013AIFDialog.java @@ -0,0 +1,455 @@ +package com.connor.wf.plm.wf013; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.wf.plm.util.CodeBean; +import com.connor.wf.plm.util.CopyPropsBean; +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.GetCodeBean; +import com.connor.wf.plm.util.MenuBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +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.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf013AIFDialog extends AbstractAIFDialog { + private TCSession session; + private InterfaceAIFComponent targetComp; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JTextField jtext1; + private JTextField jtext2; + private JTextField jtext3; + //private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut=new JButton(""); + private JButton celBut=new JButton("ȡ"); + private GetCodeBean getcode; + private String selnodename=""; + private JComboBox jcomname=new JComboBox(); + private Map nameMap=new HashMap<>(); + private boolean islov=false; + + public Wf013AIFDialog(TCSession session, InterfaceAIFComponent targetComp,String name) { + this.session = session; + this.targetComp = targetComp; + this.name = name; + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode=new GetCodeBean(session); + menuBean=getcode.getMenuBean(name); + //codeBeanList = bean.getCodeBeanList(); + init(); + + } + + + /** + * жǷlov + */ + private void getNameLov(String type) { + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + TCPropertyDescriptor propertyDescriptor = tctype.getPropertyDescriptor("object_name"); + TCComponentListOfValues lov = propertyDescriptor.getLOV(); + if (lov!=null) { + islov=true; + String[] strs=lov.getListOfValues().getStringListOfValues();//ʵֵ + for(String s1:strs){ + String a1 = lov.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + jcomname.addItem(a1); + nameMap.put(a1, s1);//ʾ:ʵ + } + }else{ + islov=false; + } + if (islov) { + jp2.add("6.2.left.center", jcomname); + }else{ + jp2.add("6.2.left.center", jtext3); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + /** + * ҳ + */ + private void init() { + // TODO Auto-generated method stub + this.setTitle("" + name); + this.setPreferredSize(new Dimension(500, 340)); + this.setLayout(new PropertyLayout()); + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(250, 250)); + jp2.setPreferredSize(new Dimension(250, 250)); + JTree tree = getTree(menuBean); + tree.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e + .getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + + childCount); + selnodename = ""; + if (childCount > 0) { + jp2.setVisible(false); + } else { + jp2.setVisible(true); + setTextStr(treeNode); + } + + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + + JLabel jl1 = new JLabel("룺"); + JLabel jl2 = new JLabel("汾"); + JLabel jl3 = new JLabel("ƣ"); + jtext1 = new JTextField(12); + jtext2 = new JTextField(12); + jtext3 = new JTextField(12); + jtext1.setEnabled(false); + jtext2.setEnabled(false); + jcomname.setEnabled(false); + jp2.add("1.1.left.center", new JLabel("")); + jp2.add("2.1.center.center", jl1); + jp2.add("2.2.left.center", jtext1); + jp2.add("3.1.left.center", new JLabel("")); + jp2.add("4.1.center.center", jl2); + jp2.add("4.2.left.center", jtext2); + jp2.add("5.1.left.center", new JLabel("")); + jp2.add("6.1.center.center", jl3); + jp2.setVisible(false); + + add("1.1.center.center", jp1); + add("1.2.center.center", jp2); + add("2.1.center.center", okBut); + add("2.2.center.center", celBut); + okBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȷ"); + if (jp2.isVisible()) { + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + if (!nameMap.containsKey(itemName)) { + MessageBox.post("ƴ,Χѡ!", "ʾ", MessageBox.INFORMATION); + } + }else{ + itemName=jtext3.getText(); + } + if (!itemName.equals("")) { + createItem(); + + } else { + MessageBox + .post("ƲΪ!", "ʾ", MessageBox.INFORMATION); + } + } else { + MessageBox.post("ѡ񴴽!", "ʾ", MessageBox.INFORMATION); + } + + } + }); + celBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + + /** + * ¼ + */ + protected void createItem() { + + // TODO Auto-generated method stub + try { + String type = selCodeBean.getType(); + DataBaseControl data = new DataBaseControl(session); + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + try { + String newID = data.getNewCode("PLMCODE", selCodeBean); + TCComponentItem find = tctype.find(newID); + if (find != null) { + MessageBox.post("ǰˮID:" + newID + "Ѵڶ,޷!", "", + MessageBox.ERROR); + } else { + this.setVisible(false); + if (selnodename.equals("")) { + if (targetComp == null|| !(targetComp instanceof TCComponentItemRevision)) { + MessageBox.post("ĶΪ,ֻѡгƷ汾,ִд˲!!!", "",0); + return; + }else { + if (!targetComp.getType().equals("WF2_finPartRevision")) { + MessageBox.post("ĶΪ,ֻѡгƷ汾,ִд˲!!!", "",0); + return; + } + } + } + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + itemName=nameMap.get(itemName); + }else{ + itemName=jtext3.getText(); + } + TCComponentItem item = tctype.create(newID,jtext2.getText(), type, itemName, "", null); + boolean isNewStuff = true; + CopyPropsBean copyPropBean = selCodeBean.getCopyPropBean(); + if (copyPropBean!=null) { + String type2 = copyPropBean.getType(); + List props = copyPropBean.getProps(); + if (targetComp!=null&&targetComp.getType().equals(type2)) { + boolean isok=true; + TCComponentItemRevision furev=null; + if (targetComp instanceof TCComponentItemRevision) { + furev=(TCComponentItemRevision) targetComp; + }else if (targetComp instanceof TCComponentItem) { + furev=((TCComponentItem)targetComp).getLatestItemRevision(); + }else{ + isok=false; + System.out.println("ְֻ֧汾Ͷ"); + } + if (props!=null&&props.size()>0&&isok) { + for (int i = 0; i < props.size(); i++) { + String[] split = props.get(i).split("="); + if (split != null && split.length == 2) { + String propstr = ""; + if (split[0].startsWith("ITEM.")) { + TCComponentItem com = furev.getItem(); + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } else if (split[0].startsWith("REV.")) { + TCComponentItemRevision com = furev; + propstr = com.getTCProperty(split[0].substring(4)).getStringValue(); + } else if (split[0].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) furev.getReferenceListProperty("IMAN_master_form_rev")[0]; + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } + if (propstr != null&& !propstr.equals("")) { + if (split[1].startsWith("ITEM.")) { + TCComponentItem com = item; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } else if (split[1].startsWith("REV.")) { + TCComponentItemRevision com = item.getLatestItemRevision(); + com.getTCProperty(split[1].substring(4)).setStringValue(propstr); + } else if (split[1].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) item.getLatestItemRevision() + .getReferenceListProperty("IMAN_master_form_rev")[0]; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } + } + + } + } + } + } + } + if (selnodename.equals("")) { + String stringValue = session.getPreferenceService().getStringValue("WF2_semiFinPart_bczj_Dataset"); + if (stringValue!=null) { + TCComponentDataset dataset= (TCComponentDataset) session.stringToComponent(stringValue); + TCComponentItemRevision laterev = item.getLatestItemRevision(); + String idstr = item.getProperty("item_id"); + String revidstr=laterev.getProperty("item_revision_id"); + TCComponentDataset newData = dataset.saveAs(idstr+"/"+revidstr); + laterev.add("IMAN_specification", newData); + } + } + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + Wf013Operation op=new Wf013Operation(session, classid, item.getLatestItemRevision(), new Integer[] {}, new String[] {}); + session.queueOperation(op); + } else { + System.out.println("δҵ͵ķid,"); + } + if (isNewStuff) { + MessageBox.post("" + item + "ɹ,NewStuffļ²鿴!", + "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post("" + item + "ɹ,ڵǰļ²鿴!", "ɹ", + MessageBox.INFORMATION); + } + + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + /** + * ѡеײ¼ + * + */ + protected void setTextStr(DefaultMutableTreeNode treeNode) { + // TODO Auto-generated method stub + selnodename = treeNode.toString(); + if (islov) { + if (nameMap.containsKey(selnodename)) { + jcomname.setSelectedItem(selnodename); + } + }else{ + jtext3.setText(selnodename); + } + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean != null) { + String type = selCodeBean.getType(); + String code = selCodeBean.getCode(); + code = code + " [L]"; + getNameLov(type); + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + jtext1.setText(code); + jtext2.setText(tctype.getNewRev(null)); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode + * ڵ + * @param names + * ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + */ + private JTree getTree(MenuBean menuBean1) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( + treenodename); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, + DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + +} diff --git a/src/com/connor/wf/plm/wf013/Wf013Action.java b/src/com/connor/wf/plm/wf013/Wf013Action.java new file mode 100644 index 0000000..4518889 --- /dev/null +++ b/src/com/connor/wf/plm/wf013/Wf013Action.java @@ -0,0 +1,41 @@ +package com.connor.wf.plm.wf013; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf013Action extends AbstractAIFAction { + private AbstractAIFApplication app; + private InterfaceAIFComponent tar; + private TCSession session; + private String name; + + public Wf013Action(AbstractAIFApplication arg0, String arg1, String name) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.tar = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.name = name; + } + + @Override + public void run() { + // TODO Auto-generated method stub + // if (tar == null || !(tar instanceof TCComponentItemRevision)) { + // MessageBox.post("ѡгƷ汾,ִв!!!", "", 0); + // return; + // } + // + // if (tar.getType().equals("WF2_finPartRevision")) { + // MessageBox.post("ѡгƷ汾,ִв!!!", "", 0); + // return; + // }else{ + Wf013AIFDialog dia = new Wf013AIFDialog(session, tar, name); + new Thread(dia).start(); + // } + + } + +} diff --git a/src/com/connor/wf/plm/wf013/Wf013Handler.java b/src/com/connor/wf/plm/wf013/Wf013Handler.java new file mode 100644 index 0000000..3848325 --- /dev/null +++ b/src/com/connor/wf/plm/wf013/Wf013Handler.java @@ -0,0 +1,38 @@ +package com.connor.wf.plm.wf013; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * :Wf013Handler + * :Ʒ + * :2019-02-26 + * Ա zl + * + */ +public class Wf013Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + try { + String name = arg0.getCommand().getName(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + //TCSession session = (TCSession) app.getSession(); + //InterfaceAIFComponent com = app.getTargetComponent(); + Wf013Action dia = new Wf013Action(app, null,name); + new Thread(dia).start(); + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf013/Wf013Operation.java b/src/com/connor/wf/plm/wf013/Wf013Operation.java new file mode 100644 index 0000000..8e0a5c2 --- /dev/null +++ b/src/com/connor/wf/plm/wf013/Wf013Operation.java @@ -0,0 +1,79 @@ +package com.connor.wf.plm.wf013; + +import java.util.ArrayList; +import java.util.List; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf013Operation extends AbstractAIFOperation { + + private TCSession session; + private String classid; + private TCComponentItemRevision rev; + private Integer[] keys; + private String[] vels; + + public Wf013Operation(TCSession session, String classid, + TCComponentItemRevision rev, Integer[] keys, String[] vels) { + // TODO Auto-generated constructor stub + this.session = session; + this.classid = classid; + this.rev = rev; + this.keys = keys; + this.vels = vels; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + sendObjToClassficationByWebService(classid, rev, keys, vels); + + } + + /** + * ͷ + * + * @param class_id + * id + * @param rev + * 汾 + * @param keys + * id + * @param vals + * ֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/wf/plm/wf015/Wf015AIFDialog.java b/src/com/connor/wf/plm/wf015/Wf015AIFDialog.java new file mode 100644 index 0000000..af596e5 --- /dev/null +++ b/src/com/connor/wf/plm/wf015/Wf015AIFDialog.java @@ -0,0 +1,512 @@ +package com.connor.wf.plm.wf015; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.wf.plm.util.CodeBean; +import com.connor.wf.plm.util.CopyPropsBean; +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.GetCodeBean; +import com.connor.wf.plm.util.MenuBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +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.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf015AIFDialog extends AbstractAIFDialog { + private TCSession session; + private InterfaceAIFComponent targetComp; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JTextField jtext1; + private JTextField jtext2; + private JTextField jtext3; + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private String selnodename = ""; + private JComboBox jcom; + private Map map = new HashMap(); + private JComboBox jcomname=new JComboBox(); + private Map nameMap=new HashMap<>(); + private boolean islov=false; + private String datasetUid=""; + + public Wf015AIFDialog(TCSession session, InterfaceAIFComponent targetComp, + String name) { + this.session = session; + this.targetComp = targetComp; + this.name = name; + if (name.equals("Դ")) { + datasetUid="WF2_ProcResource_Dataset"; + }else if(name.equals("ͼ")){ + datasetUid="WF2_subPartDraw_Dataset"; + }else if(name.equals("ͼ")){ + datasetUid="WF_file_path"; + } + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + load(); + // codeBeanList = bean.getCodeBeanList(); + init(); + + } + + /** + * жǷlov + */ + private void getNameLov(String type) { + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + TCPropertyDescriptor propertyDescriptor = tctype.getPropertyDescriptor("object_name"); + TCComponentListOfValues lov = propertyDescriptor.getLOV(); + if (lov!=null) { + islov=true; + String[] strs=lov.getListOfValues().getStringListOfValues();//ʵֵ + for(String s1:strs){ + String a1 = lov.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + jcomname.addItem(a1); + nameMap.put(a1, s1);//ʾ:ʵ + } + }else{ + islov=false; + } + if (islov) { + jp2.add("6.2.left.center", jcomname); + }else{ + jp2.add("6.2.left.center", jtext3); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ģ + */ + private void load() { + // TODO Auto-generated method stub + String[] stringArray = session.getPreferenceService().getStringValues( + datasetUid); + if (stringArray != null && stringArray.length > 0) { + for (int i = 0; i < stringArray.length; i++) { + String[] split = stringArray[i].split("="); + if (split != null && split.length == 2) { + map.put(split[1], split[0]); + } + } + } + } + + /** + * ҳ + */ + private void init() { + // TODO Auto-generated method stub + this.setTitle("" + name); + this.setPreferredSize(new Dimension(600, 400)); + this.setLayout(new PropertyLayout()); + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(250, 270)); + jp2.setPreferredSize(new Dimension(350, 270)); + JTree tree = getTree(menuBean); + tree.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e + .getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + + childCount); + selnodename = ""; + if (childCount > 0) { + jp2.setVisible(false); + } else { + jp2.setVisible(true); + setTextStr(treeNode); + } + + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + ; + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + + JLabel jl1 = new JLabel("룺"); + JLabel jl2 = new JLabel("汾"); + JLabel jl3 = new JLabel("ƣ"); + jtext1 = new JTextField(12); + jtext2 = new JTextField(12); + jtext3 = new JTextField(12); + jtext1.setEnabled(false); + jtext2.setEnabled(false); + jcomname.setEnabled(false); + + JLabel jl4 = new JLabel("ͼֽģ壺"); + jcom = new JComboBox(); + for (String key : map.keySet()) { + jcom.addItem(key); + } + + jp2.add("1.1.left.center", new JLabel("")); + jp2.add("2.1.center.center", jl1); + jp2.add("2.2.left.center", jtext1); + jp2.add("3.1.left.center", new JLabel("")); + jp2.add("4.1.center.center", jl2); + jp2.add("4.2.left.center", jtext2); + jp2.add("5.1.left.center", new JLabel("")); + jp2.add("6.1.center.center", jl3); + jp2.add("7.1.left.center", new JLabel("")); + jp2.add("8.1.center.center", jl4); + jp2.add("8.2.left.center", jcom); + if("ͼ".equals(name)){ + JLabel jl5 = new JLabel("(ĸǵ)"); + JLabel jl6 = new JLabel("(װζݶ)"); + JLabel jl7 = new JLabel("(װλ̥侶Ȧ)"); + JLabel jl8 = new JLabel("(סס׵)"); + JLabel jl9 = new JLabel("(֡רlogo)"); + jp2.add("9.1.center.center", new JLabel("")); + jp2.add("10.1.center.center", new JLabel("")); + jp2.add("11.1.center.center", new JLabel("")); + jp2.add("12.1.center.center", new JLabel("")); + jp2.add("13.1.center.center", new JLabel("")); + jp2.add("14.1.center.center", new JLabel("")); + jp2.add("10.2.left.center", jl5); + jp2.add("11.2.left.center", jl6); + jp2.add("12.2.left.center", jl7); + jp2.add("13.2.left.center", jl8); + jp2.add("14.2.left.center", jl9); + } + if("ͼ".equals(name)){ + JLabel jl5 = new JLabel("ѡģʱѡӦģ"); + jp2.add("9.1.center.center", new JLabel("")); + jp2.add("10.1.center.center", new JLabel("")); + jp2.add("11.1.center.center", new JLabel("")); + jp2.add("12.1.center.center", new JLabel("")); + jp2.add("13.1.center.center", new JLabel("")); + jp2.add("14.1.center.center", new JLabel("")); + jp2.add("10.2.left.center", jl5); + } + jp2.setVisible(false); + + add("1.1.center.center", jp1); + add("1.2.center.center", jp2); + add("2.1.center.center", okBut); + add("2.2.center.center", celBut); + okBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȷ"); + if (jp2.isVisible()) { + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + if (!nameMap.containsKey(itemName)) { + MessageBox.post("ƴ,Χѡ!", "ʾ", MessageBox.INFORMATION); + } + }else{ + itemName=jtext3.getText(); + } + if (!itemName.equals("")) { + createItem(); + } else { + MessageBox.post("ƲΪ!", "ʾ", MessageBox.INFORMATION); + } + } else { + MessageBox.post("ѡ񴴽!", "ʾ", MessageBox.INFORMATION); + } + + } + }); + celBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + + /** + * ¼ + */ + protected void createItem() { + // TODO Auto-generated method stub + try { + String type = selCodeBean.getType(); + DataBaseControl data = new DataBaseControl(session); + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + + try { + String newID = data.getNewCode("PLMCODE", selCodeBean); + TCComponentItem find = tctype.find(newID); + if (find != null) { + MessageBox.post("ǰˮID:" + newID + "Ѵڶ,޷!", "", + MessageBox.ERROR); + } else { + this.setVisible(false); + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + itemName=nameMap.get(itemName); + }else{ + itemName=jtext3.getText(); + } + TCComponentItem item = tctype.create(newID, + jtext2.getText(), type, itemName, "", null); + String boxstr=jcom.getSelectedItem().toString(); + if (!boxstr.equals("")&&map.containsKey(boxstr)) { + String uid=map.get(boxstr); + TCComponentItemRevision rev = item.getLatestItemRevision(); + String idstr = rev.getTCProperty("item_id").getStringValue(); + String revidstr = rev.getTCProperty("item_revision_id").getStringValue(); + TCComponentDataset dataset= (TCComponentDataset) session.stringToComponent(uid); + TCComponentDataset newData = dataset.saveAs(idstr+"/"+revidstr); + rev.add("IMAN_specification", newData); + } + + System.out.println("ʼͬѡԵ"); + CopyPropsBean copyPropBean = selCodeBean.getCopyPropBean(); + if (copyPropBean!=null) { + String type2 = copyPropBean.getType(); + List props = copyPropBean.getProps(); + if (targetComp!=null&&targetComp.getType().equals(type2)) { + boolean isok=true; + TCComponentItemRevision furev=null; + if (targetComp instanceof TCComponentItemRevision) { + furev=(TCComponentItemRevision) targetComp; + }else if (targetComp instanceof TCComponentItem) { + furev=((TCComponentItem)targetComp).getLatestItemRevision(); + }else{ + isok=false; + System.out.println("ְֻ֧汾Ͷ"); + } + if (props!=null&&props.size()>0&&isok) { + for (int i = 0; i < props.size(); i++) { + String[] split = props.get(i).split("="); + if (split != null && split.length == 2) { + String propstr = ""; + if (split[0].startsWith("ITEM.")) { + TCComponentItem com = furev.getItem(); + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } else if (split[0].startsWith("REV.")) { + TCComponentItemRevision com = furev; + propstr = com.getTCProperty(split[0].substring(4)).getStringValue(); + } else if (split[0].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) furev.getReferenceListProperty("IMAN_master_form_rev")[0]; + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } + if (propstr != null&& !propstr.equals("")) { + if (split[1].startsWith("ITEM.")) { + TCComponentItem com = item; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } else if (split[1].startsWith("REV.")) { + TCComponentItemRevision com = item.getLatestItemRevision(); + com.getTCProperty(split[1].substring(4)).setStringValue(propstr); + } else if (split[1].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) item.getLatestItemRevision() + .getReferenceListProperty("IMAN_master_form_rev")[0]; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } + } + + } + } + } + } + }else{ + System.out.println("δͬ,ͬ"); + } + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + Wf015Operation op=new Wf015Operation(session, classid, item.getLatestItemRevision(), new Integer[] {}, new String[] {}); + session.queueOperation(op); + } else { + System.out.println("δҵ͵ķid,"); + } + if (isNewStuff) { + MessageBox.post("" + item + "ɹ,NewStuffļ²鿴!", + "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post("" + item + "ɹ,ڵǰļ²鿴!", "ɹ", + MessageBox.INFORMATION); + } + + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + /** + * ѡеײ¼ + * + */ + protected void setTextStr(DefaultMutableTreeNode treeNode) { + // TODO Auto-generated method stub + selnodename = treeNode.toString(); + if (islov) { + if (nameMap.containsKey(selnodename)) { + jcomname.setSelectedItem(selnodename); + } + }else{ + jtext3.setText(selnodename); + } + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean != null) { + String type = selCodeBean.getType(); + String code = selCodeBean.getCode(); + code = code + " [L]"; + getNameLov(type); + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + jtext1.setText(code); + jtext2.setText(tctype.getNewRev(null)); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode + * ڵ + * @param names + * ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + */ + private JTree getTree(MenuBean menuBean1) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( + treenodename); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, + DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + +} diff --git a/src/com/connor/wf/plm/wf015/Wf015Action.java b/src/com/connor/wf/plm/wf015/Wf015Action.java new file mode 100644 index 0000000..60518e4 --- /dev/null +++ b/src/com/connor/wf/plm/wf015/Wf015Action.java @@ -0,0 +1,34 @@ +package com.connor.wf.plm.wf015; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf015Action extends AbstractAIFAction { + private AbstractAIFApplication app; + private InterfaceAIFComponent tar; + private TCSession session; + private String name; + + + public Wf015Action(AbstractAIFApplication arg0, String arg1,String name) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.tar = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.name=name; + } + + @Override + public void run() { + // TODO Auto-generated method stub + Wf015AIFDialog dia = new Wf015AIFDialog(session, tar,name); + new Thread(dia).start(); + + + + } + +} diff --git a/src/com/connor/wf/plm/wf015/Wf015Handler.java b/src/com/connor/wf/plm/wf015/Wf015Handler.java new file mode 100644 index 0000000..5f6c84b --- /dev/null +++ b/src/com/connor/wf/plm/wf015/Wf015Handler.java @@ -0,0 +1,38 @@ +package com.connor.wf.plm.wf015; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * :Wf015Handler + * :Դ + * :2019-03-05 + * Ա zl + * + */ +public class Wf015Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + try { + String name = arg0.getCommand().getName(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + //TCSession session = (TCSession) app.getSession(); + //InterfaceAIFComponent com = app.getTargetComponent(); + Wf015Action dia = new Wf015Action(app, null,name); + new Thread(dia).start(); + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf015/Wf015Operation.java b/src/com/connor/wf/plm/wf015/Wf015Operation.java new file mode 100644 index 0000000..a518f95 --- /dev/null +++ b/src/com/connor/wf/plm/wf015/Wf015Operation.java @@ -0,0 +1,77 @@ +package com.connor.wf.plm.wf015; + +import java.util.ArrayList; +import java.util.List; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf015Operation extends AbstractAIFOperation { + + private TCSession session; + private String classid; + private TCComponentItemRevision rev; + private Integer[] keys; + private String[] vels; + + public Wf015Operation(TCSession session, String classid, + TCComponentItemRevision rev, Integer[] keys, String[] vels) { + // TODO Auto-generated constructor stub + this.session = session; + this.classid = classid; + this.rev = rev; + this.keys = keys; + this.vels = vels; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + sendObjToClassficationByWebService(classid, rev, keys, vels); + + } + + /** + * ͷ + * + * @param class_id + * id + * @param rev + * 汾 + * @param keys + * id + * @param vals + * ֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/wf/plm/wf016/Wf016AIFDialog.java b/src/com/connor/wf/plm/wf016/Wf016AIFDialog.java new file mode 100644 index 0000000..a2795a0 --- /dev/null +++ b/src/com/connor/wf/plm/wf016/Wf016AIFDialog.java @@ -0,0 +1,527 @@ +package com.connor.wf.plm.wf016; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.CodeBean; +import com.connor.wf.plm.util.CopyPropsBean; +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.GetCodeBean; +import com.connor.wf.plm.util.MenuBean; +import com.connor.wf.plm.util.MenuCodeBean; +import com.connor.wf.plm.util.ParseXML; +import com.connor.wf.plm.util.SoaServerUtil; +import com.connor.wf.plm.wf017.Wf017Operation; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf016AIFDialog extends AbstractAIFDialog { + private TCSession session; + private InterfaceAIFComponent targetComp; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JTextField jtext1; + private JTextField jtext2; + private JTextField jtext3; + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private String selnodename = ""; + private JComboBox jcomname=new JComboBox(); + private Map nameMap=new HashMap<>(); + private boolean islov=false; + + public Wf016AIFDialog(TCSession session, InterfaceAIFComponent targetComp, + String name) { + this.session = session; + this.targetComp = targetComp; + this.name = name; + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + // codeBeanList = bean.getCodeBeanList(); + init(); + + } + + /** + * жǷlov + */ + private void getNameLov(String type) { + + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + TCPropertyDescriptor propertyDescriptor = tctype.getPropertyDescriptor("object_name"); + TCComponentListOfValues lov = propertyDescriptor.getLOV(); + if (lov!=null) { + islov=true; + String[] strs=lov.getListOfValues().getStringListOfValues();//ʵֵ + for(String s1:strs){ + String a1 = lov.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + jcomname.addItem(a1); + nameMap.put(a1, s1);//ʾ:ʵ + } + }else{ + islov=false; + } + if (islov) { + jp2.add("6.2.left.center", jcomname); + }else{ + jp2.add("6.2.left.center", jtext3); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ҳ + */ + private void init() { + // TODO Auto-generated method stub + this.setTitle("" + name); + this.setPreferredSize(new Dimension(500, 340)); + this.setLayout(new PropertyLayout()); + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(250, 250)); + jp2.setPreferredSize(new Dimension(250, 250)); + JTree tree = getTree(menuBean); + tree.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e + .getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + + childCount); + selnodename = ""; + if (childCount > 0) { + jp2.setVisible(false); + } else { + jp2.setVisible(true); + setTextStr(treeNode); + } + + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + ; + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + + JLabel jl1 = new JLabel("룺"); + JLabel jl2 = new JLabel("汾"); + JLabel jl3 = new JLabel("ƣ"); + jtext1 = new JTextField(12); + jtext2 = new JTextField(12); + jtext3 = new JTextField(12); + jtext1.setEnabled(false); + jtext2.setEnabled(false); + jcomname.setEnabled(false); + + jp2.add("1.1.left.center", new JLabel("")); + jp2.add("2.1.center.center", jl1); + jp2.add("2.2.left.center", jtext1); + jp2.add("3.1.left.center", new JLabel("")); + jp2.add("4.1.center.center", jl2); + jp2.add("4.2.left.center", jtext2); + jp2.add("5.1.left.center", new JLabel("")); + jp2.add("6.1.center.center", jl3); + + jp2.setVisible(false); + + add("1.1.center.center", jp1); + add("1.2.center.center", jp2); + add("2.1.center.center", okBut); + add("2.2.center.center", celBut); + okBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȷ"); + if (jp2.isVisible()) { + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + if (!nameMap.containsKey(itemName)) { + MessageBox.post("ƴ,Χѡ!", "ʾ", MessageBox.INFORMATION); + } + }else{ + itemName=jtext3.getText(); + } + if (!itemName.equals("")) { + createItem(); + } else { + MessageBox.post("ƲΪ!", "ʾ", MessageBox.INFORMATION); + } + } else { + MessageBox.post("ѡ񴴽!", "ʾ", MessageBox.INFORMATION); + } + + } + }); + celBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + + /** + * ¼ + */ + protected void createItem() { + // TODO Auto-generated method stub + try { + String type = selCodeBean.getType(); + DataBaseControl data = new DataBaseControl(session); + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + + try { + String newID = data.getNewCode("PLMCODE", selCodeBean); + TCComponentItem find = tctype.find(newID); + if (find != null) { + MessageBox.post("ǰˮID:" + newID + "Ѵڶ,޷!", "", + MessageBox.ERROR); + } else { + this.setVisible(false); + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + itemName=nameMap.get(itemName); + }else{ + itemName=jtext3.getText(); + } + TCComponentItem item = tctype.create(newID, + jtext2.getText(), type, itemName, "", null); + + System.out.println("ʼͬѡԵ"); + CopyPropsBean copyPropBean = selCodeBean.getCopyPropBean(); + if (copyPropBean!=null) { + String type2 = copyPropBean.getType(); + List props = copyPropBean.getProps(); + if (targetComp!=null&&targetComp.getType().equals(type2)) { + boolean isok=true; + TCComponentItemRevision furev=null; + if (targetComp instanceof TCComponentItemRevision) { + furev=(TCComponentItemRevision) targetComp; + }else if (targetComp instanceof TCComponentItem) { + furev=((TCComponentItem)targetComp).getLatestItemRevision(); + }else{ + isok=false; + System.out.println("ְֻ֧汾Ͷ"); + } + if (props!=null&&props.size()>0&&isok) { + for (int i = 0; i < props.size(); i++) { + System.out.println("prop="+ props.get(i)); + String[] split = props.get(i).split("="); + if (split != null && split.length == 2) { + String propstr = ""; + if (split[0].startsWith("ITEM.")) { + TCComponentItem com = furev.getItem(); + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } else if (split[0].startsWith("REV.")) { + TCComponentItemRevision com = furev; + propstr = com.getTCProperty(split[0].substring(4)).getStringValue(); + } else if (split[0].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) furev.getReferenceListProperty("IMAN_master_form_rev")[0]; + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } + if (propstr != null&& !propstr.equals("")) { + if (split[1].startsWith("ITEM.")) { + TCComponentItem com = item; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } else if (split[1].startsWith("REV.")) { + TCComponentItemRevision com = item.getLatestItemRevision(); + com.getTCProperty(split[1].substring(4)).setStringValue(propstr); + } else if (split[1].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) item.getLatestItemRevision() + .getReferenceListProperty("IMAN_master_form_rev")[0]; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } + } + + } + } + } + } + }else{ + System.out.println("δͬ,ͬ"); + } + + //+Ŀλˮ+ֱ+ + if (targetComp.getType().equals("WF2_2DprodDrawRevision")) { + TCComponentItemRevision furev=(TCComponentItemRevision) targetComp; + TCComponentForm form=(TCComponentForm) furev.getReferenceListProperty("IMAN_master_form_rev")[0]; + String spoke=form.getTCProperty("wf2_spoke").getDisplayableValue();// + String itemid=furev.getTCProperty("item_id").getStringValue(); + String lsm=itemid.substring(itemid.length()-5); + String dia=form.getTCProperty("wf2_rimDiameter").getDisplayableValue();//ֱ + String rim=form.getTCProperty("wf2_rimWidth").getDisplayableValue();// + System.out.println("rim1="+rim); + rim=rim.replaceAll("\\.", ""); + String khljh=spoke+lsm+dia+rim; + System.out.println("khljh="+khljh); + item.getLatestItemRevision().getReferenceListProperty("IMAN_master_form_rev")[0].setStringProperty("wf2_wfPartNumber", khljh); + String asmbPlant = getProjectAsmbPlant(furev); + item.getLatestItemRevision().getReferenceListProperty("IMAN_master_form_rev")[0].setStringProperty("wf2_asmbPlant", asmbPlant); + } + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + Wf016Operation op=new Wf016Operation(session, classid, item.getLatestItemRevision(), new Integer[] {}, new String[] {}); + session.queueOperation(op); + } else { + System.out.println("δҵ͵ķid,"); + } + if (isNewStuff) { + MessageBox.post("" + item + "ɹ,NewStuffļ²鿴!", + "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post("" + item + "ɹ,ڵǰļ²鿴!", "ɹ", + MessageBox.INFORMATION); + } + + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + + private String getProjectAsmbPlant(TCComponentItemRevision furev) { + // TODO Auto-generated method stub + String asmbPlant = ""; + try { + String projectID = furev.getStringProperty("project_ids"); + if(!("".equals(projectID)) && !(" ".equals(projectID)) && projectID != null) { + String[] keys = new String[]{"Ŀ ID"}; + String[] values = new String[]{projectID}; + System.out.println("projectID===================="+projectID); + List compList = queryObject("ĿIDĿ", keys, values); + System.out.println("size==========="+compList.size()); + TCComponent comp = compList.get(0); + if(comp instanceof TCComponentProject) { + TCComponentProject targetProject = (TCComponentProject) comp; + asmbPlant = comp.getStringProperty("wf2_asmbPlant"); + } + }else { + return ""; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return asmbPlant; + } + + /** + * ѡеײ¼ + * + */ + protected void setTextStr(DefaultMutableTreeNode treeNode) { + // TODO Auto-generated method stub + selnodename = treeNode.toString(); + if (islov) { + if (nameMap.containsKey(selnodename)) { + jcomname.setSelectedItem(selnodename); + } + }else{ + jtext3.setText(selnodename); + } + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean != null) { + String type = selCodeBean.getType(); + String code = selCodeBean.getCode(); + code = code + " [L]"; + getNameLov(type); + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + jtext1.setText(code); + jtext2.setText(tctype.getNewRev(null)); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode + * ڵ + * @param names + * ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + */ + private JTree getTree(MenuBean menuBean1) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( + treenodename); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, + DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + + /** + * ͨѯѯĿ + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName ,String[] keys,String[] values){ + TCComponent[] components = null; + try { + 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{ + return null; + } + } + +} diff --git a/src/com/connor/wf/plm/wf016/Wf016Action.java b/src/com/connor/wf/plm/wf016/Wf016Action.java new file mode 100644 index 0000000..d694373 --- /dev/null +++ b/src/com/connor/wf/plm/wf016/Wf016Action.java @@ -0,0 +1,43 @@ +package com.connor.wf.plm.wf016; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf016Action extends AbstractAIFAction { + private AbstractAIFApplication app; + private InterfaceAIFComponent tar; + private TCSession session; + private String name; + + public Wf016Action(AbstractAIFApplication arg0, String arg1, String name) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.tar = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.name = name; + } + + @Override + public void run() { + // TODO Auto-generated method stub + if (tar == null || !(tar instanceof TCComponentItemRevision)) { + MessageBox.post("ʧܣѡƷͼ汾д", "", 0); + return; + } + + if (!tar.getType().equals("WF2_2DprodDrawRevision")) { + MessageBox.post("ʧܣѡƷͼ汾д", "", 0); + return; + } else { + Wf016AIFDialog dia = new Wf016AIFDialog(session, tar, name); + new Thread(dia).start(); + } + + } + +} diff --git a/src/com/connor/wf/plm/wf016/Wf016Handler.java b/src/com/connor/wf/plm/wf016/Wf016Handler.java new file mode 100644 index 0000000..b7aadbc --- /dev/null +++ b/src/com/connor/wf/plm/wf016/Wf016Handler.java @@ -0,0 +1,38 @@ +package com.connor.wf.plm.wf016; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * :Wf016Handler + * :Ʒ + * :2019-03-06 + * Ա zl + * + */ +public class Wf016Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + try { + String name = arg0.getCommand().getName(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + //TCSession session = (TCSession) app.getSession(); + //InterfaceAIFComponent com = app.getTargetComponent(); + Wf016Action dia = new Wf016Action(app, null,name); + new Thread(dia).start(); + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf016/Wf016Operation.java b/src/com/connor/wf/plm/wf016/Wf016Operation.java new file mode 100644 index 0000000..4930bf2 --- /dev/null +++ b/src/com/connor/wf/plm/wf016/Wf016Operation.java @@ -0,0 +1,77 @@ +package com.connor.wf.plm.wf016; + +import java.util.ArrayList; +import java.util.List; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf016Operation extends AbstractAIFOperation { + + private TCSession session; + private String classid; + private TCComponentItemRevision rev; + private Integer[] keys; + private String[] vels; + + public Wf016Operation(TCSession session, String classid, + TCComponentItemRevision rev, Integer[] keys, String[] vels) { + // TODO Auto-generated constructor stub + this.session = session; + this.classid = classid; + this.rev = rev; + this.keys = keys; + this.vels = vels; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + sendObjToClassficationByWebService(classid, rev, keys, vels); + + } + + /** + * ͷ + * + * @param class_id + * id + * @param rev + * 汾 + * @param keys + * id + * @param vals + * ֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/wf/plm/wf017/Wf017AIFDialog.java b/src/com/connor/wf/plm/wf017/Wf017AIFDialog.java new file mode 100644 index 0000000..e653262 --- /dev/null +++ b/src/com/connor/wf/plm/wf017/Wf017AIFDialog.java @@ -0,0 +1,461 @@ +package com.connor.wf.plm.wf017; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import com.connor.wf.plm.util.CodeBean; +import com.connor.wf.plm.util.CopyPropsBean; +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.GetCodeBean; +import com.connor.wf.plm.util.MenuBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +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.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf017AIFDialog extends AbstractAIFDialog { + private TCSession session; + private InterfaceAIFComponent targetComp; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JTextField jtext1; + private JTextField jtext2; + private JTextField jtext3; + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private String selnodename = ""; + private JComboBox jcomname=new JComboBox(); + private Map nameMap=new HashMap<>(); + private boolean islov=false; + + public Wf017AIFDialog(TCSession session, InterfaceAIFComponent targetComp, + String name) { + this.session = session; + this.targetComp = targetComp; + this.name = name; + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + // codeBeanList = bean.getCodeBeanList(); + + init(); + + } + + + /** + * жǷlov + */ + private void getNameLov(String type) { + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + TCPropertyDescriptor propertyDescriptor = tctype.getPropertyDescriptor("object_name"); + TCComponentListOfValues lov = propertyDescriptor.getLOV(); + if (lov!=null) { + islov=true; + String[] strs=lov.getListOfValues().getStringListOfValues();//ʵֵ + for(String s1:strs){ + String a1 = lov.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + jcomname.addItem(a1); + System.out.println(s1+"-----"+a1); + nameMap.put(a1, s1);//ʾ:ʵ + } + }else{ + islov=false; + } + if (islov) { + jp2.add("6.2.left.center", jcomname); + }else{ + jp2.add("6.2.left.center", jtext3); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + /** + * ҳ + */ + private void init() { + // TODO Auto-generated method stub + this.setTitle("" + name); + this.setPreferredSize(new Dimension(600, 400)); + this.setLayout(new PropertyLayout()); + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(250, 270)); + jp2.setPreferredSize(new Dimension(350, 270)); + JTree tree = getTree(menuBean); + tree.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e + .getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + + childCount); + selnodename = ""; + if (childCount > 0) { + jp2.setVisible(false); + } else { + jp2.setVisible(true); + setTextStr(treeNode); + } + + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + ; + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + + JLabel jl1 = new JLabel("룺"); + JLabel jl2 = new JLabel("汾"); + JLabel jl3 = new JLabel("ƣ"); + jtext1 = new JTextField(12); + jtext2 = new JTextField(12); + jtext3 = new JTextField(12); + jtext1.setEnabled(false); + jtext2.setEnabled(false); + jcomname.setEnabled(false); + + jp2.add("1.1.left.center", new JLabel("")); + jp2.add("2.1.center.center", jl1); + jp2.add("2.2.left.center", jtext1); + jp2.add("3.1.left.center", new JLabel("")); + jp2.add("4.1.center.center", jl2); + jp2.add("4.2.left.center", jtext2); + jp2.add("5.1.left.center", new JLabel("")); + jp2.add("6.1.center.center", jl3); + if("".equals(name)){ + JLabel jl4 = new JLabel("(ĸǵ)"); + JLabel jl5 = new JLabel("(װζݶ)"); + JLabel jl6 = new JLabel("(װλ̥侶Ȧ)"); + JLabel jl7 = new JLabel("(סס׵)"); + JLabel jl8 = new JLabel("(֡רlogo)"); + jp2.add("7.1.center.center", new JLabel("")); + jp2.add("8.1.center.center", new JLabel("")); + jp2.add("9.1.center.center", new JLabel("")); + jp2.add("10.1.center.center", new JLabel("")); + jp2.add("11.1.center.center", new JLabel("")); + jp2.add("12.1.center.center", new JLabel("")); + jp2.add("8.2.left.center", jl4); + jp2.add("9.2.left.center", jl5); + jp2.add("10.2.left.center", jl6); + jp2.add("11.2.left.center", jl7); + jp2.add("12.2.left.center", jl8); + } + + + jp2.setVisible(false); + + add("1.1.center.center", jp1); + add("1.2.center.center", jp2); + add("2.1.center.center", okBut); + add("2.2.center.center", celBut); + okBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȷ"); + if (jp2.isVisible()) { + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + if (!nameMap.containsKey(itemName)) { + MessageBox.post("ƴ,Χѡ!", "ʾ", MessageBox.INFORMATION); + } + }else{ + itemName=jtext3.getText(); + } + if (!itemName.equals("")) { + createItem(); + } else { + MessageBox.post("ƲΪ!", "ʾ", MessageBox.INFORMATION); + } + } else { + MessageBox.post("ѡ񴴽!", "ʾ", MessageBox.INFORMATION); + } + + } + }); + celBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + + /** + * ¼ + */ + protected void createItem() { + // TODO Auto-generated method stub + try { + String type = selCodeBean.getType(); + DataBaseControl data = new DataBaseControl(session); + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + + try { + String newID = data.getNewCode("PLMCODE", selCodeBean); + TCComponentItem find = tctype.find(newID); + if (find != null) { + MessageBox.post("ǰˮID:" + newID + "Ѵڶ,޷!", "", + MessageBox.ERROR); + } else { + this.setVisible(false); + String itemName=""; + if (islov) { + itemName=(String) jcomname.getSelectedItem(); + itemName=nameMap.get(itemName); + }else{ + itemName=jtext3.getText(); + } + TCComponentItem item = tctype.create(newID, + jtext2.getText(), type, itemName, "", null); + + System.out.println("ʼͬѡԵ"); + CopyPropsBean copyPropBean = selCodeBean.getCopyPropBean(); + if (copyPropBean!=null) { + String type2 = copyPropBean.getType(); + List props = copyPropBean.getProps(); + if (targetComp!=null&&targetComp.getType().equals(type2)) { + boolean isok=true; + TCComponentItemRevision furev=null; + if (targetComp instanceof TCComponentItemRevision) { + furev=(TCComponentItemRevision) targetComp; + }else if (targetComp instanceof TCComponentItem) { + furev=((TCComponentItem)targetComp).getLatestItemRevision(); + }else{ + isok=false; + System.out.println("ְֻ֧汾Ͷ"); + } + if (props!=null&&props.size()>0&&isok) { + for (int i = 0; i < props.size(); i++) { + String[] split = props.get(i).split("="); + if (split != null && split.length == 2) { + String propstr = ""; + if (split[0].startsWith("ITEM.")) { + TCComponentItem com = furev.getItem(); + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } else if (split[0].startsWith("REV.")) { + TCComponentItemRevision com = furev; + propstr = com.getTCProperty(split[0].substring(4)).getStringValue(); + } else if (split[0].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) furev.getReferenceListProperty("IMAN_master_form_rev")[0]; + propstr = com.getTCProperty(split[0].substring(5)).getStringValue(); + } + if (propstr != null&& !propstr.equals("")) { + if (split[1].startsWith("ITEM.")) { + TCComponentItem com = item; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } else if (split[1].startsWith("REV.")) { + TCComponentItemRevision com = item.getLatestItemRevision(); + com.getTCProperty(split[1].substring(4)).setStringValue(propstr); + } else if (split[1].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) item.getLatestItemRevision() + .getReferenceListProperty("IMAN_master_form_rev")[0]; + com.getTCProperty(split[1].substring(5)).setStringValue(propstr); + } + } + + } + } + } + } + }else{ + System.out.println("δͬ,ͬ"); + } + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder().add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder().add("contents", item); + } + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + Wf017Operation op=new Wf017Operation(session, classid, item.getLatestItemRevision(), new Integer[] {}, new String[] {}); + session.queueOperation(op); + } else { + System.out.println("δҵ͵ķid,"); + } + if (isNewStuff) { + MessageBox.post("" + item + "ɹ,NewStuffļ²鿴!", + "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post("" + item + "ɹ,ڵǰļ²鿴!", "ɹ", + MessageBox.INFORMATION); + } + + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + /** + * ѡеײ¼ + * + */ + protected void setTextStr(DefaultMutableTreeNode treeNode) { + // TODO Auto-generated method stub + selnodename = treeNode.toString(); + if (islov) { + if (nameMap.containsKey(selnodename)) { + jcomname.setSelectedItem(selnodename); + } + }else{ + jtext3.setText(selnodename); + } + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean != null) { + String type = selCodeBean.getType(); + String code = selCodeBean.getCode(); + code = code + " [L]"; + getNameLov(type); + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + jtext1.setText(code); + jtext2.setText(tctype.getNewRev(null)); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode + * ڵ + * @param names + * ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + */ + private JTree getTree(MenuBean menuBean1) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( + treenodename); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, + DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + +} diff --git a/src/com/connor/wf/plm/wf017/Wf017Action.java b/src/com/connor/wf/plm/wf017/Wf017Action.java new file mode 100644 index 0000000..0a75dfe --- /dev/null +++ b/src/com/connor/wf/plm/wf017/Wf017Action.java @@ -0,0 +1,31 @@ +package com.connor.wf.plm.wf017; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf017Action extends AbstractAIFAction { + private AbstractAIFApplication app; + private InterfaceAIFComponent tar; + private TCSession session; + private String name; + + public Wf017Action(AbstractAIFApplication arg0, String arg1, String name) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.tar = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.name = name; + } + + @Override + public void run() { + // TODO Auto-generated method stub + Wf017AIFDialog dia = new Wf017AIFDialog(session, tar, name); + new Thread(dia).start(); + + } + +} diff --git a/src/com/connor/wf/plm/wf017/Wf017Handler.java b/src/com/connor/wf/plm/wf017/Wf017Handler.java new file mode 100644 index 0000000..6db5e1b --- /dev/null +++ b/src/com/connor/wf/plm/wf017/Wf017Handler.java @@ -0,0 +1,38 @@ +package com.connor.wf.plm.wf017; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * :Wf017Handler + * : + * :2019-03-07 + * Ա zl + * + */ +public class Wf017Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + try { + String name = arg0.getCommand().getName(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + //TCSession session = (TCSession) app.getSession(); + //InterfaceAIFComponent com = app.getTargetComponent(); + Wf017Action dia = new Wf017Action(app, null,name); + new Thread(dia).start(); + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf017/Wf017Operation.java b/src/com/connor/wf/plm/wf017/Wf017Operation.java new file mode 100644 index 0000000..2cfcf13 --- /dev/null +++ b/src/com/connor/wf/plm/wf017/Wf017Operation.java @@ -0,0 +1,77 @@ +package com.connor.wf.plm.wf017; + +import java.util.ArrayList; +import java.util.List; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf017Operation extends AbstractAIFOperation { + + private TCSession session; + private String classid; + private TCComponentItemRevision rev; + private Integer[] keys; + private String[] vels; + + public Wf017Operation(TCSession session, String classid, + TCComponentItemRevision rev, Integer[] keys, String[] vels) { + // TODO Auto-generated constructor stub + this.session = session; + this.classid = classid; + this.rev = rev; + this.keys = keys; + this.vels = vels; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + sendObjToClassficationByWebService(classid, rev, keys, vels); + + } + + /** + * ͷ + * + * @param class_id + * id + * @param rev + * 汾 + * @param keys + * id + * @param vals + * ֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/wf/plm/wf020/CreateChangeOrderDialog.java b/src/com/connor/wf/plm/wf020/CreateChangeOrderDialog.java new file mode 100644 index 0000000..1b32dd7 --- /dev/null +++ b/src/com/connor/wf/plm/wf020/CreateChangeOrderDialog.java @@ -0,0 +1,197 @@ +package com.connor.wf.plm.wf020; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; +/** + * :CreateChangeOrderDialog + * :֪ͨ + * :2019-03-04 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class CreateChangeOrderDialog extends AbstractAIFDialog{ + private static final long serialVersionUID = 1L; + private InterfaceAIFComponent[] targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + public CreateChangeOrderDialog(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponents(); + init(); + } + private void init() { + //жǷΪ뵥 + final TCComponent itemR = (TCComponent)targetComponents[0]; + if(!itemR.getTypeComponent().toString().equals("WF2_ECRRevision")) { + System.out.println(itemR.getTypeComponent()); + MessageBox.post("ʧܣѡ뵥汾д", "ʾϢ",MessageBox.INFORMATION); + return; + }else { + + //ô֪ͨij + + this.setTitle("֪ͨ"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(380, 330)); + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + //ģо + final iTextField id_TextField = new iTextField(); + final iTextField name_TextField = new iTextField(); + name_TextField.setText("֪ͨ"); + //final iTextField re_TextField = new iTextField(); //λ + final iTextField desc_TextField = new iTextField();// + + final JLabel jText = new JLabel(); + final JLabel jid = new JLabel(); + final JLabel jname= new JLabel(); + //final JLabel jre = new JLabel(); + final JLabel jdesc = new JLabel(); + jText.setText(" IDֵ\"ECN\"nnnnnnnб༭"); + jid.setText("ID:"); + jname.setText(":"); + //jre.setText("λ:"); + jdesc.setText(":"); + id_TextField.setPreferredSize(new Dimension(180, 20)); + name_TextField.setPreferredSize(new Dimension(180, 20)); + // re_TextField.setPreferredSize(new Dimension(180, 20)); + desc_TextField.setPreferredSize(new Dimension(180, 20)); + JButton give_button = new JButton("ָ"); + + + //panel.add("1.1.center.center.preferred.preferred",jText); + + panel.add("1.1.left.center",new JLabel(" ")); + panel.add("1.2.center.center",jText); + + panel.add("2.1.left.center",jid); + panel.add("2.2.center.center",id_TextField); + panel.add("2.3.right.center",give_button); + + + panel.add("3.1.left.center",jname); + panel.add("3.2.center.center",name_TextField); + + // panel.add("3.2.left.center.perferred.perferred",re_TextField); + + panel.add("4.1.left.center",jdesc); + panel.add("4.2.center.center",desc_TextField); + + + + //ť 뵽ָ + + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.center.center", panel); + this.add("2.1.center.center", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + + give_button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + + TCComponentItemType ccomponentitemtype; + + + try { + ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_ECN"); + id_TextField.setText(ccomponentitemtype.getNewID()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + }); + + ok_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + //֪ͨ + + String itemId=id_TextField.getText().trim(); + String itemName=name_TextField.getText().trim(); + String itemDescription = desc_TextField.getText().trim(); + + if(itemName.equals("")|itemName=="null") { + MessageBox.post("Ϊ", "ʾϢ",MessageBox.INFORMATION); + }else { + + TCComponentItemType ccomponentitemtype; + try { + ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_ECN"); + TCComponentItem item = ccomponentitemtype.create(itemId,"A","WF2_ECN",itemName,itemDescription,null); + + + //item֪ͨļӸӹϵ + + + itemR.add("WF2_ECNRe", item); + + MessageBox.post("֪ͨӳɹ", "ʾϢ",MessageBox.INFORMATION); + closeDialog(); + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }); + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + + + + } + } + private void closeDialog() { + disposeDialog(); + setVisible(false); +} +} diff --git a/src/com/connor/wf/plm/wf020/Wf020Handler.java b/src/com/connor/wf/plm/wf020/Wf020Handler.java new file mode 100644 index 0000000..827ae06 --- /dev/null +++ b/src/com/connor/wf/plm/wf020/Wf020Handler.java @@ -0,0 +1,31 @@ +package com.connor.wf.plm.wf020; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.wf.plm.wf011.CreateSubPartDrawDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +/** + * :Wf020Handler + * :֪ͨ + * :2019-03-04 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class Wf020Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + CreateChangeOrderDialog createChangeOrderDialog = new CreateChangeOrderDialog(app); + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf022/Wf022Handler.java b/src/com/connor/wf/plm/wf022/Wf022Handler.java new file mode 100644 index 0000000..81b4113 --- /dev/null +++ b/src/com/connor/wf/plm/wf022/Wf022Handler.java @@ -0,0 +1,66 @@ +package com.connor.wf.plm.wf022; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.wf.plm.wf012.Wf012Dialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf022Handler + * : ͼֽ޶ + * :2019-03-02 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf022Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private TCSession session; + private InterfaceAIFComponent target; + private String[] types; + private Boolean flag; + private TCComponentItemRevision rev; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.target = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.flag = false; + this.rev = null; + this.types = new String[]{"WF2_finPartRevision","WF2_semiFinPartRevision","WF2_rawMaterialRevision", + "WF2_procResourceRevision","WF2_moldRevision","WF2_mdPartRevision","WF2_subpartRevision","WF2_pkgMaterialRevision", + "WF2_2DprodDrawRevision","WF2_pkgDrawRevision","WF2_subPartDrawRevision","WF2_processDrawRevision"}; + if(target instanceof TCComponentItemRevision){ + rev = (TCComponentItemRevision) target; + String targetType = rev.getType(); + for (String type : types) { + if(type.equals(targetType)){ + flag = true; + break; + } + } + + }else{ + MessageBox.post("ѡ汾", "ʾ", MessageBox.INFORMATION); + return null; + } + + if(flag){ + Wf022Operation operation = new Wf022Operation(app,rev); + session.queueOperation(operation); + }else{ + MessageBox.post("ѡϻͼֽ汾", "ʾ", MessageBox.INFORMATION); + } + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf022/Wf022Operation.java b/src/com/connor/wf/plm/wf022/Wf022Operation.java new file mode 100644 index 0000000..8d0b09b --- /dev/null +++ b/src/com/connor/wf/plm/wf022/Wf022Operation.java @@ -0,0 +1,130 @@ +package com.connor.wf.plm.wf022; + +import java.util.ArrayList; +import java.util.List; + + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + + +public class Wf022Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCComponentItemRevision rev; + private TCSession session; + private TCPreferenceService service; + private String url = ""; + private Integer[] classKeys; + private String[] classVals; + + + + public Wf022Operation(AbstractAIFUIApplication app, + TCComponentItemRevision rev) { + this.app = app; + this.rev = rev; + this.session = (TCSession) app.getSession(); + } + + + @Override + public void executeOperation() throws Exception { + try { + openByPass(session); + TCComponentItemRevision newRev = rev.saveAs(rev.getItem().getNewRev()); + closeByPass(session); + String newclass = newRev.getClassificationClass(); + if (newclass != null && (!newclass.equals(""))) { + System.out.println("°汾ĬϷͷ,跢ͷִ"); + } else { + String classname = rev.getClassificationClass(); + if (classname != null&&(!classname.equals(""))) { + service = session.getPreferenceService(); + url = service + .getStringValue("Autocode_SendClassServer_URL"); + System.out.println("url=" + url); + + TCComponentICO[] icos = rev.getClassificationObjects(); + + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + classKeys = new Integer[icss.length]; + classVals = new String[icss.length]; + for (int i = 0; i < icss.length; i++) { + classKeys[i] = icss[i].getId(); + classVals[i] = icss[i].getValue(); + } + } + sendObjToClassficationByWebService(classname, newRev, + classKeys, classVals);//ͷ + System.out.println("ͷ"); + } + + } + MessageBox.post("޶!!","",MessageBox.INFORMATION); + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("޶ʧ:"+e.getMessage(),"",MessageBox.ERROR); + } + + } + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + + //·(һҪ) + public void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_set_bypass", obj); + } + + //· + public void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_close_bypass", obj); + +// session.getUserService().call("Connor_set_bypass", new Object[]{});//bypass +// session.getUserService().call("Connor_close_bypass", new Object[]{});//bypass + } +} diff --git a/src/com/connor/wf/plm/wf023/Wf023Dialog.java b/src/com/connor/wf/plm/wf023/Wf023Dialog.java new file mode 100644 index 0000000..a0cda5b --- /dev/null +++ b/src/com/connor/wf/plm/wf023/Wf023Dialog.java @@ -0,0 +1,172 @@ +package com.connor.wf.plm.wf023; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf023Dialog extends AbstractAIFDialog{ + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentSchedule schedule; + private List values; + private JComboBox comb; + private AIFComponentContext[] childs; + private String pathRoute; + private JTextField pathField ; + private String fielName; + public Wf023Dialog(AbstractAIFUIApplication app, TCComponentSchedule schedule) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.schedule = schedule; + this.values = new ArrayList(); + this.comb = null; + this.childs = null; + this.pathRoute = null; + this.pathField = null; + this.fielName = null; + } + public void run(){ + initUI(); + } + /** + * ҳ + */ + private void initUI() { + String puid = session.getPreferenceService().getStringValue( + "WF2_Check_Template_puid"); + if (puid == null||puid.equals("")) { + + MessageBox.post("ѡWF2_Check_Template_puidδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + try { + TCComponentDataset excelData = (TCComponentDataset) session.stringToComponent(puid); + fielName = excelData.getStringProperty("object_name"); + System.out.println("fielName====================="+fielName); + + + + TCComponent scheduleChild = schedule.getReferenceProperty("fnd0SummaryTask"); + childs = scheduleChild.getChildren(); + for (AIFComponentContext child : childs) { + TCComponent comp = (TCComponent) child.getComponent(); + String type = comp.getType(); + if("ScheduleTask".equals(type)){ + String val = comp.getStringProperty("object_name"); + values.add(val); + } + } + System.out.println(schedule); + } catch (TCException e) { + e.printStackTrace(); + } + + + this.setLayout(new BorderLayout()); + this.setTitle("Ŀ"); + this.setPreferredSize(new Dimension(320, 130)); + this.setResizable(false); + JPanel mainPanel = new JPanel(new BorderLayout()); + JPanel centerPanel = new JPanel(new PropertyLayout()); + JPanel southPanel = new JPanel(new FlowLayout()); + JLabel name = new JLabel(" ׶"); + comb = new JComboBox(); + for (int i = 0; i < values.size(); i++) { + comb.addItem(values.get(i)); + } + FileSystemView fsv = FileSystemView.getFileSystemView(); + final String deekPath = fsv.getHomeDirectory().getPath(); + System.out.println("·Ϊ==============="+deekPath); + JLabel path = new JLabel(" ·"); + pathField = new JTextField(16); + pathField.setText(deekPath); + JButton selBtn = new JButton("ѡ"); + centerPanel.add("1.1.center.top", name); + centerPanel.add("1.2.center.top", comb); + centerPanel.add("2.1.center.top", path); + centerPanel.add("2.2.center.top", pathField); + centerPanel.add("2.3.center.top", selBtn); + selBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser choose = new JFileChooser(); + //choose.setCurrentDirectory(new File(deekPath)); + choose.setFileSelectionMode(1); + if (choose.showOpenDialog(null) != 1){ + pathField.setText(choose.getSelectedFile() + .getAbsolutePath()); + + + } + } + }); + + JButton okBtn = new JButton("ȷ"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String path = pathField.getText(); + if("".equals(path)){ + disposeDialog(); + MessageBox.post("δѡ񵼳·","ʾ",MessageBox.INFORMATION); + return; + } + SimpleDateFormat sf = new SimpleDateFormat("yyyyMMDDHHmmss"); + String time = sf.format(new Date()); + pathRoute = pathField.getText()+"\\"+fielName+time+".xlsx"; + String name = (String) comb.getSelectedItem(); + + Wf023Operation operation = new Wf023Operation(app, childs, name,pathRoute); + session.queueOperation(operation); + disposeDialog(); + } + }); + JButton celBtn = new JButton("ȡ"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + mainPanel.add(centerPanel, BorderLayout.CENTER); + mainPanel.add(southPanel,BorderLayout.SOUTH); + this.add(mainPanel,BorderLayout.CENTER); + this.centerToScreen(); + this.showDialog(); + + } + + +} diff --git a/src/com/connor/wf/plm/wf023/Wf023Handler.java b/src/com/connor/wf/plm/wf023/Wf023Handler.java new file mode 100644 index 0000000..e76649b --- /dev/null +++ b/src/com/connor/wf/plm/wf023/Wf023Handler.java @@ -0,0 +1,44 @@ +package com.connor.wf.plm.wf023; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf022Handler + * : Ŀ죨׶Σ + * :2019-03-08 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf023Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.target = app.getTargetComponent(); + TCComponentSchedule schedule = null; + if(target != null){ + if(target instanceof TCComponentSchedule){ + schedule = (TCComponentSchedule) target; + Wf023Dialog dialog = new Wf023Dialog(app, schedule); + new Thread(dialog).start(); + }else{ + MessageBox.post("ѡеIJʱ", "ʾ", MessageBox.INFORMATION); + } + }else{ + MessageBox.post("ûѡж", "ʾ", MessageBox.INFORMATION); + } + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf023/Wf023Operation.java b/src/com/connor/wf/plm/wf023/Wf023Operation.java new file mode 100644 index 0000000..b1c4f17 --- /dev/null +++ b/src/com/connor/wf/plm/wf023/Wf023Operation.java @@ -0,0 +1,291 @@ +package com.connor.wf.plm.wf023; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf023Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private AIFComponentContext[] childs; + private String name; + private TCSession session; + private ProgressBarThread wait; + private String pathRoute; + private XSSFSheet sheet ; + private final static long aDay = 1000 * 60 * 60 * 24; + private String[] setProp; + private SimpleDateFormat format; + private XSSFCellStyle cellStyle; + private int i = 2; + private short height = 0; + public Wf023Operation(AbstractAIFUIApplication app, + AIFComponentContext[] childs, String name,String pathRoute) { + super(); + this.app = app; + this.childs = childs; + this.name = name; + this.wait = null; + this.session = (TCSession) app.getSession(); + this.pathRoute = pathRoute; + this.sheet = null; + this.setProp = new String[]{"ResourceAssignment","finish_date","actual_finish_date","fnd0state"};// ʱˣʱ䣬ʵʱ + this.format = new SimpleDateFormat("yy-MM-dd hh:mm"); + this.cellStyle = null; + } + + @Override + public void executeOperation() throws Exception { + wait = new ProgressBarThread("", "ִУԵ..."); + wait.start(); + writeToExcel(); + } + /** + * д뵽excel + */ + private void writeToExcel(){ + FileInputStream fis=null; + FileOutputStream fos=null; + String puid = session.getPreferenceService().getStringValue( + "WF2_Check_Template_puid"); + if (puid == null||puid.equals("")) { + + MessageBox.post("ѡWF2_Check_Template_puidδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + try { + TCComponentDataset excelData = (TCComponentDataset) session.stringToComponent(puid); + File file=((TCComponentDataset)excelData).getTcFiles()[0].getFmsFile(); + // File file=components[0].getTcFiles()[0].getFmsFile(); + + fis = new FileInputStream(file); + System.out.println("fis:"+fis); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + + System.out.println("workBook:"+workbook); + + sheet = workbook.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(2); + height = targetRow.getHeight(); + XSSFCell targetCell = targetRow.getCell(0); + cellStyle = targetCell.getCellStyle(); + if (sheet == null) { + MessageBox.post("sheet", "", 2); + return; + } + System.out.println("sheet:"+sheet); + + for (AIFComponentContext child : childs) { + TCComponent comp = (TCComponent) child.getComponent(); + String property = comp.getStringProperty("object_name"); + if(name == null || name == ""){ + MessageBox.post("δѡʱ׶,ѡ񣡣","ʾ",MessageBox.INFORMATION); + }else{ + if(name.equals(property)){ + XSSFRow row = sheet.getRow(i); + if(row == null){ + row = sheet.createRow(i); + } + + row.setHeight(height); + i++; + for(int k=0;k<9;k++){ + XSSFCell cell = row.getCell(k); + if(cell == null){ + cell = row.createCell(k); + cell.setCellStyle(cellStyle); + } + } + XSSFCell cell = row.getCell(0); + cell.setCellValue(name); + AIFComponentContext[] tasks = comp.getChildren("child_task_taglist"); + for (AIFComponentContext task : tasks) { + TCComponentScheduleTask childTask = (TCComponentScheduleTask) task.getComponent(); + hasChild(childTask); + } + } + } + } + wait.setBool(true); + wait.interrupt(); + fos = new FileOutputStream(new File(pathRoute)); + workbook.write(fos); + Runtime.getRuntime().exec((new StringBuilder("cmd /c \"")).append(pathRoute).append("\"").toString()); + } catch (Exception e1) { + e1.printStackTrace(); + System.out.println("============================ʧ"); + MessageBox.post("ʧ","",2); + return; + }finally{ + try { + if(fis!=null) + fis.close(); + if(fos!=null) + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + /** + * жǷ + * paramchildTask ڵ + */ + public void hasChild(TCComponentScheduleTask childTask){ + try { + AIFComponentContext[] clids = childTask.getChildren("child_task_taglist"); + + if(clids != null && clids.length > 0){ + for (AIFComponentContext clid : clids) { + TCComponentScheduleTask cldTask = (TCComponentScheduleTask) clid.getComponent(); + hasChild(cldTask); + } + }else{ + XSSFRow row = sheet.getRow(i); + if(row == null){ + row = sheet.createRow(i); + } + row.setHeight(height); + i++; + for(int k=0;k<9;k++){ + XSSFCell cell = row.getCell(k); + if(cell == null){ + cell = row.createCell(k); + cell.setCellStyle(cellStyle); + } + } + XSSFCell cell = row.getCell(1); + System.out.println("type======================="+childTask.getType()); + cell.setCellValue(childTask.getStringProperty("object_name")); + TCComponent[] properties = childTask.getReferenceListProperty("sch_task_deliverable_list"); + if(properties != null && properties.length > 0){ + for (TCComponent tc : properties) { + String[] data = childTask.getProperties(setProp); + TCComponent comp = tc.getReferenceProperty("fnd0DeliverableInstance"); + String name1 = ""; + if(comp != null){ + TCComponent[] tcs = comp.getReferenceListProperty("contents"); + if(tcs != null && tcs.length > 0){ + for (int j = 0; j < tcs.length; j++) { + name1 += tcs[j]; + } + } + } + String name = tc.getStringProperty("object_name"); + cell = row.getCell(2); + if(cell == null){ + cell = row.createCell(2); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(name); + cell = row.getCell(3); + if(cell == null){ + cell = row.createCell(3); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(name1); + cell = row.getCell(4); + if(cell == null){ + cell = row.createCell(4); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(data[0]); + cell = row.getCell(5); + + if(cell == null){ + cell = row.createCell(5); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(data[1]); + cell = row.getCell(6); + if(cell == null){ + cell = row.createCell(6); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(data[2]); + try { + if (null != data[3] && data[3].contains("")) { + if (data[2] != null && data[2].length() > 0) { // ״̬ + long duration = format.parse(data[2]).getTime() - format.parse(data[1]).getTime(); + if (duration > 0) { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue("(ӳ" + (duration / aDay) + ")"); + } else if (duration == 0) { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue("(ʱ)"); + } else { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue("(ǰ" + -(duration / aDay) + ")"); + } + } else { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(""); + } + } else { + long duration = (new Date()).getTime() - format.parse(data[1]).getTime(); + if (duration > 0) { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue("δ(ӳ" + (duration / aDay) + ")"); + } else { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + + cell.setCellStyle(cellStyle); + } + cell.setCellValue("δ"); + } + } + } catch (ParseException e) { + e.printStackTrace(); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/wf/plm/wf024/Wf024Dialog.java b/src/com/connor/wf/plm/wf024/Wf024Dialog.java new file mode 100644 index 0000000..b7ac8a6 --- /dev/null +++ b/src/com/connor/wf/plm/wf024/Wf024Dialog.java @@ -0,0 +1,133 @@ +package com.connor.wf.plm.wf024; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +public class Wf024Dialog extends AbstractAIFDialog{ + private AbstractAIFUIApplication app; + private TCComponentSchedule schedule; + private TCSession session; + private String pathRoute; + private JTextField pathField; + private String fielName; + + public Wf024Dialog(AbstractAIFUIApplication app, TCComponentSchedule schedule) { + this.app = app; + this.schedule = schedule; + this.session = (TCSession) app.getSession(); + this.pathRoute = null; + this.pathField = null; + this.fielName = null; + } + + public void run(){ + initUI(); + } + /** + * ҳ + */ + private void initUI() { + String puid = session.getPreferenceService().getStringValue( + "WF2_Check_Template_puid"); + if (puid == null||puid.equals("")) { + MessageBox.post("ѡFED_Check_Template_puidδ,ϵԱ!!", + "", MessageBox.ERROR); + return ; + } + try { + TCComponentDataset excelData = (TCComponentDataset) session.stringToComponent(puid); + fielName = excelData.getStringProperty("object_name"); + System.out.println("fielName====================="+fielName); + } catch (TCException e1) { + e1.printStackTrace(); + } + this.setLayout(new BorderLayout()); + this.setTitle("Ŀ"); + this.setPreferredSize(new Dimension(320, 120)); + this.setResizable(false); + JPanel mainPanel = new JPanel(new BorderLayout()); + JPanel centerPanel = new JPanel(new PropertyLayout()); + JPanel southPanel = new JPanel(new FlowLayout()); + JLabel path = new JLabel(" ·"); + FileSystemView fsv = FileSystemView.getFileSystemView(); + final String deekPath = fsv.getHomeDirectory().getPath(); + System.out.println("·Ϊ==============="+deekPath); + pathField = new JTextField(16); + pathField.setText(deekPath); + JButton selBtn = new JButton("ѡ"); + centerPanel.add("1.1.center.top", new JLabel(" ")); + centerPanel.add("2.1.center.top", path); + centerPanel.add("2.2.center.top", pathField); + centerPanel.add("2.3.center.top", selBtn); + selBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser choose = new JFileChooser(); + //choose.setCurrentDirectory(new File(deekPath)); + choose.setFileSelectionMode(1); + if (choose.showOpenDialog(null) != 1){ + pathField.setText(choose.getSelectedFile() + .getAbsolutePath()); + + + } + } + }); + + JButton okBtn = new JButton("ȷ"); + okBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + String path = pathField.getText(); + System.out.println("path====================="+path); + if("".equals(path)){ + disposeDialog(); + MessageBox.post("δѡ񵼳·","ʾ",MessageBox.INFORMATION); + return; + } + SimpleDateFormat sf = new SimpleDateFormat("yyyyMMDDHHmmss"); + String time = sf.format(new Date()); + pathRoute = pathField.getText()+"\\"+fielName+time+".xlsx"; + Wf024Operation operation = new Wf024Operation(app, schedule,pathRoute); + session.queueOperation(operation); + disposeDialog(); + } + }); + JButton celBtn = new JButton("ȡ"); + celBtn.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + southPanel.add(okBtn); + southPanel.add(celBtn); + mainPanel.add(centerPanel, BorderLayout.CENTER); + mainPanel.add(southPanel,BorderLayout.SOUTH); + this.add(mainPanel,BorderLayout.CENTER); + this.centerToScreen(); + this.showDialog(); + } +} diff --git a/src/com/connor/wf/plm/wf024/Wf024Handler.java b/src/com/connor/wf/plm/wf024/Wf024Handler.java new file mode 100644 index 0000000..aba9990 --- /dev/null +++ b/src/com/connor/wf/plm/wf024/Wf024Handler.java @@ -0,0 +1,45 @@ +package com.connor.wf.plm.wf024; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +/** + * :Wf022Handler + * : Ŀ죨 + * :2019-03-11 + * Ա + * + * ޸ ޸ ޸ + * 2019-01-24 XXXX + */ +public class Wf024Handler extends AbstractHandler{ + private AbstractAIFUIApplication app; + private InterfaceAIFComponent target; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + this.app = AIFUtility.getCurrentApplication(); + this.target = app.getTargetComponent(); + TCComponentSchedule schedule = null; + if(target != null){ + if(target instanceof TCComponentSchedule){ + schedule = (TCComponentSchedule) target; + Wf024Dialog dialog = new Wf024Dialog(app, schedule); + new Thread(dialog).start(); + }else{ + MessageBox.post("ѡеIJʱ", "ʾ", MessageBox.INFORMATION); + } + }else{ + MessageBox.post("ûѡж", "ʾ", MessageBox.INFORMATION); + } + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf024/Wf024Operation.java b/src/com/connor/wf/plm/wf024/Wf024Operation.java new file mode 100644 index 0000000..be00369 --- /dev/null +++ b/src/com/connor/wf/plm/wf024/Wf024Operation.java @@ -0,0 +1,303 @@ +package com.connor.wf.plm.wf024; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf024Operation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCComponentSchedule schedule; + private String fielName; + private TCSession session; + private ProgressBarThread wait; + private String pathRoute; + private XSSFSheet sheet ; + private final static long aDay = 1000 * 60 * 60 * 24; + private String[] setProp; + private SimpleDateFormat format; + private XSSFCellStyle cellStyle; + private int i = 2; + private short height = 0; + public Wf024Operation(AbstractAIFUIApplication app,TCComponentSchedule schedule,String pathRoute) { + super(); + this.app = app; + this.schedule = schedule; + this.session = (TCSession) app.getSession(); + this.pathRoute = pathRoute; + this.sheet = null; + this.setProp = new String[]{"ResourceAssignment","finish_date","actual_finish_date","fnd0state"};// ʱˣʱ䣬ʵʱ + this.format = new SimpleDateFormat("yy-MM-dd hh:mm"); + this.cellStyle = null; + } + + @Override + public void executeOperation() throws Exception { + wait = new ProgressBarThread("", "ִУԵ..."); + wait.start(); + writeToExcel(); + } + /** + * д뵽excel + */ + private void writeToExcel(){ + + FileInputStream fis=null; + FileOutputStream fos=null; + String puid = session.getPreferenceService().getStringValue( + "WF2_Check_Template_puid"); + if (puid == null||puid.equals("")) { + + MessageBox.post("ѡFED_Check_Template_puidδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + try { + TCComponentDataset excelData = (TCComponentDataset) session.stringToComponent(puid); + File file=((TCComponentDataset)excelData).getTcFiles()[0].getFmsFile(); + // File file=components[0].getTcFiles()[0].getFmsFile(); + + fis = new FileInputStream(file); + System.out.println("fis:"+fis); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + + System.out.println("workBook:"+workbook); + + sheet = workbook.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(2); + height = targetRow.getHeight(); + XSSFCell targetCell = targetRow.getCell(0); + cellStyle = targetCell.getCellStyle(); + if (sheet == null) { + MessageBox.post("sheet", "", 2); + return; + } + System.out.println("sheet:"+sheet); + AIFComponentContext[] childs = getChilds(); + for (AIFComponentContext child : childs) { + TCComponent comp = (TCComponent) child.getComponent(); + String type = comp.getType(); + if(!"ScheduleTask".equals(type)){ + continue; + } + String property = comp.getStringProperty("object_name"); + XSSFRow row = sheet.getRow(i); + if(row == null){ + row = sheet.createRow(i); + } + row.setHeight(height); + i++; + for(int k=0;k<9;k++){ + XSSFCell cell = row.getCell(k); + if(cell == null){ + cell = row.createCell(k); + cell.setCellStyle(cellStyle); + } + } + XSSFCell cell = row.getCell(0); + cell.setCellValue(property); + AIFComponentContext[] tasks = comp.getChildren("child_task_taglist"); + for (AIFComponentContext task : tasks) { + TCComponentScheduleTask childTask = (TCComponentScheduleTask) task.getComponent(); + hasChild(childTask); + } + } + + wait.setBool(true); + wait.interrupt(); + fos = new FileOutputStream(new File(pathRoute)); + workbook.write(fos); + Runtime.getRuntime().exec((new StringBuilder("cmd /c \"")).append(pathRoute).append("\"").toString()); + } catch (Exception e1) { + e1.printStackTrace(); + System.out.println("============================ʧ"); + MessageBox.post("ʧ","",2); + return; + }finally{ + try { + if(fis!=null) + fis.close(); + if(fos!=null) + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + /** + * жǷ + * paramchildTask ڵ + */ + public void hasChild(TCComponentScheduleTask childTask){ + try { + AIFComponentContext[] clids = childTask.getChildren("child_task_taglist"); + + if(clids != null && clids.length > 0){ + for (AIFComponentContext clid : clids) { + TCComponentScheduleTask cldTask = (TCComponentScheduleTask) clid.getComponent(); + hasChild(cldTask); + } + }else{ + XSSFRow row = sheet.getRow(i); + if(row == null){ + row = sheet.createRow(i); + } + row.setHeight(height); + i++; + for(int k = 0;k < 9;k++){ + XSSFCell cell = row.getCell(k); + if(cell == null){ + cell = row.createCell(k); + cell.setCellStyle(cellStyle); + } + } + XSSFCell cell = row.getCell(1); + System.out.println("type======================="+childTask.getType()); + cell.setCellValue(childTask.getStringProperty("object_name")); + TCComponent[] properties = childTask.getReferenceListProperty("sch_task_deliverable_list"); + if(properties != null && properties.length > 0){ + for (TCComponent tc : properties) { + String[] data = childTask.getProperties(setProp); + TCComponent comp = tc.getReferenceProperty("fnd0DeliverableInstance"); + String name1 = ""; + if(comp != null){ + TCComponent[] tcs = comp.getReferenceListProperty("contents"); + if(tcs != null && tcs.length > 0){ + for (int j = 0; j < tcs.length; j++) { + name1 += tcs[j]; + } + } + } + String name = tc.getStringProperty("object_name"); + cell = row.getCell(2); + if(cell == null){ + cell = row.createCell(2); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(name); + cell = row.getCell(3); + if(cell == null){ + cell = row.createCell(3); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(name1); + cell = row.getCell(4); + if(cell == null){ + cell = row.createCell(4); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(data[0]); + cell = row.getCell(5); + + if(cell == null){ + cell = row.createCell(5); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(data[1]); + cell = row.getCell(6); + if(cell == null){ + cell = row.createCell(6); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(data[2]); + try { + if (null != data[3] && data[3].contains("")) { + if (data[2] != null && data[2].length() > 0) { // ״̬ + long duration; + duration = format.parse(data[2]).getTime() - format.parse(data[1]).getTime(); + if (duration > 0) { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue("(ӳ" + (duration / aDay) + ")"); + } else if (duration == 0) { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue("(ʱ)"); + } else { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue("(ǰ" + -(duration / aDay) + ")"); + } + } else { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(""); + } + } else { + long duration = (new Date()).getTime() - format.parse(data[1]).getTime(); + if (duration > 0) { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue("δ(ӳ" + (duration / aDay) + ")"); + } else { + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + + cell.setCellStyle(cellStyle); + } + cell.setCellValue("δ"); + } + } + } catch (ParseException e) { + e.printStackTrace(); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + /** + * ڵ + */ + public AIFComponentContext[] getChilds(){ + AIFComponentContext[] childs = null; + try { + TCComponent scheduleChild = schedule.getReferenceProperty("fnd0SummaryTask"); + childs = scheduleChild.getChildren(); + } catch (TCException e) { + e.printStackTrace(); + } + return childs; + } +} diff --git a/src/com/connor/wf/plm/wf037/Wf037AIFAction.java b/src/com/connor/wf/plm/wf037/Wf037AIFAction.java new file mode 100644 index 0000000..0352033 --- /dev/null +++ b/src/com/connor/wf/plm/wf037/Wf037AIFAction.java @@ -0,0 +1,26 @@ +package com.connor.wf.plm.wf037; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class Wf037AIFAction extends AbstractAIFAction { + private AbstractAIFApplication app; + public Wf037AIFAction(AbstractAIFApplication arg0, String arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + } + + @Override + public void run() { + // TODO Auto-generated method stub + Wf037AIFCommand comm = new Wf037AIFCommand(app); + try { + comm.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/wf/plm/wf037/Wf037AIFCommand.java b/src/com/connor/wf/plm/wf037/Wf037AIFCommand.java new file mode 100644 index 0000000..70527c2 --- /dev/null +++ b/src/com/connor/wf/plm/wf037/Wf037AIFCommand.java @@ -0,0 +1,18 @@ +package com.connor.wf.plm.wf037; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; + +public class Wf037AIFCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + public Wf037AIFCommand(AbstractAIFApplication arg0){ + this.app = arg0; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + super.executeModal(); + Wf037AIFDialog dialog = new Wf037AIFDialog(app); + } +} diff --git a/src/com/connor/wf/plm/wf037/Wf037AIFDialog.java b/src/com/connor/wf/plm/wf037/Wf037AIFDialog.java new file mode 100644 index 0000000..85f347a --- /dev/null +++ b/src/com/connor/wf/plm/wf037/Wf037AIFDialog.java @@ -0,0 +1,213 @@ +package com.connor.wf.plm.wf037; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf037AIFDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent targetComp; + private TCComponentDataset comp; + private JLabel jLabel; + private JTextField jtf = new JTextField(20); + private JButton jButton; + private JFileChooser jFileChooser; + private JButton okBut = new JButton(""); + private JButton celBut = new JButton("ȡ"); + private List fmsFilelist = new ArrayList<>(); + private List hzmlist = new ArrayList<>(); + private List namelist = new ArrayList<>(); + private FileInputStream fis; + private FileOutputStream fos; + + public Wf037AIFDialog(AbstractAIFApplication arg0){ + this.app = arg0; + this.session = (TCSession)app.getSession(); + this.targetComp = app.getTargetComponent(); + if(targetComp instanceof TCComponentDataset){ + comp = (TCComponentDataset) targetComp; + getload(); + init(); + }else{ + MessageBox.post("ݼ","error",MessageBox.ERROR); + } + } + + //ȡļб + private void getload(){ + String projectID = ""; + try { + AIFComponentContext[] revs = comp.whereReferenced(); + for (int i = 0; i < revs.length; i++) { + InterfaceAIFComponent rev = revs[i].getComponent(); + if(rev instanceof TCComponentItemRevision){ + TCComponentItemRevision targetRev = (TCComponentItemRevision) rev; + projectID = targetRev.getStringProperty("project_ids"); + System.out.println("projectID================"+projectID); + break; + } + } + + TCComponentTcFile[] file = ((TCComponentDataset)targetComp) + .getTcFiles(); + if(file == null || file.length ==0){ + MessageBox.post("ݼûõļ飡", + "WARNING",MessageBox.WARNING); + return; + }else{ + for(int i=0;i realbean=new ArrayList<>(); + private String type=""; + private File[] fs=null; + public Wf038AIFDialog(TCSession arg0,InterfaceAIFComponent arg1){ + this.session = arg0; + this.targetComp = arg1; + } + + public void run(){ + if(targetComp == null){ + MessageBox.post("ѡļл汾!!","", MessageBox.ERROR); + return; + } + type = targetComp.getType(); + System.out.println("tyep="+type); + if(type.equals("Folder")||type.contains("Revision")){ + getReal(); + init(); + }else{ + MessageBox.post("ѡļл汾!!","", MessageBox.ERROR); + return; + } + } + + public void init(){ + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + setLayout(new PropertyLayout()); + jb4 = new JLabel(" ļ·"); + jt4.setText(deskPath); + pBut = new JButton("..."); + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath)); + jFileChooser.setMultiSelectionEnabled(true); + add("1.1.left.top", jb4); + add("1.2.left.top", jt4); + add("1.3.left.top", pBut); + add("2.1.left.top", okBut); + add("2.2.left.top", celBut); + setVisible(true); + this.centerToScreen(); + this.pack(); + pBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + + okBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ʼϴ"); + if(!jt4.getText().equals("")){ + String[] strs=jt4.getText().split(";"); + boolean is = true; + for(String str:strs){ + is = uploadfile(str); + if(!is){ + break; + } + } + if(is){ + MessageBox.post("ϴ!!","ɹ", MessageBox.INFORMATION); + } + setVisible(false); + } + } + }); + + celBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + } + + public boolean uploadfile(String fathname){ + try { + String datType=""; + String toolType=""; + String realname=""; + for(RealBean bean:realbean){ + if(fathname.endsWith(bean.getHzm())){ + datType = bean.getDaType(); + toolType = bean.getToolType(); + realname = bean.getRealname(); + } + } + if((datType==null)||datType.equals("")){ + MessageBox.post("ݲָ֧͵ļϴ!!!","ʾ", MessageBox.INFORMATION); + return false; + } + File file = new File(fathname); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + TCComponentDataset dataset = datasetType.create(file.getName(), "", datType); + if(dataset == null){ + MessageBox.post("ʧ", "", MessageBox.ERROR); + return false; + } + dataset.setFiles(new String[]{fathname}, new String[]{toolType}); + if(type.equals("Folder")){ + System.out.println("ļйϵ:contents"); + ((TCComponent)targetComp).add("contents",dataset); + }else{ + System.out.println("汾ϵ:"+realname); + ((TCComponent)targetComp).add(realname,dataset); + } + return true; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ϴʧ:"+e.getMessage(),"", MessageBox.ERROR); + return false; + } + + } + + private void getReal(){ + String[] names = session.getPreferenceService().getStringValues(UpFileStr); + if(names != null){ + for(int i=0;i> list) { + // TODO Auto-generated method stub + for (int i = 0; i < list.size(); i++) { + XSSFRow rowm = sheet.createRow(i + 1); + XSSFCellStyle sty =workBook.createCellStyle(); //sheet.getRow(0).getCell(0).getCellStyle(); + for (int j = 0; j < list.get(i).size(); j++) { + XSSFCell c = rowm.createCell(j); + c.setCellStyle(sty); + c.setCellValue(list.get(i).get(j)); + + + } + + } + + } + +} diff --git a/src/com/connor/wf/plm/wf050/Wf050AIFDialog.java b/src/com/connor/wf/plm/wf050/Wf050AIFDialog.java new file mode 100644 index 0000000..69e4d9b --- /dev/null +++ b/src/com/connor/wf/plm/wf050/Wf050AIFDialog.java @@ -0,0 +1,479 @@ +package com.connor.wf.plm.wf050; + +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.wf.plm.util.CalendarPanel; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf050AIFDialog extends AbstractAIFDialog { + private TCSession session; + private InterfaceAIFComponent targetComp; + private JTextField text0; + private JTextField text; + private JTextField text1; + private JTextField text2; + private JComboBox comboBox; + private CalendarPanel cap1; + private CalendarPanel cap2; + private Map map; + private String[] str1; + private JFileChooser jFileChooser; + private XSSFSheet sheet ; + private XSSFCellStyle cellStyle; + public Wf050AIFDialog(TCSession arg0,InterfaceAIFComponent arg1){ + this.session = arg0; + this.targetComp = arg1; + } + + public void run(){ + init(); + } + + public void init(){ + System.out.println("init()"); + this.setTitle(""); + this.setPreferredSize(new Dimension(300, 250)); + this.setLayout(new PropertyLayout()); + comboBox=new JComboBox(); + comboBox.setPreferredSize(new Dimension(116, 24));// JComboBoxȵĴ + try { + TCComponentFormType tccFormType = (TCComponentFormType)session.getTypeComponent("WF2_ECRRevisionMaster"); + TCComponentListOfValues lov1 = tccFormType.getFormPropertyDescriptor("wf2_applicationDpt").getLOV(); + if(lov1!=null){ + map=new HashMap<>(); + String[] strs1=lov1.getListOfValues().getStringListOfValues();//ʵֵ + str1 = new String[strs1.length]; + int i=0; + comboBox.addItem(" "); + for(String s1:strs1){ + String a1 = lov1.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + comboBox.addItem(a1);//ʵֵӦʾֵ + str1[i]=a1;i++; + map.put(s1, a1);//ʵk:ʾv + } + } + } catch (TCException e1) { + + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + text0=new JTextField(10); + text=new JTextField(10); + text1=new JTextField(6); + text2=new JTextField(6); + + JButton okBut = new JButton("ȷ"); + JButton celBut = new JButton("ȡ"); + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + panel.add("1.1.left.center", new JLabel("")); + panel.add("2.1.left.center", new JLabel("")); + panel.add("3.1.left.center.preferred.preferred", new JLabel("𷽣")); + panel.add("3.2.right.center.perferred.perferred", text0); + panel.add("4.1.left.center", new JLabel("")); + panel.add("5.1.left.center.preferred.preferred", new JLabel("벿ţ")); + panel.add("5.2.right.center.perferred.perferred", comboBox); + panel.add("6.1.left.center", new JLabel("")); + panel.add("7.1.left.center.preferred.preferred", new JLabel("Ŀţ")); + panel.add("7.2.right.center.perferred.perferred", text); + panel.add("8.1.left.center", new JLabel("")); + panel.add("9.1.center.top", new JLabel("ڣ")); + panel.add("9.2.center.top", text1); + panel.add("9.3.center.top", new JLabel("")); + panel.add("9.4.center.top", text2); + panel.add("10.1.left.center", new JLabel("")); + panel.add("11.1.left.center", new JLabel("")); + panel.add("12.1.left.center", new JLabel("")); + + buttonPanel.add(okBut); + buttonPanel.add(celBut); + + this.add("1.1.center.top.preferred.preferred", panel); + this.add("2.1.center.top.preferred.preferred", buttonPanel); + + setVisible(true); + this.centerToScreen(); + //this.setAlwaysOnTop(true); + this.pack(); + + text1.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + cap1 = new CalendarPanel(text1); + } + }); + + text2.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + cap2 = new CalendarPanel(text2); + } + }); + + okBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//ڸʽ + String pa=selectFileButtonEvent(); + if (pa==null) { + return; + } + String fpath = pa+"\\_"+df.format(new Date())+".xlsx"; + System.out.println("fpath="+fpath); + setVisible(false); + List list = getValues(); + valuesToExcel(list,fpath); + System.out.println("ok()"); + + } + }); + + celBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + } + + private List getValues(){ + List list = new ArrayList<>(); + List tages = new ArrayList<>(); + List tvalues = new ArrayList<>(); + String initor = "";// + String pronum = "";//Ŀ + String reqdepk = "";//벿 + if(comboBox.getSelectedItem()==null || comboBox.getSelectedItem().equals("")) { + }else{ + if(comboBox.getSelectedItem().toString().trim().length()>0){ + reqdepk =getKey(map,comboBox.getSelectedItem().toString()); + tages.add("벿"); + tvalues.add((String)reqdepk); + } + } + if(text.getText()==null || text.getText().equals("")){ + }else{ + pronum = text.getText(); + tages.add("Ŀ"); + tvalues.add(pronum); + } + if(text0.getText()==null || text0.getText().equals("")) { + }else{ + initor = text0.getText(); + tages.add(""); + tvalues.add(initor); + } + if(text2.getText()==null || text2.getText().equals("")) { + }else{ + tages.add(""); + tvalues.add(text2.getText()); + } + + if(text1.getText()==null || text1.getText().equals("")) { + }else{ + tages.add(""); + tvalues.add(text1.getText()); + } + if(0==tages.size()){ + tages.add("벿"); + tvalues.add("*"); + } + String[] array1 = new String[tages.size()]; + String[] s1=tages.toArray(array1); + + String[] array2 = new String[tvalues.size()]; + String[] s2=tvalues.toArray(array2); + System.out.println("tages="+tages.toString()); + System.out.println("tvalues="+tvalues.toString()); + + try { + //TCComponent[] components=session.search("ѯ",s1,s2); + String[] keys = new String[]{""}; + String[] values = new String[]{"WF2_trailRunPlan"}; + List components = queryObject("ѯ", s1, s2); + System.out.println("="+components.size()); + + /* + if (components!=null && components.length>0) { + for (int i = 0; i < components.length; i++) { + System.out.println("="+components[i]+";="+components[i].getType()); + if(components[i].getType().equals("WF2_ECRRevision")){ + System.out.println("ȷ"); + TCComponent[] referenceListPropertys = components[i].getReferenceListProperty("WF2_ECNRe"); + System.out.println("referenceListPropertys.length="+referenceListPropertys.length); + if(referenceListPropertys!=null && referenceListPropertys.length>0){ + for(int j=0;j0){ + for(int i=0;i map,String value){ + if(value == null) return null; + String key=""; + for (Map.Entry entry : map.entrySet()) { + if(value.equals(entry.getValue())){ + key=entry.getKey(); + } + } + return key; + } + /** + * ͨѯѯƷͼ + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName ,String[] keys,String[] values){ + TCComponent[] components = null; + try { + 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; + } + } +} diff --git a/src/com/connor/wf/plm/wf050/Wf050Handler.java b/src/com/connor/wf/plm/wf050/Wf050Handler.java new file mode 100644 index 0000000..b33c6a1 --- /dev/null +++ b/src/com/connor/wf/plm/wf050/Wf050Handler.java @@ -0,0 +1,25 @@ +package com.connor.wf.plm.wf050; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf050Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + Wf050AIFDialog dialog = new Wf050AIFDialog(session,targetComp); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf051/Problems.java b/src/com/connor/wf/plm/wf051/Problems.java new file mode 100644 index 0000000..a0dc617 --- /dev/null +++ b/src/com/connor/wf/plm/wf051/Problems.java @@ -0,0 +1,108 @@ +package com.connor.wf.plm.wf051; + +import java.util.Date; +/** + * :Problems + * :㵼 + * :2019-03-04 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class Problems { + //creation_date ʱ wf2_problemDescr wf2_countermeasuresʩ wf2_responsibleDptβ last_mod_date ޸ʱ wf2_proofScheme֤ wf2_inventoryHandling洦 wf2_trackingBatch θ + //wf2_validationResults ֤ wf2_remarksע + private Date creation_date; + private String wf2_problemDescr; + private String wf2_countermeasures; + private String wf2_responsibleDpt; + private Date last_mod_date; + private String wf2_proofScheme; + private String wf2_inventoryHandling; + private String wf2_trackingBatch; + private String wf2_validationResults; + private String wf2_remarks; + public Problems(Date creation_date, String wf2_problemDescr, String wf2_countermeasures, String wf2_responsibleDpt, Date last_mod_date, String wf2_proofScheme, + String wf2_inventoryHandling, String wf2_trackingBatch,String wf2_validationResults,String wf2_remarks) { + // TODO Auto-generated constructor stub + this.creation_date=creation_date; + this.wf2_problemDescr=wf2_problemDescr; + this.wf2_countermeasures=wf2_countermeasures; + this.wf2_responsibleDpt=wf2_responsibleDpt; + this.last_mod_date=last_mod_date; + this.wf2_proofScheme=wf2_proofScheme; + this.wf2_inventoryHandling=wf2_inventoryHandling; + this.wf2_trackingBatch=wf2_trackingBatch; + this.wf2_validationResults=wf2_validationResults; + this.wf2_remarks=wf2_remarks; + } + + public Date getCreation_date() { + return creation_date; + } + + public void setCreation_date(Date creation_date) { + this.creation_date = creation_date; + } + + public Date getLast_mod_date() { + return last_mod_date; + } + + public void setLast_mod_date(Date last_mod_date) { + this.last_mod_date = last_mod_date; + } + + public String getWf2_problemDescr() { + return wf2_problemDescr; + } + public void setWf2_problemDescr(String wf2_problemDescr) { + this.wf2_problemDescr = wf2_problemDescr; + } + public String getWf2_countermeasures() { + return wf2_countermeasures; + } + public void setWf2_countermeasures(String wf2_countermeasures) { + this.wf2_countermeasures = wf2_countermeasures; + } + public String getWf2_responsibleDpt() { + return wf2_responsibleDpt; + } + public void setWf2_responsibleDpt(String wf2_responsibleDpt) { + this.wf2_responsibleDpt = wf2_responsibleDpt; + } + public String getWf2_proofScheme() { + return wf2_proofScheme; + } + public void setWf2_proofScheme(String wf2_proofScheme) { + this.wf2_proofScheme = wf2_proofScheme; + } + public String getWf2_inventoryHandling() { + return wf2_inventoryHandling; + } + public void setWf2_inventoryHandling(String wf2_inventoryHandling) { + this.wf2_inventoryHandling = wf2_inventoryHandling; + } + public String getWf2_trackingBatch() { + return wf2_trackingBatch; + } + public void setWf2_trackingBatch(String wf2_trackingBatch) { + this.wf2_trackingBatch = wf2_trackingBatch; + } + public String getWf2_validationResults() { + return wf2_validationResults; + } + public void setWf2_validationResults(String wf2_validationResults) { + this.wf2_validationResults = wf2_validationResults; + } + public String getWf2_remarks() { + return wf2_remarks; + } + public void setWf2_remarks(String wf2_remarks) { + this.wf2_remarks = wf2_remarks; + } + + + +} diff --git a/src/com/connor/wf/plm/wf051/ReportExcel.java b/src/com/connor/wf/plm/wf051/ReportExcel.java new file mode 100644 index 0000000..410644d --- /dev/null +++ b/src/com/connor/wf/plm/wf051/ReportExcel.java @@ -0,0 +1,271 @@ +package com.connor.wf.plm.wf051; + +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.JOptionPane; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFComment; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; +/** + * :ReportExcel + * :㵼 + * :2019-03-04 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +/** + * ÿԴPOI3.0.2̬EXCELĵ + * + * @author leno + * @version v1.0 + * @param + * Ӧ÷ͣһjavabean + * עΪ˼boolean͵xxxgetʽΪgetXxx(),isXxx() + * byte[]jpgʽͼƬ + */ +public class ReportExcel +{ + public void exportExcel(Collection dataset, OutputStream out) + { + exportExcel("POIEXCELĵ", null, dataset, out, "yyyy-MM-dd"); + } + + public void exportExcel(String[] headers, Collection dataset, + OutputStream out) + { + exportExcel("POIEXCELĵ", headers, dataset, out, "yyyy-MM-dd"); + } + + public void exportExcel(String[] headers, Collection dataset, + OutputStream out, String pattern) + { + exportExcel("POIEXCELĵ", headers, dataset, out, pattern); + } + + /** + * һͨõķJAVAķƣԽJAVAвҷһEXCEL ʽָIO豸 + * + * @param title + * + * @param headers + * + * @param dataset + * Ҫʾݼ,һҪ÷javabeanĶ󡣴˷ֵ֧ + * javabeanԵлͼString,Date,byte[](ͼƬ) + * @param out + * 豸󣬿ԽEXCELĵļ + * @param pattern + * ʱݣ趨ʽĬΪ"yyy-MM-dd" + */ + @SuppressWarnings("unchecked") + public void exportExcel(String title, String[] headers, + Collection dataset, OutputStream out, String pattern) + { + // һ + HSSFWorkbook workbook = new HSSFWorkbook(); + // һ + HSSFSheet sheet = workbook.createSheet(title); + // ñĬпΪ15ֽ + sheet.setDefaultColumnWidth((short) 15); + // һʽ + HSSFCellStyle style = workbook.createCellStyle(); + // Щʽ + style.setFillForegroundColor(HSSFColor.SKY_BLUE.index); + style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + style.setBorderBottom(HSSFCellStyle.BORDER_THIN); + style.setBorderLeft(HSSFCellStyle.BORDER_THIN); + style.setBorderRight(HSSFCellStyle.BORDER_THIN); + style.setBorderTop(HSSFCellStyle.BORDER_THIN); + style.setAlignment(HSSFCellStyle.ALIGN_CENTER); + // һ + HSSFFont font = workbook.createFont(); + font.setColor(HSSFColor.VIOLET.index); + font.setFontHeightInPoints((short) 12); + font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + // Ӧõǰʽ + style.setFont(font); + // ɲһʽ + HSSFCellStyle style2 = workbook.createCellStyle(); + style2.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index); + style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + style2.setBorderBottom(HSSFCellStyle.BORDER_THIN); + style2.setBorderLeft(HSSFCellStyle.BORDER_THIN); + style2.setBorderRight(HSSFCellStyle.BORDER_THIN); + style2.setBorderTop(HSSFCellStyle.BORDER_THIN); + style2.setAlignment(HSSFCellStyle.ALIGN_CENTER); + style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); + // һ + HSSFFont font2 = workbook.createFont(); + font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL); + // Ӧõǰʽ + style2.setFont(font2); + + // һͼĶ + HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); + // ע͵ĴСλ,ĵ + HSSFComment comment = patriarch.createComment(new HSSFClientAnchor(0, + 0, 0, 0, (short) 4, 2, (short) 6, 5)); + // ע + comment.setString(new HSSFRichTextString("POIעͣ")); + // עߣƶԪǿ״̬п. + comment.setAuthor("leno"); + + // + HSSFRow row = sheet.createRow(0); + for (short i = 0; i < headers.length; i++) + { + HSSFCell cell = row.createCell(i); + cell.setCellStyle(style); + HSSFRichTextString text = new HSSFRichTextString(headers[i]); + cell.setCellValue(text); + } + + // ݣ + Iterator it = dataset.iterator(); + int index = 0; + while (it.hasNext()) + { + index++; + row = sheet.createRow(index); + T t = (T) it.next(); + // ÷䣬javabeanԵȺ˳򣬶̬getXxx()õֵ + Field[] fields = t.getClass().getDeclaredFields(); + for (short i = 0; i < fields.length; i++) + { + HSSFCell cell = row.createCell(i); + cell.setCellStyle(style2); + Field field = fields[i]; + String fieldName = field.getName(); + String getMethodName = "get" + + fieldName.substring(0, 1).toUpperCase() + + fieldName.substring(1); + try + { + Class tCls = t.getClass(); + Method getMethod = tCls.getMethod(getMethodName, + new Class[] + {}); + Object value = getMethod.invoke(t, new Object[] + {}); + // жֵͺǿת + String textValue = null; + + if (value instanceof Boolean) + { + boolean bValue = (Boolean) value; + textValue = ""; + if (!bValue) + { + textValue = "Ů"; + } + } + else if (value instanceof Date) + { + Date date = (Date) value; + SimpleDateFormat sdf = new SimpleDateFormat(pattern); + textValue = sdf.format(date); + } + else if (value instanceof byte[]) + { + // ͼƬʱиΪ60px; + row.setHeightInPoints(60); + // ͼƬпΪ80px,עﵥλһ + sheet.setColumnWidth(i, (short) (35.7 * 80)); + // sheet.autoSizeColumn(i); + byte[] bsValue = (byte[]) value; + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, + 1023, 255, (short) 6, index, (short) 6, index); + anchor.setAnchorType(2); + patriarch.createPicture(anchor, workbook.addPicture( + bsValue, HSSFWorkbook.PICTURE_TYPE_JPEG)); + } + else + { + // Ͷַ򵥴 + textValue = value.toString(); + } + // ͼƬݣʽжtextValueǷȫ + if (textValue != null) + { + Pattern p = Pattern.compile("^//d+(//.//d+)?$"); + Matcher matcher = p.matcher(textValue); + if (matcher.matches()) + { + // ֵdouble + cell.setCellValue(Double.parseDouble(textValue)); + } + else + { + HSSFRichTextString richString = new HSSFRichTextString( + textValue); + HSSFFont font3 = workbook.createFont(); + font3.setColor(HSSFColor.BLUE.index); + richString.applyFont(font3); + cell.setCellValue(richString); + } + } + } + catch (SecurityException e) + { + e.printStackTrace(); + } + catch (NoSuchMethodException e) + { + e.printStackTrace(); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(); + } + catch (IllegalAccessException e) + { + e.printStackTrace(); + } + catch (InvocationTargetException e) + { + e.printStackTrace(); + } + finally + { + // Դ + } + } + } + try + { + workbook.write(out); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + +} + + diff --git a/src/com/connor/wf/plm/wf051/ReportExcels.java b/src/com/connor/wf/plm/wf051/ReportExcels.java new file mode 100644 index 0000000..4448cee --- /dev/null +++ b/src/com/connor/wf/plm/wf051/ReportExcels.java @@ -0,0 +1,242 @@ +package com.connor.wf.plm.wf051; + +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.JOptionPane; + + +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; + +import org.apache.poi.hssf.usermodel.HSSFFont; + +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFRichTextString; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +/** + * :ReportExcel + * :㵼 + * :2019-03-04 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +/** + * ÿԴPOI3.0.2̬EXCELĵ + * + * @author leno + * @version v1.0 + * @param + * Ӧ÷ͣһjavabean + * עΪ˼boolean͵xxxgetʽΪgetXxx(),isXxx() + * byte[]jpgʽͼƬ + */ +public class ReportExcels +{ + /** + * һͨõķJAVAķƣԽJAVAвҷһEXCEL ʽָIO豸 + * + * @param title + * + * @param headers + * + * @param dataset + * Ҫʾݼ,һҪ÷javabeanĶ󡣴˷ֵ֧ + * javabeanԵлͼString,Date,byte[](ͼƬ) + * @param out + * 豸󣬿ԽEXCELĵļ + * @param pattern + * ʱݣ趨ʽĬΪ"yyy-MM-dd" + */ + @SuppressWarnings("unchecked") + public void exportExcel(XSSFWorkbook workbook,XSSFSheet sheet,Collection dataset, OutputStream out, String pattern) + { + + // ñĬпΪ15ֽ + sheet.setDefaultColumnWidth((short) 15); + // һʽ + XSSFCellStyle style = workbook.createCellStyle(); + // Щʽ + style.setFillForegroundColor(HSSFColor.SKY_BLUE.index); + style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + style.setBorderBottom(HSSFCellStyle.BORDER_THIN); + style.setBorderLeft(HSSFCellStyle.BORDER_THIN); + style.setBorderRight(HSSFCellStyle.BORDER_THIN); + style.setBorderTop(HSSFCellStyle.BORDER_THIN); + style.setAlignment(HSSFCellStyle.ALIGN_CENTER); + // һ + XSSFFont font = workbook.createFont(); + font.setColor(HSSFColor.VIOLET.index); + font.setFontHeightInPoints((short) 12); + font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + // Ӧõǰʽ + style.setFont(font); + // ɲһʽ + XSSFCellStyle style2 = workbook.createCellStyle(); + style2.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index); + style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); + style2.setBorderBottom(HSSFCellStyle.BORDER_THIN); + style2.setBorderLeft(HSSFCellStyle.BORDER_THIN); + style2.setBorderRight(HSSFCellStyle.BORDER_THIN); + style2.setBorderTop(HSSFCellStyle.BORDER_THIN); + style2.setAlignment(HSSFCellStyle.ALIGN_CENTER); + style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); + // һ + XSSFFont font2 = workbook.createFont(); + font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL); + // Ӧõǰʽ + style2.setFont(font2); + + // + XSSFRow row = sheet.getRow(0); +// for (short i = 0; i < headers.length; i++) +// { +// HSSFCell cell = row.createCell(i); +// cell.setCellStyle(style); +// HSSFRichTextString text = new HSSFRichTextString(headers[i]); +// cell.setCellValue(text); +// } + + // ݣ + Iterator it = dataset.iterator(); + int index = 0; + while (it.hasNext()) + { + index++; + row = sheet.createRow(index); + T t = (T) it.next(); + // ÷䣬javabeanԵȺ˳򣬶̬getXxx()õֵ + Field[] fields = t.getClass().getDeclaredFields(); + for (short i = 0; i < fields.length; i++) + { + XSSFCell cell = row.createCell(i); + cell.setCellStyle(style2); + Field field = fields[i]; + String fieldName = field.getName(); + String getMethodName = "get" + + fieldName.substring(0, 1).toUpperCase() + + fieldName.substring(1); + try + { + Class tCls = t.getClass(); + Method getMethod = tCls.getMethod(getMethodName, + new Class[] + {}); + Object value = getMethod.invoke(t, new Object[] + {}); + // жֵͺǿת + String textValue = null; + + if (value instanceof Boolean) + { + boolean bValue = (Boolean) value; + textValue = ""; + if (!bValue) + { + textValue = "Ů"; + } + } + else if (value instanceof Date) + { + Date date = (Date) value; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + textValue = sdf.format(date); + } + else if (value instanceof byte[]) + { + // ͼƬʱиΪ60px; + row.setHeightInPoints(60); + // ͼƬпΪ80px,עﵥλһ + sheet.setColumnWidth(i, (short) (35.7 * 80)); + // sheet.autoSizeColumn(i); + byte[] bsValue = (byte[]) value; + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, + 1023, 255, (short) 6, index, (short) 6, index); + anchor.setAnchorType(2); + + } + else + { + // Ͷַ򵥴 + textValue = value.toString(); + } + // ͼƬݣʽжtextValueǷȫ + if (textValue != null) + { + Pattern p = Pattern.compile("^//d+(//.//d+)?$"); + Matcher matcher = p.matcher(textValue); + if (matcher.matches()) + { + // ֵdouble + cell.setCellValue(Double.parseDouble(textValue)); + } + else + { + XSSFRichTextString richString = new XSSFRichTextString( + textValue); + XSSFFont font3 = workbook.createFont(); + font3.setColor(HSSFColor.BLUE.index); + richString.applyFont(font3); + cell.setCellValue(richString); + } + } + } + catch (SecurityException e) + { + e.printStackTrace(); + } + catch (NoSuchMethodException e) + { + e.printStackTrace(); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(); + } + catch (IllegalAccessException e) + { + e.printStackTrace(); + } + catch (InvocationTargetException e) + { + e.printStackTrace(); + } + finally + { + // Դ + } + } + } + try + { + workbook.write(out); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + +} + + diff --git a/src/com/connor/wf/plm/wf051/ReportProblemsDialog.java b/src/com/connor/wf/plm/wf051/ReportProblemsDialog.java new file mode 100644 index 0000000..6fc66bb --- /dev/null +++ b/src/com/connor/wf/plm/wf051/ReportProblemsDialog.java @@ -0,0 +1,333 @@ +package com.connor.wf.plm.wf051; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.filechooser.FileSystemView; + + +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; +/** + * :ReportProblemsDialog + * :㵼Ľ + * :2019-03-04 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ + +public class ReportProblemsDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private JFileChooser jFileChooser; + private InterfaceAIFComponent[] targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + private String fielName; + private TCComponentProject project; + private int i = 2; + public ReportProblemsDialog(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponents(); + init(); + } + private void init() { + + // + //1. + + + this.setTitle("㱨"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(280, 230)); + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + // + final iTextField problem_TextField = new iTextField(); + final iTextField productType_TextField = new iTextField(); + final iTextField projectPhase_TextField = new iTextField(); + + + problem_TextField.setPreferredSize(new Dimension(180, 20)); + productType_TextField.setPreferredSize(new Dimension(180, 20)); + projectPhase_TextField.setPreferredSize(new Dimension(180, 20)); + + JLabel problem = new JLabel(""); + JLabel productType = new JLabel("Ʒͺ"); + JLabel projectphase = new JLabel("Ŀ׶"); + + panel.add("1.1.left.center.preferred.preferred",problem); + panel.add("1.2.right.center.perferred.perferred",problem_TextField); + + panel.add("2.1.left.center.preferred.preferred",productType); + panel.add("2.2.right.center.perferred.perferred",productType_TextField); + + panel.add("3.1.left.center.preferred.preferred",projectphase); + panel.add("3.2.right.center.perferred.perferred",projectPhase_TextField); + + //ť 뵽ָ + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.center.top.preferred.preferred", panel); + this.add("2.1.center.top.preferred.preferred", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + ok_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + + + try { + //1ͨѡҵģ AXXxKS_BjsmraC + String puid = session.getPreferenceService().getStringValue("WF2_probelm_Template_puid"); + + if (puid == null||puid.equals("")) { + + MessageBox.post("ѡWF2_probelm_Template_puidδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + //AbWxaxcUJsmraC + + TCComponentDataset excelData = (TCComponentDataset) session.stringToComponent(puid); + fielName = excelData.getStringProperty("object_name"); + System.out.println("fielName====================="+fielName); + + + + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//ڸʽ + String fpath = selectFileButtonEvent()+"\\㱨_"+df.format(new Date())+".xlsx"; + System.out.println("fpath="+fpath); + + FileInputStream fis=null; + FileOutputStream fos=null; + XSSFSheet sheet=null ; + XSSFCellStyle cellStyle=null; + excelData = (TCComponentDataset) session.stringToComponent(puid); + + System.out.println(excelData.getTcFiles()); + System.out.println(excelData.getTcFiles()[0]); + System.out.println(excelData.getTcFiles()[0].getFmsFile()); + File file=((TCComponentDataset)excelData).getTcFiles()[0].getFmsFile(); + // File file=components[0].getTcFiles()[0].getFmsFile(); + + fis = new FileInputStream(file); + System.out.println("fis:"+fis); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + + System.out.println("workBook:"+workbook); + sheet = workbook.getSheetAt(0); + cellStyle = workbook.createCellStyle(); + + + if (sheet == null) { + MessageBox.post("sheet", "", 2); + return; + } + System.out.println("sheet:"+sheet); + + + //ȡϢ + String wf2_problemcategory = problem_TextField.getText().trim();// + String wf2_productnumber = productType_TextField.getText().trim();//Ʒͺ + String wf2_stageProject = projectPhase_TextField.getText().trim();//Ŀ׶ + + //8 + TCComponent[] components1=null; + if(wf2_problemcategory.length()==0&&wf2_productnumber.length()>0&&wf2_stageProject.length()>0) {// 1.A! B C + components1= session.search("WF2_problems", new String[] { "wf2_productnumber","wf2_stageProject" },new String[] {wf2_productnumber,wf2_stageProject}); + + }else if(wf2_problemcategory.length()==0&&wf2_productnumber.length()==0&&wf2_stageProject.length()==0) { + + components1= null; + + }else if(wf2_problemcategory.length()==0&&wf2_productnumber.length()>0&&wf2_stageProject.length()==0) { + + components1= session.search("WF2_problems", new String[] { "wf2_productnumber"},new String[] {wf2_productnumber}); + + + }else if(wf2_problemcategory.length()==0&&wf2_productnumber.length()==0&&wf2_stageProject.length()>0) { + + components1= session.search("WF2_problems", new String[] {"wf2_stageProject" },new String[] {wf2_stageProject}); + + }else if(wf2_problemcategory.length()>0&&wf2_productnumber.length()==0&&wf2_stageProject.length()==0) { + + components1= session.search("WF2_problems", new String[] { "wf2_problemCategory"},new String[] {wf2_problemcategory}); + + }else if(wf2_problemcategory.length()>0&&wf2_productnumber.length()>0&&wf2_stageProject.length()==0) { + + components1= session.search("WF2_problems", new String[] { "wf2_problemCategory","wf2_productnumber"},new String[] {wf2_problemcategory,wf2_productnumber}); + + }else if(wf2_problemcategory.length()>0&&wf2_productnumber.length()==0&&wf2_stageProject.length()>0) { + + components1= session.search("WF2_problems", new String[] { "wf2_problemCategory","wf2_stageProject" },new String[] {wf2_problemcategory,wf2_stageProject}); + + }else if(wf2_problemcategory.length()>0&&wf2_productnumber.length()>0&&wf2_stageProject.length()>0) { + + components1= session.search("WF2_problems", new String[] { "wf2_problemCategory","wf2_productnumber","wf2_stageProject" },new String[] {wf2_problemcategory,wf2_productnumber,wf2_stageProject}); + + } + + System.out.println(components1); + List dataset = new ArrayList(); + for (TCComponent tcComponent : components1) { + + TCComponent a =tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0]; + + System.out.println(a); + + Date creation_date=tcComponent.getDateProperty("creation_date"); //tcComponent.getStringProperty("creation_date"); + String wf2_problemDescr=tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_problemDescr"); + if(wf2_problemDescr==null) { + wf2_problemDescr=" "; + } + String wf2_countermeasures=tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_countermeasures"); + if(wf2_countermeasures==null) { + wf2_countermeasures=" "; + } + String wf2_responsibleDpt = tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_responsibleDpt"); + if(wf2_responsibleDpt==null) { + wf2_responsibleDpt=" "; + } + Date last_mod_date = tcComponent.getDateProperty("last_mod_date"); //tcComponent.getStringProperty("last_mod_date").toString(); + String wf2_proofScheme = tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_proofScheme"); + if(wf2_proofScheme==null) { + wf2_proofScheme=" "; + } + String wf2_inventoryHandling = tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_inventoryHandling"); + if(wf2_inventoryHandling==null) { + wf2_inventoryHandling=" "; + } + String wf2_trackingBatch = tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_trackingBatch"); + if(wf2_trackingBatch==null) { + wf2_trackingBatch=" "; + } + String wf2_validationResults = tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_validationResults"); + if(wf2_validationResults==null) { + wf2_validationResults=" "; + } + String wf2_remarks = tcComponent.getReferenceListProperty("IMAN_master_form_rev")[0].getStringProperty("wf2_remarks"); + if(wf2_remarks==null) { + wf2_remarks=" "; + } + + dataset.add(new Problems(creation_date, wf2_problemDescr, wf2_countermeasures, wf2_responsibleDpt, last_mod_date, wf2_proofScheme, wf2_inventoryHandling, wf2_trackingBatch, wf2_validationResults, wf2_remarks)); + + } + + ReportExcels ex = new ReportExcels(); + + Date d = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + System.out.println(sdf.format(d)); + OutputStream out = new FileOutputStream(fpath); + ex.exportExcel(workbook, sheet, dataset, out, sdf.toString()); + + out.close(); + JOptionPane.showMessageDialog(null, "ɹ!"); + System.out.println("excelɹ"); + closeDialog(); + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + System.out.println("excelռ"); + MessageBox.post("excelռ,ȹر㱨excelʹøù", + "", MessageBox.ERROR); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + }); + + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + + + + } + private void closeDialog() { + disposeDialog(); + setVisible(false); +} + + //·ѡ + public String selectFileButtonEvent(){ + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath)); + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int state = jFileChooser.showOpenDialog(null); + if(state == 1) { + return null; + }else{ + File f = jFileChooser.getSelectedFile(); + return f.getAbsolutePath(); + } + } + +} diff --git a/src/com/connor/wf/plm/wf051/Wf051Handler.java b/src/com/connor/wf/plm/wf051/Wf051Handler.java new file mode 100644 index 0000000..6575bb7 --- /dev/null +++ b/src/com/connor/wf/plm/wf051/Wf051Handler.java @@ -0,0 +1,30 @@ +package com.connor.wf.plm.wf051; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.wf.plm.wf020.CreateChangeOrderDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +/** + * :Wf051Handler + * :㵼handler + * :2019-03-04 + * Ա ܾ + * + * ޸ ޸ ޸ + * + */ +public class Wf051Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + ReportProblemsDialog reportProblemsDialog = new ReportProblemsDialog(app); + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf052/WF052_2Dialog.java b/src/com/connor/wf/plm/wf052/WF052_2Dialog.java new file mode 100644 index 0000000..17076e8 --- /dev/null +++ b/src/com/connor/wf/plm/wf052/WF052_2Dialog.java @@ -0,0 +1,149 @@ +package com.connor.wf.plm.wf052; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileSystemView; + +import com.connor.wf.plm.wf046.ExportXMKB_Operation; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class WF052_2Dialog extends AbstractAIFDialog{ + private TCSession session; + private JTextField textField; + private JButton okButton; + private JButton celButton; + private JButton pathButton; + // ļѡ + private JFileChooser jFileChooser; + public WF052_2Dialog(TCSession session){ + this.session = session; + } + public void run(){ + initUI(); + } + private void initUI() { + // TODO Auto-generated method stub + FileSystemView fsv = FileSystemView.getFileSystemView(); // õϵͳfileview + String deskPath = fsv.getHomeDirectory().getPath(); // ǰû· + + this.setSize(new Dimension(600, 400)); + this.setTitle(""); + this.textField = new JTextField(deskPath); + + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath));// ļѡijʼĿ¼Ϊǰû + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + this.pathButton = new JButton("..."); + this.okButton = new JButton("ȷ"); + this.celButton = new JButton("ȡ"); + String name=""; + try { + name=session.getUser().getProperty("user_name"); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + JPanel midJPanel = new JPanel(new PropertyLayout()); + midJPanel.setBorder(new TitledBorder(BorderFactory + .createLineBorder(Color.WHITE), "ѡ񵼳·")); // ߿ TitleBorder + + midJPanel.add("1.1.left.top", new JLabel("·")); + midJPanel.add("1.2.left.top", this.textField); + midJPanel.add("1.3.left.top", this.pathButton); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(this.okButton); + rootJPanel.add(this.celButton); + + pathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + okEvent(); + + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + celEvent(); + + } + }); + + this.setLayout(new BorderLayout()); + this.add(midJPanel, BorderLayout.CENTER); + this.add(rootJPanel, BorderLayout.SOUTH); + + this.centerToScreen(); + this.pack(); + this.setVisible(true); + this.showDialog(); + } + + public void celEvent() { + // TODO Auto-generated method stub + this.disposeDialog(); + this.dispose(); + } + + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile();// fΪѡ񵽵Ŀ¼ + textField.setText(f.getAbsolutePath()); + } + } + + public void okEvent() { + + this.disposeDialog(); + this.dispose(); + + try { + String path=textField.getText(); + System.out.println("ok"); + + Wf052_2Operation op=new Wf052_2Operation(session,path); + session.queueOperation(op); + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} diff --git a/src/com/connor/wf/plm/wf052/Wf052AIFDialog.java b/src/com/connor/wf/plm/wf052/Wf052AIFDialog.java new file mode 100644 index 0000000..b72a29e --- /dev/null +++ b/src/com/connor/wf/plm/wf052/Wf052AIFDialog.java @@ -0,0 +1,335 @@ +package com.connor.wf.plm.wf052; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf052AIFDialog extends AbstractAIFDialog { + private TCSession session; + private InterfaceAIFComponent targetComp; + private JTextField text; + private JFileChooser jFileChooser; + private XSSFSheet sheet ; + private XSSFCellStyle cellStyle; + public Wf052AIFDialog(TCSession arg0,InterfaceAIFComponent arg1){ + this.session = arg0; + this.targetComp = arg1; + } + + public void run(){ + init(); + } + + public void init(){ + System.out.println("init()"); + this.setTitle("ȴտ"); + this.setPreferredSize(new Dimension(250, 150)); + this.setLayout(new PropertyLayout()); + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + text=new JTextField(12); + JButton okBut = new JButton("ȷ"); + JButton celBut = new JButton("ȡ"); + + panel.add("1.1.left.center", new JLabel("")); + panel.add("2.1.left.center", new JLabel("")); + panel.add("3.1.left.center", new JLabel("")); + panel.add("4.1.left.center.preferred.preferred",new JLabel(" Ŀţ")); + panel.add("4.2.right.center.perferred.perferred",text); + panel.add("5.1.left.center", new JLabel("")); + panel.add("6.1.left.center", new JLabel("")); + + buttonPanel.add(okBut); + buttonPanel.add(celBut); + + this.add("1.1.center.top.preferred.preferred", panel); + this.add("2.1.center.top.preferred.preferred", buttonPanel); + + setVisible(true); + this.centerToScreen(); + this.setAlwaysOnTop(true); + this.pack(); + + okBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if(text.getText().equals("")){ + MessageBox.post("Ŀ!!","", MessageBox.ERROR); + return; + }else{ + getValuesToExcel(); + } + } + }); + + celBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + } + + public void getValuesToExcel(){ + FileInputStream fis=null; + FileOutputStream fos=null; + String puid = session.getPreferenceService().getStringValue( + "WF2_Heat_Treatment_puid"); + if (puid == null||puid.equals("")) { + + MessageBox.post("ѡWF2_Heat_Treatment_puidδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + try{ + String path = null; + TCComponent[] components=session.search("...", new String[]{ " ID" }, new String[]{"T"+text.getText()}); + if (components!=null&&components.length>0) { + System.out.println("="+components.length); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//ڸʽ + path = selectFileButtonEvent()+"\\ȴտ_"+df.format(new Date())+".xlsx"; + System.out.println("path="+path); + }else{ + MessageBox.post("Ҳ!!","", MessageBox.ERROR); + return; + } + TCComponentItemRevision rev = ((TCComponentItem) components[0]).getLatestItemRevision(); + System.out.println("rev="+rev); + TCComponent[] referenceListPropertys = rev.getReferenceListProperty("WF2_moldRe");//WF3_moju + System.out.println("referenceListPropertys.length="+referenceListPropertys.length); + + List list = new ArrayList<>(); + if(referenceListPropertys!=null && referenceListPropertys.length>0){ + for(int i=0;i0){ + TCComponentTcFile[] file = ((TCComponentDataset) tccd[0]).getTcFiles(); + if(file != null && file.length >0){ + File fmsFile = file[0].getFmsFile(); + System.out.println("fmsFile.getName()="+fmsFile.getName()+" i="+i); + if(fmsFile!=null){ + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + ImageIO.write(ImageIO.read(fmsFile), "jpg", byteArrayOut); + XSSFDrawing patriarch = sheet.createDrawingPatriarch(); + XSSFClientAnchor anchor = new XSSFClientAnchor(50, 10, 1000, 240,(short) 1, i+2, (short)2, i+3); + anchor.setAnchorType(3); + patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG)); + } + } + } + + cell = row.getCell(2); + if(cell == null){ + cell = row.createCell(2); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(revt.getProperty("wf2_customerName")); + + cell = row.getCell(3); + if(cell == null){ + cell = row.createCell(3); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(revt.getProperty("wf2_productName")); + + cell = row.getCell(4); + if(cell == null){ + cell = row.createCell(4); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(revt.getTCProperty("wf2_preDrillCenHolesize").getDisplayableValue()); + + cell = row.getCell(5); + if(cell == null){ + cell = row.createCell(5); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(revt.getProperty("wf2_moldNumber")); + + cell = row.getCell(6); + if(cell == null){ + cell = row.createCell(6); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(revt.getProperty("wf2_revDimensionA")); + + cell = row.getCell(7); + if(cell == null){ + cell = row.createCell(7); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(revt.getProperty("wf2_productHardness")); + + cell = row.getCell(8); + if(cell == null){ + cell = row.createCell(8); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(revt.getProperty("wf2_steelTempPosition")); + + cell = row.getCell(9); + if(cell == null){ + cell = row.createCell(9); + cell.setCellStyle(cellStyle); + } + cell.setCellValue(revt.getTCProperty("wf2_agingType").getDisplayableValue()); + } + } + + fos = new FileOutputStream(new File(path)); + workbook.write(fos); + Runtime.getRuntime().exec((new StringBuilder("cmd /c \"")).append(path).append("\"").toString()); + + setVisible(false); +/* if(list!=null && list.size()>0){ + String[] title = { "", "ͼ", "ͻ", "Ʒ", "Ԥ״С", "ģ", "УߴA", "ƷӲ", "ֺλ", "ʱЧʽ"}; + values = new Object[list.size() + 2][title.length]; + values[0][0] = "ȴտ"; + for (int m = 0; m < title.length; m++) { + values[1][m] = title[m]; + } + for(int i=0;i0){ + TCComponentTcFile[] file = ((TCComponentDataset) tccd[0]).getTcFiles(); + if(file != null && file.length >0){ + File fmsFile = file[0].getFmsFile(); + System.out.println("fmsFile.getName()="+fmsFile.getName()+" i="+i); + if(fmsFile.getName().endsWith("jpg")||fmsFile.getName().endsWith("JPG")){ + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + ImageIO.write(ImageIO.read(fmsFile), "jpg", byteArrayOut); + values[i + 2][1] = byteArrayOut; + } + } + } + values[i + 2][2]=list.get(i).getProperty("wf2_customerName"); + values[i + 2][3]=list.get(i).getProperty("wf2_productName"); + values[i + 2][4]=list.get(i).getTCProperty("wf2_preDrillCenHolesize").getDisplayableValue(); + values[i + 2][5]=list.get(i).getProperty("wf2_moldNumber"); + values[i + 2][6]=list.get(i).getProperty("wf2_revDimensionA"); + values[i + 2][7]=list.get(i).getProperty("wf2_productHardness"); + values[i + 2][8]=list.get(i).getProperty("wf2_steelTempPosition"); + values[i + 2][9]=list.get(i).getTCProperty("wf2_agingType").getDisplayableValue(); + } + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet("sheet1"); + ExcelUtil.writeArrayToExcel(wb, sheet, list.size() + 2, title.length, values); + ExcelUtil.writeWorkbook(wb, path); + }*/ + + } catch (IOException e){ + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //·ѡ + public String selectFileButtonEvent(){ + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath)); + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int state = jFileChooser.showOpenDialog(null); + if(state == 1) { + return null; + }else{ + File f = jFileChooser.getSelectedFile(); + return f.getAbsolutePath(); + } + } +} diff --git a/src/com/connor/wf/plm/wf052/Wf052Handler.java b/src/com/connor/wf/plm/wf052/Wf052Handler.java new file mode 100644 index 0000000..174715a --- /dev/null +++ b/src/com/connor/wf/plm/wf052/Wf052Handler.java @@ -0,0 +1,23 @@ +package com.connor.wf.plm.wf052; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf052Handler extends AbstractHandler { + + public Object execute(ExecutionEvent event) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + Wf052AIFDialog dialog = new Wf052AIFDialog(session,targetComp); + new Thread(dialog).start(); + return null; + } +} diff --git a/src/com/connor/wf/plm/wf052/Wf052_2Handler.java b/src/com/connor/wf/plm/wf052/Wf052_2Handler.java new file mode 100644 index 0000000..f313597 --- /dev/null +++ b/src/com/connor/wf/plm/wf052/Wf052_2Handler.java @@ -0,0 +1,22 @@ +package com.connor.wf.plm.wf052; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf052_2Handler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + WF052_2Dialog dialog = new WF052_2Dialog(session); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf052/Wf052_2Operation.java b/src/com/connor/wf/plm/wf052/Wf052_2Operation.java new file mode 100644 index 0000000..be37446 --- /dev/null +++ b/src/com/connor/wf/plm/wf052/Wf052_2Operation.java @@ -0,0 +1,436 @@ +package com.connor.wf.plm.wf052; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +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.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import javax.imageio.ImageIO; + +import org.apache.commons.lang.StringUtils; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFPicture; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + + +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf052_2Operation extends AbstractAIFOperation{ + private TCSession session; + private TCPreferenceService service; + private String outPutFile; + private ProgressBarThread wait; + public Wf052_2Operation(TCSession session,String outPutFile){ + this.session = session; + this.service = session.getPreferenceService(); + this.outPutFile = outPutFile; + + } + @Override + public void executeOperation() throws Exception { + String[] keys = new String[]{""}; + String[] values = new String[]{"WF2_2DprodDraw"}; + List compList = queryObject("...", keys, values); + String puid = service.getStringValue("WF2_rechuli_Excel"); + TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(puid); + File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// ڸʽ + String time = df.format(new Date()); + outPutFile = outPutFile + File.separator + "ȴտ" + time + ".xlsx"; + wait = new ProgressBarThread("ɱ", + "УԵ..."); + wait.start();// + try { + writeExcel(compList,file,outPutFile); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ"+e.getMessage(),"",MessageBox.ERROR); + return; + } + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱ,鿴","",MessageBox.INFORMATION); + Runtime.getRuntime().exec("cmd /c \"" + outPutFile + "\""); + } + /** + * ͨѯѯƷͼ + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName ,String[] keys,String[] values){ + TCComponent[] components = null; + try { + 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; + } + } + public void writeExcel(List compList, File file,String outPutFile){ + BufferedImage bufferImg = null; + try { + FileInputStream is = new FileInputStream(file); + + XSSFWorkbook wb = new XSSFWorkbook(is); + + XSSFSheet sheet = wb.getSheetAt(0); + int k = 3; + int num = 1; + int start = k; + XSSFRow targetRow = sheet.getRow(3); + short h = targetRow.getHeight(); + XSSFCell targetCell = targetRow.getCell(0); + XSSFCellStyle cellStyle = targetCell.getCellStyle(); + for (int i = 0; i < compList.size(); i++) { + String celiangValue =""; + TCComponentDataset img = null; + TCComponentDataset product = null; + TCComponentItemRevision itemRev = null; + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + List nameList = new ArrayList(); + List itemList = new ArrayList(); + TCComponentItem item = (TCComponentItem) compList.get(i); + try { + itemRev = item.getLatestItemRevision(); + TCComponent[] properties = itemRev.getReferenceListProperty("WF2_moldRe"); + if(properties == null || properties.length <= 0){ + continue; + } + for(int o = 0;o < properties.length;o++){ + String name = properties[o].getStringProperty("object_name"); + String id = properties[o].getStringProperty("item_id"); + System.out.println("name==================="+name); + System.out.println("id==================="+id); + if(name.contains("-")){ + String[] names = name.split("-"); + name = names[1]; + } + if(id.contains(".")){ + System.out.println("id2===================="+id); + String[] ids = id.split("\\."); + String moldNum = ids[0]+"-"+name; + if(!nameList.contains(moldNum)){ + nameList.add(moldNum); + itemList.add(properties[o]); + } + }else{ + String moldNum = id+"-"+name; + if(!nameList.contains(moldNum)){ + nameList.add(moldNum); + itemList.add(properties[o]); + } + } + } + for(int o = 0;o < itemList.size();o++){ + XSSFRow row = sheet.getRow(k); + if(row == null){ + row = sheet.createRow(k); + } + row.setHeight(h); + k++; + String descValue =""; + String cellValue =""; + String diameter =""; + for(int p = 0;p < 9;p++){ + XSSFCell cell = row.getCell(p); + if(cell == null){ + cell = row.createCell(p); + } + cell.setCellStyle(cellStyle); + if(p == 3){ + TCComponentItemRevision rev = ((TCComponentItem)(itemList.get(o))).getLatestItemRevision(); + TCComponent[] rechuli = rev.getReferenceListProperty("WF2_hTrtProCdRe"); + if(rechuli != null && rechuli.length > 0){ + TCComponentItemRevision rechuliRev = ((TCComponentItem)rechuli[0]).getLatestItemRevision(); + TCComponent[] datasets = rechuliRev.getReferenceListProperty("IMAN_specification"); + + for(int j = 0;j < datasets.length;j++){ + String type = datasets[j].getType(); + if("TIF".equals(type)){ + img = (TCComponentDataset) datasets[j]; + } + if("MSExcelX".equals(type)){ + TCComponentDataset dataset = (TCComponentDataset) datasets[j]; + TCComponentTcFile[] files = dataset.getTcFiles(); + try { + if(files != null && files.length > 0){ + File file1 = files[0].getFmsFile(); + FileInputStream in = new FileInputStream(file1); + XSSFWorkbook wb1 = new XSSFWorkbook(in); + XSSFSheet sheet1 = wb1.getSheetAt(0); + XSSFRow row1 = sheet1.getRow(11); + XSSFCell cell1 = row1.getCell(15); + cellValue = getCellValue(cell1); + XSSFRow row2 = sheet1.getRow(14); + XSSFCell cell2 = row2.getCell(13); + descValue = getCellValue(cell2); + XSSFRow row3 = sheet1.getRow(4); + XSSFCell cell3 = row3.getCell(13); + celiangValue = getCellValue(cell3); + XSSFRow row4 = sheet1.getRow(4); + XSSFCell cell4 = row4.getCell(5); + diameter = getCellValue(cell4); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + if(diameter != null && diameter != ""){ + cell.setCellValue(diameter); + } + } + if(p == 4){ + String moldNum = nameList.get(o); + cell.setCellValue(moldNum); + } + if(p == 5){ + if(cellValue != null && cellValue != ""){ + cell.setCellValue(cellValue); + } + } + if(p == 7){ + if(descValue != null && descValue != ""){ + cell.setCellValue(descValue); + } + } + } + CellRangeAddress region = new CellRangeAddress(k-1, k-1, 7, 8); + sheet.addMergedRegion(region); + + } + if(itemList.size()<6){ + int n = itemList.size(); + n = 6-n; + for(int b=0;b getValues(){ + List list = new ArrayList<>(); + List tages = new ArrayList<>(); + List tvalues = new ArrayList<>(); + if(text1.getText()==null || text1.getText().equals("")) { + }else{ + tages.add("ͻ"); + tvalues.add(text1.getText()); + } + if(text2.getText()==null || text2.getText().equals("")) { + }else{ + tages.add("ƽ̨"); + tvalues.add(text2.getText()); + } + if(text3.getText()==null || text3.getText().equals("")) { + }else{ + tages.add(""); + tvalues.add(text3.getText()); + } + if(text4.getText()==null || text4.getText().equals("")) { + }else{ + tages.add("ֱ"); + tvalues.add(text4.getText()); + } + tages.add(""); + tvalues.add("*"); + + String[] array1 = new String[tages.size()]; + String[] s1=tages.toArray(array1); + + String[] array2 = new String[tvalues.size()]; + String[] s2=tvalues.toArray(array2); + + try { + TCComponent[] components=session.search("Ʒ",s1,s2); + System.out.println("="+components.length); + if (components!=null && components.length>0) { + for (int i = 0; i < components.length; i++) { + System.out.println("="+components[i]+";="+components[i].getType()); + if(components[i].getType().equals("WF2_finPartRevision")){ + TCComponent[] referenceListPropertys = components[i].getReferenceListProperty("IMAN_master_form_rev"); + list.add(referenceListPropertys[0]); + System.out.println("i="+i+";list.size()="+list.size()); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return list; + } + + private void valuesToExcelt(List list,String path){ + FileInputStream fis=null; + FileOutputStream fos=null; + String puid = session.getPreferenceService().getStringValue( + "WF2_Product_Summary_puid"); + if (puid == null||puid.equals("")) { + + MessageBox.post("ѡWF2_Product_Summary_puidδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + try{ + TCComponentDataset excelData = (TCComponentDataset) session.stringToComponent(puid); + File filet=((TCComponentDataset)excelData).getTcFiles()[0].getFmsFile(); + fis = new FileInputStream(filet); + System.out.println("fis:"+fis); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + System.out.println("workBook:"+workbook); + sheet = workbook.getSheetAt(0); + cellStyle = workbook.createCellStyle(); + System.out.println("list.size()="+list.size()); + if(list!=null && list.size()>0){ + for(int i=0;i list,String fpath){ + try{ + if(list!=null && list.size()>0){ + String[] title = { "", "ͼ", "Ϻ", "ͻ", "ƽ̨", "()", "(ֱ)"}; + values = new Object[list.size() + 2][title.length]; + values[0][0] = "Ʒ"; + for (int m = 0; m < title.length; m++) { + values[1][m] = title[m]; + } + for(int i=0;i0){ + TCComponentTcFile[] file = ((TCComponentDataset) tccd[0]).getTcFiles(); + if(file != null && file.length >0){ + File fmsFile = file[0].getFmsFile(); + System.out.println("fmsFile.getName()="+fmsFile.getName()+" i="+i); + if(fmsFile.getName().endsWith("jpg")||fmsFile.getName().endsWith("JPG")){ + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + ImageIO.write(ImageIO.read(fmsFile), "jpg", byteArrayOut); + values[i + 2][1] = byteArrayOut; + } + } + } + values[i + 2][2]=list.get(i).getProperty("wf2_wfPartNumber"); + values[i + 2][3]=list.get(i).getProperty("wf2_customerName"); + values[i + 2][4]=list.get(i).getProperty("wf2_vehiclePlatform"); + values[i + 2][5]=list.get(i).getProperty("wf2_sizeWidth"); + values[i + 2][6]=list.get(i).getProperty("wf2_sizeDiameter"); + } + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet("sheet1"); + ExcelUtil.writeArrayToExcel(wb, sheet, list.size() + 2, title.length, values); + ExcelUtil.writeWorkbook(wb, fpath); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }*/ + + //·ѡ + public String selectFileButtonEvent(){ + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath)); + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int state = jFileChooser.showOpenDialog(null); + if(state == 1) { + return null; + }else{ + File f = jFileChooser.getSelectedFile(); + return f.getAbsolutePath(); + } + } +} diff --git a/src/com/connor/wf/plm/wf053/Wf053Handler.java b/src/com/connor/wf/plm/wf053/Wf053Handler.java new file mode 100644 index 0000000..c7491e0 --- /dev/null +++ b/src/com/connor/wf/plm/wf053/Wf053Handler.java @@ -0,0 +1,25 @@ +package com.connor.wf.plm.wf053; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf053Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + Wf053AIFDialog dialog = new Wf053AIFDialog(session,targetComp); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf057/Test.java b/src/com/connor/wf/plm/wf057/Test.java new file mode 100644 index 0000000..e4ea8cb --- /dev/null +++ b/src/com/connor/wf/plm/wf057/Test.java @@ -0,0 +1,86 @@ +package com.connor.wf.plm.wf057; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFPicture; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class Test { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + FileOutputStream fileOut =null; + BufferedImage bufferImg =null; + // ȰѶͼƬŵһByteArrayOutputStreamУԱByteArray + try { + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + bufferImg = ImageIO.read(new File("D:/a.png")); + ImageIO.write(bufferImg, "jpg", byteArrayOut); + + XSSFWorkbook wb = new XSSFWorkbook(); + XSSFSheet sheet1 = wb.createSheet("test picture"); + // ͼĶһsheetֻܻȡһһҪע㣩 + XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); + // XSSFClientAnchor anchor1 = new XSSFClientAnchor(0, 0, + // 1023,100,(short) 1, 1, (short)5, 8); + // XSSFClientAnchor anchor2 = new XSSFClientAnchor(0, 0, + // 1023,100,(short) 1, 9, (short)5, 16); + // //ͼƬ + // patriarch.createPicture(anchor1, + // wb.addPicture(byteArrayOut.toByteArray(), + // XSSFWorkbook.PICTURE_TYPE_JPEG)); + // patriarch.createPicture(anchor2, + // wb.addPicture(byteArrayOut.toByteArray(), + // XSSFWorkbook.PICTURE_TYPE_JPEG)); + // anchorҪͼƬ + XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 255, 255, (short) 1, 1, (short) 5, 8); + anchor.setAnchorType(3); + // ͼƬ + patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); + fileOut = new FileOutputStream("D:/Excel.xlsx"); + // дexcelļ + wb.write(fileOut); + System.out.println("----2007Excleļ------"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (fileOut != null) { + try { + fileOut.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + public static void testDrawImg(XSSFWorkbook wb, XSSFDrawing drawing, + String imgSrc, int col, int row) throws FileNotFoundException, + IOException { + + int pictureIdx = wb.addPicture( + IOUtils.toByteArray(new FileInputStream(imgSrc)), + Workbook.PICTURE_TYPE_PNG); + XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 500, 250, + (short) col, row, (short) col, row); + XSSFPicture pict = drawing.createPicture(anchor, pictureIdx); + pict.resize(0.5); + } + +} diff --git a/src/com/connor/wf/plm/wf057/Wf057AIFDialog.java b/src/com/connor/wf/plm/wf057/Wf057AIFDialog.java new file mode 100644 index 0000000..ea4255f --- /dev/null +++ b/src/com/connor/wf/plm/wf057/Wf057AIFDialog.java @@ -0,0 +1,786 @@ +package com.connor.wf.plm.wf057; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +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.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeNode; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.wf.plm.util.CodeBean; +import com.connor.wf.plm.util.CopyPropsBean; +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.GetCodeBean; +import com.connor.wf.plm.util.MenuBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.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.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf057AIFDialog extends AbstractAIFDialog { + private TCSession session; + private InterfaceAIFComponent targetComp; + private String name; + private MenuBean menuBean; + private JPanel jp1; + private JPanel jp2; + private JTextField jtext1; + private JTextField jtext2; + private JTextField jtext3; + private JLabel jl4; + private JLabel jl5; + // private List codeBeanList; + private CodeBean selCodeBean; + private JButton okBut = new JButton("ȷ"); + private JButton celBut = new JButton("ȡ"); + private GetCodeBean getcode; + private String selnodename = ""; + private JComboBox jcom; + private JComboBox jcom1; + private Map map = new HashMap(); + private Map map1 = new HashMap(); + private JComboBox jcomname = new JComboBox(); + private Map nameMap = new HashMap<>(); + private boolean islov = false; + private String datasetUid = ""; + private String datasetUid1 = ""; + + public Wf057AIFDialog(TCSession session, InterfaceAIFComponent targetComp, + String name) { + this.session = session; + this.targetComp = targetComp; + this.name = name; + if (name.equals("")) { + datasetUid = "WF2_pkgMaterial_Dataset"; + datasetUid1 = "WF2_subPartDraw_Dataset"; + } + } + + @Override + public void run() { + // TODO Auto-generated method stub + getcode = new GetCodeBean(session); + menuBean = getcode.getMenuBean(name); + load(datasetUid,map); + load(datasetUid1,map1); + // codeBeanList = bean.getCodeBeanList(); + init(); + + } + + /** + * жǷlov + */ + private void getNameLov(String type) { + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + TCPropertyDescriptor propertyDescriptor = tctype + .getPropertyDescriptor("object_name"); + TCComponentListOfValues lov = propertyDescriptor.getLOV(); + if (lov != null) { + islov = true; + String[] strs = lov.getListOfValues().getStringListOfValues();// ʵֵ + for (String s1 : strs) { + String a1 = lov.getListOfValues().getDisplayableValue(s1);// ʵֵӦʾֵ + jcomname.addItem(a1); + nameMap.put(a1, s1);// ʾ:ʵ + } + } else { + islov = false; + } + if (islov) { + jp2.add("6.2.left.center", jcomname); + } else { + jp2.add("6.2.left.center", jtext3); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ģ + */ + private void load(String uid,Map valueMap) { + // TODO Auto-generated method stub + String[] stringArray = session.getPreferenceService().getStringValues( + uid); + if (stringArray != null && stringArray.length > 0) { + for (int i = 0; i < stringArray.length; i++) { + String[] split = stringArray[i].split("="); + if (split != null && split.length == 2) { + valueMap.put(split[1], split[0]); + } + } + } + } + + /** + * ҳ + */ + private void init() { + // TODO Auto-generated method stub + this.setTitle("" + name); + this.setPreferredSize(new Dimension(500, 340)); + this.setLayout(new PropertyLayout()); + jp1 = new JPanel(new BorderLayout()); + jp2 = new JPanel(new PropertyLayout()); + jp1.setPreferredSize(new Dimension(250, 250)); + jp2.setPreferredSize(new Dimension(250, 250)); + JTree tree = getTree(menuBean); + tree.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e + .getPath().getLastPathComponent(); + int childCount = treeNode.getChildCount(); + System.out.println("ǰѡеĽڵ: " + treeNode + " ӽڵ:" + + childCount); + selnodename = ""; + if (childCount > 0) { + jp2.setVisible(false); + } else { + jp2.setVisible(true); + setTextStr(treeNode); + } + + } + }); + JScrollPane scrollPane = new JScrollPane(tree); + scrollPane.setPreferredSize(new Dimension(250, 250)); + ; + // ӹ嵽 + jp1.add(scrollPane, BorderLayout.CENTER); + + JLabel jl1 = new JLabel("룺"); + JLabel jl2 = new JLabel("汾"); + JLabel jl3 = new JLabel("ƣ"); + jtext1 = new JTextField(12); + jtext2 = new JTextField(12); + jtext3 = new JTextField(12); + jtext1.setEnabled(false); + jtext2.setEnabled(false); + jcomname.setEnabled(false); + + jl4 = new JLabel("ĵģ壺"); + jcom = new JComboBox(); + for (String key : map.keySet()) { + jcom.addItem(key); + } + jl5 = new JLabel("ͼֽģ壺"); + jcom1 = new JComboBox(); + for (String key : map1.keySet()) { + jcom1.addItem(key); + } + + jp2.add("1.1.left.center", new JLabel("")); + jp2.add("2.1.center.center", jl1); + jp2.add("2.2.left.center", jtext1); + jp2.add("3.1.left.center", new JLabel("")); + jp2.add("4.1.center.center", jl2); + jp2.add("4.2.left.center", jtext2); + jp2.add("5.1.left.center", new JLabel("")); + jp2.add("6.1.center.center", jl3); + jp2.add("7.1.left.center", new JLabel("")); + jp2.add("8.1.center.center", jl5); + jp2.add("8.2.left.center", jcom1); + jp2.add("9.1.center.center", jl4); + jp2.add("9.2.left.center", jcom); + jp2.setVisible(false); + + add("1.1.center.center", jp1); + add("1.2.center.center", jp2); + add("2.1.center.center", okBut); + add("2.2.center.center", celBut); + okBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȷ"); + if (jp2.isVisible()) { + String itemName = ""; + if (islov) { + itemName = (String) jcomname.getSelectedItem(); + if (!nameMap.containsKey(itemName)) { + MessageBox.post("ƴ,Χѡ!", "ʾ", + MessageBox.INFORMATION); + } + } else { + itemName = jtext3.getText(); + } + if (!itemName.equals("")) { + createItem(); + } else { + MessageBox.post("ƲΪ!", "ʾ", MessageBox.INFORMATION); + } + } else { + MessageBox.post("ѡ񴴽!", "ʾ", MessageBox.INFORMATION); + } + + } + }); + celBut.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("ȡ"); + setVisible(false); + } + }); + this.setVisible(true); + this.centerToScreen(); + // this.pack(); + } + + /** + * ¼ + */ + protected void createItem() { + // TODO Auto-generated method stub + try { + String type = selCodeBean.getType(); + DataBaseControl data = new DataBaseControl(session); + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + this.setVisible(false); + if (selnodename.equals("Ʒǩ")) { + if (targetComp == null + || !(targetComp instanceof TCComponentItemRevision)) { + MessageBox.post("ĶΪƷǩ,ֻѡгƷ汾,ִд˲!!!", "", 0); + return; + } else { + if (!targetComp.getType().equals("WF2_finPartRevision")) { + MessageBox.post("ĶΪƷǩ,ֻѡгƷ汾,ִд˲!!!", "", + 0); + return; + } + } + } + + try { + String newID = data.getNewCode("PLMCODE", selCodeBean); + TCComponentItem find = tctype.find(newID); + if (find != null) { + MessageBox.post("ǰˮID:" + newID + "Ѵڶ,޷!", "", + MessageBox.ERROR); + } else { + this.setVisible(false); + String itemName = ""; + if (islov) { + itemName = (String) jcomname.getSelectedItem(); + itemName = nameMap.get(itemName); + } else { + itemName = jtext3.getText(); + } + TCComponentItem item = tctype.create(newID, + jtext2.getText(), type, itemName, "", null); + String picstr = jcom1.getSelectedItem().toString(); + if (!picstr.equals("") && map1.containsKey(picstr)) { + String uid = map1.get(picstr); + TCComponentItemRevision rev = item + .getLatestItemRevision(); + String idstr = rev.getTCProperty("item_id") + .getStringValue(); + String revidstr = rev.getTCProperty( + "item_revision_id").getStringValue(); + TCComponentDataset dataset = (TCComponentDataset) session + .stringToComponent(uid); + TCComponentDataset newData = dataset.saveAs(idstr + + "/" + revidstr); + rev.add("IMAN_specification", newData); + File file = setDataset(newData, targetComp, picstr, + rev); + } + if (jcom.isVisible()) { + String boxstr = jcom.getSelectedItem().toString(); + if (!boxstr.equals("") && map.containsKey(boxstr)) { + String uid = map.get(boxstr); + TCComponentItemRevision rev = item + .getLatestItemRevision(); + String idstr = rev.getTCProperty("item_id") + .getStringValue(); + String revidstr = rev.getTCProperty( + "item_revision_id").getStringValue(); + TCComponentDataset dataset = (TCComponentDataset) session + .stringToComponent(uid); + TCComponentDataset newData = dataset.saveAs(idstr + + "/" + revidstr); + rev.add("IMAN_specification", newData); + File file = setDataset(newData, targetComp, boxstr, + rev); + if (file != null) { + newData.setFiles( + new String[] { file.getPath() }, + new String[] { "excel" }); + } + } + } + + System.out.println("ʼͬѡԵ"); + CopyPropsBean copyPropBean = selCodeBean.getCopyPropBean(); + if (copyPropBean != null) { + String type2 = copyPropBean.getType(); + List props = copyPropBean.getProps(); + if (targetComp != null + && targetComp.getType().equals(type2)) { + boolean isok = true; + TCComponentItemRevision furev = null; + if (targetComp instanceof TCComponentItemRevision) { + furev = (TCComponentItemRevision) targetComp; + } else if (targetComp instanceof TCComponentItem) { + furev = ((TCComponentItem) targetComp) + .getLatestItemRevision(); + } else { + isok = false; + System.out.println("ְֻ֧汾Ͷ"); + } + if (props != null && props.size() > 0 && isok) { + for (int i = 0; i < props.size(); i++) { + String[] split = props.get(i).split("="); + if (split != null && split.length == 2) { + String propstr = ""; + if (split[0].startsWith("ITEM.")) { + TCComponentItem com = furev + .getItem(); + propstr = com.getTCProperty( + split[0].substring(5)) + .getStringValue(); + } else if (split[0].startsWith("REV.")) { + TCComponentItemRevision com = furev; + propstr = com.getTCProperty( + split[0].substring(4)) + .getStringValue(); + } else if (split[0].startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) furev + .getReferenceListProperty("IMAN_master_form_rev")[0]; + propstr = com.getTCProperty( + split[0].substring(5)) + .getStringValue(); + } + if (propstr != null + && !propstr.equals("")) { + if (split[1].startsWith("ITEM.")) { + TCComponentItem com = item; + com.getTCProperty( + split[1].substring(5)) + .setStringValue(propstr); + } else if (split[1] + .startsWith("REV.")) { + TCComponentItemRevision com = item + .getLatestItemRevision(); + com.getTCProperty( + split[1].substring(4)) + .setStringValue(propstr); + } else if (split[1] + .startsWith("FORM.")) { + TCComponentForm com = (TCComponentForm) item + .getLatestItemRevision() + .getReferenceListProperty( + "IMAN_master_form_rev")[0]; + com.getTCProperty( + split[1].substring(5)) + .setStringValue(propstr); + } + } + + } + } + } + } + } else { + System.out.println("δͬ,ͬ"); + } + + boolean isNewStuff = true; + if (targetComp == null) { + session.getUser().getNewStuffFolder() + .add("contents", item); + } else if (targetComp instanceof TCComponentFolder) { + ((TCComponentFolder) targetComp).add("contents", item); + isNewStuff = false; + } else { + session.getUser().getNewStuffFolder() + .add("contents", item); + } + String classid = selCodeBean.getClassID(); + if (classid != null && !classid.equals("")) { + Wf057Operation op = new Wf057Operation(session, + classid, item.getLatestItemRevision(), + new Integer[] {}, new String[] {}); + session.queueOperation(op); + } else { + System.out.println("δҵ͵ķid,"); + } + if (isNewStuff) { + MessageBox.post("" + item + "ɹ,NewStuffļ²鿴!", + "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post("" + item + "ɹ,ڵǰļ²鿴!", "ɹ", + MessageBox.INFORMATION); + } + + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(":" + e.getMessage(), "", + MessageBox.INFORMATION); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ݼ + * + * @param dataset + * ݼ + * @param targetComp2 + * ѡгƷ + * @param name + * Ӣİ汾 + * @param newrev + * ¶汾 + */ + private File setDataset(TCComponentDataset dataset, + InterfaceAIFComponent targetComp2, String name, + TCComponentItemRevision newrev) { + // TODO Auto-generated method stub + File fileout = null; + String pro = "WF2_pkgMaterial_Dataset_CN"; + if (name.contains("Ӣ")) { + pro = "WF2_pkgMaterial_Dataset_EN"; + } + if (targetComp2 instanceof TCComponentItemRevision) { + + String[] prostrs = session.getPreferenceService().getStringValues( + pro); + try { + File jpgfile=getCptjpg((TCComponentItemRevision)targetComp2); + FileInputStream fis = null; + FileOutputStream fos = null; + XSSFWorkbook workBook = null; + try { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComp2; + TCComponentItem item = rev.getItem(); + TCComponent form = rev + .getReferenceListProperty("IMAN_master_form_rev")[0]; + TCComponentItem newitem = newrev.getItem(); + TCComponent newform = newrev + .getReferenceListProperty("IMAN_master_form_rev")[0]; + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + File fmsFile = tcFiles[0].getFmsFile(); + System.out.println("fmsFile=" + fmsFile); + // File file=getFile(fmsFile); + fis = new FileInputStream(fmsFile); + workBook = new XSSFWorkbook(fis); + XSSFSheet sheet = workBook.getSheetAt(0); + if (prostrs != null && prostrs.length > 0) { + for (int i = 0; i < prostrs.length; i++) { + String str = prostrs[i]; + System.out.println("------" + str); + String[] split = str.split("="); + int row = Integer.parseInt(split[0]); + int col = Integer.parseInt(split[1]); + XSSFCell cell = sheet.getRow(row - 1).getCell( + col - 1); + if (cell == null) { + System.out.println("Ԫ:" + row + "--" + col + + ""); + continue; + } + if (split[2].equals("")) { + String cpname = rev.getProperty("object_name"); + String cpcode = form.getProperty("wf2_wfPartNumber"); + if (cpname!=null&&cpcode!=null) { + String ljmc=cpname+cpcode; + System.out.println("ljmc="+ljmc); + cell.setCellValue(ljmc); + } + + }if (split[2].equals("ͼƬ")) { + if (jpgfile!=null) { + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + BufferedImage bufferImg = ImageIO.read(jpgfile); + ImageIO.write(bufferImg, "jpg", byteArrayOut); + + XSSFDrawing patriarch = sheet.createDrawingPatriarch(); + XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 350, 350, (short) (col-1), row-1, (short) (col+17), row+17); + anchor.setAnchorType(3); + // ͼƬ + patriarch.createPicture(anchor, workBook.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); + }else{ + System.out.println("δҵͼƬ"); + } + + }else if (split[2].contains(".")) { + String val = ""; + String str1 = split[2].split("\\.")[0]; + String str2 = split[2].split("\\.")[1]; + if (str1.toUpperCase().equals("REV")) { + val = rev.getProperty(str2); + } else if (str1.toUpperCase().equals("FORM")) { + val = form.getProperty(str2); + } else if (str1.toUpperCase().equals("ITEM")) { + val = item.getProperty(str2); + } else if (str1.toUpperCase().equals("NEWITEM")) { + val = newitem.getProperty(str2); + } else if (str1.toUpperCase().equals("NEWFORM")) { + val = newform.getProperty(str2); + } else if (str1.toUpperCase().equals("NEWREV")) { + val = newrev.getProperty(str2); + } + System.out.println("val="+val ); + int celltype=cell.getCellType(); + System.out.println("celltype="+celltype ); + if (celltype ==3||celltype==1) { + if (val != null) { + cell.setCellValue(val); + } else { + cell.setCellValue(""); + } + } + + } + } + + } + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// ڸʽ + String time = df.format(new Date()); + String excelPath = System.getenv("TEMP") + File.separator + + "WFƷǩ" + time + ".xlsx"; + fileout = new File(excelPath); + System.out.println("excelPath=" + excelPath); + fos = new FileOutputStream(fileout); + workBook.write(fos); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + + if (fos != null) { + fos.close(); + } + if (fis != null) { + fis.close(); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return fileout; + } + + + /** + * òƷͼ¹ҵͼƬļ + * @param rev + * @return + */ + private File getCptjpg(TCComponentItemRevision rev) { + // TODO Auto-generated method stub + try { + TCComponent[] cpts = rev.getReferenceListProperty("TC_Is_Represented_By"); + if (cpts!=null&&cpts.length>0) { + TCComponent[] datasets = cpts[0].getReferenceListProperty("IMAN_specification"); + if (datasets!=null&&datasets.length>0) { + for (int i = 0; i < datasets.length; i++) { + TCComponentDataset dataset=(TCComponentDataset) datasets[i]; + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + if (tcFiles!=null&&tcFiles.length>0) { + File fmsFile = tcFiles[0].getFmsFile(); + if (fmsFile.getPath().endsWith("jpg")||fmsFile.getPath().endsWith("png")) { + return fmsFile; + } + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + /** + * ѡеײ¼ + * + */ + protected void setTextStr(DefaultMutableTreeNode treeNode) { + // TODO Auto-generated method stub + selnodename = treeNode.toString(); + if (islov) { + if (nameMap.containsKey(selnodename)) { + jcomname.setSelectedItem(selnodename); + } + } else { + jtext3.setText(selnodename); + } + if (selnodename.endsWith("Ʒǩ") || selnodename.endsWith("ǩ")) {// ֻвƷǩѡģ + jl4.setVisible(true); + jcom.setVisible(true); + if (targetComp!=null&&targetComp instanceof TCComponentItemRevision) { + try { + String item_id=((TCComponentItemRevision)targetComp).getProperty("item_id"); + jtext3.setText("мܱǩ"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + } else { + jl4.setVisible(false); + jcom.setVisible(false); + } + String names = getNode(treeNode, ""); + selCodeBean = getcode.getCodebean(names); + if (selCodeBean != null) { + String type = selCodeBean.getType(); + String code = selCodeBean.getCode(); + code = code + " [L]"; + getNameLov(type); + try { + TCComponentItemType tctype = (TCComponentItemType) session + .getTypeComponent(type); + jtext1.setText(code); + jtext2.setText(tctype.getNewRev(null)); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * õǰTreeNodeĸ-ƻ + * + * @param treeNode + * ڵ + * @param names + * ƻ + * @return + */ + private String getNode(TreeNode treeNode, String names) { + // TODO Auto-generated method stub + if (!names.equals("")) { + names = "&" + names; + } + names = treeNode.toString() + names; + + TreeNode parent = treeNode.getParent(); + if (parent != null) { + return getNode(parent, names); + } + + return names; + } + + /** + * + * + * @param menuBean1 + * @return + */ + private JTree getTree(MenuBean menuBean1) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( + treenodename); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), rootNode); + } + } + JTree tree = new JTree(rootNode); + tree.setShowsRootHandles(true); + // tree.setEditable(true); + + return tree; + } + + /** + * ݹ˵ṹ + * + * @param menuBean1 + * @param rootNode + */ + private void getRecursion(MenuBean menuBean1, + DefaultMutableTreeNode rootNode) { + // TODO Auto-generated method stub + String treenodename = menuBean1.getName(); + List list = menuBean1.getList(); + DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename); + rootNode.add(node); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + getRecursion(list.get(i), node); + } + } + } + +} diff --git a/src/com/connor/wf/plm/wf057/Wf057Action.java b/src/com/connor/wf/plm/wf057/Wf057Action.java new file mode 100644 index 0000000..9dec4d7 --- /dev/null +++ b/src/com/connor/wf/plm/wf057/Wf057Action.java @@ -0,0 +1,34 @@ +package com.connor.wf.plm.wf057; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf057Action extends AbstractAIFAction { + private AbstractAIFApplication app; + private InterfaceAIFComponent tar; + private TCSession session; + private String name; + + + public Wf057Action(AbstractAIFApplication arg0, String arg1,String name) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + this.tar = app.getTargetComponent(); + this.session = (TCSession) app.getSession(); + this.name=name; + } + + @Override + public void run() { + // TODO Auto-generated method stub + Wf057AIFDialog dia = new Wf057AIFDialog(session, tar,name); + new Thread(dia).start(); + + + + } + +} diff --git a/src/com/connor/wf/plm/wf057/Wf057Handler.java b/src/com/connor/wf/plm/wf057/Wf057Handler.java new file mode 100644 index 0000000..d1ad09d --- /dev/null +++ b/src/com/connor/wf/plm/wf057/Wf057Handler.java @@ -0,0 +1,38 @@ +package com.connor.wf.plm.wf057; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * :Wf057Handler + * : + * :2019-03-22 + * Ա zl + * + */ +public class Wf057Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + try { + String name = arg0.getCommand().getName(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + //TCSession session = (TCSession) app.getSession(); + //InterfaceAIFComponent com = app.getTargetComponent(); + Wf057Action dia = new Wf057Action(app, null,name); + new Thread(dia).start(); + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf057/Wf057Operation.java b/src/com/connor/wf/plm/wf057/Wf057Operation.java new file mode 100644 index 0000000..4b36b0e --- /dev/null +++ b/src/com/connor/wf/plm/wf057/Wf057Operation.java @@ -0,0 +1,77 @@ +package com.connor.wf.plm.wf057; + +import java.util.ArrayList; +import java.util.List; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf057Operation extends AbstractAIFOperation { + + private TCSession session; + private String classid; + private TCComponentItemRevision rev; + private Integer[] keys; + private String[] vels; + + public Wf057Operation(TCSession session, String classid, + TCComponentItemRevision rev, Integer[] keys, String[] vels) { + // TODO Auto-generated constructor stub + this.session = session; + this.classid = classid; + this.rev = rev; + this.keys = keys; + this.vels = vels; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + sendObjToClassficationByWebService(classid, rev, keys, vels); + + } + + /** + * ͷ + * + * @param class_id + * id + * @param rev + * 汾 + * @param keys + * id + * @param vals + * ֵ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + String url = session.getPreferenceService().getStringValue( + "Autocode_SendClassServer_URL"); + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/wf/plm/wf058/ExportMJXX_Dialog.java b/src/com/connor/wf/plm/wf058/ExportMJXX_Dialog.java new file mode 100644 index 0000000..2ee96ba --- /dev/null +++ b/src/com/connor/wf/plm/wf058/ExportMJXX_Dialog.java @@ -0,0 +1,157 @@ +package com.connor.wf.plm.wf058; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class ExportMJXX_Dialog extends AbstractAIFDialog { + + private JTextField textField; + private JButton okButton; + private JButton celButton; + private JButton pathButton; + // ļѡ + private JFileChooser jFileChooser; + + private TCSession session; + + public ExportMJXX_Dialog(TCSession session) { + // TODO Auto-generated constructor stub + this.session=session; + //ExportHZB_Operation ex=new ExportHZB_Operation(maptab); + //session.queueOperation(ex); + } + + public void run() { + initUI(); + + } + private void initUI() { + // TODO Auto-generated method stub + FileSystemView fsv = FileSystemView.getFileSystemView(); // õϵͳfileview + String deskPath = fsv.getHomeDirectory().getPath(); // ǰû· + + this.setSize(new Dimension(600, 400)); + this.setTitle(""); + this.textField = new JTextField(deskPath); + + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath));// ļѡijʼĿ¼Ϊǰû + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + this.pathButton = new JButton("..."); + this.okButton = new JButton("ȷ"); + this.celButton = new JButton("ȡ"); + String name=""; + try { + name=session.getUser().getProperty("user_name"); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + JPanel midJPanel = new JPanel(new PropertyLayout()); + midJPanel.setBorder(new TitledBorder(BorderFactory + .createLineBorder(Color.WHITE), "ѡ񵼳·")); // ߿ TitleBorder + + midJPanel.add("1.1.left.top", new JLabel("·")); + midJPanel.add("1.2.left.top", this.textField); + midJPanel.add("1.3.left.top", this.pathButton); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(this.okButton); + rootJPanel.add(this.celButton); + + pathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + okEvent(); + + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + celEvent(); + + } + }); + + this.setLayout(new BorderLayout()); + this.add(midJPanel, BorderLayout.CENTER); + this.add(rootJPanel, BorderLayout.SOUTH); + + this.centerToScreen(); + this.pack(); + this.setVisible(true); + this.showDialog(); + } + + public void celEvent() { + // TODO Auto-generated method stub + this.disposeDialog(); + this.dispose(); + } + + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile();// fΪѡ񵽵Ŀ¼ + textField.setText(f.getAbsolutePath()); + } + } + + public void okEvent() { + + this.disposeDialog(); + this.dispose(); + + try { + String path=textField.getText(); + System.out.println("ok"); + + ExportMJXX_Operation op=new ExportMJXX_Operation(session,path); + session.queueOperation(op); + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/wf/plm/wf058/ExportMJXX_Handler.java b/src/com/connor/wf/plm/wf058/ExportMJXX_Handler.java new file mode 100644 index 0000000..91d5c92 --- /dev/null +++ b/src/com/connor/wf/plm/wf058/ExportMJXX_Handler.java @@ -0,0 +1,26 @@ +package com.connor.wf.plm.wf058; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class ExportMJXX_Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + ExportMJXX_Dialog action=new ExportMJXX_Dialog(session); + new Thread(action).start(); + + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf058/ExportMJXX_Operation.java b/src/com/connor/wf/plm/wf058/ExportMJXX_Operation.java new file mode 100644 index 0000000..e449e9c --- /dev/null +++ b/src/com/connor/wf/plm/wf058/ExportMJXX_Operation.java @@ -0,0 +1,162 @@ +package com.connor.wf.plm.wf058; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ExportMJXX_Operation extends AbstractAIFOperation { + + private TCSession session; + private String path; + private File file; + + + private XSSFSheet sheet; + private XSSFWorkbook workBook; + private FileInputStream fis; + private FileOutputStream fos; + private String excelPath; + private ProgressBarThread wait; + + public ExportMJXX_Operation( TCSession session, + String path) { + // TODO Auto-generated constructor stub + this.session = session; + this.path = path; + + } + + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + file = getSXX(); + if (file != null) { + wait = new ProgressBarThread("ɱ", + "УԵ..."); + wait.start();// + // getVal(); + try { + writeExcel(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ"+e.getMessage(),"",MessageBox.ERROR); + return; + } + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱ,鿴","",MessageBox.INFORMATION); + Runtime.getRuntime().exec("cmd /c \"" + excelPath + "\""); + } + + } + + public File getSXX() { + TCPreferenceService pref = session.getPreferenceService(); + String puid = pref.getStringValue("WF2_Mold_Excel_Option");// ѡpuid//w_XxdLj$JsmraC + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session + .stringToComponent(puid); + if (dataset == null) { + return null; + } + TCComponentTcFile[] file = dataset.getTcFiles(); + if (file.length == 0 || file.length != 1) { + MessageBox.post("ݼûõļļ࣬飡", "WARNING", + MessageBox.WARNING); + return null; + } else { + File fmsFile = file[0].getFmsFile(); + return fmsFile; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + MessageBox.post("δҵѡ[WF2_Mold_Excel_Option]ѡô", "", + MessageBox.ERROR); + return null; + } + return null; + } + + public void writeExcel() { + // TODO Auto-generated method stub + + try { + fis = new FileInputStream(file); + workBook = new XSSFWorkbook(fis); + if (workBook != null) { + + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// ڸʽ + String time = df.format(new Date()); + excelPath = path + File.separator + "ģ߻" + + time + ".xlsx"; + File fileout = new File(excelPath); + fos = new FileOutputStream(fileout); + workBook.write(fos); + // Runtime.getRuntime().exec(excelPath); + + + + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ,"+e.getMessage(),"",MessageBox.ERROR); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ"+e.getMessage(),"",MessageBox.ERROR); + } + + } + + public void writeSheet(XSSFSheet sheet, List> list) { + // TODO Auto-generated method stub + for (int i = 0; i < list.size(); i++) { + XSSFRow rowm = sheet.createRow(i + 1); + XSSFCellStyle sty =workBook.createCellStyle(); //sheet.getRow(0).getCell(0).getCellStyle(); + for (int j = 0; j < list.get(i).size(); j++) { + XSSFCell c = rowm.createCell(j); + c.setCellStyle(sty); + c.setCellValue(list.get(i).get(j)); + + + } + + } + + } + +} diff --git a/src/com/connor/wf/plm/wf058/ImportMJXX_Dialog.java b/src/com/connor/wf/plm/wf058/ImportMJXX_Dialog.java new file mode 100644 index 0000000..d648ce9 --- /dev/null +++ b/src/com/connor/wf/plm/wf058/ImportMJXX_Dialog.java @@ -0,0 +1,152 @@ +package com.connor.wf.plm.wf058; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class ImportMJXX_Dialog extends AbstractAIFDialog { + + private JTextField textField; + private JButton okButton; + private JButton celButton; + private JButton pathButton; + // ļѡ + private JFileChooser jFileChooser; + + private TCSession session; + + public ImportMJXX_Dialog(TCSession session) { + // TODO Auto-generated constructor stub + this.session=session; + //ExportHZB_Operation ex=new ExportHZB_Operation(maptab); + //session.queueOperation(ex); + } + + public void run() { + initUI(); + + } + private void initUI() { + // TODO Auto-generated method stub + FileSystemView fsv = FileSystemView.getFileSystemView(); // õϵͳfileview + String deskPath = fsv.getHomeDirectory().getPath(); // ǰû· + + this.setSize(new Dimension(600, 400)); + this.setTitle("ϴ"); + this.textField = new JTextField(deskPath); + + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath));// ļѡijʼĿ¼Ϊǰû + //this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + this.pathButton = new JButton("..."); + this.okButton = new JButton("ȷ"); + this.celButton = new JButton("ȡ"); + + + JPanel midJPanel = new JPanel(new PropertyLayout()); + midJPanel.setBorder(new TitledBorder(BorderFactory + .createLineBorder(Color.WHITE), "ѡϴļ")); // ߿ TitleBorder + + midJPanel.add("1.1.left.top", new JLabel("ѡļ")); + midJPanel.add("1.2.left.top", this.textField); + midJPanel.add("1.3.left.top", this.pathButton); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(this.okButton); + rootJPanel.add(this.celButton); + + pathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + okEvent(); + + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + celEvent(); + + } + }); + + this.setLayout(new BorderLayout()); + this.add(midJPanel, BorderLayout.CENTER); + this.add(rootJPanel, BorderLayout.SOUTH); + + this.centerToScreen(); + this.pack(); + this.setVisible(true); + this.showDialog(); + } + + public void celEvent() { + // TODO Auto-generated method stub + this.disposeDialog(); + this.dispose(); + } + + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile();// fΪѡ񵽵Ŀ¼ + textField.setText(f.getAbsolutePath()); + } + } + + public void okEvent() { + + this.disposeDialog(); + this.dispose(); + + try { + String path=textField.getText(); + System.out.println("ok"); + + + ImportMJXX_Operation op=new ImportMJXX_Operation(session,path); + session.queueOperation(op); + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/wf/plm/wf058/ImportMJXX_Handler.java b/src/com/connor/wf/plm/wf058/ImportMJXX_Handler.java new file mode 100644 index 0000000..8ee6f73 --- /dev/null +++ b/src/com/connor/wf/plm/wf058/ImportMJXX_Handler.java @@ -0,0 +1,26 @@ +package com.connor.wf.plm.wf058; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class ImportMJXX_Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + ImportMJXX_Dialog action=new ImportMJXX_Dialog(session); + new Thread(action).start(); + + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf058/ImportMJXX_Operation.java b/src/com/connor/wf/plm/wf058/ImportMJXX_Operation.java new file mode 100644 index 0000000..249a10c --- /dev/null +++ b/src/com/connor/wf/plm/wf058/ImportMJXX_Operation.java @@ -0,0 +1,208 @@ +package com.connor.wf.plm.wf058; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.wf.plm.util.DataBaseControl; +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ImportMJXX_Operation extends AbstractAIFOperation { + + private TCSession session; + private String path; + private File file; + + + private XSSFSheet sheet; + private XSSFWorkbook workBook; + private FileInputStream fis; + private Map map=new HashMap(); + + + public ImportMJXX_Operation( TCSession session, + String path) { + // TODO Auto-generated constructor stub + this.session = session; + this.path = path; + + } + + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + System.out.println("path="+path); + if (!path.endsWith(".xlsx")) { + MessageBox.post("ѡ·,Ҳļ!","",MessageBox.ERROR); + return; + } + file =new File(path); + readExcel(); + MessageBox.post("ϴ","",MessageBox.INFORMATION); + + + } +// +// //Ϣ +// private void getSqlConn() { +// // TODO Auto-generated method stub +// conns = session.getPreferenceService().getStringValues("WF2_SQL_Connect"); +// if (conns==null||conns.length<=0) { +// MessageBox.post("δҵѡWF2_SQL_Connect,ѡô,ϵԱ!", "ERROR", +// MessageBox.ERROR); +// } +// +// } + + public void readExcel() { + // TODO Auto-generated method stub + + try { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// ڸʽ + String time = df.format(new Date()); + String user=session.getUser().toString(); + fis = new FileInputStream(file); + workBook = new XSSFWorkbook(fis); + sheet= workBook.getSheetAt(0); + int lastRowNum = sheet.getLastRowNum(); + System.out.println("lastRowNum="+lastRowNum); + if (lastRowNum>4) { + for (int i = 3; i < lastRowNum; i++) { + XSSFRow row = sheet.getRow(i); + XSSFCell cell3 = row.getCell(3); + XSSFCell cell16 = row.getCell(16); + String v3 = getCellValue(cell3); + if (v3==null||v3.equals("")) { + continue; + } + String v16 = getCellValue(cell16); + if (v16==null) { + continue; + } + map.put(v3, v16); + + } + if (map.size()>0) { + for (Map.Entry entry : map.entrySet()) { + setSqlVal(entry.getKey(),entry.getValue(),time,user); + } + } + + } + + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ϴʧ"+e.getMessage(),"",MessageBox.ERROR); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ϴʧ"+e.getMessage(),"",MessageBox.ERROR); + }finally{ + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + + } + + + /** + * ݿֵ + * @param v3 + * @param v16 » + * @param time ʱ + * @param user Ա + */ + private void setSqlVal(String v3, String v16, String time, String user) { + // TODO Auto-generated method stub + try { + DataBaseControl data = new DataBaseControl(session); + data.setSqlConn(v3, v16,time,user); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + /** + * õԪֵ + * @param cell + * @return + */ + public String getCellValue(XSSFCell cell){ + String cellValue = ""; + if(cell == null){ + return cellValue; + } + switch (cell.getCellType()) { + case XSSFCell.CELL_TYPE_NUMERIC: + if(DateUtil.isCellDateFormatted(cell)){ + SimpleDateFormat sdf = null; + if(cell.getCellStyle().getDataFormat() == 14){ + sdf = new SimpleDateFormat("yyyy/MM/dd"); + }else if(cell.getCellStyle().getDataFormat() == 21){ + sdf = new SimpleDateFormat("HH:mm:ss"); + }else if(cell.getCellStyle().getDataFormat() == 22){ + sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + }else{ + throw new RuntimeException("ڸʽ!!!"); + } + Date date = cell.getDateCellValue(); + cellValue = sdf.format(date); + }else if(cell.getCellStyle().getDataFormat() == 0){ + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cellValue = String.valueOf(cell.getRichStringCellValue().getString()); + } + break; + case XSSFCell.CELL_TYPE_STRING: + cellValue = String.valueOf(cell.getStringCellValue()); + break; + case XSSFCell.CELL_TYPE_BOOLEAN: + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case XSSFCell.CELL_TYPE_FORMULA: + cellValue = String.valueOf(cell.getCellFormula()); + break; + case XSSFCell.CELL_TYPE_BLANK: + cellValue = null; + break; + case XSSFCell.CELL_TYPE_ERROR: + cellValue = "Ƿַ"; + break; + default: + break; + } + return cellValue; + } +} diff --git a/src/com/connor/wf/plm/wf058/Wf058Handler.java b/src/com/connor/wf/plm/wf058/Wf058Handler.java new file mode 100644 index 0000000..6c0e897 --- /dev/null +++ b/src/com/connor/wf/plm/wf058/Wf058Handler.java @@ -0,0 +1,39 @@ +package com.connor.wf.plm.wf058; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * :Wf058Handler ȡ + * :ɿģͼֽ + * :2019-04-22 + * Ա zl + * + */ +public class Wf058Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent com = app.getTargetComponent(); + if (com!=null&&com.getType().equals("WF2_2DprodDrawRevision")) { + Wf058Operation operation = new Wf058Operation(com, session); + session.queueOperation(operation); + }else{ + MessageBox.post("ѡƷͼ汾в!!", "", MessageBox.INFORMATION); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf058/Wf058Operation.java b/src/com/connor/wf/plm/wf058/Wf058Operation.java new file mode 100644 index 0000000..6757b37 --- /dev/null +++ b/src/com/connor/wf/plm/wf058/Wf058Operation.java @@ -0,0 +1,154 @@ +package com.connor.wf.plm.wf058; + +import java.util.ArrayList; +import java.util.List; + +import com.connor.wf.plm.util.ClassProperty; +import com.connor.wf.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + +public class Wf058Operation extends AbstractAIFOperation { + + private TCSession session; + private String classid; + private TCComponentItemRevision rev; + private TCPreferenceService service; + private String url = ""; + private Integer[] classKeys; + private String[] classVals; + + public Wf058Operation(InterfaceAIFComponent com, TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + this.rev = (TCComponentItemRevision) com; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + String revid = rev.getProperty("item_revision_id"); + TCComponentItemRevision newRev = rev.saveAs(revid + ".001"); + String newclass = newRev.getClassificationClass(); + if (newclass != null && (!newclass.equals(""))) { + System.out.println("°汾ĬϷͷ,跢ͷִ"); + } else { + String classname = rev.getClassificationClass(); + if (classname != null && (!classname.equals(""))) { + service = session.getPreferenceService(); + url = service + .getStringValue("Autocode_SendClassServer_URL"); + System.out.println("url=" + url); + + TCComponentICO[] icos = rev.getClassificationObjects(); + + if (icos != null && icos.length > 0) { + ICSProperty[] icss = icos[0].getICSProperties(true); + classKeys = new Integer[icss.length]; + classVals = new String[icss.length]; + for (int i = 0; i < icss.length; i++) { + classKeys[i] = icss[i].getId(); + classVals[i] = icss[i].getValue(); + } + } + sendObjToClassficationByWebService(classname, newRev, + classKeys, classVals);// ͷ + System.out.println("ͷ"); + } + + } + setReleases(newRev); + + MessageBox.post("ɳɹ!!", "", MessageBox.INFORMATION); + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("ʧ:" + e.getMessage(), "", MessageBox.ERROR); + } + + } + + + private void setReleases(TCComponentItemRevision newRev) { + // TODO Auto-generated method stub + try { + setReleaseStatus(newRev, "WF2_openMold");// + String[] stringArray = session.getPreferenceService().getStringValues("WF2_2DprodDraw_Release_Rela"); + if (stringArray!=null&&stringArray.length>0) { + for (int i = 0; i < stringArray.length; i++) { + TCComponent[] tccom = newRev.getReferenceListProperty(stringArray[i]); + if (tccom!=null&&tccom.length>0) { + for (int j = 0; j < tccom.length; j++) { + setReleaseStatus(tccom[j], "WF2_openMold"); + } + } + + } + } + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * c÷״̬ + * + * @param item + * ҪĶ + * @param statusName + * ״̬ + * @throws TCException + */ + public void setReleaseStatus(TCComponent item, String statusName) + throws TCException { + TCUserService userservice = this.session.getUserService(); + + Object[] obj = new Object[2]; + obj[0] = item; + obj[1] = statusName; + userservice.call("connor_set_release_status", obj); + + } + + /** + * ͷ + */ + public void sendObjToClassficationByWebService(String class_id, + TCComponentItemRevision rev, Integer[] keys, String[] vals) { + try { + System.out.println("class_id-----dddddd----->" + class_id); + if (!class_id.replace(" ", "").equals("")) { + + List propList = new ArrayList<>(); + + for (int i = 0; i < keys.length; i++) { + + ClassProperty prop = new ClassProperty(keys[i], vals[i]);// + propList.add(prop); + } + String json = SoaServerUtil.objectToJson(propList);// JavaתΪjson + SoaServerUtil.grantWritePrivilege(session, rev);// дȨ + SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// ͵ + + SoaServerUtil.grantReadPrivilege(session, rev);// Ȩ + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } +} diff --git a/src/com/connor/wf/plm/wf059/Wf059Handler.java b/src/com/connor/wf/plm/wf059/Wf059Handler.java new file mode 100644 index 0000000..ed69645 --- /dev/null +++ b/src/com/connor/wf/plm/wf059/Wf059Handler.java @@ -0,0 +1,40 @@ +package com.connor.wf.plm.wf059; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * :Wf059Handler + * :ƽƷ + * :2019-05-08 + * Ա zl + * + */ +public class Wf059Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent com = app.getTargetComponent(); + if (com!=null&&com.getType().equals("WF2_dynamicBalMhRevision")) { + Wf059Operation operation = new Wf059Operation((TCComponentItemRevision) com, session); + session.queueOperation(operation); + }else{ + MessageBox.post("ѡƽ(ӹ)汾в!!", "", MessageBox.INFORMATION); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf059/Wf059Operation.java b/src/com/connor/wf/plm/wf059/Wf059Operation.java new file mode 100644 index 0000000..f71309a --- /dev/null +++ b/src/com/connor/wf/plm/wf059/Wf059Operation.java @@ -0,0 +1,57 @@ +package com.connor.wf.plm.wf059; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +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.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf059Operation extends AbstractAIFOperation { + + private TCSession session; + private TCComponentItemRevision rev; + + + public Wf059Operation(TCComponentItemRevision com, TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + this.rev = com; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent("WF2_dynamicBal"); + String id=tctype.getNewID(); + String revid=tctype.getNewRev(null); + TCPropertyDescriptor de=tctype.getPropertyDescriptor("object_name"); + String name=de.getDefaultValue(); + if (name==null||name.equals("")) { + name="ƽ(Ʒ)"; + } + System.out.println("item="+id+"--"+revid+"--"+name); + TCComponentItem item = tctype.create(id,revid, "WF2_dynamicBal",name, "", null); + TCComponentItemRevision newrev = item.getLatestItemRevision(); + newrev.setProperty("wf2_customerName", rev.getProperty("wf2_customerName"));//ͻ + newrev.setProperty("wf2_productNumber", rev.getProperty("wf2_productNumber"));// Ʒ + newrev.setProperty("wf2_customerStandard", rev.getProperty("wf2_customerStandard"));// ͻ׼ + newrev.setProperty("wf2_size", rev.getProperty("wf2_size"));// + newrev.setProperty("wf2_diameter", rev.getProperty("wf2_diameter"));// Ŀֱ + + session.getUser().getNewStuffFolder().add("contents", item); + MessageBox.post("ɹ,NewStuffļ²鿴!!", "", MessageBox.INFORMATION); + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("ʧ:" + e.getMessage(), "", MessageBox.ERROR); + } + + } + + + +} diff --git a/src/com/connor/wf/plm/wf060/Wf060Handler.java b/src/com/connor/wf/plm/wf060/Wf060Handler.java new file mode 100644 index 0000000..9d3696c --- /dev/null +++ b/src/com/connor/wf/plm/wf060/Wf060Handler.java @@ -0,0 +1,40 @@ +package com.connor.wf.plm.wf060; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * :Wf060Handler + * :ƽӹ + * :2019-05-08 + * Ա zl + * + */ +public class Wf060Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent com = app.getTargetComponent(); + if (com!=null&&com.getType().equals("WF2_finPartRevision")) { + Wf060Operation operation = new Wf060Operation((TCComponentItemRevision) com, session); + session.queueOperation(operation); + }else{ + MessageBox.post("ѡƷ汾в!!", "", MessageBox.INFORMATION); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf060/Wf060Operation.java b/src/com/connor/wf/plm/wf060/Wf060Operation.java new file mode 100644 index 0000000..9189d2a --- /dev/null +++ b/src/com/connor/wf/plm/wf060/Wf060Operation.java @@ -0,0 +1,60 @@ +package com.connor.wf.plm.wf060; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf060Operation extends AbstractAIFOperation { + + private TCSession session; + private TCComponentItemRevision rev; + + + public Wf060Operation(TCComponentItemRevision com, TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + this.rev = com; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent("WF2_dynamicBalMh"); + String id=tctype.getNewID(); + String revid=tctype.getNewRev(null); + TCPropertyDescriptor de=tctype.getPropertyDescriptor("object_name"); + String name=de.getDefaultValue(); + if (name==null||name.equals("")) { + name="ƽ(ӹ)"; + } + System.out.println("item="+id+"--"+revid+"--"+name); + TCComponentItem item = tctype.create(id,revid, "WF2_dynamicBalMh",name, "", null); + TCComponentItemRevision newrev = item.getLatestItemRevision(); + TCComponent form = rev.getReferenceListProperty("IMAN_master_form_rev")[0]; + String wid = form.getProperty("wf2_sizeWidth")==null?"": form.getProperty("wf2_sizeWidth"); + String dia = form.getProperty("wf2_sizeDiameter")==null?"": form.getProperty("wf2_sizeDiameter"); + newrev.setProperty("wf2_customerName", form.getProperty("wf2_customerName"));//ͻ + newrev.setProperty("wf2_productNumber", rev.getProperty("item_id"));// Ʒ + newrev.setProperty("wf2_size", dia+"*"+wid);// + newrev.setProperty("wf2_diameter", form.getProperty("wf2_ctrHoleDiameter"));// Ŀֱ + + session.getUser().getNewStuffFolder().add("contents", item); + MessageBox.post("ɹ,NewStuffļ²鿴!!", "", MessageBox.INFORMATION); + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("ʧ:" + e.getMessage(), "", MessageBox.ERROR); + } + + } + + + +} diff --git a/src/com/connor/wf/plm/wf061/TestMain.java b/src/com/connor/wf/plm/wf061/TestMain.java new file mode 100644 index 0000000..f6a47a4 --- /dev/null +++ b/src/com/connor/wf/plm/wf061/TestMain.java @@ -0,0 +1,201 @@ +package com.connor.wf.plm.wf061; + +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.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.Arrays; +import java.util.List; + +import org.apache.poi.POIXMLDocumentPart; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + + +public class TestMain { + + /** + * @param args + */ + public static void main(String[] args) { + String a = "111111|2"; + System.out.println(a.contains("|")); + } + + + /** + * + * @param sheet + * @return + * @throws IOException + */ + public static XSSFDrawing getDrawing(XSSFSheet sheet) throws IOException { + XSSFDrawing drawing = null; + List list = sheet.getRelations(); + + for (POIXMLDocumentPart part : list) { + if (part instanceof XSSFDrawing) { + System.out.println("part=" + part); + drawing = (XSSFDrawing) part; + } + } + if (drawing == null) { + drawing = sheet.createDrawingPatriarch(); + } + return drawing; + } + + public static void main1(String[] args) { + // TODO Auto-generated method stub +// try { +// +// FileOutputStream output = new FileOutputStream(new File( +// "D:\\22.xlsx")); +// FileInputStream is = new FileInputStream("D:\\11.xlsx"); +// XSSFWorkbook wb = new XSSFWorkbook(is); +// XSSFSheet sheetSCHD = wb.getSheetAt(0); +// //copyRows(1,23,26,sheetSCHD); +// CellCopyPolicy policy=new CellCopyPolicy(); +// policy.setCondenseRows(true); +// policy.setCopyCellFormula(true); +// policy.setCopyCellStyle(true); +// sheetSCHD.shiftRows(0, 20, 23, true,true); +// wb.write(output); +// output.close(); +// is.close(); +// System.out.println("111"); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + + + + + +// for (int i = 0; i < 11; i++) { +// int n=i/10;//iΪi+1 +// int m=i%10+1; +// int rownum=n*23+m*2+2; +// System.out.println(""+(i+1)+"---"+rownum+""); +// } + + +// BigDecimal bd2=new BigDecimal("0.000002"); +// int cou = checkIsDoublePointTwo(bd2.doubleValue()); +// System.out.println("cou="+cou); +// +// String str_MENGE="1.0"; +// int BMENG=100; +// BigDecimal bd1=new BigDecimal(str_MENGE); +// BigDecimal bm=new BigDecimal(String.valueOf(BMENG)); +// BigDecimal quanew = bd1.multiply(bm); +// str_MENGE = quanew.toString(); +// System.out.println("sss="+str_MENGE); +// DecimalFormat decimalFormat = new DecimalFormat("###################.###########"); +// System.out.println(decimalFormat.format(quanew.doubleValue())); +// +// BigDecimal bd=new BigDecimal("0.0078860"); +// BigDecimal bs=new BigDecimal(1000); +// BigDecimal multiply = bd.multiply(bs); +// double param=multiply.doubleValue(); +// System.out.println(param); +// int len = checkIsDoublePointTwo(param); +// System.out.println(len); + } + + public static int checkIsDoublePointTwo(Double param) { + if (param == null) { + return 0; + } + BigDecimal bd = new BigDecimal(String.valueOf(param)); + DecimalFormat decimalFormat = new DecimalFormat("###################.###########"); + String str=decimalFormat.format(bd.doubleValue()); + + String[] ss =str.split("\\."); + if (ss.length <= 1) { + return 0; + } + return ss[1].length(); + } +// public static void copyRows(int startRow, int endRow, int pPosition, +// XSSFSheet sheet) { +// int pStartRow = startRow - 1; +// int pEndRow = endRow - 1; +// int targetRowFrom; +// int targetRowTo; +// int columnCount; +// CellRangeAddress region = null; +// int i; +// int j; +// if (pStartRow == -1 || pEndRow == -1) { +// return; +// } +// // ϲĵԪ +// for (i = 0; i < sheet.getNumMergedRegions(); i++) { +// region = sheet.getMergedRegion(i); +// if ((region.getFirstRow() >= pStartRow) +// && (region.getLastRow() <= pEndRow)) { +// targetRowFrom = region.getFirstRow() - pStartRow + pPosition; +// targetRowTo = region.getLastRow() - pStartRow + pPosition; +// CellRangeAddress newRegion = region.copy(); +// newRegion.setFirstRow(targetRowFrom); +// newRegion.setFirstColumn(region.getFirstColumn()); +// newRegion.setLastRow(targetRowTo); +// newRegion.setLastColumn(region.getLastColumn()); +// sheet.addMergedRegion(newRegion); +// } +// } +// // п +// for (i = pStartRow; i <= pEndRow; i++) { +// System.out.println("i=" + i); +// XSSFRow sourceRow = sheet.getRow(i); +// columnCount = sourceRow.getLastCellNum(); +// if (sourceRow != null) { +// XSSFRow newRow = sheet.createRow(pPosition - pStartRow + i); +// newRow.setHeight(sourceRow.getHeight()); +// for (j = 0; j < columnCount; j++) { +// XSSFCell templateCell = sourceRow.getCell(j); +// if (templateCell != null) { +// XSSFCell newCell = newRow.createCell(j); +// copyCell(templateCell, newCell); +// } +// } +// } +// } +// } +// +// private static void copyCell(XSSFCell srcCell, XSSFCell distCell) { +// distCell.setCellStyle(srcCell.getCellStyle()); +// if (srcCell.getCellComment() != null) { +// distCell.setCellComment(srcCell.getCellComment()); +// } +// int srcCellType = srcCell.getCellType(); +// distCell.setCellType(srcCellType); +// if (srcCellType == XSSFCell.CELL_TYPE_NUMERIC) { +// distCell.setCellValue(srcCell.getNumericCellValue()); +// } else if (srcCellType == XSSFCell.CELL_TYPE_STRING) { +// distCell.setCellValue(srcCell.getRichStringCellValue()); +// } else if (srcCellType == XSSFCell.CELL_TYPE_BLANK) { +// // nothing21 +// } else if (srcCellType == XSSFCell.CELL_TYPE_BOOLEAN) { +// distCell.setCellValue(srcCell.getBooleanCellValue()); +// } else if (srcCellType == XSSFCell.CELL_TYPE_ERROR) { +// distCell.setCellErrorValue(srcCell.getErrorCellValue()); +// } else if (srcCellType == XSSFCell.CELL_TYPE_FORMULA) { +// distCell.setCellFormula(srcCell.getCellFormula()); +// } else { // nothing29 +// +// } +// } +} \ No newline at end of file diff --git a/src/com/connor/wf/plm/wf061/Wf061Handler.java b/src/com/connor/wf/plm/wf061/Wf061Handler.java new file mode 100644 index 0000000..33a832d --- /dev/null +++ b/src/com/connor/wf/plm/wf061/Wf061Handler.java @@ -0,0 +1,40 @@ +package com.connor.wf.plm.wf061; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * :Wf060Handler + * :ȴտ + * :2019-05-15 + * Ա zl + * + */ +public class Wf061Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent com = app.getTargetComponent(); + if (com!=null&&com.getType().equals("WF2_moldRevision")) { + Wf061Operation operation = new Wf061Operation((TCComponentItemRevision) com, session); + session.queueOperation(operation); + }else{ + MessageBox.post("ѡģ߰汾в!!", "", MessageBox.INFORMATION); + } + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf061/Wf061Operation.java b/src/com/connor/wf/plm/wf061/Wf061Operation.java new file mode 100644 index 0000000..4cd1f62 --- /dev/null +++ b/src/com/connor/wf/plm/wf061/Wf061Operation.java @@ -0,0 +1,287 @@ +package com.connor.wf.plm.wf061; + +import java.awt.Graphics; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.imageio.ImageIO; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFPicture; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf061Operation extends AbstractAIFOperation { + + private TCSession session; + private TCComponentItemRevision rev; + + + public Wf061Operation(TCComponentItemRevision com, TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + this.rev = com; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + TCComponentItemType tctype = (TCComponentItemType) session.getTypeComponent("WF2_heTrReRqmt"); + String id=tctype.getNewID(); + String revid=tctype.getNewRev(null); + TCPropertyDescriptor de=tctype.getPropertyDescriptor("object_name"); + String name=de.getDefaultValue(); + if (name==null||name.equals("")) { + name="ȴտ"; + } + System.out.println("item="+id+"--"+revid+"--"+name); + TCComponentItem item = tctype.create(id,revid, "WF2_heTrReRqmt",name, "", null); + TCComponentItemRevision newrev = item.getLatestItemRevision(); + //TCComponent form = rev.getReferenceListProperty("IMAN_master_form_rev")[0]; + String uid = session.getPreferenceService().getStringValue("WF2_heTrReRqmt_Dataset"); + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(uid); + TCComponentDataset newData = dataset.saveAs(id+ "/" + revid); + newrev.add("IMAN_specification", newData); + rev.add("WF2_hTrtProCdRe", item); + + File file = setDataset(newData,newrev,rev); + if (file != null) { + newData.setFiles( + new String[] { file.getPath() }, + new String[] { "excel" }); + } + MessageBox.post("ɹ,ڰ汾ȴտļ²鿴!!", "", MessageBox.INFORMATION); + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("ʧ:" + e.getMessage(), "", MessageBox.ERROR); + } + + } + + /** + * ѡexcel + * @param dataset + * @param newrev + * @param rev + * @return + */ + private File setDataset(TCComponentDataset dataset, + TCComponentItemRevision newrev, TCComponentItemRevision rev) { + // TODO Auto-generated method stub + File fileout = null; + + String[] prostrs = session.getPreferenceService().getStringValues("WF2_heTrReRqmt_Dataset_Data"); + try { + AIFComponentContext[] cpts = rev.getItem().whereReferencedByTypeRelation(new String[]{"WF2_2DprodDrawRevision"},new String[]{"WF2_moldRe"}); + TCComponentItemRevision cptrev=null; + if (cpts!=null&&cpts.length>0) { + cptrev = (TCComponentItemRevision) cpts[0].getComponent(); + }else{ + return null; + } + File jpgfile=getCptjpg(cpts); + FileInputStream fis = null; + FileOutputStream fos = null; + XSSFWorkbook workBook = null; + try { + TCComponentItem item = rev.getItem(); + TCComponent form = rev.getReferenceListProperty("IMAN_master_form_rev")[0]; + TCComponentItem newitem = newrev.getItem(); + TCComponent newform = newrev + .getReferenceListProperty("IMAN_master_form_rev")[0]; + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + File fmsFile = tcFiles[0].getFmsFile(); + + System.out.println("fmsFile=" + fmsFile); + // File file=getFile(fmsFile); + fis = new FileInputStream(fmsFile); + workBook = new XSSFWorkbook(fis); + XSSFSheet sheet = workBook.getSheetAt(0); + if (prostrs != null && prostrs.length > 0) { + for (int i = 0; i < prostrs.length; i++) { + String str = prostrs[i]; + System.out.println("------" + str); + String[] split = str.split("="); + int row = Integer.parseInt(split[0]); + int col = Integer.parseInt(split[1]); + XSSFCell cell = sheet.getRow(row - 1).getCell( + col - 1); + if (cell == null) { + System.out.println("Ԫ:" + row + "--" + col + + ""); + continue; + } + if (split[2].equals("ͻ")) { + TCComponent cptform = cptrev.getReferenceListProperty("IMAN_master_form_rev")[0]; + String khmc = cptform.getTCProperty("wf2_customer").getDisplayableValue(); + System.out.println("khmc="+khmc); + if (khmc!=null) { + cell.setCellValue(khmc); + } + + }if (split[2].equals("ƷĿ")) { + + String cptid = cptrev.getProperty("item_id"); + String mjname = item.getProperty("object_name"); + mjname = mjname.split("-")[0]; + mjname=mjname.replaceAll("\\.", ""); + String cpxmbh=cptid+"-"+mjname; + cell.setCellValue(cpxmbh); + + }if (split[2].equals("ͼƬ")) { + if (jpgfile!=null) { + InputStream picin=new FileInputStream(jpgfile); + +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// BufferedImage prevImage = ImageIO.read(jpgfile); +// double width = prevImage.getWidth(); +// double height = prevImage.getHeight(); +// double percent = 156/height; +// +// ImageIO.write(prevImage, "jpg", byteArrayOut); + + XSSFDrawing patriarch = sheet.createDrawingPatriarch(); + XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (col-1), row-1, col, row); + anchor.setAnchorType(2); + // ͼƬ + + //XSSFPicture pic = patriarch.createPicture(anchor, workBook.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); + XSSFPicture pic = patriarch.createPicture(anchor, workBook.addPicture(picin, XSSFWorkbook.PICTURE_TYPE_TIFF)); + //pic.resize(percent); + if (picin!=null) { + picin.close(); + } + }else{ + System.out.println("δҵͼƬ"); + } + + }else if (split[2].contains(".")) { + String val = ""; + String str1 = split[2].split("\\.")[0]; + String str2 = split[2].split("\\.")[1]; + if (str1.toUpperCase().equals("REV")) { + val = rev.getProperty(str2); + } else if (str1.toUpperCase().equals("FORM")) { + val = form.getProperty(str2); + } else if (str1.toUpperCase().equals("ITEM")) { + val = item.getProperty(str2); + } else if (str1.toUpperCase().equals("NEWITEM")) { + val = newitem.getProperty(str2); + } else if (str1.toUpperCase().equals("NEWFORM")) { + val = newform.getProperty(str2); + } else if (str1.toUpperCase().equals("NEWREV")) { + val = newrev.getProperty(str2); + } + System.out.println("val="+val ); + int celltype=cell.getCellType(); + System.out.println("celltype="+celltype ); + if (celltype ==3||celltype==1) { + if (val != null) { + cell.setCellValue(val); + } else { + cell.setCellValue(""); + } + } + + } + } + + } + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// ڸʽ + String time = df.format(new Date()); + String excelPath = System.getenv("TEMP") + File.separator + + "WFȴտ" + time + ".xlsx"; + fileout = new File(excelPath); + System.out.println("excelPath=" + excelPath); + fos = new FileOutputStream(fileout); + workBook.write(fos); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + + if (fos != null) { + fos.close(); + } + if (fis != null) { + fis.close(); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return fileout; + } + + /** + * òƷͼ¹ҵͼƬļ + * @param rev + * @return + */ + private File getCptjpg(AIFComponentContext[] cpts) { + // TODO Auto-generated method stub + try { + // AIFComponentContext[] cpts = rev.getItem().whereReferencedByTypeRelation(new String[]{"WF2_2DprodDrawRevision"},new String[]{"WF2_moldRe"}); + + if (cpts!=null&&cpts.length>0) { + TCComponentItemRevision cpt=(TCComponentItemRevision) cpts[0].getComponent(); + TCComponent[] datasets = cpt.getReferenceListProperty("IMAN_specification"); + if (datasets!=null&&datasets.length>0) { + for (int i = 0; i < datasets.length; i++) { + TCComponentDataset dataset=(TCComponentDataset) datasets[i]; + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + if (tcFiles!=null&&tcFiles.length>0) { + File fmsFile = tcFiles[0].getFmsFile(); + if (fmsFile.getPath().endsWith("tif")) { + return fmsFile; + } + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + +} diff --git a/src/com/connor/wf/plm/wf062/ExportDPHCP_Dialog.java b/src/com/connor/wf/plm/wf062/ExportDPHCP_Dialog.java new file mode 100644 index 0000000..9885b97 --- /dev/null +++ b/src/com/connor/wf/plm/wf062/ExportDPHCP_Dialog.java @@ -0,0 +1,157 @@ +package com.connor.wf.plm.wf062; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class ExportDPHCP_Dialog extends AbstractAIFDialog { + + private JTextField textField; + private JButton okButton; + private JButton celButton; + private JButton pathButton; + // ļѡ + private JFileChooser jFileChooser; + + private TCSession session; + + public ExportDPHCP_Dialog(TCSession session) { + // TODO Auto-generated constructor stub + this.session=session; + //ExportHZB_Operation ex=new ExportHZB_Operation(maptab); + //session.queueOperation(ex); + } + + public void run() { + initUI(); + + } + private void initUI() { + // TODO Auto-generated method stub + FileSystemView fsv = FileSystemView.getFileSystemView(); // õϵͳfileview + String deskPath = fsv.getHomeDirectory().getPath(); // ǰû· + + this.setSize(new Dimension(600, 400)); + this.setTitle(""); + this.textField = new JTextField(deskPath); + + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath));// ļѡijʼĿ¼Ϊǰû + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + this.pathButton = new JButton("..."); + this.okButton = new JButton("ȷ"); + this.celButton = new JButton("ȡ"); + String name=""; + try { + name=session.getUser().getProperty("user_name"); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + JPanel midJPanel = new JPanel(new PropertyLayout()); + midJPanel.setBorder(new TitledBorder(BorderFactory + .createLineBorder(Color.WHITE), "ѡ񵼳·")); // ߿ TitleBorder + + midJPanel.add("1.1.left.top", new JLabel("·")); + midJPanel.add("1.2.left.top", this.textField); + midJPanel.add("1.3.left.top", this.pathButton); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(this.okButton); + rootJPanel.add(this.celButton); + + pathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + okEvent(); + + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + celEvent(); + + } + }); + + this.setLayout(new BorderLayout()); + this.add(midJPanel, BorderLayout.CENTER); + this.add(rootJPanel, BorderLayout.SOUTH); + + this.centerToScreen(); + this.pack(); + this.setVisible(true); + this.showDialog(); + } + + public void celEvent() { + // TODO Auto-generated method stub + this.disposeDialog(); + this.dispose(); + } + + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile();// fΪѡ񵽵Ŀ¼ + textField.setText(f.getAbsolutePath()); + } + } + + public void okEvent() { + + this.disposeDialog(); + this.dispose(); + + try { + String path=textField.getText(); + System.out.println("ok"); + + ExportDPHCP_Operation op=new ExportDPHCP_Operation(session,path); + session.queueOperation(op); + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/wf/plm/wf062/ExportDPHCP_Handler.java b/src/com/connor/wf/plm/wf062/ExportDPHCP_Handler.java new file mode 100644 index 0000000..eac68ae --- /dev/null +++ b/src/com/connor/wf/plm/wf062/ExportDPHCP_Handler.java @@ -0,0 +1,26 @@ +package com.connor.wf.plm.wf062; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class ExportDPHCP_Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + ExportDPHCP_Dialog action=new ExportDPHCP_Dialog(session); + new Thread(action).start(); + + + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf062/ExportDPHCP_Operation.java b/src/com/connor/wf/plm/wf062/ExportDPHCP_Operation.java new file mode 100644 index 0000000..c30edf7 --- /dev/null +++ b/src/com/connor/wf/plm/wf062/ExportDPHCP_Operation.java @@ -0,0 +1,671 @@ +package com.connor.wf.plm.wf062; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +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.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.imageio.ImageIO; + +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFPicture; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ExportDPHCP_Operation extends AbstractAIFOperation { + + private TCSession session; + private String path; + private File file; + + private XSSFWorkbook workBook; + private FileInputStream fis; + private FileOutputStream fos; + private String excelPath; + private ProgressBarThread wait; + private Map> cpMap = new HashMap>(); + private Map> jjgMap = new HashMap>(); + + public ExportDPHCP_Operation(TCSession session, String path) { + // TODO Auto-generated constructor stub + this.session = session; + this.path = path; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + file = getSXX(); + if (file != null) { + wait = new ProgressBarThread("ɱ", "УԵ..."); + wait.start();// + // getVal(); + getProps(); + + try { + writeExcel(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ" + e.getMessage(), "", + MessageBox.ERROR); + return; + } + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱ,鿴", "", MessageBox.INFORMATION); + //Runtime.getRuntime().exec("cmd /c \"" + excelPath + "\""); + } + + } + + /** + * ʼȡ + */ + private void getProps() { + // TODO Auto-generated method stub + + try { + TCComponent[] dphcps = session.search("...",new String[] { "" }, new String[] { "WF2_dynamicBal" }); + System.out.println("鵽ƽƷ:" + dphcps.length); + TCComponent[] dphjjgs = session.search("...",new String[] { "" }, new String[] { "WF2_dynamicBalMh" }); + System.out.println("鵽ƽӹ:" + dphjjgs.length); + + for (int i = 0; i < dphcps.length; i++) { + TCComponentItem item = (TCComponentItem) dphcps[i]; + TCComponentItemRevision itemrev = item.getLatestItemRevision(); + String khname = itemrev.getTCProperty("wf2_customerName").getDisplayableValue(); + if (khname != null && !khname.equals("")) { + if (cpMap.containsKey(khname)) { + List list = cpMap.get(khname); + list.add(itemrev); + cpMap.put(khname, list); + }else{ + List list =new ArrayList<>(); + list.add(itemrev); + cpMap.put(khname, list); + } + } + } + for (int i = 0; i < dphjjgs.length; i++) { + TCComponentItem item = (TCComponentItem) dphjjgs[i]; + TCComponentItemRevision itemrev = item.getLatestItemRevision(); + String khname = itemrev.getTCProperty("wf2_customerName").getDisplayableValue(); + if (khname != null && !khname.equals("")) { + if (jjgMap.containsKey(khname)) { + List list = jjgMap.get(khname); + list.add(itemrev); + jjgMap.put(khname, list); + }else{ + List list =new ArrayList<>(); + list.add(itemrev); + jjgMap.put(khname, list); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * ģ + * @return + */ + public File getSXX() { + TCPreferenceService pref = session.getPreferenceService(); + String puid = pref.getStringValue("WF2_dynamicBal_hzbuid");// ѡpuid + if (puid != null) { + try { + TCComponentDataset dataset = (TCComponentDataset) session + .stringToComponent(puid); + if (dataset == null) { + return null; + } + TCComponentTcFile[] file = dataset.getTcFiles(); + if (file.length == 0 || file.length != 1) { + MessageBox.post("ݼûõļļ࣬飡", "WARNING", + MessageBox.WARNING); + return null; + } else { + File fmsFile = file[0].getFmsFile(); + return fmsFile; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + MessageBox.post("δҵѡ[WF2_dynamicBal_hzbuid]ѡô", "", + MessageBox.ERROR); + return null; + } + return null; + } + + + public void writeExcel() { + // TODO Auto-generated method stub + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// ڸʽ + String time = df.format(new Date()); + excelPath = System.getenv("TEMP")+ File.separator + "ᶯƽܱ" + time + ".xlsx"; + String wsfname= System.getenv("TEMP")+ File.separator +"copySheet.wsf"; + InputStream wsfis=getClass().getResourceAsStream("copySheet.wsf"); + downloadfile(file,excelPath);//excel + downloadfile2(wsfis,wsfname);//wsf + for (Map.Entry> entry : cpMap.entrySet()) { + System.out.println("Ʒkey= " + entry.getKey()); + String key=entry.getKey(); + List listcom=entry.getValue(); + int len=listcom.size(); + int cou=(len-1)/10;//0-10 0 11-20 1 + runWsf(wsfname,new String[]{excelPath,"Ʒ",key+"(Ʒ)",cou+""}); + } + + for (Map.Entry> entry : cpMap.entrySet()) { + System.out.println("ӹkey= " + entry.getKey()); + String key=entry.getKey(); + List listcom=entry.getValue(); + int len=listcom.size(); + int cou=(len-1)/10;//0-10 0 11-20 1 + runWsf(wsfname,new String[]{excelPath,"ӹ",key+"(ӹ)",cou+""}); + } + try { + + File filein = new File(excelPath); + fis = new FileInputStream(filein); + workBook = new XSSFWorkbook(fis); + //ʼƷsheet + for (Map.Entry> entry : cpMap.entrySet()) { + String key = entry.getKey(); + XSSFSheet sheet = workBook.getSheet(key+"(Ʒ)"); + List listcom=entry.getValue(); + for (int i = 0; i < listcom.size(); i++) { + TCComponentItemRevision rev = (TCComponentItemRevision) listcom.get(i); + String value1 = rev.getProperty("wf2_customerName");// ͻ + String value2 = rev.getProperty("wf2_productNumber");// Ʒ + String value3 = rev.getProperty("wf2_customerStandard");// ͻ׼ + String value4 = rev.getProperty("wf2_valveType");// ͺ + String[] value5_1 = rev.getTCProperty("wf2_dynamicBalMePoint") + .getStringArrayValue();// ƽ1 + String[] value5_2 = rev.getTCProperty("wf2_dynamicBalMePointVal") + .getStringArrayValue();// ƽ2 + String value6 = rev.getProperty("wf2_ET");// ƫET + String value7 = rev.getProperty("wf2_diameter");// Ŀֱ + String value8 = rev.getProperty("wf2_harmonicRqmt");// гҪ + String value9 = rev.getProperty("wf2_finishedPatch");// Ʒ + String value10 = rev.getProperty("wf2_size");// + int n=i/10;//iΪi+1 + int m=i%10+1; + int rownum=n*23+m*2+2; + System.out.println(""+(i+1)+"---"+rownum+""); + XSSFRow row = sheet.getRow(rownum-1); + if (row==null) { + row=sheet.createRow(rownum-1); + } + for (int j = 0; j < 12; j++) { + XSSFCell cell=getCell(row,j); + switch (j) { + case 0: + if (m==1) { + cell.setCellValue(value1); + } + break; + case 1: + setJpg(value2,sheet,rownum-1,1); + break; + case 2: + cell.setCellValue(value2==null?"":value2); + break; + case 3: + cell.setCellValue(value3==null?"":value3); + break; + case 4: + cell.setCellValue(value4==null?"":value4); + break; + case 5: + if (value5_1!=null) { + for (int k = 0; k < value5_1.length; k++) { + if (k!=0) { + XSSFRow row2 = sheet.getRow(rownum-1+k); + XSSFCell cell2 = getCell(row2, j); + cell=cell2; + } + cell.setCellValue(value5_1[k]==null?"":value5_1[k]); + } + } + break; + case 6: + if (value5_2!=null) { + for (int k = 0; k < value5_2.length; k++) { + if (k!=0) { + XSSFRow row2 = sheet.getRow(rownum-1+k); + XSSFCell cell2 = getCell(row2, j); + cell=cell2; + } + cell.setCellValue(value5_2[k]==null?"":value5_2[k]); + } + } + break; + case 7: + cell.setCellValue(value6==null?"":value6); + break; + case 8: + cell.setCellValue(value7==null?"":value7); + break; + case 9: + cell.setCellValue(value8==null?"":value8); + break; + case 10: + cell.setCellValue(value9==null?"":value9); + break; + case 11: + cell.setCellValue(value10); + break; + default: + break; + } + + } + + } + + } + //ʼӹsheet + for (Map.Entry> entry : jjgMap.entrySet()) { + String key = entry.getKey(); + XSSFSheet sheet = workBook.getSheet(key+"(ӹ)"); + List listcom=entry.getValue(); + for (int i = 0; i < listcom.size(); i++) { + TCComponentItemRevision rev = (TCComponentItemRevision) listcom.get(i); + String value1 = rev.getProperty("wf2_customerName");// ͻ + String value2 = rev.getProperty("wf2_productNumber");// Ʒ + String value3 = rev.getProperty("wf2_fileStandard");// ļ׼ + String value4 = rev.getProperty("wf2_internalAcceptMe");// ڲ(ӹ) + String value5 = rev.getProperty("wf2_maxReworkAllowed");// + String value6 = rev.getProperty("wf2_reworkPoint");// + String value7 = rev.getProperty("wf2_customerStandard");// ͻ׼ + String value8 = rev.getProperty("wf2_internalAcceptFin");// ڲ(Ʒ) + String value9 = rev.getProperty("wf2_valveCounterweight");// + String value10 = rev.getProperty("wf2_size");// + String value11 = rev.getProperty("wf2_diameter");// Ŀ + String[] valStr_1 = rev.getTCProperty("wf2_dynamicBalMePoint").getStringArrayValue();// ƽ1 + String[] valStr_2 = rev.getTCProperty("wf2_dynamicBalMePointVal").getStringArrayValue();// ƽ2 + int n=i/10;//iΪi+1 + int m=i%10+1; + int rownum=n*23+m*2+2; + System.out.println(""+(i+1)+"---"+rownum+""); + XSSFRow row = sheet.getRow(rownum-1); + if (row==null) { + row=sheet.createRow(rownum-1); + } + for (int j = 0; j < 14; j++) { + XSSFCell cell=getCell(row,j); + switch (j) { + case 0: + if (m==1) { + cell.setCellValue(value1); + } + break; + case 1: + setJpg(value2,sheet,rownum-1,1); + break; + case 2: + cell.setCellValue(value2==null?"":value2); + break; + case 3: + cell.setCellValue(value3==null?"":value3); + break; + case 4: + cell.setCellValue(value4==null?"":value4); + break; + case 5: + cell.setCellValue(value5==null?"":value5); + break; + case 6: + cell.setCellValue(value6==null?"":value6); + break; + case 7: + cell.setCellValue(value7==null?"":value7); + break; + case 8: + cell.setCellValue(value8==null?"":value8); + break; + case 9: + cell.setCellValue(value9==null?"":value9); + break; + case 10: + if (valStr_1!=null) { + for (int k = 0; k < valStr_1.length; k++) { + if (k!=0) { + XSSFRow row2 = sheet.getRow(rownum-1+k); + XSSFCell cell2 = getCell(row2, j); + cell=cell2; + } + cell.setCellValue(valStr_1[k]==null?"":valStr_1[k]); + } + } + break; + case 11: + if (valStr_2!=null) { + for (int k = 0; k < valStr_2.length; k++) { + if (k!=0) { + XSSFRow row2 = sheet.getRow(rownum-1+k); + XSSFCell cell2 = getCell(row2, j); + cell=cell2; + } + cell.setCellValue(valStr_2[k]==null?"":valStr_2[k]); + } + } + break; + case 12: + cell.setCellValue(value10); + break; + case 13: + cell.setCellValue(value11); + break; + default: + break; + } + } + } + } + String usertime = df.format(new Date()); + String userpath = path + File.separator + + "ƽܱ" + usertime + ".xlsx"; + File fileout = new File(userpath); + System.out.println("userpath=" + userpath); + fos = new FileOutputStream(fileout); + workBook.write(fos); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ," + e.getMessage(), "", MessageBox.ERROR); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ" + e.getMessage(), "", MessageBox.ERROR); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ" + e.getMessage(), "", MessageBox.ERROR); + } + + } + + /** + * ͼƬ + * @param rev 汾 + * @param sheet + * @param row + * @param col + */ + private void setJpg(String name, XSSFSheet sheet, + int row, int col) { + // TODO Auto-generated method stub + System.out.println("Ʒ:"+name); + TCComponentItemRevision rev=null; + try { + if (name != null) { + TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem find = type.find(name); + if (find!=null&&find.getType().equals("WF2_finPart")) { + TCComponentItemRevision cplaterev = find.getLatestItemRevision(); + TCComponent[] cpts = cplaterev.getReferenceListProperty("TC_Is_Represented_By"); + if (cpts!=null&&cpts.length>0) { + if (cpts[0] instanceof TCComponentItemRevision) { + rev=(TCComponentItemRevision) cpts[0]; + } + } + } + //rev=find.getLatestItemRevision(); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (rev==null) { + System.out.println("δҵƷͼ"); + return; + } + File jpgfile=getCptjpg(rev); + if (jpgfile!=null) { + try { +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// BufferedImage prevImage = ImageIO.read(jpgfile); + + InputStream picin=new FileInputStream(jpgfile); + + //ImageIO.write(prevImage, "jpg", byteArrayOut); + + XSSFDrawing patriarch = sheet.createDrawingPatriarch(); + XSSFClientAnchor anchor = new XSSFClientAnchor(3*10000,3*10000,-3*10000,-3*10000,col,row,col+1,row+2);//ƫ; + anchor.setAnchorType(2); + // ͼƬ + XSSFPicture pic = patriarch.createPicture(anchor, workBook.addPicture(picin, XSSFWorkbook.PICTURE_TYPE_TIFF)); + //pic.resize(percent); + if (picin!=null) { + picin.close(); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else{ + System.out.println(rev+"δҵͼƬ"); + } + + + } + + /** + * òƷͼ¹ҵͼƬļ + * + * @param rev + * @return + */ + private File getCptjpg(TCComponentItemRevision cpt) { + // TODO Auto-generated method stub + try { + + TCComponent[] datasets = cpt + .getReferenceListProperty("IMAN_specification"); + if (datasets != null && datasets.length > 0) { + for (int i = 0; i < datasets.length; i++) { + TCComponentDataset dataset = (TCComponentDataset) datasets[i]; + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + if (tcFiles != null && tcFiles.length > 0) { + File fmsFile = tcFiles[0].getFmsFile(); + if ( +// fmsFile.getPath().endsWith("jpg") +// || fmsFile.getPath().endsWith("png") +// || + fmsFile.getPath().endsWith("tif")) { + return fmsFile; + } + } + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + + // cell + private XSSFCell getCell(XSSFRow row, int j) { + // TODO Auto-generated method stub + XSSFCell cell = row.getCell(j); + CellStyle sty = workBook.createCellStyle(); + if (cell == null) { + cell = row.createCell(j); + cell.setCellStyle(sty); + } + return cell; + } + + // vbű + 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()]); + Runtime runtime = Runtime.getRuntime(); + Process process = runtime.exec(cmd); + process.waitFor(); + // MessageBox.post("Success!","INFORMATION",MessageBox.INFORMATION); + + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + public void writeSheet(XSSFSheet sheet, List> list) { + // TODO Auto-generated method stub + for (int i = 0; i < list.size(); i++) { + XSSFRow rowm = sheet.createRow(i + 1); + XSSFCellStyle sty = workBook.createCellStyle(); // sheet.getRow(0).getCell(0).getCellStyle(); + for (int j = 0; j < list.get(i).size(); j++) { + XSSFCell c = rowm.createCell(j); + c.setCellStyle(sty); + c.setCellValue(list.get(i).get(j)); + + } + + } + + } + + /** + * ļصָ· + * + * @param fpath + * Ҫصļ + * @param path + * صļλ + */ + private void downloadfile(File fpath, String path) { + FileInputStream fis = null; + FileOutputStream fos = null; + try { + File fileout = new File(path); + fis = new FileInputStream(fpath); + fos = new FileOutputStream(fileout); + byte[] bs = new byte[1024]; + int len = 0; + while ((len = fis.read(bs)) != -1) { + fos.write(bs, 0, len); + } + if (fos != null) + fos.close(); + if (fis != null) + fis.close(); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (fos != null) + fos.close(); + if (fis != null) + fis.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ļصָ· + * + * @param fpath + * Ҫصļ + * @param path + * صļλ + */ + private void downloadfile2(InputStream fis, String path) { + FileOutputStream fos = null; + try { + File fileout = new File(path); + fos = new FileOutputStream(fileout); + byte[] bs = new byte[1024]; + int len = 0; + while ((len = fis.read(bs)) != -1) { + fos.write(bs, 0, len); + } + if (fos != null) + fos.close(); + if (fis != null) + fis.close(); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (fos != null) + fos.close(); + if (fis != null) + fis.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + +} diff --git a/src/com/connor/wf/plm/wf062/copySheet.wsf b/src/com/connor/wf/plm/wf062/copySheet.wsf new file mode 100644 index 0000000..bc79be0 --- /dev/null +++ b/src/com/connor/wf/plm/wf062/copySheet.wsf @@ -0,0 +1,64 @@ + + + + diff --git a/src/com/connor/wf/plm/wf063/Wf063Dialog.java b/src/com/connor/wf/plm/wf063/Wf063Dialog.java new file mode 100644 index 0000000..9890f0b --- /dev/null +++ b/src/com/connor/wf/plm/wf063/Wf063Dialog.java @@ -0,0 +1,141 @@ +package com.connor.wf.plm.wf063; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileSystemView; + +import com.connor.wf.plm.wf052.Wf052_2Operation; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf063Dialog extends AbstractAIFDialog{ + + private TCSession session; + private JTextField textField; + private JButton okButton; + private JButton celButton; + private JButton pathButton; + // ļѡ + private JFileChooser jFileChooser; + public Wf063Dialog(TCSession session){ + this.session = session; + } + public void run(){ + initUI(); + } + private void initUI() { + // TODO Auto-generated method stub + FileSystemView fsv = FileSystemView.getFileSystemView(); // õϵͳfileview + String deskPath = fsv.getHomeDirectory().getPath(); // ǰû· + + this.setSize(new Dimension(600, 400)); + this.setTitle(""); + this.textField = new JTextField(deskPath); + + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath));// ļѡijʼĿ¼Ϊǰû + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + this.pathButton = new JButton("..."); + this.okButton = new JButton("ȷ"); + this.celButton = new JButton("ȡ"); + + JPanel midJPanel = new JPanel(new PropertyLayout()); + midJPanel.setBorder(new TitledBorder(BorderFactory + .createLineBorder(Color.WHITE), "ѡ񵼳·")); // ߿ TitleBorder + + midJPanel.add("1.1.left.top", new JLabel("·")); + midJPanel.add("1.2.left.top", this.textField); + midJPanel.add("1.3.left.top", this.pathButton); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(this.okButton); + rootJPanel.add(this.celButton); + + pathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + okEvent(); + + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + celEvent(); + + } + }); + + this.setLayout(new BorderLayout()); + this.add(midJPanel, BorderLayout.CENTER); + this.add(rootJPanel, BorderLayout.SOUTH); + + this.centerToScreen(); + this.pack(); + this.setVisible(true); + this.showDialog(); + } + + public void celEvent() { + // TODO Auto-generated method stub + this.disposeDialog(); + this.dispose(); + } + + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile();// fΪѡ񵽵Ŀ¼ + textField.setText(f.getAbsolutePath()); + } + } + + public void okEvent() { + + this.disposeDialog(); + this.dispose(); + + try { + String path=textField.getText(); + System.out.println("ok"); + + Wf063Operation op=new Wf063Operation(session,path); + session.queueOperation(op); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/wf/plm/wf063/Wf063Handler.java b/src/com/connor/wf/plm/wf063/Wf063Handler.java new file mode 100644 index 0000000..2957aae --- /dev/null +++ b/src/com/connor/wf/plm/wf063/Wf063Handler.java @@ -0,0 +1,23 @@ +package com.connor.wf.plm.wf063; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.wf.plm.wf052.WF052_2Dialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf063Handler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Wf063Dialog dialog = new Wf063Dialog(session); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf063/Wf063Operation.java b/src/com/connor/wf/plm/wf063/Wf063Operation.java new file mode 100644 index 0000000..2306ad1 --- /dev/null +++ b/src/com/connor/wf/plm/wf063/Wf063Operation.java @@ -0,0 +1,256 @@ +package com.connor.wf.plm.wf063; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFTable; +import org.apache.poi.xwpf.usermodel.XWPFTableCell; +import org.apache.poi.xwpf.usermodel.XWPFTableRow; + +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf063Operation extends AbstractAIFOperation{ + private TCSession session; + private String path; + private TCPreferenceService service; + private ProgressBarThread wait; + public Wf063Operation(TCSession session, String path) { + this.session = session; + this.path = path; + this.service = session.getPreferenceService(); + } + @Override + public void executeOperation() throws Exception { + String[] keys = new String[]{""}; + String[] values = new String[]{"WF2_trailRunPlan"}; + List compList = queryObject("Ҷ", keys, values); + String puid = service.getStringValue("WF2_shizhi_Excel"); + TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(puid); + File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// ڸʽ + String time = df.format(new Date()); + path = path + File.separator + "ƷƼ¼ܱ" + time + ".xlsx"; + wait = new ProgressBarThread("ɱ", + "УԵ..."); + wait.start();// + try { + writeExcel(compList,file,path); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ"+e.getMessage(),"",MessageBox.ERROR); + return; + } + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱ,鿴","",MessageBox.INFORMATION); + Runtime.getRuntime().exec("cmd /c \"" + path + "\""); + } + + + + /** + * ͨѯѯƷͼ + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName ,String[] keys,String[] values){ + TCComponent[] components = null; + try { + 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; + } + } + public void writeExcel(List compList, File file,String path){ + try { + FileInputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is); + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(3); + short h = targetRow.getHeight(); + XSSFCell targetCell = targetRow.getCell(0); + XSSFCellStyle cellStyle = targetCell.getCellStyle(); + int o = 3; + int t = 1; + for (int i = 0; i < compList.size(); i++) { + TCComponentItem item = (TCComponentItem) compList.get(i); + TCComponent[] revs = item.getReferenceListProperty("revision_list"); + for (int j = 0; j < revs.length; j++) { + String[] arrs = new String[59]; + for (int k = 0; k < arrs.length; k++) { + arrs[k] = " "; + } + if(revs[j] instanceof TCComponentItemRevision){ + TCComponentItemRevision rev = (TCComponentItemRevision) revs[j]; + TCComponent[] status = rev.getReferenceListProperty("release_status_list"); + if(status == null || status.length <= 0) { + continue; + } + TCComponent[] references = rev.getReferenceListProperty("IMAN_specification"); + for(int p = 0;p < references.length;p++){ + if(references[p] instanceof TCComponentDataset){ + TCComponentDataset dataset = (TCComponentDataset) references[p]; + String type = dataset.getStringProperty("object_type"); + String name = dataset.getStringProperty("object_name"); + System.out.println("====================="+name+type); + if("MSWordX".equals(type)){ + try { + TCComponentTcFile[] files = dataset.getTcFiles(); + if(files != null && files.length > 0){ + File file1 = files[0].getFmsFile(); + FileInputStream in = new FileInputStream(file1); + XWPFDocument document = new XWPFDocument (in); + List tables = document.getTables(); + XWPFTable table = tables.get(0); + List rows = table.getRows(); + arrs[0] = ""+t; + t++; + List tableCells = rows.get(1).getTableCells(); + XWPFTableCell cell = tableCells.get(3); + String value = cell.getText(); + arrs[1] = value; + tableCells = rows.get(2).getTableCells(); + cell = tableCells.get(1); + value = cell.getText(); + arrs[2] = value; + value = rev.getStringProperty("item_id"); + arrs[3] = value; + tableCells = rows.get(4).getTableCells(); + cell = tableCells.get(1); + value = cell.getText(); + arrs[4] = value; + tableCells = rows.get(6).getTableCells(); + cell = tableCells.get(1); + value = cell.getText(); + arrs[5] = value; + tableCells = rows.get(5).getTableCells(); + cell = tableCells.get(1); + value = cell.getText(); + arrs[7] = value; + + in.close(); + + + XSSFRow row = sheet.getRow(o); + if(row == null){ + row = sheet.createRow(o); + } + for (int k = 0; k < arrs.length; k++) { + XSSFCell excelCell = row.getCell(k); + if(excelCell == null){ + excelCell = row.createCell(k); + } + excelCell.setCellStyle(cellStyle); + excelCell.setCellValue(arrs[k]); + } + o++; + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + } + } + } + } + FileOutputStream output = new FileOutputStream(new File(path)); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static String getCellValue(XSSFCell cell){ + String cellValue = ""; + if(cell == null){ + return cellValue; + } + switch (cell.getCellType()) { + case XSSFCell.CELL_TYPE_NUMERIC: + if(DateUtil.isCellDateFormatted(cell)){ + SimpleDateFormat sdf = null; + if(cell.getCellStyle().getDataFormat() == 14){ + sdf = new SimpleDateFormat("yyyy/MM/dd"); + }else if(cell.getCellStyle().getDataFormat() == 21){ + sdf = new SimpleDateFormat("HH:mm:ss"); + }else if(cell.getCellStyle().getDataFormat() == 22){ + sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + }else{ + throw new RuntimeException("ڸʽ!!!"); + } + Date date = cell.getDateCellValue(); + cellValue = sdf.format(date); + }else if(cell.getCellStyle().getDataFormat() == 0){ + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cellValue = String.valueOf(cell.getRichStringCellValue().getString()); + } + break; + case XSSFCell.CELL_TYPE_STRING: + cellValue = String.valueOf(cell.getStringCellValue()); + break; + case XSSFCell.CELL_TYPE_BOOLEAN: + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case XSSFCell.CELL_TYPE_FORMULA: + cellValue = String.valueOf(cell.getCellFormula()); + break; + case XSSFCell.CELL_TYPE_BLANK: + cellValue = null; + break; + case XSSFCell.CELL_TYPE_ERROR: + cellValue = "Ƿַ"; + break; + default: + break; + } + return cellValue; + } + +} diff --git a/src/com/connor/wf/plm/wf064.rar b/src/com/connor/wf/plm/wf064.rar new file mode 100644 index 0000000..5bbec30 Binary files /dev/null and b/src/com/connor/wf/plm/wf064.rar differ diff --git a/src/com/connor/wf/plm/wf064/DateChooser.java b/src/com/connor/wf/plm/wf064/DateChooser.java new file mode 100644 index 0000000..c1934f4 --- /dev/null +++ b/src/com/connor/wf/plm/wf064/DateChooser.java @@ -0,0 +1,1391 @@ +package com.connor.wf.plm.wf064; + +import java.awt.BasicStroke; + +import java.awt.BorderLayout; + +import java.awt.Color; + +import java.awt.Component; + +import java.awt.Cursor; + +import java.awt.Dimension; + +import java.awt.Font; + +import java.awt.Graphics; + +import java.awt.Graphics2D; + +import java.awt.GridLayout; + +import java.awt.Point; + +import java.awt.Polygon; + +import java.awt.Stroke; + +import java.awt.Toolkit; + +import java.awt.event.FocusEvent; + +import java.awt.event.FocusListener; + +import java.awt.event.MouseAdapter; + +import java.awt.event.MouseEvent; + +import java.awt.event.MouseListener; + +import java.awt.event.MouseMotionListener; + +import java.text.SimpleDateFormat; + +import java.util.ArrayList; + +import java.util.Calendar; + +import java.util.Comparator; + +import java.util.Date; + +import java.util.List; + + + +import javax.swing.BorderFactory; + +import javax.swing.JComponent; + +import javax.swing.JFrame; + +import javax.swing.JLabel; + +import javax.swing.JPanel; + +import javax.swing.JTextField; + +import javax.swing.Popup; + +import javax.swing.PopupFactory; + +import javax.swing.SwingUtilities; + +import javax.swing.event.AncestorEvent; + +import javax.swing.event.AncestorListener; + + + +/** + + * ѡָڵʾʽ + + */ + +public class DateChooser extends JPanel { + + + + private static final long serialVersionUID = 4529266044762990227L; + + + + private Date initDate; + + private Calendar now = Calendar.getInstance(); + + private Calendar select; + + private JPanel monthPanel;// + + private JP1 jp1;//Ŀ, + + private JP2 jp2; + + private JP3 jp3; + + private JP4 jp4; + + private Font font = new Font("", Font.PLAIN, 12); + + private final LabelManager lm = new LabelManager(); + + private SimpleDateFormat sdf; + + private boolean isShow = false; + + private Popup pop; + + + + private JComponent showDate; + + + + public static DateChooser getInstance() { + + return new DateChooser(); + + } + + + + public static DateChooser getInstance(Date date) { + + return new DateChooser(date); + + } + + + + public static DateChooser getInstance(String format) { + + return new DateChooser(format); + + } + + + + public static DateChooser getInstance(Date date, String format) { + + return new DateChooser(date, format); + + } + + + + /** + + * Creates a new instance of DateChooser + + */ + + private DateChooser() { + + this(new Date()); + + } + + + + private DateChooser(Date date) { + + this(date, "yyyyMMdd"); + + } + + + + private DateChooser(String format) { + + this(new Date(), format); + + } + + + + private DateChooser(Date date, String format) { + + initDate = date; + + sdf = new SimpleDateFormat(format); + + select = Calendar.getInstance(); + + select.setTime(initDate); + + initPanel(); + + } + + + + /** + + * Ƿûѡ + + */ + + public void setEnabled(boolean b) { + + super.setEnabled(b); + + showDate.setEnabled(b); + + } + + + + /** + + *õǰѡ + + */ + + public Date getDate() { + + return select.getTime(); + + } + + + + public String getStrDate() { + + return sdf.format(select.getTime()); + + } + + + + public String getStrDate(String format) { + + sdf = new SimpleDateFormat(format); + + return sdf.format(select.getTime()); + + } + + + + //ݳʼ,ʼ + + private void initPanel() { + + monthPanel = new JPanel(new BorderLayout()); + + monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + + JPanel up = new JPanel(new BorderLayout()); + + up.add(jp1 = new JP1(), BorderLayout.NORTH); + + up.add(jp2 = new JP2(), BorderLayout.CENTER); + + monthPanel.add(jp3 = new JP3(), BorderLayout.CENTER); + + monthPanel.add(up, BorderLayout.NORTH); + + monthPanel.add(jp4 = new JP4(), BorderLayout.SOUTH); + + this.addAncestorListener(new AncestorListener() { + + public void ancestorAdded(AncestorEvent event) { + + + + } + + + + public void ancestorRemoved(AncestorEvent event) { + + + + } + + + + //ֻҪһƶ,Ͼpopupʧ + + public void ancestorMoved(AncestorEvent event) { + + hidePanel(); + + } + + }); + + } + + + + public void register(final JComponent showDate) { + + this.showDate = showDate; + + + + showDate.setRequestFocusEnabled(true); + + showDate.addMouseListener(new MouseAdapter() { + + public void mousePressed(MouseEvent me) { + + showDate.requestFocusInWindow(); + + } + + }); + + this.setBackground(Color.WHITE); + + this.add(showDate, BorderLayout.CENTER); + + this.setPreferredSize(new Dimension(90, 25)); + + this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); + + showDate.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + showDate.setForeground(Color.RED); + + } + + } + + + + public void mouseExited(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + showDate.setForeground(Color.BLACK); + + } + + } + + + + public void mousePressed(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.CYAN); + + if (isShow) { + + hidePanel(); + + } else { + + showPanel(showDate); + + } + + } + + } + + + + public void mouseReleased(MouseEvent me) { + + if (showDate.isEnabled()) { + + showDate.setForeground(Color.BLACK); + + } + + } + + }); + + showDate.addFocusListener(new FocusListener() { + + public void focusLost(FocusEvent e) { + + hidePanel(); + + } + + + + public void focusGained(FocusEvent e) { + + + + } + + }); + + } + + + + //µˢ + + private void refresh() { + + jp1.updateDate(); + + jp2.updateDate(); + + jp3.updateDate(); + + jp4.updateDate(); + + SwingUtilities.updateComponentTreeUI(this); + + } + + + + //ύ + + private void commit() { + + //TODO add other components here + + if (showDate instanceof JTextField) { + + ((JTextField) showDate).setText(sdf.format(select.getTime())); + + }else if (showDate instanceof JLabel) { + + ((JLabel) showDate).setText(sdf.format(select.getTime())); + + } + + + + hidePanel(); + + } + + + + //ѡ + + private void hidePanel() { + + if (pop != null) { + + isShow = false; + + pop.hide(); + + pop = null; + + } + + } + + + + //ʾѡ + + private void showPanel(Component owner) { + + if (pop != null) { + + pop.hide(); + + } + + Point show = new Point(0, showDate.getHeight()); + + SwingUtilities.convertPointToScreen(show, showDate); + + Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); + + int x = show.x; + + int y = show.y; + + if (x < 0) { + + x = 0; + + } + + if (x > size.width - 295) { + + x = size.width - 295; + + } + + if (y < size.height - 170) { + + } else { + + y -= 188; + + } + + pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y); + + pop.show(); + + isShow = true; + + } + + + + /** + + * ʾ·ݵ + + */ + + private class JP1 extends JPanel { + + private static final long serialVersionUID = -5638853772805561174L; + + JLabel yearleft, yearright, monthleft, monthright, center, centercontainer; + + + + public JP1() { + + super(new BorderLayout()); + + this.setBackground(new Color(160, 185, 215)); + + initJP1(); + + } + + + + private void initJP1() { + + yearleft = new JLabel(" <<", JLabel.CENTER); + + yearleft.setToolTipText("һ"); + + yearright = new JLabel(">> ", JLabel.CENTER); + + yearright.setToolTipText("һ"); + + yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + + + + monthleft = new JLabel(" <", JLabel.RIGHT); + + monthleft.setToolTipText("һ"); + + monthright = new JLabel("> ", JLabel.LEFT); + + monthright.setToolTipText("һ"); + + monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); + + monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); + + + + centercontainer = new JLabel("", JLabel.CENTER); + + centercontainer.setLayout(new BorderLayout()); + + center = new JLabel("", JLabel.CENTER); + + + + centercontainer.add(monthleft, BorderLayout.WEST); + + centercontainer.add(center, BorderLayout.CENTER); + + centercontainer.add(monthright, BorderLayout.EAST); + + + + this.add(yearleft, BorderLayout.WEST); + + this.add(centercontainer, BorderLayout.CENTER); + + this.add(yearright, BorderLayout.EAST); + + this.setPreferredSize(new Dimension(295, 25)); + + + + updateDate(); + + + + yearleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearleft.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + yearleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearleft.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, -1); + + yearleft.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + yearleft.setForeground(Color.BLACK); + + } + + }); + + yearright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + yearright.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + yearright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + yearright.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.YEAR, 1); + + yearright.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + yearright.setForeground(Color.BLACK); + + } + + }); + + monthleft.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthleft.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + monthleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthleft.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, -1); + + monthleft.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + monthleft.setForeground(Color.BLACK); + + } + + }); + + monthright.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + monthright.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + monthright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + monthright.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + select.add(Calendar.MONTH, 1); + + monthright.setForeground(Color.WHITE); + + refresh(); + + } + + + + public void mouseReleased(MouseEvent me) { + + monthright.setForeground(Color.BLACK); + + } + + }); + + } + + + + private void updateDate() { + + center.setText(select.get(Calendar.YEAR) + "" + (select.get(Calendar.MONTH) + 1) + ""); + + } + + } + + + + private class JP2 extends JPanel { + + private static final long serialVersionUID = -8176264838786175724L; + + + + public JP2() { + + this.setPreferredSize(new Dimension(295, 20)); + + } + + + + protected void paintComponent(Graphics g) { + + g.setFont(font); + + g.drawString(" һ ڶ ", 5, 10); + + g.drawLine(0, 15, getWidth(), 15); + + } + + + + private void updateDate() { + + + + } + + } + + + + private class JP3 extends JPanel { + + private static final long serialVersionUID = 43157272447522985L; + + + + public JP3() { + + super(new GridLayout(6, 7)); + + this.setPreferredSize(new Dimension(295, 100)); + + initJP3(); + + } + + + + private void initJP3() { + + updateDate(); + + } + + + + public void updateDate() { + + this.removeAll(); + + lm.clear(); + + Date temp = select.getTime(); + + Calendar select = Calendar.getInstance(); + + select.setTime(temp); + + select.set(Calendar.DAY_OF_MONTH, 1); + + int index = select.get(Calendar.DAY_OF_WEEK); + + int sum = (index == 1 ? 8 : index); + + select.add(Calendar.DAY_OF_MONTH, 0 - sum); + + for (int i = 0; i < 42; i++) { + + select.add(Calendar.DAY_OF_MONTH, 1); + + lm.addLabel(new MyLabel(select.get(Calendar.YEAR), select.get(Calendar.MONTH), select.get(Calendar.DAY_OF_MONTH))); + + } + + for (MyLabel my : lm.getLabels()) { + + this.add(my); + + } + + select.setTime(temp); + + } + + } + + + + private class MyLabel extends JLabel implements Comparator, MouseListener, MouseMotionListener { + + private static final long serialVersionUID = 3668734399227577214L; + + private int year, month, day; + + private boolean isSelected; + + + + public MyLabel(int year, int month, int day) { + + super("" + day, JLabel.CENTER); + + this.year = year; + + this.day = day; + + this.month = month; + + this.addMouseListener(this); + + this.addMouseMotionListener(this); + + this.setFont(font); + + if (month == select.get(Calendar.MONTH)) { + + this.setForeground(Color.BLACK); + + } else { + + this.setForeground(Color.LIGHT_GRAY); + + } + + if (day == select.get(Calendar.DAY_OF_MONTH)) { + + this.setBackground(new Color(160, 185, 215)); + + } else { + + this.setBackground(Color.WHITE); + + } + + } + + + + public boolean getIsSelected() { + + return isSelected; + + } + + + + public void setSelected(boolean b, boolean isDrag) { + + isSelected = b; + + if (b && !isDrag) { + + int temp = select.get(Calendar.MONTH); + + select.set(year, month, day); + + if (temp == month) { + + SwingUtilities.updateComponentTreeUI(jp3); + + } else { + + refresh(); + + } + + } + + this.repaint(); + + } + + + + protected void paintComponent(Graphics g) { + + if (day == select.get(Calendar.DAY_OF_MONTH) && month == select.get(Calendar.MONTH)) { + + //ǰѡ,ʾ + + g.setColor(new Color(160, 185, 215)); + + g.fillRect(0, 0, getWidth(), getHeight()); + + } + + if (year == now.get(Calendar.YEAR) && month == now.get(Calendar.MONTH) && day == now.get(Calendar.DAY_OF_MONTH)) { + + //ں͵ǰһ,ú + + Graphics2D gd = (Graphics2D) g; + + gd.setColor(Color.RED); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + if (isSelected) {//ѡ˾ͻһ߿ + + Stroke s = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 2.0f, 2.0f }, 1.0f); + + Graphics2D gd = (Graphics2D) g; + + gd.setStroke(s); + + gd.setColor(Color.BLACK); + + Polygon p = new Polygon(); + + p.addPoint(0, 0); + + p.addPoint(getWidth() - 1, 0); + + p.addPoint(getWidth() - 1, getHeight() - 1); + + p.addPoint(0, getHeight() - 1); + + gd.drawPolygon(p); + + } + + super.paintComponent(g); + + } + + + + public boolean contains(Point p) { + + return this.getBounds().contains(p); + + } + + + + private void update() { + + repaint(); + + } + + + + public void mouseClicked(MouseEvent e) { + + } + + + + public void mousePressed(MouseEvent e) { + + isSelected = true; + + update(); + + } + + + + public void mouseReleased(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, false); + + commit(); + + } + + + + public void mouseEntered(MouseEvent e) { + + } + + + + public void mouseExited(MouseEvent e) { + + } + + + + public void mouseDragged(MouseEvent e) { + + Point p = SwingUtilities.convertPoint(this, e.getPoint(), jp3); + + lm.setSelect(p, true); + + } + + + + public void mouseMoved(MouseEvent e) { + + } + + + + public int compare(MyLabel o1, MyLabel o2) { + + Calendar c1 = Calendar.getInstance(); + + c1.set(o1.year, o2.month, o1.day); + + Calendar c2 = Calendar.getInstance(); + + c2.set(o2.year, o2.month, o2.day); + + return c1.compareTo(c2); + + } + + } + + + + private class LabelManager { + + private List list; + + + + public LabelManager() { + + list = new ArrayList(); + + } + + + + public List getLabels() { + + return list; + + } + + + + public void addLabel(MyLabel my) { + + list.add(my); + + } + + + + public void clear() { + + list.clear(); + + } + + + + @SuppressWarnings("unused") + + public void setSelect(MyLabel my, boolean b) { + + for (MyLabel m : list) { + + if (m.equals(my)) { + + m.setSelected(true, b); + + } else { + + m.setSelected(false, b); + + } + + } + + } + + + + public void setSelect(Point p, boolean b) { + + //϶,ҪŻһ,Ч + + if (b) { + + //ʾǷܷ,ñȽеıǩ,ܷصı־ǰһǩ + + //Ҫʾıǩҵ˾Ϳ + + boolean findPrevious = false, findNext = false; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + findNext = true; + + if (m.getIsSelected()) { + + findPrevious = true; + + } else { + + m.setSelected(true, b); + + } + + } else if (m.getIsSelected()) { + + findPrevious = true; + + m.setSelected(false, b); + + } + + if (findPrevious && findNext) { + + return; + + } + + } + + } else { + + MyLabel temp = null; + + for (MyLabel m : list) { + + if (m.contains(p)) { + + temp = m; + + } else if (m.getIsSelected()) { + + m.setSelected(false, b); + + } + + } + + if (temp != null) { + + temp.setSelected(true, b); + + } + + } + + } + + + + } + + + + private class JP4 extends JPanel { + + private static final long serialVersionUID = -6391305687575714469L; + + + + public JP4() { + + super(new BorderLayout()); + + this.setPreferredSize(new Dimension(295, 20)); + + this.setBackground(new Color(160, 185, 215)); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + + final JLabel jl = new JLabel(": " + sdf.format(new Date())); + + jl.setToolTipText("ѡ"); + + this.add(jl, BorderLayout.CENTER); + + jl.addMouseListener(new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + jl.setForeground(Color.RED); + + } + + + + public void mouseExited(MouseEvent me) { + + jl.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + + jl.setForeground(Color.BLACK); + + } + + + + public void mousePressed(MouseEvent me) { + + jl.setForeground(Color.WHITE); + + select.setTime(new Date()); + + refresh(); + + commit(); + + } + + + + public void mouseReleased(MouseEvent me) { + + jl.setForeground(Color.BLACK); + + } + + }); + + } + + + + private void updateDate() { + + + + } + + } + + + + public static void main(String[] args) { + + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-MM-dd"); + + JTextField showDate1 = new JTextField("ѡ"); + + JLabel showDate2 = new JLabel("ѡ"); + + + + dateChooser1.register(showDate1); + + dateChooser2.register(showDate2); + + + + JFrame jf = new JFrame("ѡ"); + + jf.add(showDate1, BorderLayout.NORTH); + + jf.add(showDate2, BorderLayout.SOUTH); + + jf.pack(); + + jf.setLocationRelativeTo(null); + + jf.setVisible(true); + + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + } + +} \ No newline at end of file diff --git a/src/com/connor/wf/plm/wf064/Wf064Dialog.java b/src/com/connor/wf/plm/wf064/Wf064Dialog.java new file mode 100644 index 0000000..f967d9f --- /dev/null +++ b/src/com/connor/wf/plm/wf064/Wf064Dialog.java @@ -0,0 +1,171 @@ +package com.connor.wf.plm.wf064; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.JTextField; +import javax.swing.SpinnerDateModel; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileSystemView; + +import com.connor.wf.plm.wf052.Wf052_2Operation; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.common.JTimeSpinner; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf064Dialog extends AbstractAIFDialog{ + + private TCSession session; + private JTextField textField; + private JButton okButton; + private JButton celButton; + private JButton pathButton; + private JTextField showDate1; + private JTextField showDate2; + // ļѡ + private JFileChooser jFileChooser; + public Wf064Dialog(TCSession session){ + this.session = session; + } + public void run(){ + initUI(); + } + private void initUI() { + // TODO Auto-generated method stub + FileSystemView fsv = FileSystemView.getFileSystemView(); // õϵͳfileview + String deskPath = fsv.getHomeDirectory().getPath(); // ǰû· + + this.setSize(new Dimension(600, 400)); + this.setTitle(""); + this.textField = new JTextField(deskPath); + + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath));// ļѡijʼĿ¼Ϊǰû + this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + this.pathButton = new JButton("..."); + this.okButton = new JButton("ȷ"); + this.celButton = new JButton("ȡ"); + DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d HH:mm"); + + DateChooser dateChooser2 = DateChooser.getInstance("yyyy-M-d HH:mm"); + Date date = new Date(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm"); + String time = df.format(date); + showDate1 = new JTextField(time); + + showDate2 = new JTextField(time); + dateChooser1.register(showDate1); + dateChooser2.register(showDate2); + + + JPanel midJPanel = new JPanel(new PropertyLayout()); + midJPanel.setBorder(new TitledBorder(BorderFactory + .createLineBorder(Color.WHITE), "ѡ񵼳·")); // ߿ TitleBorder + midJPanel.add("1.1.left.top", new JLabel("ʼڣ")); + midJPanel.add("1.2.left.top", showDate1); + midJPanel.add("2.1.left.top", new JLabel("ֹڣ")); + midJPanel.add("2.2.left.top", showDate2); + midJPanel.add("3.1.left.top", new JLabel("·")); + midJPanel.add("3.2.left.top", this.textField); + midJPanel.add("3.3.left.top", this.pathButton); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(this.okButton); + rootJPanel.add(this.celButton); + + pathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + okEvent(); + + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + celEvent(); + + } + }); + + this.setLayout(new BorderLayout()); + this.add(midJPanel, BorderLayout.CENTER); + this.add(rootJPanel, BorderLayout.SOUTH); + + this.centerToScreen(); + this.pack(); + this.setVisible(true); + this.showDialog(); + } + + public void celEvent() { + // TODO Auto-generated method stub + this.disposeDialog(); + this.dispose(); + } + + public void selectFileButtonEvent() { + int state = jFileChooser.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jFileChooser.getSelectedFile();// fΪѡ񵽵Ŀ¼ + textField.setText(f.getAbsolutePath()); + } + } + + public void okEvent() { + + this.disposeDialog(); + this.dispose(); + + try { + String path=textField.getText(); + System.out.println("ok"); + String time1 = showDate1.getText(); + String time2 = showDate2.getText(); + System.out.println("time1============"+time1); + System.out.println("time2============"+time2); + + Wf064Operation op=new Wf064Operation(session,time1,time2,path); + session.queueOperation(op); + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/wf/plm/wf064/Wf064Handler.java b/src/com/connor/wf/plm/wf064/Wf064Handler.java new file mode 100644 index 0000000..e9e9c57 --- /dev/null +++ b/src/com/connor/wf/plm/wf064/Wf064Handler.java @@ -0,0 +1,23 @@ +package com.connor.wf.plm.wf064; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.wf.plm.wf052.WF052_2Dialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf064Handler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Wf064Dialog dialog = new Wf064Dialog(session); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf064/Wf064Operation.java b/src/com/connor/wf/plm/wf064/Wf064Operation.java new file mode 100644 index 0000000..b9987bc --- /dev/null +++ b/src/com/connor/wf/plm/wf064/Wf064Operation.java @@ -0,0 +1,291 @@ +package com.connor.wf.plm.wf064; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.wf.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class Wf064Operation extends AbstractAIFOperation{ + private TCSession session; + private String path; + private String time1; + private String time2; + private TCPreferenceService service; + private ProgressBarThread wait; + public Wf064Operation(TCSession session,String time1,String time2, String path) { + this.session = session; + this.time1 = time1; + this.time2 = time2; + this.path = path; + this.service = session.getPreferenceService(); + } + @Override + public void executeOperation() throws Exception { + String[] keys = new String[]{"","ʱ","ʱ"}; + String[] types = service.getStringValues("WF2_FileDown_Type"); + List allList = new ArrayList(); + for (int i = 0; i < types.length; i++) { + String[] values = new String[]{types[i],time1,time2}; + List compList = queryObject("ļ·ѯ", keys, values); + if(compList != null){ + allList.add(compList); + } + } + + String puid = service.getStringValue("WF2_FileDown_Excel"); + TCComponentDataset excel = (TCComponentDataset) session.stringToComponent(puid); + File file = ((TCComponentDataset)excel).getTcFiles()[0].getFmsFile(); + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");// ڸʽ + String time = df.format(new Date()); + path = path + File.separator + "ļ·¼ܱ" + time + ".xlsx"; + wait = new ProgressBarThread("ɱ", + "УԵ..."); + wait.start();// + try { + writeExcel(allList,file,path); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱʧ"+e.getMessage(),"",MessageBox.ERROR); + return; + } + wait.setBool(true);// رս + wait.interrupt(); + MessageBox.post("ɱ,鿴","",MessageBox.INFORMATION); + Runtime.getRuntime().exec("cmd /c \"" + path + "\""); + } + + + + /** + * ͨѯѯƷͼ + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName ,String[] keys,String[] values){ + TCComponent[] components = null; + try { + 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{ + return null; + } + } + public void writeExcel(List allList, File file,String path){ + System.out.println("allList.size===================="+allList.size()); + int k = 1; + + List value = new ArrayList(); + try { + for (int i = 0; i < allList.size(); i++) { + List compList = allList.get(i); + for (int j = 0; j < compList.size(); j++,k++) { + String[] values = new String[36]; + TCComponent comp = compList.get(j); + if(comp instanceof TCComponentItemRevision){ + TCComponentItemRevision rev = (TCComponentItemRevision) comp; + TCComponentItem item = rev.getItem(); + if(rev != null){ + TCComponent[] status = rev.getReferenceListProperty("release_status_list"); + if(status != null && status.length > 0){ + values[0]=""+k; + String id = rev.getStringProperty("item_id"); + String name = rev.getStringProperty("object_name"); + String revId = rev.getStringProperty("item_revision_id"); + values[1] = id; + values[2] = name; + TCProperty prop1 = item.getTCProperty("wf2_time_id"); + if(prop1 != null){ + String downId = prop1.getStringValue(); + if(downId != null && downId != ""){ + values[3] = downId + revId; + } + } + values[4] = revId; + String project = item.getStringProperty("project_ids"); + values[5] = project; + TCComponent form = rev.getReferenceListProperty("IMAN_master_form_rev")[0]; + TCProperty prop2 = form.getTCProperty("wf2_designer"); + if(prop2 != null){ + String value1 = prop2.getStringValue(); + values[6] = value1; + values[7] = value1; + } + TCProperty prop3 = form.getTCProperty("wf2_proofreader"); + if(prop3 != null){ + String value1 = prop3.getStringValue(); + values[8] = value1; + } + TCProperty prop4 = form.getTCProperty("wf2_auditor"); + if(prop4 != null){ + String value1 = prop4.getStringValue(); + values[9] = value1; + } + TCProperty prop5 = form.getTCProperty("wf2_approver"); + if(prop5 != null){ + String value1 = prop5.getStringValue(); + values[10] = value1; + } + TCProperty prop6 = form.getTCProperty("wf2_approvalDate"); + if(prop6 != null){ + String value1 = prop6.getStringValue(); + values[11] = value1; + } + int n = 12; + String [] vals = null; + TCProperty prop7 = form.getTCProperty("wf2_ctsgnr"); + if(prop7 != null){ + String value1 = prop7.getStringValue(); + if(value1.contains("$")){ + System.out.println("value1==============="+value1); + System.out.println("зָ"); + vals = value1.split("\\$"); + for (int o = 0; o < vals.length; n += 2,o++ ) { + values[n] = vals[o]; + } + }else{ + values[n] = value1; + } + } + int m = 13; + TCProperty prop8 = form.getTCProperty("wf2_ctsgnrDate"); + if(prop8 != null){ + String value1 = prop8.getStringValue(); + if(value1.contains("$")){ + System.out.println("зָ"); + vals = value1.split("\\$"); + for (int o = 0; o < vals.length; m += 2,o++ ) { + values[m] = vals[o]; + } + }else{ + values[m] = value1; + } + } + value.add(values); + }else{ + continue; + } + } + } + } + } + FileInputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is); + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow targetRow = sheet.getRow(2); + short h = targetRow.getHeight(); + XSSFCell targetCell = targetRow.getCell(0); + XSSFCellStyle cellStyle = targetCell.getCellStyle(); + for (int i = 0; i < value.size(); i++) { + String[] vals = value.get(i); + XSSFRow row = sheet.getRow(i+2); + if(row == null){ + row = sheet.createRow(i+2); + } + row.setHeight(h); + for (int j = 0; j < vals.length; j++) { + XSSFCell cell = row.getCell(j); + if(cell == null){ + cell = row.createCell(j); + } + cell.setCellStyle(cellStyle); + cell.setCellValue(vals[j]); + } + } + FileOutputStream output = new FileOutputStream(new File(path)); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static String getCellValue(XSSFCell cell){ + String cellValue = ""; + if(cell == null){ + return cellValue; + } + switch (cell.getCellType()) { + case XSSFCell.CELL_TYPE_NUMERIC: + if(DateUtil.isCellDateFormatted(cell)){ + SimpleDateFormat sdf = null; + if(cell.getCellStyle().getDataFormat() == 14){ + sdf = new SimpleDateFormat("yyyy/MM/dd"); + }else if(cell.getCellStyle().getDataFormat() == 21){ + sdf = new SimpleDateFormat("HH:mm:ss"); + }else if(cell.getCellStyle().getDataFormat() == 22){ + sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + }else{ + throw new RuntimeException("ڸʽ!!!"); + } + Date date = cell.getDateCellValue(); + cellValue = sdf.format(date); + }else if(cell.getCellStyle().getDataFormat() == 0){ + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cellValue = String.valueOf(cell.getRichStringCellValue().getString()); + } + break; + case XSSFCell.CELL_TYPE_STRING: + cellValue = String.valueOf(cell.getStringCellValue()); + break; + case XSSFCell.CELL_TYPE_BOOLEAN: + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case XSSFCell.CELL_TYPE_FORMULA: + cellValue = String.valueOf(cell.getCellFormula()); + break; + case XSSFCell.CELL_TYPE_BLANK: + cellValue = null; + break; + case XSSFCell.CELL_TYPE_ERROR: + cellValue = "Ƿַ"; + break; + default: + break; + } + return cellValue; + } + +} diff --git a/src/com/connor/wf/plm/wf065/ChangeOwnerbean.java b/src/com/connor/wf/plm/wf065/ChangeOwnerbean.java new file mode 100644 index 0000000..cd6a031 --- /dev/null +++ b/src/com/connor/wf/plm/wf065/ChangeOwnerbean.java @@ -0,0 +1,43 @@ +package com.connor.wf.plm.wf065; + +public class ChangeOwnerbean { + + private String id; + private String customerName; + private String owner; + private String createdTime; + private String desc; + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getCustomerName() { + return customerName; + } + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + public String getOwner() { + return owner; + } + public void setOwner(String owner) { + this.owner = owner; + } + public String getCreatedTime() { + return createdTime; + } + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + public String getDesc() { + return desc; + } + public void setDesc(String desc) { + this.desc = desc; + } + + + +} diff --git a/src/com/connor/wf/plm/wf065/SelectOwnerAction.java b/src/com/connor/wf/plm/wf065/SelectOwnerAction.java new file mode 100644 index 0000000..7aa1051 --- /dev/null +++ b/src/com/connor/wf/plm/wf065/SelectOwnerAction.java @@ -0,0 +1,24 @@ +package com.connor.wf.plm.wf065; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class SelectOwnerAction extends AbstractAIFAction { + + private AbstractAIFUIApplication app; + + public SelectOwnerAction(AbstractAIFUIApplication app, String string) { + super(app,string); + this.app=app; + } + + @Override + public void run() { + try { + new SelectOwnerCommand(app).executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/wf/plm/wf065/SelectOwnerCommand.java b/src/com/connor/wf/plm/wf065/SelectOwnerCommand.java new file mode 100644 index 0000000..5e3f1ae --- /dev/null +++ b/src/com/connor/wf/plm/wf065/SelectOwnerCommand.java @@ -0,0 +1,20 @@ +package com.connor.wf.plm.wf065; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; + +public class SelectOwnerCommand extends AbstractAIFCommand { + + private TCSession session; + + public SelectOwnerCommand(AbstractAIFUIApplication app) { + this.session=(TCSession)app.getSession(); + } + + @Override + public void executeModal() throws Exception { + new Thread(new SelectOwnerDialog(session)).start(); + } + +} diff --git a/src/com/connor/wf/plm/wf065/SelectOwnerDialog.java b/src/com/connor/wf/plm/wf065/SelectOwnerDialog.java new file mode 100644 index 0000000..e9d9439 --- /dev/null +++ b/src/com/connor/wf/plm/wf065/SelectOwnerDialog.java @@ -0,0 +1,366 @@ +package com.connor.wf.plm.wf065; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.lang.reflect.InvocationTargetException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.MissingResourceException; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableRowSorter; + +import com.teamcenter.rac.aif.AIFClipboard; +import com.teamcenter.rac.aif.AIFPortal; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +public class SelectOwnerDialog extends AbstractAIFDialog implements ActionListener{ + + private static final long serialVersionUID = 6130114042631785757L; + private static final int width=800; + DefaultTableModel model; + private TCSession session; + private JButton qryBtn; + private JComboBox comboBox; + private String[] columnNames = {"Ŀ","ͻ","","Ŀ",""}; + private JTable qryTable; + private Object[][] beans; + private String[] loginProps; + private TCPreferenceService service; + private JPopupMenu m_popupMenu; + public SelectOwnerDialog(TCSession session) { + super(false); + this.session=session; + this.service = session.getPreferenceService(); + } + /** + * ˢtableʾÿ + */ + private void refreshTable() { + qryTable.removeAll(); + model.setDataVector(beans, columnNames); + //qryTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + qryTable.getColumnModel().getColumn(0).setPreferredWidth(110); + qryTable.getColumnModel().getColumn(1).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(2).setPreferredWidth(80); + qryTable.getColumnModel().getColumn(3).setPreferredWidth(50); + qryTable.getColumnModel().getColumn(4).setPreferredWidth(110); + + } + + @Override + public void run() { + //ʾ + initUI(); + //òѯť + qryBtn.setEnabled(true); + } + + + + @SuppressWarnings("serial") + private void initUI() { + this.setTitle("ĿϢ"); + this.setLayout(new FlowLayout(FlowLayout.CENTER,2,3)); + this.setPreferredSize(new Dimension(width, 555)); + this.setLocation(2, 5); + Object[][] cellData = getRecords("*"); + model = new DefaultTableModel() { + private static final long serialVersionUID = 6905817304437097181L; + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + qryTable = new JTable(model){ + public String getToolTipText(MouseEvent e) { + int row=qryTable.rowAtPoint(e.getPoint()); + int col=qryTable.columnAtPoint(e.getPoint()); + String tiptextString=null; + if(row>-1 && col>-1){ + Object value=qryTable.getValueAt(row, col); + if(null!=value && !"".equals(value)) + tiptextString=value.toString();//ʾԪ + } + return tiptextString; + } + }; + qryTable.addMouseListener(new MouseAdapter() { + int tableRow = -1; + public void mouseClicked(MouseEvent e){ + if(e.getButton() == MouseEvent.BUTTON3){ +// tableRow = qryTable.rowAtPoint(e.getPoint()); + tableRow = qryTable.getSelectedRow(); + qryTable.setRowSelectionInterval(tableRow, tableRow); + int indexRow = qryTable.convertRowIndexToModel(tableRow); + System.out.println("indexRow=============="+indexRow); + if(tableRow >= 0){ + System.out.println("1111111111111111111"); + createPopupMenu(indexRow); + + } + } + } + }); + + TableRowSorter sorter = new TableRowSorter(model); + qryTable.setRowSorter(sorter); //ΪJTable + model.setDataVector(cellData, columnNames); + qryTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + JScrollPane scrollPane=new JScrollPane(qryTable); + scrollPane.setPreferredSize(new Dimension(width-5, 392)); + //JPanel qryPanel=new JPanel(new PropertyLayout(5,5,5,0,5,5)); + JPanel qryPanel=new JPanel(new FlowLayout(FlowLayout.CENTER,8,3)); + + JLabel itemIdLabel=new JLabel("ͻ:"); + comboBox = new JComboBox(); + List khlist=new ArrayList<>(); + khlist.add("пͻ"); + String[] names = service.getStringValues("WF2_CustomerName_ID"); + for (int i = 0; i < names.length; i++) { + String[] vals = names[i].split("="); + khlist.add(vals[0]); + } + for (int i = 0; i < khlist.size(); i++) { + comboBox.addItem(khlist.get(i)); + } + qryBtn=new JButton("ѯ"); + + qryPanel.add(itemIdLabel); + qryPanel.add(comboBox); + qryPanel.add(qryBtn); + JPanel rootPanel=new JPanel(new ButtonLayout()); + qryBtn.setEnabled(false); + addListeners(); + this.add(qryPanel); + this.add(scrollPane); + this.add(rootPanel); +// this.setResizable(false); + this.showDialog(); + } + + private void addListeners() { + this.qryBtn.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent event) { + Object obj=event.getSource(); + if(obj.equals(this.qryBtn)) { //ѯ + String customerName = (String) comboBox.getSelectedItem(); + if(!("пͻ".equals(customerName))){ + beans = getRecords(customerName); + }else{ + beans = getRecords("*"); + } + if(beans!=null) { + refreshTable(); + } + } + } + + /** + * ѯĿϢȡ¼ + * @return tabledataVector + */ + private Object[][] getRecords(String customerName){ + List list=new ArrayList<>(); + String[] keys = new String[]{"ͻ*"}; + String[] values = new String[]{customerName}; + List compList = queryObject("ڿͻƲĿ", keys, values); + if(compList != null && compList.size() > 0){ + for (int i = 0; i < compList.size(); i++) { + TCComponent comp = compList.get(i); + ChangeOwnerbean project = new ChangeOwnerbean(); + try { + String id = comp.getStringProperty("project_id"); + String name = comp.getStringProperty("object_name"); + StringBuilder sb = new StringBuilder(id); + if(!(" ".equals(name)) && !("".equals(name))){ + sb.append("-"); + sb.append(name); + } + String proName = sb.toString(); + project.setId(proName); + String desc = comp.getStringProperty("object_desc"); + project.setDesc(desc); + String cstName = comp.getStringProperty("wf2_customerName"); + project.setCustomerName(cstName); + TCComponent user = comp.getRelatedComponent("owning_user"); + String owner = user.getStringProperty("user_name"); + project.setOwner(owner); + Date date = comp.getDateProperty("creation_date"); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// ڸʽ + String createdTime = df.format(date); + project.setCreatedTime(createdTime); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + list.add(project); + } + } + //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// ڸʽ + + //װ + Object res[][] = new Object[list.size()][this.columnNames.length]; + int i=0; + for (ChangeOwnerbean record : list) { + res[i++]=new Object[] {record.getId(),record.getCustomerName(),record.getDesc(),record.getOwner(),record.getCreatedTime()}; + } + return res; + } + + + /** + * ͨѯѯĿ + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName ,String[] keys,String[] values){ + TCComponent[] components = null; + try { + 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{ + return null; + } + } + //Ҽ˵ + private void createPopupMenu(final int row) { + //m_popupMenu = new JPopupMenu(); + + //JMenuItem delMenItem = new JMenuItem(); + //delMenItem.setText("͵'ҵTeamcenter'"); + //delMenItem.addActionListener(new java.awt.event.ActionListener() { + //public void actionPerformed(java.awt.event.ActionEvent evt) { + //òҪ + System.out.println("==͵item=="+row); + int column = 0; + String selectedValue = (String) qryTable.getModel().getValueAt(row,column); + String proId = selectedValue; + if(selectedValue.contains("-")){ + String [] ids = selectedValue.split("-"); + proId = ids[0]; + } + System.out.println("proId=============="+proId); + String[] keys = new String[]{"Ŀ ID"}; + String[] values = new String[]{proId}; + List compList = queryObject("ĿIDĿ", keys, values); + System.out.println("size==========="+compList.size()); + TCComponent comp = compList.get(0); + if ((comp instanceof TCComponent)) { + Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open"); + OpenCommand localOpenCommand; + try { + localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand", + new Object[] { AIFUtility.getActiveDesktop(), comp }); + localOpenCommand.executeModeless(); + } catch (MissingResourceException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //} + //}); + //m_popupMenu.add(delMenItem); + } + + private class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + private static final long serialVersionUID = -7149062901533662226L; + + public TableCellTextAreaRenderer() { + //setLineWrap(true); //Զ + //setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + if(isSelected){ + //ñѡеһеɫ + setBackground(new Color(51,153,255)); + setForeground(new Color(255,255,255)); + }else{ + setBackground(table.getBackground()); + setForeground(table.getForeground()); + } + + // 㵱еѸ߶ + 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) + table.setRowHeight(row, maxPreferredHeight); + setText(value == null ? "" : value.toString()); + return this; + } + } +} diff --git a/src/com/connor/wf/plm/wf065/SelectOwnerHandler.java b/src/com/connor/wf/plm/wf065/SelectOwnerHandler.java new file mode 100644 index 0000000..8d688cd --- /dev/null +++ b/src/com/connor/wf/plm/wf065/SelectOwnerHandler.java @@ -0,0 +1,19 @@ +package com.connor.wf.plm.wf065; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class SelectOwnerHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new Thread(new SelectOwnerAction(app,"")).start(); + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf066/WF066Dialog.java b/src/com/connor/wf/plm/wf066/WF066Dialog.java new file mode 100644 index 0000000..79680d1 --- /dev/null +++ b/src/com/connor/wf/plm/wf066/WF066Dialog.java @@ -0,0 +1,191 @@ +package com.connor.wf.plm.wf066; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; + +public class WF066Dialog extends AbstractAIFDialog{ + private static final long serialVersionUID = 1L; + private InterfaceAIFComponent[] targetComponents = null; + private AbstractAIFApplication app; + private TCSession session; + public WF066Dialog(AbstractAIFApplication arg0) { + + this.app=arg0; + this.session=(TCSession) app.getSession(); + targetComponents = app.getTargetComponents(); + + } + public void run(){ + init(); + } + private void init() { + //жǷΪ뵥 + final TCComponent itemR = (TCComponent)targetComponents[0]; + if(!itemR.getTypeComponent().toString().equals("WF2_newMatDevRvwRevision")) { + System.out.println(itemR.getTypeComponent()); + MessageBox.post("ʧܣѡ²Ͽ뵥汾д", "ʾϢ",MessageBox.INFORMATION); + return; + }else { + + //ô֪ͨij + + this.setTitle("²Ͽյ"); + this.setLayout(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //JPanelĴС + this.setPreferredSize(new Dimension(380, 330)); + + + //panel + JPanel panel = new JPanel(new PropertyLayout(5, 5, 5, 5, 5, 5)); + + //ťpanel + JPanel buttonPanel = new JPanel(new ButtonLayout( + ButtonLayout.HORIZONTAL, ButtonLayout.CENTER, 30)); + + //ģо + final iTextField id_TextField = new iTextField(); + final iTextField name_TextField = new iTextField(); + name_TextField.setText("²Ͽյ"); + final iTextField desc_TextField = new iTextField();// + + final JLabel jText = new JLabel(); + final JLabel jid = new JLabel(); + final JLabel jname= new JLabel(); + //final JLabel jre = new JLabel(); + final JLabel jdesc = new JLabel(); + jText.setText(" IDֵ\"DOC\"nnnnnnnnб༭"); + jid.setText("ID:"); + jname.setText(":"); + //jre.setText("λ:"); + jdesc.setText(":"); + id_TextField.setPreferredSize(new Dimension(180, 20)); + name_TextField.setPreferredSize(new Dimension(180, 20)); + // re_TextField.setPreferredSize(new Dimension(180, 20)); + desc_TextField.setPreferredSize(new Dimension(180, 20)); + JButton give_button = new JButton("ָ"); + + + //panel.add("1.1.center.center.preferred.preferred",jText); + + panel.add("1.1.left.center",new JLabel(" ")); + panel.add("1.2.center.center",jText); + + panel.add("2.1.left.center",jid); + panel.add("2.2.center.center",id_TextField); + panel.add("2.3.right.center",give_button); + + + panel.add("3.1.left.center",jname); + panel.add("3.2.center.center",name_TextField); + + // panel.add("3.2.left.center.perferred.perferred",re_TextField); + + panel.add("4.1.left.center",jdesc); + panel.add("4.2.center.center",desc_TextField); + + + + //ť 뵽ָ + + + JButton ok_Button = new JButton("ȷ"); + JButton cancel_Button = new JButton("ȡ"); + + buttonPanel.add(ok_Button); + buttonPanel.add(cancel_Button); + + this.add("1.1.center.center", panel); + this.add("2.1.center.center", buttonPanel); + + + this.centerToScreen(); + this.setVisible(true); + + + give_button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + + TCComponentItemType ccomponentitemtype; + + + try { + ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_newMatCheck"); + id_TextField.setText(ccomponentitemtype.getNewID()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + }); + + ok_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + //²Ͽյ + + String itemId=id_TextField.getText().trim(); + String itemName=name_TextField.getText().trim(); + String itemDescription = desc_TextField.getText().trim(); + + if(itemName.equals("") || itemName==null) { + MessageBox.post("Ϊ", "ʾϢ",MessageBox.INFORMATION); + }else { + + TCComponentItemType ccomponentitemtype; + try { + ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("WF2_newMatCheck"); + TCComponentItem item = ccomponentitemtype.create(itemId,"A","WF2_newMatCheck",itemName,itemDescription,null); + + + //item֪ͨļӸӹϵ + + + itemR.add("WF2_newMatRelation", item); + + MessageBox.post("²Ͽյӳɹ", "ʾϢ",MessageBox.INFORMATION); + closeDialog(); + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }); + + cancel_Button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + closeDialog(); + } + }); + + + + } + } + private void closeDialog() { + disposeDialog(); + setVisible(false); + } +} diff --git a/src/com/connor/wf/plm/wf066/Wf066Handler.java b/src/com/connor/wf/plm/wf066/Wf066Handler.java new file mode 100644 index 0000000..316933a --- /dev/null +++ b/src/com/connor/wf/plm/wf066/Wf066Handler.java @@ -0,0 +1,23 @@ +package com.connor.wf.plm.wf066; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.wf.plm.wf011.CreateSubPartDrawDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class Wf066Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + WF066Dialog dialog = new WF066Dialog(app); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/connor/wf/plm/wf067/Wf067AIFDialog.java b/src/com/connor/wf/plm/wf067/Wf067AIFDialog.java new file mode 100644 index 0000000..d10126a --- /dev/null +++ b/src/com/connor/wf/plm/wf067/Wf067AIFDialog.java @@ -0,0 +1,608 @@ +package com.connor.wf.plm.wf067; + + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +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.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class Wf067AIFDialog extends AbstractAIFDialog { + private TCSession session; + private TCPreferenceService service; + private InterfaceAIFComponent targetComp; + private TCComponentProject comp = null; + private TCComponentForm pictureForm = null; + private List formList = new ArrayList(); + private TCComponent[] items = null; + private Map fieldMap = new HashMap(); + private Map map = new HashMap(); + private Map> boxMap = new HashMap>(); + private Map> map2 = new HashMap>(); + private Map typeMap = new HashMap(); + private JScrollPane scr1; + private JScrollPane scr2; + private JScrollPane scr3; + private JButton okBtn=new JButton("ȷ"); + private JButton celBtn=new JButton("ȡ"); + private JButton custBtn=new JButton("ȡ"); + private JButton calBtn=new JButton("ر"); + private String type=""; + private String projectId = ""; + public Wf067AIFDialog(TCSession arg0,InterfaceAIFComponent arg1){ + this.session = arg0; + this.targetComp = arg1; + this.service = session.getPreferenceService(); + } + + public void run(){ + if(targetComp == null){ + MessageBox.post("ѡĿ!!","", MessageBox.ERROR); + return; + } + type = targetComp.getType(); + System.out.println("tyep="+type); + if(!("TC_Project".equals(type))) { + MessageBox.post("ѡĿ!!","ʾ", MessageBox.INFORMATION); + return; + } + String[] attrs = service.getStringValues("WF2_Project_attrs"); + if (attrs == null || attrs.length <= 0) { + + MessageBox.post("ѡWF2_Project_attrsδ,ϵԱ!!", + "", MessageBox.ERROR); + return; + } + if(targetComp instanceof TCComponentProject) { + comp = (TCComponentProject) targetComp; + init(attrs); + } + } + + public void init(String[] attrs){ + try { + projectId = comp.getStringProperty("project_id"); + StringBuilder sb = new StringBuilder("T"); + sb.append(projectId); + String pictrueId = sb.toString(); + String[] keys = new String[] {" ID"}; + String[] values = new String[] {pictrueId}; + List compList = queryObject(" ID", keys, values); + if(compList != null && compList.size() > 0) { + TCComponentItem pictureItem = (TCComponentItem) compList.get(0); + TCComponentItemRevision rev = pictureItem.getLatestItemRevision(); + TCComponent[] form = rev.getReferenceListProperty("IMAN_master_form_rev"); + pictureForm = (TCComponentForm) form[0]; + items = rev.getReferenceListProperty("representation_for"); + if(items != null && items.length > 0) { + for (int i = 0; i < items.length; i++) { + if(items[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) items[i]; + TCComponentItem item = itemRev.getItem(); + TCComponentItemRevision latestRev = item.getLatestItemRevision(); + TCComponentForm itemForm = (TCComponentForm) latestRev.getReferenceListProperty("IMAN_master_form_rev")[0]; + formList.add(itemForm); + } + } + }else { + MessageBox.post("ĿӦͼֽûжӦ϶ȴϽй!!", + "", MessageBox.ERROR); + return; + } + }else { + MessageBox.post("ĿӦͼֽûдȴͼֽ!!", + "", MessageBox.ERROR); + return; + } + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + this.setLayout(new PropertyLayout()); + this.setTitle("ͬ"); + this.setPreferredSize(new Dimension(1000, 600)); + JPanel item = new JPanel(new PropertyLayout()); + JPanel picture = new JPanel(new PropertyLayout()); + JPanel project = new JPanel(new PropertyLayout()); + + scr1 = new JScrollPane(item); + scr2 = new JScrollPane(picture); + scr3 = new JScrollPane(project); + + scr1.setPreferredSize(new Dimension(330, 500)); + scr2.setPreferredSize(new Dimension(330, 500)); + scr3.setPreferredSize(new Dimension(330, 500)); + + JPanel itemJpanel = new JPanel(new PropertyLayout());// Խ + JPanel pictureJpanel = new JPanel(new PropertyLayout());// ͼֽԽ + JPanel projectJpanel = new JPanel(new PropertyLayout());// ĿԽ + JPanel attJpanel = new JPanel(new PropertyLayout());// Խ + JPanel jbutJpanel = new JPanel(new PropertyLayout());// ť + + JLabel jb1 = new JLabel(""); + JLabel jb2 = new JLabel("ͼֽ"); + JLabel jb3 = new JLabel("Ŀ"); + + itemJpanel.add("1.1.center.top", jb1); + itemJpanel.add("2.1.center.top", scr1); + + pictureJpanel.add("1.1.center.top", jb2); + pictureJpanel.add("2.1.center.top", scr2); + + projectJpanel.add("1.1.center.top", jb3); + projectJpanel.add("2.1.center.top", scr3); + try { + int j = 1,k=1,p=1; + for (int i = 0; i < attrs.length; i++) { + String[] attr = attrs[i].split("\\;"); + String[] attrVal = attr[0].split("="); + JLabel label = new JLabel(attrVal[0]); + label.setBounds(5, 5, 5, 5); + //project.add(j+".1.center.top", new JLabel(" ")); + project.add(j+".1.center.top", label); + String val = comp.getStringProperty(attrVal[1]); + typeMap.put(attrVal[1],attr[2]); + if("true".equals(attr[1])) { + JComboBox comb = new JComboBox(); + project.add(j+".2.center.top", comb); + setLovValue(attrVal[1],comp,val,comb); + boxMap.put(attrVal[1], comb); + if("".equals(attrVal[0])) { + map2.put(attrVal[0], comb); + }else if("".equals(attrVal[0])){ + map2.put(attrVal[0], comb); + }else if("ֱ".equals(attrVal[0])) { + map2.put(attrVal[0], comb); + } + }else if("false".equals(attr[1])) { + JTextField field = new JTextField(12); + if(val != null && !("".equals(val.trim()))) { + field.setText(val); + } + project.add(j+".2.center.top", field); + if("".equals(attrVal[0])) { + map.put(attrVal[0], field); + }else if("ر".equals(attrVal[0])){ + map.put(attrVal[0], field); + }else if("غ".equals(attrVal[0])) { + map.put(attrVal[0], field); + }else if("".equals(attrVal[0])) { + map.put(attrVal[0], field); + } + fieldMap.put(attrVal[1], field); + } + j++; + if("ͼֽ".equals(attr[2])) { + JTextField field = new JTextField(12); + setTextValue(attrVal[1],pictureForm,field); + field.setEditable(false); + JLabel pLabel = new JLabel(attrVal[0]); + //picture.add(p+".1.center.top", new JLabel(" ")); + picture.add(p+".1.center.top", pLabel); + picture.add(p+".2.center.top", field); + p++; + }else if("".equals(attr[2])) { + JTextField field = new JTextField(12); + for (int l = 0; l < formList.size(); l++) { + TCComponentForm itemForm = formList.get(l); + setTextValue(attrVal[1],itemForm,field); + } + field.setEditable(false); + JLabel tLabel = new JLabel(attrVal[0]); + //item.add(k+".1.center.top", new JLabel(" ")); + item.add(k+".1.center.top", tLabel); + item.add(k+".2.center.top", field); + k++; + }else if("".equals(attr[2])) { + JTextField field = new JTextField(12); + for (int l = 0; l < formList.size(); l++) { + TCComponentForm itemForm = formList.get(l); + setTextValue(attrVal[1],itemForm,field); + } + field.setEditable(false); + JTextField field1 = new JTextField(12); + setTextValue(attrVal[1],pictureForm,field1); + field1.setEditable(false); + JLabel pLabel = new JLabel(attrVal[0]); + JLabel tLabel = new JLabel(attrVal[0]); + //item.add(k+".1.center.top", new JLabel(" ")); + item.add(k+".1.center.top", tLabel); + item.add(k+".2.center.top", field); + //picture.add(p+".1.center.top", new JLabel(" ")); + picture.add(p+".1.center.top", pLabel); + picture.add(p+".2.center.top", field1); + p++; + k++; + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + attJpanel.add("1.1.center.top", projectJpanel); + attJpanel.add("1.2.center.top", itemJpanel); + attJpanel.add("1.3.center.top", pictureJpanel); + jbutJpanel.add("1.1.center.top", custBtn); + jbutJpanel.add("1.2.center.top", calBtn); + jbutJpanel.add("1.3.center.top", okBtn); + jbutJpanel.add("1.4.center.top", celBtn); + this.setBounds(5, 5, 5, 5); + this.add("1.1.center.top", attJpanel); + this.add("2.1.center.top", jbutJpanel); + this.setVisible(true); + this.setResizable(false); + this.centerToScreen(); + this.pack(); + okBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + openByPass(session); + setItemValue(); + closeByPass(session); + setVisible(false); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + custBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + getWFPartnumber(); + } + + }); + calBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + calculation(); + + } + }); + celBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + } + public void setLovValue(String attrType,TCComponentProject comp,String realValue,JComboBox comb) { + try { + TCComponentListOfValues lov1 = comp.getTCProperty(attrType).getLOV(); + if(lov1!=null){ + String[] strs1=lov1.getListOfValues().getStringListOfValues();//ʵֵ + if(realValue != null && !("".equals(realValue.trim()))) { + for(String s1:strs1){ + if(realValue.equals(s1)) { + String value = lov1.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + comb.addItem(value); + break; + } + } + }else { + comb.addItem(" "); + } + for(String s1:strs1){ + String value = lov1.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + comb.addItem(value); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + public void setTextValue(String attrType,TCComponentForm form,JTextField field) { + System.out.println("attrType==========="+attrType); + try { + String realValue = form.getStringProperty(attrType); + TCComponentListOfValues lov1 = form.getTCProperty(attrType).getLOV(); + if(lov1!=null){ + String[] strs1=lov1.getListOfValues().getStringListOfValues();//ʵֵ + if(realValue != null && !("".equals(realValue.trim()))) { + for(String s1:strs1){ + if(realValue.equals(s1)) { + String value = lov1.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + field.setText(value); + break; + } + } + } + }else { + field.setText(realValue); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + /** + * ͨѯѯĿ + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName ,String[] keys,String[] values){ + TCComponent[] components = null; + try { + 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{ + return null; + } + } + + public void setItemValue() { + try { + + for (Entry entry : fieldMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue().getText(); + comp.setStringProperty(key, value); + if(typeMap.containsKey(key)) { + for (Entry entry1 : typeMap.entrySet()) { + String key1 = entry1.getKey(); + if(key.equals(key1)) { + String type = entry1.getValue(); + if("ͼֽ".equals(type)) { + pictureForm.setStringProperty(key, value); + break; + }else if("".equals(type)) { + for (int i = 0; i < items.length; i++) { + if(items[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) items[i]; + TCComponentItem item = itemRev.getItem(); + TCComponentItemRevision latestRev = item.getLatestItemRevision(); + TCComponentForm form = (TCComponentForm) latestRev.getReferenceListProperty("IMAN_master_form_rev")[0]; + form.setStringProperty(key, value); + } + } + break; + }else if("".equals(type)) { + pictureForm.setStringProperty(key, value); + for (int i = 0; i < items.length; i++) { + if(items[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) items[i]; + TCComponentItem item = itemRev.getItem(); + TCComponentItemRevision latestRev = item.getLatestItemRevision(); + TCComponentForm form = (TCComponentForm) latestRev.getReferenceListProperty("IMAN_master_form_rev")[0]; + form.setStringProperty(key, value); + } + } + break; + } + } + + } + } + } + for (Entry> entry : boxMap.entrySet()) { + String key = entry.getKey(); + TCComponentListOfValues lov = comp.getTCProperty(key).getLOV(); + String realValue = (String) entry.getValue().getSelectedItem(); + if(lov!=null){ + String[] strs1=lov.getListOfValues().getStringListOfValues();//ʵֵ + if(realValue != null && !("".equals(realValue.trim()))) { + for(String s1:strs1){ + String value = lov.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + if(realValue.equals(value)) { + comp.setStringProperty(key, s1); + if(typeMap.containsKey(key)) { + for (Entry entry1 : typeMap.entrySet()) { + String key1 = entry1.getKey(); + if(key.equals(key1)) { + String type = entry1.getValue(); + if("ͼֽ".equals(type)) { + pictureForm.setStringProperty(key, s1); + break; + }else if("".equals(type)) { + for (int i = 0; i < items.length; i++) { + if(items[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) items[i]; + TCComponentItem item = itemRev.getItem(); + TCComponentItemRevision latestRev = item.getLatestItemRevision(); + TCComponentForm form = (TCComponentForm) latestRev.getReferenceListProperty("IMAN_master_form_rev")[0]; + form.setStringProperty(key, s1); + } + } + break; + }else if("".equals(type)) { + pictureForm.setStringProperty(key, s1); + for (int i = 0; i < items.length; i++) { + if(items[i] instanceof TCComponentItemRevision) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) items[i]; + TCComponentItem item = itemRev.getItem(); + TCComponentItemRevision latestRev = item.getLatestItemRevision(); + TCComponentForm form = (TCComponentForm) latestRev.getReferenceListProperty("IMAN_master_form_rev")[0]; + form.setStringProperty(key, s1); + } + } + break; + } + } + } + } + break; + } + } + } + } + } + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + public void calculation() { + String zaihe = ""; + String lilunwight = ""; + JTextField field = null; + for (Entry entry : map.entrySet()) { + String key = entry.getKey(); + if("".equals(key)) { + lilunwight = entry.getValue().getText(); + }else if("غ".equals(key)) { + zaihe = entry.getValue().getText(); + }else if("ر".equals(key)) { + field = entry.getValue(); + } + } + if("".equals(zaihe.trim()) || "".equals(lilunwight.trim())) { + MessageBox.post("Ȱغд!!", + "ʾ", MessageBox.ERROR); + return; + } + BigDecimal zaiheBg = null; + BigDecimal lilunwightBg = null; + if(!("".equals(zaihe)) && !("".equals(lilunwight))){ + try { + zaiheBg = new BigDecimal(zaihe); + } catch (Exception e1) { + e1.printStackTrace(); + setAlwaysOnTop(false); + MessageBox.post("غֵ", "", MessageBox.ERROR); + setAlwaysOnTop(true); + return; + } + try { + lilunwightBg = new BigDecimal(lilunwight); + } catch (Exception e1) { + e1.printStackTrace(); + setAlwaysOnTop(false); + MessageBox.post("ֵ", "", MessageBox.ERROR); + setAlwaysOnTop(true); + return; + + } + BigDecimal finVal = zaiheBg.divide(lilunwightBg,2,BigDecimal.ROUND_HALF_UP); + String finString = finVal.toString(); + field.setText(finString); + }else{ + setAlwaysOnTop(false); + MessageBox.post("غֵֵδд", "ʾ", MessageBox.INFORMATION); + setAlwaysOnTop(true); + return; + } + } + + public void getWFPartnumber() { + // TODO Auto-generated method stub + JTextField field = null; + String rimWidth = ""; + String rimDiameter = ""; + String futiao = ""; + for (Entry entry : map.entrySet()) { + String key = entry.getKey(); + if("".equals(key)) { + field = entry.getValue(); + break; + } + } + for (Entry> entry : map2.entrySet()) { + String key = entry.getKey(); + if("".equals(key)) { + JComboBox box = entry.getValue(); + futiao = (String) box.getSelectedItem(); + }else if("".equals(key)) { + JComboBox box = entry.getValue(); + rimWidth = (String) box.getSelectedItem(); + }else if("ֱ".equals(key)) { + JComboBox box = entry.getValue(); + rimDiameter = (String) box.getSelectedItem(); + } + } + if("".equals(futiao.trim()) || "".equals(rimWidth.trim()) || "".equals(rimDiameter.trim()) ) { + MessageBox.post("Ȱѷȡֱд!!", + "ʾ", MessageBox.ERROR); + return; + } + StringBuilder sb = new StringBuilder(futiao); + int num = projectId.indexOf("P"); + String id = projectId.substring(num+1); + sb.append(id); + sb.append(rimDiameter); + sb.append(rimWidth); + String finVal = sb.toString(); + System.out.println("finVal==============="+finVal); + if(finVal.contains(".")) { + String[] vals = finVal.split("\\."); + StringBuilder sb1 = new StringBuilder(vals[0]); + + for (int i = 1; i < vals.length; i++) { + System.out.println("vals==========="+vals[i]); + sb1.append(vals[i]); + } + field.setText(sb1.toString()); + } + } + //· + public void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_close_bypass", obj); + +// session.getUserService().call("Connor_set_bypass", new Object[]{});//bypass +// session.getUserService().call("Connor_close_bypass", new Object[]{});//bypass + } + public void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_set_bypass", obj); + } +} diff --git a/src/com/connor/wf/plm/wf067/Wf067Handler.java b/src/com/connor/wf/plm/wf067/Wf067Handler.java new file mode 100644 index 0000000..98cb6ce --- /dev/null +++ b/src/com/connor/wf/plm/wf067/Wf067Handler.java @@ -0,0 +1,25 @@ +package com.connor.wf.plm.wf067; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class Wf067Handler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + Wf067AIFDialog dialog = new Wf067AIFDialog(session,targetComp); + new Thread(dialog).start(); + return null; + } + +} diff --git a/src/com/teamcenter/rac/commands/cut/CutOperation.java b/src/com/teamcenter/rac/commands/cut/CutOperation.java new file mode 100644 index 0000000..f4e724c --- /dev/null +++ b/src/com/teamcenter/rac/commands/cut/CutOperation.java @@ -0,0 +1,259 @@ +/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. + +package com.teamcenter.rac.commands.cut; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.common.IMultiTarget; +import com.teamcenter.rac.kernel.*; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.log.Debug; +import java.util.*; +import org.apache.log4j.Logger; + +public class CutOperation extends AbstractAIFOperation + implements IMultiTarget +{ + + public CutOperation(TCComponent tccomponent, TCComponent tccomponent1, String s) + { + m_pendingCut = false; + m_parentCmp = tccomponent; + m_childCmps = (new TCComponent[] { + tccomponent1 + }); + m_contextString = s; + } + + public CutOperation(AIFComponentContext aifcomponentcontext, boolean flag) + { + m_pendingCut = false; + m_parentCmp = (TCComponent)aifcomponentcontext.getParentComponent(); + m_childCmps = (new TCComponent[] { + (TCComponent)aifcomponentcontext.getComponent() + }); + m_contextString = (String)aifcomponentcontext.getContext(); + m_pendingCut = flag; + } + + public CutOperation(TCComponent tccomponent, AIFComponentContext aaifcomponentcontext[], boolean flag) + { + m_pendingCut = false; + m_parentCmp = tccomponent; + if(aaifcomponentcontext != null) + { + ArrayList arraylist = new ArrayList(); + for(int i = 0; i < aaifcomponentcontext.length; i++) + arraylist.add((TCComponent)aaifcomponentcontext[i].getComponent()); + + m_childCmps = (TCComponent[])arraylist.toArray(new TCComponent[arraylist.size()]); + m_contextString = (String)aaifcomponentcontext[0].getContext(); + } + m_pendingCut = flag; + } + + + // + private boolean isSchedule(TCComponent com) { + // TODO Auto-generated method stub + try { + if(com.getType().equals("Folder")){ + TCComponent[] tcmps= com.getReferenceListProperty("fnd0StartedWorkflowTasks"); + if(tcmps!=null&&tcmps.length>0){ + System.out.println(""); + for (TCComponent tcComponent : tcmps) { + if("Ŀȷ".equals(tcComponent.getStringProperty("object_name"))){ + System.out.println("ָ[Ŀȷ]"); + return true; + } + + } + + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return false; + } + + public void executeOperation() + throws TCException + { + if(m_parentCmp == null) + return; + TCSession tcsession = m_parentCmp.getSession(); + Registry registry = Registry.getRegistry(this); + boolean flag = false; + StringBuilder stringbuilder = new StringBuilder(); + if(m_childCmps != null) + { + for(int i = 0; i < m_childCmps.length; i++) + { + // ʱļɾ + boolean bo= isSchedule(m_childCmps[i]); + if(bo){ + MessageBox.post("ļ޷!!","",MessageBox.ERROR); + return; + } + + stringbuilder.append((new StringBuilder(String.valueOf(i != 0 ? ", " : ""))).append(m_childCmps[i]).toString()); + if(!flag && (m_childCmps[i] instanceof TCComponentWorkContext)) + flag = true; + } + + } + tcsession.setStatus((new StringBuilder(String.valueOf(registry.getString("cutting")))).append(" ").append(stringbuilder.toString()).append(" ").append(registry.getString("from")).append(" ").append(m_parentCmp.toString()).toString()); + if(!m_pendingCut && m_childCmps != null) + try + { + TCComponent tccomponent = null; + Object obj = null; + if(m_parentCmp instanceof TCComponentPseudoFolder) + tccomponent = ((TCComponentPseudoFolder)m_parentCmp).getOwningComponent(); + if((m_parentCmp instanceof TCComponentPseudoFolder) && (tccomponent instanceof TCComponentTask) && m_parentCmp.toString().equals("Parent Processes")) + try + { + TCComponentProcess tccomponentprocess = ((TCComponentTask)tccomponent).getProcess(); + for(int j = 0; j < m_childCmps.length; j++) + { + TCComponentProcess tccomponentprocess1 = (TCComponentProcess)m_childCmps[j]; + TCComponent tccomponent1 = ((TCComponentPseudoFolder)m_parentCmp).getOwningComponent(); + tccomponentprocess1.removeSubProcess(tccomponentprocess, tccomponent1); + } + + m_parentCmp.refresh(); + m_parentCmp.fireComponentChangeEvent(); + } + catch(Exception exception) + { + Debug.println(exception.getClass().getName(), exception); + } + else + if((m_parentCmp instanceof TCComponentPseudoFolder) && (tccomponent instanceof TCComponentDataset) || (m_parentCmp instanceof TCComponentDataset) && m_contextString.equals("ref_list")) + { + removeDatasetNamedReference(); + } else + { + if((m_parentCmp instanceof TCComponentTraceLink) && m_childCmps[0].isTypeOf("Fnd0CustomNoteRevision")) + m_contextString = "fnd0CustomNotes"; + m_parentCmp.cutOperation(m_contextString, m_childCmps); + } + tcsession.setReadyStatus(); + if(flag) + clearWorkContextProperty(tcsession); + } + catch(TCException tcexception) + { + tcsession.setStatus(tcexception.toString()); + throw tcexception; + } + } + + private void clearWorkContextProperty(AbstractAIFSession abstractaifsession) + { + if(abstractaifsession != null && (abstractaifsession instanceof TCSession)) + { + TCSession tcsession = (TCSession)abstractaifsession; + TCComponentUser tccomponentuser = tcsession.getUser(); + if(tccomponentuser != null) + tccomponentuser.clearCache("work_contexts"); + } + } + + private void removeDatasetNamedReference() + { + ArrayList arraylist = new ArrayList(); + ArrayList arraylist1 = new ArrayList(); + TCComponent tccomponent = null; + if(m_parentCmp instanceof TCComponentPseudoFolder) + tccomponent = ((TCComponentPseudoFolder)m_parentCmp).getOwningComponent(); + TCComponentDataset tccomponentdataset; + if(m_parentCmp instanceof TCComponentDataset) + tccomponentdataset = (TCComponentDataset)m_parentCmp; + else + tccomponentdataset = (TCComponentDataset)tccomponent; + try + { + TCProperty tcproperty = tccomponentdataset.getTCProperty("ref_list"); + TCComponent atccomponent[] = tcproperty.getReferenceValueArray(); + TCProperty tcproperty1 = tccomponentdataset.getTCProperty("ref_names"); + String as[] = tcproperty1.getStringValueArray(); + if(atccomponent != null && atccomponent.length != 0 && as != null && as.length != 0) + { + for(int i = 0; i < m_childCmps.length; i++) + { + for(int j = 0; j < atccomponent.length; j++) + { + if(m_childCmps[i] != atccomponent[j]) + continue; + if(m_childCmps[i] instanceof TCComponentTcFile) + { + arraylist.add(atccomponent[j].toString()); + arraylist1.add(as[j]); + TCComponentTcFile tccomponenttcfile = (TCComponentTcFile)atccomponent[j]; + tccomponenttcfile.setRefDatasetNamedReferences(as[j]); + } else + { + tccomponentdataset.removeNamedReference(as[j]); + TCComponentForm tccomponentform = (TCComponentForm)atccomponent[j]; + tccomponentform.setRefDatasetNamedReferences(as[j]); + m_parentCmp.refresh(); + } + break; + } + + } + + } + if(arraylist.size() != 0) + { + String as1[] = (String[])arraylist.toArray(new String[arraylist.size()]); + String as2[] = (String[])arraylist1.toArray(new String[arraylist1.size()]); + tccomponentdataset.removeFiles(as1, as2); + m_parentCmp.refresh(); + } else + { + if((m_parentCmp instanceof TCComponentTraceLink) && m_childCmps[0].isTypeOf("Fnd0CustomNoteRevision")) + m_contextString = "fnd0CustomNotes"; + m_parentCmp.cutOperation(m_contextString, m_childCmps); + } + } + catch(Exception exception) + { + Logger.getLogger("com.teamcenter.rac.commands.cut.CutOperation").error(exception.getLocalizedMessage(), exception); + } + } + + public AIFComponentContext[] getTargetContexts() + { + return (new AIFComponentContext[] { + new AIFComponentContext(null, m_parentCmp, "context") + }); + } + + public Map getPartialFailedTargets() + { + return Collections.emptyMap(); + } + + private final TCComponent m_parentCmp; + private TCComponent m_childCmps[]; + private String m_contextString; + private boolean m_pendingCut; +} + + +/* + DECOMPILATION REPORT + + Decompiled from: D:\Siemens\Teamcenter\OTW11\rac\plugins\com.teamcenter.rac.common_11000.2.0.jar + Total time: 124 ms + Jad reported messages/errors: + Exit status: 0 + Caught exceptions: +*/ \ No newline at end of file diff --git a/src/com/teamcenter/rac/form/Myform.java b/src/com/teamcenter/rac/form/Myform.java new file mode 100644 index 0000000..a820cbd --- /dev/null +++ b/src/com/teamcenter/rac/form/Myform.java @@ -0,0 +1,254 @@ +package com.teamcenter.rac.form; + +import java.awt.Dimension; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.PropertyLayout; + +public class Myform extends AbstractRendering { + private TCComponentForm form; + private DefaultTableModel model; + private TCComponentItemRevision rev; + private String value1; + private String value2; + private String value3; + private String value4; + private String value5; + private String value6; + private String value7; + private String value8; + private Map map1; + private Map map2; + private String[] stra1; + private String[] stra2; + public Myform(TCComponent arg0) throws Exception { + super(arg0); + // TODO Auto-generated constructor stub + form = (TCComponentForm)arg0; + rev = (TCComponentItemRevision)form.whereReferenced()[0].getComponent(); + loadRendering(); + } + + + @Override + public void loadRendering() throws TCException { + // TODO Auto-generated method stub + TCComponentListOfValues lov1= rev.getTCProperty("wf2_preDrillCenHolesize").getLOV(); + if(lov1!=null){ + map1=new HashMap<>(); + String[] strs1=lov1.getListOfValues().getStringListOfValues();//ʵֵ + stra1 = new String[strs1.length]; + int i=0; + for(String s1:strs1){ + String a1 = lov1.getListOfValues().getDisplayableValue(s1);//ʵֵӦʾֵ + stra1[i]=a1;i++; + map1.put(s1, a1);//ʵk:ʾv + } + } + + TCComponentListOfValues lov2= rev.getTCProperty("wf2_agingType").getLOV(); + if(lov2!=null){ + map2=new HashMap<>(); + String[] strs2=lov2.getListOfValues().getStringListOfValues();//ʵֵ + stra2 = new String[strs2.length]; + int j=0; + for(String s2:strs2){ + String a2 = lov2.getListOfValues().getDisplayableValue(s2);//ʵֵӦʾֵ + stra2[j]=a2;j++; + map2.put(s2, a2);//ʵk:ʾv + } + } + + value1=rev.getProperty("wf2_customerName"); + value2=rev.getProperty("wf2_productName"); + value3=rev.getTCProperty("wf2_preDrillCenHolesize").getDisplayableValue(); + value4=rev.getProperty("wf2_moldNumber"); + value5=rev.getProperty("wf2_revDimensionA"); + value6=rev.getProperty("wf2_productHardness"); + value7=rev.getProperty("wf2_steelTempPosition"); + value8=rev.getTCProperty("wf2_agingType").getDisplayableValue(); + + initUI(); + } + + @SuppressWarnings("unchecked") + private void initUI(){ + this.setPreferredSize(new Dimension(800, 100)); + this.setLayout(new PropertyLayout()); + String[][] datas = {}; + String[] titles = {"ͻ", "Ʒ", "Ԥ״С", "ģ", "УߴA", "ƷӲ", "ֺλ", "ʱЧʽ" }; + model = new DefaultTableModel(datas, titles); + model.addRow(new String[] {value1,value2,value3,value4,value5,value6,value7,value8}); + JTable table = new JTable(model); + + table.setRowHeight(25); + table.setPreferredScrollableViewportSize(new Dimension(600, 25)); + table.getColumnModel().getColumn(2).setPreferredWidth(100); + + JComboBox cbx1 = new JComboBox(stra1);// б + TableCellEditor tce1=new DefaultCellEditor(cbx1);// ༭ + JComboBox cbx2 = new JComboBox(stra2); + TableCellEditor tce2=new DefaultCellEditor(cbx2); + + table.getColumnModel().getColumn(2).setCellEditor(tce1); + table.getColumnModel().getColumn(7).setCellEditor(tce2); + + this.add("1.1.center.top", new JLabel("ȴسߴҪ")); + this.add("2.1.center.top",new JScrollPane(table)); + this.setVisible(true); + } + + @Override + public void saveRendering() { + // TODO Auto-generated method stub + + value1 = model.getValueAt(0,0).toString(); + value2 = model.getValueAt(0,1).toString(); + value3 =getKey(map1,model.getValueAt(0,2).toString()); + value4 = model.getValueAt(0,3).toString(); + value5 = model.getValueAt(0,4).toString(); + value6 = model.getValueAt(0,5).toString(); + value7 = model.getValueAt(0,6).toString(); + value8 =getKey(map2,model.getValueAt(0,7).toString()); + try { + rev.setStringProperty("wf2_customerName", value1); + rev.setStringProperty("wf2_productName", value2); + rev.setStringProperty("wf2_preDrillCenHolesize", value3); + rev.setStringProperty("wf2_moldNumber", value4); + rev.setStringProperty("wf2_revDimensionA", value5); + rev.setStringProperty("wf2_productHardness", value6); + rev.setStringProperty("wf2_steelTempPosition", value7); + rev.setStringProperty("wf2_agingType", value8); + rev.refresh(); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public boolean isRenderingModified() { + try { + value1=rev.getProperty("wf2_customerName"); + value2=rev.getProperty("wf2_productName"); + value3=rev.getTCProperty("wf2_preDrillCenHolesize").getDisplayableValue(); + value4=rev.getProperty("wf2_moldNumber"); + value5=rev.getProperty("wf2_revDimensionA"); + value6=rev.getProperty("wf2_productHardness"); + value7=rev.getProperty("wf2_steelTempPosition"); + value8=rev.getTCProperty("wf2_agingType").getDisplayableValue(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(value1 != null && !model.getValueAt(0,0).toString().equals(value1) ){ + System.out.println("value1="+value1); + return true; + } + if(value2 != null && !model.getValueAt(0,1).toString().equals(value2) ){ + System.out.println("value2="+value2); + return true; + } + if(value3 != null && !model.getValueAt(0,2).toString().equals(value3) ){ + System.out.println("value3="+value3); + return true; + } + if(value4 != null && !model.getValueAt(0,3).toString().equals(value4) ){ + System.out.println("value4="+value4); + return true; + } + if(value5 != null && !model.getValueAt(0,4).toString().equals(value5) ){ + System.out.println("value5="+value5); + return true; + } + if(value6 != null && !model.getValueAt(0,5).toString().equals(value6) ){ + System.out.println("value6="+value6); + return true; + } + if(value7 != null && !model.getValueAt(0,6).toString().equals(value7) ){ + System.out.println("value7="+value7); + return true; + } + if(value8 != null && !model.getValueAt(0,7).toString().equals(value8) ){ + System.out.println("value8="+value8); + return true; + } + return false; + } + + public Map getRenderingModified() { + Map modifiedRendering = new HashMap (); + value1 = model.getValueAt(0,0).toString(); + value2 = model.getValueAt(0,1).toString(); + value3 =getKey(map1,model.getValueAt(0,2).toString()); + value4 = model.getValueAt(0,3).toString(); + value5 = model.getValueAt(0,4).toString(); + value6 = model.getValueAt(0,5).toString(); + value7 = model.getValueAt(0,6).toString(); + value8 =getKey(map2,model.getValueAt(0,7).toString()); + try { + if(value1 != null && !model.getValueAt(0,0).toString().equals(value1) ){ + rev.setStringProperty("wf2_customerName", value1); + modifiedRendering.put("wf2_customerName", rev.getProperty("wf2_customerName")); + } + if(value2 != null && !model.getValueAt(0,1).toString().equals(value2) ){ + rev.setStringProperty("wf2_productName", value2); + modifiedRendering.put("wf2_productName", rev.getProperty("wf2_productName")); + } + if(value3 != null && !model.getValueAt(0,2).toString().equals(value3) ){ + rev.setStringProperty("wf2_preDrillCenHolesize", value3); + modifiedRendering.put("wf2_preDrillCenHolesize", rev.getProperty("wf2_preDrillCenHolesize")); + } + if(value4 != null && !model.getValueAt(0,3).toString().equals(value4) ){ + rev.setStringProperty("wf2_moldNumber", value4); + modifiedRendering.put("wf2_moldNumber", rev.getProperty("wf2_moldNumber")); + } + if(value5 != null && !model.getValueAt(0,4).toString().equals(value5) ){ + rev.setStringProperty("wf2_revDimensionA", value5); + modifiedRendering.put("wf2_revDimensionA", rev.getProperty("wf2_revDimensionA")); + } + if(value6 != null && !model.getValueAt(0,5).toString().equals(value6) ){ + rev.setStringProperty("wf2_productHardness", value6); + modifiedRendering.put("wf2_productHardness", rev.getProperty("wf2_productHardness")); + } + if(value7 != null && !model.getValueAt(0,6).toString().equals(value7) ){ + rev.setStringProperty("wf2_steelTempPosition", value7); + modifiedRendering.put("wf2_steelTempPosition", rev.getProperty("wf2_steelTempPosition")); + } + if(value8 != null && !model.getValueAt(0,7).toString().equals(value8) ){ + rev.setStringProperty("wf2_agingType", value8); + modifiedRendering.put("wf2_agingType", rev.getProperty("wf2_agingType")); + } + } catch (TCException ex){ + ex.toString(); + } + return modifiedRendering; + } + + private static String getKey(Map map,String value){ + if(value == null) return null; + String key=""; + for (Map.Entry entry : map.entrySet()) { + if(value.equals(entry.getValue())){ + key=entry.getKey(); + } + } + return key; + } +} diff --git a/src/com/teamcenter/rac/form/WF2_dynamicBalMhRevisionForm.java b/src/com/teamcenter/rac/form/WF2_dynamicBalMhRevisionForm.java new file mode 100644 index 0000000..463e111 --- /dev/null +++ b/src/com/teamcenter/rac/form/WF2_dynamicBalMhRevisionForm.java @@ -0,0 +1,462 @@ +package com.teamcenter.rac.form; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; + +import com.connor.wf.plm.table.CTMap; +import com.connor.wf.plm.table.CTable; +import com.connor.wf.plm.table.TableCellTextAreaRenderer; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.PropertyLayout; + +//ƽҪܱӹ) +public class WF2_dynamicBalMhRevisionForm extends AbstractRendering { + private TCComponentForm form; + + private TCComponentItemRevision rev; + private String value1 = "";// ͻ + private String value2 = "";// Ʒ + private String value3 = "";// ļ׼ + private String value4 = "";// ڲ(ӹ) + private String value5 = "";// + private String value6 = "";// + private String value7 = "";// ͻ׼ + private String value8 = "";// ڲ(Ʒ) + private String value9 = "";// + private String[] valStr_1;// ƽ1 + private String[] valStr_2;// ƽ2 + private String value10 = "";// + private String value11 = "";// Ŀ + + + private CTMap ctmap; + private CTable table; + + public WF2_dynamicBalMhRevisionForm(TCComponent arg0) throws Exception { + super(arg0); + // TODO Auto-generated constructor stub + form = (TCComponentForm) arg0; + AIFComponentContext[] revs = form.whereReferencedByTypeRelation(new String[]{"WF2_dynamicBalMhRevision"},new String[]{"IMAN_master_form","IMAN_master_form_rev"}); + rev = (TCComponentItemRevision) revs[0].getComponent(); + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + // TODO Auto-generated method stub + value1 = rev.getProperty("wf2_customerName");// ͻ + value2 = rev.getProperty("wf2_productNumber");// Ʒ + value3 = rev.getProperty("wf2_fileStandard");// ļ׼ + value4 = rev.getProperty("wf2_internalAcceptMe");// ڲ(ӹ) + value5 = rev.getProperty("wf2_maxReworkAllowed");// + value6 = rev.getProperty("wf2_reworkPoint");// + value7 = rev.getProperty("wf2_customerStandard");// ͻ׼ + value8 = rev.getProperty("wf2_internalAcceptFin");// ڲ(Ʒ) + value9 = rev.getProperty("wf2_valveCounterweight");// + value10 = rev.getProperty("wf2_size");// + value11 = rev.getProperty("wf2_diameter");// Ŀ + + valStr_1 = rev.getTCProperty("wf2_dynamicBalMePoint") + .getStringArrayValue();// ƽ1 + valStr_2 = rev.getTCProperty("wf2_dynamicBalMePointVal") + .getStringArrayValue();// ƽ2 + initUI(); + } + + private void initUI() { + + this.setLayout(new PropertyLayout()); + // this.setPreferredSize(new Dimension(800, 100)); + ctmap = new CTMap(4, 13) {// װ(̳DefaultTableModel) + @Override + public boolean isCellEditable(int row, int column) { + // TODO Auto-generated method stub + if (row == 0 || row == 1) {// һ.вܱ༭ + return false; + } + return true; + } + }; + table = new CTable(ctmap);// װ(̳JTable) + + + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// tableݾ + tcr.setHorizontalAlignment(SwingConstants.CENTER); + table.setDefaultRenderer(Object.class, tcr); + +// TableCellTextAreaRenderer tca=new TableCellTextAreaRenderer();//ָԪԶ +// table.getColumnModel().getColumn(0).setCellRenderer(tca); + table.getColumnModel().getColumn(4).setPreferredWidth(100); + + + table.setBorder(new LineBorder(Color.BLACK)); + JScrollPane pane = new JScrollPane(table);// ù + pane.setPreferredSize(new Dimension(1000, 127)); + + // и + table.setRowHeight(30); + + // رͷ + table.getTableHeader().setVisible(false); + DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); + renderer.setPreferredSize(new Dimension(0, 0)); + table.getTableHeader().setDefaultRenderer(renderer); + + JLabel la = new JLabel("ƽҪܱ(ӹ)"); + la.setFont(new Font("", Font.PLAIN, 17)); + ctmap.combine(new int[] { 0 }, new int[] { 2, 3, 4, 5 }); + ctmap.combine(new int[] { 0 }, new int[] { 6, 7 }); + ctmap.combine(new int[] { 0, 1 }, new int[] { 0 }); + ctmap.combine(new int[] { 0, 1 }, new int[] { 1 }); + ctmap.combine(new int[] { 0, 1 }, new int[] { 8 }); + ctmap.combine(new int[] { 0, 1 }, new int[] { 9, 10 }); + ctmap.combine(new int[] { 0, 1 }, new int[] { 11 }); + ctmap.combine(new int[] { 0, 1 }, new int[] { 12 }); + + ctmap.combine(new int[] { 2, 3 }, new int[] { 0 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 1 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 2 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 3 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 4 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 5 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 6 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 7 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 8 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 11 }); + ctmap.combine(new int[] { 2, 3 }, new int[] { 12 }); + + ctmap.setValueAt("ͻ", 0, 0); + ctmap.setValueAt("Ʒ", 0, 1); + ctmap.setValueAt("ӹ", 0, 2); + ctmap.setValueAt("ļ׼", 1, 2); + ctmap.setValueAt("ڲ", 1, 3); + ctmap.setValueAt("", 1, 4); + ctmap.setValueAt("", 1, 5); + ctmap.setValueAt("Ʒ", 0, 6); + ctmap.setValueAt("ͻ׼", 1, 6); + ctmap.setValueAt("ڲ", 1, 7); + ctmap.setValueAt("", 0, 8); + ctmap.setValueAt("ƽ", 0, 9); + ctmap.setValueAt("", 0, 11); + ctmap.setValueAt("Ŀ", 0, 12); + + ctmap.setValueAt(value1, 2, 0); + ctmap.setValueAt(value2, 2, 1); + ctmap.setValueAt(value3, 2, 2); + ctmap.setValueAt(value4, 2, 3); + ctmap.setValueAt(value5, 2, 4); + ctmap.setValueAt(value6, 2, 5); + ctmap.setValueAt(value7, 2, 6); + ctmap.setValueAt(value8, 2, 7); + ctmap.setValueAt(value9, 2, 8); + ctmap.setValueAt(value10, 2, 11); + ctmap.setValueAt(value11, 2, 12); + if (valStr_1 != null && valStr_2 != null) { + for (int i = 0; i < valStr_1.length; i++) { + ctmap.setValueAt(valStr_1[i], 2 + i, 9); + ctmap.setValueAt(valStr_2[i], 2 + i, 10); + } + } + this.add("1.1.center.top", la); + this.add("2.1.center.top", pane); + this.setVisible(true); + } + + @Override + public void saveRendering() { + // TODO Auto-generated method stub + System.out.println("saveRendering"); + if (table != null && table.getCellEditor() != null) { + table.getCellEditor().stopCellEditing();// ˳Ԫ༭ + } + value1 = getVal(2, 0); + value2 = getVal(2, 1); + value3 = getVal(2, 2); + value4 = getVal(2, 3); + value5 = getVal(2, 4); + value6 = getVal(2, 5); + value7 = getVal(2, 6); + value8 = getVal(2, 7); + value9 = getVal(2, 8); + value10 = getVal(2, 11); + value11 = getVal(2, 12); + valStr_1 = new String[2]; + valStr_1[0] =getVal(2, 9); + valStr_1[1] =getVal(3, 9); + valStr_2 = new String[2]; + valStr_2[0] =getVal(2, 10); + valStr_2[1] =getVal(3, 10); + try { + rev.setStringProperty("wf2_customerName", value1); + rev.setStringProperty("wf2_productNumber", value2); + rev.setStringProperty("wf2_fileStandard", value3); + rev.setStringProperty("wf2_internalAcceptMe", value4); + rev.setStringProperty("wf2_maxReworkAllowed", value5); + rev.setStringProperty("wf2_reworkPoint", value6); + rev.setStringProperty("wf2_customerStandard", value7); + rev.setStringProperty("wf2_internalAcceptFin", value8); + rev.setStringProperty("wf2_valveCounterweight", value9); + rev.setStringProperty("wf2_size", value10); + rev.setStringProperty("wf2_diameter", value11); + rev.getTCProperty("wf2_dynamicBalMePoint").setStringValueArray( + valStr_1); + rev.getTCProperty("wf2_dynamicBalMePointVal").setStringValueArray( + valStr_2); + rev.refresh(); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + //ñеԪֵ + private String getVal(int i, int j) { + return ctmap.getValueAt(i, j)==null?"":ctmap.getValueAt(i, j).toString(); + } + + public boolean isRenderingModified() { + if (table != null && table.getCellEditor() != null) { + table.getCellEditor().stopCellEditing();// ˳Ԫ༭ + } + String value1 = "";// ͻ + String value2 = "";// Ʒ + String value3 = "";// ļ׼ + String value4 = "";// ڲ(ӹ) + String value5 = "";// + String value6 = "";// + String value7 = "";// ͻ׼ + String value8 = "";// ڲ(Ʒ) + String value9 = "";// + String[] valStr_1=null;// ƽ1 + String[] valStr_2=null;// ƽ2 + String value10 = "";// + String value11 = "";// Ŀ + try { + value1 = rev.getProperty("wf2_customerName");// ͻ + value2 = rev.getProperty("wf2_productNumber");// Ʒ + value3 = rev.getProperty("wf2_fileStandard");// ļ׼ + value4 = rev.getProperty("wf2_internalAcceptMe");// ڲ(ӹ) + value5 = rev.getProperty("wf2_maxReworkAllowed");// + value6 = rev.getProperty("wf2_reworkPoint");// + value7 = rev.getProperty("wf2_customerStandard");// ͻ׼ + value8 = rev.getProperty("wf2_internalAcceptFin");// ڲ(Ʒ) + value9 = rev.getProperty("wf2_valveCounterweight");// + value10 = rev.getProperty("wf2_size");// + value11 = rev.getProperty("wf2_diameter");// Ŀ + + valStr_1 = rev.getTCProperty("wf2_dynamicBalMePoint") + .getStringArrayValue();// ƽ1 + valStr_2 = rev.getTCProperty("wf2_dynamicBalMePointVal") + .getStringArrayValue();// ƽ2 + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + if (value1 != null && !getVal(2, 0).equals(value1)) { + return true; + } + if (value2 != null && !getVal(2, 1).equals(value2)) { + return true; + } + if (value3 != null && !getVal(2, 2).equals(value3)) { + return true; + } + if (value4 != null && !getVal(2, 3).equals(value4)) { + return true; + } + if (value5 != null && !getVal(2, 4).equals(value4)) { + return true; + } + + if (value6 != null && !getVal(2, 5).equals(value6)) { + return true; + } + if (value7 != null && !getVal(2, 6).equals(value7)) { + return true; + } + if (value8 != null && !getVal(2, 7).equals(value8)) { + return true; + } + if (value9 != null && !getVal(2, 8).equals(value9)) { + return true; + } + if (value10 != null && !getVal(2, 11).equals(value10)) { + return true; + } + if (value11 != null && !getVal(2, 12).equals(value11)) { + return true; + } + + if (valStr_1 != null) { + for (int i = 0; i < valStr_1.length; i++) { + if (valStr_1[i]==null) { + valStr_1[i]=""; + } + if (!getVal(2 + i, 9).equals(valStr_1[i])) { + System.out.println("9"+i); + return true; + } + } + } + if (valStr_2 != null) { + for (int i = 0; i < valStr_2.length; i++) { + if (valStr_2[i]==null) { + valStr_2[i]=""; + } + if (!getVal(2 + i, 10).equals(valStr_2[i])) { + System.out.println("10"+i); + return true; + } + } + } + return false; + } + + public Map getRenderingModified() { + if (table != null && table.getCellEditor() != null) { + table.getCellEditor().stopCellEditing(); + } + Map modifiedRendering = new HashMap(); + String value1 = "";// ͻ + String value2 = "";// Ʒ + String value3 = "";// ļ׼ + String value4 = "";// ڲ(ӹ) + String value5 = "";// + String value6 = "";// + String value7 = "";// ͻ׼ + String value8 = "";// ڲ(Ʒ) + String value9 = "";// + String[] valStr_1=null;// ƽ1 + String[] valStr_2=null;// ƽ2 + String value10 = "";// + String value11 = "";// Ŀ + + try { + value1 = rev.getProperty("wf2_customerName");// ͻ + value2 = rev.getProperty("wf2_productNumber");// Ʒ + value3 = rev.getProperty("wf2_fileStandard");// ļ׼ + value4 = rev.getProperty("wf2_internalAcceptMe");// ڲ(ӹ) + value5 = rev.getProperty("wf2_maxReworkAllowed");// + value6 = rev.getProperty("wf2_reworkPoint");// + value7 = rev.getProperty("wf2_customerStandard");// ͻ׼ + value8 = rev.getProperty("wf2_internalAcceptFin");// ڲ(Ʒ) + value9 = rev.getProperty("wf2_valveCounterweight");// + value10 = rev.getProperty("wf2_size");// + value11 = rev.getProperty("wf2_diameter");// Ŀ + valStr_1 = rev.getTCProperty("wf2_dynamicBalMePoint") + .getStringArrayValue();// ƽ1 + valStr_2 = rev.getTCProperty("wf2_dynamicBalMePointVal") + .getStringArrayValue();// ƽ2 + if (value1 != null&& !getVal(2, 0).equals(value1)) { + rev.setStringProperty("wf2_customerName", getVal(2, 0)); + modifiedRendering.put("wf2_customerName", value1); + } + if (value2 != null&& !getVal(2, 1).equals(value2)) { + rev.setStringProperty("wf2_productNumber",getVal(1, 1)); + modifiedRendering.put("wf2_productNumber", value2); + } + if (value3 != null&& !getVal(2, 2).equals(value3)) { + rev.setStringProperty("wf2_customerStandard",getVal(2, 2)); + modifiedRendering.put("wf2_customerStandard", value3); + } + if (value4 != null&& !getVal(2, 3).equals(value4)) { + rev.setStringProperty("wf2_valveType",getVal(2, 3)); + modifiedRendering.put("wf2_valveType", value4); + } + if (value5 != null&& !getVal(2, 4).equals(value5)) { + rev.setStringProperty("wf2_valveType",getVal(2, 4)); + modifiedRendering.put("wf2_valveType", value5); + } + + if (value6 != null + && !getVal(2, 5).equals(value6)) { + rev.setStringProperty("wf2_ET", getVal(2, 5)); + modifiedRendering.put("wf2_ET", value6); + } + if (value7 != null + && !getVal(2, 6).equals(value7)) { + rev.setStringProperty("wf2_diameter", getVal(2, 6)); + modifiedRendering.put("wf2_diameter", value7); + } + if (value8 != null + && !getVal(2, 7).equals(value8)) { + rev.setStringProperty("wf2_harmonicRqmt",getVal(2, 7)); + modifiedRendering.put("wf2_harmonicRqmt", value8); + } + if (value9 != null + && !getVal(2, 8).equals(value9)) { + rev.setStringProperty("wf2_finishedPatch",getVal(2, 8)); + modifiedRendering.put("wf2_finishedPatch", value9); + } + if (value10 != null&& !getVal(2, 11).equals(value10)) { + rev.setStringProperty("wf2_size",getVal(2, 11)); + modifiedRendering.put("wf2_size", value10); + } + if (value11 != null&& !getVal(2, 12).equals(value11)) { + rev.setStringProperty("wf2_size", getVal(2, 12)); + modifiedRendering.put("wf2_size", value11); + } + if (valStr_1 != null) { + boolean booval_1 = false; + for (int i = 0; i < valStr_1.length; i++) { + if (valStr_1[i]==null) { + valStr_1[i]=""; + } + if (!getVal(2 + i, 9).equals(valStr_1[i])) { + booval_1 = true; + } + } + if (booval_1) { + String[] strs_valStr_1 = new String[2]; + strs_valStr_1[0] = getVal(2, 9); + strs_valStr_1[1] = getVal(3, 9); + rev.getTCProperty("wf2_dynamicBalMePoint").setStringValueArray(strs_valStr_1); + modifiedRendering.put("wf2_dynamicBalMePoint", valStr_1); + } + + } + if (valStr_2 != null) { + boolean booval_2 = false; + for (int i = 0; i < valStr_2.length; i++) { + if (valStr_2[i]==null) { + valStr_2[i]=""; + } + if (!getVal(2 + i, 10).equals(valStr_2[i])) { + booval_2 = true; + } + } + if (booval_2) { + String[] strs_valStr_2 = new String[2]; + strs_valStr_2[0] =getVal(2, 10).toString(); + strs_valStr_2[1] =getVal(3, 10).toString(); + rev.getTCProperty("wf2_dynamicBalMePointVal").setStringValueArray(strs_valStr_2); + modifiedRendering.put("wf2_dynamicBalMePointVal", valStr_2); + } + + } + + } catch (TCException ex) { + ex.printStackTrace(); + } + return modifiedRendering; + } + +} diff --git a/src/com/teamcenter/rac/form/WF2_dynamicBalRevisionForm.java b/src/com/teamcenter/rac/form/WF2_dynamicBalRevisionForm.java new file mode 100644 index 0000000..5416a18 --- /dev/null +++ b/src/com/teamcenter/rac/form/WF2_dynamicBalRevisionForm.java @@ -0,0 +1,398 @@ +package com.teamcenter.rac.form; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.SwingConstants; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; + +import com.connor.wf.plm.table.CTMap; +import com.connor.wf.plm.table.CTable; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.PropertyLayout; + +//ƽҪܱ(Ʒ) +public class WF2_dynamicBalRevisionForm extends AbstractRendering { + private TCComponentForm form; + + private TCComponentItemRevision rev; + private String value1 = "";// ͻ + private String value2 = "";// Ʒ + private String value3 = "";// ͻ׼ + private String value4 = "";// ͺ + private String[] value5_1;// ƽ1 + private String[] value5_2;// ƽ2 + private String value6 = "";// ƫET + private String value7 = "";// Ŀֱ + private String value8 = "";// гҪ + private String value9 = "";// Ʒ + private String value10 = "";// + private CTMap ctmap; + private CTable table; + + public WF2_dynamicBalRevisionForm(TCComponent arg0) throws Exception { + super(arg0); + // TODO Auto-generated constructor stub + form = (TCComponentForm) arg0; + AIFComponentContext[] revs = form.whereReferencedByTypeRelation(new String[]{"WF2_dynamicBalRevision"},new String[]{"IMAN_master_form","IMAN_master_form_rev"}); + rev = (TCComponentItemRevision) revs[0].getComponent(); + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + // TODO Auto-generated method stub + value1 = rev.getProperty("wf2_customerName");// ͻ + value2 = rev.getProperty("wf2_productNumber");// Ʒ + value3 = rev.getProperty("wf2_customerStandard");// ͻ׼ + value4 = rev.getProperty("wf2_valveType");// ͺ + value5_1 = rev.getTCProperty("wf2_dynamicBalMePoint") + .getStringArrayValue();// ƽ1 + value5_2 = rev.getTCProperty("wf2_dynamicBalMePointVal") + .getStringArrayValue();// ƽ2 + value6 = rev.getProperty("wf2_ET");// ƫET + value7 = rev.getProperty("wf2_diameter");// Ŀֱ + value8 = rev.getProperty("wf2_harmonicRqmt");// гҪ + value9 = rev.getProperty("wf2_finishedPatch");// Ʒ + value10 = rev.getProperty("wf2_size");// + initUI(); + } + + private void initUI() { + + this.setLayout(new PropertyLayout()); + // this.setPreferredSize(new Dimension(800, 100)); + ctmap = new CTMap(3, 11) {// װ(̳DefaultTableModel) + @Override + public boolean isCellEditable(int row, int column) { + // TODO Auto-generated method stub + if (row == 0) {// һвܱ༭ + return false; + } + return true; + } + }; + table = new CTable(ctmap);// װ(̳JTable) + + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// tableݾ + tcr.setHorizontalAlignment(SwingConstants.CENTER); + table.setDefaultRenderer(Object.class, tcr); + table.setBorder(new LineBorder(Color.BLACK)); + JScrollPane pane = new JScrollPane(table);// ù + pane.setPreferredSize(new Dimension(900, 110)); + + // и + table.setRowHeight(35); + + // رͷ + table.getTableHeader().setVisible(false); + DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); + renderer.setPreferredSize(new Dimension(0, 0)); + table.getTableHeader().setDefaultRenderer(renderer); + + JLabel la = new JLabel("ƽҪܱ(Ʒ)"); + la.setFont(new Font("", Font.PLAIN, 17)); + ctmap.combine(new int[] { 0 }, new int[] { 4, 5 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 0 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 1 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 2 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 3 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 6 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 7 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 8 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 9 }); + ctmap.combine(new int[] { 1, 2 }, new int[] { 10 }); + ctmap.setValueAt("ͻ", 0, 0); + ctmap.setValueAt("Ʒ", 0, 1); + ctmap.setValueAt("ͻ׼", 0, 2); + ctmap.setValueAt("ͺ", 0, 3); + ctmap.setValueAt("ƽ", 0, 4); + ctmap.setValueAt("ƫET", 0, 6); + ctmap.setValueAt("Ŀֱ", 0, 7); + ctmap.setValueAt("гҪ", 0, 8); + ctmap.setValueAt("Ʒ", 0, 9); + ctmap.setValueAt("", 0, 10); + + ctmap.setValueAt(value1, 1, 0); + ctmap.setValueAt(value2, 1, 1); + ctmap.setValueAt(value3, 1, 2); + ctmap.setValueAt(value4, 1, 3); + ctmap.setValueAt(value6, 1, 6); + ctmap.setValueAt(value7, 1, 7); + ctmap.setValueAt(value8, 1, 8); + ctmap.setValueAt(value9, 1, 9); + ctmap.setValueAt(value10, 1, 10); + if (value5_1 != null && value5_2 != null) { + for (int i = 0; i < value5_1.length; i++) { + ctmap.setValueAt(value5_1[i], 1 + i, 4); + ctmap.setValueAt(value5_2[i], 1 + i, 5); + } + } + + this.add("1.1.center.top", la); + this.add("2.1.center.top", pane); + this.setVisible(true); + } + + @Override + public void saveRendering() { + // TODO Auto-generated method stub + System.out.println("saveRendering"); + if (table != null && table.getCellEditor() != null) { + table.getCellEditor().stopCellEditing();// ˳Ԫ༭ + } + + value1 = getVal(1, 0); + value2 = getVal(1, 1); + value3 = getVal(1, 2); + value4 = getVal(1, 3); + value5_1 = new String[2]; + value5_1[0] = getVal(1, 4); + value5_1[1] = getVal(2, 4); + value5_2 = new String[2]; + value5_2[0] = getVal(1, 5); + value5_2[1] = getVal(2, 5); + value6 = getVal(1, 6); + value7 = getVal(1, 7); + value8 = getVal(1, 8); + value9 = getVal(1, 9); + value10 = getVal(1, 10); + try { + + rev.setStringProperty("wf2_customerName", value1); + rev.setStringProperty("wf2_productNumber", value2); + rev.setStringProperty("wf2_customerStandard", value3); + rev.setStringProperty("wf2_valveType", value4); + rev.getTCProperty("wf2_dynamicBalMePoint").setStringValueArray( + value5_1); + rev.getTCProperty("wf2_dynamicBalMePointVal").setStringValueArray( + value5_2); + rev.setStringProperty("wf2_ET", value6); + rev.setStringProperty("wf2_diameter", value7); + rev.setStringProperty("wf2_harmonicRqmt", value8); + rev.setStringProperty("wf2_finishedPatch", value9); + rev.setStringProperty("wf2_size", value10); + rev.refresh(); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + // ñеԪֵ + private String getVal(int i, int j) { + return ctmap.getValueAt(i, j) == null ? "" : ctmap.getValueAt(i, j).toString(); + } + + public boolean isRenderingModified() { + if (table != null && table.getCellEditor() != null) { + table.getCellEditor().stopCellEditing();// ˳Ԫ༭ + } + String value1 = "";// ͻ + String value2 = "";// Ʒ + String value3 = "";// ͻ׼ + String value4 = "";// ͺ + String[] value5_1 = null;// ƽ1 + String[] value5_2 = null;// ƽ2 + String value6 = "";// ƫET + String value7 = "";// Ŀֱ + String value8 = "";// гҪ + String value9 = "";// Ʒ + String value10 = "";// + try { + value1 = rev.getProperty("wf2_customerName");// ͻ + value2 = rev.getProperty("wf2_productNumber");// Ʒ + value3 = rev.getProperty("wf2_customerStandard");// ͻ׼ + value4 = rev.getProperty("wf2_valveType");// ͺ + value5_1 = rev.getTCProperty("wf2_dynamicBalMePoint") + .getStringArrayValue();// ƽ1 + value5_2 = rev.getTCProperty("wf2_dynamicBalMePointVal") + .getStringArrayValue();// ƽ2 + value6 = rev.getProperty("wf2_ET");// ƫET + value7 = rev.getProperty("wf2_diameter");// Ŀֱ + value8 = rev.getProperty("wf2_harmonicRqmt");// гҪ + value9 = rev.getProperty("wf2_finishedPatch");// Ʒ + value10 = rev.getProperty("wf2_size");// + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if (value1 != null && !getVal(1, 0).equals(value1)) { + return true; + } + if (value2 != null && !getVal(1, 1).equals(value2)) { + return true; + } + if (value3 != null && !getVal(1, 2).equals(value3)) { + return true; + } + if (value4 != null && !getVal(1, 3).equals(value4)) { + return true; + } + if (value5_1 != null) { + for (int i = 0; i < value5_1.length; i++) { + if (value5_1[i]==null) { + value5_1[i]=""; + } + if (!getVal(1 + i, 4).equals(value5_1[i])) { + return true; + } + } + } + if (value5_2 != null) { + for (int i = 0; i < value5_2.length; i++) { + if (value5_2[i]==null) { + value5_2[i]=""; + } + if (!getVal(1 + i, 5).equals(value5_2[i])) { + return true; + } + } + } + + if (value6 != null && !getVal(1, 6).equals(value6)) { + return true; + } + if (value7 != null && !getVal(1, 7).equals(value7)) { + return true; + } + if (value8 != null && !getVal(1, 8).equals(value8)) { + return true; + } + if (value9 != null && !getVal(1, 9).equals(value9)) { + return true; + } + if (value10 != null && !getVal(1, 10).equals(value10)) { + return true; + } + return false; + } + + public Map getRenderingModified() { + if (table != null && table.getCellEditor() != null) { + table.getCellEditor().stopCellEditing(); + } + Map modifiedRendering = new HashMap(); + String value1 = "";// ͻ + String value2 = "";// Ʒ + String value3 = "";// ͻ׼ + String value4 = "";// ͺ + String[] value5_1 = null;// ƽ1 + String[] value5_2 = null;// ƽ2 + String value6 = "";// ƫET + String value7 = "";// Ŀֱ + String value8 = "";// гҪ + String value9 = "";// Ʒ + String value10 = "";// + + try { + value1 = rev.getProperty("wf2_customerName");// ͻ + value2 = rev.getProperty("wf2_productNumber");// Ʒ + value3 = rev.getProperty("wf2_customerStandard");// ͻ׼ + value4 = rev.getProperty("wf2_valveType");// ͺ + value5_1 = rev.getTCProperty("wf2_dynamicBalMePoint") + .getStringArrayValue();// ƽ1 + value5_2 = rev.getTCProperty("wf2_dynamicBalMePointVal") + .getStringArrayValue();// ƽ2 + value6 = rev.getProperty("wf2_ET");// ƫET + value7 = rev.getProperty("wf2_diameter");// Ŀֱ + value8 = rev.getProperty("wf2_harmonicRqmt");// гҪ + value9 = rev.getProperty("wf2_finishedPatch");// Ʒ + value10 = rev.getProperty("wf2_size");// + if (value1 != null && !getVal(1, 0).equals(value1)) { + rev.setStringProperty("wf2_customerName", getVal(1, 0)); + modifiedRendering.put("wf2_customerName", value1); + } + if (value2 != null && !getVal(1, 1).equals(value2)) { + rev.setStringProperty("wf2_productNumber", getVal(1, 1)); + modifiedRendering.put("wf2_productNumber", value2); + } + if (value3 != null && !getVal(1, 2).equals(value3)) { + rev.setStringProperty("wf2_customerStandard", getVal(1, 2)); + modifiedRendering.put("wf2_customerStandard", value3); + } + if (value4 != null && !getVal(1, 3).equals(value4)) { + rev.setStringProperty("wf2_valveType", getVal(1, 3)); + modifiedRendering.put("wf2_valveType", value4); + } + if (value5_1 != null) { + boolean booval5_1 = false; + for (int i = 0; i < value5_1.length; i++) { + if (value5_1[i]==null) { + value5_1[i]=""; + } + if (!getVal(1 + i, 4).equals(value5_1[i])) { + booval5_1 = true; + } + } + if (booval5_1) { + String[] strs_value5_1 = new String[2]; + strs_value5_1[0] = getVal(1, 4); + strs_value5_1[1] = getVal(2, 4); + rev.getTCProperty("wf2_dynamicBalMePoint") + .setStringValueArray(strs_value5_1); + modifiedRendering.put("wf2_dynamicBalMePoint", value5_1); + } + + } + if (value5_2 != null) { + boolean booval5_2 = false; + for (int i = 0; i < value5_2.length; i++) { + if (value5_2[i]==null) { + value5_2[i]=""; + } + if (!getVal(1 + i, 5).equals(value5_2[i])) { + booval5_2 = true; + } + } + if (booval5_2) { + String[] strs_value5_2 = new String[2]; + strs_value5_2[0] = getVal(1, 5); + strs_value5_2[1] = getVal(2, 5); + rev.getTCProperty("wf2_dynamicBalMePointVal") + .setStringValueArray(strs_value5_2); + modifiedRendering.put("wf2_dynamicBalMePointVal", value5_2); + } + + } + + if (value6 != null && !getVal(1, 6).equals(value6)) { + rev.setStringProperty("wf2_ET", getVal(1, 6)); + modifiedRendering.put("wf2_ET", value6); + } + if (value7 != null && !getVal(1, 7).equals(value7)) { + rev.setStringProperty("wf2_diameter", getVal(1, 7)); + modifiedRendering.put("wf2_diameter", value7); + } + if (value8 != null && !getVal(1, 8).equals(value8)) { + rev.setStringProperty("wf2_harmonicRqmt", getVal(1, 8)); + modifiedRendering.put("wf2_harmonicRqmt", value8); + } + if (value9 != null && !getVal(1, 9).equals(value9)) { + rev.setStringProperty("wf2_finishedPatch", getVal(1, 9)); + modifiedRendering.put("wf2_finishedPatch", value9); + } + if (value10 != null && !getVal(1, 10).equals(value10)) { + rev.setStringProperty("wf2_size", getVal(1, 10)); + modifiedRendering.put("wf2_size", value10); + } + } catch (TCException ex) { + ex.printStackTrace(); + } + return modifiedRendering; + } + +} diff --git a/src/com/teamcenter/rac/form/form_user.properties b/src/com/teamcenter/rac/form/form_user.properties new file mode 100644 index 0000000..8f65595 --- /dev/null +++ b/src/com/teamcenter/rac/form/form_user.properties @@ -0,0 +1,5 @@ +WF2_hTrtProcCrdRevisionMaster.FORMJAVARENDERING=com.teamcenter.rac.form.Myform + +WF2_dynamicBalRevisionMaster.FORMJAVARENDERING=com.teamcenter.rac.form.WF2_dynamicBalRevisionForm + +WF2_dynamicBalMhRevisionMaster.FORMJAVARENDERING=com.teamcenter.rac.form.WF2_dynamicBalMhRevisionForm \ No newline at end of file diff --git a/src/com/teamcenter/rac/project/views/ProjectDefinitionView.java b/src/com/teamcenter/rac/project/views/ProjectDefinitionView.java new file mode 100644 index 0000000..6d9be11 --- /dev/null +++ b/src/com/teamcenter/rac/project/views/ProjectDefinitionView.java @@ -0,0 +1,1861 @@ +package com.teamcenter.rac.project.views; + +import com.connor.number.GetNumber; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.InterfaceAIFOperationListener; +import com.teamcenter.rac.aif.kernel.IOperationService; +import com.teamcenter.rac.aifrcp.AifrcpPlugin; +import com.teamcenter.rac.common.lov.view.controls.LOVDisplayer; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.SessionChangedEvent; +import com.teamcenter.rac.kernel.SessionChangedListener; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentRole; +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.project.Messages; +import com.teamcenter.rac.project.ProjectUIPostActions; +import com.teamcenter.rac.project.common.IC_UserProxy; +import com.teamcenter.rac.project.common.ProjectConstants; +import com.teamcenter.rac.project.common.ProjectManager; +import com.teamcenter.rac.project.common.ProjectTeamStatus; +import com.teamcenter.rac.project.common.ProjectTeamTreeManager; +import com.teamcenter.rac.project.filter.ProgramTreeFilter; +import com.teamcenter.rac.project.nodes.ProjectRootNode; +import com.teamcenter.rac.project.nodes.ProjectTeamContentNode; +import com.teamcenter.rac.project.nodes.ProjectTeamContentNodeData; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.ui.views.AbstractContentViewPart; +import com.teamcenter.rac.ui.views.providers.GroupRole; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.OSGIUtil; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.Utilities; +import com.teamcenter.rac.util.log.Debug; +import com.teamcenter.rac.vns.model.IContentView; +import com.teamcenter.services.rac.core.ProjectLevelSecurityService; +import com.teamcenter.services.rac.core._2012_09.ProjectLevelSecurity; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeSet; +import org.apache.log4j.Logger; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.custom.ViewForm; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.forms.widgets.Form; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +public class ProjectDefinitionView extends AbstractContentViewPart + implements SessionChangedListener, IContentView +{ + private Composite m_headerComposite = null; + private Button m_createButton = null; + private Button m_modifyButton = null; + private Button m_copyButton = null; + private Button m_deleteButton = null; + private Button m_clearButton = null; + private Button jk_idButton = null; + private Text m_idText = null; + private Text m_nameText = null; + private Text m_descriptionText = null; + private LOVDisplayer m_categoryCombo; + private Button m_activeStatusBtn = null; + private Button m_inactiveStatusBtn = null; + private Button m_inactiveandInviisibleStatusBtn = null; + private static ProjectTeamTreeManager m_projectTeamManager; + private TCComponentProject project = null; + private TCSession session = RACUIUtil.getTCSession(); + private final Registry reg = ProjectConstants.projectReg; + private String projectID; + private String projectName; + private String projectDesc; + private String projectCollaborationCategories; + private boolean useProgramSec = false; + private boolean projectStatus = false; + private boolean projectVisibility = false; + private ProjectLevelSecurity.ProjectTeamData[] projectTeamMembers = null; + private ProjectLevelSecurity.ProjectOpsResponse result = null; + private boolean isPA = false; + private boolean isPTA = false; + protected ArrayList infos = null; + private boolean isModified = false; + private boolean isNewlyCreated = false; + private boolean isDirty = false; + private boolean isLoading = false; + private ProjectUIPostActions m_contributer = null; + private static final Logger logger = Logger.getLogger(ProjectDefinitionView.class); + private Text m_parentText; + private String m_parentProject = null; + private Button m_ProgramBtn = null; + private Button m_ProjectBtn = null; + private Button m_teamInheritance = null; + private int teamInheritanceValue; + private static ProjectDefinitionView pDefView; + + public ProjectDefinitionView() + { + setShowHeader(true); + setMultiSelectionSupported(false); + setProcessNullSelectionsEnabled(true); + setComponentEventListeningEnabled(true); + AbstractTCAdminApplicationViewHelper localAbstractTCAdminApplicationViewHelper = ProjectManager.getApp(); + try + { + localAbstractTCAdminApplicationViewHelper.checkApplicationPriviledgeWithMessage(); + } + catch (Exception localException) + { + logger.error(localException.getClass().getName(), localException); + } + this.isPA = localAbstractTCAdminApplicationViewHelper.isPAPrivileged(); + this.isPTA = localAbstractTCAdminApplicationViewHelper.isPTAPrivileged(); + loadPostActionExtension(); + } + + protected void createContent(Composite paramComposite) + { + paramComposite.setLayout(new FillLayout(512)); + SashForm localSashForm = new SashForm(paramComposite, 512); + localSashForm.setSashWidth(5); + localSashForm.setLayout(new FillLayout()); + getToolkit().adapt(localSashForm, true, true); + ViewForm localViewForm1 = new ViewForm(localSashForm, 16777216); + getToolkit().adapt(localViewForm1, true, true); + ViewForm localViewForm2 = new ViewForm(localSashForm, 16777216); + getToolkit().adapt(localViewForm2, true, true); + localViewForm1.setContent(createTopForm(localViewForm1)); + localViewForm2.setContent(createBottomForm(localViewForm2)); + localViewForm2.setBorderVisible(true); + localSashForm.setWeights(new int[] { 25, 75 }); + getTCSession().addSessionChangeListener(this); + } + + protected Control createHeadControl(Composite paramComposite) + { + Composite localComposite = createHeaderComposite(paramComposite); + createButtons(localComposite); + getScrolledForm().getForm().setHeadClient(this.m_headerComposite); + getScrolledForm().getForm().getHead().update(); + return this.m_headerComposite; + } + + public boolean isDirtyStill() + { + boolean bool = m_projectTeamManager.teamModified(); + return (this.isDirty) || (bool); + } + + public boolean isLoading() + { + return this.isLoading; + } + + public void setLoading(boolean paramBoolean) + { + this.isLoading = paramBoolean; + } + + public void disableButtons() + { + if (Display.getCurrent() != null) + { + this.m_createButton.setEnabled(false); + this.m_modifyButton.setEnabled(false); + this.m_copyButton.setEnabled(false); + this.m_deleteButton.setEnabled(false); + this.m_clearButton.setEnabled(false); + } + else + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + ProjectDefinitionView.this.m_createButton.setEnabled(false); + ProjectDefinitionView.this.m_modifyButton.setEnabled(false); + ProjectDefinitionView.this.m_copyButton.setEnabled(false); + ProjectDefinitionView.this.m_deleteButton.setEnabled(false); + ProjectDefinitionView.this.m_clearButton.setEnabled(false); + } + }); + } + } + + public void enableButtons() + { + if (Display.getCurrent() != null) + { + validateButtons(); + this.m_clearButton.setEnabled(true); + } + else + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + ProjectDefinitionView.this.validateButtons(); + ProjectDefinitionView.this.m_clearButton.setEnabled(true); + } + }); + } + } + + protected synchronized Composite createTopForm(Composite paramComposite) + { + Composite localComposite1 = getToolkit().createComposite(paramComposite, 0); + GridLayout localGridLayout = new GridLayout(3, false); + localComposite1.setLayout(localGridLayout); + Label localLabel1 = getToolkit().createLabel(localComposite1, Messages.getString("projectID.LABEL"), 64); + GridData localGridData1 = new GridData(16384, 4, false, false); + localLabel1.setLayoutData(localGridData1); + Label localLabel2 = getToolkit().createLabel(localComposite1, "*"); + GridData localGridData2 = new GridData(4, 4, false, false); + localLabel2.setLayoutData(localGridData2); + localLabel2.setForeground(localComposite1.getDisplay().getSystemColor(3)); + GridData localGridData3 = new GridData(4, 128, false, false); + this.m_idText = getToolkit().createText(localComposite1, "", 2048); + localGridData3 = new GridData(16384, 16777216, true, false); + localGridData3.widthHint = 152; + this.m_idText.setLayoutData(localGridData3); + this.m_idText.setTextLimit(128); + this.m_idText.addKeyListener(new KeyListener() + { + public void keyReleased(KeyEvent paramKeyEvent) + { + if ((ProjectDefinitionView.this.isPA) || (ProjectDefinitionView.this.isPTA) || (ProjectDefinitionView.this.isPTA())) + ProjectDefinitionView.this.validateButtons(); + } + + public void keyPressed(KeyEvent paramKeyEvent) + { + ProjectDefinitionView.this.isDirty = true; + } + }); + this.m_idText.addMouseMoveListener(new MouseMoveListener() + { + public void mouseMove(MouseEvent paramMouseEvent) + { + if (ProjectDefinitionView.this.m_idText.getCharCount() > 50) + ProjectDefinitionView.this.m_idText.setToolTipText(ProjectDefinitionView.this.m_idText.getText()); + else + ProjectDefinitionView.this.m_idText.setToolTipText(""); + } + }); + Label localLabel3 = getToolkit().createLabel(localComposite1, Messages.getString("projectName.LABEL"), 64); + localGridData3 = new GridData(4, 128, false, false, 1, 1); + localLabel3.setLayoutData(localGridData3); + Label localLabel4 = getToolkit().createLabel(localComposite1, "*"); + GridData localGridData4 = new GridData(4, 4, false, false); + localLabel4.setLayoutData(localGridData4); + localLabel4.setForeground(localComposite1.getDisplay().getSystemColor(3)); + this.m_nameText = getToolkit().createText(localComposite1, "", 2048); + getToolkit().adapt(this.m_nameText, true, true); + localGridData3 = new GridData(16384, 16777216, true, false); + localGridData3.widthHint = 160; + this.m_nameText.setLayoutData(localGridData3); + this.m_nameText.addKeyListener(new KeyListener() + { + public void keyReleased(KeyEvent paramKeyEvent) + { + if ((ProjectDefinitionView.this.isPA) || (ProjectDefinitionView.this.isPTA) || (ProjectDefinitionView.this.isPTA())) + ProjectDefinitionView.this.validateButtons(); + } + + public void keyPressed(KeyEvent paramKeyEvent) + { + ProjectDefinitionView.this.isDirty = true; + } + }); + this.m_nameText.addMouseMoveListener(new MouseMoveListener() + { + public void mouseMove(MouseEvent paramMouseEvent) + { + if (ProjectDefinitionView.this.m_nameText.getCharCount() > 50) + ProjectDefinitionView.this.m_nameText.setToolTipText(ProjectDefinitionView.this.m_idText.getText()); + else + ProjectDefinitionView.this.m_nameText.setToolTipText(""); + } + }); + Label localLabel5 = getToolkit().createLabel(localComposite1, Messages.getString("projectDesc.LABEL"), 64); + localGridData3 = new GridData(4, 128, false, false, 2, 1); + localLabel5.setLayoutData(localGridData3); + this.m_descriptionText = getToolkit().createText(localComposite1, "", 2626); + localGridData3 = new GridData(16384, 16777216, true, false); + localGridData3.widthHint = 250; + localGridData3.heightHint = 50; + this.m_descriptionText.setLayoutData(localGridData3); + this.m_descriptionText.setTextLimit(256); + this.m_descriptionText.addKeyListener(new KeyListener() + { + public void keyReleased(KeyEvent paramKeyEvent) + { + if ((ProjectDefinitionView.this.isPA) || (ProjectDefinitionView.this.isPTA) || (ProjectDefinitionView.this.isPTA())) + ProjectDefinitionView.this.validateButtons(); + } + + public void keyPressed(KeyEvent paramKeyEvent) + { + ProjectDefinitionView.this.isDirty = true; + } + }); + this.m_descriptionText.addMouseMoveListener(new MouseMoveListener() + { + public void mouseMove(MouseEvent paramMouseEvent) + { + if (ProjectDefinitionView.this.m_descriptionText.getCharCount() > 50) + ProjectDefinitionView.this.m_descriptionText.setToolTipText(ProjectDefinitionView.this.m_idText.getText()); + else + ProjectDefinitionView.this.m_descriptionText.setToolTipText(""); + } + }); + Label localLabel6 = getToolkit().createLabel(localComposite1, Messages.getString("projectCollaborationCategories.LABEL"), 64); + localGridData3 = new GridData(4, 128, false, false, 2, 1); + localLabel6.setLayoutData(localGridData3); + TCPropertyDescriptor localTCPropertyDescriptor = null; + try + { + TCComponentType localTCComponentType = getTCSession().getTypeComponent("TC_Project"); + localTCPropertyDescriptor = localTCComponentType.getPropertyDescriptor("fnd0CollaborationCategories"); + } + catch (TCException localTCException) + { + logger.error(localTCException.getLocalizedMessage(), localTCException); + } + this.m_categoryCombo = new LOVDisplayer(localComposite1, 2); + this.m_categoryCombo.initialize(this.project, localTCPropertyDescriptor, null); + getToolkit().adapt(this.m_categoryCombo, true, true); + localGridData3 = new GridData(16384, 16777216, true, false); + localGridData3.widthHint = 250; + localGridData3.heightHint = 25; + this.m_categoryCombo.setLayoutData(localGridData3); + this.m_categoryCombo.addPropertyChangeListener(new IPropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent) + { + if ((ProjectDefinitionView.this.isPA) || (ProjectDefinitionView.this.isPTA) || (ProjectDefinitionView.this.isPTA())) + { + ProjectDefinitionView.this.validateButtons(); + ProjectDefinitionView.this.isDirty = true; + } + } + }); + Label localLabel7 = getToolkit().createLabel(localComposite1, Messages.getString("projectParent.LABEL"), 1); + localGridData3 = new GridData(4, 128, false, false, 2, 1); + localLabel7.setLayoutData(localGridData3); + this.m_parentText = getToolkit().createText(localComposite1, "", 2048); + getToolkit().adapt(this.m_parentText, true, true); + localGridData3 = new GridData(16384, 16777216, true, false); + localGridData3.widthHint = 160; + this.m_parentText.setLayoutData(localGridData3); + this.m_parentText.setEnabled(false); + Label localLabel8 = getToolkit().createLabel(localComposite1, Messages.getString("projectStatus.LABEL"), 1); + localGridData3 = new GridData(4, 128, false, false, 2, 1); + localLabel8.setLayoutData(localGridData3); + Composite localComposite2 = new Composite(localComposite1, 0); + localComposite2.setLayout(new RowLayout()); + SelectionAdapter local10 = new SelectionAdapter() + { + public void widgetSelected(SelectionEvent paramSelectionEvent) + { + if ((ProjectDefinitionView.this.isPA) || (ProjectDefinitionView.this.isPTA) || (ProjectDefinitionView.this.isPTA())) + { + ProjectDefinitionView.this.validateButtons(); + ProjectDefinitionView.this.isDirty = true; + } + } + }; + this.m_activeStatusBtn = new Button(localComposite2, 16); + this.m_activeStatusBtn.setText(Messages.getString("activeStatusButton.TITLE")); + this.m_activeStatusBtn.addSelectionListener(local10); + this.m_activeStatusBtn.setSelection(true); + this.m_inactiveStatusBtn = new Button(localComposite2, 16); + this.m_inactiveStatusBtn.setText(Messages.getString("inactiveStatusButton.TITLE")); + this.m_inactiveStatusBtn.addSelectionListener(local10); + this.m_inactiveandInviisibleStatusBtn = new Button(localComposite2, 16); + this.m_inactiveandInviisibleStatusBtn.setText(Messages.getString("inactiveInvisibleStatusButton.TITLE")); + this.m_inactiveandInviisibleStatusBtn.addSelectionListener(local10); + Label localLabel9 = getToolkit().createLabel(localComposite1, "", 1); + localGridData3 = new GridData(4, 128, false, false, 2, 1); + localLabel9.setLayoutData(localGridData3); + Composite localComposite3 = new Composite(localComposite1, 0); + localComposite3.setLayout(new RowLayout()); + this.m_ProgramBtn = new Button(localComposite3, 16); + this.m_ProgramBtn.setText(Messages.getString("program.LABEL")); + this.m_ProgramBtn.addSelectionListener(local10); + this.m_ProgramBtn.setSelection(false); + this.m_ProjectBtn = new Button(localComposite3, 16); + this.m_ProjectBtn.setText(Messages.getString("project.LABEL")); + this.m_ProjectBtn.addSelectionListener(local10); + this.m_ProjectBtn.setSelection(true); + Label localLabel10 = getToolkit().createLabel(localComposite1, "", 1); + localGridData3 = new GridData(4, 128, false, false, 2, 1); + localLabel10.setLayoutData(localGridData3); + this.m_teamInheritance = new Button(localComposite1, 32); + this.m_teamInheritance.setText(Messages.getString("inheritance.LABEL")); + localGridData3 = new GridData(16384, 16777216, true, false); + this.m_teamInheritance.setLayoutData(localGridData3); + this.m_teamInheritance.setSelection(false); + SelectionAdapter local11 = new SelectionAdapter() + { + public void widgetSelected(SelectionEvent paramSelectionEvent) + { + if ((ProjectDefinitionView.this.isPA) || (ProjectDefinitionView.this.isPTA) || (ProjectDefinitionView.this.isPTA())) + { + String str1 = Messages.getString("inheritanceWarning.TITLE"); + String str2; + if (ProjectDefinitionView.this.m_teamInheritance.getSelection()) + { + str2 = Messages.getString("inheritanceTrue.WARNING"); + MessageBox.post(str2, str1, 4); + } + else + { + str2 = Messages.getString("inheritanceFalse.WARNING"); + MessageBox.post(str2, str1, 4); + } + ProjectDefinitionView.this.validateButtons(); + ProjectDefinitionView.this.isDirty = true; + } + } + }; + this.m_teamInheritance.addSelectionListener(local11); + return localComposite1; + } + + protected synchronized Composite createBottomForm(Composite paramComposite) + { + CTabFolder localCTabFolder = new CTabFolder(paramComposite, 1); + getToolkit().adapt(localCTabFolder, true, true); + CTabItem localCTabItem = new CTabItem(localCTabFolder, 0); + localCTabItem.setText(Messages.USERS); + m_projectTeamManager = new ProjectTeamTreeManager(localCTabFolder, this); + localCTabItem.setControl(m_projectTeamManager); + localCTabFolder.setSelection(localCTabItem); + return localCTabFolder; + } + + protected Composite createHeaderComposite(Composite paramComposite) + { + if ((this.m_headerComposite != null) && (!this.m_headerComposite.isDisposed())) + { + this.m_headerComposite.dispose(); + this.m_headerComposite = null; + } + this.m_headerComposite = new Composite(paramComposite, 64); + this.m_headerComposite.setLayoutData(new GridData(4, 4, true, true)); + FillLayout localFillLayout = new FillLayout(); + this.m_headerComposite.setLayout(localFillLayout); + Group localGroup = new Group(this.m_headerComposite, 64); + localGroup.setText(ProjectConstants.OPTIONS_TEXT); + return localGroup; + } + + protected void createButtons(Composite paramComposite) + { + RowLayout localRowLayout = new RowLayout(256); + localRowLayout.spacing = 5; + localRowLayout.marginLeft = 5; + localRowLayout.marginRight = 5; + paramComposite.setLayout(localRowLayout); + this.m_createButton = getToolkit().createButton(paramComposite, ProjectConstants.CREATE_TEXT, 8); + this.m_createButton.setEnabled(false); + this.m_createButton.setImage(ProjectConstants.CREATE_ICON); + this.m_createButton.setToolTipText(ProjectConstants.CREATE_TEXT); + this.m_createButton.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent paramSelectionEvent) + { + ProjectManager.getInstance().doRefresh(); + ProjectDefinitionView.this.createProjectOperation(); + ProjectDefinitionView.this.isDirty = false; + } + + public void widgetDefaultSelected(SelectionEvent paramSelectionEvent) + { + } + }); + this.m_modifyButton = getToolkit().createButton(paramComposite, ProjectConstants.MODIFY_TEXT, 8); + this.m_modifyButton.setEnabled(false); + this.m_modifyButton.setImage(ProjectConstants.MODIFY_ICON); + this.m_modifyButton.setToolTipText(ProjectConstants.MODIFY_TEXT); + this.m_modifyButton.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent paramSelectionEvent) + { + ProjectDefinitionView.this.modifyProjectOperation(); + ProjectDefinitionView.this.isDirty = false; + } + + public void widgetDefaultSelected(SelectionEvent paramSelectionEvent) + { + } + }); + this.m_copyButton = getToolkit().createButton(paramComposite, ProjectConstants.COPY_TEXT, 8); + this.m_copyButton.setEnabled(false); + this.m_copyButton.setImage(ProjectConstants.COPY_ICON); + this.m_copyButton.setToolTipText(ProjectConstants.COPY_TEXT); + this.m_copyButton.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent paramSelectionEvent) + { + ProjectDefinitionView.this.copyProjectOperation(); + ProjectManager.getInstance().doRefresh(); + ProjectDefinitionView.this.isDirty = false; + } + + public void widgetDefaultSelected(SelectionEvent paramSelectionEvent) + { + } + }); + this.m_deleteButton = getToolkit().createButton(paramComposite, ProjectConstants.DELETE_TEXT, 8); + this.m_deleteButton.setEnabled(false); + this.m_deleteButton.setImage(ProjectConstants.DELETE_ICON); + this.m_deleteButton.setToolTipText(ProjectConstants.DELETE_TEXT); + this.m_deleteButton.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent paramSelectionEvent) + { + ProjectDefinitionView.this.deleteProjectOperation(); + ProjectManager.getInstance().doRefresh(); + ProjectDefinitionView.this.clearOperation(); + ProjectDefinitionView.this.isDirty = false; + } + + public void widgetDefaultSelected(SelectionEvent paramSelectionEvent) + { + } + }); + this.m_clearButton = getToolkit().createButton(paramComposite, ProjectConstants.CLEAR_BUTTON_TEXT, 8); + this.m_clearButton.setEnabled(true); + this.m_clearButton.setImage(ProjectConstants.CLEAR_BUTTON_IMAGE); + this.m_clearButton.setToolTipText(ProjectConstants.CLEAR_BUTTON_TEXT); + this.m_clearButton.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent paramSelectionEvent) + { + ProjectDefinitionView.this.isDirty = false; + ProjectDefinitionView.this.clearOperation(); + } + + public void widgetDefaultSelected(SelectionEvent paramSelectionEvent) + { + } + }); + // idָɰť +// jk_idButton = getToolkit().createButton(paramComposite, "ָID", 8); +// jk_idButton.setEnabled(true); +// jk_idButton.setToolTipText("ָID"); +// jk_idButton.addSelectionListener(new SelectionListener() { +// +// @Override +// public void widgetSelected(SelectionEvent arg0) { +// // TODO Auto-generated method stub +// try { +// String id = m_idText.getText(); +// System.out.println("==============="+id); +// if(id == null || id == ""){ +// GetNumber number = new GetNumber(); +// String projectID = number.getNewCode("project_id","P","00000"); +// m_idText.setText(projectID); +// }else{ +// MessageBox.post("ĿIDѱָ","ʾ",MessageBox.ERROR); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// } +// +// @Override +// public void widgetDefaultSelected(SelectionEvent arg0) { +// +// } +// }); + } + + private void createProjectOperation() + { + this.m_createButton.setEnabled(false); + collectData(); + TCComponentProjectType localTCComponentProjectType = null; + try + { + localTCComponentProjectType = (TCComponentProjectType)this.session.getTypeComponent("TC_Project"); + } + catch (TCException localTCException1) + { + logger.error(localTCException1.getClass().getName(), localTCException1); + } + Object[] arrayOfObject = { TCComponentProject.getDisplayName(this.session) }; + TCComponentProject localTCComponentProject = null; + if (localTCComponentProjectType != null) + try + { + localTCComponentProject = localTCComponentProjectType.find(this.projectID); + if (localTCComponentProject != null) + { + String str1 = MessageFormat.format(this.reg.getString("duplicateProject.TITLE", "Duplicate Project"), arrayOfObject); + String str2 = MessageFormat.format(this.reg.getString("duplicateProjectID.MESSAGE", "Duplicate Project ID"), arrayOfObject); + MessageBox.post(str2, str1, 1); + return; + } + } + catch (TCException localTCException2) + { + logger.error(localTCException2.getClass().getName(), localTCException2); + TCComponent[] arrayOfTCComponent = ProjectManager.getInstance().findProjectsByNameOrID(this.projectName, false); + if ((arrayOfTCComponent != null) && (arrayOfTCComponent.length > 0)) + { + String str2 = this.reg.getString("duplicateProject.TITLE", "Duplicate Project "); + String localObject = MessageFormat.format(this.reg.getString("duplicateProjectName.MESSAGE", "Duplicate Project Name"), arrayOfObject); + MessageBox.post((String)localObject, str2, 1); + return; + } + } + if (!checkTeamAdminMembership()) + return; + this.infos = getSelectedMembersHelper(); + final int i = getTeamInheritance(); + String str2 = MessageFormat.format(this.reg.getString("createProject.MESSAGE", "Creating Project"), arrayOfObject); + AbstractAIFOperation localObject = new AbstractAIFOperation(str2, false) + { + public void executeOperation() + { + try + { + com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ProjectInformation2[] arrayOfProjectInformation2 = new com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ProjectInformation2[1]; + arrayOfProjectInformation2[0] = new com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ProjectInformation2(); + arrayOfProjectInformation2[0].clientId = "PLS-RAC-SESSION"; + arrayOfProjectInformation2[0].projectId = ProjectDefinitionView.this.projectID; + arrayOfProjectInformation2[0].projectName = ProjectDefinitionView.this.projectName; + arrayOfProjectInformation2[0].projectDescription = ProjectDefinitionView.this.projectDesc; + arrayOfProjectInformation2[0].useProgramContext = ProjectDefinitionView.this.useProgramSec; + arrayOfProjectInformation2[0].active = ProjectDefinitionView.this.projectStatus; + arrayOfProjectInformation2[0].visible = ProjectDefinitionView.this.projectVisibility; + HashMap localHashMap = new HashMap(); + if (!ProjectDefinitionView.this.projectCollaborationCategories.isEmpty()) + { + String localObject1 = ProjectDefinitionView.this.projectCollaborationCategories; + int i = ((String)localObject1).indexOf(","); + ArrayList localArrayList = new ArrayList(); + while (i != -1) + { + String localObject3 = ((String)localObject1).substring(0, i); + localArrayList.add(localObject3); + localObject1 = ((String)localObject1).substring(i + 1); + i = ((String)localObject1).indexOf(","); + } + localArrayList.add(localObject1); + String[] localObject3 = new String[localArrayList.size()]; + localArrayList.toArray(localObject3); + localHashMap.put("fnd0CollaborationCategories", localObject3); + } + if (!ProjectDefinitionView.this.m_parentProject.isEmpty()) + localHashMap.put("fnd0Parent", new String[] { ProjectDefinitionView.this.m_parentProject }); + localHashMap.put("fnd0InheritTeamFromParent", new String[] { Integer.toString(i) }); + arrayOfProjectInformation2[0].propertyMap = localHashMap; + arrayOfProjectInformation2[0].teamMembers = new ProjectLevelSecurity.TeamMemberInfo[ProjectDefinitionView.this.infos.size()]; + arrayOfProjectInformation2[0].teamMembers = ((ProjectLevelSecurity.TeamMemberInfo[])ProjectDefinitionView.this.infos.toArray(arrayOfProjectInformation2[0].teamMembers)); + ProjectLevelSecurity.ProjectOpsResponse localObject1 = ProjectManager.getInstance().createProjects(arrayOfProjectInformation2); + if ((localObject1 != null) && (((ProjectLevelSecurity.ProjectOpsResponse)localObject1).serviceData != null)) + { + Object localObject2; + if (((ProjectLevelSecurity.ProjectOpsResponse)localObject1).serviceData.sizeOfPartialErrors() > 0) + { + final com.teamcenter.rac.kernel.TCExceptionPartial exception = SoaUtil.checkPartialErrorsNoThrow(((ProjectLevelSecurity.ProjectOpsResponse)localObject1).serviceData); + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + MessageBox.post(exception); + } + }); + } + if (((ProjectLevelSecurity.ProjectOpsResponse)localObject1).serviceData.sizeOfCreatedObjects() > 0) + { + localObject2 = localObject1.projectOpsOutputs[0].project; + ProjectManager.getInstance().addCreatedProjects((TCComponentProject)localObject2); + ProjectDefinitionView.this.isNewlyCreated = true; + ProjectDefinitionView.m_projectTeamManager.setProject((TCComponentProject)localObject2); + if (ProjectDefinitionView.this.m_contributer != null) + ProjectDefinitionView.this.m_contributer.projectCreated((TCComponentProject)localObject2); + } + } + } + catch (Exception localException) + { + ProjectDefinitionView.logger.error(localException.getClass(), localException); + } + } + }; + IOperationService localIOperationService = (IOperationService)OSGIUtil.getService(AifrcpPlugin.getDefault(), IOperationService.class); + localIOperationService.queueOperation((Job)localObject); + if ((this.isNewlyCreated) && (m_projectTeamManager != null)) + { + this.isDirty = false; + m_projectTeamManager.reloadProjectTeam(); + this.isNewlyCreated = false; + } + } + + private synchronized void modifyProjectOperation() + { + setLoading(true); + disableButtons(); + m_projectTeamManager.getProjectTeamMembersViewer().expandAll(); + if (!checkTeamAdminMembership()) + return; + collectData(); + this.result = null; + Object[] arrayOfObject = { TCComponentProject.getDisplayName(this.session) }; + String str = MessageFormat.format(this.reg.getString("modifyProject.MESSAGE", "Modifying Project"), arrayOfObject); + final int i = getTeamInheritance(); + AbstractAIFOperation local18 = new AbstractAIFOperation(str, false) + { + public void executeOperation() + { + ProjectDefinitionView.this.infos = ProjectDefinitionView.this.getSelectedMembersHelper(); + } + }; + local18.addOperationListener(new InterfaceAIFOperationListener() + { + public void startOperation(String paramString) + { + } + + public void endOperation() + { + AbstractAIFOperation local1 = new AbstractAIFOperation( false) + { + public void executeOperation() + { + try + { + com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ModifyProjectsInfo2[] arrayOfModifyProjectsInfo2 = new com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ModifyProjectsInfo2[1]; + arrayOfModifyProjectsInfo2[0] = new com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ModifyProjectsInfo2(); + arrayOfModifyProjectsInfo2[0].sourceProject = ProjectDefinitionView.this.project; + arrayOfModifyProjectsInfo2[0].clientId = "PLS-RAC-SESSION"; + arrayOfModifyProjectsInfo2[0].projectInfo = new com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ProjectInformation2(); + arrayOfModifyProjectsInfo2[0].projectInfo.projectId = ProjectDefinitionView.this.projectID; + arrayOfModifyProjectsInfo2[0].projectInfo.projectName = ProjectDefinitionView.this.projectName; + arrayOfModifyProjectsInfo2[0].projectInfo.projectDescription = ProjectDefinitionView.this.projectDesc; + arrayOfModifyProjectsInfo2[0].projectInfo.useProgramContext = ProjectDefinitionView.this.useProgramSec; + arrayOfModifyProjectsInfo2[0].projectInfo.active = ProjectDefinitionView.this.projectStatus; + arrayOfModifyProjectsInfo2[0].projectInfo.visible = ProjectDefinitionView.this.projectVisibility; + HashMap localHashMap = new HashMap(); + if (!ProjectDefinitionView.this.projectCollaborationCategories.isEmpty()) + { + ArrayList localArrayList = new ArrayList(); + String str = ProjectDefinitionView.this.projectCollaborationCategories; + for (int i = str.indexOf(","); i != -1; i = str.indexOf(",")) + { + String localObject = str.substring(0, i); + localArrayList.add(localObject); + str = str.substring(i + 1); + } + localArrayList.add(str); + String[] localObject = new String[localArrayList.size()]; + localArrayList.toArray(localObject); + localHashMap.put("fnd0CollaborationCategories", localObject); + } + localHashMap.put("fnd0InheritTeamFromParent", new String[] { Integer.toString(i) }); + arrayOfModifyProjectsInfo2[0].projectInfo.propertyMap = localHashMap; + arrayOfModifyProjectsInfo2[0].projectInfo.teamMembers = new ProjectLevelSecurity.TeamMemberInfo[ProjectDefinitionView.this.infos.size()]; + arrayOfModifyProjectsInfo2[0].projectInfo.teamMembers = ((ProjectLevelSecurity.TeamMemberInfo[])ProjectDefinitionView.this.infos.toArray(arrayOfModifyProjectsInfo2[0].projectInfo.teamMembers)); + ProjectDefinitionView.this.result = ProjectManager.getInstance().modifyProjects(arrayOfModifyProjectsInfo2); + } + catch (Exception localException) + { + ProjectDefinitionView.logger.error(localException.getClass().getName(), localException); + } + } + }; + local1.addOperationListener(new InterfaceAIFOperationListener() + { + public void startOperation(String paramString) + { + } + + public void endOperation() + { + try + { + String str = ProjectDefinitionView.this.project.getProperty("project_id"); + if (ProjectDefinitionView.this.result != null) + { + Object localObject; + if (ProjectDefinitionView.this.result.serviceData.sizeOfPartialErrors() > 0) + { + final com.teamcenter.rac.kernel.TCExceptionPartial exception = SoaUtil.checkPartialErrorsNoThrow(ProjectDefinitionView.this.result.serviceData); + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + MessageBox.post(exception); + } + }); + } + if ((ProjectDefinitionView.this.result.projectOpsOutputs != null) && (ProjectDefinitionView.this.result.projectOpsOutputs.length > 0)) + { + localObject = ProjectDefinitionView.this.result.projectOpsOutputs[0].project; + ProjectManager.getInstance().projectModified((TCComponentProject)localObject); + if (ProjectDefinitionView.this.m_contributer != null) + ProjectDefinitionView.this.m_contributer.projectModified((TCComponentProject)localObject, str, ProjectDefinitionView.this.projectID); + ProjectDefinitionView.this.setLoading(false); + ProjectDefinitionView.this.enableButtons(); + } + } + } + catch (Exception localException) + { + ProjectDefinitionView.logger.error(localException.getClass().getName(), localException); + } + } + }); + IOperationService localIOperationService = (IOperationService)OSGIUtil.getService(AifrcpPlugin.getDefault(), IOperationService.class); + localIOperationService.queueOperation(local1); + ProjectDefinitionView.this.isModified = true; + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + ProjectDefinitionView.this.validateButtons(); + } + }); + } + }); + IOperationService localIOperationService = (IOperationService)OSGIUtil.getService(AifrcpPlugin.getDefault(), IOperationService.class); + localIOperationService.queueOperation(local18); + } + + private boolean doesUserHaveWriteAccessToThisObject(TCComponentProject paramTCComponentProject) + { + boolean i = true; + TCSession localTCSession = getTCSession(); + TCAccessControlService localTCAccessControlService = localTCSession.getTCAccessControlService(); + try + { + boolean[] arrayOfBoolean = localTCAccessControlService.checkPrivileges(paramTCComponentProject, new String[] { "WRITE" }); + i = arrayOfBoolean[0]; + } + catch (Exception localException) + { + i = false; + logger.error(localException.getClass().getName(), localException); + } + return i; + } + + private void copyProjectOperation() + { + if (!checkTeamAdminMembership()) + return; + collectData(); + TCComponentProjectType localTCComponentProjectType = null; + try + { + localTCComponentProjectType = (TCComponentProjectType)this.session.getTypeComponent("TC_Project"); + } + catch (TCException localTCException1) + { + logger.error(localTCException1.getClass().getName(), localTCException1); + } + Object[] arrayOfObject = { TCComponentProject.getDisplayName(this.session) }; + TCComponentProject localTCComponentProject = null; + if (localTCComponentProjectType != null) + try + { + localTCComponentProject = localTCComponentProjectType.find(this.projectID); + if (localTCComponentProject != null) + { + String str1 = MessageFormat.format(this.reg.getString("duplicateProject.TITLE", "Duplicate Project"), arrayOfObject); + String str2 = MessageFormat.format(this.reg.getString("duplicateProjectID.MESSAGE", "Duplicate Project ID"), arrayOfObject); + MessageBox.post(str2, str1, 1); + return; + } + } + catch (TCException localTCException2) + { + logger.error(localTCException2.getClass().getName(), localTCException2); + TCComponent[] arrayOfTCComponent = ProjectManager.getInstance().findProjectsByNameOrID(this.projectName, false); + if ((arrayOfTCComponent != null) && (arrayOfTCComponent.length > 0)) + { + String str2 = this.reg.getString("duplicateProject.TITLE", "Duplicate Project "); + String localObject = MessageFormat.format(this.reg.getString("duplicateProjectName.MESSAGE", "Duplicate Project Name"), arrayOfObject); + MessageBox.post((String)localObject, str2, 1); + return; + } + } + this.infos = getSelectedMembersHelper(); + final int i = getTeamInheritance(); + final String str2 = MessageFormat.format(this.reg.getString("copyProject.MESSAGE", "Copying Project"), arrayOfObject); + Job localObject = new Job(str2) + { + protected IStatus run(IProgressMonitor paramIProgressMonitor) + { + paramIProgressMonitor.beginTask(str2, -1); + try + { + if (ProjectDefinitionView.this.project != null) + { + com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ProjectInformation2 localProjectInformation2 = new com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.ProjectInformation2(); + localProjectInformation2.projectId = ProjectDefinitionView.this.projectID; + localProjectInformation2.projectName = ProjectDefinitionView.this.projectName; + localProjectInformation2.projectDescription = ProjectDefinitionView.this.projectDesc; + localProjectInformation2.projectDescription = ProjectDefinitionView.this.projectDesc; + localProjectInformation2.active = ProjectDefinitionView.this.projectStatus; + localProjectInformation2.visible = ProjectDefinitionView.this.projectVisibility; + localProjectInformation2.useProgramContext = ProjectDefinitionView.this.useProgramSec; + HashMap localHashMap = new HashMap(); + if (!ProjectDefinitionView.this.projectCollaborationCategories.isEmpty()) + { + String localObject1 = ProjectDefinitionView.this.projectCollaborationCategories; + int i = ((String)localObject1).indexOf(","); + List localObject2 = new ArrayList(); + while (i != -1) + { + String localObject3 = ((String)localObject1).substring(0, i); + ((List)localObject2).add(localObject3); + localObject1 = ((String)localObject1).substring(i + 1); + i = ((String)localObject1).indexOf(","); + } + ((List)localObject2).add(localObject1); + String[] localObject3 = new String[((List)localObject2).size()]; + ((List)localObject2).toArray(localObject3); + localHashMap.put("fnd0CollaborationCategories", localObject3); + } + localHashMap.put("fnd0InheritTeamFromParent", new String[] { Integer.toString(i) }); + localProjectInformation2.propertyMap = localHashMap; + localProjectInformation2.teamMembers = new ProjectLevelSecurity.TeamMemberInfo[ProjectDefinitionView.this.infos.size()]; + localProjectInformation2.teamMembers = ((ProjectLevelSecurity.TeamMemberInfo[])ProjectDefinitionView.this.infos.toArray(localProjectInformation2.teamMembers)); + com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.CopyProjectsInfo2 localObject1[] = new com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.CopyProjectsInfo2[1]; + localObject1[0] = new com.teamcenter.services.rac.core._2017_05.ProjectLevelSecurity.CopyProjectsInfo2(); + localObject1[0].projectInfo = localProjectInformation2; + localObject1[0].sourceProject = ProjectDefinitionView.this.project; + localObject1[0].clientId = localProjectInformation2.projectId; + ProjectLevelSecurityService localProjectLevelSecurityService = ProjectLevelSecurityService.getService(ProjectDefinitionView.this.session); + Object localObject2 = localProjectLevelSecurityService.copyProjects2(localObject1); + if (((ProjectLevelSecurity.ProjectOpsResponse)localObject2).serviceData.sizeOfPartialErrors() > 0) + { + final com.teamcenter.rac.kernel.TCExceptionPartial exception = SoaUtil.checkPartialErrorsNoThrow(((ProjectLevelSecurity.ProjectOpsResponse)localObject2).serviceData); + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + MessageBox.post(exception); + } + }); + } + if (((ProjectLevelSecurity.ProjectOpsResponse)localObject2).serviceData.sizeOfCreatedObjects() > 0) + { + TCComponentProject localObject3 = (TCComponentProject)((ProjectLevelSecurity.ProjectOpsResponse)localObject2).serviceData.getCreatedObject(0); + ProjectManager.getInstance().addCreatedProjects((TCComponentProject)localObject3); + } + } + } + catch (Exception localException) + { + ProjectDefinitionView.logger.error(localException.getClass().getName(), localException); + } + finally + { + paramIProgressMonitor.done(); + } + return (IStatus)(IStatus)(IStatus)Status.OK_STATUS; + } + }; + ((Job)localObject).setPriority(10); + ((Job)localObject).setRule(getTCSession().getOperationJobRule()); + ((Job)localObject).schedule(); + ProjectManager.getInstance().projectModified(this.project); + validateButtons(); + } + + private synchronized void deleteProjectOperation() + { + Object[] arrayOfObject = { TCComponentProject.getDisplayName(this.session) }; + boolean bool = MessageDialog.openConfirm(this.m_idText.getShell(), this.reg.getString("confirmDelete.TITLE", "Confirm Delete"), MessageFormat.format(this.reg.getString("confirmDeleteProject.MESSAGE"), arrayOfObject)); + if (!bool) + return; + final String str1 = getProjectID(); + String str2 = MessageFormat.format(this.reg.getString("deleteProject.MESSAGE", "Deleting Project"), arrayOfObject); + this.session.setStatus(str2); + Display.getDefault().syncExec(new Runnable() + { + public void run() + { + if (ProjectDefinitionView.this.project == null) + return; + TCComponentProject localTCComponentProject = ProjectDefinitionView.this.session.getCurrentProject(); + try + { + if (Debug.isOn("project")) + Debug.println("deleteProjectOperation: deleting... " + str1); + if ((localTCComponentProject != null) && (localTCComponentProject.equals(ProjectDefinitionView.this.project))) + ProjectDefinitionView.this.session.setCurrentProject(null); + ProjectDefinitionView.this.project.delete(); + } + catch (Exception localException) + { + MessageBox.post(localException); + } + ProjectDefinitionView.this.session.setReadyStatus(); + } + }); + } + + public void sessionChanged(SessionChangedEvent paramSessionChangedEvent) + { + AbstractTCAdminApplicationViewHelper localAbstractTCAdminApplicationViewHelper = ProjectManager.getApp(); + try + { + localAbstractTCAdminApplicationViewHelper.initializeApplicationPriviledge(); + } + catch (Exception localException) + { + logger.error(localException.getClass().getName(), localException); + } + this.isPA = localAbstractTCAdminApplicationViewHelper.isPAPrivileged(); + if (localAbstractTCAdminApplicationViewHelper.isPTAPrivileged()) + { + boolean bool = isTeamDefined(); + if ((bool) && (this.project != null) && (m_projectTeamManager.getRoot() != null) && (m_projectTeamManager.getRoot().getObject() != null)) + { + ProjectTeamStatus localProjectTeamStatus = (ProjectTeamStatus)m_projectTeamManager.getRoot().getObject(); + this.isPTA = localProjectTeamStatus.doesTheObjectExistInPTA(getTCSession().getUser()); + } + } + else + { + this.isPTA = localAbstractTCAdminApplicationViewHelper.isPTAPrivileged(); + } + } + + protected synchronized void processSetInput(IWorkbenchPart paramIWorkbenchPart, List paramList) + { + Object localObject1 = paramList.isEmpty() ? null : paramList.get(0); + if (localObject1 == null) + return; + if ((localObject1 instanceof ProjectRootNode)) + clearOperation(); + m_projectTeamManager.clearProjectTeamSearch(true); + TCComponentProject localTCComponentProject = (TCComponentProject)AdapterUtil.getAdapter(localObject1, TCComponentProject.class, true); + int i = (localTCComponentProject != null) && (this.project != null) && (this.project.getUid().equals(localTCComponentProject.getUid())) ? 1 : 0; + int j = (i != 0) && (!this.isModified) ? 0 : 1; + setInputObject(paramIWorkbenchPart, localTCComponentProject); + if ((localTCComponentProject == null) && (i == 0)) + { + this.project = localTCComponentProject; + if (!isDirtyStill()) + clearOperation(); + else + validateButtons(); + return; + } + if ((localTCComponentProject != null) && (j != 0)) + { + setLoading(true); + disableButtons(); + this.project = localTCComponentProject; + String[] arrayOfString1 = new String[11]; + arrayOfString1[0] = "project_id"; + arrayOfString1[1] = "project_name"; + arrayOfString1[2] = "project_desc"; + arrayOfString1[3] = "is_active"; + arrayOfString1[4] = "use_program_security"; + arrayOfString1[5] = "is_visible"; + arrayOfString1[6] = "owning_user"; + arrayOfString1[7] = "object_string"; + arrayOfString1[8] = "fnd0CollaborationCategories"; + arrayOfString1[9] = "fnd0Parent"; + arrayOfString1[10] = "fnd0InheritTeamFromParent"; + TCProperty[] arrayOfTCProperty = null; + try + { + arrayOfTCProperty = localTCComponentProject.getTCProperties(arrayOfString1); + } + catch (TCException localTCException1) + { + logger.error(localTCException1.getClass().getName(), localTCException1); + } + try + { + this.projectID = arrayOfTCProperty[0].getStringValue(); + this.projectName = arrayOfTCProperty[1].getStringValue(); + this.projectDesc = arrayOfTCProperty[2].getStringValue(); + this.projectStatus = arrayOfTCProperty[3].getLogicalValue(); + this.projectVisibility = arrayOfTCProperty[5].getLogicalValue(); + this.useProgramSec = arrayOfTCProperty[4].getLogicalValue(); + boolean bool = (!this.projectStatus) && (!this.projectVisibility); + this.m_idText.setText(this.projectID); + this.m_nameText.setText(this.projectName); + this.m_descriptionText.setText(this.projectDesc); + this.projectCollaborationCategories = Utilities.getStringForArray(arrayOfTCProperty[8].getStringArrayValue(), ","); + this.m_categoryCombo.setSelectedValue(arrayOfTCProperty[8]); + if (this.m_parentText != null) + this.m_parentText.setText(arrayOfTCProperty[9].getDisplayValue()); + this.m_activeStatusBtn.setSelection(this.projectStatus); + this.m_inactiveStatusBtn.setSelection((!this.projectStatus) && (!bool)); + if (this.useProgramSec) + { + this.m_ProgramBtn.setSelection(true); + this.m_ProjectBtn.setSelection(false); + this.m_ProgramBtn.setEnabled(true); + this.m_teamInheritance.setEnabled(false); + } + else + { + this.m_ProgramBtn.setSelection(false); + this.m_ProjectBtn.setSelection(true); + if ((this.m_parentText != null) && (!this.m_parentText.getText().isEmpty())) + { + this.m_ProgramBtn.setEnabled(false); + this.m_teamInheritance.setEnabled(true); + m_projectTeamManager.setButtonStatus(false, false); + } + else + { + this.m_ProgramBtn.setEnabled(true); + this.m_teamInheritance.setEnabled(false); + } + } + this.m_inactiveandInviisibleStatusBtn.setSelection(bool); + m_projectTeamManager.setProject(this.project); + if ((this.useProgramSec) || (arrayOfTCProperty[9].getReferenceValue() == null)) + m_projectTeamManager.resetOrgTree(); + if (arrayOfTCProperty[9].getReferenceValue() != null) + { + TCComponentProject localObject2 = (TCComponentProject)arrayOfTCProperty[9].getReferenceValue(); + ProgramTreeFilter localObject3 = new ProgramTreeFilter((TCComponentProject)localObject2, 3); + m_projectTeamManager.getAvailableTreeViewer().addFilter((ProgramTreeFilter)localObject3); + } + this.teamInheritanceValue = arrayOfTCProperty[10].getIntValue(); + this.m_teamInheritance.setSelection(this.teamInheritanceValue == 1); + } + catch (TCException localTCException2) + { + logger.error(localTCException2.getClass().getName(), localTCException2); + } + this.projectTeamMembers = null; + String[] arrayOfString2 = { TCComponentProject.getDisplayName(ProjectManager.getInstance().getTCSession()) }; + Object localObject2 = ProjectConstants.projectReg.getStringWithSubstitution("loadingProjects.MESSAGE", arrayOfString2); + Object localObject3 = new AbstractAIFOperation((String)localObject2, false) + { + public void executeOperation() + { + try + { + ProjectLevelSecurity.ProjectClientId[] arrayOfProjectClientId = new ProjectLevelSecurity.ProjectClientId[1]; + arrayOfProjectClientId[0] = new ProjectLevelSecurity.ProjectClientId(); + arrayOfProjectClientId[0].clientId = "PLS-RAC-SESSION"; + arrayOfProjectClientId[0].tcProject = ProjectDefinitionView.this.project; + ProjectLevelSecurity.ProjectTeamsResponse localProjectTeamsResponse = ProjectManager.getInstance().getProjectTeamMembers(arrayOfProjectClientId); + ProjectDefinitionView.this.projectTeamMembers = localProjectTeamsResponse.projectTeams; + } + catch (Exception localException) + { + ProjectDefinitionView.logger.error(localException.getClass().getName(), localException); + } + } + }; + ((AbstractAIFOperation)localObject3).addOperationListener(new InterfaceAIFOperationListener() + { + public void startOperation(String paramString) + { + } + + public void endOperation() + { + ProjectDefinitionView.this.getProjectTeamJobPost(); + } + }); + IOperationService localIOperationService = (IOperationService)OSGIUtil.getService(AifrcpPlugin.getDefault(), IOperationService.class); + localIOperationService.queueOperation((Job)localObject3); + } + } + + private void getProjectTeamJobPost() + { + if (Display.getCurrent() != null) + { + m_projectTeamManager.clearProjectTeamSearch(true); + AbstractAIFOperation local24 = new AbstractAIFOperation("Loading Project Team Data", false) + { + public void executeOperation() + { + try + { + ProjectDefinitionView.m_projectTeamManager.setProject(ProjectDefinitionView.this.project); + ProjectDefinitionView.m_projectTeamManager.setProjectTeamMembers(ProjectDefinitionView.this.projectTeamMembers); + ProjectDefinitionView.m_projectTeamManager.loadProjectTeamData(); + } + catch (Exception localException) + { + ProjectDefinitionView.logger.error(localException.getClass().getName(), localException); + } + } + }; + local24.addOperationListener(new InterfaceAIFOperationListener() + { + public void startOperation(String paramString) + { + } + + public void endOperation() + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + ProjectDefinitionView.this.setLoading(false); + ProjectDefinitionView.this.enableButtons(); + ProjectDefinitionView.m_projectTeamManager.getProjectTeamViewer().refresh(); + } + }); + } + }); + IOperationService localIOperationService = (IOperationService)OSGIUtil.getService(AifrcpPlugin.getDefault(), IOperationService.class); + localIOperationService.queueOperation(local24); + } + else + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + ProjectDefinitionView.m_projectTeamManager.clearProjectTeamSearch(true); + } + }); + m_projectTeamManager.setProject(this.project); + m_projectTeamManager.setProjectTeamMembers(this.projectTeamMembers); + m_projectTeamManager.loadProjectTeamData(); + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + ProjectDefinitionView.this.setLoading(false); + ProjectDefinitionView.this.enableButtons(); + ProjectDefinitionView.m_projectTeamManager.getProjectTeamViewer().refresh(); + } + }); + } + } + + private synchronized void collectData() + { + this.projectID = this.m_idText.getText().trim(); + this.projectName = this.m_nameText.getText().trim(); + this.projectDesc = this.m_descriptionText.getText().trim(); + this.useProgramSec = this.m_ProgramBtn.getSelection(); + this.projectStatus = ((this.m_activeStatusBtn.getSelection()) && (!this.m_inactiveandInviisibleStatusBtn.getSelection())); + this.projectVisibility = (!this.m_inactiveandInviisibleStatusBtn.getSelection()); + this.projectCollaborationCategories = Utilities.getStringForArray(Utilities.getArray(this.m_categoryCombo.getSelectedValue()), ","); + this.m_parentProject = this.m_parentText.getText().trim(); + } + + public void clearOperation() + { + if (this.project != null) + { + processSetOriginalInput(this, new ArrayList()); + this.project = null; + makeContentViewBlank(this, null, true); + } + if (m_projectTeamManager != null) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + ProjectDefinitionView.m_projectTeamManager.clearProjectTeamSearch(true); + ProjectDefinitionView.m_projectTeamManager.clearSelectedMembers(); + if (ProjectDefinitionView.this.m_activeStatusBtn != null) + ProjectDefinitionView.this.m_activeStatusBtn.setSelection(true); + } + }); + m_projectTeamManager.resetOrgTree(); + } + this.projectID = ""; + this.projectName = ""; + this.projectDesc = ""; + this.useProgramSec = false; + this.projectStatus = true; + this.projectVisibility = true; + this.project = null; + if (this.m_idText != null) + this.m_idText.setText(""); + if (this.m_nameText != null) + this.m_nameText.setText(""); + if (this.m_descriptionText != null) + this.m_descriptionText.setText(""); + if (this.m_categoryCombo.getSelectedValue() != null) + this.m_categoryCombo.setSelectedValue(""); + if (this.m_parentText != null) + this.m_parentText.setText(""); + if (this.m_activeStatusBtn != null) + this.m_activeStatusBtn.setSelection(true); + if (this.m_inactiveStatusBtn != null) + this.m_inactiveStatusBtn.setSelection(false); + if (this.m_ProgramBtn != null) + { + this.m_ProgramBtn.setEnabled(true); + this.m_ProgramBtn.setSelection(false); + } + if (this.m_ProjectBtn != null) + this.m_ProjectBtn.setSelection(true); + if (this.m_inactiveandInviisibleStatusBtn != null) + this.m_inactiveandInviisibleStatusBtn.setSelection(false); + if (this.m_teamInheritance != null) + { + this.m_teamInheritance.setSelection(false); + this.m_teamInheritance.setEnabled(false); + } + if (m_projectTeamManager != null) + m_projectTeamManager.setRoot(null); + ProjectManager.getInstance().clearAll(); + validateButtons(); + } + + private boolean checkTeamAdminMembership() + { + boolean i = true; + if (this.m_teamInheritance.getSelection()) + return i; + ProjectTeamStatus localProjectTeamStatus = ProjectTeamStatus.getInstance(); + if (((localProjectTeamStatus == null) && (m_projectTeamManager.getRoot() != null)) || ((localProjectTeamStatus != null) && (localProjectTeamStatus.getProject() != this.project) && (m_projectTeamManager.getRoot().getObject() != null) && ((m_projectTeamManager.getRoot().getObject() instanceof ProjectTeamStatus)))) + localProjectTeamStatus = (ProjectTeamStatus)m_projectTeamManager.getRoot().getObject(); + TCComponentUser localTCComponentUser = this.session.getUser(); + TCComponentRole localTCComponentRole = this.session.getRole(); + TCComponentGroup localTCComponentGroup = this.session.getGroup(); + if ((m_projectTeamManager.getRoot() != null) && (m_projectTeamManager.getRoot().getObject() != null) && (localProjectTeamStatus != null) && (localProjectTeamStatus.getProjectTeamAmins() != null) && (!localProjectTeamStatus.getProjectTeamAmins().isEmpty())) + return i; + if ((localProjectTeamStatus == null) || (localProjectTeamStatus.getProjectTeamAmins().isEmpty())) + { + Object[] arrayOfObject = { TCComponentProject.getDisplayName(this.session) }; + boolean bool = MessageDialog.openConfirm(this.m_idText.getShell(), MessageFormat.format(this.reg.getString("confirmPTA.TITLE", "Add Project Team Admin"), arrayOfObject), MessageFormat.format(this.reg.getString("confirmPTA.MESSAGE"), arrayOfObject)); + if (!bool) + i = false; + else + try + { + m_projectTeamManager.addAsAdmin(localTCComponentGroup, localTCComponentRole, localTCComponentUser); + } + catch (Exception localException) + { + logger.error(localException.getClass().getName(), localException); + } + } + return i; + } + + public boolean isValidSelectedObjectForViewPart(IWorkbenchPart paramIWorkbenchPart, Object paramObject) + { + return (AdapterUtil.getAdapter(paramObject, ProjectRootNode.class) != null) || (AdapterUtil.getAdapter(paramObject, TCComponentProject.class) != null); + } + + protected void makeViewBlank(IWorkbenchPart paramIWorkbenchPart, List paramList, boolean paramBoolean) + { + super.makeViewBlank(paramIWorkbenchPart, paramList, paramBoolean); + validateButtons(); + } + + public String getProjectID() + { + return this.m_idText.getText(); + } + + public String getProjectName() + { + return this.m_nameText.getText(); + } + + public String getProjectDesc() + { + return this.m_descriptionText.getText(); + } + + public String getProjectCollaborationCategories() + { + String str = ""; + str = Utilities.getStringForArray(Utilities.getArray(this.m_categoryCombo.getSelectedValue()), ","); + return str; + } + + public boolean getProjectStatus() + { + return this.m_activeStatusBtn.getSelection(); + } + + public boolean getProgramVisibility() + { + return !this.m_inactiveandInviisibleStatusBtn.getSelection(); + } + + public synchronized boolean getProgramSecurity() + { + return !this.m_ProjectBtn.getSelection(); + } + + public String getParentProject() + { + return this.m_parentText.getText(); + } + + private boolean isTeamDefined() + { + return (m_projectTeamManager != null) && (m_projectTeamManager.getRoot() != null); + } + + public synchronized void validateButtons() + { + if (isLoading()) + return; + boolean bool1 = isTeamDefined(); + if ((bool1) && (this.project != null) && (m_projectTeamManager.getRoot() != null) && (m_projectTeamManager.getRoot().getObject() != null)) + { + ProjectTeamStatus localObject = (ProjectTeamStatus)m_projectTeamManager.getRoot().getObject(); + String str1 = getTCSession().getUser().toString(); + this.isPTA = ((ProjectTeamStatus)localObject).getProjectTeamAmins().contains(str1); + } + Object localObject = getProjectName(); + String str1 = getProjectID(); + String str2 = getProjectDesc(); + String str3 = getProjectCollaborationCategories(); + boolean bool2 = getProgramVisibility() ^ this.projectVisibility; + boolean bool3 = false; + if (this.m_ProjectBtn != null) + bool3 = getProgramSecurity() ^ this.useProgramSec; + int i = 0; + if (this.m_teamInheritance != null) + i = getTeamInheritance() != this.teamInheritanceValue ? 1 : 0; + localObject = localObject != null ? ((String)localObject).trim() : null; + str1 = str1 != null ? str1.trim() : null; + str2 = str2 != null ? str2.trim() : null; + int j = 0; + if ((str1 != null) && (this.projectID != null) && (!str1.equals(this.projectID))) + j = 1; + int k = 0; + if ((localObject != null) && (this.projectName != null) && (!((String)localObject).equals(this.projectName))) + k = 1; + int m = 0; + if ((str2 != null) && (this.projectDesc != null) && (!str2.equals(this.projectDesc))) + m = 1; + int n = 0; + if (!str3.equalsIgnoreCase(this.projectCollaborationCategories)) + n = 1; + this.m_createButton.setEnabled((this.isPA) && (localObject != null) && (((String)localObject).length() > 0) && (str1 != null) && (str1.length() > 0) && ((bool1) || (i != 0)) && ((this.project == null) || ((j != 0) && (k != 0)))); + boolean bool4; + if (this.project != null) + { + bool4 = this.m_activeStatusBtn.getSelection() ^ this.projectStatus; + boolean bool5 = m_projectTeamManager.teamModified(); + if ((this.teamInheritanceValue == 1) && (i == 0)) + bool5 = false; + int i1 = (this.isPA) && (isPTA()) ? 1 : 0; + if ((isPTA()) && (!this.isPA)) + { + if (bool5) + i1 = 1; + if ((k != 0) || (j != 0) || (bool4) || (m != 0) || (bool2) || (bool3) || (n != 0)) + i1 = 0; + } + if ((isPTA()) && (!this.isPA)) + { + if (bool5) + i1 = 1; + if ((k != 0) || (j != 0) || (bool4) || (m != 0) || (bool2) || (bool3)) + i1 = 0; + } + this.m_modifyButton.setEnabled(((i1 != 0) && (bool1) && ((k != 0) || (j != 0) || (bool4) || (m != 0) || (bool5) || (bool2) || (bool3) || (n != 0))) || (i != 0)); + } + else + { + this.m_modifyButton.setEnabled(false); + } + if (this.project != null) + this.m_copyButton.setEnabled((this.isPA) && (localObject != null) && (((String)localObject).length() > 0) && (str1 != null) && (str1.length() > 0) && (bool1) && (j != 0) && (k != 0)); + else + this.m_copyButton.setEnabled(false); + if (this.m_deleteButton != null) + { + bool4 = false; + if (this.project != null) + { + TCComponentUser localTCComponentUser = getTCSession().getUser(); + try + { + String str4 = this.project.getProperty("owning_user"); + if ((str4 != null) && (localTCComponentUser != null) && (localTCComponentUser.toString().contains(str4))) + bool4 = true; + } + catch (TCException localTCException) + { + logger.error(localTCException.getClass().getName(), localTCException); + } + } + this.m_deleteButton.setEnabled((this.isPA) && (this.project != null) && (bool4)); + } + } + + private int getTeamInheritance() + { + return this.m_teamInheritance.getSelection() ? 1 : 0; + } + + public boolean isTeamInherited() + { + return this.m_teamInheritance.getSelection(); + } + + public boolean isPTA() + { + if (this.isPTA) + return true; + TCComponentUser localTCComponentUser = getTCSession().getUser(); + if (this.project != null) + try + { + String str = this.project.getProperty("owning_user"); + if ((str != null) && (localTCComponentUser != null) && (localTCComponentUser.toString().equalsIgnoreCase(str))) + return true; + } + catch (TCException localTCException) + { + logger.error(localTCException.getClass().getName(), localTCException); + try + { + if ((m_projectTeamManager.projectTeamMembers != null) && (m_projectTeamManager.projectTeamMembers[0] != null)) + for (Object localObject : m_projectTeamManager.projectTeamMembers[0].projectTeamAdmins) + if (localObject == localTCComponentUser) + return true; + } + catch (Exception localException) + { + logger.error(localException.getClass().getName(), localException); + } + } + return false; + } + + private synchronized ArrayList getSelectedMembersHelper() + { + ProjectTeamStatus localProjectTeamStatus = null; + localProjectTeamStatus = getPTM(localProjectTeamStatus); + this.infos = new ArrayList(); + TreeSet localTreeSet = getPTMChildren(); + Object localObject2; + Object localObject1; + if (localTreeSet != null) + try + { + String str1 = null; + if (this.project != null) + str1 = this.project.getProperty("project_team"); + localObject2 = localTreeSet.iterator(); + while (((Iterator)localObject2).hasNext()) + { + localObject1 = (ProjectTeamContentNode)((Iterator)localObject2).next(); + if ((((ProjectTeamContentNode)localObject1).getObject() instanceof GroupRole)) + { + GroupRole localObject3 = (GroupRole)((ProjectTeamContentNode)localObject1).getObject(); + if ((str1 != null) && (((GroupRole)localObject3).getGroup().toDisplayString().equals(str1)) && (((GroupRole)localObject3).getRole() == ProjectTeamTreeManager.getProjectAdminRole())) + continue; + TreeSet localObject4 = ((ProjectTeamContentNode)localObject1).data.m_children; + if (localObject4 == null) + continue; + Iterator localIterator = ((TreeSet)localObject4).iterator(); + while (localIterator.hasNext()) + { + ProjectTeamContentNode localProjectTeamContentNode = (ProjectTeamContentNode)localIterator.next(); + IC_UserProxy localIC_UserProxy = null; + String str2 = localProjectTeamContentNode.toString(); + if ((localProjectTeamContentNode.getObject() instanceof IC_UserProxy)) + { + localIC_UserProxy = (IC_UserProxy)localProjectTeamContentNode.getObject(); + } + else if ((localProjectTeamContentNode.getObject() instanceof ProjectTeamContentNode)) + { + ProjectTeamContentNode localObject5 = (ProjectTeamContentNode)localProjectTeamContentNode.getObject(); + if (localObject5 != null) + localIC_UserProxy = (IC_UserProxy)((ProjectTeamContentNode)localObject5).getObject(); + } + if (localIC_UserProxy != null) + str2 = localIC_UserProxy.toString(); + Object localObject5 = ProjectManager.getInstance().getGroupMember(((GroupRole)localObject3).getGroup(), ((GroupRole)localObject3).getRole(), str2); + if (localObject5 == null) + continue; + ProjectLevelSecurity.TeamMemberInfo localTeamMemberInfo = new ProjectLevelSecurity.TeamMemberInfo(); + localTeamMemberInfo.teamMember = ((TCComponent)localObject5); + localTeamMemberInfo.teamMemberType = ProjectConstants.UNPRIVILEGED; + this.infos.add(localTeamMemberInfo); + } + } + else if ((((ProjectTeamContentNode)localObject1).getObject() instanceof TCComponentRole)) + { + getProjectTeamForModifyOrCreate(localProjectTeamStatus, this.infos, (ProjectTeamContentNode)localObject1); + } + else + { + ProjectLevelSecurity.TeamMemberInfo localObject3 = new ProjectLevelSecurity.TeamMemberInfo(); + ((ProjectLevelSecurity.TeamMemberInfo)localObject3).teamMember = ((TCComponent)((ProjectTeamContentNode)localObject1).getObject()); + if (((ProjectTeamContentNode)localObject1).getPrivilege() == -1) + ((ProjectLevelSecurity.TeamMemberInfo)localObject3).teamMemberType = ProjectConstants.UNPRIVILEGED; + else + ((ProjectLevelSecurity.TeamMemberInfo)localObject3).teamMemberType = ((ProjectTeamContentNode)localObject1).getPrivilege(); + this.infos.add(localObject3); + } + } + } + catch (TCException localTCException) + { + logger.error(localTCException.getClass().getName(), localTCException); + } + if (localProjectTeamStatus != null) + { + ArrayList localArrayList = localProjectTeamStatus.getPrivilegedMembers(); + if (!localArrayList.isEmpty()) + { + localObject2 = localArrayList.iterator(); + while (((Iterator)localObject2).hasNext()) + { + localObject1 = (TCComponent)((Iterator)localObject2).next(); + ProjectLevelSecurity.TeamMemberInfo localObject3 = new ProjectLevelSecurity.TeamMemberInfo(); + ((ProjectLevelSecurity.TeamMemberInfo)localObject3).teamMember = ((TCComponent)localObject1); + ((ProjectLevelSecurity.TeamMemberInfo)localObject3).teamMemberType = ProjectConstants.PRIVILEGED; + this.infos.add(localObject3); + } + } + localObject1 = localProjectTeamStatus.getProjectTeamAmins(); + if (!((ArrayList)localObject1).isEmpty()) + { + Iterator localObject3 = ((ArrayList)localObject1).iterator(); + while (((Iterator)localObject3).hasNext()) + { + localObject2 = (TCComponent)((Iterator)localObject3).next(); + ProjectLevelSecurity.TeamMemberInfo localObject4 = new ProjectLevelSecurity.TeamMemberInfo(); + ((ProjectLevelSecurity.TeamMemberInfo)localObject4).teamMember = ((TCComponent)localObject2); + ((ProjectLevelSecurity.TeamMemberInfo)localObject4).teamMemberType = ProjectConstants.TEAMADMIN; + this.infos.add(localObject4); + } + } + } + this.infos.trimToSize(); + return (ArrayList)(ArrayList)(ArrayList)(ArrayList)(ArrayList)this.infos; + } + + private ProjectTeamStatus getPTM(ProjectTeamStatus paramProjectTeamStatus) + { + if ((m_projectTeamManager.getRoot() != null) && (m_projectTeamManager.getRoot().getObject() != null) && ((m_projectTeamManager.getRoot().getObject() instanceof ProjectTeamStatus))) + paramProjectTeamStatus = (ProjectTeamStatus)m_projectTeamManager.getRoot().getObject(); + return paramProjectTeamStatus; + } + + private TreeSet getPTMChildren() + { + TreeSet localTreeSet; + if ((m_projectTeamManager.getRoot() != null) && (m_projectTeamManager.getRoot().data != null) && (m_projectTeamManager.getRoot().data.m_children != null)) + localTreeSet = m_projectTeamManager.getRoot().data.m_children; + else + localTreeSet = null; + return localTreeSet; + } + + public Text getIdText() + { + return this.m_idText; + } + + public Text getNameText() + { + return this.m_nameText; + } + + public Text getDescriptionText() + { + return this.m_descriptionText; + } + + public Button getActiveStatusBtn() + { + return this.m_activeStatusBtn; + } + + public ProjectTeamTreeManager getProjectTeamManager() + { + return m_projectTeamManager; + } + + private void getProjectTeamForModifyOrCreate(ProjectTeamStatus paramProjectTeamStatus, ArrayList paramArrayList, ProjectTeamContentNode paramProjectTeamContentNode) + { + if ((paramProjectTeamContentNode != null) && ((paramProjectTeamContentNode.getObject() instanceof TCComponentRole))) + { + TreeSet localTreeSet = paramProjectTeamContentNode.data.m_children; + Iterator localIterator = localTreeSet.iterator(); + while (localIterator.hasNext()) + { + ProjectTeamContentNode localProjectTeamContentNode = (ProjectTeamContentNode)localIterator.next(); + TCComponentUser localTCComponentUser = (TCComponentUser)localProjectTeamContentNode.getObject(); + com.teamcenter.rac.kernel.TCComponentGroupMember arrayOfTCComponentGroupMember[] = null; + try + { + arrayOfTCComponentGroupMember = localTCComponentUser.getGroupMembers(); + } + catch (TCException localTCException) + { + logger.error(localTCException.getClass().getName(), localTCException); + } + if (arrayOfTCComponentGroupMember == null) + continue; + com.teamcenter.rac.kernel.TCComponentGroupMember localTCComponentGroupMember = arrayOfTCComponentGroupMember[0]; + if (localTCComponentGroupMember == null) + continue; + ProjectLevelSecurity.TeamMemberInfo localTeamMemberInfo = new ProjectLevelSecurity.TeamMemberInfo(); + localTeamMemberInfo.teamMember = localTCComponentGroupMember; + localTeamMemberInfo.teamMemberType = ProjectConstants.UNPRIVILEGED; + paramArrayList.add(localTeamMemberInfo); + } + } + } + + public Button getCreateButton() + { + return this.m_createButton; + } + + public TCComponentProject getProject() + { + return this.project; + } + + private void loadPostActionExtension() + { + IExtensionPoint localIExtensionPoint = Platform.getExtensionRegistry().getExtensionPoint("com.teamcenter.rac.project.ProjectUIPostActions"); + if (localIExtensionPoint != null) + { + IExtension[] arrayOfIExtension = localIExtensionPoint.getExtensions(); + if ((arrayOfIExtension != null) && (arrayOfIExtension.length > 0)) + { + IConfigurationElement[] arrayOfIConfigurationElement = arrayOfIExtension[0].getConfigurationElements(); + if (arrayOfIConfigurationElement != null) + try + { + this.m_contributer = ((ProjectUIPostActions)arrayOfIConfigurationElement[0].createExecutableExtension("class")); + } + catch (CoreException localCoreException) + { + Logger.getLogger(ProjectDefinitionView.class).error(localCoreException.getLocalizedMessage(), localCoreException); + } + } + } + } + + protected void postCreateContent() + { + pDefView = this; + } + + public static ProjectDefinitionView getProjectDefViewInstance() + { + return pDefView; + } + + public void setParentProgram(String paramString) + { + this.m_parentText.setText(paramString); + } + + public void setProjectButton() + { + this.m_ProjectBtn.setSelection(true); + this.m_ProgramBtn.setSelection(false); + this.m_ProgramBtn.setEnabled(false); + this.m_teamInheritance.setEnabled(true); + } + + private class LoadTeamInfoTask + implements Runnable + { + private ProjectTeamStatus ptm; + private TreeSet children; + + private LoadTeamInfoTask() + { + } + + public ProjectTeamStatus getPtm() + { + return this.ptm; + } + + public void setPtm(ProjectTeamStatus paramProjectTeamStatus) + { + this.ptm = paramProjectTeamStatus; + } + + public TreeSet getChildren() + { + return this.children; + } + + public void setChildren(TreeSet paramTreeSet) + { + this.children = paramTreeSet; + } + + public void run() + { + ProjectDefinitionView.this.getPTM(this.ptm); + ProjectDefinitionView.this.getPTMChildren(); + } + } +} \ No newline at end of file diff --git a/src/com/teamcenter/rac/schedule/WFDelete1Action.java b/src/com/teamcenter/rac/schedule/WFDelete1Action.java new file mode 100644 index 0000000..61ed901 --- /dev/null +++ b/src/com/teamcenter/rac/schedule/WFDelete1Action.java @@ -0,0 +1,88 @@ +/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. + +package com.teamcenter.rac.schedule; + +import com.teamcenter.rac.aif.*; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +public class WFDelete1Action extends AbstractAIFAction +{ + + public WFDelete1Action(AbstractAIFUIApplication abstractaifuiapplication, String s) + { + super(abstractaifuiapplication, s); + System.out.println("-----------WFDelete1Action------------"); + } + + public void run() + { + System.out.println("---------------WFDelete1Action run------------------------"); + InterfaceAIFComponent components[] = this.application.getTargetComponents(); + for(int i = 0; i < components.length; i ++) + { + TCComponent tmpScheduleTask = (TCComponent)components[i]; + System.out.println("type:"+tmpScheduleTask.getType()); + if(tmpScheduleTask instanceof TCComponentScheduleTask) + { + String ismb=""; + try { + ismb = tmpScheduleTask.getTCProperty("wf2_initaltask").getStringValue(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("ismb="+ismb); + if("1".equals(ismb)){ + System.out.println("ģʱ,ɾ"); + MessageBox.post("ʱɾ!!!","޷ɾ",MessageBox.ERROR); + return; + }else{ + System.out.println("ģʱ"); + } + + } + + } + + + String s; + s = getCommandKey(); + if(s == null) + return; + try + { + AbstractAIFCommand abstractaifcommand = null; + if(actionName.equals("deleteAction")) + abstractaifcommand = (AbstractAIFCommand)registry.newInstanceFor(s, new Object[] { + application.getSession() + }); + if(abstractaifcommand != null) + abstractaifcommand.executeModal(); + } + catch(Exception exception) + { + MessageBox messagebox = new MessageBox(parent, exception); + messagebox.setModal(true); + messagebox.setVisible(true); + } + return; + } +} + + +/* + DECOMPILATION REPORT + + Decompiled from: D:\Teamcenter_4Sh\OTW11\rac\plugins\com.teamcenter.rac.schedule_11000.2.0.jar + Total time: 1085 ms + Jad reported messages/errors: +Couldn't resolve all exception handlers in method run + Exit status: 0 + Caught exceptions: +*/ \ No newline at end of file diff --git a/src/com/teamcenter/rac/schedule/common/util/ScheduleConfirmDialog.java b/src/com/teamcenter/rac/schedule/common/util/ScheduleConfirmDialog.java new file mode 100644 index 0000000..9524cc2 --- /dev/null +++ b/src/com/teamcenter/rac/schedule/common/util/ScheduleConfirmDialog.java @@ -0,0 +1,170 @@ +/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. + +package com.teamcenter.rac.schedule.common.util; +//ʱǷӳ +import com.teamcenter.rac.common.TCTypeRenderer; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.util.*; +import java.awt.Container; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; + +public class ScheduleConfirmDialog extends JDialog +{ + + public ScheduleConfirmDialog(JFrame jframe, TCComponent tccomponent, String s, String s1, String s2) + { + super(jframe, true); + answer = -1; + cookieName = s2; + registry = Registry.getRegistry(this); + setTitle(s); + JPanel jpanel = new JPanel(new VerticalLayout(5, 5, 5, 5, 5)); + MLabel mlabel = new MLabel(s1, 0); + jpanel.add("top", mlabel); + JScrollPane jscrollpane = new JScrollPane(); + JPanel jpanel1 = new JPanel(new VerticalLayout(5, 10, 10, 5, 5)); + JLabel jlabel = new JLabel(tccomponent.toString(), TCTypeRenderer.getIcon(tccomponent, false), 2); + jpanel1.add("top", jlabel); + jscrollpane.getViewport().add(jpanel1); + jpanel.add("unbound", jscrollpane); + dontShowCheckBox = new JCheckBox(registry.getString("dontShowAgain.MESSAGE")); + Font font = dontShowCheckBox.getFont(); + dontShowCheckBox.setFont(new Font(font.getName(), 1, font.getSize() - 2)); + if(cookieName.equals("")) + dontShowCheckBox.setVisible(false); + JPanel jpanel2 = new JPanel(new ButtonLayout()); + yes = new JButton(registry.getString("yes")); + String s3 = registry.getString("yes.mnemonic", null); + if(s3 != null) + yes.setMnemonic(s3.charAt(0)); + yes.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent actionevent) + { + answer = 2; + setCookie(answer); + setVisible(false); + dispose(); + } + + final ScheduleConfirmDialog this$0; + + + { + this$0 = ScheduleConfirmDialog.this; + } + } +); + jpanel2.add(yes); + JButton jbutton = new JButton(registry.getString("no")); + s3 = registry.getString("no.mnemonic", null); + if(s3 != null) + jbutton.setMnemonic(s3.charAt(0)); + jbutton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent actionevent) + { + answer = 1; + setCookie(answer); + setVisible(false); + dispose(); + } + + final ScheduleConfirmDialog this$0; + + + { + this$0 = ScheduleConfirmDialog.this; + } + } +); + jpanel2.add(jbutton); + jpanel.add("bottom", jpanel2); + jpanel.add("bottom", new Separator()); + jpanel.add("bottom.nobind.right", dontShowCheckBox); + getContentPane().add("Center", jpanel); + pack(); + setAlwaysOnTop(true); + UIUtilities.centerToScreen(this); + yes.requestFocusInWindow(); + } + + public static int post(JFrame jframe, TCComponent tccomponent, String s, String s1, String s2) + { +// ScheduleConfirmDialog scheduleconfirmdialog = new ScheduleConfirmDialog(jframe, tccomponent, s, s1, s2); +// scheduleconfirmdialog.setVisible(true); + return 1; +// return scheduleconfirmdialog.answer; + } + + public void setVisible(boolean flag) + { + if(cookieName != null && flag) + { + int i = getCookie(); + if(i == 0) + { + super.setVisible(flag); + super.setAlwaysOnTop(true); + } else + { + answer = i; + } + } else + { + super.setVisible(flag); + } + } + + private void setCookie(int i) + { + if(dontShowCheckBox.isSelected()) + { + Cookie cookie = Cookie.getCookie(cookieName, true); + try + { + cookie.setString(cookieName, i); + cookie.close(); + } + catch(Exception _ex) { } + } + } + + private int getCookie() + { + try + { + Cookie cookie = Cookie.getCookie(cookieName, true); + if(cookie.exists()) + return cookie.getNumber(cookieName); + } + catch(Exception _ex) { } + return 0; + } + + public static final int NOT_EXIST = 0; + public static final int NO = 1; + public static final int YES = 2; + private int answer; + private String cookieName; + protected Registry registry; + protected JCheckBox dontShowCheckBox; + private JButton yes; + + + +} + + +/* + DECOMPILATION REPORT + + Decompiled from: D:\WXTeamcenter\OTW11\rac\plugins\com.teamcenter.rac.schedule_11000.2.0.jar + Total time: 60 ms + Jad reported messages/errors: + Exit status: 0 + Caught exceptions: +*/ \ No newline at end of file diff --git a/src/com/teamcenter/rac/schedule/schedule_user.properties b/src/com/teamcenter/rac/schedule/schedule_user.properties new file mode 100644 index 0000000..c07abce --- /dev/null +++ b/src/com/teamcenter/rac/schedule/schedule_user.properties @@ -0,0 +1,3 @@ +#delete +#-------------------------------------------------- +deleteAction=com.teamcenter.rac.schedule.WFDelete1Action \ No newline at end of file