commit 048f982f79c4976ba4ae14cdf207e0c4b7307c58 Author: hongcj Date: Tue Jun 3 16:31:44 2025 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..d5042c1 --- /dev/null +++ b/.classpath @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.project b/.project new file mode 100644 index 0000000..fc30815 --- /dev/null +++ b/.project @@ -0,0 +1,34 @@ + + + com.connor.pro105.plm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f42de36 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..878d898 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,264 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.connor.pro105.plm;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.connor.pro105.plm.Activator +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.core.expressions;bundle-version="3.4.400", + org.eclipse.ui;bundle-version="3.8.0", + com.teamcenter.rac.aifrcp;bundle-version="11000.2.0", + com.teamcenter.rac.common;bundle-version="11000.2.0", + com.teamcenter.rac.kernel;bundle-version="11000.2.0", + com.teamcenter.rac.util;bundle-version="11000.2.0", + org.apache.log4j;bundle-version="1.2.15", + com.teamcenter.rac.ui;bundle-version="11000.2.0", + com.teamcenter.rac.ui.commands;bundle-version="11000.2.0", + com.teamcenter.rac.project;bundle-version="11000.2.0", + TcSoaProjectManagementLoose;bundle-version="11000.2.0", + TcSoaProjectManagementRac;bundle-version="11000.2.0", + TcSoaProjectManagementTypes;bundle-version="11000.2.0", + com.teamcenter.rac.schedule;bundle-version="11000.2.0", + org.eclipse.core.databinding.beans;bundle-version="1.2.200", + org.eclipse.core.databinding.observable;bundle-version="1.4.1", + org.eclipse.jface.databinding;bundle-version="1.6.0", + org.eclipse.ui.views;bundle-version="3.6.100", + com.teamcenter.rac.cme.stylesheet;bundle-version="11000.2.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ActivationPolicy: lazy +Export-Package: + com.connor.pro105.plm, + javax.sql, + javax.xml.stream, + javax.xml.stream.events, + javax.xml.stream.util, + oracle.core.lmx, + oracle.core.lvf, + oracle.jdbc, + oracle.jdbc.connector, + oracle.jdbc.driver, + oracle.jdbc.internal, + oracle.jdbc.oci, + oracle.jdbc.oracore, + oracle.jdbc.pool, + oracle.jdbc.util, + oracle.jdbc.xa, + oracle.jdbc.xa.client, + oracle.jpub.runtime, + oracle.net.TNSAddress, + oracle.net.ano, + oracle.net.aso, + oracle.net.jndi, + oracle.net.nl, + oracle.net.nl.mesg, + oracle.net.ns, + oracle.net.nt, + oracle.net.resolver, + oracle.security.o3logon, + oracle.sql, + oracle.sql.converter, + org.apache.commons.codec, + org.apache.commons.codec.binary, + org.apache.commons.codec.digest, + org.apache.commons.codec.language, + org.apache.commons.codec.language.bm, + org.apache.commons.codec.net, + org.apache.commons.logging, + org.apache.commons.logging.impl, + org.apache.poi, + org.apache.poi.common.usermodel, + org.apache.poi.ddf, + org.apache.poi.dev, + org.apache.poi.extractor, + org.apache.poi.hpsf, + org.apache.poi.hpsf.extractor, + org.apache.poi.hpsf.wellknown, + org.apache.poi.hssf, + org.apache.poi.hssf.dev, + org.apache.poi.hssf.eventmodel, + org.apache.poi.hssf.eventusermodel, + org.apache.poi.hssf.eventusermodel.dummyrecord, + org.apache.poi.hssf.extractor, + org.apache.poi.hssf.model, + org.apache.poi.hssf.record, + org.apache.poi.hssf.record.aggregates, + org.apache.poi.hssf.record.cf, + org.apache.poi.hssf.record.chart, + org.apache.poi.hssf.record.common, + org.apache.poi.hssf.record.cont, + org.apache.poi.hssf.record.crypto, + org.apache.poi.hssf.record.pivottable, + org.apache.poi.hssf.usermodel, + org.apache.poi.hssf.util, + org.apache.poi.openxml4j.exceptions, + org.apache.poi.openxml4j.opc, + org.apache.poi.openxml4j.opc.internal, + org.apache.poi.openxml4j.opc.internal.marshallers, + org.apache.poi.openxml4j.opc.internal.signature, + org.apache.poi.openxml4j.opc.internal.unmarshallers, + org.apache.poi.openxml4j.opc.signature, + org.apache.poi.openxml4j.util, + org.apache.poi.poifs.common, + org.apache.poi.poifs.crypt, + org.apache.poi.poifs.dev, + org.apache.poi.poifs.eventfilesystem, + org.apache.poi.poifs.filesystem, + org.apache.poi.poifs.nio, + org.apache.poi.poifs.property, + org.apache.poi.poifs.storage, + org.apache.poi.ss, + org.apache.poi.ss.extractor, + org.apache.poi.ss.format, + org.apache.poi.ss.formula, + org.apache.poi.ss.formula.atp, + org.apache.poi.ss.formula.constant, + org.apache.poi.ss.formula.eval, + org.apache.poi.ss.formula.eval.forked, + org.apache.poi.ss.formula.function, + org.apache.poi.ss.formula.functions, + org.apache.poi.ss.formula.ptg, + org.apache.poi.ss.formula.udf, + org.apache.poi.ss.usermodel, + org.apache.poi.ss.usermodel.charts, + org.apache.poi.ss.util, + org.apache.poi.ss.util.cellwalk, + org.apache.poi.util, + org.apache.poi.xslf, + org.apache.poi.xslf.extractor, + org.apache.poi.xslf.model, + org.apache.poi.xslf.model.geom, + org.apache.poi.xslf.usermodel, + org.apache.poi.xslf.util, + org.apache.poi.xssf.dev, + org.apache.poi.xssf.eventusermodel, + org.apache.poi.xssf.extractor, + org.apache.poi.xssf.model, + org.apache.poi.xssf.streaming, + org.apache.poi.xssf.usermodel, + org.apache.poi.xssf.usermodel.charts, + org.apache.poi.xssf.usermodel.extensions, + org.apache.poi.xssf.usermodel.helpers, + org.apache.poi.xssf.util, + org.apache.poi.xwpf.extractor, + org.apache.poi.xwpf.model, + org.apache.poi.xwpf.usermodel, + org.apache.xmlbeans, + org.apache.xmlbeans.impl.common, + org.apache.xmlbeans.impl.config, + org.apache.xmlbeans.impl.inst2xsd, + org.apache.xmlbeans.impl.inst2xsd.util, + org.apache.xmlbeans.impl.jam, + org.apache.xmlbeans.impl.jam.annotation, + org.apache.xmlbeans.impl.jam.internal, + org.apache.xmlbeans.impl.jam.internal.classrefs, + org.apache.xmlbeans.impl.jam.internal.elements, + org.apache.xmlbeans.impl.jam.internal.javadoc, + org.apache.xmlbeans.impl.jam.internal.parser, + org.apache.xmlbeans.impl.jam.internal.reflect, + org.apache.xmlbeans.impl.jam.mutable, + org.apache.xmlbeans.impl.jam.provider, + org.apache.xmlbeans.impl.jam.visitor, + org.apache.xmlbeans.impl.jam.xml, + org.apache.xmlbeans.impl.piccolo.io, + org.apache.xmlbeans.impl.piccolo.util, + org.apache.xmlbeans.impl.piccolo.xml, + org.apache.xmlbeans.impl.regex, + org.apache.xmlbeans.impl.richParser, + org.apache.xmlbeans.impl.schema, + org.apache.xmlbeans.impl.soap, + org.apache.xmlbeans.impl.store, + org.apache.xmlbeans.impl.tool, + org.apache.xmlbeans.impl.util, + org.apache.xmlbeans.impl.validator, + org.apache.xmlbeans.impl.values, + org.apache.xmlbeans.impl.xb.ltgfmt, + org.apache.xmlbeans.impl.xb.ltgfmt.impl, + org.apache.xmlbeans.impl.xb.substwsdl, + org.apache.xmlbeans.impl.xb.substwsdl.impl, + org.apache.xmlbeans.impl.xb.xmlconfig, + org.apache.xmlbeans.impl.xb.xmlconfig.impl, + org.apache.xmlbeans.impl.xb.xmlschema, + org.apache.xmlbeans.impl.xb.xmlschema.impl, + org.apache.xmlbeans.impl.xb.xsdownload, + org.apache.xmlbeans.impl.xb.xsdownload.impl, + org.apache.xmlbeans.impl.xb.xsdschema, + org.apache.xmlbeans.impl.xb.xsdschema.impl, + org.apache.xmlbeans.impl.xpathgen, + org.apache.xmlbeans.impl.xsd2inst, + org.apache.xmlbeans.soap, + org.apache.xmlbeans.xml.stream, + org.apache.xmlbeans.xml.stream.events, + org.apache.xmlbeans.xml.stream.utils, + org.dom4j, + org.dom4j.bean, + org.dom4j.datatype, + org.dom4j.dom, + org.dom4j.dtd, + org.dom4j.io, + org.dom4j.jaxb, + org.dom4j.rule, + org.dom4j.rule.pattern, + org.dom4j.swing, + org.dom4j.tree, + org.dom4j.util, + org.dom4j.xpath, + org.dom4j.xpp, + org.openxmlformats.schemas.drawingml.x2006.chart, + org.openxmlformats.schemas.drawingml.x2006.chart.impl, + org.openxmlformats.schemas.drawingml.x2006.main, + org.openxmlformats.schemas.drawingml.x2006.main.impl, + org.openxmlformats.schemas.drawingml.x2006.picture, + org.openxmlformats.schemas.drawingml.x2006.picture.impl, + org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing, + org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl, + org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing, + org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.impl, + org.openxmlformats.schemas.officeDocument.x2006.customProperties, + org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl, + org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes, + org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.impl, + org.openxmlformats.schemas.officeDocument.x2006.extendedProperties, + org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl, + org.openxmlformats.schemas.officeDocument.x2006.relationships, + org.openxmlformats.schemas.officeDocument.x2006.relationships.impl, + org.openxmlformats.schemas.presentationml.x2006.main, + org.openxmlformats.schemas.presentationml.x2006.main.impl, + org.openxmlformats.schemas.spreadsheetml.x2006.main, + org.openxmlformats.schemas.spreadsheetml.x2006.main.impl, + org.openxmlformats.schemas.wordprocessingml.x2006.main, + org.openxmlformats.schemas.wordprocessingml.x2006.main.impl, + org.w3c.dom, + repackage, + schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707, + schemaorg_apache_xmlbeans.system.sXMLCONFIG, + schemaorg_apache_xmlbeans.system.sXMLLANG, + schemaorg_apache_xmlbeans.system.sXMLSCHEMA, + schemaorg_apache_xmlbeans.system.sXMLTOOLS, + schemasMicrosoftComOfficeExcel, + schemasMicrosoftComOfficeExcel.impl, + schemasMicrosoftComOfficeOffice, + schemasMicrosoftComOfficeOffice.impl, + schemasMicrosoftComVml, + schemasMicrosoftComVml.impl +Import-Package: com.teamcenter.rac.kernel, + com.teamcenter.rac.workflow.processdesigner.plugin, + com.teamcenter.services.rac.core, + com.teamcenter.services.rac.core._2006_03, + com.teamcenter.services.rac.core._2008_06, + org.eclipse.core.databinding +Bundle-ClassPath: src/com/teamcenter/rac/schedule/common/, + poi/classes12.jar, + poi/commons-codec-1.10.jar, + poi/commons-logging-1.1.jar, + poi/dom4j-1.6.1.jar, + poi/jsr173_1.0_api.jar, + poi/jxl_1.0.0.jar, + poi/poi-3.9-20121203.jar, + poi/poi-examples-3.9-20121203.jar, + poi/poi-excelant-3.9-20121203.jar, + poi/poi-ooxml-3.9-20121203.jar, + poi/poi-ooxml-schemas-3.9-20121203.jar, + poi/poi-scratchpad-3.9-20121203.jar, + poi/xmlbeans-2.5.0.jar, + . diff --git a/bin/com/connor/pro105/plm/Activator.class b/bin/com/connor/pro105/plm/Activator.class new file mode 100644 index 0000000..412d379 Binary files /dev/null and b/bin/com/connor/pro105/plm/Activator.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordAction.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordAction.class new file mode 100644 index 0000000..9a1a99e Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordAction.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC$1.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC$1.class new file mode 100644 index 0000000..817a03c Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC$2.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC$2.class new file mode 100644 index 0000000..af13736 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC$2.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC.class new file mode 100644 index 0000000..c4791fd Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM$1.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM$1.class new file mode 100644 index 0000000..180dd40 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM$2.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM$2.class new file mode 100644 index 0000000..6921baa Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM$2.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM.class new file mode 100644 index 0000000..4cb0231 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS$1.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS$1.class new file mode 100644 index 0000000..aeb1ac6 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS$2.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS$2.class new file mode 100644 index 0000000..1b97598 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS$2.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS.class new file mode 100644 index 0000000..10cd47f Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW$1.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW$1.class new file mode 100644 index 0000000..8b7b36e Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW$2.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW$2.class new file mode 100644 index 0000000..daa304f Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW$2.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW.class new file mode 100644 index 0000000..46894fa Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordHandler.class b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordHandler.class new file mode 100644 index 0000000..3a8301f Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/AlterTechWordHandler.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordAction.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordAction.class new file mode 100644 index 0000000..7b71b56 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordAction.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordBean.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordBean.class new file mode 100644 index 0000000..3975af7 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordBean.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$1.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$1.class new file mode 100644 index 0000000..7ba27fa Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$2.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$2.class new file mode 100644 index 0000000..797c882 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$2.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$3.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$3.class new file mode 100644 index 0000000..d39c366 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$3.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$4.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$4.class new file mode 100644 index 0000000..d87df36 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$4.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$5.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$5.class new file mode 100644 index 0000000..767d013 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC$5.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC.class new file mode 100644 index 0000000..c51f833 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$1.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$1.class new file mode 100644 index 0000000..f7dcf38 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$2.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$2.class new file mode 100644 index 0000000..db1a064 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$2.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$3.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$3.class new file mode 100644 index 0000000..7db2133 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$3.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$4.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$4.class new file mode 100644 index 0000000..befce4c Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$4.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$5.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$5.class new file mode 100644 index 0000000..81a1104 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM$5.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM.class new file mode 100644 index 0000000..4ac4b35 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$1.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$1.class new file mode 100644 index 0000000..fdc7d29 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$2.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$2.class new file mode 100644 index 0000000..58e87a8 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$2.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$3.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$3.class new file mode 100644 index 0000000..9ee3ce0 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$3.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$4.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$4.class new file mode 100644 index 0000000..106b0e6 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$4.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$5.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$5.class new file mode 100644 index 0000000..1794799 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS$5.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS.class new file mode 100644 index 0000000..a838cd8 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$1.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$1.class new file mode 100644 index 0000000..31e3b92 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$2.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$2.class new file mode 100644 index 0000000..9d2a581 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$2.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$3.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$3.class new file mode 100644 index 0000000..7cd94a0 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$3.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$4.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$4.class new file mode 100644 index 0000000..4806a03 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$4.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$5.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$5.class new file mode 100644 index 0000000..1f4e465 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW$5.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW.class new file mode 100644 index 0000000..1802356 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordHandler.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordHandler.class new file mode 100644 index 0000000..1b15d54 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordHandler.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordOperation.class b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordOperation.class new file mode 100644 index 0000000..08c00d8 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/CreatTechWordOperation.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/DocumentUtil.class b/bin/com/connor/pro105/plm/creatTechWord/DocumentUtil.class new file mode 100644 index 0000000..4d18ca9 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/DocumentUtil.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwBasicComboPopup.class b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwBasicComboPopup.class new file mode 100644 index 0000000..f8435a9 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwBasicComboPopup.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwDefaultComboBoxModel.class b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwDefaultComboBoxModel.class new file mode 100644 index 0000000..b02aa23 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwDefaultComboBoxModel.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwDefaultListSelectionModel.class b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwDefaultListSelectionModel.class new file mode 100644 index 0000000..1a2b97f Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwDefaultListSelectionModel.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwJCheckBox.class b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwJCheckBox.class new file mode 100644 index 0000000..e475f07 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwJCheckBox.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwMetalComboBoxUI.class b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwMetalComboBoxUI.class new file mode 100644 index 0000000..70b7d17 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwMetalComboBoxUI.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwMouseAdapter.class b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwMouseAdapter.class new file mode 100644 index 0000000..709bcf6 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo$RwMouseAdapter.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/MultiCombo.class b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo.class new file mode 100644 index 0000000..cd34c71 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/MultiCombo.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/ProgressBar$1.class b/bin/com/connor/pro105/plm/creatTechWord/ProgressBar$1.class new file mode 100644 index 0000000..0dd387d Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/ProgressBar$1.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/ProgressBar$TaskThread.class b/bin/com/connor/pro105/plm/creatTechWord/ProgressBar$TaskThread.class new file mode 100644 index 0000000..10413bd Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/ProgressBar$TaskThread.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/ProgressBar.class b/bin/com/connor/pro105/plm/creatTechWord/ProgressBar.class new file mode 100644 index 0000000..c89cdd0 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/ProgressBar.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/ProgressBarThread.class b/bin/com/connor/pro105/plm/creatTechWord/ProgressBarThread.class new file mode 100644 index 0000000..661323c Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/ProgressBarThread.class differ diff --git a/bin/com/connor/pro105/plm/creatTechWord/Util.class b/bin/com/connor/pro105/plm/creatTechWord/Util.class new file mode 100644 index 0000000..431fc23 Binary files /dev/null and b/bin/com/connor/pro105/plm/creatTechWord/Util.class differ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..f74ea2d --- /dev/null +++ b/build.properties @@ -0,0 +1,18 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + poi/classes12.jar,\ + poi/commons-codec-1.10.jar,\ + poi/commons-logging-1.1.jar,\ + poi/dom4j-1.6.1.jar,\ + poi/jsr173_1.0_api.jar,\ + poi/jxl_1.0.0.jar,\ + poi/poi-3.9-20121203.jar,\ + poi/poi-examples-3.9-20121203.jar,\ + poi/poi-excelant-3.9-20121203.jar,\ + poi/poi-ooxml-3.9-20121203.jar,\ + poi/poi-ooxml-schemas-3.9-20121203.jar,\ + poi/poi-scratchpad-3.9-20121203.jar,\ + poi/xmlbeans-2.5.0.jar diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..41f403c --- /dev/null +++ b/plugin.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/poi/classes12.jar b/poi/classes12.jar new file mode 100644 index 0000000..9eaf0b4 Binary files /dev/null and b/poi/classes12.jar differ diff --git a/poi/commons-codec-1.10.jar b/poi/commons-codec-1.10.jar new file mode 100644 index 0000000..1d7417c Binary files /dev/null and b/poi/commons-codec-1.10.jar differ diff --git a/poi/commons-logging-1.1.jar b/poi/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/poi/commons-logging-1.1.jar differ diff --git a/poi/dom4j-1.6.1.jar b/poi/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/poi/dom4j-1.6.1.jar differ diff --git a/poi/jsr173_1.0_api.jar b/poi/jsr173_1.0_api.jar new file mode 100644 index 0000000..fef9a9c Binary files /dev/null and b/poi/jsr173_1.0_api.jar differ diff --git a/poi/ojdbc7.jar b/poi/ojdbc7.jar new file mode 100644 index 0000000..fd38a6c Binary files /dev/null and b/poi/ojdbc7.jar differ diff --git a/poi/ojdbc8-19.3.0.0.jar b/poi/ojdbc8-19.3.0.0.jar new file mode 100644 index 0000000..2ebb05e Binary files /dev/null and b/poi/ojdbc8-19.3.0.0.jar differ diff --git a/poi/poi-3.9-20121203.jar b/poi/poi-3.9-20121203.jar new file mode 100644 index 0000000..0f46288 Binary files /dev/null and b/poi/poi-3.9-20121203.jar differ diff --git a/poi/poi-ooxml-3.9-20121203.jar b/poi/poi-ooxml-3.9-20121203.jar new file mode 100644 index 0000000..8792d46 Binary files /dev/null and b/poi/poi-ooxml-3.9-20121203.jar differ diff --git a/poi/poi-ooxml-schemas-3.9-20121203.jar b/poi/poi-ooxml-schemas-3.9-20121203.jar new file mode 100644 index 0000000..eda4ef4 Binary files /dev/null and b/poi/poi-ooxml-schemas-3.9-20121203.jar differ diff --git a/poi/xmlbeans-2.5.0.jar b/poi/xmlbeans-2.5.0.jar new file mode 100644 index 0000000..c368fb2 Binary files /dev/null and b/poi/xmlbeans-2.5.0.jar differ diff --git a/src/com/connor/pro105/plm/Activator.java b/src/com/connor/pro105/plm/Activator.java new file mode 100644 index 0000000..47981b4 --- /dev/null +++ b/src/com/connor/pro105/plm/Activator.java @@ -0,0 +1,30 @@ +package com.connor.pro105.plm; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/AlterTechWordAction.java b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordAction.java new file mode 100644 index 0000000..eb84bcf --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordAction.java @@ -0,0 +1,45 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; + +public class AlterTechWordAction extends AbstractAIFAction { +private AbstractAIFApplication app; +private String commandID; + + public AlterTechWordAction( String commandID, AbstractAIFApplication app, String String) { + super(app, String); + this.commandID=commandID; + this.app=app; + } + + + @Override + public void run() { + if(commandID.equals("alterTechWordC")) { + + + AlterTechWordDialogC dialog=new AlterTechWordDialogC(app); + new Thread(dialog).start(); + }else if(commandID.equals("alterTechWordM")) { + + AlterTechWordDialogM dialog=new AlterTechWordDialogM(app); + new Thread(dialog).start(); + }else if(commandID.equals("alterTechWordW")) { + + AlterTechWordDialogW dialog=new AlterTechWordDialogW(app); + new Thread(dialog).start(); + }else if(commandID.equals("alterTechWordS")) { + + AlterTechWordDialogS dialog=new AlterTechWordDialogS(app); + new Thread(dialog).start(); + } + + } + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC.java b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC.java new file mode 100644 index 0000000..f42974d --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogC.java @@ -0,0 +1,775 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.KPropertyLOVDisplayer; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +//@SuppressWarnings({"rawtypes", "unchecked"}) +@SuppressWarnings("unchecked") +public class AlterTechWordDialogC extends AbstractAIFDialog implements ActionListener { + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private JPanel mainJpanel; + private JPanel leftJpanel; + private JPanel basicInfoJpanel; + private JPanel selectItemJpanel; + private JPanel rightJpanel; + private JPanel createInfoJpanel; +// private JTextField pathJTextField; +// private String selectType; +// private String selectSecondDoc; +// private String selectDocCategory; + private JButton okButton; + private JButton celButton; + private JButton searchButton; + private JButton selectButton; + private JCheckBox zjtsyq; + JTextField[] searchField = null; +// JTextField itemNameField=new JTextField(15); + JRadioButton[] radioButton = null; + ButtonGroup bg = new ButtonGroup(); + private JPanel bottomJpanel; + +// private String exportFile; + +// private ProgressBarThread wait; + private TCComponentItemRevision rev=null; + private TCComponentForm form=null; + private TCComponentItem itemX=null; + private TCComponentForm itemFormX=null; + private TCComponentDataset dataset=null; + public AlterTechWordDialogC(AbstractAIFApplication app) { + super(AIFUtility.getActiveDesktop()); + this.app = app; + this.session = (TCSession) app.getSession(); + rev=(TCComponentItemRevision) app.getTargetComponent(); + try { + itemX=rev.getItem(); + form=(TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + itemFormX=(TCComponentForm) itemX.getRelatedComponents("IMAN_master_form")[0]; + TCComponent[] datasets=rev.getRelatedComponents("IMAN_specification"); + if(datasets.length>0) { + dataset=(TCComponentDataset) rev.getRelatedComponents("IMAN_specification")[0]; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void run() { +// super.run();//ע򴰿ʾ + + try { + readProperty();// excelжȡϢ + } catch (Exception e) { + e.printStackTrace(); + } + + initUI(); + } + + + Map> map1 = new HashMap>(); + Map> map2 = new HashMap>(); + Map> map3 = new HashMap>(); + Map> listMap = new HashMap>(); + String[] excelPre = null; + String[] createInfo = null; + + + + + + Map> map1_2 = new HashMap<>(); + Map> map2_3 = new HashMap<>(); + List list_1 = new ArrayList<>();// һֵǷظ + List jcomboxList_1 = new ArrayList<>();// һֵǷظ + List list_2 = new ArrayList<>();// ֵǷظ + List list_3 = new ArrayList<>();// ֵǷظ + + private void readProperty() throws IOException { + excelPre=session.getPreferenceService().getStringValues("Connor_AVIC_NewDocumentBasicC"); + createInfo = session.getPreferenceService().getStringValues("Connor_AVIC_AlterDocumentCreationC"); + createLabel = new JLabel[createInfo.length]; + createText = new JTextField[createInfo.length]; + createCom = new JComboBox[createInfo.length]; + + } + + JLabel[] createLabel = null; + JTextField[] createText = null; + JComboBox[] createCom = null; + Dimension dimension = new Dimension(150, 30); + Map basicMap = new HashMap(); + Map basicPropertyMap = new HashMap(); + Map createMap = new HashMap(); + Map searchMap = new HashMap(); + DefaultComboBoxModel model1 = null; + DefaultComboBoxModel model2 = null; + DefaultComboBoxModel model3 = null; + JLabel[] basicLabel=null; + JLabel[] searchLabel=null; + JTextField[] basicText=null; + private void initUI() { + this.setTitle("ĵ޸"); + + okButton = new JButton("޸"); + okButton.addActionListener(this); + this.getRootPane().setDefaultButton(searchButton);//õǰĬѡаť + celButton = new JButton("ȡ"); + celButton.addActionListener(this); + searchButton = new JButton("ѯ"); + searchButton.addActionListener(this); + selectButton = new JButton("ѡ"); + selectButton.addActionListener(this); + + this.setLayout(new BorderLayout()); + + this.setSize(850, 550); + mainJpanel = new JPanel(new PropertyLayout()); + mainJpanel.setPreferredSize(new Dimension(950, 450)); + leftJpanel = new JPanel(new PropertyLayout()); + leftJpanel.setPreferredSize(new Dimension(500, 450)); + basicInfoJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel.setPreferredSize(new Dimension(500, 300)); + rightJpanel = new JPanel(new PropertyLayout()); + rightJpanel.setPreferredSize(new Dimension(450, 350)); + createInfoJpanel = new JPanel(new PropertyLayout()); +// createInfoJpanel.setPreferredSize(new Dimension(400, 280)); +basicInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + + basicLabel=new JLabel[excelPre.length-2]; + basicText=new JTextField[excelPre.length-2]; + int a=2; + for (int i = 1; i < excelPre.length-1; i++) { + String[] proValue = excelPre[i].split("="); + if(i>3) { + + basicLabel[i-1]=new JLabel(proValue[0]); + basicLabel[i-1].setPreferredSize(new Dimension(90,25)); + String value2= proValue[1]; + if(value2.toLowerCase().startsWith("itemrevisionmaster")) { + basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + basicInfoJpanel.add(a+".2.left.top", basicLabel[i-1]); + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + } + a++; + } + } + leftJpanel.add("1.1.left.top",basicInfoJpanel); + + int i=1; + selectItemJpanel.add(i+".1.left.top",new JLabel("ѡ ")); + i++; +// selectItemJpanel.add(i+".1.left.top",new JLabel(" ѯѡ")); +// i++; + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchC"); + searchLabel=new JLabel[values.length-1]; + + searchField=new JTextField[values.length-1]; + for (int j = 0; j < searchField.length; j++) { + searchField[j]=new JTextField(15); + searchLabel[j]=new JLabel(values[j+1]); + searchLabel[j].setPreferredSize(new Dimension(90,25)); + searchMap.put(searchLabel[j], searchField[j]); + } + +// session.search(arg0, arg1, arg2) + for (int j = 1; j < values.length; j++) { +// String string = values[j]; + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + selectItemJpanel.add(i+".2.left.top",searchLabel[j-1]); + selectItemJpanel.add(i+".3.left.top",searchField[j-1]); + if(j==values.length-1) { + selectItemJpanel.add(i+".4.left.top",searchButton); + } + i++; + + } + + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + JLabel label= new JLabel("ѯ"); + label.setPreferredSize(new Dimension(90,25)); + selectItemJpanel.add(i+".2.left.top",label); + resultPanel=new JPanel(new PropertyLayout()); + + scrollPane=new JScrollPane(resultPanel); + scrollPane.setPreferredSize(new Dimension(240,150)); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + selectItemJpanel.add(i+".3.left.top",scrollPane); + selectItemJpanel.add(i+".4.left.top",selectButton); + +// leftJpanel.add("2.1.left.top",selectItemJpanel); + + + createInfoJpanel.add("1.1.left.top", + new JLabel("Ϣ")); + int b = 2; + for (int j = 0; j < createInfo.length; j++) { + createInfoJpanel.add(b + ".1.left.top", new JLabel(" ")); + String[] string = createInfo[j].split("="); + createLabel[j] = new JLabel(string[0]); + createLabel[j].setPreferredSize(new Dimension(90, 25)); + createInfoJpanel.add(b + ".2.left.top", createLabel[j]); + String[] string2=string[1].split(":"); + if (string2.length > 1) { + if(string2[0].startsWith("#")) {//TODO + createCom[j] = new MultiCombo(session.getPreferenceService().getStringValues(string2[0].substring(1))); + createCom[j].setPreferredSize(new Dimension(250, 30)); + createCom[j].setEditable(true); + createMap.put(createLabel[j], createCom[j]); + createInfoJpanel.add(b+".3.left.top", createCom[j]); + try { + String[] propertyInfo=string2[1].split("\\."); + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + ((MultiCombo)createCom[j]).setValue(form.getProperty(propertyInfo[1])); + }else if(propertyInfo[0].toUpperCase().equals("ITEM")) { + ((MultiCombo)createCom[j]).setValue(itemX.getProperty(propertyInfo[1])); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + b++; + continue; + } + DefaultComboBoxModel model; + String[] lovs = string2[0].split(";"); + List list = new ArrayList(); + for (int k = 0; k < lovs.length; k++) { + list.add(lovs[k]); + + } + + model = new DefaultComboBoxModel(list.toArray(new String[list.size()])); + createCom[j] = new JComboBox<>(model); + String[] propertyInfo=string2[1].split("\\."); + String propertyValue=""; + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + try { + propertyValue=form.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } + createCom[j].setSelectedItem(propertyValue); + createCom[j].setPreferredSize(new Dimension(100, 30)); + createMap.put(createLabel[j], createCom[j]); + createInfoJpanel.add(b + ".3.left.top", createCom[j]); + if(string[0].equals("ܼ")) { + DocumentUtil.mjCom=createCom[j]; + createMap.put(createLabel[j], DocumentUtil.mjCom); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.mjCom); + + createCom[j].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + try { + System.out.println("ip_clearance==========="+session.getUser().getStringProperty("ip_clearance")); + } catch (Exception e2) { + e2.printStackTrace(); + } + + System.out.println("ѡ====="+e.getItem().toString()); + if (e.getStateChange() == ItemEvent.SELECTED) { + try { + KPropertyLOVDisplayer.checkIP(e.getItem().toString()); + } catch (Exception e1) { + DocumentUtil.mjCom.setSelectedIndex(-1); + MessageBox.post("ûܼ޸ĺִܼܹд˲","",MessageBox.INFORMATION); + } + + } + } + }); + } + } else { + createText[j] = new JTextField(15); + createMap.put(createLabel[j], createText[j]); + String[] propertyInfo=string[1].split("\\."); + String propertyValue=""; + TCComponent x=null; + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + x=form; + }else if(propertyInfo[0].toUpperCase().equals("REV")) { + x=rev; + }else if(propertyInfo[0].toUpperCase().equals("DATASET")) { + if(dataset!=null) { + + x=dataset; + } + } + if(x!=null) { + + try { + System.out.println(x==null); + System.out.println(propertyInfo[1]); + System.out.println(x.getTCProperty(propertyInfo[1])==null); + propertyValue=x.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (Exception e1) { + e1.printStackTrace(); + } + createText[j].setText(propertyValue); + createInfoJpanel.add(b + ".3.left.top", createText[j]); + } + } + + b++; + + } + + rightJpanel.add("1.1.left.top", createInfoJpanel); + + mainJpanel.add("1.1.left.top",leftJpanel); + mainJpanel.add("1.2.left.top", rightJpanel); + bottomJpanel = new JPanel(new FlowLayout()); + bottomJpanel.add(okButton); + bottomJpanel.add(celButton); + // ͨȡѡЩؼɱ༭(jlabel*,*Ҳü) + String[] editable = session.getPreferenceService().getStringValues("Connor_AVIC_AlterEditableC"); + for (int j = 0; j < editable.length; j++) { + boolean boo = false; + String string = editable[j]; + boo = DocumentUtil.setEditable(createMap, string); + if (boo == false) { + + boo = DocumentUtil.setEditable(basicMap, string); + if (boo == false) { + + DocumentUtil.setEditable(searchMap, string); + } + } + + } + zjtsyq=new JCheckBox("Ҫ"); + zjtsyq.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTextField field=null; + JTextField field1=null; + JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("ļ")) { + field=((JTextField)me.getValue()); + } + + } + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { + field1=((JTextField)me.getValue()); + } + if(me.getKey().getText().startsWith("ͼ")) { + field2=((JTextField)me.getValue()); + } + + } + if(zjtsyq.isSelected()) { + field.setEditable(true); + field1.setEditable(true); + field2.setEditable(true); + }else { + field.setEditable(false); + field1.setEditable(false); + field2.setEditable(false); + } + } + }); + for(Map.Entry me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + try { + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + + } +// this.add(zjtsyq,BorderLayout.NORTH); + this.add(mainJpanel, BorderLayout.CENTER); + this.add(bottomJpanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + JPanel resultPanel = new JPanel(new PropertyLayout()); + JScrollPane scrollPane = new JScrollPane(resultPanel); + + Map radioMap=new HashMap(); + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObj = e.getSource(); + if (sourceObj.equals(okButton)) { + + + try { + TCComponentDataset newdataset =null; + if(dataset!=null) { + newdataset=dataset; + } + // + JTextField field2 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("")) { + field2 = ((JTextField) me.getValue()); + } + + } + rev.setStringProperty("object_name", field2.getText()); + // ʵļ + JTextField field3 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().contains("ʵļ")) { + field3 = ((JTextField) me.getValue()); + } + + } + objectName = field3.getText(); + if(newdataset!=null) { + + newdataset.setStringProperty("object_name", field3.getText()); + } + + String[] propertyName = session.getPreferenceService().getStringValues("Connor_AVIC_SetFormPropertyC"); + Map mapX = new HashMap<>(); + for (int i = 0; i < propertyName.length; i++) { + String[] value = propertyName[i].split("="); + mapX.put(value[0], value[1]); + } + Map propertyValue = new HashMap<>(); + for (java.util.Map.Entry me : basicMap.entrySet()) { + if (mapX.containsKey(me.getKey().getText())) { + String value = ""; + try { + value = ((JTextField) me.getValue()).getText(); + } catch (Exception e1) { + value = (String) ((JComboBox) me.getValue()).getSelectedItem(); + } + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + + } + for (java.util.Map.Entry me : createMap.entrySet()) { + if (mapX.containsKey(me.getKey().getText())) { + String value = ""; + Object comp = me.getValue(); + if(comp instanceof MultiCombo) + value = ((MultiCombo)comp).getValue();//TODO + else if(comp instanceof JTextField) + value=((JTextField)comp).getText(); + else + value=(String)((JComboBox)comp).getSelectedItem(); + TCComponent tarForm=((TCComponent) app.getTargetComponent()).getRelatedComponents("IMAN_master_form_rev")[0]; + if(!tarForm.getProperty("ac5_DocumentNumber").equals(value)) { + if(me.getKey().getText().contains("ļ")) { + TCComponent[] comps; + try { + comps = session.search("DocSearch1", new String[] {"ĵ"}, new String[] {value}); + if(comps.length>0) { + + MessageBox.post("","ļŲΨһ޸",MessageBox.INFORMATION); + + return; + }else { + this.disposeDialog(); + this.dispose(); + } + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } + }else { + this.disposeDialog(); + this.dispose(); + } + + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + this.disposeDialog(); + this.dispose(); + } + for (java.util.Map.Entry me : propertyValue.entrySet()) { + TCComponent tccomponentX = form; + String objectType = me.getKey().split("\\.")[0]; + String valueType = me.getKey().split("\\.")[1].split(":")[1]; + String pname = me.getKey().split("\\.")[1].split(":")[0]; + if (objectType.toLowerCase().equals("itemrevisionmaster")) { + tccomponentX = form; + } + if (valueType.toLowerCase().equals("text")) { + tccomponentX.setStringProperty(pname, me.getValue()); + } else if (valueType.toLowerCase().equals("lov")) { + String trueValue = (String) tccomponentX.getTCProperty(pname).getLOV().getListOfValues() + .getRealValue(me.getValue()); + tccomponentX.setStringProperty(pname, trueValue); + if(pname.equals("ip_classification")) { + System.out.println("ܼ================"+trueValue); + itemX.setStringProperty(pname, trueValue); + form.setStringProperty(pname, trueValue); + itemFormX.setStringProperty(pname, trueValue); + rev.setStringProperty(pname, trueValue); + + } + } + } + if(newdataset!=null) { + + // ͨcmdķʽwsfļϣҪעexcelword + // ļ + String testPath = ""; + testPath = DocumentUtil.downLoadFile(newdataset); + // ļ + String dataFile = ""; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm") || testPath.endsWith(".docx") + || testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx") || testPath.endsWith(".xls")) { + try { + dataFile = DocumentUtil.jk_SetCAXAFile("Connor_AVIC_NewDocumentThesignC",session,newdataset, true); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + String wsfType = "word"; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm") || testPath.endsWith(".docx")) { + wsfType = "word"; + } else if (testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx") || testPath.endsWith(".xls")) { + wsfType = "excel"; + } + // ȡwsfļλ,滻 + String wsfpath = null; + File file = new File(testPath); + String path = testPath.substring(0, testPath.lastIndexOf("\\") + 1); + String suffix = testPath.substring(testPath.lastIndexOf("."), testPath.length()); + System.out.println(path); + System.out.println(suffix); + try { + if (wsfType.equals("word")) { + + wsfpath = DocumentUtil.getFileFromClass(getClass(), "SubstMacros-MSWord.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath, new String[] { testPath, dataFile }); + + // ļ + testPath = path + objectName + suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] { testPath }, new String[] { "word" }); + } else if (wsfType.equals("excel")) { + wsfpath = DocumentUtil.getFileFromClass(getClass(), "SubstMacros-MSExcel.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath, new String[] { testPath, dataFile }); + // ļ + testPath = path + objectName + suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] { testPath }, new String[] { "excel" }); + + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } catch (Exception e1) { + e1.printStackTrace(); + } + MessageBox.post("","",MessageBox.INFORMATION); + } else if (sourceObj.equals(celButton)) { + + this.disposeDialog(); + this.dispose(); + }else if(sourceObj.equals(searchButton)){ + this.getRootPane().setDefaultButton(selectButton);//õǰĬѡаť + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchC"); + + String[] selectItem=new String[values.length-1]; + String[] selectValue=new String[values.length-1]; + int i=0; + boolean isNull=true; + for(java.util.Map.Entry me:searchMap.entrySet()) { + String key=me.getKey().getText(); + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { + value="*"; + }else { + value="*"+value+"*"; + isNull=false; + } + selectItem[i]=key; + selectValue[i]=value; + i++; + } + + if(isNull==true) { + + MessageBox.post("ĿȫΪ","",MessageBox.INFORMATION); + + }else { + + try { + TCComponent[] comps=session.search(values[0], selectItem, selectValue); + System.out.println("========"+comps.length); + this.disposeDialog(); + this.showDialog(); + radioButton=new JRadioButton[comps.length]; + radioMap=new HashMap(); + resultPanel.removeAll(); +// scrollPane.remove(resultPanel); + bg=new ButtonGroup(); + //ѯóɿõ + String[] properties=session.getPreferenceService().getStringValues("Connor_AVIC_SearchPropertiesC"); + if(comps.length==0) { + + MessageBox.post("ѯΪ","",MessageBox.INFORMATION); + + } + for (int j = 0; j < comps.length; j++) { + TCComponent tcComponent = comps[j]; + String name=""; + for (int k = 0; k < properties.length; k++) { + //ְ汾Ͷ + TCComponent tcComponent0=null; + String[] ps=properties[k].split("\\."); + System.out.println(); + if(ps[0].toUpperCase().equals("REV")){ + tcComponent0=tcComponent; + }else if(ps[0].toUpperCase().equals("REVMASTER")) { + tcComponent0=tcComponent.getRelatedComponents("IMAN_master_form_rev")[0]; + } + name=name+tcComponent0.getProperty(ps[1]); + if(k me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + //ͼţȡitem_id + if(property.startsWith("ͼ")) { + field.setText(item.getProperty("item_id")); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + //Ըֵ + //ƣͺ+ĵ+ˮֹ޸ģ +// JTextField field0=null; +// JComboBox combox1=null; + + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { +// field0=((JTextField)me.getValue()); + } + + if(me.getKey().getText().startsWith("ĵ")) { +// combox1=((JComboBox)me.getValue()); + } + + } + + //ѡڸƣʵļƺļ +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + + } + + } + + String objectName = ""; + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM.java b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM.java new file mode 100644 index 0000000..7b076ed --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogM.java @@ -0,0 +1,789 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.KPropertyLOVDisplayer; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class AlterTechWordDialogM extends AbstractAIFDialog implements ActionListener { + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private JPanel mainJpanel; + private JPanel leftJpanel; + private JPanel basicInfoJpanel; + private JPanel selectItemJpanel; + private JPanel rightJpanel; + private JPanel createInfoJpanel; +// private JTextField pathJTextField; +// private String selectType; +// private String selectSecondDoc; +// private String selectDocCategory; + private JButton okButton; + private JButton celButton; + private JButton searchButton; + private JButton selectButton; + private JCheckBox zjtsyq; + JTextField[] searchField = null; +// JTextField itemNameField=new JTextField(15); + JRadioButton[] radioButton = null; + ButtonGroup bg = new ButtonGroup(); + private JPanel bottomJpanel; + +// private String exportFile; + +// private ProgressBarThread wait; + private TCComponentItemRevision rev=null; + private TCComponentForm form=null; + private TCComponentItem itemX=null; + private TCComponentForm itemFormX=null; + private TCComponentDataset dataset=null; + + public AlterTechWordDialogM(AbstractAIFApplication app) { + super(AIFUtility.getActiveDesktop()); + this.app = app; + this.session = (TCSession) app.getSession(); + rev=(TCComponentItemRevision) app.getTargetComponent(); + try { + itemX=rev.getItem(); + form=(TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + itemFormX=(TCComponentForm) itemX.getRelatedComponents("IMAN_master_form")[0]; + TCComponent[] datasets=rev.getRelatedComponents("IMAN_specification"); + if(datasets.length>0) { + dataset=(TCComponentDataset) rev.getRelatedComponents("IMAN_specification")[0]; + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + @Override + public void run() { +// super.run();//ע򴰿ʾ + + try { + readProperty();// excelжȡϢ + } catch (IOException e) { + e.printStackTrace(); + } + + initUI(); + } + + + Map> map1 = new HashMap>(); + Map> map2 = new HashMap>(); + Map> map3 = new HashMap>(); + Map> listMap = new HashMap>(); + String[] excelPre = null; + String[] createInfo = null; + + + + + Map> map1_2 = new HashMap<>(); + Map> map2_3 = new HashMap<>(); + List list_1 = new ArrayList<>();// һֵǷظ + List jcomboxList_1 = new ArrayList<>();// һֵǷظ + List list_2 = new ArrayList<>();// ֵǷظ + List list_3 = new ArrayList<>();// ֵǷظ + + private void readProperty() throws IOException { + excelPre=session.getPreferenceService().getStringValues("Connor_AVIC_NewDocumentBasicM"); + createInfo = session.getPreferenceService().getStringValues("Connor_AVIC_AlterDocumentCreationM"); + createLabel = new JLabel[createInfo.length]; + createText = new JTextField[createInfo.length]; + createCom = new JComboBox[createInfo.length]; + + } + + JLabel[] createLabel = null; + JTextField[] createText = null; + JComboBox[] createCom = null; + Dimension dimension = new Dimension(150, 30); + Map basicMap = new HashMap(); + Map basicPropertyMap = new HashMap(); + Map createMap = new HashMap(); + Map searchMap = new HashMap(); + DefaultComboBoxModel model1 = null; + DefaultComboBoxModel model2 = null; + DefaultComboBoxModel model3 = null; + JLabel[] basicLabel=null; + JLabel[] searchLabel=null; + JTextField[] basicText=null; + private void initUI() { + this.setTitle("ĵ޸"); + + okButton = new JButton("޸"); + okButton.addActionListener(this); + this.getRootPane().setDefaultButton(searchButton);//õǰĬѡаť + celButton = new JButton("ȡ"); + celButton.addActionListener(this); + searchButton = new JButton("ѯ"); + searchButton.addActionListener(this); + selectButton = new JButton("ѡ"); + selectButton.addActionListener(this); + + this.setLayout(new BorderLayout()); + + this.setSize(850, 550); + mainJpanel = new JPanel(new PropertyLayout()); + mainJpanel.setPreferredSize(new Dimension(950, 450)); + leftJpanel = new JPanel(new PropertyLayout()); + leftJpanel.setPreferredSize(new Dimension(500, 450)); + basicInfoJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel.setPreferredSize(new Dimension(500, 300)); + rightJpanel = new JPanel(new PropertyLayout()); + rightJpanel.setPreferredSize(new Dimension(450, 350)); + createInfoJpanel = new JPanel(new PropertyLayout()); +// createInfoJpanel.setPreferredSize(new Dimension(400, 280)); + basicInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + + basicLabel=new JLabel[excelPre.length-2]; + basicText=new JTextField[excelPre.length-2]; + int a=2; + for (int i = 1; i < excelPre.length-1; i++) { + String[] proValue = excelPre[i].split("="); + if(i>3) { + + basicLabel[i-1]=new JLabel(proValue[0]); + basicLabel[i-1].setPreferredSize(new Dimension(90,25)); + String value2= proValue[1]; + + if(value2.toLowerCase().startsWith("itemrevisionmaster")) { + basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + basicInfoJpanel.add(a+".2.left.top", basicLabel[i-1]); + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + } +// else if(value2.toLowerCase().startsWith("sheet")) { +// basicText[i-1]=new JTextField(15); +// basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); +// basicMap.put(basicLabel[i-1],basicText[i-1]); +// basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); +// } + a++; + } + } + leftJpanel.add("1.1.left.top",basicInfoJpanel); + + int i=1; + selectItemJpanel.add(i+".1.left.top",new JLabel("ѡ ")); + i++; +// selectItemJpanel.add(i+".1.left.top",new JLabel(" ѯѡ")); +// i++; + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchM"); + searchLabel=new JLabel[values.length-1]; + + searchField=new JTextField[values.length-1]; + for (int j = 0; j < searchField.length; j++) { + searchField[j]=new JTextField(15); + searchLabel[j]=new JLabel(values[j+1]); + searchLabel[j].setPreferredSize(new Dimension(90,25)); + searchMap.put(searchLabel[j], searchField[j]); + } + +// session.search(arg0, arg1, arg2) + for (int j = 1; j < values.length; j++) { +// String string = values[j]; + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + selectItemJpanel.add(i+".2.left.top",searchLabel[j-1]); + selectItemJpanel.add(i+".3.left.top",searchField[j-1]); + if(j==values.length-1) { + selectItemJpanel.add(i+".4.left.top",searchButton); + } + i++; + + } + + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + JLabel label= new JLabel("ѯ"); + label.setPreferredSize(new Dimension(90,25)); + selectItemJpanel.add(i+".2.left.top",label); + resultPanel=new JPanel(new PropertyLayout()); + + scrollPane=new JScrollPane(resultPanel); + scrollPane.setPreferredSize(new Dimension(250,150)); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + selectItemJpanel.add(i+".3.left.top",scrollPane); + selectItemJpanel.add(i+".4.left.top",selectButton); + +// leftJpanel.add("2.1.left.top",selectItemJpanel); + + + createInfoJpanel.add("1.1.left.top", + new JLabel("Ϣ")); + int b = 2; + for (int j = 0; j < createInfo.length; j++) { + createInfoJpanel.add(b + ".1.left.top", new JLabel(" ")); + String[] string = createInfo[j].split("="); + createLabel[j] = new JLabel(string[0]); + createLabel[j].setPreferredSize(new Dimension(90, 25)); + createInfoJpanel.add(b + ".2.left.top", createLabel[j]); + String[] string2=string[1].split(":"); + if (string2.length > 1) { + if(string2[0].startsWith("#")) {//TODO + createCom[j] = new MultiCombo(session.getPreferenceService().getStringValues(string2[0].substring(1))); + createCom[j].setPreferredSize(new Dimension(250, 30)); + createCom[j].setEditable(true); + createMap.put(createLabel[j], createCom[j]); + createInfoJpanel.add(b+".3.left.top", createCom[j]); + try { + String[] propertyInfo=string2[1].split("\\."); + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + ((MultiCombo)createCom[j]).setValue(form.getProperty(propertyInfo[1])); + }else if(propertyInfo[0].toUpperCase().equals("ITEM")) { + ((MultiCombo)createCom[j]).setValue(itemX.getProperty(propertyInfo[1])); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + b++; + continue; + } + DefaultComboBoxModel model; + String[] lovs = string2[0].split(";"); + List list = new ArrayList(); + for (int k = 0; k < lovs.length; k++) { + list.add(lovs[k]); + + } + + model = new DefaultComboBoxModel(list.toArray(new String[list.size()])); + createCom[j] = new JComboBox(model); + String[] propertyInfo=string2[1].split("\\."); + String propertyValue=""; + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + try { + propertyValue=form.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (Exception e1) { + e1.printStackTrace(); + } + }else if(propertyInfo[0].toUpperCase().equals("ITEM")) { + try { + propertyValue=itemX.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + createCom[j].setSelectedItem(propertyValue); + createCom[j].setPreferredSize(new Dimension(100, 30)); + createMap.put(createLabel[j], createCom[j]); + createInfoJpanel.add(b + ".3.left.top", createCom[j]); + if(string[0].equals("ܼ")) { + DocumentUtil.mjCom=createCom[j]; + createMap.put(createLabel[j], DocumentUtil.mjCom); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.mjCom); + + createCom[j].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + try { + System.out.println("ip_clearance==========="+session.getUser().getStringProperty("ip_clearance")); + } catch (TCException e2) { + e2.printStackTrace(); + } + + System.out.println("ѡ====="+e.getItem().toString()); + if (e.getStateChange() == ItemEvent.SELECTED) { + try { + KPropertyLOVDisplayer.checkIP(e.getItem().toString()); + } catch (Exception e1) { + DocumentUtil.mjCom.setSelectedIndex(-1); + MessageBox.post("ûܼ޸ĺִܼܹд˲","",MessageBox.INFORMATION); + } + + } + } + }); + } + } else { + createText[j] = new JTextField(15); + createMap.put(createLabel[j], createText[j]); + String[] propertyInfo=string[1].split("\\."); + String propertyValue=""; + TCComponent x=null; + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + x=form; + }else if(propertyInfo[0].toUpperCase().equals("REV")) { + x=rev; + }else if(propertyInfo[0].toUpperCase().equals("ITEM")) { + x=itemX; + }else if(propertyInfo[0].toUpperCase().equals("DATASET")) { + if(dataset!=null) { + + x=dataset; + } + } + if(x!=null) { + + try { + System.out.println(x==null); + System.out.println(propertyInfo[1]); + System.out.println(x.getTCProperty(propertyInfo[1])==null); + propertyValue=x.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (Exception e1) { + e1.printStackTrace(); + } + createText[j].setText(propertyValue); + createInfoJpanel.add(b + ".3.left.top", createText[j]); + } + } + + b++; + + } + + rightJpanel.add("1.1.left.top", createInfoJpanel); + + mainJpanel.add("1.1.left.top",leftJpanel); + mainJpanel.add("1.2.left.top", rightJpanel); + bottomJpanel = new JPanel(new FlowLayout()); + bottomJpanel.add(okButton); + bottomJpanel.add(celButton); + // ͨȡѡЩؼɱ༭(jlabel*,*Ҳü) + String[] editable = session.getPreferenceService().getStringValues("Connor_AVIC_AlterEditableM"); + for (int j = 0; j < editable.length; j++) { + boolean boo = false; + String string = editable[j]; + boo = DocumentUtil.setEditable(createMap, string); + if (boo == false) { + + boo = DocumentUtil.setEditable(basicMap, string); + if (boo == false) { + + DocumentUtil.setEditable(searchMap, string); + } + } + + } + zjtsyq=new JCheckBox("Ҫ"); + zjtsyq.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTextField field=null; + JTextField field1=null; + JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("ļ")) { + field=((JTextField)me.getValue()); + } + + } + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { + field1=((JTextField)me.getValue()); + } + if(me.getKey().getText().startsWith("ͼ")) { + field2=((JTextField)me.getValue()); + } + + } + if(zjtsyq.isSelected()) { + field.setEditable(true); + field1.setEditable(true); + field2.setEditable(true); + }else { + field.setEditable(false); + field1.setEditable(false); + field2.setEditable(false); + } + } + }); + for(Map.Entry me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + try { + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + + } +// this.add(zjtsyq,BorderLayout.NORTH); + this.add(mainJpanel, BorderLayout.CENTER); + this.add(bottomJpanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + JPanel resultPanel = new JPanel(new PropertyLayout()); + JScrollPane scrollPane = new JScrollPane(resultPanel); + + Map radioMap=new HashMap(); + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObj = e.getSource(); + if (sourceObj.equals(okButton)) { + + + try { + TCComponentDataset newdataset =null; + if(dataset!=null) { + newdataset=dataset; + } + // + JTextField field2 = null; + // ʵļ + JTextField field3 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("")) { + field2 = ((JTextField) me.getValue()); + }else if (me.getKey().getText().startsWith("ʵļ")) { + field3 = ((JTextField) me.getValue()); + } + + } + rev.setStringProperty("object_name", field2.getText()); + objectName = field3.getText(); + if(newdataset!=null) { + + newdataset.setStringProperty("object_name", field3.getText()); + } + + String[] propertyName = session.getPreferenceService().getStringValues("Connor_AVIC_SetFormPropertyM"); + Map mapX = new HashMap<>(); + for (int i = 0; i < propertyName.length; i++) { + String[] value = propertyName[i].split("="); + mapX.put(value[0], value[1]); + } + Map propertyValue = new HashMap<>(); + for (Entry me : basicMap.entrySet()) { + if (mapX.containsKey(me.getKey().getText())) { + String value = ""; + try { + value = ((JTextField) me.getValue()).getText(); + } catch (Exception e1) { + value = (String) ((JComboBox) me.getValue()).getSelectedItem(); + } + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + + } + for (Entry me : createMap.entrySet()) { + if (mapX.containsKey(me.getKey().getText())) { + String value = ""; + Object comp = me.getValue(); + if(comp instanceof MultiCombo) + value = ((MultiCombo)comp).getValue();//TODO + else if(comp instanceof JTextField) + value=((JTextField)comp).getText(); + else + value=(String)((JComboBox)comp).getSelectedItem(); + TCComponent tarForm=((TCComponent) app.getTargetComponent()).getRelatedComponents("IMAN_master_form_rev")[0]; + if(!tarForm.getProperty("ac5_DocumentNumber").equals(value)) { + if(me.getKey().getText().contains("ļ")) { + TCComponent[] comps; + try { + comps = session.search("DocSearch1", new String[] {"ĵ"}, new String[] {value}); + if(comps.length>0) { + + MessageBox.post("","ļŲΨһ޸",MessageBox.INFORMATION); + + return; + }else { + this.disposeDialog(); + this.dispose(); + } + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } + }else { + this.disposeDialog(); + this.dispose(); + } + + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + this.disposeDialog(); + this.dispose(); + } + for (Entry me : propertyValue.entrySet()) { + TCComponent tccomponentX = form; + String objectType = me.getKey().split("\\.")[0]; + String valueType = me.getKey().split("\\.")[1].split(":")[1]; + String pname = me.getKey().split("\\.")[1].split(":")[0]; + if (objectType.toLowerCase().equals("itemrevisionmaster")) { + tccomponentX = form; + } + if (valueType.toLowerCase().equals("text")) { + tccomponentX.setStringProperty(pname, me.getValue()); + } else if (valueType.toLowerCase().equals("lov")) { + String trueValue = (String) tccomponentX.getTCProperty(pname).getLOV().getListOfValues() + .getRealValue(me.getValue()); + tccomponentX.setStringProperty(pname, trueValue); + if(pname.equals("ip_classification")) { + System.out.println("ܼ================"+trueValue); + itemX.setStringProperty(pname, trueValue); + form.setStringProperty(pname, trueValue); + itemFormX.setStringProperty(pname, trueValue); + rev.setStringProperty(pname, trueValue); + + } + } + } + if(newdataset!=null) { + // ͨcmdķʽwsfļϣҪעexcelword + // ļ + String testPath = ""; + testPath = DocumentUtil.downLoadFile(newdataset); + // ļ + String dataFile = ""; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm") || testPath.endsWith(".docx") + || testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx") || testPath.endsWith(".xls")) { + try { + dataFile = DocumentUtil.jk_SetCAXAFile("Connor_AVIC_NewDocumentThesignM",session,newdataset, true); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + String wsfType = "word"; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm") || testPath.endsWith(".docx")) { + wsfType = "word"; + } else if (testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx") || testPath.endsWith(".xls")) { + wsfType = "excel"; + } + // ȡwsfļλ,滻 + String wsfpath = null; + File file = new File(testPath); + String path = testPath.substring(0, testPath.lastIndexOf("\\") + 1); + String suffix = testPath.substring(testPath.lastIndexOf("."), testPath.length()); + System.out.println(path); + System.out.println(suffix); + try { + if (wsfType.equals("word")) { + + wsfpath = DocumentUtil.getFileFromClass(getClass(), "SubstMacros-MSWord.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath, new String[] { testPath, dataFile }); + + // ļ + testPath = path + objectName + suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] { testPath }, new String[] { "word" }); + } else if (wsfType.equals("excel")) { + wsfpath =DocumentUtil.getFileFromClass(getClass(), "SubstMacros-MSExcel.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath, new String[] { testPath, dataFile }); + // ļ + testPath = path + objectName + suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] { testPath }, new String[] { "excel" }); + + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + MessageBox.post("","",MessageBox.INFORMATION); + } else if (sourceObj.equals(celButton)) { + + this.disposeDialog(); + this.dispose(); + }else if(sourceObj.equals(searchButton)){ + this.getRootPane().setDefaultButton(selectButton);//õǰĬѡаť + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchM"); + + String[] selectItem=new String[values.length-1]; + String[] selectValue=new String[values.length-1]; + int i=0; + boolean isNull=true; + for(Entry me:searchMap.entrySet()) { + String key=me.getKey().getText(); + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { + value="*"; + }else { + value="*"+value+"*"; + isNull=false; + } + selectItem[i]=key; + selectValue[i]=value; + i++; + } + + if(isNull==true) { + + MessageBox.post("ĿȫΪ","",MessageBox.INFORMATION); + + + }else { + + try { + TCComponent[] comps=session.search(values[0], selectItem, selectValue); + System.out.println("========"+comps.length); + this.disposeDialog(); + this.showDialog(); + radioButton=new JRadioButton[comps.length]; + radioMap=new HashMap(); + resultPanel.removeAll(); +// scrollPane.remove(resultPanel); + bg=new ButtonGroup(); + //ѯóɿõ + String[] properties=session.getPreferenceService().getStringValues("Connor_AVIC_SearchPropertiesM"); + if(comps.length==0) { + + MessageBox.post("ѯΪ","",MessageBox.INFORMATION); + + } + for (int j = 0; j < comps.length; j++) { + TCComponent tcComponent = comps[j]; + String name=""; + for (int k = 0; k < properties.length; k++) { + //ְ汾Ͷ + TCComponent tcComponent0=null; + String[] ps=properties[k].split("\\."); + System.out.println(); + if(ps[0].toUpperCase().equals("REV")){ + tcComponent0=tcComponent; + }else if(ps[0].toUpperCase().equals("REVMASTER")) { + tcComponent0=tcComponent.getRelatedComponents("IMAN_master_form_rev")[0]; + }else if(ps[0].toUpperCase().equals("ITEM")) { + tcComponent0=((TCComponentItemRevision)tcComponent).getItem(); + } + name=name+tcComponent0.getProperty(ps[1]); + if(k me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + //ͼţȡitem_id + if(property.startsWith("ͼ")) { + field.setText(item.getProperty("item_id")); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + //Ըֵ + //ƣͺ+ĵ+ˮֹ޸ģ +// JTextField field0=null; +// JComboBox combox1=null; + + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { +// field0=((JTextField)me.getValue()); + } + + if(me.getKey().getText().startsWith("ĵ")) { +// combox1=((JComboBox)me.getValue()); + } + + } + + //ѡڸƣʵļƺļ +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + + } + + } + + String objectName = ""; + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS.java b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS.java new file mode 100644 index 0000000..f707a0f --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogS.java @@ -0,0 +1,780 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.KPropertyLOVDisplayer; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +@SuppressWarnings("unchecked") +public class AlterTechWordDialogS extends AbstractAIFDialog implements ActionListener { + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private JPanel mainJpanel; + private JPanel leftJpanel; + private JPanel basicInfoJpanel; + private JPanel selectItemJpanel; + private JPanel rightJpanel; + private JPanel createInfoJpanel; +// private JTextField pathJTextField; +// private String selectType; +// private String selectSecondDoc; +// private String selectDocCategory; + private JButton okButton; + private JButton celButton; + private JButton searchButton; + private JButton selectButton; + private JCheckBox zjtsyq; + JTextField[] searchField = null; +// JTextField itemNameField=new JTextField(15); + JRadioButton[] radioButton = null; + ButtonGroup bg = new ButtonGroup(); + private JPanel bottomJpanel; + +// private String exportFile; + +// private ProgressBarThread wait; + private TCComponentItemRevision rev=null; + private TCComponentForm form=null; + private TCComponentItem itemX=null; + private TCComponentForm itemFormX=null; + private TCComponentDataset dataset=null; + public AlterTechWordDialogS(AbstractAIFApplication app) { + super(AIFUtility.getActiveDesktop()); + this.app = app; + this.session = (TCSession) app.getSession(); + rev=(TCComponentItemRevision) app.getTargetComponent(); + try { + itemX=rev.getItem(); + form=(TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + itemFormX=(TCComponentForm) itemX.getRelatedComponents("IMAN_master_form")[0]; + TCComponent[] datasets=rev.getRelatedComponents("IMAN_specification"); + if(datasets.length>0) { + dataset=(TCComponentDataset) rev.getRelatedComponents("IMAN_specification")[0]; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void run() { +// super.run();//ע򴰿ʾ + + try { + readProperty();// excelжȡϢ + } catch (IOException e) { + e.printStackTrace(); + } + + initUI(); + } + + + Map> map1 = new HashMap>(); + Map> map2 = new HashMap>(); + Map> map3 = new HashMap>(); + Map> listMap = new HashMap>(); + String[] excelPre = null; + String[] createInfo = null; + + + + + Map> map1_2 = new HashMap<>(); + Map> map2_3 = new HashMap<>(); + List list_1 = new ArrayList<>();// һֵǷظ + List jcomboxList_1 = new ArrayList<>();// һֵǷظ + List list_2 = new ArrayList<>();// ֵǷظ + List list_3 = new ArrayList<>();// ֵǷظ + + private void readProperty() throws IOException { + excelPre=session.getPreferenceService().getStringValues("Connor_AVIC_NewDocumentBasicS"); + createInfo = session.getPreferenceService().getStringValues("Connor_AVIC_AlterDocumentCreationS"); + createLabel = new JLabel[createInfo.length]; + createText = new JTextField[createInfo.length]; + createCom = new JComboBox[createInfo.length]; + + } + + JLabel[] createLabel = null; + JTextField[] createText = null; + JComboBox[] createCom = null; + Dimension dimension = new Dimension(150, 30); + Map basicMap = new HashMap(); + Map basicPropertyMap = new HashMap(); + Map createMap = new HashMap(); + Map searchMap = new HashMap(); + DefaultComboBoxModel model1 = null; + DefaultComboBoxModel model2 = null; + DefaultComboBoxModel model3 = null; + JLabel[] basicLabel=null; + JLabel[] searchLabel=null; + JTextField[] basicText=null; + private void initUI() { + this.setTitle("ĵ޸"); + + okButton = new JButton("޸"); + okButton.addActionListener(this); + this.getRootPane().setDefaultButton(searchButton);//õǰĬѡаť + celButton = new JButton("ȡ"); + celButton.addActionListener(this); + searchButton = new JButton("ѯ"); + searchButton.addActionListener(this); + selectButton = new JButton("ѡ"); + selectButton.addActionListener(this); + + this.setLayout(new BorderLayout()); + + this.setSize(850, 550); + mainJpanel = new JPanel(new PropertyLayout()); + mainJpanel.setPreferredSize(new Dimension(950, 450)); + leftJpanel = new JPanel(new PropertyLayout()); + leftJpanel.setPreferredSize(new Dimension(500, 450)); + basicInfoJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel.setPreferredSize(new Dimension(500, 300)); + rightJpanel = new JPanel(new PropertyLayout()); + rightJpanel.setPreferredSize(new Dimension(450, 350)); + createInfoJpanel = new JPanel(new PropertyLayout()); +// createInfoJpanel.setPreferredSize(new Dimension(400, 280)); +basicInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + + basicLabel=new JLabel[excelPre.length-2]; + basicText=new JTextField[excelPre.length-2]; + int a=2; + for (int i = 1; i < excelPre.length-1; i++) { + String[] proValue = excelPre[i].split("="); + if(i>3) { + + basicLabel[i-1]=new JLabel(proValue[0]); + basicLabel[i-1].setPreferredSize(new Dimension(90,25)); + String value2= proValue[1]; + + if(value2.toLowerCase().startsWith("itemrevisionmaster")) { + basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + basicInfoJpanel.add(a+".2.left.top", basicLabel[i-1]); + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + } +// else if(value2.toLowerCase().startsWith("sheet")) { +// basicText[i-1]=new JTextField(15); +// basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); +// basicMap.put(basicLabel[i-1],basicText[i-1]); +// basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); +// } + a++; + } + } + leftJpanel.add("1.1.left.top",basicInfoJpanel); + + int i=1; + selectItemJpanel.add(i+".1.left.top",new JLabel("ѡ ")); + i++; +// selectItemJpanel.add(i+".1.left.top",new JLabel(" ѯѡ")); +// i++; + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchS"); + searchLabel=new JLabel[values.length-1]; + + searchField=new JTextField[values.length-1]; + for (int j = 0; j < searchField.length; j++) { + searchField[j]=new JTextField(15); + searchLabel[j]=new JLabel(values[j+1]); + searchLabel[j].setPreferredSize(new Dimension(90,25)); + searchMap.put(searchLabel[j], searchField[j]); + } + +// session.search(arg0, arg1, arg2) + for (int j = 1; j < values.length; j++) { +// String string = values[j]; + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + selectItemJpanel.add(i+".2.left.top",searchLabel[j-1]); + selectItemJpanel.add(i+".3.left.top",searchField[j-1]); + if(j==values.length-1) { + selectItemJpanel.add(i+".4.left.top",searchButton); + } + i++; + + } + + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + JLabel label= new JLabel("ѯ"); + label.setPreferredSize(new Dimension(90,25)); + selectItemJpanel.add(i+".2.left.top",label); + resultPanel=new JPanel(new PropertyLayout()); + + scrollPane=new JScrollPane(resultPanel); + scrollPane.setPreferredSize(new Dimension(250,150)); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + selectItemJpanel.add(i+".3.left.top",scrollPane); + selectItemJpanel.add(i+".4.left.top",selectButton); + +// leftJpanel.add("2.1.left.top",selectItemJpanel); + + + createInfoJpanel.add("1.1.left.top", + new JLabel("Ϣ")); + int b = 2; + for (int j = 0; j < createInfo.length; j++) { + createInfoJpanel.add(b + ".1.left.top", new JLabel(" ")); + String[] string = createInfo[j].split("="); + createLabel[j] = new JLabel(string[0]); + createLabel[j].setPreferredSize(new Dimension(90, 25)); + createInfoJpanel.add(b + ".2.left.top", createLabel[j]); + String[] string2=string[1].split(":"); + if (string2.length > 1) { + if(string2[0].startsWith("#")) {//TODO + createCom[j] = new MultiCombo(session.getPreferenceService().getStringValues(string2[0].substring(1))); + createCom[j].setPreferredSize(new Dimension(250, 30)); + createCom[j].setEditable(true); + createMap.put(createLabel[j], createCom[j]); + createInfoJpanel.add(b+".3.left.top", createCom[j]); + try { + String[] propertyInfo=string2[1].split("\\."); + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + ((MultiCombo)createCom[j]).setValue(form.getProperty(propertyInfo[1])); + }else if(propertyInfo[0].toUpperCase().equals("ITEM")) { + ((MultiCombo)createCom[j]).setValue(itemX.getProperty(propertyInfo[1])); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + b++; + continue; + } + DefaultComboBoxModel model; + String[] lovs = string2[0].split(";"); + List list = new ArrayList(); + for (int k = 0; k < lovs.length; k++) { + list.add(lovs[k]); + + } + + model = new DefaultComboBoxModel(list.toArray(new String[list.size()])); + createCom[j] = new JComboBox<>(model); + String[] propertyInfo=string2[1].split("\\."); + String propertyValue=""; + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + try { + propertyValue=form.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + createCom[j].setSelectedItem(propertyValue); + createCom[j].setPreferredSize(new Dimension(100, 30)); + createMap.put(createLabel[j], createCom[j]); + createInfoJpanel.add(b + ".3.left.top", createCom[j]); + if(string[0].equals("ܼ")) { + DocumentUtil.mjCom=createCom[j]; + createMap.put(createLabel[j], DocumentUtil.mjCom); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.mjCom); + + createCom[j].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + try { + System.out.println("ip_clearance==========="+session.getUser().getStringProperty("ip_clearance")); + } catch (TCException e2) { + e2.printStackTrace(); + } + + System.out.println("ѡ====="+e.getItem().toString()); + if (e.getStateChange() == ItemEvent.SELECTED) { + try { + KPropertyLOVDisplayer.checkIP(e.getItem().toString()); + } catch (Exception e1) { + DocumentUtil.mjCom.setSelectedIndex(-1); + MessageBox.post("ûܼ޸ĺִܼܹд˲","",MessageBox.INFORMATION); + } + + } + } + }); + } + } else { + createText[j] = new JTextField(15); + createMap.put(createLabel[j], createText[j]); + String[] propertyInfo=string[1].split("\\."); + String propertyValue=""; + TCComponent x=null; + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + x=form; + }else if(propertyInfo[0].toUpperCase().equals("REV")) { + x=rev; + }else if(propertyInfo[0].toUpperCase().equals("DATASET")) { + if(dataset!=null) { + + x=dataset; + } + } + if(x!=null) { + + try { + System.out.println(x==null); + System.out.println(propertyInfo[1]); + System.out.println(x.getTCProperty(propertyInfo[1])==null); + propertyValue=x.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (TCException e1) { + e1.printStackTrace(); + } + createText[j].setText(propertyValue); + createInfoJpanel.add(b + ".3.left.top", createText[j]); + } + } + + b++; + + } + + rightJpanel.add("1.1.left.top", createInfoJpanel); + + mainJpanel.add("1.1.left.top",leftJpanel); + mainJpanel.add("1.2.left.top", rightJpanel); + bottomJpanel = new JPanel(new FlowLayout()); + bottomJpanel.add(okButton); + bottomJpanel.add(celButton); + // ͨȡѡЩؼɱ༭(jlabel*,*Ҳü) + String[] editable = session.getPreferenceService().getStringValues("Connor_AVIC_AlterEditableS"); + for (int j = 0; j < editable.length; j++) { + boolean boo = false; + String string = editable[j]; + boo = DocumentUtil.setEditable(createMap, string); + if (boo == false) { + + boo = DocumentUtil.setEditable(basicMap, string); + if (boo == false) { + + DocumentUtil.setEditable(searchMap, string); + } + } + + } + zjtsyq=new JCheckBox("Ҫ"); + zjtsyq.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTextField field=null; + JTextField field1=null; + JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("ļ")) { + field=((JTextField)me.getValue()); + } + + } + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { + field1=((JTextField)me.getValue()); + } + if(me.getKey().getText().startsWith("ͼ")) { + field2=((JTextField)me.getValue()); + } + + } + if(zjtsyq.isSelected()) { + field.setEditable(true); + field1.setEditable(true); + field2.setEditable(true); + }else { + field.setEditable(false); + field1.setEditable(false); + field2.setEditable(false); + } + } + }); + for(Map.Entry me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + try { + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + + } +// this.add(zjtsyq,BorderLayout.NORTH); + this.add(mainJpanel, BorderLayout.CENTER); + this.add(bottomJpanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + JPanel resultPanel = new JPanel(new PropertyLayout()); + JScrollPane scrollPane = new JScrollPane(resultPanel); + + Map radioMap=new HashMap(); + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObj = e.getSource(); + if (sourceObj.equals(okButton)) { + + try { + TCComponentDataset newdataset =null; + if(dataset!=null) { + newdataset=dataset; + } + // + JTextField field2 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("")) { + field2 = ((JTextField) me.getValue()); + } + + } + rev.setStringProperty("object_name", field2.getText()); + // ʵļ + JTextField field3 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("ʵļ")) { + field3 = ((JTextField) me.getValue()); + } + + } + objectName = field3.getText(); + if(newdataset!=null) { + + newdataset.setStringProperty("object_name", field3.getText()); + } + + String[] propertyName = session.getPreferenceService().getStringValues("Connor_AVIC_SetFormPropertyS"); + Map mapX = new HashMap<>(); + for (int i = 0; i < propertyName.length; i++) { + String[] value = propertyName[i].split("="); + mapX.put(value[0], value[1]); + } + Map propertyValue = new HashMap<>(); + for (java.util.Map.Entry me : basicMap.entrySet()) { + if (mapX.containsKey(me.getKey().getText())) { + String value = ""; + try { + value = ((JTextField) me.getValue()).getText(); + } catch (Exception e1) { + value = (String) ((JComboBox) me.getValue()).getSelectedItem(); + } + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + + } + for (java.util.Map.Entry me : createMap.entrySet()) { + if (mapX.containsKey(me.getKey().getText())) { + String value = ""; + Object comp = me.getValue(); + if(comp instanceof MultiCombo) + value = ((MultiCombo)comp).getValue();//TODO + else if(comp instanceof JTextField) + value=((JTextField)comp).getText(); + else + value=(String)((JComboBox)comp).getSelectedItem(); + TCComponent tarForm=((TCComponent) app.getTargetComponent()).getRelatedComponents("IMAN_master_form_rev")[0]; + if(!tarForm.getProperty("ac5_DocumentNumber").equals(value)) { + if(me.getKey().getText().contains("ļ")) { + TCComponent[] comps; + try { + comps = session.search("DocSearch1", new String[] {"ĵ"}, new String[] {value}); + if(comps.length>0) { + + MessageBox.post("","ļŲΨһ޸",MessageBox.INFORMATION); + + return; + }else { + this.disposeDialog(); + this.dispose(); + } + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } + }else { + this.disposeDialog(); + this.dispose(); + } + + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + this.disposeDialog(); + this.dispose(); + + } + for (java.util.Map.Entry me : propertyValue.entrySet()) { + TCComponent tccomponentX = form; + String objectType = me.getKey().split("\\.")[0]; + String valueType = me.getKey().split("\\.")[1].split(":")[1]; + String pname = me.getKey().split("\\.")[1].split(":")[0]; + if (objectType.toLowerCase().equals("itemrevisionmaster")) { + tccomponentX = form; + } + if (valueType.toLowerCase().equals("text")) { + tccomponentX.setStringProperty(pname, me.getValue()); + } else if (valueType.toLowerCase().equals("lov")) { + String trueValue = (String) tccomponentX.getTCProperty(pname).getLOV().getListOfValues() + .getRealValue(me.getValue()); + tccomponentX.setStringProperty(pname, trueValue); + if(pname.equals("ip_classification")) { + System.out.println("ܼ================"+trueValue); + itemX.setStringProperty(pname, trueValue); + form.setStringProperty(pname, trueValue); + itemFormX.setStringProperty(pname, trueValue); + rev.setStringProperty(pname, trueValue); + + } + } + } + if(newdataset!=null) { + + // ͨcmdķʽwsfļϣҪעexcelword + // ļ + String testPath = ""; + testPath = DocumentUtil.downLoadFile(newdataset); + // ļ + String dataFile = ""; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm") || testPath.endsWith(".docx") + || testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx") || testPath.endsWith(".xls")) { + try { + dataFile = DocumentUtil.jk_SetCAXAFile("Connor_AVIC_NewDocumentThesignS",session,newdataset, true); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + String wsfType = "word"; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm") || testPath.endsWith(".docx")) { + wsfType = "word"; + } else if (testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx") || testPath.endsWith(".xls")) { + wsfType = "excel"; + } + // ȡwsfļλ,滻 + String wsfpath = null; + File file = new File(testPath); + String path = testPath.substring(0, testPath.lastIndexOf("\\") + 1); + String suffix = testPath.substring(testPath.lastIndexOf("."), testPath.length()); + System.out.println(path); + System.out.println(suffix); + try { + if (wsfType.equals("word")) { + + wsfpath = DocumentUtil.getFileFromClass(getClass(), "SubstMacros-MSWord.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath, new String[] { testPath, dataFile }); + + // ļ + testPath = path + objectName + suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] { testPath }, new String[] { "word" }); + } else if (wsfType.equals("excel")) { + wsfpath =DocumentUtil.getFileFromClass(getClass(), "SubstMacros-MSExcel.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath, new String[] { testPath, dataFile }); + // ļ + testPath = path + objectName + suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] { testPath }, new String[] { "excel" }); + + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + MessageBox.post("","",MessageBox.INFORMATION); + } else if (sourceObj.equals(celButton)) { + + this.disposeDialog(); + this.dispose(); + }else if(sourceObj.equals(searchButton)){ + this.getRootPane().setDefaultButton(selectButton);//õǰĬѡаť + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchS"); + + String[] selectItem=new String[values.length-1]; + String[] selectValue=new String[values.length-1]; + int i=0; + boolean isNull=true; + for(java.util.Map.Entry me:searchMap.entrySet()) { + String key=me.getKey().getText(); + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { + value="*"; + }else { + value="*"+value+"*"; + isNull=false; + } + selectItem[i]=key; + selectValue[i]=value; + i++; + } + + if(isNull==true) { + + MessageBox.post("ĿȫΪ","",MessageBox.INFORMATION); + + }else { + + try { + TCComponent[] comps=session.search(values[0], selectItem, selectValue); + System.out.println("========"+comps.length); + this.disposeDialog(); + this.showDialog(); + radioButton=new JRadioButton[comps.length]; + radioMap=new HashMap(); + resultPanel.removeAll(); +// scrollPane.remove(resultPanel); + bg=new ButtonGroup(); + //ѯóɿõ + String[] properties=session.getPreferenceService().getStringValues("Connor_AVIC_SearchPropertiesS"); + if(comps.length==0) { + + MessageBox.post("ѯΪ","",MessageBox.INFORMATION); + + } + for (int j = 0; j < comps.length; j++) { + TCComponent tcComponent = comps[j]; + String name=""; + for (int k = 0; k < properties.length; k++) { + //ְ汾Ͷ + TCComponent tcComponent0=null; + String[] ps=properties[k].split("\\."); + System.out.println(); + if(ps[0].toUpperCase().equals("REV")){ + tcComponent0=tcComponent; + }else if(ps[0].toUpperCase().equals("REVMASTER")) { + tcComponent0=tcComponent.getRelatedComponents("IMAN_master_form_rev")[0]; + } + name=name+tcComponent0.getProperty(ps[1]); + if(k me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + //ͼţȡitem_id + if(property.startsWith("ͼ")) { + field.setText(item.getProperty("item_id")); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + //Ըֵ + //ƣͺ+ĵ+ˮֹ޸ģ +// JTextField field0=null; +// JComboBox combox1=null; + + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { +// field0=((JTextField)me.getValue()); + } + + if(me.getKey().getText().startsWith("ĵ")) { +// combox1=((JComboBox)me.getValue()); + } + + } + + //ѡڸƣʵļƺļ +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + + } + + } + + String objectName = ""; + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW.java b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW.java new file mode 100644 index 0000000..2f74fca --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordDialogW.java @@ -0,0 +1,779 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.KPropertyLOVDisplayer; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +@SuppressWarnings("unchecked") +public class AlterTechWordDialogW extends AbstractAIFDialog implements ActionListener { + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private JPanel mainJpanel; + private JPanel leftJpanel; + private JPanel basicInfoJpanel; + private JPanel selectItemJpanel; + private JPanel rightJpanel; + private JPanel createInfoJpanel; +// private JTextField pathJTextField; +// private String selectType; +// private String selectSecondDoc; +// private String selectDocCategory; + private JButton okButton; + private JButton celButton; + private JButton searchButton; + private JButton selectButton; + private JCheckBox zjtsyq; + JTextField[] searchField = null; +// JTextField itemNameField=new JTextField(15); + JRadioButton[] radioButton = null; + ButtonGroup bg = new ButtonGroup(); + private JPanel bottomJpanel; + +// private String exportFile; + +// private ProgressBarThread wait; + private TCComponentItemRevision rev=null; + private TCComponentForm form=null; + private TCComponentItem itemX=null; + private TCComponentForm itemFormX=null; + private TCComponentDataset dataset=null; + public AlterTechWordDialogW(AbstractAIFApplication app) { + super(AIFUtility.getActiveDesktop()); + this.app = app; + this.session = (TCSession) app.getSession(); + rev=(TCComponentItemRevision) app.getTargetComponent(); + try { + itemX=rev.getItem(); + form=(TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + itemFormX=(TCComponentForm) itemX.getRelatedComponents("IMAN_master_form")[0]; + TCComponent[] datasets=rev.getRelatedComponents("IMAN_specification"); + if(datasets.length>0) { + dataset=(TCComponentDataset) rev.getRelatedComponents("IMAN_specification")[0]; + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + @Override + public void run() { +// super.run();//ע򴰿ʾ + + try { + readProperty();// excelжȡϢ + } catch (IOException e) { + e.printStackTrace(); + } + + initUI(); + } + + + Map> map1 = new HashMap>(); + Map> map2 = new HashMap>(); + Map> map3 = new HashMap>(); + Map> listMap = new HashMap>(); + String[] excelPre = null; + String[] createInfo = null; + + + + + Map> map1_2 = new HashMap<>(); + Map> map2_3 = new HashMap<>(); + List list_1 = new ArrayList<>();// һֵǷظ + List jcomboxList_1 = new ArrayList<>();// һֵǷظ + List list_2 = new ArrayList<>();// ֵǷظ + List list_3 = new ArrayList<>();// ֵǷظ + + private void readProperty() throws IOException { + excelPre=session.getPreferenceService().getStringValues("Connor_AVIC_NewDocumentBasicW"); + createInfo = session.getPreferenceService().getStringValues("Connor_AVIC_AlterDocumentCreationW"); + createLabel = new JLabel[createInfo.length]; + createText = new JTextField[createInfo.length]; + createCom = new JComboBox[createInfo.length]; + + } + + JLabel[] createLabel = null; + JTextField[] createText = null; + JComboBox[] createCom = null; + Dimension dimension = new Dimension(150, 30); + Map basicMap = new HashMap(); + Map basicPropertyMap = new HashMap(); + Map createMap = new HashMap(); + Map searchMap = new HashMap(); + DefaultComboBoxModel model1 = null; + DefaultComboBoxModel model2 = null; + DefaultComboBoxModel model3 = null; + JLabel[] basicLabel=null; + JLabel[] searchLabel=null; + JTextField[] basicText=null; + private void initUI() { + this.setTitle("ͱĵ޸"); + + okButton = new JButton("޸"); + okButton.addActionListener(this); + this.getRootPane().setDefaultButton(searchButton);//õǰĬѡаť + celButton = new JButton("ȡ"); + celButton.addActionListener(this); + searchButton = new JButton("ѯ"); + searchButton.addActionListener(this); + selectButton = new JButton("ѡ"); + selectButton.addActionListener(this); + + this.setLayout(new BorderLayout()); + + this.setSize(850, 550); + mainJpanel = new JPanel(new PropertyLayout()); + mainJpanel.setPreferredSize(new Dimension(950, 450)); + leftJpanel = new JPanel(new PropertyLayout()); + leftJpanel.setPreferredSize(new Dimension(500, 450)); + basicInfoJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel.setPreferredSize(new Dimension(500, 300)); + rightJpanel = new JPanel(new PropertyLayout()); + rightJpanel.setPreferredSize(new Dimension(450, 350)); + createInfoJpanel = new JPanel(new PropertyLayout()); +// createInfoJpanel.setPreferredSize(new Dimension(400, 280)); +basicInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + + basicLabel=new JLabel[excelPre.length-2]; + basicText=new JTextField[excelPre.length-2]; + int a=2; + for (int i = 1; i < excelPre.length-1; i++) { + String[] proValue = excelPre[i].split("="); + if(i>3) { + + basicLabel[i-1]=new JLabel(proValue[0]); + basicLabel[i-1].setPreferredSize(new Dimension(90,25)); + String value2= proValue[1]; + + if(value2.toLowerCase().startsWith("itemrevisionmaster")) { + basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + basicInfoJpanel.add(a+".2.left.top", basicLabel[i-1]); + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + } +// else if(value2.toLowerCase().startsWith("sheet")) { +// basicText[i-1]=new JTextField(15); +// basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); +// basicMap.put(basicLabel[i-1],basicText[i-1]); +// basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); +// } + a++; + } + } + leftJpanel.add("1.1.left.top",basicInfoJpanel); + + int i=1; + selectItemJpanel.add(i+".1.left.top",new JLabel("ѡ ")); + i++; +// selectItemJpanel.add(i+".1.left.top",new JLabel(" ѯѡ")); +// i++; + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchW"); + searchLabel=new JLabel[values.length-1]; + + searchField=new JTextField[values.length-1]; + for (int j = 0; j < searchField.length; j++) { + searchField[j]=new JTextField(15); + searchLabel[j]=new JLabel(values[j+1]); + searchLabel[j].setPreferredSize(new Dimension(90,25)); + searchMap.put(searchLabel[j], searchField[j]); + } + +// session.search(arg0, arg1, arg2) + for (int j = 1; j < values.length; j++) { +// String string = values[j]; + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + selectItemJpanel.add(i+".2.left.top",searchLabel[j-1]); + selectItemJpanel.add(i+".3.left.top",searchField[j-1]); + if(j==values.length-1) { + selectItemJpanel.add(i+".4.left.top",searchButton); + } + i++; + + } + + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + JLabel label= new JLabel("ѯ"); + label.setPreferredSize(new Dimension(90,25)); + selectItemJpanel.add(i+".2.left.top",label); + resultPanel=new JPanel(new PropertyLayout()); + + scrollPane=new JScrollPane(resultPanel); + scrollPane.setPreferredSize(new Dimension(250,150)); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + selectItemJpanel.add(i+".3.left.top",scrollPane); + selectItemJpanel.add(i+".4.left.top",selectButton); + +// leftJpanel.add("2.1.left.top",selectItemJpanel); + + + createInfoJpanel.add("1.1.left.top", + new JLabel("Ϣ")); + int b = 2; + for (int j = 0; j < createInfo.length; j++) { + createInfoJpanel.add(b + ".1.left.top", new JLabel(" ")); + String[] string = createInfo[j].split("="); + createLabel[j] = new JLabel(string[0]); + createLabel[j].setPreferredSize(new Dimension(90, 25)); + createInfoJpanel.add(b + ".2.left.top", createLabel[j]); + String[] string2=string[1].split(":"); + if (string2.length > 1) { + if(string2[0].startsWith("#")) {//TODO + createCom[j] = new MultiCombo(session.getPreferenceService().getStringValues(string2[0].substring(1))); + createCom[j].setPreferredSize(new Dimension(250, 30)); + createCom[j].setEditable(true); + createMap.put(createLabel[j], createCom[j]); + createInfoJpanel.add(b+".3.left.top", createCom[j]); + try { + String[] propertyInfo=string2[1].split("\\."); + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + ((MultiCombo)createCom[j]).setValue(form.getProperty(propertyInfo[1])); + }else if(propertyInfo[0].toUpperCase().equals("ITEM")) { + ((MultiCombo)createCom[j]).setValue(itemX.getProperty(propertyInfo[1])); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + b++; + continue; + } + DefaultComboBoxModel model; + String[] lovs = string2[0].split(";"); + List list = new ArrayList(); + for (int k = 0; k < lovs.length; k++) { + list.add(lovs[k]); + + } + + model = new DefaultComboBoxModel(list.toArray(new String[list.size()])); + createCom[j] = new JComboBox<>(model); + String[] propertyInfo=string2[1].split("\\."); + String propertyValue=""; + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + try { + propertyValue=form.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + createCom[j].setSelectedItem(propertyValue); + createCom[j].setPreferredSize(new Dimension(100, 30)); + createMap.put(createLabel[j], createCom[j]); + createInfoJpanel.add(b + ".3.left.top", createCom[j]); + if(string[0].equals("ܼ")) { + DocumentUtil.mjCom=createCom[j]; + createMap.put(createLabel[j], DocumentUtil.mjCom); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.mjCom); + + createCom[j].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + try { + System.out.println("ip_clearance==========="+session.getUser().getStringProperty("ip_clearance")); + } catch (TCException e2) { + e2.printStackTrace(); + } + + System.out.println("ѡ====="+e.getItem().toString()); + if (e.getStateChange() == ItemEvent.SELECTED) { + try { + KPropertyLOVDisplayer.checkIP(e.getItem().toString()); + } catch (Exception e1) { + DocumentUtil.mjCom.setSelectedIndex(-1); + MessageBox.post("ûܼ޸ĺִܼܹд˲","",MessageBox.INFORMATION); + } + + } + } + }); + } + } else { + createText[j] = new JTextField(15); + createMap.put(createLabel[j], createText[j]); + String[] propertyInfo=string[1].split("\\."); + String propertyValue=""; + TCComponent x=null; + if(propertyInfo[0].toUpperCase().equals("REVMASTER")) { + x=form; + }else if(propertyInfo[0].toUpperCase().equals("REV")) { + x=rev; + }else if(propertyInfo[0].toUpperCase().equals("DATASET")) { + if(dataset!=null) { + + x=dataset; + } + } + if(x!=null) { + + try { + System.out.println(x==null); + System.out.println(propertyInfo[1]); + System.out.println(x.getTCProperty(propertyInfo[1])==null); + propertyValue=x.getTCProperty(propertyInfo[1]).getDisplayValue(); + } catch (TCException e1) { + e1.printStackTrace(); + } + createText[j].setText(propertyValue); + createInfoJpanel.add(b + ".3.left.top", createText[j]); + } + } + + b++; + + } + + rightJpanel.add("1.1.left.top", createInfoJpanel); + + mainJpanel.add("1.1.left.top",leftJpanel); + mainJpanel.add("1.2.left.top", rightJpanel); + bottomJpanel = new JPanel(new FlowLayout()); + bottomJpanel.add(okButton); + bottomJpanel.add(celButton); + // ͨȡѡЩؼɱ༭(jlabel*,*Ҳü) + String[] editable = session.getPreferenceService().getStringValues("Connor_AVIC_AlterEditableW"); + for (int j = 0; j < editable.length; j++) { + boolean boo = false; + String string = editable[j]; + boo = DocumentUtil.setEditable(createMap, string); + if (boo == false) { + + boo = DocumentUtil.setEditable(basicMap, string); + if (boo == false) { + + DocumentUtil.setEditable(searchMap, string); + } + } + + } + zjtsyq=new JCheckBox("Ҫ"); + zjtsyq.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTextField field=null; + JTextField field1=null; + JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("ļ")) { + field=((JTextField)me.getValue()); + } + + } + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { + field1=((JTextField)me.getValue()); + } + if(me.getKey().getText().startsWith("ͼ")) { + field2=((JTextField)me.getValue()); + } + + } + if(zjtsyq.isSelected()) { + field.setEditable(true); + field1.setEditable(true); + field2.setEditable(true); + }else { + field.setEditable(false); + field1.setEditable(false); + field2.setEditable(false); + } + } + }); + for(Map.Entry me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + try { + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + + } +// this.add(zjtsyq,BorderLayout.NORTH); + this.add(mainJpanel, BorderLayout.CENTER); + this.add(bottomJpanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + JPanel resultPanel = new JPanel(new PropertyLayout()); + JScrollPane scrollPane = new JScrollPane(resultPanel); + + Map radioMap=new HashMap(); + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObj = e.getSource(); + if (sourceObj.equals(okButton)) { + + try { + TCComponentDataset newdataset =null; + if(dataset!=null) { + newdataset=dataset; + } + // + JTextField field2 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("")) { + field2 = ((JTextField) me.getValue()); + } + + } + rev.setStringProperty("object_name", field2.getText()); + // ʵļ + JTextField field3 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("ʵļ")) { + field3 = ((JTextField) me.getValue()); + } + + } + objectName = field3.getText(); + if(newdataset!=null) { + + newdataset.setStringProperty("object_name", field3.getText()); + } + + String[] propertyName = session.getPreferenceService().getStringValues("Connor_AVIC_SetFormPropertyW"); + Map mapX = new HashMap<>(); + for (int i = 0; i < propertyName.length; i++) { + String[] value = propertyName[i].split("="); + mapX.put(value[0], value[1]); + } + Map propertyValue = new HashMap<>(); + for (java.util.Map.Entry me : basicMap.entrySet()) { + if (mapX.containsKey(me.getKey().getText())) { + String value = ""; + try { + value = ((JTextField) me.getValue()).getText(); + } catch (Exception e1) { + value = (String) ((JComboBox) me.getValue()).getSelectedItem(); + } + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + + } + for (java.util.Map.Entry me : createMap.entrySet()) { + if (mapX.containsKey(me.getKey().getText())) { + String value = ""; + Object comp = me.getValue(); + if(comp instanceof MultiCombo) + value = ((MultiCombo)comp).getValue();//TODO + else if(comp instanceof JTextField) + value=((JTextField)comp).getText(); + else + value=(String)((JComboBox)comp).getSelectedItem(); + TCComponent tarForm=((TCComponent) app.getTargetComponent()).getRelatedComponents("IMAN_master_form_rev")[0]; + if(!tarForm.getProperty("ac5_DocumentNumber").equals(value)) { + if(me.getKey().getText().contains("ļ")) { + TCComponent[] comps; + try { + comps = session.search("DocSearch1", new String[] {"ĵ"}, new String[] {value}); + if(comps.length>0) { + + MessageBox.post("","ļŲΨһ޸",MessageBox.INFORMATION); + + return; + }else { + this.disposeDialog(); + this.dispose(); + } + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } + }else { + this.disposeDialog(); + this.dispose(); + } + + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + this.disposeDialog(); + this.dispose(); + } + for (java.util.Map.Entry me : propertyValue.entrySet()) { + TCComponent tccomponentX = form; + String objectType = me.getKey().split("\\.")[0]; + String valueType = me.getKey().split("\\.")[1].split(":")[1]; + String pname = me.getKey().split("\\.")[1].split(":")[0]; + if (objectType.toLowerCase().equals("itemrevisionmaster")) { + tccomponentX = form; + } + if (valueType.toLowerCase().equals("text")) { + tccomponentX.setStringProperty(pname, me.getValue()); + } else if (valueType.toLowerCase().equals("lov")) { + String trueValue = (String) tccomponentX.getTCProperty(pname).getLOV().getListOfValues() + .getRealValue(me.getValue()); + tccomponentX.setStringProperty(pname, trueValue); + if(pname.equals("ip_classification")) { + System.out.println("ܼ================"+trueValue); + itemX.setStringProperty(pname, trueValue); + form.setStringProperty(pname, trueValue); + itemFormX.setStringProperty(pname, trueValue); + rev.setStringProperty(pname, trueValue); + + } + } + } + if(newdataset!=null) { + + // ͨcmdķʽwsfļϣҪעexcelword + // ļ + String testPath = ""; + testPath = DocumentUtil.downLoadFile(newdataset); + // ļ + String dataFile = ""; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm") || testPath.endsWith(".docx") + || testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx") || testPath.endsWith(".xls")) { + try { + dataFile = DocumentUtil.jk_SetCAXAFile("Connor_AVIC_NewDocumentThesignW",session,newdataset, true); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + String wsfType = "word"; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm") || testPath.endsWith(".docx")) { + wsfType = "word"; + } else if (testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx") || testPath.endsWith(".xls")) { + wsfType = "excel"; + } + // ȡwsfļλ,滻 + String wsfpath = null; + File file = new File(testPath); + String path = testPath.substring(0, testPath.lastIndexOf("\\") + 1); + String suffix = testPath.substring(testPath.lastIndexOf("."), testPath.length()); + System.out.println(path); + System.out.println(suffix); + try { + if (wsfType.equals("word")) { + + wsfpath = DocumentUtil.getFileFromClass(getClass(), "SubstMacros-MSWord.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath, new String[] { testPath, dataFile }); + + // ļ + testPath = path + objectName + suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] { testPath }, new String[] { "word" }); + } else if (wsfType.equals("excel")) { + wsfpath =DocumentUtil.getFileFromClass(getClass(), "SubstMacros-MSExcel.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath, new String[] { testPath, dataFile }); + // ļ + testPath = path + objectName + suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] { testPath }, new String[] { "excel" }); + + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + MessageBox.post("","",MessageBox.INFORMATION); + } else if (sourceObj.equals(celButton)) { + + this.disposeDialog(); + this.dispose(); + }else if(sourceObj.equals(searchButton)){ + this.getRootPane().setDefaultButton(selectButton);//õǰĬѡаť + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchW"); + + String[] selectItem=new String[values.length-1]; + String[] selectValue=new String[values.length-1]; + int i=0; + boolean isNull=true; + for(java.util.Map.Entry me:searchMap.entrySet()) { + String key=me.getKey().getText(); + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { + value="*"; + }else { + value="*"+value+"*"; + isNull=false; + } + selectItem[i]=key; + selectValue[i]=value; + i++; + } + + if(isNull==true) { + + MessageBox.post("ĿȫΪ","",MessageBox.INFORMATION); + + }else { + + try { + TCComponent[] comps=session.search(values[0], selectItem, selectValue); + System.out.println("========"+comps.length); + this.disposeDialog(); + this.showDialog(); + radioButton=new JRadioButton[comps.length]; + radioMap=new HashMap(); + resultPanel.removeAll(); +// scrollPane.remove(resultPanel); + bg=new ButtonGroup(); + //ѯóɿõ + String[] properties=session.getPreferenceService().getStringValues("Connor_AVIC_SearchPropertiesW"); + if(comps.length==0) { + + MessageBox.post("ѯΪ","",MessageBox.INFORMATION); + + } + for (int j = 0; j < comps.length; j++) { + TCComponent tcComponent = comps[j]; + String name=""; + for (int k = 0; k < properties.length; k++) { + //ְ汾Ͷ + TCComponent tcComponent0=null; + String[] ps=properties[k].split("\\."); + System.out.println(); + if(ps[0].toUpperCase().equals("REV")){ + tcComponent0=tcComponent; + }else if(ps[0].toUpperCase().equals("REVMASTER")) { + tcComponent0=tcComponent.getRelatedComponents("IMAN_master_form_rev")[0]; + } + name=name+tcComponent0.getProperty(ps[1]); + if(k me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + //ͼţȡitem_id + if(property.startsWith("ͼ")) { + field.setText(item.getProperty("item_id")); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + //Ըֵ + //ƣͺ+ĵ+ˮֹ޸ģ +// JTextField field0=null; +// JComboBox combox1=null; + + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { +// field0=((JTextField)me.getValue()); + } + + if(me.getKey().getText().startsWith("ĵ")) { +// combox1=((JComboBox)me.getValue()); + } + + } + + //ѡڸƣʵļƺļ +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + + } + + } + + String objectName = ""; + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/AlterTechWordHandler.java b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordHandler.java new file mode 100644 index 0000000..a0cfc25 --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/AlterTechWordHandler.java @@ -0,0 +1,86 @@ +package com.connor.pro105.plm.creatTechWord; + +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; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.util.MessageBox; + +public class AlterTechWordHandler extends AbstractHandler { + ; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandID=arg0.getCommand().getId(); + AbstractAIFApplication app=AIFUtility.getCurrentApplication(); + if(app.getTargetComponent()==null) { + MessageBox.post("ѡĵ汾","",MessageBox.INFORMATION); + }else { + + try { + System.out.println(app.getTargetComponent().getProperty("object_type")); + if(commandID.equals("alterTechWordC")) { + if( app.getTargetComponent().getProperty("object_type").equals("ĵ汾")||app.getTargetComponent().getProperty("object_type").equals("Civil Doc Revision") + ) { + if(((TCComponent)app.getTargetComponent()).getProperty("release_status_list").length()>0) { + MessageBox.post("ļѷ޸","",MessageBox.INFORMATION); + } else { + + AlterTechWordAction action=new AlterTechWordAction(commandID,app,null); + new Thread(action).start(); + } + }else { + MessageBox.post("ѡĵ汾","",MessageBox.INFORMATION); + } + }else if(commandID.equals("alterTechWordM")) { + if( app.getTargetComponent().getProperty("object_type").equals("ĵ汾")||app.getTargetComponent().getProperty("object_type").equals("Military Doc Revision") + ) { + if(((TCComponent)app.getTargetComponent()).getProperty("release_status_list").length()>0) { + MessageBox.post("ļѷ޸","",MessageBox.INFORMATION); + } else { + + AlterTechWordAction action=new AlterTechWordAction(commandID,app,null); + new Thread(action).start(); + } + }else { + MessageBox.post("ѡĵ汾","",MessageBox.INFORMATION); + } + }else if(commandID.equals("alterTechWordW")) { + if( app.getTargetComponent().getProperty("object_type").equals("ͱĵ汾")||app.getTargetComponent().getProperty("object_type").equals("General Doc Revision") + ) { + if(((TCComponent)app.getTargetComponent()).getProperty("release_status_list").length()>0) { + MessageBox.post("ļѷ޸","",MessageBox.INFORMATION); + } else { + + AlterTechWordAction action=new AlterTechWordAction(commandID,app,null); + new Thread(action).start(); + } + }else { + MessageBox.post("ѡͱĵ汾","",MessageBox.INFORMATION); + } + }else if(commandID.equals("alterTechWordS")) { + if( app.getTargetComponent().getProperty("object_type").equals("ĵ汾")||app.getTargetComponent().getProperty("object_type").equals("Soft Tech Doc Revision") + ) { + if(((TCComponent)app.getTargetComponent()).getProperty("release_status_list").length()>0) { + MessageBox.post("ļѷ޸","",MessageBox.INFORMATION); + } else { + + AlterTechWordAction action=new AlterTechWordAction(commandID,app,null); + new Thread(action).start(); + } + }else { + MessageBox.post("ѡĵ汾","",MessageBox.INFORMATION); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/CreatTechWordAction.java b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordAction.java new file mode 100644 index 0000000..4c83026 --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordAction.java @@ -0,0 +1,52 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMViewRevision; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; + +public class CreatTechWordAction extends AbstractAIFAction { +private AbstractAIFApplication app; +String opType; +String commandID; + + public CreatTechWordAction(String commandID,String opType, AbstractAIFApplication app, String String) { + super(app, String); + this.opType=opType; + this.app=app; + this.commandID=commandID; + } + + + @Override + public void run() { + if(commandID.equals("creatTechWordC")) { + + CreatTechWordDialogC dialog=new CreatTechWordDialogC(opType,app); + new Thread(dialog).start(); + }else if(commandID.equals("creatTechWordM")) { + + CreatTechWordDialogM dialog=new CreatTechWordDialogM(opType,app); + new Thread(dialog).start(); + }else if(commandID.equals("creatTechWordW")) { + + CreatTechWordDialogW dialog=new CreatTechWordDialogW(opType,app); + new Thread(dialog).start(); + }else if(commandID.equals("creatTechWordS")) { + + CreatTechWordDialogS dialog=new CreatTechWordDialogS(opType,app); + new Thread(dialog).start(); + } + + + + } + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/CreatTechWordBean.java b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordBean.java new file mode 100644 index 0000000..af3f3f1 --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordBean.java @@ -0,0 +1,121 @@ +package com.connor.pro105.plm.creatTechWord; + +public class CreatTechWordBean { + + private String item_id;//Ŀպ + public String getItem_id() { + return item_id; + } + public void setItem_id(String item_id) { + this.item_id = item_id; + } + public String getXmlh() { + return xmlh; + } + public void setXmlh(String xmlh) { + this.xmlh = xmlh; + } + public String getHxc8jingli() { + return hxc8jingli; + } + public void setHxc8jingli(String hxc8jingli) { + this.hxc8jingli = hxc8jingli; + } + public String getHxc8cp() { + return hxc8cp; + } + public void setHxc8cp(String hxc8cp) { + this.hxc8cp = hxc8cp; + } + public String getHxc8kh() { + return hxc8kh; + } + public void setHxc8kh(String hxc8kh) { + this.hxc8kh = hxc8kh; + } + public String getHxc8cxdm() { + return hxc8cxdm; + } + public void setHxc8cxdm(String hxc8cxdm) { + this.hxc8cxdm = hxc8cxdm; + } + public String getHxc8scjd() { + return hxc8scjd; + } + public void setHxc8scjd(String hxc8scjd) { + this.hxc8scjd = hxc8scjd; + } + public String getHxc8ycl() { + return hxc8ycl; + } + public void setHxc8ycl(String hxc8ycl) { + this.hxc8ycl = hxc8ycl; + } + public String getHxc8jieduan() { + return hxc8jieduan; + } + public void setHxc8jieduan(String hxc8jieduan) { + this.hxc8jieduan = hxc8jieduan; + } + public String getHxc8miaoshu() { + return hxc8miaoshu; + } + public void setHxc8miaoshu(String hxc8miaoshu) { + this.hxc8miaoshu = hxc8miaoshu; + } + public String getHxc8result() { + return hxc8result; + } + public void setHxc8result(String hxc8result) { + this.hxc8result = hxc8result; + } + public String getHxc8risk() { + return hxc8risk; + } + public void setHxc8risk(String hxc8risk) { + this.hxc8risk = hxc8risk; + } + public String getHxc8plan() { + return hxc8plan; + } + public void setHxc8plan(String hxc8plan) { + this.hxc8plan = hxc8plan; + } + public String getHxc8finish() { + return hxc8finish; + } + public void setHxc8finish(String hxc8finish) { + this.hxc8finish = hxc8finish; + } + public String getHxc8zr() { + return hxc8zr; + } + public void setHxc8zr(String hxc8zr) { + this.hxc8zr = hxc8zr; + } + public String getHxc8open() { + return hxc8open; + } + public void setHxc8open(String hxc8open) { + this.hxc8open = hxc8open; + } + private String xmlh;//Ŀ + private String hxc8jingli;//Ŀ + private String hxc8cp;//Ʒ + private String hxc8kh;//ͻ + private String hxc8cxdm;//ʹ + private String hxc8scjd;// + private String hxc8ycl;//Ԥ + private String hxc8jieduan;//Ŀ׶ + private String hxc8miaoshu;/// + private String hxc8result;//Ӱ/ + private String hxc8risk;//յȼ + private String hxc8plan;//Ӧʩ/ƻ + private String hxc8finish;//ƻ + private String hxc8zr;// + private String hxc8open;///ر + + + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC.java b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC.java new file mode 100644 index 0000000..1c6c96d --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogC.java @@ -0,0 +1,850 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.KPropertyLOVDisplayer; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +@SuppressWarnings("unchecked") +public class CreatTechWordDialogC extends AbstractAIFDialog implements ActionListener{ + /** + * + */ + private static final long serialVersionUID = 1L; + + private AbstractAIFApplication app; + private TCSession session; + private JPanel mainJpanel; + private JPanel leftJpanel; + private JPanel basicInfoJpanel; + private JPanel selectItemJpanel; + private JPanel rightJpanel; + private JCheckBox zjtsyq; + private JPanel createInfoJpanel; +// private JTextField pathJTextField; + private String selectSecondDoc; + private String selectDocCategory; + private JButton okButton; + private JButton celButton; + private JButton searchButton; + private JButton selectButton; + + JTextField[] searchField=null; +// JTextField itemNameField=new JTextField(15); + JRadioButton[] radioButton=null; + ButtonGroup bg=new ButtonGroup(); + private JPanel bottomJpanel; + +// private String exportFile; + +// private ProgressBarThread wait; + String opType; + public CreatTechWordDialogC(String opType, AbstractAIFApplication app) { + super(AIFUtility.getActiveDesktop()); + this.app=app; + this.opType=opType; + this.session=(TCSession) app.getSession(); + } + + @Override + public void run() { +// super.run();//ע򴰿ʾ + try { + DocumentUtil.readProperty( session, "Connor_AVIC_NewDocumentBasicC", "Connor_AVIC_NewDocumentCreationC");//excelжȡϢ + } catch (IOException e) { + e.printStackTrace(); + } + initUI(); + } + + + + + Dimension dimension=new Dimension(250,30); + JLabel[] basicLabel=null; + JLabel[] searchLabel=null; + JTextField[] basicText=null; + JComboBox[] basicCom=null; + Map basicMap=new HashMap(); + Map basicPropertyMap=new HashMap(); + Map basicMap2=new LinkedHashMap();//ź׺Ϣ + Map createMap=new HashMap(); + Map searchMap=new HashMap(); + DefaultComboBoxModel model1=null; + DefaultComboBoxModel model2=null; + DefaultComboBoxModel model3=null; + List listq=null; + + private void initUI() { + this.setTitle("ĵ"); + + okButton=new JButton(""); + okButton.addActionListener(this); + celButton=new JButton("ȡ"); + celButton.addActionListener(this); + searchButton=new JButton("ѯ"); + this.getRootPane().setDefaultButton(searchButton);//õǰĬѡаť + searchButton.addActionListener(this); + selectButton=new JButton("ѡ"); + selectButton.addActionListener(this); + + + this.setLayout(new BorderLayout()); + this.setSize(850, 550); + mainJpanel = new JPanel(new PropertyLayout()); + mainJpanel.setPreferredSize(new Dimension(950, 600)); + leftJpanel = new JPanel(new PropertyLayout()); + leftJpanel.setPreferredSize(new Dimension(500, 600)); + basicInfoJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel.setPreferredSize(new Dimension(500, 300)); + rightJpanel = new JPanel(new PropertyLayout()); + rightJpanel.setPreferredSize(new Dimension(550, 350)); + createInfoJpanel = new JPanel(new PropertyLayout()); +// createInfoJpanel.setPreferredSize(new Dimension(400, 280)); + + basicInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + + basicLabel=new JLabel[DocumentUtil.excelPre.length-2]; + basicText=new JTextField[DocumentUtil.excelPre.length-2]; + basicCom=new JComboBox[3]; + + String houzhui=""; + int a=2; + for (int i = 1; i < DocumentUtil.excelPre.length-1; i++) { + String[] proValue = DocumentUtil.excelPre[i].split("="); + basicLabel[i-1]=new JLabel(proValue[0]); + basicLabel[i-1].setPreferredSize(new Dimension(90,25)); + String value2= proValue[1]; + basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + basicInfoJpanel.add(a+".2.left.top", basicLabel[i-1]); + + if(value2.toLowerCase().startsWith("itemrevisionmaster")) { + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + }else if(value2.toLowerCase().startsWith("sheet")){ + // sheetʹӱлȡֵ һ=sheet.itemrevisionmaster.ac5_yjjh + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicMap2.put(basicLabel[i-1],basicText[i-1]); +// basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + }else { + if(i==1) { + model1=new DefaultComboBoxModel(DocumentUtil.jcomboxList_1.toArray(new String[DocumentUtil.jcomboxList_1.size()])); + basicCom[0]=new JComboBox<>(model1); + basicCom[0].setPreferredSize(dimension); + basicCom[0].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getItem() != null) { + DocumentUtil.selectType = (String) e.getItem(); + System.out.println("1ѡ==="+DocumentUtil.selectType); + List list=DocumentUtil.map1_2.get(DocumentUtil.selectType); + List list2=new ArrayList<>(); + model2.removeAllElements(); +// basicCom[1].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + System.out.println(string); + list2.add(string.split("###")[1]); + model2.addElement(string.split("###")[1]); +// basicCom[1].addItem(string.split("###")[1]); + } +// model2=new DefaultComboBoxModel(list2.toArray(new String[list2.size()])); +// basicCom[1]=new JComboBox(model2); + } + } + }); + }else if(i==2) { + String xx=DocumentUtil.jcomboxList_1.get(0); + List list=DocumentUtil.map1_2.get(xx); + List list2=new ArrayList<>(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + System.out.println(string); + list2.add(string.split("###")[1]); + + } + model2=new DefaultComboBoxModel(list2.toArray(new String[list2.size()])); + basicCom[1]=new JComboBox<>(model2); + basicCom[1].setPreferredSize(dimension); + basicCom[1].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + + if(e.getStateChange()==ItemEvent.SELECTED) { + if(DocumentUtil.selectType==null) { + DocumentUtil.selectType = (String) basicCom[0].getSelectedItem(); + } + selectSecondDoc = (String) e.getItem(); + System.out.println("2ѡ==="+DocumentUtil.selectType+"###"+selectSecondDoc+"www"); + List list=DocumentUtil.map2_3.get(DocumentUtil.selectType+"###"+selectSecondDoc); + listq=new ArrayList(); + model3.removeAllElements(); +// basicCom[2].removeAllItems(); + + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + + System.out.println(Thread.currentThread().getStackTrace()[1].getLineNumber()+string); + model3.addElement(string.split("-")[0]);//غ׺ + listq.add(string); +// basicCom[2].addItem(string); + + } + DocumentUtil.sethouzhui(listq, selectDocCategory, basicMap2); + } + } + }); + }else if(i==3) { + String xx=DocumentUtil.jcomboxList_1.get(0); + List list=DocumentUtil.map1_2.get(xx); + List list2=DocumentUtil.map2_3.get(list.get(0)); + final List list2New=new ArrayList(); + + for (int j = 0; j < list2.size(); j++) { + list2New.add(list2.get(j).split("-")[0]); + } + + houzhui=list2.get(0); + + System.out.println("houzhui======"+houzhui); + model3=new DefaultComboBoxModel(list2New.toArray(new String[list2New.size()])); + basicCom[2]=new JComboBox<>(model3); + basicCom[2].setPreferredSize(dimension); + basicCom[2].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if(e.getStateChange()==ItemEvent.SELECTED) { + + selectDocCategory = (String) e.getItem(); + System.out.println("3ѡ==="+selectDocCategory); + DocumentUtil.reset(basicMap, createMap); +// setFileName2(); + if(listq==null) { + System.out.println("3ѡ0==="+(String)basicCom[0].getItemAt(0)+"###"+(String)basicCom[1].getItemAt(0)+"www"); + selectSecondDoc = (String)basicCom[1].getSelectedItem(); + DocumentUtil.selectType= (String)basicCom[0].getSelectedItem(); + System.out.println("3ѡ1==="+DocumentUtil.selectType+"###"+selectSecondDoc+"www"); + List list=DocumentUtil.map2_3.get(DocumentUtil.selectType+"###"+selectSecondDoc); + listq=new ArrayList(); +// basicCom[2].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + + System.out.println(Thread.currentThread().getStackTrace()[1].getLineNumber()+string); + model3.addElement(string.split("-")[0]);//غ׺ + listq.add(string); +// basicCom[2].addItem(string); + + } + } + DocumentUtil.sethouzhui(listq, selectDocCategory, basicMap2); + + } + } + }); + } + + + + + + basicInfoJpanel.add(a+".3.left.top", basicCom[i-1]); + basicMap.put(basicLabel[i-1],basicCom[i-1]); + } + a++; + } + + /* + * for(java.util.Map.Entry me:basicMap.entrySet()) { + * basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + * basicInfoJpanel.add(a+".2.left.top", me.getKey()); + * basicInfoJpanel.add(a+".3.left.top", (Component) me.getValue()); a++; } + */ + /* + * for (int i = 1; i < excelPre.length; i++) { String[] proValue = + * excelPre[i].split("="); basicInfoJpanel.add(i+".1.left.top",new + * JLabel(" ")); basicInfoJpanel.add(i+".2.left.top", new JLabel(proValue[0])); + * + * } + */ + + + //״μ + int count1 = 1; + for (Map.Entry me : basicMap2.entrySet()) { + JTextField field = (JTextField) me.getValue(); + field.setText(houzhui.split("-")[count1]); + count1++; + } + + + + leftJpanel.add("1.1.left.top",basicInfoJpanel); + int i=1; + selectItemJpanel.add(i+".1.left.top",new JLabel("ѡ ")); + i++; +// selectItemJpanel.add(i+".1.left.top",new JLabel(" ѯѡ")); +// i++; + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchC"); + searchLabel=new JLabel[values.length-1]; + + searchField=new JTextField[values.length-1]; + for (int j = 0; j < searchField.length; j++) { + searchField[j]=new JTextField(15); + searchLabel[j]=new JLabel(values[j+1]); + searchLabel[j].setPreferredSize(new Dimension(90,25)); + searchMap.put(searchLabel[j], searchField[j]); + } + +// session.search(arg0, arg1, arg2) + for (int j = 1; j < values.length; j++) { +// String string = values[j]; + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + selectItemJpanel.add(i+".2.left.top",searchLabel[j-1]); + selectItemJpanel.add(i+".3.left.top",searchField[j-1]); + if(j==values.length-1) { + selectItemJpanel.add(i+".4.left.top",searchButton); + } + i++; + + } + + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + JLabel label= new JLabel("ѯ"); + label.setPreferredSize(new Dimension(90,25)); + selectItemJpanel.add(i+".2.left.top",label); + resultPanel=new JPanel(new PropertyLayout()); + + scrollPane=new JScrollPane(resultPanel); + scrollPane.setPreferredSize(new Dimension(250,150)); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + selectItemJpanel.add(i+".3.left.top",scrollPane); + selectItemJpanel.add(i+".4.left.top",selectButton); + + leftJpanel.add("2.1.left.top",selectItemJpanel); + + createInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + int b=2; + for (int j = 0; j < DocumentUtil.createInfo.length; j++) { + createInfoJpanel.add(b+".1.left.top",new JLabel(" ")); + String[] string = DocumentUtil.createInfo[j].split("="); + DocumentUtil.createLabel[j]=new JLabel(string[0]); + DocumentUtil.createLabel[j].setPreferredSize(new Dimension(90,25)); + createInfoJpanel.add(b+".2.left.top",DocumentUtil.createLabel[j]); + if(string.length>1) { + if(string[1].startsWith("#")) {//TODO + DocumentUtil.createCom[j] = new MultiCombo(session.getPreferenceService().getStringValues(string[1].substring(1))); + DocumentUtil.createCom[j].setPreferredSize(new Dimension(250, 30)); + DocumentUtil.createCom[j].setEditable(true); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createCom[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createCom[j]); + b++; + continue; + } + DefaultComboBoxModel model; + String[] lovs=string[1].split(";"); + List list=new ArrayList(); + for (int k = 0; k < lovs.length; k++) { + list.add(lovs[k]); + + } + + model=new DefaultComboBoxModel(list.toArray(new String[list.size()])); + DocumentUtil.createCom[j]=new JComboBox<>(model); + DocumentUtil.createCom[j].setPreferredSize(new Dimension(150, 30)); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createCom[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createCom[j]); + if(string[0].equals("ܼ")) { + DocumentUtil.mjCom=DocumentUtil.createCom[j]; + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.mjCom); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.mjCom); + + DocumentUtil.createCom[j].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + try { + System.out.println("ip_clearance==========="+session.getUser().getStringProperty("ip_clearance")); + } catch (Exception e2) { + e2.printStackTrace(); + } + + System.out.println("ѡ====="+e.getItem().toString()); + if (e.getStateChange() == ItemEvent.SELECTED) { + try { + KPropertyLOVDisplayer.checkIP(e.getItem().toString()); + } catch (Exception e1) { + DocumentUtil.mjCom.setSelectedIndex(-1); + MessageBox.post("ûܼ޸ĺִܼܹд˲","",MessageBox.INFORMATION); + } + + } + } + }); + } + }else { + DocumentUtil.createText[j]=new JTextField(15); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createText[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createText[j]); + } + + b++; + + } + for(java.util.Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʋ")) { + String groupName=null; + try { +// groupName = session.getGroup().getFullName();//Ҫػ + groupName=session.getGroup().getProperty("display_name");//ȡײ + if(groupName.split("\\.").length>0) { + groupName=groupName.split("\\.")[0]; + } + } catch (Exception e1) { + e1.printStackTrace(); + } + ((JTextField)me.getValue()).setText(groupName); + } + + } + rightJpanel.add("1.1.left.top",createInfoJpanel); + + mainJpanel.add("1.1.left.top",leftJpanel); + mainJpanel.add("1.2.left.top",rightJpanel); + bottomJpanel=new JPanel(new FlowLayout()); + bottomJpanel.add(okButton); + bottomJpanel.add(celButton); + //ͨȡѡЩؼɱ༭(jlabel*,*Ҳü) + String[] editable=session.getPreferenceService().getStringValues("Connor_AVIC_editableC"); + for (int j = 0; j < editable.length; j++) { + boolean boo=false; + String string = editable[j]; + boo=DocumentUtil.setEditable(createMap,string); + if(boo==false) { + + boo=DocumentUtil.setEditable(basicMap,string); + if(boo==false) { + + DocumentUtil.setEditable(searchMap,string); + } + } + + } + zjtsyq=new JCheckBox("Ҫ"); + zjtsyq.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTextField field=null; + JTextField field1=null; + JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("ļ")) { + field=((JTextField)me.getValue()); + } + + } + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { + field1=((JTextField)me.getValue()); + } + if(me.getKey().getText().startsWith("ͼ")) { + field2=((JTextField)me.getValue()); + } + + } + if(zjtsyq.isSelected()) { + field.setEditable(true); + field.setText(""); + field1.setEditable(true); + field2.setEditable(true); + }else { + field.setEditable(false); + field.setText(""); + field1.setEditable(false); + field2.setEditable(false); + } + } + }); + this.add(zjtsyq,BorderLayout.NORTH); + this.add(mainJpanel,BorderLayout.CENTER); + this.add(bottomJpanel,BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + JPanel resultPanel=new JPanel(new PropertyLayout()); + JScrollPane scrollPane=new JScrollPane(resultPanel); + + + + + + + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObj = e.getSource(); + if(sourceObj.equals(selectButton)){ + this.getRootPane().setDefaultButton(okButton);//õǰĬѡаť + String item_id=""; + for(int i=0;i me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + //ͼţȡitem_id + if(property.startsWith("ͼ")) { + field.setText(item.getProperty("item_id")); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + //Ըֵ + //ƣͺ+ĵ+ˮֹ޸ģ +// JTextField field0=null; +// JComboBox combox1=null; + + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { +// field0=((JTextField)me.getValue()); + } + + if(me.getKey().getText().startsWith("ĵ")) { +// combox1=((JComboBox)me.getValue()); + } + + } + + //ѡڸƣʵļƺļ +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + String yjjh="";//һ + for(Map.Entry me: basicMap2.entrySet()) { + if(me.getKey().getText().equals(DocumentUtil.wz)) { + yjjh=((JTextField)me.getValue()).getText(); + } + } + DocumentUtil.setFileName2("Connor_AVIC_NewDocumentSerialC", basicMap,createMap, zjtsyq, session, basicCom,yjjh); + }else if(sourceObj.equals(okButton)){ + + //ӱУ + JTextField fieldX=null; + String message=""; + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("*")&& me.getValue() instanceof JTextField) { + fieldX=((JTextField)me.getValue()); + if(fieldX.getText().trim().length()==0) { + message=message+me.getKey().getText()+";"; + } + } + + } + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("*")) { + fieldX=((JTextField)me.getValue()); + if(fieldX.getText().trim().length()==0) { + message=message+me.getKey().getText()+";"; + } + } + + } + + if(message.length()>0) { + MessageBox.post(":"+message,"",MessageBox.INFORMATION); + }else { + //УǷзǷַ + + JTextField fieldName=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ʵļ")) { + fieldName=((JTextField)me.getValue()); + } + + } + String filename=fieldName.getText(); + if(DocumentUtil.isValidFileName(filename)==false) { + MessageBox.post("ʵļƺзǷַϵԱ޸ģļ","",MessageBox.INFORMATION); + }else { + if(zjtsyq.isSelected()==true) { + JTextField field=null; + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().startsWith("Ʒͺ")) { + field=((JTextField)me.getValue()); + } + + } + if(field.getText().length()>0) { +// this.disposeDialog(); +// this.dispose(); + }else { + + MessageBox.post("ƷͺŲΪ","",MessageBox.INFORMATION); + } + }else { + +// this.disposeDialog(); +// this.dispose(); + } + // + String yjjh="";//һ + for(Map.Entry me: basicMap2.entrySet()) { + if(me.getKey().getText().equals(DocumentUtil.wz)) { + yjjh=((JTextField)me.getValue()).getText(); + } + } + DocumentUtil.setFileName("Connor_AVIC_NewDocumentSerialC", basicMap, createMap, session, zjtsyq, basicCom,yjjh); + try { + Map map=DocumentUtil.getPuid("Connor_AVIC_NewDocumentBasicC",session); + DocumentUtil.selectType=(String) basicCom[0].getSelectedItem(); + selectSecondDoc=(String) basicCom[1].getSelectedItem(); + selectDocCategory=(String) basicCom[2].getSelectedItem(); + + String puid=""; + for (Map.Entry me:map.entrySet()) { + String keyName=me.getKey(); + if(keyName.contains(DocumentUtil.selectType+"-"+selectSecondDoc+"-"+selectDocCategory)) { + puid=map.get(keyName); + } + } + +// String puid=map.get(DocumentUtil.selectType+"-"+selectSecondDoc+"-"+selectDocCategory); +// System.out.println(DocumentUtil.selectType+"-"+selectSecondDoc+"-"+selectDocCategory); + System.out.println(puid); + try { + TCComponentDataset comp=(TCComponentDataset) session.stringToComponent(puid); + TCComponentDataset newdataset=null; + if(comp==null) { + if(puid.length()>0) { + + MessageBox.post("Ҳĵģ","",MessageBox.INFORMATION); + return; + }else { + newdataset=null; + } + }else { + + newdataset=comp.saveAs(null); + } + // +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + + //ʵļ +// JTextField field3=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("ʵļ")) { +// field3=((JTextField)me.getValue()); + } + + } +// objectName=field3.getText(); +// newdataset.setStringProperty("object_name", field3.getText()); + if(newdataset!=null) { + + newdataset.setStringProperty("object_name", DocumentUtil.entityFileName); + } + TCComponent compX= (TCComponent) app.getTargetComponent(); + TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("Document"); +// JTextField field4=null; +// //ͱΪ汾ֵ + JComboBox field5=null; + JComboBox field6=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("ļ")) { +// field4=((JTextField)me.getValue()); + } + if(me.getKey().getText().startsWith("ͱ")) { + field5=(JComboBox)me.getValue(); + } + if(me.getKey().getText().startsWith("汾")) { + field6=(JComboBox)me.getValue(); + } + } +// TCComponentItem item=type.create(field4.getText(), field5.getSelectedItem()+"00", "Ac5_MilitaryDoc", field2.getText(), "", null); + if (DocumentUtil.fileCode.length() > 0) { + boolean create = false; + try { + // ѯ +// TCComponent[] comps = session.search("DocSearch1", new String[] { "ĵ" }, new String[] { DocumentUtil.fileCode }); + TCComponent[] comps=session.search(" ID", new String[] {" ID"}, new String[] {DocumentUtil.fileCode}); + if (comps.length > 0) { + create = false; + } else { + create = true; + } + } catch (Exception e2) { + e2.printStackTrace(); + } + + if (create == false) { +// MessageBox.post("ļ"+DocumentUtil.fileCode+"Ψһ޸","",MessageBox.INFORMATION); + MessageBox.post("ID"+DocumentUtil.fileCode+"ΨһԹд","",MessageBox.INFORMATION); + } else { + this.disposeDialog(); + this.dispose(); + DocumentUtil.createNewItem("Connor_AVIC_NewDocumentThesignC", getClass(), session, basicMap, createMap, + DocumentUtil.entityFileName, DocumentUtil.fileCode, type, DocumentUtil.fileName, + compX, field5, field6, newdataset, "Ac5_CivilDoc", "Connor_AVIC_SetFormPropertyC", DocumentUtil.yjjh); + } + }else { + MessageBox.post("дļ","",MessageBox.INFORMATION); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + }else if(sourceObj.equals(celButton)){ + this.disposeDialog(); + this.dispose(); + }else if(sourceObj.equals(searchButton)){ + this.getRootPane().setDefaultButton(selectButton);//õǰĬѡаť + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchC"); + + String[] selectItem=new String[values.length-1]; + String[] selectValue=new String[values.length-1]; + int i=0; + boolean isNull=true; + for(java.util.Map.Entry me:searchMap.entrySet()) { + String key=me.getKey().getText(); + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { + value="*"; + }else { + value="*"+value+"*"; + isNull=false; + } + selectItem[i]=key; + selectValue[i]=value; + i++; + } + + if(isNull==true) { + MessageBox.post("ĿȫΪ","",MessageBox.INFORMATION); + }else { + try { +// TCComponent[] comps=session.search(values[0], selectItem, selectValue); + TCComponent[] comps=DocumentUtil.getResult(session,searchMap,values[0]); + System.out.println("========"+comps.length); + this.disposeDialog(); + this.showDialog(); + radioButton=new JRadioButton[comps.length]; + radioMap=new HashMap(); + resultPanel.removeAll(); +// scrollPane.remove(resultPanel); + bg=new ButtonGroup(); + //ѯóɿõ + String[] properties=session.getPreferenceService().getStringValues("Connor_AVIC_SearchPropertiesC"); + if(comps.length==0) { + MessageBox.post("ѯΪ","",MessageBox.INFORMATION); + } + for (int j = 0; j < comps.length; j++) { + TCComponent tcComponent = comps[j]; + String name=""; + for (int k = 0; k < properties.length; k++) { + //ְ汾Ͷ + TCComponent tcComponent0=null; + String[] ps=properties[k].split("\\."); + System.out.println(); + if(ps[0].toUpperCase().equals("REV")){ + tcComponent0=tcComponent; + }else if(ps[0].toUpperCase().equals("REVMASTER")) { + tcComponent0=tcComponent.getRelatedComponents("IMAN_master_form_rev")[0]; + } + name=name+tcComponent0.getProperty(ps[1]); + if(k radioMap=new HashMap(); + + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM.java b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM.java new file mode 100644 index 0000000..0da2edf --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogM.java @@ -0,0 +1,883 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +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.TCSession; +import com.teamcenter.rac.stylesheet.KPropertyLOVDisplayer; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CreatTechWordDialogM extends AbstractAIFDialog implements ActionListener{ + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private JPanel mainJpanel; + private JPanel leftJpanel; + private JPanel basicInfoJpanel; + private JPanel selectItemJpanel; + private JPanel rightJpanel; + private JCheckBox zjtsyq; + private JPanel createInfoJpanel; + private String selectType; + private String selectSecondDoc; + private String selectDocCategory; + private JButton okButton; + private JButton celButton; + private JButton searchButton; + private JButton selectButton; + + JTextField[] searchField=null; +// JTextField itemNameField=new JTextField(15); + JRadioButton[] radioButton=null; + ButtonGroup bg=new ButtonGroup(); + private JPanel bottomJpanel; + + + String opType; + public CreatTechWordDialogM(String opType, AbstractAIFApplication app) { + super(AIFUtility.getActiveDesktop()); + this.app=app; + this.opType=opType; + this.session=(TCSession) app.getSession(); + } + + @Override + public void run() { +// super.run();//ע򴰿ʾ + try { + DocumentUtil.readProperty( session, "Connor_AVIC_NewDocumentBasicM", "Connor_AVIC_NewDocumentCreationM");//excelжȡϢ + } catch (IOException e) { + e.printStackTrace(); + } + initUI(); + } + + + + Dimension dimension=new Dimension(250,30); + JLabel[] basicLabel=null; + JLabel[] searchLabel=null; + JTextField[] basicText=null; + JComboBox[] basicCom=null; + Map basicMap=new HashMap(); + Map basicMap2=new LinkedHashMap();//ź׺Ϣ + Map basicPropertyMap=new HashMap(); + Map createMap=new HashMap(); + Map searchMap=new HashMap(); + DefaultComboBoxModel model1=null; + DefaultComboBoxModel model2=null; + DefaultComboBoxModel model3=null; + List listq=null; + @SuppressWarnings("unchecked") + private void initUI() { + this.setTitle("ĵ"); + + okButton=new JButton(""); + okButton.addActionListener(this); + celButton=new JButton("ȡ"); + celButton.addActionListener(this); + searchButton=new JButton("ѯ"); + this.getRootPane().setDefaultButton(searchButton);//õǰĬѡаť + searchButton.addActionListener(this); + selectButton=new JButton("ѡ"); + selectButton.addActionListener(this); + + + this.setLayout(new BorderLayout()); + this.setSize(850, 550); + mainJpanel = new JPanel(new PropertyLayout()); + mainJpanel.setPreferredSize(new Dimension(950, 600)); + leftJpanel = new JPanel(new PropertyLayout()); + leftJpanel.setPreferredSize(new Dimension(500, 600)); + basicInfoJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel.setPreferredSize(new Dimension(500, 300)); + rightJpanel = new JPanel(new PropertyLayout()); + rightJpanel.setPreferredSize(new Dimension(550, 350)); + createInfoJpanel = new JPanel(new PropertyLayout()); +// createInfoJpanel.setPreferredSize(new Dimension(400, 280)); + + basicInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + + basicLabel=new JLabel[DocumentUtil.excelPre.length-2]; + basicText=new JTextField[DocumentUtil.excelPre.length-2]; + basicCom=new JComboBox[3]; + + + int a=2; + String houzhui=""; + for (int i = 1; i < DocumentUtil.excelPre.length-1; i++) { + String[] proValue = DocumentUtil.excelPre[i].split("="); + basicLabel[i-1]=new JLabel(proValue[0]); + basicLabel[i-1].setPreferredSize(new Dimension(90,25)); + String value2= proValue[1]; + basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + basicInfoJpanel.add(a+".2.left.top", basicLabel[i-1]); + + if(value2.toLowerCase().startsWith("itemrevisionmaster")) { + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + }else if(value2.toLowerCase().startsWith("sheet")){ + // sheetʹӱлȡֵ һ=sheet.itemrevisionmaster.ac5_yjjh + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicMap2.put(basicLabel[i-1],basicText[i-1]); +// basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + }else{ + if(i==1) { + model1=new DefaultComboBoxModel(DocumentUtil.jcomboxList_1.toArray(new String[DocumentUtil.jcomboxList_1.size()])); + basicCom[0]=new JComboBox<>(model1); + basicCom[0].setPreferredSize(dimension); + basicCom[0].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getItem() != null) { + selectType = (String) e.getItem(); + System.out.println("1ѡ==="+selectType); + List list=DocumentUtil.map1_2.get(selectType); + List list2=new ArrayList<>(); + model2.removeAllElements(); +// basicCom[1].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + System.out.println("212"+string); + list2.add(string.split("###")[1]); + model2.addElement(string.split("###")[1]); +// basicCom[1].addItem(string.split("###")[1]); + } +// model2=new DefaultComboBoxModel(list2.toArray(new String[list2.size()])); +// basicCom[1]=new JComboBox(model2); + } + } + }); + }else if(i==2) { + String xx=DocumentUtil.jcomboxList_1.get(0); + List list=DocumentUtil.map1_2.get(xx); + List list2=new ArrayList<>(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + System.out.println("228"+string); + list2.add(string.split("###")[1]); + + } + + model2=new DefaultComboBoxModel(list2.toArray(new String[list2.size()])); + basicCom[1]=new JComboBox<>(model2); + basicCom[1].setPreferredSize(dimension); + basicCom[1].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + + if(e.getStateChange()==ItemEvent.SELECTED) { + if(selectType==null) { + selectType = (String) basicCom[0].getSelectedItem(); + } + selectSecondDoc = (String) e.getItem(); + System.out.println("2ѡ==="+selectType+"###"+selectSecondDoc+"www"); + List list=DocumentUtil.map2_3.get(selectType+"###"+selectSecondDoc); + listq=new ArrayList(); + model3.removeAllElements(); +// basicCom[2].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + + System.out.println(Thread.currentThread().getStackTrace()[1].getLineNumber()+string); + model3.addElement(string.split("-")[0]);//غ׺ + listq.add(string); +// basicCom[2].addItem(string); + + } + DocumentUtil.sethouzhui(listq, selectDocCategory, basicMap2); + + } + } + }); + }else if(i==3) { + String xx=DocumentUtil.jcomboxList_1.get(0); + List list=DocumentUtil.map1_2.get(xx); + List list2=DocumentUtil.map2_3.get(list.get(0)); + final List list2New=new ArrayList(); + + for (int j = 0; j < list2.size(); j++) { + list2New.add(list2.get(j).split("-")[0]); + } + + houzhui=list2.get(0); + + System.out.println("houzhui======"+houzhui); + + // ı + model3=new DefaultComboBoxModel(list2New.toArray(new String[list2New.size()])); + basicCom[2]=new JComboBox<>(model3); + basicCom[2].setPreferredSize(dimension); + + basicCom[2].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if(e.getStateChange()==ItemEvent.SELECTED) { + + selectDocCategory = (String) e.getItem(); + System.out.println("3ѡ==="+selectDocCategory); +// setFileName2(); + DocumentUtil.reset(basicMap, createMap); + // 20200727 + if(listq==null) { + System.out.println("3ѡ0==="+(String)basicCom[0].getItemAt(0)+"###"+(String)basicCom[1].getItemAt(0)+"www"); + selectSecondDoc = (String)basicCom[1].getSelectedItem(); + selectType= (String)basicCom[0].getSelectedItem(); + System.out.println("3ѡ1==="+selectType+"###"+selectSecondDoc+"www"); + List list=DocumentUtil.map2_3.get(selectType+"###"+selectSecondDoc); + listq=new ArrayList(); +// basicCom[2].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + + System.out.println(Thread.currentThread().getStackTrace()[1].getLineNumber()+string); + model3.addElement(string.split("-")[0]);//غ׺ + listq.add(string); +// basicCom[2].addItem(string); + + } + } + DocumentUtil.sethouzhui(listq, selectDocCategory, basicMap2); + +// String houzhui1=list2.get(0); + + System.out.println("end"); + } + } + }); + } + + + + + + basicInfoJpanel.add(a+".3.left.top", basicCom[i-1]); + basicMap.put(basicLabel[i-1],basicCom[i-1]); + } + a++; + } + + + + //״μ + int count1 = 1; + for (Map.Entry me : basicMap2.entrySet()) { + JTextField field = (JTextField) me.getValue(); + field.setText(houzhui.split("-")[count1]); + count1++; + } + + + leftJpanel.add("1.1.left.top",basicInfoJpanel); + int i=1; + selectItemJpanel.add(i+".1.left.top",new JLabel("ѡ ")); + i++; +// selectItemJpanel.add(i+".1.left.top",new JLabel(" ѯѡ")); +// i++; + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchM"); + searchLabel=new JLabel[values.length-1]; + + searchField=new JTextField[values.length-1]; + for (int j = 0; j < searchField.length; j++) { + searchField[j]=new JTextField(15); + searchLabel[j]=new JLabel(values[j+1]); + searchLabel[j].setPreferredSize(new Dimension(90,25)); + searchMap.put(searchLabel[j], searchField[j]); + } + +// session.search(arg0, arg1, arg2) + for (int j = 1; j < values.length; j++) { +// String string = values[j]; + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + selectItemJpanel.add(i+".2.left.top",searchLabel[j-1]); + selectItemJpanel.add(i+".3.left.top",searchField[j-1]); + if(j==values.length-1) { + selectItemJpanel.add(i+".4.left.top",searchButton); + } + i++; + + } + + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + JLabel label= new JLabel("ѯ"); + label.setPreferredSize(new Dimension(90,25)); + selectItemJpanel.add(i+".2.left.top",label); + resultPanel=new JPanel(new PropertyLayout()); + + scrollPane=new JScrollPane(resultPanel); + scrollPane.setPreferredSize(new Dimension(250,150)); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + selectItemJpanel.add(i+".3.left.top",scrollPane); + selectItemJpanel.add(i+".4.left.top",selectButton); + + leftJpanel.add("2.1.left.top",selectItemJpanel); + + createInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + int b=2; + for (int j = 0; j < DocumentUtil.createInfo.length; j++) { + createInfoJpanel.add(b+".1.left.top",new JLabel(" ")); + String[] string = DocumentUtil.createInfo[j].split("="); + DocumentUtil.createLabel[j]=new JLabel(string[0]); + DocumentUtil.createLabel[j].setPreferredSize(new Dimension(90,25)); + createInfoJpanel.add(b+".2.left.top",DocumentUtil.createLabel[j]); + if(string.length>1) { + if(string[1].startsWith("#")) {//TODO + DocumentUtil.createCom[j] = new MultiCombo(session.getPreferenceService().getStringValues(string[1].substring(1))); + DocumentUtil.createCom[j].setPreferredSize(new Dimension(250, 30)); + DocumentUtil.createCom[j].setEditable(true); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createCom[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createCom[j]); + b++; + continue; + } + DefaultComboBoxModel model; + String[] lovs=string[1].split(";"); + List list=new ArrayList(); + for (int k = 0; k < lovs.length; k++) { + list.add(lovs[k]); + + } + + model=new DefaultComboBoxModel(list.toArray(new String[list.size()])); + DocumentUtil.createCom[j]=new JComboBox<>(model); + DocumentUtil.createCom[j].setPreferredSize(new Dimension(150, 30)); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createCom[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createCom[j]); + if(string[0].equals("ܼ")) { + DocumentUtil.mjCom=DocumentUtil.createCom[j]; + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.mjCom); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.mjCom); + + DocumentUtil.createCom[j].addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + try { + System.out.println("ip_clearance==========="+session.getUser().getStringProperty("ip_clearance")); + } catch (Exception e2) { + e2.printStackTrace(); + } + + System.out.println("ѡ====="+e.getItem().toString()); + if (e.getStateChange() == ItemEvent.SELECTED) { + try { + KPropertyLOVDisplayer.checkIP(e.getItem().toString()); + } catch (Exception e1) { + DocumentUtil.mjCom.setSelectedIndex(-1); + MessageBox.post("ûܼ޸ĺִܼܹд˲","",MessageBox.INFORMATION); + } + + } + } + }); + } + }else { + DocumentUtil.createText[j]=new JTextField(15); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createText[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createText[j]); + } + + b++; + + } + for(java.util.Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("Ʋ")) { + String groupName=null; + try { +// groupName = session.getGroup().getFullName();//Ҫػ + groupName=session.getGroup().getProperty("display_name"); + if(groupName.split("\\.").length>0) { + groupName=groupName.split("\\.")[0]; + } + } catch (Exception e1) { + e1.printStackTrace(); + } + ((JTextField)me.getValue()).setText(groupName); + } + + } + rightJpanel.add("1.1.left.top",createInfoJpanel); + + mainJpanel.add("1.1.left.top",leftJpanel); + mainJpanel.add("1.2.left.top",rightJpanel); + bottomJpanel=new JPanel(new FlowLayout()); + bottomJpanel.add(okButton); + bottomJpanel.add(celButton); + //ͨȡѡЩؼɱ༭(jlabel*,*Ҳü) + String[] editable=session.getPreferenceService().getStringValues("Connor_AVIC_editableM"); + for (int j = 0; j < editable.length; j++) { + boolean boo=false; + String string = editable[j]; + boo=DocumentUtil.setEditable(createMap,string); + if(boo==false) { + + boo=DocumentUtil.setEditable(basicMap,string); + if(boo==false) { + + DocumentUtil.setEditable(searchMap,string); + } + } + + } + zjtsyq=new JCheckBox("Ҫ"); + zjtsyq.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTextField field=null; + JTextField field1=null; + JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ļ")) { + field=((JTextField)me.getValue()); + } + + } + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { + field1=((JTextField)me.getValue()); + } + if(me.getKey().getText().contains("ͼ")) { + field2=((JTextField)me.getValue()); + } + + } + if(zjtsyq.isSelected()) { + field.setEditable(true); + field.setText(""); + field1.setEditable(true); + field2.setEditable(true); + }else { + field.setEditable(false); + field.setText(""); + field1.setEditable(false); + field2.setEditable(false); + } + } + }); + this.add(zjtsyq,BorderLayout.NORTH); + this.add(mainJpanel,BorderLayout.CENTER); + this.add(bottomJpanel,BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + JPanel resultPanel=new JPanel(new PropertyLayout()); + JScrollPane scrollPane=new JScrollPane(resultPanel); + + + + @SuppressWarnings("unchecked") + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObj = e.getSource(); + if(sourceObj.equals(selectButton)){ + this.getRootPane().setDefaultButton(okButton);//õǰĬѡаť + String item_id=""; + for(int i=0;i me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + //ͼţȡitem_id + if(property.contains("ͼ")) { + field.setText(item.getProperty("item_id")); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + //Ըֵ + //ƣͺ+ĵ+ˮֹ޸ģ +// JTextField field0=null; +// JComboBox combox1=null; + + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { +// field0=((JTextField)me.getValue()); + } + + if(me.getKey().getText().startsWith("ĵ")) { +// combox1=((JComboBox)me.getValue()); + } + + } + + //ѡڸƣʵļƺļ +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + String yjjh="";//һ + for(Map.Entry me: basicMap2.entrySet()) { + if(me.getKey().getText().equals(DocumentUtil.wz)) { + yjjh=((JTextField)me.getValue()).getText(); + } + } + DocumentUtil.setFileName2("Connor_AVIC_NewDocumentSerialM",basicMap,createMap,zjtsyq, session, basicCom,yjjh); + }else if(sourceObj.equals(okButton)){ +// + //ӱУ + JTextField fieldX=null; + String message=""; + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("*")&& me.getValue() instanceof JTextField) { + System.out.println("598"+me.getKey().getText()); + fieldX=((JTextField)me.getValue()); + if(fieldX.getText().trim().length()==0) { + message=message+me.getKey().getText()+";"; + } + } + + } + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("*")) { + System.out.println("608"+me.getKey().getText()); + fieldX=((JTextField)me.getValue()); + if(fieldX.getText().trim().length()==0) { + message=message+me.getKey().getText()+";"; + } + } + + } + + if(message.length()>0) { + MessageBox.post(":"+message,"",MessageBox.INFORMATION); + }else { + //УǷзǷַ + + JTextField fieldName=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ʵļ")) { + fieldName=((JTextField)me.getValue()); + } + + } + String filename=fieldName.getText(); + if(DocumentUtil.isValidFileName(filename)==false) { + MessageBox.post("ʵļƺзǷַϵԱ޸ģļ","",MessageBox.INFORMATION); + }else { + + if(zjtsyq.isSelected()==true) { + JTextField field=null; + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { + field=((JTextField)me.getValue()); + } + + } + if(field.getText().length()>0) { +// this.disposeDialog(); +// this.dispose(); + }else { + + MessageBox.post("ƷͺŲΪ","",MessageBox.INFORMATION); + } + }else { + +// this.disposeDialog(); +// this.dispose(); + } + // + String yjjh="";//һ + for(Map.Entry me: basicMap2.entrySet()) { + if(me.getKey().getText().equals(DocumentUtil.wz)) { + yjjh=((JTextField)me.getValue()).getText(); + } + } + DocumentUtil.setFileName("Connor_AVIC_NewDocumentSerialM", basicMap, createMap, session, zjtsyq, basicCom,yjjh); + System.out.println("ļ======"+DocumentUtil.fileCode); + + + /* + * if(true) { return ; } + */ + try { + Map map=DocumentUtil.getPuid("Connor_AVIC_NewDocumentBasicM",session); + selectType=(String) basicCom[0].getSelectedItem(); + selectSecondDoc=(String) basicCom[1].getSelectedItem(); + selectDocCategory=(String) basicCom[2].getSelectedItem(); + String puid=""; + for (Map.Entry me:map.entrySet()) { + String keyName=me.getKey(); + if(keyName.contains(selectType+"-"+selectSecondDoc+"-"+selectDocCategory)) { + puid=map.get(keyName); + } + } +// String puid=map.get(selectType+"-"+selectSecondDoc+"-"+selectDocCategory); +// System.out.println(selectType+"-"+selectSecondDoc+"-"+selectDocCategory); + System.out.println(puid); + try { + TCComponentDataset comp=(TCComponentDataset) session.stringToComponent(puid); + TCComponentDataset newdataset=null; + if(comp==null) { + if(puid.length()>0) { + + MessageBox.post("Ҳĵģ","",MessageBox.INFORMATION); + return; + }else { + newdataset=null; + } + }else { + + newdataset=comp.saveAs(null); + } + // +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + + //ʵļ +// JTextField field3=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ʵļ")) { +// field3=((JTextField)me.getValue()); + } + + } +// objectName=field3.getText(); +// newdataset.setStringProperty("object_name", field3.getText()); + if(newdataset!=null) { + newdataset.setStringProperty("object_name", DocumentUtil.entityFileName); + } + TCComponent compX= (TCComponent) app.getTargetComponent(); + TCComponentItemType type=(TCComponentItemType) session.getTypeComponent("Document"); +// JTextField field4=null; + //ͱΪ汾ֵ + JComboBox field5=null; + JComboBox field6=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ļ")) { +// field4=((JTextField)me.getValue()); + } + if(me.getKey().getText().contains("ͱ")) { + field5=(JComboBox)me.getValue(); + } + if(me.getKey().getText().contains("汾")) { + field6=(JComboBox)me.getValue(); + } + + } +// TCComponentItem item=type.create(field4.getText(), field5.getSelectedItem()+"00", "Ac5_MilitaryDoc", +// field2.getText(), "", null); + if(DocumentUtil.fileCode.length()>0) { + + boolean create=false; + try { + // ѯ +// TCComponent[] comps=session.search("DocSearch1", new String[] {"ĵ"}, +// new String[] {DocumentUtil.fileCode});//ͨDocSearch1汾ϵĵŲѯǷظĶ + TCComponent[] comps=session.search(" ID", new String[] {" ID"}, new String[] {DocumentUtil.fileCode}); + if(comps.length>0) { + create=false; + }else { + create=true; + } + } catch (Exception e2) { + e2.printStackTrace(); + } + + if(create==false) { +// MessageBox.post("ļ"+DocumentUtil.fileCode+"Ψһ޸","",MessageBox.INFORMATION); + MessageBox.post("ID"+DocumentUtil.fileCode+"ΨһԹд","",MessageBox.INFORMATION); + }else { + this.disposeDialog(); + this.dispose(); + DocumentUtil.createNewItem("Connor_AVIC_NewDocumentThesignM",getClass(),session,basicMap,createMap, + DocumentUtil.entityFileName,DocumentUtil.fileCode,type,DocumentUtil.fileName, + compX,field5,field6,newdataset,"Ac5_MilitaryDoc","Connor_AVIC_SetFormPropertyM",DocumentUtil.yjjh); + + } + }else { + MessageBox.post("дļ","",MessageBox.INFORMATION); + } + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(""+e1.getMessage(),"",MessageBox.ERROR); + } + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(""+e1.getMessage(),"",MessageBox.ERROR); + } + } + } + }else if(sourceObj.equals(celButton)){ + + this.disposeDialog(); + this.dispose(); + }else if(sourceObj.equals(searchButton)){ + this.getRootPane().setDefaultButton(selectButton);//õǰĬѡаť + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchM"); + + String[] selectItem=new String[values.length-1]; + String[] selectValue=new String[values.length-1]; + int i=0; + boolean isNull=true; + for(java.util.Map.Entry me:searchMap.entrySet()) { + + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { +// value="*"; + }else { + i++; + } + } + selectItem=new String[i]; + selectValue=new String[i]; + i=0; + for(java.util.Map.Entry me:searchMap.entrySet()) { + String key=me.getKey().getText(); + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { +// value="*"; + }else { + value="*"+value+"*"; + isNull=false; + selectItem[i]=key; + selectValue[i]=value; + i++; + } + } + + if(isNull==true) { + MessageBox.post("ĿȫΪ","",MessageBox.INFORMATION); + }else { + try { + + + + +// TCComponent[] comps=session.search(values[0], selectItem, selectValue); + TCComponent[] comps=DocumentUtil.getResult(session,searchMap,values[0]); + System.out.println("========"+comps.length); + this.disposeDialog(); + this.showDialog(); + radioButton=new JRadioButton[comps.length]; + radioMap=new HashMap(); + resultPanel.removeAll(); +// scrollPane.remove(resultPanel); + bg=new ButtonGroup(); + //ѯóɿõ + String[] properties=session.getPreferenceService().getStringValues("Connor_AVIC_SearchPropertiesM"); + if(comps.length==0) { + MessageBox.post("ѯΪ","",MessageBox.INFORMATION); + } + for (int j = 0; j < comps.length; j++) { + TCComponent tcComponent = comps[j]; + String name=""; + for (int k = 0; k < properties.length; k++) { + //ְ汾Ͷ + TCComponent tcComponent0=null; + String[] ps=properties[k].split("\\."); + System.out.println(); + if(ps[0].toUpperCase().equals("REV")){ + tcComponent0=tcComponent; + }else if(ps[0].toUpperCase().equals("REVMASTER")) { + tcComponent0=tcComponent.getRelatedComponents("IMAN_master_form_rev")[0]; + }else if(ps[0].toUpperCase().equals("ITEM")) { + tcComponent0=((TCComponentItemRevision)tcComponent).getItem(); + } + name=name+tcComponent0.getProperty(ps[1]); + if(k radioMap=new HashMap(); + + + + + + + + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS.java b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS.java new file mode 100644 index 0000000..6be4362 --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogS.java @@ -0,0 +1,890 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +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.stylesheet.KPropertyLOVDisplayer; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +@SuppressWarnings("unchecked") +public class CreatTechWordDialogS extends AbstractAIFDialog implements ActionListener{ + /** + * + */ + private static final long serialVersionUID = 1L; + + private AbstractAIFApplication app; + private TCSession session; + private JPanel mainJpanel; + private JPanel leftJpanel; + private JPanel basicInfoJpanel; + private JPanel selectItemJpanel; + private JPanel rightJpanel; + private JCheckBox zjtsyq; + private JPanel createInfoJpanel; + private String selectType; + private String selectSecondDoc; + private String selectDocCategory; + private JButton okButton; + private JButton celButton; + private JButton searchButton; + private JButton selectButton; + + JTextField[] searchField=null; +// JTextField itemNameField=new JTextField(15); + JRadioButton[] radioButton=null; + ButtonGroup bg=new ButtonGroup(); + private JPanel bottomJpanel; + + + String opType; + + public CreatTechWordDialogS(String opType, AbstractAIFApplication app) { + super(AIFUtility.getActiveDesktop()); + this.app=app; + this.opType=opType; + this.session=(TCSession) app.getSession(); + } + + @Override + public void run() { +// super.run();//ע򴰿ʾ + try { + DocumentUtil.readProperty( session, "Connor_AVIC_NewDocumentBasicS", "Connor_AVIC_NewDocumentCreationS");//excelжȡϢ + } catch (IOException e) { + e.printStackTrace(); + } + initUI(); + } + + + + Dimension dimension=new Dimension(250,30); + JLabel[] basicLabel=null; + JLabel[] searchLabel=null; + JTextField[] basicText=null; + JComboBox[] basicCom=null; + Map basicMap=new HashMap(); + Map basicMap2=new LinkedHashMap();//ź׺Ϣ + Map basicPropertyMap=new HashMap(); + Map createMap=new HashMap(); + Map searchMap=new HashMap(); + DefaultComboBoxModel model1=null; + DefaultComboBoxModel model2=null; + DefaultComboBoxModel model3=null; + List listq=null; + private void initUI() { + this.setTitle("ĵ"); + + okButton=new JButton(""); + okButton.addActionListener(this); + celButton=new JButton("ȡ"); + celButton.addActionListener(this); + searchButton=new JButton("ѯ"); + this.getRootPane().setDefaultButton(searchButton);//õǰĬѡаť + searchButton.addActionListener(this); + selectButton=new JButton("ѡ"); + selectButton.addActionListener(this); + + + this.setLayout(new BorderLayout()); + this.setSize(850, 550); + mainJpanel = new JPanel(new PropertyLayout()); + mainJpanel.setPreferredSize(new Dimension(950, 600)); + leftJpanel = new JPanel(new PropertyLayout()); + leftJpanel.setPreferredSize(new Dimension(500, 600)); + basicInfoJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel.setPreferredSize(new Dimension(500, 300)); + rightJpanel = new JPanel(new PropertyLayout()); + rightJpanel.setPreferredSize(new Dimension(550, 350)); + createInfoJpanel = new JPanel(new PropertyLayout()); +// createInfoJpanel.setPreferredSize(new Dimension(400, 280)); + + basicInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + + basicLabel=new JLabel[DocumentUtil.excelPre.length-2]; + basicText=new JTextField[DocumentUtil.excelPre.length-2]; + basicCom=new JComboBox[3]; + + + int a=2; + String houzhui=""; + for (int i = 1; i < DocumentUtil.excelPre.length-1; i++) { + String[] proValue = DocumentUtil.excelPre[i].split("="); + basicLabel[i-1]=new JLabel(proValue[0]); + basicLabel[i-1].setPreferredSize(new Dimension(90,25)); + String value2= proValue[1]; + basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + basicInfoJpanel.add(a+".2.left.top", basicLabel[i-1]); + + if(value2.toLowerCase().startsWith("itemrevisionmaster")) { + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + }else if(value2.toLowerCase().startsWith("sheet")){ + // sheetʹӱлȡֵ һ=sheet.itemrevisionmaster.ac5_yjjh + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicMap2.put(basicLabel[i-1],basicText[i-1]); +// basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + }else{ + if(i==1) { + model1=new DefaultComboBoxModel(DocumentUtil.jcomboxList_1.toArray(new String[DocumentUtil.jcomboxList_1.size()])); + basicCom[0]=new JComboBox<>(model1); + basicCom[0].setPreferredSize(dimension); + basicCom[0].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getItem() != null) { + selectType = (String) e.getItem(); + System.out.println("1ѡ==="+selectType); + List list=DocumentUtil.map1_2.get(selectType); + List list2=new ArrayList<>(); + model2.removeAllElements(); +// basicCom[1].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + System.out.println("212"+string); + list2.add(string.split("###")[1]); + model2.addElement(string.split("###")[1]); +// basicCom[1].addItem(string.split("###")[1]); + } +// model2=new DefaultComboBoxModel(list2.toArray(new String[list2.size()])); +// basicCom[1]=new JComboBox(model2); + } + } + }); + }else if(i==2) { + String xx=DocumentUtil.jcomboxList_1.get(0); + List list=DocumentUtil.map1_2.get(xx); + List list2=new ArrayList<>(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + System.out.println("228"+string); + list2.add(string.split("###")[1]); + + } + + model2=new DefaultComboBoxModel(list2.toArray(new String[list2.size()])); + basicCom[1]=new JComboBox<>(model2); + basicCom[1].setPreferredSize(dimension); + basicCom[1].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + + if(e.getStateChange()==ItemEvent.SELECTED) { + if(selectType==null) { + selectType = (String) basicCom[0].getSelectedItem(); + } + selectSecondDoc = (String) e.getItem(); + System.out.println("2ѡ==="+selectType+"###"+selectSecondDoc+"www"); + List list=DocumentUtil.map2_3.get(selectType+"###"+selectSecondDoc); + listq=new ArrayList(); + model3.removeAllElements(); +// basicCom[2].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + + System.out.println(Thread.currentThread().getStackTrace()[1].getLineNumber()+string); + model3.addElement(string.split("-")[0]);//غ׺ + listq.add(string); +// basicCom[2].addItem(string); + + } + DocumentUtil.sethouzhui(listq, selectDocCategory, basicMap2); + + } + } + }); + }else if(i==3) { + String xx=DocumentUtil.jcomboxList_1.get(0); + List list=DocumentUtil.map1_2.get(xx); + List list2=DocumentUtil.map2_3.get(list.get(0)); + final List list2New=new ArrayList(); + + for (int j = 0; j < list2.size(); j++) { + list2New.add(list2.get(j).split("-")[0]); + } + + houzhui=list2.get(0); + + System.out.println("houzhui======"+houzhui); + + // ı + model3=new DefaultComboBoxModel(list2New.toArray(new String[list2New.size()])); + basicCom[2]=new JComboBox<>(model3); + basicCom[2].setPreferredSize(dimension); + + basicCom[2].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if(e.getStateChange()==ItemEvent.SELECTED) { + + selectDocCategory = (String) e.getItem(); + System.out.println("3ѡ==="+selectDocCategory); +// setFileName2(); + DocumentUtil.reset(basicMap, createMap); + // 20200727 + if(listq==null) { + System.out.println("3ѡ0==="+(String)basicCom[0].getItemAt(0)+"###"+(String)basicCom[1].getItemAt(0)+"www"); + selectSecondDoc = (String)basicCom[1].getSelectedItem(); + selectType= (String)basicCom[0].getSelectedItem(); + System.out.println("3ѡ1==="+selectType+"###"+selectSecondDoc+"www"); + List list=DocumentUtil.map2_3.get(selectType+"###"+selectSecondDoc); + listq=new ArrayList(); +// basicCom[2].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + + System.out.println(Thread.currentThread().getStackTrace()[1].getLineNumber()+string); + model3.addElement(string.split("-")[0]);//غ׺ + listq.add(string); +// basicCom[2].addItem(string); + + } + } + DocumentUtil.sethouzhui(listq, selectDocCategory, basicMap2); + +// String houzhui1=list2.get(0); + + System.out.println("end"); + } + } + }); + } + + + + + + basicInfoJpanel.add(a+".3.left.top", basicCom[i-1]); + basicMap.put(basicLabel[i-1],basicCom[i-1]); + } + a++; + } + + + + //״μ + int count1 = 1; + for (Map.Entry me : basicMap2.entrySet()) { + JTextField field = (JTextField) me.getValue(); + field.setText(houzhui.split("-")[count1]); + count1++; + } + + + leftJpanel.add("1.1.left.top",basicInfoJpanel); + int i=1; + selectItemJpanel.add(i+".1.left.top",new JLabel("ѡ ")); + i++; +// selectItemJpanel.add(i+".1.left.top",new JLabel(" ѯѡ")); +// i++; + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchS"); + searchLabel=new JLabel[values.length-1]; + + searchField=new JTextField[values.length-1]; + for (int j = 0; j < searchField.length; j++) { + searchField[j]=new JTextField(15); + searchLabel[j]=new JLabel(values[j+1]); + searchLabel[j].setPreferredSize(new Dimension(90,25)); + searchMap.put(searchLabel[j], searchField[j]); + } + +// session.search(arg0, arg1, arg2) + for (int j = 1; j < values.length; j++) { +// String string = values[j]; + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + selectItemJpanel.add(i+".2.left.top",searchLabel[j-1]); + selectItemJpanel.add(i+".3.left.top",searchField[j-1]); + if(j==values.length-1) { + selectItemJpanel.add(i+".4.left.top",searchButton); + } + i++; + + } + + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + JLabel label= new JLabel("ѯ"); + label.setPreferredSize(new Dimension(90,25)); + selectItemJpanel.add(i+".2.left.top",label); + resultPanel=new JPanel(new PropertyLayout()); + + scrollPane=new JScrollPane(resultPanel); + scrollPane.setPreferredSize(new Dimension(250,150)); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + selectItemJpanel.add(i+".3.left.top",scrollPane); + selectItemJpanel.add(i+".4.left.top",selectButton); + + leftJpanel.add("2.1.left.top",selectItemJpanel); + + createInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + int b=2; + for (int j = 0; j < DocumentUtil.createInfo.length; j++) { + createInfoJpanel.add(b+".1.left.top",new JLabel(" ")); + String[] string = DocumentUtil.createInfo[j].split("="); + DocumentUtil.createLabel[j]=new JLabel(string[0]); + DocumentUtil.createLabel[j].setPreferredSize(new Dimension(90,25)); + createInfoJpanel.add(b+".2.left.top",DocumentUtil.createLabel[j]); + if(string.length>1) { + if(string[1].startsWith("#")) {//TODO + DocumentUtil.createCom[j] = new MultiCombo(session.getPreferenceService().getStringValues(string[1].substring(1))); + DocumentUtil.createCom[j].setPreferredSize(new Dimension(250, 30)); + DocumentUtil.createCom[j].setEditable(true); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createCom[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createCom[j]); + b++; + continue; + } + DefaultComboBoxModel model; + String[] lovs=string[1].split(";"); + List list=new ArrayList(); + for (int k = 0; k < lovs.length; k++) { + list.add(lovs[k]); + + } + + model=new DefaultComboBoxModel(list.toArray(new String[list.size()])); + DocumentUtil.createCom[j]=new JComboBox<>(model); + DocumentUtil.createCom[j].setPreferredSize(new Dimension(150, 30)); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createCom[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createCom[j]); + if(string[0].equals("ܼ")) { + DocumentUtil.mjCom=DocumentUtil.createCom[j]; + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.mjCom); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.mjCom); + + DocumentUtil.createCom[j].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + try { + System.out.println("ip_clearance==========="+session.getUser().getStringProperty("ip_clearance")); + } catch (TCException e2) { + e2.printStackTrace(); + } + + System.out.println("ѡ====="+e.getItem().toString()); + if (e.getStateChange() == ItemEvent.SELECTED) { + try { + KPropertyLOVDisplayer.checkIP(e.getItem().toString()); + } catch (Exception e1) { + DocumentUtil.mjCom.setSelectedIndex(-1); + MessageBox.post("ûܼ޸ĺִܼܹд˲","",MessageBox.INFORMATION); + } + + } + } + }); + } + }else { + DocumentUtil.createText[j]=new JTextField(15); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createText[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createText[j]); + } + + b++; + + } + for(java.util.Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("Ʋ")) { + String groupName=null; + try { +// groupName = session.getGroup().getFullName();//Ҫػ + groupName=session.getGroup().getProperty("display_name"); + if(groupName.split("\\.").length>0) { + groupName=groupName.split("\\.")[0]; + } + } catch (TCException e1) { + e1.printStackTrace(); + } + ((JTextField)me.getValue()).setText(groupName); + } + + } + rightJpanel.add("1.1.left.top",createInfoJpanel); + + mainJpanel.add("1.1.left.top",leftJpanel); + mainJpanel.add("1.2.left.top",rightJpanel); + bottomJpanel=new JPanel(new FlowLayout()); + bottomJpanel.add(okButton); + bottomJpanel.add(celButton); + //ͨȡѡЩؼɱ༭(jlabel*,*Ҳü) + String[] editable=session.getPreferenceService().getStringValues("Connor_AVIC_editableS"); + for (int j = 0; j < editable.length; j++) { + boolean boo=false; + String string = editable[j]; + boo=DocumentUtil.setEditable(createMap,string); + if(boo==false) { + + boo=DocumentUtil.setEditable(basicMap,string); + if(boo==false) { + + DocumentUtil.setEditable(searchMap,string); + } + } + + } + zjtsyq=new JCheckBox("Ҫ"); + zjtsyq.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTextField field=null; + JTextField field1=null; + JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ļ")) { + field=((JTextField)me.getValue()); + } + + } + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { + field1=((JTextField)me.getValue()); + } + if(me.getKey().getText().contains("ͼ")) { + field2=((JTextField)me.getValue()); + } + + } + if(zjtsyq.isSelected()) { + field.setEditable(true); + field.setText(""); + field1.setEditable(true); + field2.setEditable(true); + }else { + field.setEditable(false); + field.setText(""); + field1.setEditable(false); + field2.setEditable(false); + } + } + }); + this.add(zjtsyq,BorderLayout.NORTH); + this.add(mainJpanel,BorderLayout.CENTER); + this.add(bottomJpanel,BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + JPanel resultPanel=new JPanel(new PropertyLayout()); + JScrollPane scrollPane=new JScrollPane(resultPanel); + + + + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObj = e.getSource(); + if(sourceObj.equals(selectButton)){ + this.getRootPane().setDefaultButton(okButton);//õǰĬѡаť + String item_id=""; + for(int i=0;i me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + //ͼţȡitem_id + if(property.contains("ͼ")) { + field.setText(item.getProperty("item_id")); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + //Ըֵ + //ƣͺ+ĵ+ˮֹ޸ģ +// JTextField field0=null; +// JComboBox combox1=null; + + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { +// field0=((JTextField)me.getValue()); + } + + if(me.getKey().getText().startsWith("ĵ")) { +// combox1=((JComboBox)me.getValue()); + } + + } + + //ѡڸƣʵļƺļ +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + String yjjh="";//һ + for(Map.Entry me: basicMap2.entrySet()) { + if(me.getKey().getText().equals(DocumentUtil.wz)) { + yjjh=((JTextField)me.getValue()).getText(); + } + } + DocumentUtil.setFileName2("Connor_AVIC_NewDocumentSerialS",basicMap,createMap,zjtsyq, session, basicCom,yjjh); + }else if(sourceObj.equals(okButton)){ +// + //ӱУ + JTextField fieldX=null; + String message=""; + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("*")&& me.getValue() instanceof JTextField) { + System.out.println("598"+me.getKey().getText()); + fieldX=((JTextField)me.getValue()); + if(fieldX.getText().trim().length()==0) { + message=message+me.getKey().getText()+";"; + } + } + + } + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("*")) { + System.out.println("608"+me.getKey().getText()); + fieldX=((JTextField)me.getValue()); + if(fieldX.getText().trim().length()==0) { + message=message+me.getKey().getText()+";"; + } + } + + } + + if(message.length()>0) { + + MessageBox.post(":"+message,"",MessageBox.INFORMATION); + }else { + //УǷзǷַ + + JTextField fieldName=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ʵļ")) { + fieldName=((JTextField)me.getValue()); + } + + } + String filename=fieldName.getText(); + if(DocumentUtil.isValidFileName(filename)==false) { + + MessageBox.post("ʵļƺзǷַϵԱ޸ģļ","",MessageBox.INFORMATION); + }else { + + if(zjtsyq.isSelected()==true) { + JTextField field=null; + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { + field=((JTextField)me.getValue()); + } + + } + if(field.getText().length()>0) { +// this.disposeDialog(); +// this.dispose(); + }else { + + + MessageBox.post("ƷͺŲΪ","",MessageBox.INFORMATION); + } + }else { + +// this.disposeDialog(); +// this.dispose(); + } + // + String yjjh="";//һ + for(Map.Entry me: basicMap2.entrySet()) { + if(me.getKey().getText().equals(DocumentUtil.wz)) { + yjjh=((JTextField)me.getValue()).getText(); + } + } + DocumentUtil.setFileName("Connor_AVIC_NewDocumentSerialS", basicMap, createMap, session, zjtsyq, basicCom,yjjh); + System.out.println("ļ======"+DocumentUtil.fileCode); + /* + * if(true) { return ; } + */ + try { + Map map=DocumentUtil.getPuid("Connor_AVIC_NewDocumentBasicS",session); + selectType=(String) basicCom[0].getSelectedItem(); + selectSecondDoc=(String) basicCom[1].getSelectedItem(); + selectDocCategory=(String) basicCom[2].getSelectedItem(); + String puid=""; + for (Map.Entry me:map.entrySet()) { + String keyName=me.getKey(); + if(keyName.contains(selectType+"-"+selectSecondDoc+"-"+selectDocCategory)) { + puid=map.get(keyName); + } + } +// String puid=map.get(selectType+"-"+selectSecondDoc+"-"+selectDocCategory); +// System.out.println(selectType+"-"+selectSecondDoc+"-"+selectDocCategory); + System.out.println(puid); + try { + TCComponentDataset comp=(TCComponentDataset) session.stringToComponent(puid); + TCComponentDataset newdataset=null; + if(comp==null) { + if(puid.length()>0) { + + + MessageBox.post("Ҳĵģ","",MessageBox.INFORMATION); + + return; + }else { + newdataset=null; + } + }else { + + newdataset=comp.saveAs(null); + } + // +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + + //ʵļ +// JTextField field3=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ʵļ")) { +// field3=((JTextField)me.getValue()); + } + + } +// objectName=field3.getText(); +// newdataset.setStringProperty("object_name", field3.getText()); + if(newdataset!=null) { + + newdataset.setStringProperty("object_name", DocumentUtil.entityFileName); + } + TCComponent compX= (TCComponent) app.getTargetComponent(); + TCComponentItemType type=(TCComponentItemType) session.getTypeComponent("Document"); +// JTextField field4=null; + //ͱΪ汾ֵ + JComboBox field5=null; + JComboBox field6=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ļ")) { +// field4=((JTextField)me.getValue()); + } + if(me.getKey().getText().contains("ͱ")) { + field5=(JComboBox)me.getValue(); + } + if(me.getKey().getText().contains("汾")) { + field6=(JComboBox)me.getValue(); + } + + } +// TCComponentItem item=type.create(field4.getText(), field5.getSelectedItem()+"00", "Ac5_MilitaryDoc", +// field2.getText(), "", null); + if(DocumentUtil.fileCode.length()>0) { + + boolean create=false; + try { + // ѯ +// TCComponent[] comps=session.search("DocSearch1", new String[] {"ĵ"}, new String[] {DocumentUtil.fileCode}); + TCComponent[] comps=session.search(" ID", new String[] {" ID"}, new String[] {DocumentUtil.fileCode}); + if(comps.length>0) { + create=false; + }else { + create=true; + } + } catch (Exception e2) { + e2.printStackTrace(); + } + + if(create==false) { + +// MessageBox.post("ļ"+DocumentUtil.fileCode+"Ψһ޸","",MessageBox.INFORMATION); + MessageBox.post("ID"+DocumentUtil.fileCode+"ΨһԹд","",MessageBox.INFORMATION); + + }else { + this.disposeDialog(); + this.dispose(); + DocumentUtil.createNewItem("Connor_AVIC_NewDocumentThesignS",getClass(),session,basicMap, + createMap,DocumentUtil.entityFileName,DocumentUtil.fileCode,type,DocumentUtil.fileName, + compX,field5,field6,newdataset,"Ac5_SoftTechDoc","Connor_AVIC_SetFormPropertyS",DocumentUtil.yjjh); + + } + }else { + + MessageBox.post("дļ","",MessageBox.INFORMATION); + + } + + + + } catch (TCException e1) { + e1.printStackTrace(); + } + + } catch (IOException e1) { + e1.printStackTrace(); + } + } + + } + + }else if(sourceObj.equals(celButton)){ + + this.disposeDialog(); + this.dispose(); + }else if(sourceObj.equals(searchButton)){ + this.getRootPane().setDefaultButton(selectButton);//õǰĬѡаť + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchS"); + + String[] selectItem=new String[values.length-1]; + String[] selectValue=new String[values.length-1]; + int i=0; + boolean isNull=true; + for(java.util.Map.Entry me:searchMap.entrySet()) { + + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { +// value="*"; + }else { + i++; + } + } + selectItem=new String[i]; + selectValue=new String[i]; + i=0; + for(java.util.Map.Entry me:searchMap.entrySet()) { + String key=me.getKey().getText(); + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { +// value="*"; + }else { + value="*"+value+"*"; + isNull=false; + selectItem[i]=key; + selectValue[i]=value; + i++; + } + } + + if(isNull==true) { + + MessageBox.post("ĿȫΪ","",MessageBox.INFORMATION); + + }else { + + try { +// TCComponent[] comps=session.search(values[0], selectItem, selectValue); + TCComponent[] comps=DocumentUtil.getResult(session,searchMap,values[0]); + System.out.println("========"+comps.length); + this.disposeDialog(); + this.showDialog(); + radioButton=new JRadioButton[comps.length]; + radioMap=new HashMap(); + resultPanel.removeAll(); +// scrollPane.remove(resultPanel); + bg=new ButtonGroup(); + //ѯóɿõ + String[] properties=session.getPreferenceService().getStringValues("Connor_AVIC_SearchPropertiesS"); + if(comps.length==0) { + + MessageBox.post("ѯΪ","",MessageBox.INFORMATION); + + } + for (int j = 0; j < comps.length; j++) { + TCComponent tcComponent = comps[j]; + String name=""; + for (int k = 0; k < properties.length; k++) { + //ְ汾Ͷ + TCComponent tcComponent0=null; + String[] ps=properties[k].split("\\."); + System.out.println(); + if(ps[0].toUpperCase().equals("REV")){ + tcComponent0=tcComponent; + }else if(ps[0].toUpperCase().equals("REVMASTER")) { + tcComponent0=tcComponent.getRelatedComponents("IMAN_master_form_rev")[0]; + } + name=name+tcComponent0.getProperty(ps[1]); + if(k radioMap=new HashMap(); + + + + + + + + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW.java b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW.java new file mode 100644 index 0000000..7d7e324 --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordDialogW.java @@ -0,0 +1,891 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.swing.ButtonGroup; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.KPropertyLOVDisplayer; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +@SuppressWarnings("unchecked") +public class CreatTechWordDialogW extends AbstractAIFDialog implements ActionListener{ + /** + * + */ + private static final long serialVersionUID = 1L; + + private AbstractAIFApplication app; + private TCSession session; + private JPanel mainJpanel; + private JPanel leftJpanel; + private JPanel basicInfoJpanel; + private JPanel selectItemJpanel; + private JPanel rightJpanel; + private JCheckBox zjtsyq; + private JPanel createInfoJpanel; + private String selectType; + private String selectSecondDoc; + private String selectDocCategory; + private JButton okButton; + private JButton celButton; + private JButton searchButton; + private JButton selectButton; + + JTextField[] searchField=null; +// JTextField itemNameField=new JTextField(15); + JRadioButton[] radioButton=null; + ButtonGroup bg=new ButtonGroup(); + private JPanel bottomJpanel; + + + String opType; + public CreatTechWordDialogW(String opType, AbstractAIFApplication app) { + super(AIFUtility.getActiveDesktop()); + this.app=app; + this.opType=opType; + this.session=(TCSession) app.getSession(); + } + + @Override + public void run() { +// super.run();//ע򴰿ʾ + try { + DocumentUtil.readProperty( session, "Connor_AVIC_NewDocumentBasicW", "Connor_AVIC_NewDocumentCreationW");//excelжȡϢ + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + } + + + + Dimension dimension=new Dimension(250,30); + JLabel[] basicLabel=null; + JLabel[] searchLabel=null; + JTextField[] basicText=null; + JComboBox[] basicCom=null; + Map basicMap=new HashMap(); + Map basicMap2=new LinkedHashMap();//ź׺Ϣ + Map basicPropertyMap=new HashMap(); + Map createMap=new HashMap(); + Map searchMap=new HashMap(); + DefaultComboBoxModel model1=null; + DefaultComboBoxModel model2=null; + DefaultComboBoxModel model3=null; + List listq=null; + private void initUI() { + this.setTitle("ͱĵ"); + + okButton=new JButton(""); + okButton.addActionListener(this); + celButton=new JButton("ȡ"); + celButton.addActionListener(this); + searchButton=new JButton("ѯ"); + this.getRootPane().setDefaultButton(searchButton);//õǰĬѡаť + searchButton.addActionListener(this); + selectButton=new JButton("ѡ"); + selectButton.addActionListener(this); + + + this.setLayout(new BorderLayout()); + + this.setSize(850, 550); + mainJpanel = new JPanel(new PropertyLayout()); + mainJpanel.setPreferredSize(new Dimension(950, 600)); + leftJpanel = new JPanel(new PropertyLayout()); + leftJpanel.setPreferredSize(new Dimension(500, 600)); + basicInfoJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel = new JPanel(new PropertyLayout()); + selectItemJpanel.setPreferredSize(new Dimension(500, 300)); + rightJpanel = new JPanel(new PropertyLayout()); + rightJpanel.setPreferredSize(new Dimension(550, 350)); + createInfoJpanel = new JPanel(new PropertyLayout()); +// createInfoJpanel.setPreferredSize(new Dimension(400, 280)); + + basicInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + + basicLabel=new JLabel[DocumentUtil.excelPre.length-2]; + basicText=new JTextField[DocumentUtil.excelPre.length-2]; + basicCom=new JComboBox[3]; + + + int a=2; + String houzhui=""; + for (int i = 1; i < DocumentUtil.excelPre.length-1; i++) { + String[] proValue = DocumentUtil.excelPre[i].split("="); + basicLabel[i-1]=new JLabel(proValue[0]); + basicLabel[i-1].setPreferredSize(new Dimension(90,25)); + String value2= proValue[1]; + basicInfoJpanel.add(a+".1.left.top",new JLabel(" ")); + basicInfoJpanel.add(a+".2.left.top", basicLabel[i-1]); + + if(value2.toLowerCase().startsWith("itemrevisionmaster")) { + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + }else if(value2.toLowerCase().startsWith("sheet")){ + // sheetʹӱлȡֵ һ=sheet.itemrevisionmaster.ac5_yjjh + basicText[i-1]=new JTextField(15); + basicInfoJpanel.add(a+".3.left.top", basicText[i-1]); + basicMap.put(basicLabel[i-1],basicText[i-1]); + basicMap2.put(basicLabel[i-1],basicText[i-1]); +// basicPropertyMap.put(basicLabel[i-1], value2.split("\\.")[1]); + }else{ + if(i==1) { + model1=new DefaultComboBoxModel(DocumentUtil.jcomboxList_1.toArray(new String[DocumentUtil.jcomboxList_1.size()])); + basicCom[0]=new JComboBox<>(model1); + basicCom[0].setPreferredSize(dimension); + basicCom[0].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getItem() != null) { + selectType = (String) e.getItem(); + System.out.println("1ѡ==="+selectType); + List list=DocumentUtil.map1_2.get(selectType); + List list2=new ArrayList<>(); + model2.removeAllElements(); +// basicCom[1].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + System.out.println("212"+string); + list2.add(string.split("###")[1]); + model2.addElement(string.split("###")[1]); +// basicCom[1].addItem(string.split("###")[1]); + } +// model2=new DefaultComboBoxModel(list2.toArray(new String[list2.size()])); +// basicCom[1]=new JComboBox(model2); + } + } + }); + }else if(i==2) { + String xx=DocumentUtil.jcomboxList_1.get(0); + List list=DocumentUtil.map1_2.get(xx); + List list2=new ArrayList<>(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + System.out.println("228"+string); + list2.add(string.split("###")[1]); + + } + + model2=new DefaultComboBoxModel(list2.toArray(new String[list2.size()])); + basicCom[1]=new JComboBox<>(model2); + basicCom[1].setPreferredSize(dimension); + basicCom[1].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + + if(e.getStateChange()==ItemEvent.SELECTED) { + + selectSecondDoc = (String) e.getItem(); + if(selectType==null) { + selectType = (String) basicCom[0].getSelectedItem(); + } + System.out.println("2ѡ==="+selectType+"###"+selectSecondDoc+"www"); + List list=DocumentUtil.map2_3.get(selectType+"###"+selectSecondDoc); + listq=new ArrayList(); + model3.removeAllElements(); +// basicCom[2].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + + System.out.println(Thread.currentThread().getStackTrace()[1].getLineNumber()+string); + model3.addElement(string.split("-")[0]);//غ׺ + listq.add(string); +// basicCom[2].addItem(string); + + } + DocumentUtil.sethouzhui(listq, selectDocCategory, basicMap2); + + } + } + }); + }else if(i==3) { + String xx=DocumentUtil.jcomboxList_1.get(0); + List list=DocumentUtil.map1_2.get(xx); + List list2=DocumentUtil.map2_3.get(list.get(0)); + final List list2New=new ArrayList(); + + for (int j = 0; j < list2.size(); j++) { + list2New.add(list2.get(j).split("-")[0]); + } + + houzhui=list2.get(0); + + System.out.println("houzhui======"+houzhui); + + // ı + model3=new DefaultComboBoxModel(list2New.toArray(new String[list2New.size()])); + basicCom[2]=new JComboBox<>(model3); + basicCom[2].setPreferredSize(dimension); + + basicCom[2].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if(e.getStateChange()==ItemEvent.SELECTED) { + + selectDocCategory = (String) e.getItem(); + System.out.println("3ѡ==="+selectDocCategory); +// setFileName2(); + DocumentUtil.reset(basicMap, createMap); + // 20200727 + if(listq==null) { + System.out.println("3ѡ0==="+(String)basicCom[0].getItemAt(0)+"###"+(String)basicCom[1].getItemAt(0)+"www"); + selectSecondDoc = (String)basicCom[1].getSelectedItem(); + selectType= (String)basicCom[0].getSelectedItem(); + System.out.println("3ѡ1==="+selectType+"###"+selectSecondDoc+"www"); + List list=DocumentUtil.map2_3.get(selectType+"###"+selectSecondDoc); + listq=new ArrayList(); +// basicCom[2].removeAllItems(); + for (int j = 0; j < list.size(); j++) { + String string = list.get(j); + + System.out.println(Thread.currentThread().getStackTrace()[1].getLineNumber()+string); + model3.addElement(string.split("-")[0]);//غ׺ + listq.add(string); +// basicCom[2].addItem(string); + + } + } + DocumentUtil.sethouzhui(listq, selectDocCategory, basicMap2); + +// String houzhui1=list2.get(0); + + System.out.println("end"); + } + } + }); + } + + + + + + basicInfoJpanel.add(a+".3.left.top", basicCom[i-1]); + basicMap.put(basicLabel[i-1],basicCom[i-1]); + } + a++; + } + + + + //״μ + int count1 = 1; + for (Map.Entry me : basicMap2.entrySet()) { + JTextField field = (JTextField) me.getValue(); + field.setText(houzhui.split("-")[count1]); + count1++; + } + + + leftJpanel.add("1.1.left.top",basicInfoJpanel); + int i=1; + selectItemJpanel.add(i+".1.left.top",new JLabel("ѡ ")); + i++; +// selectItemJpanel.add(i+".1.left.top",new JLabel(" ѯѡ")); +// i++; + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchW"); + searchLabel=new JLabel[values.length-1]; + + searchField=new JTextField[values.length-1]; + for (int j = 0; j < searchField.length; j++) { + searchField[j]=new JTextField(15); + searchLabel[j]=new JLabel(values[j+1]); + searchLabel[j].setPreferredSize(new Dimension(90,25)); + searchMap.put(searchLabel[j], searchField[j]); + } + +// session.search(arg0, arg1, arg2) + for (int j = 1; j < values.length; j++) { +// String string = values[j]; + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + selectItemJpanel.add(i+".2.left.top",searchLabel[j-1]); + selectItemJpanel.add(i+".3.left.top",searchField[j-1]); + if(j==values.length-1) { + selectItemJpanel.add(i+".4.left.top",searchButton); + } + i++; + + } + + selectItemJpanel.add(i+".1.left.top",new JLabel(" ")); + JLabel label= new JLabel("ѯ"); + label.setPreferredSize(new Dimension(90,25)); + selectItemJpanel.add(i+".2.left.top",label); + resultPanel=new JPanel(new PropertyLayout()); + + scrollPane=new JScrollPane(resultPanel); + scrollPane.setPreferredSize(new Dimension(250,150)); + scrollPane.getVerticalScrollBar().setUnitIncrement(20); + selectItemJpanel.add(i+".3.left.top",scrollPane); + selectItemJpanel.add(i+".4.left.top",selectButton); + + leftJpanel.add("2.1.left.top",selectItemJpanel); + + createInfoJpanel.add("1.1.left.top",new JLabel("Ϣ")); + int b=2; + for (int j = 0; j < DocumentUtil.createInfo.length; j++) { + createInfoJpanel.add(b+".1.left.top",new JLabel(" ")); + String[] string = DocumentUtil.createInfo[j].split("="); + DocumentUtil.createLabel[j]=new JLabel(string[0]); + DocumentUtil.createLabel[j].setPreferredSize(new Dimension(90,25)); + createInfoJpanel.add(b+".2.left.top",DocumentUtil.createLabel[j]); + if(string.length>1) { + if(string[1].startsWith("#")) {//TODO + DocumentUtil.createCom[j] = new MultiCombo(session.getPreferenceService().getStringValues(string[1].substring(1))); + DocumentUtil.createCom[j].setPreferredSize(new Dimension(250, 30)); + DocumentUtil.createCom[j].setEditable(true); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createCom[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createCom[j]); + b++; + continue; + } + DefaultComboBoxModel model; + String[] lovs=string[1].split(";"); + List list=new ArrayList(); + for (int k = 0; k < lovs.length; k++) { + list.add(lovs[k]); + + } + + model=new DefaultComboBoxModel(list.toArray(new String[list.size()])); + DocumentUtil.createCom[j]=new JComboBox<>(model); + DocumentUtil.createCom[j].setPreferredSize(new Dimension(150, 30)); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createCom[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createCom[j]); + if(string[0].equals("ܼ")) { + DocumentUtil.mjCom=DocumentUtil.createCom[j]; + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.mjCom); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.mjCom); + + DocumentUtil.createCom[j].addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + try { + System.out.println("ip_clearance==========="+session.getUser().getStringProperty("ip_clearance")); + } catch (Exception e2) { + e2.printStackTrace(); + } + + System.out.println("ѡ====="+e.getItem().toString()); + if (e.getStateChange() == ItemEvent.SELECTED) { + try { + KPropertyLOVDisplayer.checkIP(e.getItem().toString()); + } catch (Exception e1) { + DocumentUtil.mjCom.setSelectedIndex(-1); + MessageBox.post("ûܼ޸ĺִܼܹд˲","",MessageBox.INFORMATION); + } + + } + } + }); + } + }else { + DocumentUtil.createText[j]=new JTextField(15); + createMap.put(DocumentUtil.createLabel[j], DocumentUtil.createText[j]); + createInfoJpanel.add(b+".3.left.top",DocumentUtil.createText[j]); + } + + b++; + + } + for(java.util.Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("Ʋ")) { + String groupName=null; + try { +// groupName = session.getGroup().getFullName();//Ҫػ + groupName=session.getGroup().getProperty("display_name"); + if(groupName.split("\\.").length>0) { + groupName=groupName.split("\\.")[0]; + } + } catch (Exception e1) { + e1.printStackTrace(); + } + ((JTextField)me.getValue()).setText(groupName); + } + + } + rightJpanel.add("1.1.left.top",createInfoJpanel); + + mainJpanel.add("1.1.left.top",leftJpanel); + mainJpanel.add("1.2.left.top",rightJpanel); + bottomJpanel=new JPanel(new FlowLayout()); + bottomJpanel.add(okButton); + bottomJpanel.add(celButton); + //ͨȡѡЩؼɱ༭(jlabel*,*Ҳü) + String[] editable=session.getPreferenceService().getStringValues("Connor_AVIC_editableW"); + for (int j = 0; j < editable.length; j++) { + boolean boo=false; + String string = editable[j]; + boo=DocumentUtil.setEditable(createMap,string); + if(boo==false) { + + boo=DocumentUtil.setEditable(basicMap,string); + if(boo==false) { + + DocumentUtil.setEditable(searchMap,string); + } + } + + } + zjtsyq=new JCheckBox("Ҫ"); + zjtsyq.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JTextField field=null; + JTextField field1=null; + JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ļ")) { + field=((JTextField)me.getValue()); + } + + } + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { + field1=((JTextField)me.getValue()); + } + if(me.getKey().getText().contains("ͼ")) { + field2=((JTextField)me.getValue()); + } + + } + if(zjtsyq.isSelected()) { + field.setEditable(true); + field.setText(""); + field1.setEditable(true); + field2.setEditable(true); + }else { + field.setEditable(false); + field.setText(""); + field1.setEditable(false); + field2.setEditable(false); + } + } + }); + this.add(zjtsyq,BorderLayout.NORTH); + this.add(mainJpanel,BorderLayout.CENTER); + this.add(bottomJpanel,BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + JPanel resultPanel=new JPanel(new PropertyLayout()); + JScrollPane scrollPane=new JScrollPane(resultPanel); + + + + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObj = e.getSource(); + if(sourceObj.equals(selectButton)){ + this.getRootPane().setDefaultButton(okButton);//õǰĬѡаť + String item_id=""; + for(int i=0;i me:basicPropertyMap.entrySet()) { + String property=me.getKey().getText(); + System.out.println("property========="+property); + String value=form.getProperty(me.getValue()); + System.out.println("value========="+value); + JTextField field=(JTextField) basicMap.get(me.getKey()); + field.setText(value); + //ͼţȡitem_id + if(property.contains("ͼ")) { + field.setText(item.getProperty("item_id")); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + //Ըֵ + //ƣͺ+ĵ+ˮֹ޸ģ +// JTextField field0=null; +// JComboBox combox1=null; + + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { +// field0=((JTextField)me.getValue()); + } + + if(me.getKey().getText().startsWith("ĵ")) { +// combox1=((JComboBox)me.getValue()); + } + + } + + //ѡڸƣʵļƺļ +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + String yjjh="";//һ + for(Map.Entry me: basicMap2.entrySet()) { + if(me.getKey().getText().equals(DocumentUtil.wz)) { + yjjh=((JTextField)me.getValue()).getText(); + } + } + DocumentUtil.setFileName2("Connor_AVIC_NewDocumentSerialW",basicMap,createMap,zjtsyq, session, basicCom,yjjh); + }else if(sourceObj.equals(okButton)){ +// + //ӱУ + JTextField fieldX=null; + String message=""; + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("*")&& me.getValue() instanceof JTextField) { + System.out.println("598"+me.getKey().getText()); + fieldX=((JTextField)me.getValue()); + if(fieldX.getText().trim().length()==0) { + message=message+me.getKey().getText()+";"; + } + } + + } + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("*")) { + System.out.println("608"+me.getKey().getText()); + fieldX=((JTextField)me.getValue()); + if(fieldX.getText().trim().length()==0) { + message=message+me.getKey().getText()+";"; + } + } + + } + + if(message.length()>0) { + + MessageBox.post(":"+message,"",MessageBox.INFORMATION); + }else { + //УǷзǷַ + + JTextField fieldName=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ʵļ")) { + fieldName=((JTextField)me.getValue()); + } + + } + String filename=fieldName.getText(); + if(DocumentUtil.isValidFileName(filename)==false) { + + MessageBox.post("ʵļƺзǷַϵԱ޸ģļ","",MessageBox.INFORMATION); + }else { + + if(zjtsyq.isSelected()==true) { + JTextField field=null; + for(Map.Entry me:basicMap.entrySet()) { + if(me.getKey().getText().contains("Ʒͺ")) { + field=((JTextField)me.getValue()); + } + + } + if(field.getText().length()>0) { +// this.disposeDialog(); +// this.dispose(); + }else { + + + MessageBox.post("ƷͺŲΪ","",MessageBox.INFORMATION); + } + }else { + +// this.disposeDialog(); +// this.dispose(); + } + // + String yjjh="";//һ + for(Map.Entry me: basicMap2.entrySet()) { + if(me.getKey().getText().equals(DocumentUtil.wz)) { + yjjh=((JTextField)me.getValue()).getText(); + } + } + DocumentUtil.setFileName("Connor_AVIC_NewDocumentSerialW", basicMap, createMap, session, zjtsyq, basicCom,yjjh); + System.out.println("ļ======"+DocumentUtil.fileCode); + /* + * if(true) { return ; } + */ + try { + Map map=DocumentUtil.getPuid("Connor_AVIC_NewDocumentBasicW",session); + selectType=(String) basicCom[0].getSelectedItem(); + selectSecondDoc=(String) basicCom[1].getSelectedItem(); + selectDocCategory=(String) basicCom[2].getSelectedItem(); + String puid=""; + for (Map.Entry me:map.entrySet()) { + String keyName=me.getKey(); + if(keyName.contains(selectType+"-"+selectSecondDoc+"-"+selectDocCategory)) { + puid=map.get(keyName); + } + } +// String puid=map.get(selectType+"-"+selectSecondDoc+"-"+selectDocCategory); +// System.out.println(selectType+"-"+selectSecondDoc+"-"+selectDocCategory); + System.out.println(puid); + try { + TCComponentDataset comp=(TCComponentDataset) session.stringToComponent(puid); + TCComponentDataset newdataset=null; + if(comp==null) { + if(puid.length()>0) { + + + MessageBox.post("Ҳĵģ","",MessageBox.INFORMATION); + + return; + }else { + newdataset=null; + } + }else { + + newdataset=comp.saveAs(null); + } + // +// JTextField field2=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().startsWith("")) { +// field2=((JTextField)me.getValue()); + } + + } + + //ʵļ +// JTextField field3=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ʵļ")) { +// field3=((JTextField)me.getValue()); + } + + } +// objectName=field3.getText(); +// newdataset.setStringProperty("object_name", field3.getText()); + if(newdataset!=null) { + newdataset.setStringProperty("object_name", DocumentUtil.entityFileName); + } + TCComponent compX= (TCComponent) app.getTargetComponent(); + TCComponentItemType type=(TCComponentItemType) session.getTypeComponent("Document"); +// JTextField field4=null; + //ͱΪ汾ֵ + JComboBox field5=null; + JComboBox field6=null; + for(Map.Entry me:createMap.entrySet()) { + if(me.getKey().getText().contains("ļ")) { +// field4=((JTextField)me.getValue()); + } + if(me.getKey().getText().contains("ͱ")) { + field5=(JComboBox)me.getValue(); + } + if(me.getKey().getText().contains("汾")) { + field6=(JComboBox)me.getValue(); + } + + } +// TCComponentItem item=type.create(field4.getText(), field5.getSelectedItem()+"00", "Ac5_MilitaryDoc", +// field2.getText(), "", null); + + if(DocumentUtil.fileCode.length()>0) { + + boolean create=false; + try { + // ѯ +// TCComponent[] comps=session.search("DocSearch1", new String[] {"ĵ"}, new String[] {DocumentUtil.fileCode}); + TCComponent[] comps=session.search(" ID", new String[] {" ID"}, new String[] {DocumentUtil.fileCode}); + if(comps.length>0) { + create=false; + }else { + create=true; + } + } catch (Exception e2) { + e2.printStackTrace(); + } + + if(create==false) { + +// MessageBox.post("ļ"+DocumentUtil.fileCode+"Ψһ޸","",MessageBox.INFORMATION); + MessageBox.post("ID"+DocumentUtil.fileCode+"ΨһԹд","",MessageBox.INFORMATION); + + }else { + this.disposeDialog(); + this.dispose(); + DocumentUtil.createNewItem("Connor_AVIC_NewDocumentThesignW",getClass(),session,basicMap,createMap, + DocumentUtil.entityFileName,DocumentUtil.fileCode,type,DocumentUtil.fileName,compX,field5, + field6,newdataset,"Ac5_GeneralDoc","Connor_AVIC_SetFormPropertyW",DocumentUtil.yjjh); + + } + }else { + + MessageBox.post("дļ","",MessageBox.INFORMATION); + + } + + + + } catch (Exception e1) { + e1.printStackTrace(); + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + } + + }else if(sourceObj.equals(celButton)){ + + this.disposeDialog(); + this.dispose(); + }else if(sourceObj.equals(searchButton)){ + this.getRootPane().setDefaultButton(selectButton);//õǰĬѡаť + String[] values=session.getPreferenceService().getStringValues("Connor_AVIC_SearchW"); + + String[] selectItem=new String[values.length-1]; + String[] selectValue=new String[values.length-1]; + int i=0; + boolean isNull=true; + for(java.util.Map.Entry me:searchMap.entrySet()) { + + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { +// value="*"; + }else { + i++; + } + } + selectItem=new String[i]; + selectValue=new String[i]; + i=0; + for(java.util.Map.Entry me:searchMap.entrySet()) { + String key=me.getKey().getText(); + JTextField field=(JTextField) me.getValue(); + String value=field.getText().trim(); + if(value.length()==0) { +// value="*"; + }else { + value="*"+value+"*"; + isNull=false; + selectItem[i]=key; + selectValue[i]=value; + i++; + } + } + + if(isNull==true) { + + MessageBox.post("ĿȫΪ","",MessageBox.INFORMATION); + + }else { + + try { +// TCComponent[] comps=session.search(values[0], selectItem, selectValue); + TCComponent[] comps=DocumentUtil.getResult(session,searchMap,values[0]); + System.out.println("========"+comps.length); + this.disposeDialog(); + this.showDialog(); + radioButton=new JRadioButton[comps.length]; + radioMap=new HashMap(); + resultPanel.removeAll(); +// scrollPane.remove(resultPanel); + bg=new ButtonGroup(); + //ѯóɿõ + String[] properties=session.getPreferenceService().getStringValues("Connor_AVIC_SearchPropertiesW"); + if(comps.length==0) { + + MessageBox.post("ѯΪ","",MessageBox.INFORMATION); + + } + for (int j = 0; j < comps.length; j++) { + TCComponent tcComponent = comps[j]; + String name=""; + for (int k = 0; k < properties.length; k++) { + //ְ汾Ͷ + TCComponent tcComponent0=null; + String[] ps=properties[k].split("\\."); + System.out.println(); + if(ps[0].toUpperCase().equals("REV")){ + tcComponent0=tcComponent; + }else if(ps[0].toUpperCase().equals("REVMASTER")) { + tcComponent0=tcComponent.getRelatedComponents("IMAN_master_form_rev")[0]; + } + name=name+tcComponent0.getProperty(ps[1]); + if(k radioMap=new HashMap(); + + + + + + + + + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/CreatTechWordHandler.java b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordHandler.java new file mode 100644 index 0000000..2f3cb5c --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordHandler.java @@ -0,0 +1,85 @@ +package com.connor.pro105.plm.creatTechWord; + +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.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreatTechWordHandler extends AbstractHandler { + ; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("CreatTechWordHandler"); + try { + String commandID = arg0.getCommand().getId(); + String opType = arg0.getCommand().getName(); + System.out.println("------------"+opType); + /* + * if(true) { return 0; } + */ + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCComponent compX = (TCComponent) app.getTargetComponent(); + if(compX == null) { + MessageBox.post(AIFUtility.getActiveDesktop(), "ѡļлαļ", "ERROR", MessageBox.ERROR); + return null; + } + /*TCComponent[] compS= (TCComponent[]) app.getTargetComponents(); + TCComponentTask task; + task.performTaskAction(i, s, s1, s2, tccomponent, list, list1); + for (int i = 0; i < compS.length; i++) { + try { + connorAutoWorkflow(compS[i]); + } catch (TCException e) { + e.printStackTrace(); + } + }*/ + TCComponent parent = compX; + if(compX instanceof TCComponentPseudoFolder) { + parent = compX.getRelatedComponent("owning_object"); + } + TCSession session = (TCSession) app.getSession(); + if(!session.getTCAccessControlService().checkPrivilege(parent, "WRITE")) { + MessageBox.post(AIFUtility.getActiveDesktop(), parent + " ޸Ȩޣ", "ERROR", MessageBox.ERROR); + return null; + } + if(compX instanceof TCComponentFolder || compX instanceof TCComponentPseudoFolder) { + CreatTechWordAction action = new CreatTechWordAction(commandID, opType, app, null); + new Thread(action).start(); + }else { + MessageBox.post(AIFUtility.getActiveDesktop(), "ѡļлαļ", "ERROR", MessageBox.ERROR); + return null; + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(AIFUtility.getActiveDesktop(), ""+e.toString(), "ERROR", MessageBox.ERROR); + } + return null; + } + /** + * cˢ + * + * @param item + * 汾 + * @param statusName + * Ϣ + * @throws TCException + + public void connorAutoWorkflow(TCComponent task ) throws TCException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[1]; + obj[0] = task; + userservice.call("connor_auto_workflow", obj); + + }*/ + +} diff --git a/src/com/connor/pro105/plm/creatTechWord/CreatTechWordOperation.java b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordOperation.java new file mode 100644 index 0000000..424210e --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/CreatTechWordOperation.java @@ -0,0 +1,239 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.Color; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +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 org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFColor; +import org.apache.poi.xssf.usermodel.XSSFFont; +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.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.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.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreatTechWordOperation extends AbstractAIFOperation { + private AbstractAIFApplication app; + private String exportFile; + private TCSession session; + private TCPreferenceService tcPreferenceService; + private List valueLists = new ArrayList();//йʱϢļ + + private FileInputStream fis; + private FileOutputStream fos; + private XSSFWorkbook workBook; + private ProgressBarThread wait; + int total=0; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); + public CreatTechWordOperation(ProgressBarThread wait, + AbstractAIFApplication app, String exportFile) { + this.app = app; + this.exportFile = exportFile; + this.session = (TCSession) app.getSession(); + this.wait = wait; + } + + + @Override + public void executeOperation() throws Exception { + + //ȡ + //̷ѡHX_Process + + long start = System.currentTimeMillis(); + String ssx = "hxc_risks";// ģѡwhdlh$E4aTDHqA AzWlG7qWYvbLjA + //ϵͳеHxc8XM ,ҵϵHxc8wtdͷյHxc8fengxian + TCComponent[] projects=session.search("...", new String[] {""}, new String[] {"Hxc8XM"}); + System.out.println("Ŀ--------"+projects.length); + for(int i=0;i searchMap,String queryName) throws Exception { + TCComponent[] items=null; + List keyList = new ArrayList(); + List valueList = new ArrayList(); + for (java.util.Map.Entry me : searchMap.entrySet()) { + String key = me.getKey().getText(); + JTextField field = (JTextField) me.getValue(); + String value = field.getText().trim(); + if (value.length() == 0) { +// value="*"; + } else { + value = "*" + value + "*"; + keyList.add(key); + valueList.add(value); + } + } + TCComponentQueryType queryType; + + queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + + TCQueryClause[] qc = query.describe(); + for (int j = 0; j < qc.length; j++) { + String key = qc[j].getUserEntryNameDisplay(); + String defaultValue = qc[j].getDefaultValue(); + if (defaultValue != null && defaultValue.length() > 0) { + keyList.add(key); + valueList.add(defaultValue); + } + } + String[] keyString=new String[keyList.size()]; + String[] valueString=new String[valueList.size()]; + for (int i = 0; i < keyList.size(); i++) { + keyString[i]=keyList.get(i); + valueString[i]=valueList.get(i); + } + + TCComponentContextList list = query.getExecuteResultsList(keyString,valueString); + if (list != null) { + // õѯĶĸ + int count = list.getListCount(); + InterfaceAIFComponent[] result = new InterfaceAIFComponent[count]; + items=new TCComponent[count]; + // ȡѯĶ + for (int j = 0; j < count; j++) { + result[j] = list.get(j).getComponent(); + items[j]=(TCComponent) list.get(j).getComponent(); + System.out.println("result[j]=" + result[j].toString()); + } + } + return items; + } + //ͼţƷͺźļ + public static void reset(Map basicMap,Map createMap) { + JTextField field0 = null; + JTextField field1 = null; + JTextField field2 = null; + + for (Map.Entry me : basicMap.entrySet()) { + if (me.getKey().getText().contains("Ʒͺ")) { + field0 = ((JTextField) me.getValue()); + } + + if (me.getKey().getText().startsWith("ͼ")) { + field1 = ((JTextField) me.getValue()); + } + + } + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("ļ")) { + field2 = ((JTextField) me.getValue()); + } + + } + field0.setText(""); + field1.setText(""); + field2.setText(""); + + } + public static String[] excelPre=null; + public static Map> map1_2=new HashMap<>(); + public static Map> map2_3=new HashMap<>(); + public static List list_1=new ArrayList<>();//һֵǷظ + public static List jcomboxList_1=new ArrayList<>();//һֵǷظ + public static List list_2=new ArrayList<>();//ֵǷظ + public static List list_3=new ArrayList<>();//ֵǷظ + public static Map> map1=new HashMap>(); + public static Map> map2=new HashMap>(); + public static Map> map3=new HashMap>(); + public static String[] createInfo=null; + public static JLabel[] createLabel=null; + public static JTextField[] createText=null; + public static JComboBox[] createCom=null; + public static JComboBox mjCom=null; + + Map> listMap=new HashMap>(); + public static String wz="β׺";//ԭһŸijβ׺ + public static void readProperty(TCSession session,String Connor_AVIC_NewDocumentBasic,String Connor_AVIC_NewDocumentCreation) throws IOException { + excelPre=session.getPreferenceService().getStringValues(Connor_AVIC_NewDocumentBasic); + String[] jcom1=excelPre[1].split("=")[1].split("-"); + String[] jcom2=excelPre[2].split("=")[1].split("-"); + String[] jcom3=excelPre[3].split("=")[1].split("-"); + File fmsFile=DocumentUtil.getExcle(session,excelPre[0]); + FileInputStream fis = new FileInputStream(fmsFile); + XSSFWorkbook workBook = new XSSFWorkbook(fis); + XSSFSheet sheet = workBook.getSheet("ҪռıϢ"); + int rowNum1=sheet.getLastRowNum()+1; + int rowNum=0; + for (int i = 1; i < rowNum1; i++) { + XSSFRow row=sheet.getRow(i); + XSSFCell cell=row.getCell(1); + String string=""; + if(cell!=null&&cell.getStringCellValue().trim().length()>0) { + string=string+cell.getStringCellValue().trim(); + rowNum=i+1; + }else { + rowNum=i; + break; + } + } + map1=new HashMap>();//ŵһӦ + map2=new HashMap>();//ŵڶӦ + map3=new HashMap>();//ŵӦ + int columnNums=0; + for(int i = 0; i < 100; i++) { + XSSFCell cell=sheet.getRow(0).getCell(i); + if(cell!=null) { + columnNums=i+1; + } + + } + + for (int i = 0; i < columnNums; i++) { + String columnName=sheet.getRow(0).getCell(i).getStringCellValue().trim(); + map1=DocumentUtil.findRow(excelPre[1], jcom1, columnName, i,map1); + map2=DocumentUtil.findRow(excelPre[2], jcom2, columnName, i,map2); + map3=DocumentUtil.findRow(excelPre[3], jcom3, columnName, i,map3); + + } + + list_1=new ArrayList<>();//һֵǷظ + list_2=new ArrayList<>();//ֵǷظ + list_3=new ArrayList<>();//ֵǷظ + + jcomboxList_1=DocumentUtil.getList2(excelPre,map1, rowNum, sheet); + list_1=DocumentUtil.getList(excelPre[1], rowNum, sheet, list_1,map1); + list_2=DocumentUtil.getList(excelPre[2], rowNum, sheet, list_2,map2); + list_3=DocumentUtil.getList(excelPre[3], rowNum, sheet, list_3,map3); + + //һmapʽ + map1_2=new HashMap<>(); + for (int i = 0; i < list_1.size(); i++) { + String key=list_1.get(i); + String listValue=key+"###"+list_2.get(i); + if(map1_2.containsKey(key)) { + List list=map1_2.get(key); + if(!list.contains(listValue)) { + list.add(listValue); + map1_2.put(key, list); + } + }else { + List list=new ArrayList<>(); + list.add(listValue); + map1_2.put(key, list); + } + } + //mapʽ + map2_3=new HashMap<>(); + for (int i = 0; i < list_1.size(); i++) { + String key=list_1.get(i)+"###"+list_2.get(i); +// System.out.println("key2======="+key); + String listValue=list_3.get(i); + if(map2_3.containsKey(key)) { + List list=map2_3.get(key); + if(!list.contains(listValue)) { + list.add(listValue); + map2_3.put(key, list); + } + }else { + List list=new ArrayList<>(); + list.add(listValue); + map2_3.put(key, list); + } + } + createInfo=session.getPreferenceService().getStringValues(Connor_AVIC_NewDocumentCreation); + createLabel=new JLabel[createInfo.length]; + createText=new JTextField[createInfo.length]; + createCom=new JComboBox[createInfo.length]; + + + } + public static String yjjh=""; + public static void setFileName2(String Connor_AVIC_NewDocumentSerial,Map basicMap,Map createMap,JCheckBox zjtsyq,TCSession session,JComboBox[] basicCom,String yjjh) { +// JTextField field0 = null; + JComboBox combox1 = null; + + for (Map.Entry me : basicMap.entrySet()) { + if (me.getKey().getText().startsWith("Ʒͺ")) { +// field0 = ((JTextField) me.getValue()); + } + + if (me.getKey().getText().startsWith("ĵ")) { + combox1 = ((JComboBox) me.getValue()); + } + + } + JTextField field2 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("")) { + field2 = ((JTextField) me.getValue()); + } + + } + // ˮ򣺲ѯǰ׺û½ԭĻϼ1 +// ޸ļƹ򣬲ٴвƷͺ +// String finalName = getFlowNumner(field0.getText() + ((String) combox1.getSelectedItem()).split("-")[0]); + String finalName = ((String) combox1.getSelectedItem()).split("-")[0]; + if(field2!=null) { + + field2.setText(finalName); + } + // ʵļ + JTextField field3 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("ʵļ")) { + field3 = ((JTextField) me.getValue()); + } + + } + if(field3!=null) { + + field3.setText(finalName); + } + // ļ ѡ + JTextField field4 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("ļ")) { + field4 = ((JTextField) me.getValue()); + } + + } + String[] value = session.getPreferenceService().getStringValues(Connor_AVIC_NewDocumentSerial); + // :ͼ+һ+FLOW + // :Ʒͺ+*+һ + // ѡ:YEAR+һ+FLOW + // Ҫ: + Map codeMap = new HashMap(); + + for (int i = 0; i < value.length; i++) { + String[] string = value[i].split(":"); + if (string.length == 2) { + String[] allTypes = string[0].split("\\|"); + for (int j = 0; j < allTypes.length; j++) { + codeMap.put(allTypes[j], string[1]); + + } + } + } + if (zjtsyq.isSelected()) { + + } else { + DocumentUtil.selectType = (String) basicCom[0].getSelectedItem(); + System.out.println("selectType================"+DocumentUtil.selectType); + String codeRule = codeMap.get(DocumentUtil.selectType); + System.out.println("codeRule================"+codeRule); + String finalCode = ""; + if (codeRule != null) { + System.out.println(codeRule); + String[] codes = codeRule.split("\\+"); + for (int i = 0; i < codes.length; i++) { + String string = codes[i]; + if (string.startsWith("FLOW")) { + // ѯݿ +// finalCode = getFileFlowNumner(finalCode, string); + } else if (string.startsWith("YEAR")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); + String kk = sdf.format(new Date()); + finalCode = finalCode + kk; + } else if (string.startsWith(DocumentUtil.wz)) { +// JComboBox wdlb = null; + for (Map.Entry me : basicMap.entrySet()) { + + if (me.getKey().getText().startsWith("ĵ")) { +// wdlb = ((JComboBox) me.getValue()); + } + + } + finalCode = finalCode + yjjh; +// yjjh=((String) wdlb.getSelectedItem()).split("-")[1]; + } else { + JTextField filedX = null; + JComboBox jcomboxX = null; + for (Map.Entry me : basicMap.entrySet()) { + if (me.getKey().getText().equals(string)) { + try { + filedX = ((JTextField) me.getValue()); + } catch (Exception e1) { + jcomboxX = ((JComboBox) me.getValue()); + } + } + } + if (filedX != null) { + finalCode = finalCode + filedX.getText().trim(); + } else { + finalCode = finalCode + ((String) jcomboxX.getSelectedItem()).trim(); + } + } + + } + + } + System.out.println("finalCode======================="+finalCode); + if(field4!=null) { + + field4.setText(finalCode); + } + } + } + public static void setFileName(String sxxName,Map basicMap,Map createMap, + TCSession session,JCheckBox zjtsyq,JComboBox[] basicCom,String yjjh) { +// JTextField field0 = null; +// JComboBox combox1 = null; + + for (Map.Entry me : basicMap.entrySet()) { + if (me.getKey().getText().contains("Ʒͺ")) { +// field0 = ((JTextField) me.getValue()); + } + + if (me.getKey().getText().startsWith("ĵ")) { +// combox1 = ((JComboBox) me.getValue()); + } + + } + JTextField field2 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("")) { + field2 = ((JTextField) me.getValue()); + } + + } + // ˮ򣺲ѯǰ׺û½ԭĻϼ1 +// ޸ļƹ򣬲ٴвƷͺ +// String finalName = getFlowNumner(field0.getText() + ((String) combox1.getSelectedItem()).split("-")[0]); + //20200615 ٸƼˮ + /*String finalName = getFlowNumner(((String) combox1.getSelectedItem()).split("-")[0]); + if(field2!=null) { + + field2.setText(finalName); + }*/ + fileName=field2.getText(); + // ʵļ + JTextField field3 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("ʵļ")) { + field3 = ((JTextField) me.getValue()); + } + + } + /*if(field3!=null) { + + field3.setText(finalName); + }*/ + entityFileName=field3.getText(); + // ļ ѡ + JTextField field4 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().contains("ļ")) { + field4 = ((JTextField) me.getValue()); + } + + } + String[] value = session.getPreferenceService().getStringValues(sxxName); + // :ͼ+һ+FLOW + // :Ʒͺ+*+һ + // ѡ:YEAR+һ+FLOW + // Ҫ: + Map codeMap = new HashMap(); + + for (int i = 0; i < value.length; i++) { + String[] string = value[i].split(":"); + if (string.length == 2) { + String[] allTypes = string[0].split("\\|"); + for (int j = 0; j < allTypes.length; j++) { + codeMap.put(allTypes[j], string[1]); + + } + } + } + if (zjtsyq.isSelected()) { + fileCode=field4.getText(); + } else { + selectType = (String) basicCom[0].getSelectedItem(); + System.out.println("selectType================"+selectType); + String codeRule = codeMap.get(selectType); + System.out.println("codeRule================"+codeRule); + String finalCode = ""; + if (codeRule != null) { + System.out.println(codeRule); + String[] codes = codeRule.split("\\+"); + for (int i = 0; i < codes.length; i++) { + String string = codes[i]; + if (string.startsWith("FLOW")) { + // ѯݿ + finalCode = DocumentUtil.getFileFlowNumner(session,finalCode, string); + } else if (string.startsWith("YEAR")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); + String kk = sdf.format(new Date()); + finalCode = finalCode + kk; + } else if (string.startsWith(DocumentUtil.wz)) { +// JComboBox wdlb = null; + for (Map.Entry me : basicMap.entrySet()) { + + if (me.getKey().getText().contains("ĵ")) { +// wdlb = ((JComboBox) me.getValue()); + } + + } +// finalCode = finalCode + ((String) wdlb.getSelectedItem()).split("-")[1]; + finalCode = finalCode + yjjh; + } else { + JTextField filedX = null; + JComboBox jcomboxX = null; + for (Map.Entry me : basicMap.entrySet()) { + if (me.getKey().getText().contains(string)) { + try { + filedX = ((JTextField) me.getValue()); + } catch (Exception e1) { + jcomboxX = ((JComboBox) me.getValue()); + } + } + } + if (filedX != null) { + finalCode = finalCode + filedX.getText().trim(); + } else { + finalCode = finalCode + ((String) jcomboxX.getSelectedItem()).trim(); + } + } + + } + + } + System.out.println("finalCode======================="+finalCode); + fileCode=finalCode; + if(field4!=null) { + + field4.setText(finalCode); + } + } + } + public static String fileCode=""; + public static String selectType=""; + public static String entityFileName=""; + public static String fileName=""; + public static void createNewItem(String sxxName,Class class1,TCSession session,Map basicMap, + Map createMap,String entityFileName, + String fileCode,TCComponentItemType type,String fileName,TCComponent compX,JComboBox field5, + JComboBox field6,TCComponentDataset newdataset,String docType,String Connor_AVIC_SetFormProperty,String yjjh) throws TCException { + TCComponentItem item=null; + if(docType.equals("Ac5_SoftTechDoc")) { +// item=type.create(fileCode, "00", docType, fileName, "", null); + System.out.println("°汾======================="+type.getNewRev(null)); +// item=type.create(null, null, docType, fileName, "", null); + item=type.create(fileCode, null, docType, fileName, "", null); + }else if(docType.equals("Ac5_GeneralDoc")) { +// item=type.create(fileCode, (String)field5.getSelectedItem()+(String)field6.getSelectedItem(), docType, fileName, "", null); +// item=type.create(null, (String)field6.getSelectedItem(), docType, fileName, "", null); + item=type.create(fileCode, (String)field6.getSelectedItem(), docType, fileName, "", null); + }else { +// item=type.create(null, (String)field5.getSelectedItem()+(String)field6.getSelectedItem(), docType, fileName, "", null); + item=type.create(fileCode, (String)field5.getSelectedItem()+(String)field6.getSelectedItem(), docType, fileName, "", null); + + } + if(newdataset!=null) { + + item.getLatestItemRevision().add("IMAN_specification", newdataset); + } + // 汾 Connor_AVIC _ SetFormProperty +//Ʒͺ=itemrevisionmaster.ac5_ProductModel:TEXT +// ͼ=itemrevisionmaster.ac5_PatternCodes:TEXT +// ܼ=itemrevisionmaster.ip_classification:LOV +// ͱ=itemrevisionmaster.ac5_Type:LOV +// ͱ=itemrevisionmaster.ac5_Xblx:LOV +// Ʋ=itemrevisionmaster.ac5_Bzbm:LOV + + String[] propertyName=session.getPreferenceService().getStringValues(Connor_AVIC_SetFormProperty); + Map mapX=new HashMap<>(); + for (int i = 0; i < propertyName.length; i++) { + String[] value=propertyName[i].split("="); + mapX.put(value[0], value[1]); + } + Map propertyValue=new HashMap<>(); + for(java.util.Map.Entry me:basicMap.entrySet()) { + if(mapX.containsKey(me.getKey().getText())) { + String value=""; + Object comp = me.getValue(); + if(comp instanceof MultiCombo) + value = ((MultiCombo)comp).getValue();//TODO + else if(comp instanceof JTextField) + value=((JTextField)comp).getText(); + else + value=(String)((JComboBox)comp).getSelectedItem(); + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + + } + for(java.util.Map.Entry me:createMap.entrySet()) { + if(mapX.containsKey(me.getKey().getText())) { + String value=""; + Object comp = me.getValue(); + if(comp instanceof MultiCombo) + value = ((MultiCombo)comp).getValue();//TODO + else if(comp instanceof JTextField) + value=((JTextField)comp).getText(); + else + value=(String)((JComboBox)comp).getSelectedItem(); + propertyValue.put(mapX.get(me.getKey().getText()), value); + } + + } + TCComponentForm form=(TCComponentForm) item.getLatestItemRevision().getRelatedComponents("IMAN_master_form_rev")[0]; + form.setStringProperty("ac5_Finalsyllabel",yjjh); + TCComponent tccomponentX=form; + TCComponentItemRevision itemRev=item.getLatestItemRevision(); + TCComponent itemMaster=item.getRelatedComponents("IMAN_master_form")[0]; + + for(java.util.Map.Entry me:propertyValue.entrySet()) { + String objectType=me.getKey().split("\\.")[0]; + String valueType=me.getKey().split("\\.")[1].split(":")[1]; + String pname=me.getKey().split("\\.")[1].split(":")[0]; + if(objectType.toLowerCase().equals("itemrevisionmaster")) { + tccomponentX=form; + }else if(objectType.toLowerCase().equals("item")) { + tccomponentX=item; + }else if(objectType.toLowerCase().equals("itemrevision")) { + tccomponentX=itemRev; + } + if(valueType.toLowerCase().equals("text")) { + if( me.getValue()!=null) { + tccomponentX.setStringProperty(pname, me.getValue()); + } + + }else if(valueType.toLowerCase().equals("lov")) { + System.out.println(""+pname); + System.out.println(""+me.getValue()); + if(me.getValue()!=null) { + System.out.println(tccomponentX==null); + System.out.println(tccomponentX.getTCProperty(pname)==null); + System.out.println(tccomponentX.getTCProperty(pname).getLOV()==null); + String trueValue=(String) tccomponentX.getTCProperty(pname).getLOV().getListOfValues().getRealValue(me.getValue()); + tccomponentX.setStringProperty(pname, trueValue); + if(pname.equals("ip_classification")) { + item.setProperty(pname, trueValue); + itemMaster.setProperty(pname, trueValue); + itemRev.setProperty(pname, trueValue); + form.setProperty(pname, trueValue); + } + } + } + } + //ļ + if(newdataset!=null) { + // ͨcmdķʽwsfļϣҪעexcelword + String testPath = ""; + testPath = DocumentUtil.downLoadFile(newdataset); + //ļ + String dataFile=""; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm")|| testPath.endsWith(".docx") + || testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx")|| testPath.endsWith(".xls") + ) { + try { + dataFile=DocumentUtil.jk_SetCAXAFile(sxxName,session,newdataset,true); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + String wsfType="word"; + if (testPath.endsWith(".doc") || testPath.endsWith(".docm")|| testPath.endsWith(".docx") + ) { + wsfType="word"; + }else if( testPath.endsWith(".xlsm") || testPath.endsWith(".xlsx")|| testPath.endsWith(".xls") + ){ + wsfType="excel"; + } + //ȡwsfļλ,滻 + String wsfpath=null; + File file=new File(testPath); + String path=testPath.substring(0,testPath.lastIndexOf("\\")+1); + String suffix=testPath.substring(testPath.lastIndexOf("."),testPath.length()); + System.out.println(path); + System.out.println(suffix); + try { + if(wsfType.equals("word")) { + + wsfpath = getFileFromClass(class1, "SubstMacros-MSWord.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath,new String[] { testPath,dataFile}); + + //ļ +// testPath=path+objectName+suffix; + testPath=path+entityFileName+suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] {testPath},new String[] { "word"}); + }else if(wsfType.equals("excel")) { + wsfpath = getFileFromClass(class1, "SubstMacros-MSExcel.wsf", System.getenv("Temp")); + DocumentUtil.runWsf(wsfpath,new String[] { testPath,dataFile}); + //ļ +// testPath=path+objectName+suffix; + testPath=path+entityFileName+suffix; + File fileDelete=new File(testPath); + if(fileDelete.exists()) { + fileDelete.delete(); + } + file.renameTo(new File(testPath)); + newdataset.setFiles(new String[] {testPath},new String[] { "excel"}); + + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } +// Util.setByPass(true); + System.out.println(compX.getType()); + try { + if(compX instanceof TCComponentFolder) { + compX.add("contents", item); + }else if(compX instanceof TCComponentItemRevision){ + compX.add("IMAN_specification", item); + }else if(compX instanceof TCComponentPseudoFolder) { + TCComponentItemRevision revX = (TCComponentItemRevision) compX.getRelatedComponent("owning_object"); + revX.add("Ac5_AccordFile", item); + } + }catch(Exception e) { + session.getUser().getNewStuffFolder().add("contents", item); + } +// Util.setByPass(false); + MessageBox.post("","",MessageBox.INFORMATION); + } + + + + + + + public static Map getPuid(String sxxName,TCSession session) throws IOException{ + Map puidMap=new HashMap(); + String[] values=session.getPreferenceService().getStringValues(sxxName); + File file=DocumentUtil.getExcle(session,values[0]); + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook workBook = new XSSFWorkbook(fis); + XSSFSheet sheet = workBook.getSheet("ҪռıϢ"); + int rowNum=sheet.getLastRowNum()+1; + XSSFRow row=sheet.getRow(0); + String[] keyColumns=values[values.length-1].split(":")[0].split("-"); + int[] keyColumnInt=new int[keyColumns.length]; + int k=0; + String valueColumn=values[values.length-1].split(":")[1]; + int valueInt=0; + for(int i=0;i<20;i++) { + XSSFCell cell= row.getCell(i); + if(cell==null) { + continue; + }else { + String cellValue=cell.getStringCellValue().trim(); + System.out.println(cellValue); + if(cellValue.length()>0) { + for(int j=0;j0) { + keys=keys+"-"; + } +// System.out.println(""+i+""); +// System.out.println(""+keyColumnInt[l]+""); +// System.out.println(row2.getCell(keyColumnInt[l])==null); + String cellvalue=""; + if(row2.getCell(keyColumnInt[l])==null) { + cellvalue=" "; + }else { + + row2.getCell(keyColumnInt[l]).setCellType(XSSFCell.CELL_TYPE_STRING); + cellvalue=row2.getCell(keyColumnInt[l]).getStringCellValue().trim(); + if(cellvalue.length()==0) { + cellvalue=" "; + } + } + keys=keys+cellvalue; + } + if(row2.getCell(valueInt)!=null) { + row2.getCell(valueInt).setCellType(XSSFCell.CELL_TYPE_STRING); + value=row2.getCell(valueInt).getStringCellValue().trim(); +// System.out.println("keys=="+keys); +// System.out.println("value=="+value); + puidMap.put(keys, value); + } + } + + + + return puidMap; + } + public static boolean setEditable(Map map,String labelName) { + for(java.util.Map.Entry me:map.entrySet()) { + if(me.getKey().getText().equals(labelName)) { + JTextField obj; + try { + + obj = (JTextField) me.getValue(); + obj.setEditable(false); + } catch (Exception e1) { + JComboBox obj2=(JComboBox) me.getValue(); + obj2.setEditable(false); + obj2.setEnabled(false); + } + return true; + } + + } + return false; + } + public static List getList2(String[] excelPre,Map> map1,int rowNum,XSSFSheet sheet){ + List list_1=new ArrayList<>(); + List list=map1.get(excelPre[1].split("=")[1]); + for (int i = 1; i < rowNum; i++) { + XSSFRow row=sheet.getRow(i); + String string=""; + for (int j = 0; j < list.size(); j++) { + if(j>0) { + string=string+"-"; + } + int columnNo=list.get(j); + XSSFCell cell=row.getCell(columnNo); + if(cell!=null && cell.getStringCellValue().trim().length()>0) { + string=string+cell.getStringCellValue().trim(); + }else { + string=string+" "; + } + } +// System.out.println("string======="+string); + if(!list_1.contains(string)) { + + list_1.add(string); + } + } + return list_1; + + } + public static Map> findRow(String excelPre,String[] jcom1,String columnName,int i,Map> map1) { + for (int j = 0; j < jcom1.length; j++) { + if(jcom1[j].equals(columnName)) { + if(map1.containsKey(excelPre.split("=")[1].split("-")[0])) { + List list=map1.get(excelPre.split("=")[1].split("-")[0]); + if(!list.contains(i)) { + list.add(i); + } + map1.put(excelPre.split("=")[1].split("-")[0], list); + }else { + List list=new ArrayList<>(); + list.add(i); + map1.put(excelPre.split("=")[1].split("-")[0], list); + } + } + + } + return map1; + } + public static File getExcle(TCSession session,String puid) { + File fmsFile = null; + + TCComponentDataset dateset = null; + + try { + dateset = (TCComponentDataset) session.stringToComponent(puid); + } catch (TCException e) { + e.printStackTrace(); + } + if (dateset == null) { + MessageBox.post("δҵݼϵԱѡ", "", MessageBox.ERROR); + return null; + } + try { + TCComponentTcFile[] file = dateset.getTcFiles(); + if (file.length == 0 || file.length != 1) { + MessageBox.post("ݼûõļļ࣬飡", "WARNING", MessageBox.WARNING); + return null; + } else { + fmsFile = file[0].getFmsFile(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return fmsFile; + } + public static List getList(String excelPre,int rowNum,XSSFSheet sheet,List list_1,Map> map1){ + List list=map1.get(excelPre.split("=")[1].split("-")[0]); + for (int i = 1; i < rowNum; i++) { + XSSFRow row=sheet.getRow(i); + String string=""; + for (int j = 0; j < list.size(); j++) { + if(j>0) { + string=string+"-"; + } + int columnNo=list.get(j); + XSSFCell cell=row.getCell(columnNo); + if(cell!=null&&cell.getStringCellValue().trim().length()>0) { + string=string+cell.getStringCellValue().trim(); + }else { + string=string+" "; + } + } + list_1.add(string); + } + return list_1; + + } + public static String getFileFlowNumner(TCSession session,String prefix,String flowType) { + String name=""; + try { + Connection conn=null; + conn=DocumentUtil.connect(session,conn); + String query="select * from AVIC_FILE_FLOW WHERE PREFIX='"+prefix+"'"; + + Statement stmt = conn.createStatement(); + ResultSet rs_get = null; + rs_get = stmt.executeQuery(query); + + if(!rs_get.next()) { + boolean create=false; + try { + // ѯ + TCComponent[] comps=session.search("DocSearch1", new String[] {"ĵ"}, new String[] {prefix+"000"}); + if(comps.length>0) { + create=false; + }else { + create=true; + } + } catch (Exception e2) { + e2.printStackTrace(); + } + + query="insert into AVIC_FILE_FLOW (PREFIX,FLOW) VALUES ('"+prefix+"','000')"; + System.out.println(query); + if (rs_get != null) { + rs_get.close(); + } + rs_get = stmt.executeQuery(query); + if(rs_get.next()) { + System.out.println("insert ====="); + } + if (rs_get != null) { + rs_get.close(); + } + DocumentUtil.disconnect( conn, stmt, rs_get); + + if(create==true) { + if(flowType.endsWith("000")) { + name=prefix+"000"; + }else { + name=prefix; + } + + }else { + name=getFileFlowNumner( session, prefix, flowType); + } + + }else { + String number=rs_get.getString("FLOW"); + number=String.format("%03d", Integer.valueOf(number)+1); + query="update AVIC_FILE_FLOW SET FLOW='"+number+"' WHERE PREFIX='"+prefix+"'"; + if (rs_get != null) { + rs_get.close(); + } + rs_get = stmt.executeQuery(query); + if(rs_get.next()) { + System.out.println("update ====="); + } + if (rs_get != null) { + rs_get.close(); + } + DocumentUtil.disconnect( conn, stmt, rs_get); + name=prefix+number; + try { + // ѯ + TCComponent[] comps=session.search("DocSearch1", new String[] {"ĵ"}, new String[] {name}); + if(comps.length>0) { + name=getFileFlowNumner( session, prefix, flowType); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + + + + + } catch (SQLException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + + + return name; + + + + } + /*private String getFlowNumner(TCSession session,String prefix) { + String name=""; + try { + Connection conn=null; + conn=DocumentUtil.connect(session,conn); + String query="select * from AVIC_NAME_FLOW WHERE PREFIX='"+prefix+"'"; + + Statement stmt = conn.createStatement(); + ResultSet rs_get = null; + rs_get = stmt.executeQuery(query); + if(!rs_get.next()) { + query="insert into AVIC_NAME_FLOW (PREFIX,FLOW) VALUES ('"+prefix+"','000')"; + System.out.println(query); + if (rs_get != null) { + rs_get.close(); + } + rs_get = stmt.executeQuery(query); + if(rs_get.next()) { + System.out.println("insert ====="); + } + if (rs_get != null) { + rs_get.close(); + } + name=prefix; + }else { + String number=rs_get.getString("FLOW"); + number=String.format("%03d", Integer.valueOf(number)+1); + query="update AVIC_NAME_FLOW SET FLOW='"+number+"' WHERE PREFIX='"+prefix+"'"; + if (rs_get != null) { + rs_get.close(); + } + rs_get = stmt.executeQuery(query); + if(rs_get.next()) { + System.out.println("update ====="); + } + if (rs_get != null) { + rs_get.close(); + } + name=prefix+number; + } + + + + + DocumentUtil.disconnect( conn, stmt, rs_get); + } catch (Exception e) { + e.printStackTrace(); + } + + + + return name; + + + + }*/ + public static String getJarPath(String wsfFileName) { + + + /** + * һȡǰִjarĿ¼ + */ + String filePath = System.getProperty("java.class.path"); + String pathSplit = System.getProperty("path.separator");//õǰϵͳķָwindows";",linux":" + + /** + * ûfilePathĽӦǸÿjarľ· + * ʱֻҪַɵõjarĿ¼ + */ + if(filePath.contains(pathSplit)){ + filePath = filePath.substring(0,filePath.indexOf(pathSplit)); + }else if (filePath.endsWith(".jar")) {//ȡ·еjar,ִjarеĽ".jar" + filePath = filePath.substring(0, filePath.lastIndexOf(File.separator) + 1); + } + filePath=filePath+wsfFileName; + System.out.println("jarĿ¼"+filePath); + return filePath; + } + public static String getFileFromClass(Class class1, String fileName, String path) throws Exception { + String filePath = (new StringBuilder(String.valueOf(path))).append("\\").append(fileName).toString(); + System.out.println(filePath); + File file = new File(filePath); + if(file.exists()) + file.delete(); + file.createNewFile(); + //InputStream inputStream = class1.getResourceAsStream("/com/connor/zcxny/plm/xiuding/sxys/"+fileName); + InputStream inputStream = class1.getResourceAsStream(fileName); + inputStream = new FileInputStream(getJarPath(fileName)); + //InputStream inputStream = new FileInputStream("C:\\Users\\calib\\Desktop\\xnywsf\\SubstMacros-MSWord.wsf"); + //OutputStream os = new BufferedOutputStream(new FileOutputStream(filePath)); + OutputStream os = new FileOutputStream(filePath); + int readLen = 0; + byte buf[] = new byte[102400]; + while((readLen = inputStream.read(buf)) != -1) { + os.write(buf, 0, readLen); + } + + os.flush(); + inputStream.close(); + os.close(); + return filePath; + } + /** + * ļ + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponent comp) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + // } + return value; + } + public static void disconnect(Connection conn,Statement stmt, ResultSet rs_get) { + try { + if (rs_get != null) { + rs_get.close(); + } + + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + public static Connection connect(TCSession session,Connection conn) { + // ѡ + String[] database=session.getPreferenceService().getStringValues("Connor_AVIC_database_tc"); + String JdbcDriverClass = "oracle.jdbc.driver.OracleDriver"; + String strUrl = "jdbc:oracle:thin:@10.128.18.139:1521:tc12";//ϵͳ + strUrl="jdbc:oracle:thin:@"+database[0]+":"+database[1]+":"+database[2]; + String strUserName = "infodba"; + strUserName=database[3]; + String strPassword = "infodba"; + strPassword=database[4]; + try { + Class.forName(JdbcDriverClass); + } catch (ClassNotFoundException e1) { + e1.printStackTrace(); + } + try { + conn = DriverManager.getConnection(strUrl, strUserName, strPassword); + } catch (SQLException e) { + e.printStackTrace(); + } + return conn; + + + } + /** + * ݼǰ + * + * @param caxaDataset + * @throws TCException + */ + public static String jk_SetCAXAFile(String sxxName,TCSession session,TCComponentDataset caxaDataset, + boolean bo) throws TCException { + StringBuffer infoSB = new StringBuffer(); + TCComponentItemRevision rev = null; + TCComponentItem item = null; + TCComponentForm revForm = null; +// TCComponentForm itemForm = null; + String datasetName = null; + if (caxaDataset == null) { + return null; + } + TCComponentTcFile[] tcFiles = caxaDataset.getTcFiles(); + // File file = null; + if (tcFiles != null && tcFiles.length != 0) { + + datasetName = tcFiles[0].getStringProperty("object_string"); + } + System.out.println(" datasetName =" + datasetName); + // = caxaDataset.getStringProperty("object_name"); + rev = (TCComponentItemRevision) caxaDataset + .getReferenceProperty("item_revision");// õǰݼڰ汾 + + if (rev == null) { + return null; + } + revForm = (TCComponentForm) (rev + .getReferenceListProperty("IMAN_master_form_rev"))[0]; + item = rev.getItem(); + + + + String[] refValues=null ; + if(bo){ +// Ʒͺ=REVMASTER.ac5_ProductModel +// ܼ=REVMASTER.ip_classification +// ͱ=REVMASTER.ac5_Type +// ͱ=REVMASTER.ac5_Xblx +// Ʋ=REVMASTER.ac5_Bzbm + refValues=session.getPreferenceService().getStringValues(sxxName); + } + if (refValues == null || refValues.length == 0) { + MessageBox.post(sxxName + "ѡô,ϵԱ","",MessageBox.ERROR); + return null; + } + for (String refValue : refValues) { + String[] valueS = refValue.split("="); + String value = null; + if (valueS == null || valueS.length != 2) { + continue; + } + String[] propNameS = valueS[1].split("\\."); + if (propNameS == null || propNameS.length != 2) { + continue; + } + switch (propNameS[0].toUpperCase()) { + case "ITEM": + value = DocumentUtil.hx_GetProp(item, propNameS[1]); + break; + case "REV": + value = DocumentUtil.hx_GetProp(rev, propNameS[1]); + break; + case "REVMASTER": + value = DocumentUtil.hx_GetProp(revForm, propNameS[1]); + break; + + case "ITEMMASTER": + break; + default: + break; + + } + infoSB.append(valueS[0]).append("=").append(value).append("|"); + } + String filePath1=null; + if (infoSB.toString().endsWith("|")) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmssSSS"); + + String filePath = System.getenv("TEMP") + "\\"+sdf.format(new Date())+"project.txt"; + filePath1 = System.getenv("TEMP") + "\\"+sdf.format(new Date())+"AutoCAD.txt"; + try { + // TxtFileRWHelper textFile = new TxtFileRWHelper( + // filePath); + // + // + // textFile.writeTxtFile2(infoSB.toString().substring(0, + // infoSB.toString().lastIndexOf("|"))); + + FileOutputStream writerStream = new FileOutputStream(filePath); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter( + writerStream)); + bw.write(infoSB.toString().substring(0, + infoSB.toString().lastIndexOf("|"))); + System.out.println(); + bw.close(); + writerStream.close(); + + FileOutputStream writerStream1 = new FileOutputStream(filePath1); + BufferedWriter bw1 = new BufferedWriter(new OutputStreamWriter( + writerStream1)); + bw1.write(infoSB.toString().substring(0, + infoSB.toString().lastIndexOf("|"))); + System.out.println(); + bw1.close(); + writerStream1.close(); + System.out.println(infoSB.toString().substring(0, + infoSB.toString().lastIndexOf("|"))); + } catch (IOException e) { + e.printStackTrace(); + } + + } + return filePath1; + } + public static void runWsf(String wsfPath, String[] paras) + { + try { + Vector cmdVector = new Vector(); + cmdVector.add("wscript"); + cmdVector.add(wsfPath); + for (String para : paras) { + cmdVector.add(para); + } + String[] cmd = (String[])cmdVector.toArray(new String[cmdVector.size()]); + for (int i = 0; i < cmd.length; i++) { + + System.out.println(cmd[i]); + } + Runtime runtime = Runtime.getRuntime(); + Process process = runtime.exec(cmd); + process.waitFor(); + // MessageBox.post("Success!","INFORMATION",MessageBox.INFORMATION); + + } + catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * ȡ + * + * @param comp + * @return + */ + public static String hx_GetProp(TCComponent comp, String refInfo) { + if (comp == null) { + return null; + } + if (refInfo == null) { + return null; + } + String value = null; + try { + + TCProperty prop = comp.getTCProperty(refInfo); + if (prop == null) { + + return null; + } + + value = prop.getDisplayValue(); + } catch (TCException e) { + e.printStackTrace(); + } + + return value; + } + public static boolean isValidFileName(String fileName) { + if (fileName == null || fileName.length() > 255) + return false; + else + return fileName.matches( + "[^\\s\\\\/:\\*\\?\\\"<>\\|](\\x20|[^\\s\\\\/:\\*\\?\\\"<>\\|])*[^\\s\\\\/:\\*\\?\\\"<>\\|\\.]$"); + } + public void setFileName2(String Connor_AVIC_NewDocumentSerial,Map basicMap,Map createMap,JCheckBox zjtsyq,TCSession session,String selectType,JComboBox[] basicCom) { +// JTextField field0 = null; + JComboBox combox1 = null; + + for (Map.Entry me : basicMap.entrySet()) { + if (me.getKey().getText().startsWith("Ʒͺ")) { +// field0 = ((JTextField) me.getValue()); + } + + if (me.getKey().getText().startsWith("ĵ")) { + combox1 = ((JComboBox) me.getValue()); + } + + } + JTextField field2 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("")) { + field2 = ((JTextField) me.getValue()); + } + + } + // ˮ򣺲ѯǰ׺û½ԭĻϼ1 +// ޸ļƹ򣬲ٴвƷͺ +// String finalName = getFlowNumner(field0.getText() + ((String) combox1.getSelectedItem()).split("-")[0]); + String finalName = ((String) combox1.getSelectedItem()).split("-")[0]; + if(field2!=null) { + + field2.setText(finalName); + } + // ʵļ + JTextField field3 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("ʵļ")) { + field3 = ((JTextField) me.getValue()); + } + + } + if(field3!=null) { + + field3.setText(finalName); + } + // ļ ѡ + JTextField field4 = null; + for (Map.Entry me : createMap.entrySet()) { + if (me.getKey().getText().startsWith("ļ")) { + field4 = ((JTextField) me.getValue()); + } + + } + String[] value = session.getPreferenceService().getStringValues(Connor_AVIC_NewDocumentSerial); + // :ͼ+һ+FLOW + // :Ʒͺ+*+һ + // ѡ:YEAR+һ+FLOW + // Ҫ: + Map codeMap = new HashMap(); + + for (int i = 0; i < value.length; i++) { + String[] string = value[i].split(":"); + if (string.length == 2) { + String[] allTypes = string[0].split("\\|"); + for (int j = 0; j < allTypes.length; j++) { + codeMap.put(allTypes[j], string[1]); + + } + } + } + if (zjtsyq.isSelected()) { + + } else { + selectType = (String) basicCom[0].getSelectedItem(); + System.out.println("selectType================"+selectType); + String codeRule = codeMap.get(selectType); + System.out.println("codeRule================"+codeRule); + String finalCode = ""; + if (codeRule != null) { + System.out.println(codeRule); + String[] codes = codeRule.split("\\+"); + for (int i = 0; i < codes.length; i++) { + String string = codes[i]; + if (string.startsWith("FLOW")) { + // ѯݿ +// finalCode = getFileFlowNumner(finalCode, string); + } else if (string.startsWith("YEAR")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); + String kk = sdf.format(new Date()); + finalCode = finalCode + kk; + } else if (string.startsWith(wz)) { + JComboBox wdlb = null; + for (Map.Entry me : basicMap.entrySet()) { + + if (me.getKey().getText().startsWith("ĵ")) { + wdlb = ((JComboBox) me.getValue()); + } + + } + finalCode = finalCode + ((String) wdlb.getSelectedItem()).split("-")[1]; + } else { + JTextField filedX = null; + JComboBox jcomboxX = null; + for (Map.Entry me : basicMap.entrySet()) { + if (me.getKey().getText().equals(string)) { + try { + filedX = ((JTextField) me.getValue()); + } catch (Exception e1) { + jcomboxX = ((JComboBox) me.getValue()); + } + } + } + if (filedX != null) { + finalCode = finalCode + filedX.getText().trim(); + } else { + finalCode = finalCode + ((String) jcomboxX.getSelectedItem()).trim(); + } + } + + } + + } + System.out.println("finalCode======================="+finalCode); + if(field4!=null) { + + field4.setText(finalCode); + } + } + } + public static void sethouzhui(List listq,String selectDocCategory,Map basicMap2) { + for(int i=0;i me : basicMap2.entrySet()) { + JTextField field = (JTextField) me.getValue(); + String textValue=""; + try { + textValue=houzhui1.split("-")[count1]; + } catch (Exception e1) { +// e1.printStackTrace(); + } + field.setText(textValue); + count1++; + } + + } + + } + } +} diff --git a/src/com/connor/pro105/plm/creatTechWord/MultiCombo.java b/src/com/connor/pro105/plm/creatTechWord/MultiCombo.java new file mode 100644 index 0000000..4803a11 --- /dev/null +++ b/src/com/connor/pro105/plm/creatTechWord/MultiCombo.java @@ -0,0 +1,320 @@ +package com.connor.pro105.plm.creatTechWord; + +import java.awt.Component; +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.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListSelectionModel; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.JTextField; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.plaf.basic.BasicComboPopup; +import javax.swing.plaf.basic.ComboPopup; +import javax.swing.plaf.metal.MetalComboBoxUI; + +@SuppressWarnings({ "rawtypes", "unchecked"}) +public class MultiCombo extends JComboBox implements FocusListener { + + /** + * + */ + private static final long serialVersionUID = 1L; + protected HashSet set = new HashSet<>(); + private String[] cns; + private String[] ens; + private String value; + + public MultiCombo(String str[]) { + int len = str.length; + cns = new String[len]; + ens = new String[len]; + for(int i=0; i0) + jTextField.setText(sb.substring(1)); + } + + public String getValue(){ + return value; + } + + public void setValue(String value){ + if(value==null || value.isEmpty()){ + this.value = ""; + return; + } + this.value = value; + String[] split = value.split(":"); + boolean find = false; + for(String s : split[0].split(";")){ + for(int i=0; i 0 && ';' != sb.charAt(0)) + sb.insert(0, ";"); + if (sb.length() > 0 && ';' != sb.charAt(sb.length() - 1)) + sb.append(";"); + if (sb.length() > 0 && ";".equals(sb.toString())) + sb = new StringBuilder(); + if (list.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { + if (MultiCombo.set.contains(index)) { + MultiCombo.set.remove(index); + sb1 = new StringBuilder(); + sb1.append(";").append(MultiCombo.getModel().getElementAt(index)).append(","); + k = sb.indexOf(sb1.toString()); + while (k != -1) { + sb.replace(k, k + sb1.length(), ";"); + k = sb.indexOf(sb1.toString()); + } + } else { + MultiCombo.set.add(index); + if (sb.length() == 0) + sb.append(";").append(MultiCombo.getModel().getElementAt(index)).append(";"); + else + sb.append(MultiCombo.getModel().getElementAt(index)).append(";"); + } + } else { + if (!MultiCombo.set.contains(index)) { + MultiCombo.set.clear(); + MultiCombo.set.add(index); + } + } + Object obj; + sb2 = new StringBuilder(sb); + // 滻Ŀѡֵ + for (int i = 0; i < list.getModel().getSize(); i++) { + obj = list.getModel().getElementAt(i); + sb1 = new StringBuilder(); + sb1.append(";").append(obj).append(";"); + k = sb2.indexOf(sb1.toString()); + while (k != -1) { + sb2.replace(k, k + sb1.length(), ";"); + k = sb2.indexOf(sb1.toString()); + } + } + ArrayList list1 = new ArrayList(MultiCombo.set); + Collections.sort(list1); + for (int i = 0; i < list1.size(); i++) { + obj = MultiCombo.getModel().getElementAt(Integer.parseInt(list1.get(i).toString())); + sb1 = new StringBuilder(); + sb1.append(";").append(obj).append(";"); + k = sb.indexOf(sb1.toString()); + if (k != -1 && sb2.indexOf(sb1.toString()) == -1) { + sb2.append(obj).append(";"); + } + } + sb = new StringBuilder(sb2); + if (sb.length() > 0 && ';' == sb.charAt(0)) + sb.deleteCharAt(0); + if (sb.length() > 0 && ';' == sb.charAt(sb.length() - 1)) + sb.deleteCharAt(sb.length() - 1); + if (sb.length() > 0 && ";".equals(sb.toString())) + sb = new StringBuilder(); + jTextField.setText(sb.toString()); + // java.awt.Container container =jTextField; + // while(container!=null&&!(container instanceof javax.swing.JLabel)) + // { + // container=container.getParent(); + // } + // ((cLabel)container).setValue(sb.toString()); + if(MultiCombo.set.size()>0){ + StringBuilder val = new StringBuilder(""); + for(int i=0; i