From e22b0c756eff0b9dfc0707b5b0ecff69735a439f Mon Sep 17 00:00:00 2001 From: zouxk Date: Wed, 25 Dec 2019 14:44:37 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .project | 28 ++++++++++++++++++++++++++ com.connor.jd.plm/META-INF/MANIFEST.MF | 26 ++++++++++++++---------- 3 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 .project diff --git a/.gitignore b/.gitignore index 84adb3f..b32075f 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..3b1aa08 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.jd.plm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF index 13001bc..28b5c83 100644 --- a/com.connor.jd.plm/META-INF/MANIFEST.MF +++ b/com.connor.jd.plm/META-INF/MANIFEST.MF @@ -3,16 +3,17 @@ Bundle-ManifestVersion: 2 Bundle-Name: JDProject Bundle-SymbolicName: com.connor.jd.plm;singleton:=true Bundle-Version: 1.0.0.qualifier -Require-Bundle: org.eclipse.ui;bundle-version="3.108.0", - com.teamcenter.rac.common;bundle-version="12000.1.0", - com.teamcenter.rac.tcapps;bundle-version="12000.1.0", - com.teamcenter.rac.util;bundle-version="12000.1.0", - com.teamcenter.rac.aifrcp;bundle-version="12000.1.0", - com.teamcenter.rac.ui.commands;bundle-version="12000.1.0", - com.teamcenter.rac.kernel;bundle-version="12000.1.0", - com.teamcenter.rac.ui.views;bundle-version="12000.1.0", - org.eclipse.core.runtime;bundle-version="3.12.0", - org.eclipse.ui.forms;bundle-version="3.7.0" +Require-Bundle: org.eclipse.ui;bundle-version="3.111.0", + com.teamcenter.rac.common;bundle-version="12000.2.0", + com.teamcenter.rac.tcapps;bundle-version="12000.2.0", + com.teamcenter.rac.util;bundle-version="12000.2.0", + com.teamcenter.rac.aifrcp;bundle-version="12000.2.0", + com.teamcenter.rac.ui.commands;bundle-version="12000.2.0", + com.teamcenter.rac.kernel;bundle-version="12000.2.0", + com.teamcenter.rac.ui.views;bundle-version="12000.2.0", + org.eclipse.core.runtime;bundle-version="3.15.100", + org.eclipse.ui.forms;bundle-version="3.7.400", + com.teamcenter.rac.schedule;bundle-version="12000.2.0" Automatic-Module-Name: JDProject Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: com.connor.jd.plm.action, @@ -25,7 +26,10 @@ Export-Package: com.connor.jd.plm.action, Import-Package: com.teamcenter.services, com.teamcenter.services.rac, com.teamcenter.services.rac.core, - com.teamcenter.services.rac.core._2008_06 + com.teamcenter.services.rac.core._2008_06, + org.apache.commons.httpclient, + org.apache.commons.httpclient.methods, + org.apache.commons.httpclient.params Bundle-ClassPath: ., lib/fastjson-1.2.9.jar, lib/hutool-all-5.0.7.jar, From cbad68bd6d43c46534bb598490c1946b3d09c2e1 Mon Sep 17 00:00:00 2001 From: zouxk Date: Wed, 25 Dec 2019 17:40:19 +0800 Subject: [PATCH 02/12] 12.25 --- com.connor.jd.plm/META-INF/MANIFEST.MF | 29 ++++++++++--------- .../plm/dialog/EditClassificationDialog.java | 14 +++++---- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF index 28b5c83..9ef4c63 100644 --- a/com.connor.jd.plm/META-INF/MANIFEST.MF +++ b/com.connor.jd.plm/META-INF/MANIFEST.MF @@ -3,17 +3,17 @@ Bundle-ManifestVersion: 2 Bundle-Name: JDProject Bundle-SymbolicName: com.connor.jd.plm;singleton:=true Bundle-Version: 1.0.0.qualifier -Require-Bundle: org.eclipse.ui;bundle-version="3.111.0", - com.teamcenter.rac.common;bundle-version="12000.2.0", - com.teamcenter.rac.tcapps;bundle-version="12000.2.0", - com.teamcenter.rac.util;bundle-version="12000.2.0", - com.teamcenter.rac.aifrcp;bundle-version="12000.2.0", - com.teamcenter.rac.ui.commands;bundle-version="12000.2.0", - com.teamcenter.rac.kernel;bundle-version="12000.2.0", - com.teamcenter.rac.ui.views;bundle-version="12000.2.0", - org.eclipse.core.runtime;bundle-version="3.15.100", - org.eclipse.ui.forms;bundle-version="3.7.400", - com.teamcenter.rac.schedule;bundle-version="12000.2.0" +Require-Bundle: org.eclipse.ui;bundle-version="3.108.0", + com.teamcenter.rac.common;bundle-version="12000.1.0", + com.teamcenter.rac.tcapps;bundle-version="12000.1.0", + com.teamcenter.rac.util;bundle-version="12000.1.0", + com.teamcenter.rac.aifrcp;bundle-version="12000.1.0", + com.teamcenter.rac.ui.commands;bundle-version="12000.1.0", + com.teamcenter.rac.kernel;bundle-version="12000.1.0", + org.eclipse.ui.views;bundle-version="3.8.100", + org.eclipse.core.runtime;bundle-version="3.12.0", + org.eclipse.ui.forms;bundle-version="3.7.0", + com.teamcenter.rac.schedule;bundle-version="12000.1.0" Automatic-Module-Name: JDProject Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: com.connor.jd.plm.action, @@ -27,9 +27,10 @@ Import-Package: com.teamcenter.services, com.teamcenter.services.rac, com.teamcenter.services.rac.core, com.teamcenter.services.rac.core._2008_06, - org.apache.commons.httpclient, - org.apache.commons.httpclient.methods, - org.apache.commons.httpclient.params + org.apache.http.client, + org.apache.http.client.methods, + org.apache.http.client.params, + org.apache.http.client.protocol Bundle-ClassPath: ., lib/fastjson-1.2.9.jar, lib/hutool-all-5.0.7.jar, diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java index 2c51b6d..901eaa8 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java @@ -28,7 +28,6 @@ import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentICO; import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCException; -import com.teamcenter.rac.kernel.TCProperty; import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.ics.ICSApplicationObject; import com.teamcenter.rac.kernel.ics.ICSProperty; @@ -155,11 +154,14 @@ public class EditClassificationDialog extends AbstractAIFDialog { saveClassification(rev); try { if (rev.getProperty("object_type").equals("JD2_GTBJRevision")) { - TCProperty property = rev.getTCProperty("TC_Is_Represented_By"); - TCComponent[] comp = property.getReferenceValueArray(); - if (comp.length > 0) { - TCComponentItemRevision tzrev = (TCComponentItemRevision) comp[0]; - saveClassification(tzrev); + TCComponent[] comps = rev.getReferenceListProperty("TC_Is_Represented_By"); + System.out.println(comps.length); + for (int i = 0; i < comps.length; i++) { + if (comps[i].getType().equals("JD2_XYJTZRevision")) { + System.out.println("object_string:" + comps[i].getProperty("object_string")); + TCComponentItemRevision tzrev = (TCComponentItemRevision) comps[i]; + saveClassification(tzrev); + } } } } catch (TCException e1) { From 415a949fb8bfc50a7e9fbe426a59aa7c7cfa55d3 Mon Sep 17 00:00:00 2001 From: zouxk Date: Sat, 28 Dec 2019 00:54:22 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E6=A0=B7=E5=93=81=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E5=8D=95=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.connor.jd.plm/.classpath | 1062 +++++++++-------- com.connor.jd.plm/META-INF/MANIFEST.MF | 2 +- com.connor.jd.plm/src/Test.java | 8 + .../plm/dialog/EditClassificationDialog.java | 4 +- .../jd/plm/form/SampleConfirmationForm.java | 374 +++--- .../connor/jd/plm/table/MyCellEditor1.java | 268 +++++ .../com/connor/jd/plm/table/TCTableUtil.java | 28 +- .../stylesheet_user.properties} | 0 8 files changed, 1042 insertions(+), 704 deletions(-) create mode 100644 com.connor.jd.plm/src/Test.java create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor1.java rename com.connor.jd.plm/src/com/teamcenter/rac/{form/form_user.properties => stylesheet/stylesheet_user.properties} (100%) diff --git a/com.connor.jd.plm/.classpath b/com.connor.jd.plm/.classpath index 0107178..de347d7 100644 --- a/com.connor.jd.plm/.classpath +++ b/com.connor.jd.plm/.classpath @@ -3,541 +3,543 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF index 9ef4c63..6ab32fe 100644 --- a/com.connor.jd.plm/META-INF/MANIFEST.MF +++ b/com.connor.jd.plm/META-INF/MANIFEST.MF @@ -22,7 +22,7 @@ Export-Package: com.connor.jd.plm.action, com.connor.jd.plm.handlers, com.connor.jd.plm.table, com.connor.jd.plm.util, - com.teamcenter.rac.form + com.teamcenter.rac.stylesheet Import-Package: com.teamcenter.services, com.teamcenter.services.rac, com.teamcenter.services.rac.core, diff --git a/com.connor.jd.plm/src/Test.java b/com.connor.jd.plm/src/Test.java new file mode 100644 index 0000000..907eafb --- /dev/null +++ b/com.connor.jd.plm/src/Test.java @@ -0,0 +1,8 @@ + +public class Test { + + public static void main(String[] args) { + + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java index 901eaa8..aa85294 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java @@ -151,9 +151,11 @@ public class EditClassificationDialog extends AbstractAIFDialog { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub TCComponentItemRevision rev = (TCComponentItemRevision) target; + saveClassification(rev); try { - if (rev.getProperty("object_type").equals("JD2_GTBJRevision")) { + System.out.println(rev.getProperty("object_string")); + if (rev.getType().equals("JD2_GTBJRevision")) { TCComponent[] comps = rev.getReferenceListProperty("TC_Is_Represented_By"); System.out.println(comps.length); for (int i = 0; i < comps.length; i++) { diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index 414e1de..4c60106 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -39,6 +39,7 @@ import com.connor.jd.plm.table.CTable; import com.connor.jd.plm.table.JCheckPanel; import com.connor.jd.plm.table.JRadioPanel; import com.connor.jd.plm.table.MyCellEditor; +import com.connor.jd.plm.table.MyCellEditor1; import com.connor.jd.plm.table.TCTableUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.kernel.AIFComponentContext; @@ -80,9 +81,14 @@ public class SampleConfirmationForm extends AbstractRendering { private List disableEdit2; private JRadioPanel sysl; private JCheckPanel mqjd; - String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", - "jd2_1", "jd2_2", "jd2_3", "jd2_4", "jd2_5", "jd2_6", "jd2_7", - "jd2_8", "jd2_9", "jd2_10", "jd2_min", "jd2_max", "jd2_jg" }; + String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", "jd2_1", "jd2_2", "jd2_3", "jd2_4", + "jd2_5", "jd2_6", "jd2_7", "jd2_8", "jd2_9", "jd2_10", "jd2_min", "jd2_max", "jd2_jg" }; + String[] colNames1 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", + "jd2_ctq8" }; + String[] colNames2 = { "jd2_no", "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", + "jd2_ctq8" }; + String[] colNames3 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", + "jd2_ctq8" }; public SampleConfirmationForm(TCComponent arg0) throws Exception { super(arg0); @@ -195,8 +201,7 @@ public class SampleConfirmationForm extends AbstractRendering { general.put("jd2_syyy", new int[] { 9, 10 }); model.setValueAt("目前阶段", 12, 0); disableEdit.add("12,0"); - mqjd = new JCheckPanel( - new String[] { "DV", "PV", "PR", "SR", "现场测试", "MP" }); + mqjd = new JCheckPanel(new String[] { "DV", "PV", "PR", "SR", "现场测试", "MP" }); model.setValueAt(mqjd, 12, 2); model.setValueAt("No", top, 0); @@ -294,22 +299,19 @@ public class SampleConfirmationForm extends AbstractRendering { pic.put("jd2_qtbg", new int[] { bottom + 10, 7 }); // 合并单元格 - model.combine(new int[] { 0, 1 }, - new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); + model.combine(new int[] { 0, 1 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); model.combine(new int[] { 0, 1 }, new int[] { 14, 15 }); model.combine(new int[] { 0, 1 }, new int[] { 16, 17 }); model.combine(new int[] { 0, 1 }, new int[] { 18, 19 }); model.combine(new int[] { 2, 3 }, new int[] { 0, 1 }); - model.combine(new int[] { 2, 3 }, - new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); + model.combine(new int[] { 2, 3 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); model.combine(new int[] { 2, 3 }, new int[] { 14, 15 }); model.combine(new int[] { 2, 3 }, new int[] { 16, 17 }); model.combine(new int[] { 2, 3 }, new int[] { 18, 19 }); model.combine(new int[] { 4, 5 }, new int[] { 0, 1 }); model.combine(new int[] { 4, 5 }, new int[] { 2, 3, 4 }); model.combine(new int[] { 4, 5 }, new int[] { 5, 6 }); - model.combine(new int[] { 4, 5 }, - new int[] { 7, 8, 9, 10, 11, 12, 13 }); + model.combine(new int[] { 4, 5 }, new int[] { 7, 8, 9, 10, 11, 12, 13 }); model.combine(new int[] { 4, 5 }, new int[] { 14, 15 }); model.combine(new int[] { 4, 5 }, new int[] { 16, 17 }); model.combine(new int[] { 4, 5 }, new int[] { 18, 19 }); @@ -329,84 +331,59 @@ public class SampleConfirmationForm extends AbstractRendering { model.combine(new int[] { 8 }, new int[] { 0, 1 }); model.combine(new int[] { 8 }, new int[] { 2, 3, 4, 5, 6, 7 }); model.combine(new int[] { 8 }, new int[] { 8, 9 }); - model.combine(new int[] { 8 }, - new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); + model.combine(new int[] { 8 }, new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); model.combine(new int[] { 9 }, new int[] { 0, 1 }); model.combine(new int[] { 9 }, new int[] { 2, 3, 4, 5, 6, 7 }); model.combine(new int[] { 9, 10, 11 }, new int[] { 8, 9 }); - model.combine(new int[] { 9, 10, 11 }, - new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); + model.combine(new int[] { 9, 10, 11 }, new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); model.combine(new int[] { 10 }, new int[] { 0, 1 }); model.combine(new int[] { 10 }, new int[] { 2, 3, 4, 5, 6, 7 }); model.combine(new int[] { 11 }, new int[] { 0, 1 }); model.combine(new int[] { 11 }, new int[] { 2, 3, 4, 5, 6, 7 }); model.combine(new int[] { 12 }, new int[] { 0, 1 }); - model.combine(new int[] { 12 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19 }); + model.combine(new int[] { 12 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); model.combine(new int[] { top, 1 }, new int[] { 0 }); model.combine(new int[] { top }, new int[] { 1, 2, 3, 4, 5, 6 }); - model.combine(new int[] { top }, - new int[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); + model.combine(new int[] { top }, new int[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); model.combine(new int[] { top, top + 1 }, new int[] { 19 }); model.combine(new int[] { top + 1 }, new int[] { 1, 2, 3, 4 }); model.combine(new int[] { top + 1 }, new int[] { 5, 6 }); model.combine(new int[] { bottom + 1 }, new int[] { 0, 1, 2, 3, 4, 5 }); model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 }); model.combine(new int[] { bottom + 2 }, new int[] { 2, 3 }); - model.combine( - new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6, - bottom + 7, bottom + 8, bottom + 9, bottom + 10, - bottom + 11, bottom + 12, bottom + 13 }, - new int[] { 0, 1, 2, 3 }); - model.combine( - new int[] { bottom + 2, bottom + 3, bottom + 4, bottom + 5 }, - new int[] { 4 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6, bottom + 7, bottom + 8, bottom + 9, + bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 0, 1, 2, 3 }); + model.combine(new int[] { bottom + 2, bottom + 3, bottom + 4, bottom + 5 }, new int[] { 4 }); model.combine(new int[] { bottom + 2 }, new int[] { 9, 10, 11 }); model.combine(new int[] { bottom + 2 }, new int[] { 12, 13, 14 }); model.combine(new int[] { bottom + 2 }, new int[] { 15, 16, 17 }); model.combine(new int[] { bottom + 2 }, new int[] { 18, 19 }); model.combine(new int[] { bottom + 4, bottom + 5 }, new int[] { 7, 8 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, - new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, - new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, - new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, - new int[] { 18, 19 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 9, 10, 11 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 12, 13, 14 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 15, 16, 17 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 18, 19 }); model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 4 }); model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 4 }); model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 5 }); model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 5 }); - model.combine( - new int[] { bottom + 6, bottom + 7, bottom + 8, bottom + 9 }, - new int[] { 6 }); + model.combine(new int[] { bottom + 6, bottom + 7, bottom + 8, bottom + 9 }, new int[] { 6 }); model.combine(new int[] { bottom + 6 }, new int[] { 7, 8 }); model.combine(new int[] { bottom + 6 }, new int[] { 9, 10, 11 }); model.combine(new int[] { bottom + 6 }, new int[] { 12, 13, 14 }); model.combine(new int[] { bottom + 6 }, new int[] { 15, 16, 17 }); model.combine(new int[] { bottom + 6 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, - new int[] { 7, 8 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, - new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, - new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, - new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, - new int[] { 18, 19 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 7, 8 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 9, 10, 11 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 12, 13, 14 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 15, 16, 17 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 18, 19 }); model.combine(new int[] { bottom + 10 }, new int[] { 4, 5, 6 }); - model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 }, - new int[] { 4, 5, 6 }); - model.combine(new int[] { bottom + 10, bottom + 11, bottom + 12, - bottom + 13 }, new int[] { 7, 8, 9, 10, 11 }); - model.combine(new int[] { bottom + 10, bottom + 11 }, - new int[] { 12, 13, 14, 15, 16, 17, 18, 19 }); - model.combine(new int[] { bottom + 12, bottom + 13 }, - new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 12, bottom + 13 }, - new int[] { 15, 16, 17, 18, 19 }); + model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 }, new int[] { 4, 5, 6 }); + model.combine(new int[] { bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 7, 8, 9, 10, 11 }); + model.combine(new int[] { bottom + 10, bottom + 11 }, new int[] { 12, 13, 14, 15, 16, 17, 18, 19 }); + model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 12, 13, 14 }); + model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 15, 16, 17, 18, 19 }); table = new CTable(model) { @Override @@ -429,14 +406,12 @@ public class SampleConfirmationForm extends AbstractRendering { for (int i = 7; i < model.getColumnCount() - 1; i++) { table.getColumnModel().getColumn(i).setPreferredWidth(45); } - table.getColumnModel().getColumn(model.getColumnCount() - 1) - .setPreferredWidth(80); + table.getColumnModel().getColumn(model.getColumnCount() - 1).setPreferredWidth(80); DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() { // 重写方法 @Override - public Component getTableCellRendererComponent(JTable table, - Object value, boolean isSelected, boolean hasFocus, int row, - int column) { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { // TODO Auto-generated method stub if (value instanceof JLabel) { @@ -450,10 +425,8 @@ public class SampleConfirmationForm extends AbstractRendering { int maxPreferredHeight = 0; for (int i = 0; i < table.getColumnCount(); i++) { setText("" + table.getValueAt(row, i)); - setSize(table.getColumnModel().getColumn(column).getWidth(), - 0); - maxPreferredHeight = Math.max(maxPreferredHeight, - getPreferredSize().height); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); } setBackground(Color.white); // if(points1.contains(new Point(row,column))) @@ -474,8 +447,7 @@ public class SampleConfirmationForm extends AbstractRendering { tcr1.setHorizontalAlignment(SwingConstants.CENTER); table.setDefaultRenderer(Object.class, tcr1); for (int i = 0; i < model.getColumnCount(); i++) { - table.getColumnModel().getColumn(i) - .setCellEditor(new MyCellEditor(new JTextField())); + table.getColumnModel().getColumn(i).setCellEditor(new MyCellEditor(new JTextField())); } table.addMouseListener(rightClick()); confirmPanel.add(table, BorderLayout.CENTER); @@ -484,11 +456,9 @@ public class SampleConfirmationForm extends AbstractRendering { prop = form.getProperties(); for (Entry entry : general.entrySet()) { if (prop.containsKey(entry.getKey())) { - model.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], - entry.getValue()[1]); + model.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]); } else { - model.setValueAt(entry.getKey(), entry.getValue()[0], - entry.getValue()[1]); + model.setValueAt(entry.getKey(), entry.getValue()[0], entry.getValue()[1]); System.out.println("属性‘" + entry.getKey() + "’未找到"); } } @@ -509,11 +479,9 @@ public class SampleConfirmationForm extends AbstractRendering { TCComponentDataset dataset = (TCComponentDataset) comp; String temp = System.getenv("temp"); System.out.println(temp); - String[] types = dataset.getProperty("ref_names") - .split(","); + String[] types = dataset.getProperty("ref_names").split(","); System.out.println(Arrays.toString(types)); - System.out.println(Arrays - .toString(dataset.getFileNames(types[0]))); + System.out.println(Arrays.toString(dataset.getFileNames(types[0]))); File img = dataset.getFiles(types[0], temp)[0]; System.out.println(img.getPath()); @@ -527,10 +495,8 @@ public class SampleConfirmationForm extends AbstractRendering { } System.out.println("row:" + arr[0] + ",col:" + arr[1]); icon.setImage(icon.getImage().getScaledInstance( - table.getColumnModel().getColumn(col) - .getPreferredWidth() * arr[1], - table.getRowHeight() * arr[0], - Image.SCALE_SMOOTH)); + table.getColumnModel().getColumn(col).getPreferredWidth() * arr[1], + table.getRowHeight() * arr[0], Image.SCALE_SMOOTH)); JLabel label = new JLabel(); label.setLayout(new FlowLayout(FlowLayout.CENTER)); label.setIcon(icon); @@ -543,28 +509,23 @@ public class SampleConfirmationForm extends AbstractRendering { } } else { - model.setValueAt(new JLabel(entry.getKey()), - entry.getValue()[0], entry.getValue()[1]); + model.setValueAt(new JLabel(entry.getKey()), entry.getValue()[0], entry.getValue()[1]); System.out.println("属性‘" + entry.getKey() + "’未找到"); } } if (prop.containsKey("jd2_ypqrdtable")) { - String[][] tableRows = TCTableUtil.getTableRows(form, - "jd2_ypqrdtable", colNames); + String[][] tableRows = TCTableUtil.getTableRows(form, "jd2_ypqrdtable", colNames); System.out.println(Arrays.deepToString(tableRows)); for (int i = 0; i < tableRows.length; i++) { for (int ii = 0; ii < tableRows[0].length; ii++) { if (i + top + 2 > bottom) { - int num = Integer.parseInt( - model.getValueAt(bottom, 0).toString()); + int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); model.insertRow(bottom); model.setValueAt(num + 1, bottom, 0); - model.combine(new int[] { bottom }, - new int[] { 2, 3, 4 }); + model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); bottom = model.getRowCount() - end; } - model.setValueAt(tableRows[i][ii], i + top + 2, - ii > 2 ? ii + 2 : ii); + model.setValueAt(tableRows[i][ii], i + top + 2, ii > 2 ? ii + 2 : ii); } } } @@ -577,6 +538,7 @@ public class SampleConfirmationForm extends AbstractRendering { model2 = new CTMap(49, 10); bottom2 = model2.getRowCount() - end2; + disableEdit2 = new ArrayList(); model2.setValueAt("SPL No", 0, 0); disableEdit2.add("0,0"); model2.combine(new int[] { 0, 1, 2, 3 }, new int[] { 0 }); @@ -584,7 +546,7 @@ public class SampleConfirmationForm extends AbstractRendering { disableEdit2.add("0,1"); model2.combine(new int[] { 0, 1 }, new int[] { 1 }); for (int i = 0; i < 8; i++) { - model2.setValueAt("CTQ<" + i + 1 + ">", 0, i + 2); + model2.setValueAt("CTQ<" + (i + 1) + ">", 0, i + 2); disableEdit2.add("0," + (i + 2)); } model2.setValueAt("LOW", 2, 1); @@ -592,8 +554,8 @@ public class SampleConfirmationForm extends AbstractRendering { model2.setValueAt("UP", 3, 1); disableEdit2.add("3,1"); - for (int i = top2; i <= model2.getRowCount(); i++) { - model2.setValueAt(i - top2, i, 0); + for (int i = top2; i < model2.getRowCount(); i++) { + model2.setValueAt(i - top2 + 1, i, 0); disableEdit2.add(i + ",0"); model2.combine(new int[] { i }, new int[] { 0, 1 }); } @@ -614,6 +576,11 @@ public class SampleConfirmationForm extends AbstractRendering { model2.setValueAt("工程能力意义", bottom + 15, 0); table2 = new CTable(model2) { + /** + * + */ + private static final long serialVersionUID = 1L; + @Override public boolean isCellEditable(int row, int col) { if (isEditorDisable(disableEdit2, row, col)) { @@ -624,23 +591,20 @@ public class SampleConfirmationForm extends AbstractRendering { }; table2.setRowHeight(25); table2.setBorder(BorderFactory.createLineBorder(Color.black)); - for (int i = 0; i < model.getColumnCount(); i++) { + for (int i = 0; i < model2.getColumnCount(); i++) { table2.getColumnModel().getColumn(i).setPreferredWidth(80); } DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() { // 重写方法 @Override - public Component getTableCellRendererComponent(JTable table, - Object value, boolean isSelected, boolean hasFocus, int row, - int column) { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { // TODO Auto-generated method stub int maxPreferredHeight = 0; for (int i = 0; i < table.getColumnCount(); i++) { setText("" + table.getValueAt(row, i)); - setSize(table.getColumnModel().getColumn(column).getWidth(), - 0); - maxPreferredHeight = Math.max(maxPreferredHeight, - getPreferredSize().height); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); } setBackground(Color.white); // if(points1.contains(new Point(row,column))) @@ -660,8 +624,58 @@ public class SampleConfirmationForm extends AbstractRendering { }; tcr2.setHorizontalAlignment(SwingConstants.CENTER); table2.setDefaultRenderer(Object.class, tcr2); + MyCellEditor1[] editor1 = new MyCellEditor1[model2.getColumnCount()]; + for (int i = 0; i < model2.getColumnCount(); i++) { + editor1[i] = new MyCellEditor1(new JTextField(), top2, end2, bottom2); + table2.getColumnModel().getColumn(i).setCellEditor(editor1[i]); + } table2.addMouseListener(rightClick2()); examinePanel.add(table2, BorderLayout.CENTER); + if (prop.containsKey("jd2_ctq1")) { + String[][] tableRows = TCTableUtil.getTableRows(form, "jd2_ctq1", colNames1); + System.out.println(Arrays.deepToString(tableRows)); + for (int i = 0; i < tableRows.length; i++) { + for (int ii = 0; ii < tableRows[0].length; ii++) { + model2.setValueAt(tableRows[i][ii], i + 1, ii + 2); + if (i == 1) { + if (!"".equals(tableRows[i][ii])) { + editor1[ii + 2].setLow(Double.parseDouble(tableRows[i][ii])); + editor1[ii + 2].setCnt(editor1[ii + 2].getCnt() + 1); + } + } + if (i == 2) { + if (!"".equals(tableRows[i][ii])) { + editor1[ii + 2].setUp(Double.parseDouble(tableRows[i][ii])); + editor1[ii + 2].setCnt(editor1[ii + 2].getCnt() + 1); + } + } + } + } + } + if (prop.containsKey("jd2_ctq2")) { + String[][] tableRows = TCTableUtil.getTableRows(form, "jd2_ctq2", colNames2); + System.out.println(Arrays.deepToString(tableRows)); + for (int i = 0; i < tableRows.length; i++) { + for (int ii = 0; ii < tableRows[0].length; ii++) { + if (i + top2 > bottom2) { + int num = Integer.parseInt(model2.getValueAt(bottom2, 0).toString()); + model2.insertRow(++bottom2); + model2.setValueAt(num + 1, bottom2, 0); + model2.combine(new int[] { bottom2 }, new int[] { 0, 1 }); + } + model2.setValueAt(tableRows[i][ii], i + top2, ii > 0 ? ii + 1 : ii); + } + } + } + if (prop.containsKey("jd2_ctq3")) { + String[][] tableRows = TCTableUtil.getTableRows(form, "jd2_ctq3", colNames3); + System.out.println(Arrays.deepToString(tableRows)); + for (int i = 0; i < tableRows.length; i++) { + for (int ii = 0; ii < tableRows[0].length; ii++) { + model2.setValueAt(tableRows[i][ii], i + bottom2 + 1, ii + 2); + } + } + } ScrollPane examineScrollPanel = new ScrollPane(); examineScrollPanel.add(examinePanel); @@ -715,8 +729,7 @@ public class SampleConfirmationForm extends AbstractRendering { JLabel label = null; for (Entry entry : pic.entrySet()) { if (prop.containsKey(entry.getKey())) { - label = (JLabel) model.getValueAt(entry.getValue()[0], - entry.getValue()[1]); + label = (JLabel) model.getValueAt(entry.getValue()[0], entry.getValue()[1]); try { form.setProperty(entry.getKey(), label.getToolTipText()); } catch (TCException e) { @@ -729,12 +742,10 @@ public class SampleConfirmationForm extends AbstractRendering { // 保存选择 try { if (prop.containsKey("jd2_sysl")) { - form.setProperty("jd2_sysl", sysl.getSelected() == null ? "" - : sysl.getSelected().getText()); + form.setProperty("jd2_sysl", sysl.getSelected() == null ? "" : sysl.getSelected().getText()); } if (prop.containsKey("jd2_mqjd")) { - form.setProperty("jd2_mqjd", mqjd.getSelectedText() == null ? "" - : mqjd.getSelectedText()); + form.setProperty("jd2_mqjd", mqjd.getSelectedText() == null ? "" : mqjd.getSelectedText()); } } catch (TCException e) { @@ -746,8 +757,7 @@ public class SampleConfirmationForm extends AbstractRendering { try { if (prop.containsKey(entry.getKey())) { form.setProperty(entry.getKey(), - model.getValueAt(entry.getValue()[0], - entry.getValue()[1]).toString()); + model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString()); } } catch (TCException e) { // TODO Auto-generated catch block @@ -758,25 +768,91 @@ public class SampleConfirmationForm extends AbstractRendering { if (prop.containsKey("jd2_ypqrdtable")) { List data = new ArrayList(); int num = 0; - while (model.getValueAt(top + 2 + num, 1) != null - && !"".equals(model.getValueAt(top + 2 + num, 1))) { + while (model.getValueAt(top + 2 + num, 1) != null && !"".equals(model.getValueAt(top + 2 + num, 1))) { String[] row = new String[18]; - for (int ii = 0; ii < 18; ii++) { - Object object = model.getValueAt(top + 2 + num, - ii > 2 ? ii + 2 : ii); + for (int ii = 0; ii < row.length; ii++) { + Object object = model.getValueAt(top + 2 + num, ii > 2 ? ii + 2 : ii); if (object == null) { row[ii] = ""; } else { row[ii] = object.toString(); } - System.out.println(row[ii]); } data.add(row); num++; + if (top + 2 + num > bottom) { + break; + } + } + String[][] dataArr = data.toArray(new String[data.size()][]); + System.out.println(Arrays.deepToString(dataArr)); + TCTableUtil.setTableRows(form, "jd2_ypqrdtable", "JD2_YPQRDTABLE", colNames, dataArr); + } + if (prop.containsKey("jd2_ctq1")) { + List data = new ArrayList(); + int num = 0; + while (num < 3) { + String[] row = new String[8]; + for (int ii = 0; ii < row.length; ii++) { + Object object = model2.getValueAt(num + 1, ii + 2); + if (object == null) { + row[ii] = ""; + } else { + row[ii] = object.toString(); + } + } + data.add(row); + num++; + } + String[][] dataArr = data.toArray(new String[data.size()][]); + System.out.println(Arrays.deepToString(dataArr)); + TCTableUtil.setTableRows(form, "jd2_ctq1", "JD2_CTQ1", colNames1, dataArr); + } + if (prop.containsKey("jd2_ctq2")) { + List data = new ArrayList(); + int num = 0; + while (model2.getValueAt(top2 + num, 2) != null && !"".equals(model2.getValueAt(top2 + num, 2))) { + String[] row = new String[9]; + for (int ii = 0; ii < row.length; ii++) { + Object object = model2.getValueAt(top2 + num, ii > 0 ? ii + 1 : ii); + if (object == null) { + row[ii] = ""; + } else { + row[ii] = object.toString(); + } + } + data.add(row); + num++; + if (top2 + num > bottom2) { + break; + } + } + String[][] dataArr = data.toArray(new String[data.size()][]); + System.out.println(Arrays.deepToString(dataArr)); + TCTableUtil.setTableRows(form, "jd2_ctq2", "JD2_CTQ2", colNames2, dataArr); + } + if (prop.containsKey("jd2_ctq3")) { + List data = new ArrayList(); + int num = 0; + while (num < end2 - 1) { + String[] row = new String[8]; + for (int ii = 0; ii < row.length; ii++) { + Object object = model2.getValueAt(bottom2 + 1 + num, ii + 2); + if (object == null) { + row[ii] = ""; + } else { + row[ii] = object.toString(); + } + } + data.add(row); + num++; + if (bottom2 + 1 + num > model2.getRowCount()) { + break; + } } String[][] dataArr = data.toArray(new String[data.size()][]); System.out.println(Arrays.deepToString(dataArr)); - TCTableUtil.setTableRows(form, "jd2_ypqrdtable", colNames, dataArr); + TCTableUtil.setTableRows(form, "jd2_ctq3", "JD2_CTQ3", colNames3, dataArr); } } @@ -810,8 +886,7 @@ public class SampleConfirmationForm extends AbstractRendering { MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() - && table.getSelectedRow() != -1) { + if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table.getSelectedRow() != -1) { menu.show(e.getComponent(), e.getX(), e.getY()); } } @@ -823,8 +898,7 @@ public class SampleConfirmationForm extends AbstractRendering { MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() - && table2.getSelectedRow() != -1) { + if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table2.getSelectedRow() != -1) { menu2.show(e.getComponent(), e.getX(), e.getY()); } } @@ -852,10 +926,8 @@ public class SampleConfirmationForm extends AbstractRendering { @Override public boolean accept(File var1) { // TODO Auto-generated method stub - return var1.getName().endsWith(".png") - || var1.getName().endsWith(".jpg") - || var1.getName().endsWith(".jpeg") - || var1.getName().endsWith(".bmp"); + return var1.getName().endsWith(".png") || var1.getName().endsWith(".jpg") + || var1.getName().endsWith(".jpeg") || var1.getName().endsWith(".bmp"); } }); fileChooser.showOpenDialog(menu);// 参数表示定位 @@ -866,15 +938,12 @@ public class SampleConfirmationForm extends AbstractRendering { String as2[] = { "Image" }; TCComponentDatasetType datasetType; try { - datasetType = (TCComponentDatasetType) session - .getTypeComponent("Dataset"); - TCComponentDataset dataset = datasetType - .create(file.getName(), "", "Image"); + datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + TCComponentDataset dataset = datasetType.create(file.getName(), "", "Image"); dataset.setFiles(as1, as2); TCComponent[] comps = form.getRelatedComponents(); AIFComponentContext[] ref = form.whereReferenced(); - TCComponentItemRevision rev = (TCComponentItemRevision) ref[0] - .getComponent(); + TCComponentItemRevision rev = (TCComponentItemRevision) ref[0].getComponent(); rev.add("IMAN_specification", dataset); String uid = dataset.getUid(); System.out.println("uid:" + uid); @@ -884,17 +953,14 @@ public class SampleConfirmationForm extends AbstractRendering { int[] arr = model.getSpan(row, col); System.out.println("row:" + arr[0] + ",col:" + arr[1]); icon.setImage(icon.getImage().getScaledInstance( - table.getColumnModel().getColumn(col) - .getPreferredWidth() * arr[1], - table.getRowHeight() * arr[0], - Image.SCALE_SMOOTH)); + table.getColumnModel().getColumn(col).getPreferredWidth() * arr[1], + table.getRowHeight() * arr[0], Image.SCALE_SMOOTH)); JLabel label = new JLabel(); label.setLayout(new FlowLayout(FlowLayout.CENTER)); label.setIcon(icon); label.addMouseListener(showImg(file.getPath())); label.setToolTipText(uid); - model.setValueAt(label, table.getSelectedRow(), - table.getSelectedColumn()); + model.setValueAt(label, table.getSelectedRow(), table.getSelectedColumn()); } catch (TCException e1) { // TODO Auto-generated catch block e1.printStackTrace(); @@ -913,13 +979,11 @@ public class SampleConfirmationForm extends AbstractRendering { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int row = table.getSelectedRow(); - if (row > top + 1 && row < bottom + 1) { - int num = Integer - .parseInt(model.getValueAt(bottom, 0).toString()); - model.insertRow(bottom); + if (row >= top && row <= bottom) { + int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); + model.insertRow(++bottom); model.setValueAt(num + 1, bottom, 0); model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); - bottom = model.getRowCount() - end; } else { // 提示 } @@ -936,12 +1000,10 @@ public class SampleConfirmationForm extends AbstractRendering { // TODO Auto-generated method stub int row = table2.getSelectedRow(); if (row >= top2 && row <= bottom2) { - int num = Integer - .parseInt(model2.getValueAt(bottom2, 0).toString()); - model2.insertRow(bottom2); + int num = Integer.parseInt(model2.getValueAt(bottom2, 0).toString()); + model2.insertRow(++bottom2); model2.setValueAt(num + 1, bottom2, 0); model2.combine(new int[] { bottom2 }, new int[] { 0, 1 }); - bottom2 = model2.getRowCount() - end2; } else { // 提示 } @@ -957,15 +1019,14 @@ public class SampleConfirmationForm extends AbstractRendering { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int row = table.getSelectedRow(); - if (row > top + 1 && row < bottom + 1) { - int num = Integer - .parseInt(model.getValueAt(row, 0).toString()); + if (row >= top && row <= bottom) { + int num = Integer.parseInt(model.getValueAt(row, 0).toString()); model.insertRow(row); - for (int i = row; i < model.getRowCount(); i++) { - model.setValueAt(num + i + 1 - row, row, 0); + bottom++; + for (int i = row; i <= bottom; i++) { + model.setValueAt(num + i - row, i, 0); } model.combine(new int[] { row }, new int[] { 2, 3, 4 }); - bottom = model.getRowCount() - end; } else { // 提示 } @@ -982,14 +1043,13 @@ public class SampleConfirmationForm extends AbstractRendering { // TODO Auto-generated method stub int row = table2.getSelectedRow(); if (row >= top2 && row <= bottom2) { - int num = Integer - .parseInt(model2.getValueAt(row, 0).toString()); + int num = Integer.parseInt(model2.getValueAt(row, 0).toString()); model2.insertRow(row); - for (int i = row; i < model2.getRowCount(); i++) { - model2.setValueAt(num + i + 1 - row, row, 0); + bottom2++; + for (int i = row; i <= bottom2; i++) { + model2.setValueAt(num + i - row, i, 0); } model2.combine(new int[] { row }, new int[] { 0, 1 }); - bottom2 = model2.getRowCount() - end2; } else { // 提示 } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor1.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor1.java new file mode 100644 index 0000000..b76211e --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor1.java @@ -0,0 +1,268 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.DefaultCellEditor; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor1 extends DefaultCellEditor { + private int col; + private int row; + private JTable table; + private int top; + private int end; + private int bottom; + private List data; + private double low = 0.0; + private double up = 0.0; + private int cnt = 0; + + public MyCellEditor1(JTextField paramJTextField) { + super(paramJTextField); + // TODO Auto-generated constructor stub + } + + public MyCellEditor1(JTextField paramJTextField, int top, int end, int bottom) { + super(paramJTextField); + // TODO Auto-generated constructor stub + this.top = top; + this.end = end; + this.bottom = bottom; + } + + public double getLow() { + return low; + } + + public void setLow(double low) { + this.low = low; + } + + public double getUp() { + return up; + } + + public void setUp(double up) { + this.up = up; + } + + public int getCnt() { + return cnt; + } + + public void setCnt(int cnt) { + this.cnt = cnt; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + this.col = column; + this.row = row; + this.table = table; + bottom = table.getRowCount() - end; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public boolean stopCellEditing() { + // TODO Auto-generated method stub + System.out.println("top:" + top + ",end:" + end + ",bottom:" + bottom + " 重新计算列:" + col); + data = new ArrayList(); + Object now = getCellEditorValue(); + Object obj = null; + + if (row == 2) { + if (now != null && !"".equals(now.toString().trim())) { + low = Double.parseDouble(now.toString().trim()); + cnt++; + } else { + low = 0.0; + cnt--; + } + } + if (row == 3) { + if (now != null && !"".equals(now.toString().trim())) { + up = Double.parseDouble(now.toString().trim()); + cnt++; + } else { + up = 0.0; + cnt--; + } + } + for (int i = top; i < row && i <= bottom; i++) { + obj = table.getModel().getValueAt(i, col); + if (obj != null && !"".equals(obj.toString().trim())) { + data.add(Double.parseDouble(obj.toString().trim())); + } + } + if (row >= top && row <= bottom && now != null && !"".equals(now.toString().trim())) { + data.add(Double.parseDouble(now.toString().trim())); + } + for (int i = row + 1; i <= bottom; i++) { + obj = table.getModel().getValueAt(i, col); + if (obj != null && !"".equals(obj.toString().trim())) { + data.add(Double.parseDouble(obj.toString().trim())); + } + } + System.out.println(Arrays.toString(data.toArray())); + + double sum = 0; + double max = Double.MIN_VALUE; + double min = Double.MAX_VALUE; + for (Double d : data) { + sum += d; + max = Math.max(max, d); + min = Math.min(min, d); + } + if (sum != 0) { + double r = max - min; + double avg = sum / data.size(); + table.getModel().setValueAt(String.format("%.2f", min), bottom + 1, col); + table.getModel().setValueAt(String.format("%.2f", max), bottom + 2, col); + table.getModel().setValueAt(String.format("%.2f", r), bottom + 3, col); + table.getModel().setValueAt(String.format("%.2f", avg), bottom + 5, col); + if (data.size() - 1 > 0) { + double stdevSum = 0; + for (Double d : data) { + stdevSum += Math.pow(d - avg, 2); + } + double stdev = Math.sqrt(stdevSum / (data.size() - 1)); + double bar1 = avg - 3 * stdev; + double bar2 = avg + 3 * stdev; + table.getModel().setValueAt(String.format("%.2f", stdev), bottom + 4, col); + table.getModel().setValueAt(String.format("%.2f", bar1), bottom + 6, col); + table.getModel().setValueAt(String.format("%.2f", bar2), bottom + 7, col); + + double cp = 0.0; + if (cnt == 0) { + table.getModel().setValueAt("", bottom + 8, col); + } else if (cnt == 2) { + cp = (up - low) / (6 * stdev); + table.getModel().setValueAt(String.format("%.2f", cp), bottom + 8, col); + } else if (doubleIsEqual(up, 0.0)) { + cp = (avg - low) / (3 * stdev); + table.getModel().setValueAt(String.format("%.2f", cp), bottom + 8, col); + } else { + cp = (up - avg) / (3 * stdev); + table.getModel().setValueAt(String.format("%.2f", cp), bottom + 8, col); + } + double cpu = 0.0; + if (doubleIsEqual(up, 0.0)) { + table.getModel().setValueAt("", bottom + 9, col); + } else { + cpu = (up - avg) / (3 * stdev); + table.getModel().setValueAt(String.format("%.2f", cpu), bottom + 9, col); + } + double cpl = 0.0; + if (doubleIsEqual(low, 0.0)) { + table.getModel().setValueAt("", bottom + 10, col); + } else { + cpl = (avg - low) / (3 * stdev); + table.getModel().setValueAt(String.format("%.2f", cpl), bottom + 10, col); + } + double cpk = 0.0; + if (cnt == 2) { + cpk = (1 - 2 * Math.abs(((low + up) / 2 - avg)) / (up - low)) * cp; + table.getModel().setValueAt(String.format("%.2f", cpk), bottom + 11, col); + } else { + cpk = cp; + table.getModel().setValueAt(doubleIsEqual(cpk, 0.0) ? "" : String.format("%.2f", cpk), bottom + 11, + col); + } + double su = 0.0; + if (doubleIsEqual(cpu, 0.0)) { + table.getModel().setValueAt("", bottom + 12, col); + } else { + su = (1 - normSDist(cpu * 3)) * 1000000; + table.getModel().setValueAt(String.format("%.2f", su), bottom + 12, col); + } + double sl = 0.0; + if (doubleIsEqual(cpl, 0.0)) { + table.getModel().setValueAt("", bottom + 13, col); + } else { + sl = (1 - normSDist(cpl * 3)) * 1000000; + table.getModel().setValueAt(String.format("%.2f", sl), bottom + 13, col); + } + if (cnt == 0) { + table.getModel().setValueAt("", bottom + 14, col); + } else { + table.getModel().setValueAt(String.format("%.2f", su + sl), bottom + 14, col); + } + if (cnt == 0) { + table.getModel().setValueAt("", bottom + 15, col); + } else if (cpk > 1.99) { + table.getModel().setValueAt("非常好", bottom + 15, col); + } else if (cpk > 1.66) { + table.getModel().setValueAt("很好", bottom + 15, col); + } else if (cpk > 1.32) { + table.getModel().setValueAt("好", bottom + 15, col); + } else if (cpk > 0.99) { + table.getModel().setValueAt("有能力", bottom + 15, col); + } else { + table.getModel().setValueAt("能力不足", bottom + 15, col); + } + System.out.println("cp:" + cp + ",cpu:" + cpu + ",cpl:" + cpl + ",cpk:" + cpk + ",su:" + su + ",sl:" + + sl + ",ppm:" + (su + sl)); + } else { + table.getModel().setValueAt("", bottom + 4, col); + table.getModel().setValueAt("", bottom + 6, col); + table.getModel().setValueAt("", bottom + 7, col); + table.getModel().setValueAt("", bottom + 8, col); + table.getModel().setValueAt("", bottom + 9, col); + table.getModel().setValueAt("", bottom + 10, col); + table.getModel().setValueAt("", bottom + 11, col); + table.getModel().setValueAt("", bottom + 12, col); + table.getModel().setValueAt("", bottom + 13, col); + table.getModel().setValueAt("", bottom + 14, col); + table.getModel().setValueAt("", bottom + 15, col); + } + } else { + table.getModel().setValueAt("", bottom + 1, col); + table.getModel().setValueAt("", bottom + 2, col); + table.getModel().setValueAt("", bottom + 3, col); + table.getModel().setValueAt("", bottom + 5, col); + table.getModel().setValueAt("", bottom + 4, col); + table.getModel().setValueAt("", bottom + 6, col); + table.getModel().setValueAt("", bottom + 7, col); + table.getModel().setValueAt("", bottom + 8, col); + table.getModel().setValueAt("", bottom + 9, col); + table.getModel().setValueAt("", bottom + 10, col); + table.getModel().setValueAt("", bottom + 11, col); + table.getModel().setValueAt("", bottom + 12, col); + table.getModel().setValueAt("", bottom + 13, col); + table.getModel().setValueAt("", bottom + 14, col); + table.getModel().setValueAt("", bottom + 15, col); + } + return super.stopCellEditing(); + } + + private boolean doubleIsEqual(double a, double b) { + return Math.abs(a - b) < 0.000001; + } + + private double normSDist(double z) { + // this guards against overflow + if (z > 6) + return 1; + if (z < -6) + return 0; + + double gamma = 0.231641900, a1 = 0.319381530, a2 = -0.356563782, a3 = 1.781477973, a4 = -1.821255978, + a5 = 1.330274429; + + double x = Math.abs(z); + double t = 1 / (1 + gamma * x); + + double n = 1 - (1 / (Math.sqrt(2 * Math.PI)) * Math.exp(-z * z / 2)) + * (a1 * t + a2 * Math.pow(t, 2) + a3 * Math.pow(t, 3) + a4 * Math.pow(t, 4) + a5 * Math.pow(t, 5)); + if (z < 0) + return 1.0 - n; + + return n; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java index 455d04d..2f81d5b 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java @@ -17,16 +17,14 @@ import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; public class TCTableUtil { - public static String[][] getTableRows(TCComponentForm form, String prop, - String[] colNames) { + public static String[][] getTableRows(TCComponentForm form, String prop, String[] colNames) { try { TCProperty tcProperty = form.getTCProperty(prop); TCComponent[] components = tcProperty.getReferenceValueArray(); String[][] res = new String[components.length][colNames.length]; for (int i = 0; i < components.length; i++) { for (int ii = 0; ii < colNames.length; ii++) { - res[i][ii] = components[i] - .getPropertyDisplayableValue(colNames[ii]); + res[i][ii] = components[i].getPropertyDisplayableValue(colNames[ii]); } } return res; @@ -38,13 +36,13 @@ public class TCTableUtil { return null; } - public static boolean setTableRows(TCComponentForm form, String prop, - String[] colNames, String[][] rows) { + public static boolean setTableRows(TCComponentForm form, String prop, String refName, String[] colNames, + String[][] rows) { List list = new ArrayList(); - DataManagementService service = DataManagementService.getService( - (TCSession) AIFUtility.getCurrentApplication().getSession()); + DataManagementService service = DataManagementService + .getService((TCSession) AIFUtility.getCurrentApplication().getSession()); CreateIn ci = new CreateIn(); - ci.data.boName = "JD2_table"; + ci.data.boName = refName; Map map = new HashMap(); for (int i = 0; i < rows.length; i++) { for (int ii = 0; ii < colNames.length; ii++) { @@ -53,12 +51,13 @@ public class TCTableUtil { System.out.println(map.size()); ci.data.stringProps = map; try { - CreateResponse response = service - .createObjects(new CreateIn[] { ci }); - System.out.println("CreateResponse size:" - + response.serviceData.sizeOfCreatedObjects()); + CreateResponse response = service.createObjects(new CreateIn[] { ci }); + System.out.println("CreateResponse size:" + response.serviceData.sizeOfCreatedObjects()); if (response.serviceData.sizeOfCreatedObjects() > 0) { list.add(response.output[0].objects[0]); + } else { + String str = String.join(",", response.serviceData.getPartialError(0).getMessages()); + System.out.println(str); } } catch (ServiceException e) { // TODO Auto-generated catch block @@ -66,8 +65,7 @@ public class TCTableUtil { } } try { - form.getTCProperty(prop).setReferenceValueArray( - list.toArray(new TCComponent[list.size()])); + form.getTCProperty(prop).setReferenceValueArray(list.toArray(new TCComponent[list.size()])); System.out.println("保存table成功"); return true; } catch (TCException e) { diff --git a/com.connor.jd.plm/src/com/teamcenter/rac/form/form_user.properties b/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties similarity index 100% rename from com.connor.jd.plm/src/com/teamcenter/rac/form/form_user.properties rename to com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties From a9e418e55d87ea142797b4c82bdb48624d6b5ae9 Mon Sep 17 00:00:00 2001 From: zouxk Date: Mon, 30 Dec 2019 21:37:58 +0800 Subject: [PATCH 04/12] =?UTF-8?q?12/30=20=E6=A0=B7=E5=93=81=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E5=8D=95=E7=BB=86=E8=8A=82=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jd/plm/form/SampleConfirmationForm.java | 227 ++++++++++++------ .../com/connor/jd/plm/table/JCheckPanel.java | 3 + .../com/connor/jd/plm/table/JRadioPanel.java | 9 +- .../com/connor/jd/plm/table/MyCellEditor.java | 62 ++++- .../connor/jd/plm/table/MyCellEditor1.java | 17 ++ 5 files changed, 236 insertions(+), 82 deletions(-) diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index 4c60106..bbe15bc 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -79,16 +79,24 @@ public class SampleConfirmationForm extends AbstractRendering { private Map pic; private Map general2; private List disableEdit2; - private JRadioPanel sysl; + private JRadioPanel yssl; private JCheckPanel mqjd; - String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", "jd2_1", "jd2_2", "jd2_3", "jd2_4", - "jd2_5", "jd2_6", "jd2_7", "jd2_8", "jd2_9", "jd2_10", "jd2_min", "jd2_max", "jd2_jg" }; - String[] colNames1 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", + private String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", "jd2_1", "jd2_2", "jd2_3", + "jd2_4", "jd2_5", "jd2_6", "jd2_7", "jd2_8", "jd2_9", "jd2_10", "jd2_min", "jd2_max", "jd2_jg" }; + private String[] colNames1 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", "jd2_ctq8" }; - String[] colNames2 = { "jd2_no", "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", - "jd2_ctq8" }; - String[] colNames3 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", + private String[] colNames2 = { "jd2_no", "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", + "jd2_ctq7", "jd2_ctq8" }; + private String[] colNames3 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", "jd2_ctq8" }; + private JMenuItem addP; + private JMenuItem delP; + private JMenuItem addR; + private JMenuItem insertR; + private JMenuItem delR; + private JMenuItem addR2; + private JMenuItem insertR2; + private JMenuItem delR2; public SampleConfirmationForm(TCComponent arg0) throws Exception { super(arg0); @@ -175,8 +183,8 @@ public class SampleConfirmationForm extends AbstractRendering { general.put("jd2_wlbm", new int[] { 7, 2 }); model.setValueAt("送样数量", 7, 8); disableEdit.add("7,8"); - sysl = new JRadioPanel(new String[] { "3", "5", "10", "30" }); - model.setValueAt(sysl, 7, 10); + yssl = new JRadioPanel(new String[] { "3", "5", "10", "30" }); + model.setValueAt(yssl, 7, 10); model.setValueAt("状态", 7, 14); disableEdit.add("7,14"); general.put("jd2_zt", new int[] { 7, 17 }); @@ -254,14 +262,14 @@ public class SampleConfirmationForm extends AbstractRendering { disableEdit.add(bottom + 2 + ",15"); model.setValueAt("物料包装及标签", bottom + 2, 18); disableEdit.add(bottom + 2 + ",18"); - general.put("jd2_CTime", new int[] { bottom + 3, 5 }); + general.put("jd2_Ctime", new int[] { bottom + 3, 5 }); general.put("jd2_zs", new int[] { bottom + 3, 6 }); general.put("jd2_lq", new int[] { bottom + 3, 7 }); general.put("jd2_baoz", new int[] { bottom + 3, 8 }); pic.put("jd2_gfzjbg", new int[] { bottom + 3, 9 }); pic.put("jd2_gfzyzds", new int[] { bottom + 3, 12 }); pic.put("jd2_gfqcgct", new int[] { bottom + 3, 15 }); - pic.put("jd2_wlbzjbg", new int[] { bottom + 3, 18 }); + pic.put("jd2_wlbzjbq", new int[] { bottom + 3, 18 }); model.setValueAt("Shot/24Hr", bottom + 4, 5); disableEdit.add(bottom + 4 + ",5"); model.setValueAt("吨", bottom + 4, 6); @@ -270,8 +278,8 @@ public class SampleConfirmationForm extends AbstractRendering { general.put("jd2_d", new int[] { bottom + 5, 6 }); model.setValueAt("3D重量", bottom + 6, 4); disableEdit.add(bottom + 6 + ",4"); - model.setValueAt("jd2_3dzl", bottom + 6, 5); - general.put("jd2_3dzl", new int[] { bottom + 6, 5 }); + model.setValueAt("jd2_3Dzl", bottom + 6, 5); + general.put("jd2_3Dzl", new int[] { bottom + 6, 5 }); model.setValueAt("注塑工艺条件", bottom + 6, 7); disableEdit.add(bottom + 6 + ",7"); model.setValueAt("IQC首检报告", bottom + 6, 9); @@ -282,17 +290,17 @@ public class SampleConfirmationForm extends AbstractRendering { disableEdit.add(bottom + 6 + ",15"); model.setValueAt("模具标识", bottom + 6, 18); disableEdit.add(bottom + 6 + ",18"); - pic.put("jd2_gytj", new int[] { bottom + 7, 7 }); - pic.put("jd2_iqcsjbg", new int[] { bottom + 7, 9 }); + pic.put("jd2_zsgytj", new int[] { bottom + 7, 7 }); + pic.put("jd2_icqsjbg", new int[] { bottom + 7, 9 }); pic.put("jd2_csbg", new int[] { bottom + 7, 12 }); - pic.put("jd2_czbf", new int[] { bottom + 7, 15 }); + pic.put("jd2_czbg", new int[] { bottom + 7, 15 }); pic.put("jd2_mjbs", new int[] { bottom + 7, 18 }); model.setValueAt("实测重量", bottom + 8, 4); disableEdit.add(bottom + 8 + ",4"); general.put("jd2_sczl", new int[] { bottom + 8, 5 }); model.setValueAt("IQC作业指导书", bottom + 10, 4); disableEdit.add(bottom + 10 + ",4"); - pic.put("jd2_icqjyzyzds", new int[] { bottom + 11, 4 }); + pic.put("jd2_icqjyzds", new int[] { bottom + 11, 4 }); model.setValueAt("决定", bottom + 12, 12); disableEdit.add(bottom + 12 + ",12"); general.put("jd2_jued", new int[] { bottom + 12, 15 }); @@ -447,7 +455,7 @@ public class SampleConfirmationForm extends AbstractRendering { tcr1.setHorizontalAlignment(SwingConstants.CENTER); table.setDefaultRenderer(Object.class, tcr1); for (int i = 0; i < model.getColumnCount(); i++) { - table.getColumnModel().getColumn(i).setCellEditor(new MyCellEditor(new JTextField())); + table.getColumnModel().getColumn(i).setCellEditor(new MyCellEditor(new JTextField(), top, end, bottom)); } table.addMouseListener(rightClick()); confirmPanel.add(table, BorderLayout.CENTER); @@ -458,18 +466,21 @@ public class SampleConfirmationForm extends AbstractRendering { if (prop.containsKey(entry.getKey())) { model.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]); } else { - model.setValueAt(entry.getKey(), entry.getValue()[0], entry.getValue()[1]); + model.setValueAt("", entry.getValue()[0], entry.getValue()[1]); System.out.println("属性‘" + entry.getKey() + "’未找到"); } } - if (prop.containsKey("jd2_sysl")) { - sysl.setSelected(prop.get("jd2_sysl")); + if (prop.containsKey("jd2_yssl")) { + yssl.setSelected(prop.get("jd2_yssl")); + } else { + System.out.println("属性‘jd2_yssl’未找到"); } if (prop.containsKey("jd2_mqjd")) { mqjd.setSelected(prop.get("jd2_mqjd")); + } else { + System.out.println("属性‘jd2_mqjd’未找到"); } - pic.put("user_data_1", new int[] { bottom + 3, 0 }); - pic.put("user_data_2", new int[] { bottom + 3, 9 }); + for (Entry entry : pic.entrySet()) { if (prop.containsKey(entry.getKey())) { TCComponent comp = null; @@ -503,13 +514,17 @@ public class SampleConfirmationForm extends AbstractRendering { label.addMouseListener(showImg(img.getPath())); label.setToolTipText(dataset.getUid()); model.setValueAt(label, row, col); + } else { + model.setValueAt(new JLabel(""), entry.getValue()[0], entry.getValue()[1]); + System.out.println("未找到uid为\"" + prop.get(entry.getKey()) + "\"的数据集"); } } catch (Exception e) { + model.setValueAt(new JLabel(""), entry.getValue()[0], entry.getValue()[1]); e.printStackTrace(System.out); } } else { - model.setValueAt(new JLabel(entry.getKey()), entry.getValue()[0], entry.getValue()[1]); + model.setValueAt(new JLabel(""), entry.getValue()[0], entry.getValue()[1]); System.out.println("属性‘" + entry.getKey() + "’未找到"); } } @@ -528,6 +543,8 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt(tableRows[i][ii], i + top + 2, ii > 2 ? ii + 2 : ii); } } + } else { + System.out.println("属性‘jd2_ypqrdtable’未找到"); } ScrollPane confirmScrollPanel = new ScrollPane(); @@ -682,29 +699,41 @@ public class SampleConfirmationForm extends AbstractRendering { // 确认单右键菜单 menu.setVisible(false); - JMenuItem addP; addP = new JMenuItem("添加图片"); + addP.setEnabled(false); menu.add(addP); addP.addActionListener(addPic()); - JMenuItem addR; + delP = new JMenuItem("删除图片"); + delP.setEnabled(false); + menu.add(delP); + delP.addActionListener(delPic()); addR = new JMenuItem("添加行"); + addR.setEnabled(false); menu.add(addR); addR.addActionListener(addRow()); - JMenuItem insertR; insertR = new JMenuItem("插入行"); + insertR.setEnabled(false); menu.add(insertR); insertR.addActionListener(insertRow()); + delR = new JMenuItem("删除行"); + delR.setEnabled(false); + menu.add(delR); + delR.addActionListener(deleteRow()); // 检验单右键菜单 menu2.setVisible(false); - JMenuItem addR2; addR2 = new JMenuItem("添加行"); + addR2.setEnabled(false); menu2.add(addR2); addR2.addActionListener(addRow2()); - JMenuItem insertR2; insertR2 = new JMenuItem("插入行"); + insertR2.setEnabled(false); menu2.add(insertR2); insertR2.addActionListener(insertRow2()); + delR2 = new JMenuItem("删除行"); + delR2.setEnabled(false); + menu2.add(delR2); + delR2.addActionListener(deleteRow2()); center.add("confirm", confirmScrollPanel); center.add("examine", examineScrollPanel); @@ -741,11 +770,19 @@ public class SampleConfirmationForm extends AbstractRendering { } // 保存选择 try { - if (prop.containsKey("jd2_sysl")) { - form.setProperty("jd2_sysl", sysl.getSelected() == null ? "" : sysl.getSelected().getText()); + if (prop.containsKey("jd2_yssl")) { + String value = yssl.getSelected() == null ? "" : yssl.getSelected().getText(); + if (form.getTCProperty("jd2_yssl").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_yssl").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_yssl", value); } if (prop.containsKey("jd2_mqjd")) { - form.setProperty("jd2_mqjd", mqjd.getSelectedText() == null ? "" : mqjd.getSelectedText()); + String value = mqjd.getSelectedText() == null ? "" : mqjd.getSelectedText(); + if (form.getTCProperty("jd2_mqjd").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_mqjd").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_mqjd", value); } } catch (TCException e) { @@ -756,8 +793,12 @@ public class SampleConfirmationForm extends AbstractRendering { for (Entry entry : general.entrySet()) { try { if (prop.containsKey(entry.getKey())) { - form.setProperty(entry.getKey(), - model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString()); + String value = model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString(); + if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues() + .getRealValue(value); + } + form.setProperty(entry.getKey(), value); } } catch (TCException e) { // TODO Auto-generated catch block @@ -806,7 +847,7 @@ public class SampleConfirmationForm extends AbstractRendering { } String[][] dataArr = data.toArray(new String[data.size()][]); System.out.println(Arrays.deepToString(dataArr)); - TCTableUtil.setTableRows(form, "jd2_ctq1", "JD2_CTQ1", colNames1, dataArr); + TCTableUtil.setTableRows(form, "jd2_ctq1", "JD2_CQT1", colNames1, dataArr); } if (prop.containsKey("jd2_ctq2")) { List data = new ArrayList(); @@ -829,7 +870,7 @@ public class SampleConfirmationForm extends AbstractRendering { } String[][] dataArr = data.toArray(new String[data.size()][]); System.out.println(Arrays.deepToString(dataArr)); - TCTableUtil.setTableRows(form, "jd2_ctq2", "JD2_CTQ2", colNames2, dataArr); + TCTableUtil.setTableRows(form, "jd2_ctq2", "JD2_CQT2", colNames2, dataArr); } if (prop.containsKey("jd2_ctq3")) { List data = new ArrayList(); @@ -852,7 +893,7 @@ public class SampleConfirmationForm extends AbstractRendering { } String[][] dataArr = data.toArray(new String[data.size()][]); System.out.println(Arrays.deepToString(dataArr)); - TCTableUtil.setTableRows(form, "jd2_ctq3", "JD2_CTQ3", colNames3, dataArr); + TCTableUtil.setTableRows(form, "jd2_ctq3", "JD2_CQT3", colNames3, dataArr); } } @@ -887,6 +928,13 @@ public class SampleConfirmationForm extends AbstractRendering { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table.getSelectedRow() != -1) { + int row = table.getSelectedRow(); + boolean flag = (row >= top && row <= bottom); + addR.setEnabled(flag); + insertR.setEnabled(flag); + delR.setEnabled(flag); + flag = row > bottom; + addP.setEnabled(flag); menu.show(e.getComponent(), e.getX(), e.getY()); } } @@ -899,6 +947,11 @@ public class SampleConfirmationForm extends AbstractRendering { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table2.getSelectedRow() != -1) { + int row = table2.getSelectedRow(); + boolean flag = (row >= top2 && row <= bottom2); + addR2.setEnabled(flag); + insertR2.setEnabled(flag); + delR2.setEnabled(flag); menu2.show(e.getComponent(), e.getX(), e.getY()); } } @@ -972,86 +1025,124 @@ public class SampleConfirmationForm extends AbstractRendering { return actionListener; } + private ActionListener delPic() { + ActionListener actionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + int col = table.getSelectedColumn(); + model.setValueAt(new JLabel(""), row, col); + } + + }; + return actionListener; + } + private ActionListener addRow() { + ActionListener actionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); + model.insertRow(++bottom); + model.setValueAt(num + 1, bottom, 0); + model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); + + } + }; + return actionListener; + } + + private ActionListener addRow2() { + ActionListener actionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int num = Integer.parseInt(model2.getValueAt(bottom2, 0).toString()); + model2.insertRow(++bottom2); + model2.setValueAt(num + 1, bottom2, 0); + model2.combine(new int[] { bottom2 }, new int[] { 0, 1 }); + } + }; + return actionListener; + } + + private ActionListener insertRow() { ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int row = table.getSelectedRow(); - if (row >= top && row <= bottom) { - int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); - model.insertRow(++bottom); - model.setValueAt(num + 1, bottom, 0); - model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); - } else { - // 提示 + int num = Integer.parseInt(model.getValueAt(row, 0).toString()); + model.insertRow(row); + bottom++; + for (int i = row; i <= bottom; i++) { + model.setValueAt(num + i - row, i, 0); } + model.combine(new int[] { row }, new int[] { 2, 3, 4 }); } }; return actionListener; } - private ActionListener addRow2() { + private ActionListener insertRow2() { ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int row = table2.getSelectedRow(); - if (row >= top2 && row <= bottom2) { - int num = Integer.parseInt(model2.getValueAt(bottom2, 0).toString()); - model2.insertRow(++bottom2); - model2.setValueAt(num + 1, bottom2, 0); - model2.combine(new int[] { bottom2 }, new int[] { 0, 1 }); - } else { - // 提示 + int num = Integer.parseInt(model2.getValueAt(row, 0).toString()); + model2.insertRow(row); + bottom2++; + for (int i = row; i <= bottom2; i++) { + model2.setValueAt(num + i - row, i, 0); } + model2.combine(new int[] { row }, new int[] { 0, 1 }); } }; return actionListener; } - private ActionListener insertRow() { + private ActionListener deleteRow() { ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int row = table.getSelectedRow(); - if (row >= top && row <= bottom) { - int num = Integer.parseInt(model.getValueAt(row, 0).toString()); - model.insertRow(row); - bottom++; + int num = Integer.parseInt(model.getValueAt(row, 0).toString()); + model.removeRow(row); + bottom--; + if (row <= bottom) { for (int i = row; i <= bottom; i++) { model.setValueAt(num + i - row, i, 0); } - model.combine(new int[] { row }, new int[] { 2, 3, 4 }); - } else { - // 提示 } } }; return actionListener; } - private ActionListener insertRow2() { + private ActionListener deleteRow2() { ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int row = table2.getSelectedRow(); - if (row >= top2 && row <= bottom2) { - int num = Integer.parseInt(model2.getValueAt(row, 0).toString()); - model2.insertRow(row); - bottom2++; + int num = Integer.parseInt(model2.getValueAt(row, 0).toString()); + model2.removeRow(row); + bottom2--; + if (row <= bottom2) { for (int i = row; i <= bottom2; i++) { model2.setValueAt(num + i - row, i, 0); } - model2.combine(new int[] { row }, new int[] { 0, 1 }); - } else { - // 提示 } } }; diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java index 946e475..3e31e46 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java @@ -5,11 +5,13 @@ import java.awt.FlowLayout; import java.util.ArrayList; import java.util.List; +import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JPanel; public class JCheckPanel extends JPanel { private JCheckBox[] buttons = null; + private ButtonGroup buttonGroup = new ButtonGroup(); public JCheckPanel(String[] text) { super(); @@ -17,6 +19,7 @@ public class JCheckPanel extends JPanel { for (int i = 0; i < text.length; i++) { buttons[i] = new JCheckBox(text[i]); buttons[i].setPreferredSize(new Dimension(100, 25)); + buttonGroup.add(buttons[i]); add(buttons[i]); } setLayout(new FlowLayout(FlowLayout.LEFT)); diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java index 9ad868a..4d7fbcd 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java @@ -26,9 +26,10 @@ public class JRadioPanel extends JPanel { } public JRadioButton getSelected() { - if (buttonGroup.getSelection() != null) { - return (JRadioButton) buttonGroup.getSelection() - .getSelectedObjects()[0]; + for (JRadioButton jb : buttons) { + if (jb.isSelected()) { + return jb; + } } return null; } @@ -39,7 +40,7 @@ public class JRadioPanel extends JPanel { public void setSelected(String value) { for (int i = 0; i < buttons.length; i++) { - buttons[i].setSelected(buttons[i].getText().equals(value)); + buttons[i].setSelected(buttons[i].getText().equals(value.trim())); } } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java index 8bf1cfe..562f68d 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java @@ -7,40 +7,54 @@ import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.JTextField; +import com.teamcenter.rac.util.MessageBox; + public class MyCellEditor extends DefaultCellEditor { private JRadioPanel radio = null; private JCheckPanel check = null; private JLabel img = null; private int type = -1; + private int row; + private int col; + private int top; + private int end; + private int bottom; + private JTable table; public MyCellEditor(JTextField var1) { super(var1); // TODO Auto-generated constructor stub } + public MyCellEditor(JTextField var1, int top, int end, int bottom) { + super(var1); + // TODO Auto-generated constructor stub + this.top = top; + this.end = end; + this.bottom = bottom; + } + @Override - public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, int row, int column) { + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (value instanceof JRadioPanel) { - System.out.println("radio"); radio = (JRadioPanel) value; type = 1; return radio; } else if (value instanceof JCheckPanel) { - System.out.println("check"); check = (JCheckPanel) value; type = 2; return check; } else if (value instanceof JLabel) { - System.out.println("image"); img = (JLabel) value; type = 3; return img; } + this.row = row; + this.col = column; + this.bottom = table.getRowCount() - end; + this.table = table; type = 0; - System.out.println("default"); - return super.getTableCellEditorComponent(table, value, isSelected, row, - column); + return super.getTableCellEditorComponent(table, value, isSelected, row, column); } @Override @@ -53,13 +67,41 @@ public class MyCellEditor extends DefaultCellEditor { case 3: return img; } - return super.getCellEditorValue(); + Object obj = super.getCellEditorValue(); + if (obj != null && !"".equals(obj.toString().trim()) && row >= top && row <= bottom && col >= 7 + && col < table.getColumnCount() - 3) { + try { + Double.parseDouble(obj.toString().trim()); + } catch (Exception e) { + MessageBox.post("检查数据只能输入数字", "错误", MessageBox.ERROR); + return null; + } + } + return obj; } @Override public boolean stopCellEditing() { // TODO Auto-generated method stub -// System.out.println("stop"); + if (row >= top && row <= bottom && col >= 7 && col < table.getColumnCount() - 3) { + double min = Double.MAX_VALUE; + double max = Double.MIN_VALUE; + Object obj; + for (int i = 7; i < table.getColumnCount() - 3; i++) { + obj = table.getValueAt(row, i); + if (obj != null && !"".equals(obj.toString().trim())) { + min = Math.min(min, Double.parseDouble(obj.toString().trim())); + max = Math.max(max, Double.parseDouble(obj.toString().trim())); + } + } + if (max > Double.MIN_VALUE) { + table.setValueAt(String.format("%.2f", min), row, table.getColumnCount() - 3); + table.setValueAt(String.format("%.2f", max), row, table.getColumnCount() - 2); + } else { + table.setValueAt("", row, table.getColumnCount() - 3); + table.setValueAt("", row, table.getColumnCount() - 2); + } + } return super.stopCellEditing(); } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor1.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor1.java index b76211e..c71bdfe 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor1.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor1.java @@ -9,6 +9,8 @@ import javax.swing.DefaultCellEditor; import javax.swing.JTable; import javax.swing.JTextField; +import com.teamcenter.rac.util.MessageBox; + public class MyCellEditor1 extends DefaultCellEditor { private int col; private int row; @@ -67,6 +69,21 @@ public class MyCellEditor1 extends DefaultCellEditor { return super.getTableCellEditorComponent(table, value, isSelected, row, column); } + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + Object obj = super.getCellEditorValue(); + if (obj != null && !"".equals(obj.toString().trim()) && row >= top && row <= bottom) { + try { + Double.parseDouble(obj.toString().trim()); + } catch (Exception e) { + MessageBox.post("计算区域只能输入数字", "错误", MessageBox.ERROR); + return null; + } + } + return obj; + } + @Override public boolean stopCellEditing() { // TODO Auto-generated method stub From 92fb0f72c1eff69ce1bf6162f604402f7b93223b Mon Sep 17 00:00:00 2001 From: zouxk Date: Thu, 2 Jan 2020 10:10:47 +0800 Subject: [PATCH 05/12] 1/2 commit save --- com.connor.jd.plm/META-INF/MANIFEST.MF | 4 +- com.connor.jd.plm/build.properties | 3 +- .../src/com/connor/jd/plm/db/db.setting | 15 + .../plm/dialog/EditClassificationDialog.java | 1 + .../jd/plm/form/ComponentTestFrame.java | 116 +++++ .../form/ExperimentalPowerOfAttorneyForm.java | 411 ++++++++++++++++++ .../jd/plm/form/SampleConfirmationForm.java | 22 +- .../com/connor/jd/plm/table/MyCellEditor.java | 14 +- .../connor/jd/plm/table/MyCellEditor3.java | 39 ++ .../connor/jd/plm/table/MyCellEditor4.java | 5 + .../rac/stylesheet/stylesheet_user.properties | 3 +- 11 files changed, 616 insertions(+), 17 deletions(-) create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/db/db.setting create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor3.java create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor4.java diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF index 6ab32fe..c3b4388 100644 --- a/com.connor.jd.plm/META-INF/MANIFEST.MF +++ b/com.connor.jd.plm/META-INF/MANIFEST.MF @@ -17,6 +17,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.108.0", Automatic-Module-Name: JDProject Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: com.connor.jd.plm.action, + com.connor.jd.plm.db, com.connor.jd.plm.dialog, com.connor.jd.plm.form, com.connor.jd.plm.handlers, @@ -49,4 +50,5 @@ Bundle-ClassPath: ., lib/poi-ooxml-4.1.1.jar, lib/poi-ooxml-schemas-4.1.1.jar, lib/poi-scratchpad-4.1.1.jar, - lib/xmlbeans-3.1.0.jar + lib/xmlbeans-3.1.0.jar, + src/com/connor/jd/plm/db/ diff --git a/com.connor.jd.plm/build.properties b/com.connor.jd.plm/build.properties index 3aea07f..6847fdf 100644 --- a/com.connor.jd.plm/build.properties +++ b/com.connor.jd.plm/build.properties @@ -21,4 +21,5 @@ bin.includes = plugin.xml,\ lib/poi-ooxml-4.1.1.jar,\ lib/poi-ooxml-schemas-4.1.1.jar,\ lib/poi-scratchpad-4.1.1.jar,\ - lib/xmlbeans-3.1.0.jar + lib/xmlbeans-3.1.0.jar,\ + src/com/connor/jd/plm/db/ diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/db/db.setting b/com.connor.jd.plm/src/com/connor/jd/plm/db/db.setting new file mode 100644 index 0000000..e682982 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/db/db.setting @@ -0,0 +1,15 @@ +## db.setting文件 + +url = jdbc:oracle:thin:@localhost:1521:TC +user = root +pass = 123456 + +## 可选配置 +# 是否在日志中显示执行的SQL +showSql = true +# 是否格式化显示的SQL +formatSql = false +# 是否显示SQL参数 +showParams = true +# 打印SQL的日志等级,默认debug,可以是info、warn、error +sqlLevel = debug \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java index aa85294..895b62e 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java @@ -68,6 +68,7 @@ public class EditClassificationDialog extends AbstractAIFDialog { this.setTitle("修改分类属性"); this.setAutoRequestFocus(true); this.setResizable(true); + this.setAlwaysOnTop(true); JPanel rootPanel = new JPanel(new BorderLayout()); rootPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1)); diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java new file mode 100644 index 0000000..49887e6 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java @@ -0,0 +1,116 @@ +package com.connor.jd.plm.form; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; + +import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.table.DefaultTableCellRenderer; + +import com.connor.jd.plm.table.CTMap; +import com.connor.jd.plm.table.CTable; + +public class ComponentTestFrame extends JFrame { + private String[] arr; + private CTMap model; + private CTable table; + + private static ComponentTestFrame instance; + + public static ComponentTestFrame getInstance(String[] row) { + if (instance == null) { + instance = new ComponentTestFrame(row); + } else { + instance.arr = row; + instance.init(); + } + return instance; + } + + private ComponentTestFrame(String[] row) { + this.arr = row; + this.init(); + } + + private void init() { + this.setTitle("部件测试项目"); + this.setPreferredSize(new Dimension(700, 500)); + this.setResizable(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + + model = new CTMap(10, 7); + model.setValueAt("序号", 0, 0); + model.setValueAt("部品类型", 0, 1); + model.setValueAt("试验项目", 0, 2); + model.setValueAt("试验时间", 0, 3); + model.setValueAt("样品数量", 0, 4); + model.setValueAt("试验费用", 0, 5); + model.setValueAt("是否选择", 0, 6); + + table = new CTable(model) { + @Override + public boolean isCellEditable(int row, int col) { + if (row == 0 || col == 0) { + return false; + } + return true; + } + }; + table.setRowHeight(25); + table.setBorder(BorderFactory.createLineBorder(Color.black)); + for (int i = 0; i < model.getColumnCount(); i++) { + table.getColumnModel().getColumn(i).setPreferredWidth(100); + } + DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() { + // 重写方法 + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + + if (value instanceof JCheckBox) { + return (JCheckBox) value; + } + + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + setBackground(Color.white); +// if(points1.contains(new Point(row,column))) +// setForeground(new Color(0,0,255)); +// else + setForeground(Color.black); + if (isSelected) { + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙 + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + }; + tcr1.setHorizontalAlignment(SwingConstants.CENTER); + table.setDefaultRenderer(Object.class, tcr1); + table.getColumnModel().getColumn(6).setCellEditor(new DefaultCellEditor(new JCheckBox())); + + // 填写数据 + + this.setVisible(true); + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java new file mode 100644 index 0000000..3ad8321 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java @@ -0,0 +1,411 @@ +package com.connor.jd.plm.form; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.BorderFactory; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.table.DefaultTableCellRenderer; + +import com.connor.jd.plm.table.CTMap; +import com.connor.jd.plm.table.CTable; +import com.connor.jd.plm.table.JCheckPanel; +import com.connor.jd.plm.table.MyCellEditor3; +import com.connor.jd.plm.table.TCTableUtil; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; + +public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { + private TCComponentForm form; + private CTMap model; + private CTable table; + private int top = 10; + private int end = 4; + private int bottom; + private Map prop; + private List disableEdit; + private Map general; + private JCheckPanel bgqf; + private JPopupMenu menu = new JPopupMenu(); + private JMenuItem addR; + private JMenuItem delR; + private JMenuItem test; + private String[] colNames = new String[] { "jd2_no", "jd2_name", "jd2_bgq", "jd2_bgh", "jd2_risk", "jd2_csjh", + "jd2_bz" }; + private String[][] rows; + + public ExperimentalPowerOfAttorneyForm(TCComponent arg0) throws Exception { + super(arg0); + if (arg0 instanceof TCComponentForm) { + this.form = (TCComponentForm) arg0; + loadRendering(); + } + } + + @Override + public void loadRendering() throws TCException { + this.setLayout(new BorderLayout()); + JPanel root = new JPanel(new BorderLayout()); + root.setPreferredSize(new Dimension(800, 600)); + + // 内容 + prop = form.getProperties(); + model = new CTMap(20, 11); + bottom = model.getRowCount() - end; + disableEdit = new ArrayList<>();// 不允许编辑 + general = new HashMap();// 要填写的一般属性 + model.setValueAt("吉德", 0, 0); + disableEdit.add("0,0"); + model.setValueAt("试验委托书", 0, 3); + disableEdit.add("0,3"); + model.setValueAt("表号", 0, 8); + disableEdit.add("0,8"); + model.setValueAt("生效期", 1, 8); + disableEdit.add("1,8"); + general.put("jd2_bh", new int[] { 0, 9 }); + general.put("jd2_sxq", new int[] { 1, 9 }); + model.setValueAt("委托项目:", 3, 0); + disableEdit.add("3,0"); + model.setValueAt("委托部门:", 4, 0); + disableEdit.add("4,0"); + general.put("jd2_wtxm", new int[] { 3, 3 }); + general.put("jd2_wtbm", new int[] { 4, 3 }); + model.setValueAt("供货厂家:", 3, 6); + disableEdit.add("3,6"); + model.setValueAt("接受部门:", 4, 6); + disableEdit.add("4,6"); + general.put("jd2_ghcj", new int[] { 3, 8 }); + general.put("jd2_jsbm", new int[] { 4, 8 }); + model.setValueAt("变更区分:", 5, 0); + bgqf = new JCheckPanel(new String[] { "复制模", "降本", "二元化", "改善优化", "新规部品" }); + model.setValueAt(bgqf, 5, 2); + model.setValueAt("部品型号:", 7, 0); + disableEdit.add("7,0"); + general.put("jd2_bpxh", new int[] { 7, 2 }); + model.setValueAt("适用型号:", 7, 6); + disableEdit.add("7,6"); + general.put("jd2_syxh", new int[] { 7, 7 }); + model.setValueAt("变更内容", 8, 0); + disableEdit.add("8,0"); + + model.setValueAt("NO", top, 0); + disableEdit.add(top + ",0"); + model.setValueAt("名称", top, 1); + disableEdit.add(top + ",1"); + model.setValueAt("变更前", top, 2); + disableEdit.add(top + ",2"); + model.setValueAt("变更后", top, 5); + disableEdit.add(top + ",5"); + model.setValueAt("Risk", top, 8); + disableEdit.add(top + ",8"); + model.setValueAt("测试计划", top, 9); + disableEdit.add(top + ",9"); + model.setValueAt("备注", top, 10); + disableEdit.add(top + ",10"); + + model.setValueAt("预计完成日期:", bottom, 0); + disableEdit.add(bottom + ",0"); + general.put("jd2_yjwcrq", new int[] { bottom, 2 }); + model.setValueAt("编制签名:", bottom + 1, 0); + disableEdit.add(bottom + 1 + ",0"); + model.setValueAt("批准签名:", bottom + 2, 0); + disableEdit.add(bottom + 3 + ",0"); + general.put("jd2_bz", new int[] { bottom + 2, 2 }); + general.put("jd2_pz", new int[] { bottom + 3, 2 }); + model.setValueAt("编制时间:", bottom + 2, 5); + disableEdit.add(bottom + 2 + ",5"); + model.setValueAt("批准时间:", bottom + 3, 5); + disableEdit.add(bottom + 3 + ",5"); + general.put("jd2_bzrq", new int[] { bottom + 2, 8 }); + general.put("jd2_pzrq", new int[] { bottom + 3, 8 }); + + model.combine(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 }); + model.combine(new int[] { 0, 1, 2 }, new int[] { 3, 4, 5, 6, 7 }); + model.combine(new int[] { 0 }, new int[] { 9, 10 }); + model.combine(new int[] { 1 }, new int[] { 9, 10 }); + model.combine(new int[] { 2 }, new int[] { 8, 9, 10 }); + model.combine(new int[] { 3 }, new int[] { 0, 1, 2 }); + model.combine(new int[] { 3 }, new int[] { 3, 4, 5 }); + model.combine(new int[] { 3 }, new int[] { 6, 7 }); + model.combine(new int[] { 3 }, new int[] { 8, 9, 10 }); + model.combine(new int[] { 4 }, new int[] { 0, 1, 2 }); + model.combine(new int[] { 4 }, new int[] { 3, 4, 5 }); + model.combine(new int[] { 4 }, new int[] { 6, 7 }); + model.combine(new int[] { 4 }, new int[] { 8, 9, 10 }); + model.combine(new int[] { 5 }, new int[] { 0, 1 }); + model.combine(new int[] { 5 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model.combine(new int[] { 6 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model.combine(new int[] { 7 }, new int[] { 0, 1 }); + model.combine(new int[] { 7 }, new int[] { 2, 3, 4, 5 }); + model.combine(new int[] { 7 }, new int[] { 7, 8, 9, 10 }); + model.combine(new int[] { 8, 9 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model.combine(new int[] { top }, new int[] { 2, 3, 4 }); + model.combine(new int[] { top }, new int[] { 5, 6, 7 }); + for (int i = top + 1; i <= bottom; i++) { + model.combine(new int[] { i }, new int[] { 2, 3, 4 }); + model.combine(new int[] { i }, new int[] { 5, 6, 7 }); + model.setValueAt(i - top, i, 0); + disableEdit.add(i + ",0"); + } + model.combine(new int[] { bottom + 1 }, new int[] { 0, 1 }); + model.combine(new int[] { bottom + 1 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 }); + model.combine(new int[] { bottom + 2 }, new int[] { 2, 3, 4 }); + model.combine(new int[] { bottom + 2 }, new int[] { 5, 6, 7 }); + model.combine(new int[] { bottom + 2 }, new int[] { 8, 9, 10 }); + model.combine(new int[] { bottom + 3 }, new int[] { 0, 1 }); + model.combine(new int[] { bottom + 3 }, new int[] { 2, 3, 4 }); + model.combine(new int[] { bottom + 3 }, new int[] { 5, 6, 7 }); + model.combine(new int[] { bottom + 3 }, new int[] { 8, 9, 10 }); + + table = new CTable(model) { + @Override + public boolean isCellEditable(int row, int col) { + if (isEditorDisable(disableEdit, row, col)) { + return false; + } + return true; + } + }; + + table.setRowHeight(25); + table.setBorder(BorderFactory.createLineBorder(Color.black)); + table.getColumnModel().getColumn(0).setPreferredWidth(40); + table.getColumnModel().getColumn(1).setPreferredWidth(100); + table.getColumnModel().getColumn(2).setPreferredWidth(80); + table.getColumnModel().getColumn(3).setPreferredWidth(80); + table.getColumnModel().getColumn(4).setPreferredWidth(80); + table.getColumnModel().getColumn(5).setPreferredWidth(80); + table.getColumnModel().getColumn(6).setPreferredWidth(80); + table.getColumnModel().getColumn(7).setPreferredWidth(80); + table.getColumnModel().getColumn(8).setPreferredWidth(80); + table.getColumnModel().getColumn(9).setPreferredWidth(150); + table.getColumnModel().getColumn(10).setPreferredWidth(60); + + DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() { + // 重写方法 + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + + if (value instanceof JPanel) { + return (JPanel) value; + } + + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + setBackground(Color.white); +// if(points1.contains(new Point(row,column))) +// setForeground(new Color(0,0,255)); +// else + setForeground(Color.black); + if (isSelected) { + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙 + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + }; + tcr1.setHorizontalAlignment(SwingConstants.CENTER); + table.setDefaultRenderer(Object.class, tcr1); + table.getColumnModel().getColumn(2).setCellEditor(new MyCellEditor3(new JTextField())); + table.addMouseListener(rightClick()); + + // 右键菜单 + menu.setVisible(false); + addR = new JMenuItem("新增行"); + addR.setEnabled(false); + menu.add(addR); + addR.addActionListener(addRow()); + delR = new JMenuItem("删除行"); + delR.setEnabled(false); + menu.add(delR); + delR.addActionListener(delRow()); + test = new JMenuItem("测试项"); + test.setEnabled(false); + menu.add(test); + test.addActionListener(test()); + + // 填写数据 + for (Entry entry : general.entrySet()) { + if (prop.containsKey(entry.getKey())) { + model.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]); + } else { + System.out.println("未找到属性 " + entry.getKey()); + } + } + if (prop.containsKey("jd2_bgqf")) { + bgqf.setSelected(prop.get("jd2_bgqf")); + } else { + System.out.println("未找到属性 jd2_bgqf"); + } + rows = TCTableUtil.getTableRows(form, "jd2_sywts", colNames); + for (int i = 0; i < rows.length; i++) { + if (top + i + 1 > bottom) { + this.addRow(); + } + model.setValueAt(rows[i], top + i + 1, i > 2 ? i > 3 ? i + 4 : i + 2 : i); + } + + root.add(table, BorderLayout.CENTER); + this.add(menu); + this.add(root); + } + + @Override + public void saveRendering() { + // TODO Auto-generated method stub + for (Entry entry : general.entrySet()) { + if (prop.containsKey(entry.getKey())) { + String value = model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString(); + try { + if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues() + .getRealValue(value); + } + System.out.println(entry.getKey() + ":" + value); + form.setProperty(entry.getKey(), value); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + if (prop.containsKey("jd2_bgqf")) { + String value = bgqf.getSelectedText() == null ? "" : bgqf.getSelectedText(); + try { + if (form.getTCProperty("jd2_bgqf").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_bgqf").getLOV().getListOfValues().getRealValue(value); + } + System.out.println("jd2_bgqf:" + value); + form.setProperty("jd2_bgqf", value); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + if (prop.containsKey("jd2_sywts")) { + List data = new ArrayList(); + int num = 0; + while (model.getValueAt(top + 2 + num, 1) != null && !"".equals(model.getValueAt(top + 2 + num, 1))) { + String[] row = new String[7]; + for (int ii = 0; ii < row.length; ii++) { + Object object = model.getValueAt(top + 1 + num, ii > 2 ? ii > 3 ? ii + 4 : ii + 2 : ii); + if (object == null) { + row[ii] = ""; + } else { + row[ii] = object.toString(); + } + } + data.add(row); + num++; + if (top + 1 + num > bottom) { + break; + } + } + String[][] dataArr = data.toArray(new String[data.size()][]); + System.out.println(Arrays.deepToString(dataArr)); + TCTableUtil.setTableRows(form, "jd2_sywts", "JD2_SYWTS", colNames, dataArr); + } + } + + private boolean isEditorDisable(List list, int row, int col) { + return list.contains(row + "," + col); + } + + private MouseAdapter rightClick() { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table.getSelectedRow() != -1) { + int row = table.getSelectedRow(); + boolean flag = (row >= top && row <= bottom); + addR.setEnabled(flag); + delR.setEnabled(flag); + test.setEnabled(flag); + menu.show(e.getComponent(), e.getX(), e.getY()); + } + } + }; + } + + private ActionListener addRow() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); + model.insertRow(++bottom); + model.setValueAt(num + 1, bottom, 0); + model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); + model.combine(new int[] { bottom }, new int[] { 5, 6, 7 }); + } + }; + } + + private ActionListener delRow() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); + model.removeRow(row); + bottom--; + if (row <= bottom) { + for (int i = row; i <= bottom; i++) { + model.setValueAt(num + i - row, i, 0); + } + } + } + }; + + } + + private ActionListener test() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + ComponentTestFrame.getInstance(rows[row - top - 1]); + } + }; + + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index bbe15bc..5edb55b 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -77,7 +77,6 @@ public class SampleConfirmationForm extends AbstractRendering { private Map general; private List disableEdit; private Map pic; - private Map general2; private List disableEdit2; private JRadioPanel yssl; private JCheckPanel mqjd; @@ -482,6 +481,8 @@ public class SampleConfirmationForm extends AbstractRendering { } for (Entry entry : pic.entrySet()) { + int row = entry.getValue()[0]; + int col = entry.getValue()[1]; if (prop.containsKey(entry.getKey())) { TCComponent comp = null; try { @@ -497,8 +498,7 @@ public class SampleConfirmationForm extends AbstractRendering { System.out.println(img.getPath()); ImageIcon icon = new ImageIcon(img.getPath()); - int row = entry.getValue()[0]; - int col = entry.getValue()[1]; + int[] arr = model.getSpan(row, col); int width = 0; for (int i = 0; i < arr[1]; i++) { @@ -515,16 +515,16 @@ public class SampleConfirmationForm extends AbstractRendering { label.setToolTipText(dataset.getUid()); model.setValueAt(label, row, col); } else { - model.setValueAt(new JLabel(""), entry.getValue()[0], entry.getValue()[1]); + model.setValueAt(new JLabel(""), row, col); System.out.println("未找到uid为\"" + prop.get(entry.getKey()) + "\"的数据集"); } } catch (Exception e) { - model.setValueAt(new JLabel(""), entry.getValue()[0], entry.getValue()[1]); + model.setValueAt(new JLabel(""), row, col); e.printStackTrace(System.out); } } else { - model.setValueAt(new JLabel(""), entry.getValue()[0], entry.getValue()[1]); + model.setValueAt(new JLabel(""), row, col); System.out.println("属性‘" + entry.getKey() + "’未找到"); } } @@ -740,13 +740,7 @@ public class SampleConfirmationForm extends AbstractRendering { root.add(buttons, BorderLayout.NORTH); root.add(center, BorderLayout.CENTER); this.add(menu); - this.add(root, BorderLayout.CENTER); - - center.add("confirm", confirmScrollPanel); - center.add("examine", examineScrollPanel); - root.add(buttons, BorderLayout.NORTH); - root.add(center, BorderLayout.CENTER); - this.add(menu); + this.add(menu2); this.add(root, BorderLayout.CENTER); cl.show(center, "confirm"); @@ -758,6 +752,7 @@ public class SampleConfirmationForm extends AbstractRendering { JLabel label = null; for (Entry entry : pic.entrySet()) { if (prop.containsKey(entry.getKey())) { + System.out.println(entry.getKey()); label = (JLabel) model.getValueAt(entry.getValue()[0], entry.getValue()[1]); try { form.setProperty(entry.getKey(), label.getToolTipText()); @@ -798,6 +793,7 @@ public class SampleConfirmationForm extends AbstractRendering { value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues() .getRealValue(value); } + System.out.println(entry.getKey() + ":" + value); form.setProperty(entry.getKey(), value); } } catch (TCException e) { diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java index 562f68d..32d4037 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java @@ -87,7 +87,19 @@ public class MyCellEditor extends DefaultCellEditor { double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; Object obj; - for (int i = 7; i < table.getColumnCount() - 3; i++) { + for (int i = 7; i < col; i++) { + obj = table.getValueAt(row, i); + if (obj != null && !"".equals(obj.toString().trim())) { + min = Math.min(min, Double.parseDouble(obj.toString().trim())); + max = Math.max(max, Double.parseDouble(obj.toString().trim())); + } + } + obj = getCellEditorValue(); + if (obj != null && !"".equals(obj.toString().trim())) { + min = Math.min(min, Double.parseDouble(obj.toString().trim())); + max = Math.max(max, Double.parseDouble(obj.toString().trim())); + } + for (int i = col + 1; i < table.getColumnCount() - 3; i++) { obj = table.getValueAt(row, i); if (obj != null && !"".equals(obj.toString().trim())) { min = Math.min(min, Double.parseDouble(obj.toString().trim())); diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor3.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor3.java new file mode 100644 index 0000000..f5b2295 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor3.java @@ -0,0 +1,39 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor3 extends DefaultCellEditor { + private JCheckPanel check = null; + private int type = -1; + + public MyCellEditor3(JTextField arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + // TODO Auto-generated method stub + if (value instanceof JCheckPanel) { + check = (JCheckPanel) value; + type = 1; + return check; + } + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + if (type == 1) { + return check; + } + return super.getCellEditorValue(); + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor4.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor4.java new file mode 100644 index 0000000..26ddcd7 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor4.java @@ -0,0 +1,5 @@ +package com.connor.jd.plm.table; + +public class MyCellEditor4 { + +} diff --git a/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties index 6fb45b8..a159986 100644 --- a/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties +++ b/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -1 +1,2 @@ -JD2_GTYPQRDRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.SampleConfirmationForm \ No newline at end of file +JD2_GTYPQRDRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.SampleConfirmationForm +JD2_GTSYWTSRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.ExperimentalPowerOfAttorneyForm \ No newline at end of file From ff8a87e899dafda30d73791bd88fb4814a662db6 Mon Sep 17 00:00:00 2001 From: zouxk Date: Fri, 3 Jan 2020 13:40:50 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E5=AE=9E=E9=AA=8C=E5=A7=94=E6=89=98?= =?UTF-8?q?=E4=B9=A6=E8=A1=A8=E5=8D=95=E5=AE=9A=E5=88=B6=E5=BC=80=E5=8F=91?= =?UTF-8?q?=EF=BC=8806=EF=BC=89=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90=20?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E8=A1=A8=E5=8D=95=E8=A1=A8=E6=A0=BCbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.connor.jd.plm/.classpath | 1 + com.connor.jd.plm/META-INF/MANIFEST.MF | 5 +- com.connor.jd.plm/build.properties | 4 +- .../connor/jd/plm/db => config}/db.setting | 8 +- .../plm/dialog/EditClassificationDialog.java | 34 +- .../jd/plm/form/ComponentTestFrame.java | 171 ++++- .../form/ExperimentalPowerOfAttorneyForm.java | 260 ++++---- .../com/connor/jd/plm/form/MyCallBack.java | 6 + .../jd/plm/form/SampleConfirmationForm.java | 586 +++++++++--------- .../connor/jd/plm/table/MyCellEditor4.java | 34 +- 10 files changed, 672 insertions(+), 437 deletions(-) rename com.connor.jd.plm/{src/com/connor/jd/plm/db => config}/db.setting (60%) create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/form/MyCallBack.java diff --git a/com.connor.jd.plm/.classpath b/com.connor.jd.plm/.classpath index 5862cd5..aed57d5 100644 --- a/com.connor.jd.plm/.classpath +++ b/com.connor.jd.plm/.classpath @@ -1,5 +1,6 @@ + diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF index cad01e9..ad8d3d3 100644 --- a/com.connor.jd.plm/META-INF/MANIFEST.MF +++ b/com.connor.jd.plm/META-INF/MANIFEST.MF @@ -17,7 +17,6 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.108.0", Automatic-Module-Name: JDProject Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: com.connor.jd.plm.action, - com.connor.jd.plm.db, com.connor.jd.plm.dialog, com.connor.jd.plm.form, com.connor.jd.plm.handlers, @@ -51,6 +50,6 @@ Bundle-ClassPath: ., lib/poi-ooxml-schemas-4.1.1.jar, lib/poi-scratchpad-4.1.1.jar, lib/xmlbeans-3.1.0.jar, - src/com/connor/jd/plm/db/ + lib/commons-lang3-3.9.jar, lib/ojdbc6.jar, - lib/commons-lang3-3.9.jar + config/ diff --git a/com.connor.jd.plm/build.properties b/com.connor.jd.plm/build.properties index 50cbbff..22a88a1 100644 --- a/com.connor.jd.plm/build.properties +++ b/com.connor.jd.plm/build.properties @@ -22,7 +22,7 @@ bin.includes = plugin.xml,\ lib/poi-ooxml-schemas-4.1.1.jar,\ lib/poi-scratchpad-4.1.1.jar,\ lib/xmlbeans-3.1.0.jar,\ - src/com/connor/jd/plm/db/,\ lib/ojdbc6.jar,\ - lib/commons-lang3-3.9.jar + lib/commons-lang3-3.9.jar,\ + config/ diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/db/db.setting b/com.connor.jd.plm/config/db.setting similarity index 60% rename from com.connor.jd.plm/src/com/connor/jd/plm/db/db.setting rename to com.connor.jd.plm/config/db.setting index e682982..dbbfc73 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/db/db.setting +++ b/com.connor.jd.plm/config/db.setting @@ -1,8 +1,8 @@ ## db.setting文件 url = jdbc:oracle:thin:@localhost:1521:TC -user = root -pass = 123456 +user = infodba +pass = infodba ## 可选配置 # 是否在日志中显示执行的SQL @@ -10,6 +10,4 @@ showSql = true # 是否格式化显示的SQL formatSql = false # 是否显示SQL参数 -showParams = true -# 打印SQL的日志等级,默认debug,可以是info、warn、error -sqlLevel = debug \ No newline at end of file +showParams = true \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java index 895b62e..372419d 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java @@ -154,23 +154,23 @@ public class EditClassificationDialog extends AbstractAIFDialog { TCComponentItemRevision rev = (TCComponentItemRevision) target; saveClassification(rev); - try { - System.out.println(rev.getProperty("object_string")); - if (rev.getType().equals("JD2_GTBJRevision")) { - TCComponent[] comps = rev.getReferenceListProperty("TC_Is_Represented_By"); - System.out.println(comps.length); - for (int i = 0; i < comps.length; i++) { - if (comps[i].getType().equals("JD2_XYJTZRevision")) { - System.out.println("object_string:" + comps[i].getProperty("object_string")); - TCComponentItemRevision tzrev = (TCComponentItemRevision) comps[i]; - saveClassification(tzrev); - } - } - } - } catch (TCException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } +// try { +// System.out.println(rev.getProperty("object_string")); +// if (rev.getType().equals("JD2_GTBJRevision")) { +// TCComponent[] comps = rev.getReferenceListProperty("TC_Is_Represented_By"); +// System.out.println(comps.length); +// for (int i = 0; i < comps.length; i++) { +// if (comps[i].getType().equals("JD2_XYJTZRevision")) { +// System.out.println("object_string:" + comps[i].getProperty("object_string")); +// TCComponentItemRevision tzrev = (TCComponentItemRevision) comps[i]; +// saveClassification(tzrev); +// } +// } +// } +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } DIALOG.disposeDialog(); } }; diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java index 49887e6..cb9114a 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java @@ -5,48 +5,79 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.ScrollPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; import javax.swing.BorderFactory; -import javax.swing.DefaultCellEditor; +import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; +import javax.swing.JPanel; import javax.swing.JTable; +import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.table.DefaultTableCellRenderer; import com.connor.jd.plm.table.CTMap; import com.connor.jd.plm.table.CTable; +import com.connor.jd.plm.table.MyCellEditor4; +import com.connor.jd.plm.table.TCTableUtil; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.hutool.db.Db; +import cn.hutool.db.Entity; public class ComponentTestFrame extends JFrame { - private String[] arr; private CTMap model; private CTable table; + private List list; + private int bottom; + private Container container; + private TCComponentForm form; + private TCSession session; + private MyCallBack callBack; private static ComponentTestFrame instance; - public static ComponentTestFrame getInstance(String[] row) { + public static ComponentTestFrame getInstance(TCComponentForm form, MyCallBack callBack) { if (instance == null) { - instance = new ComponentTestFrame(row); + instance = new ComponentTestFrame(form); + instance.callBack = callBack; } else { - instance.arr = row; + instance.bottom = 0; + instance.form = form; instance.init(); } return instance; } - private ComponentTestFrame(String[] row) { - this.arr = row; + private ComponentTestFrame(TCComponentForm form) { + this.form = form; + this.session = (TCSession) AIFUtility.getCurrentApplication().getSession(); this.init(); } private void init() { this.setTitle("部件测试项目"); - this.setPreferredSize(new Dimension(700, 500)); + this.setSize(560, 400); this.setResizable(true); + this.setAlwaysOnTop(true); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - Container container = this.getContentPane(); + container = this.getContentPane(); container.setLayout(new BorderLayout()); + container.setPreferredSize(new Dimension(600, 400)); model = new CTMap(10, 7); model.setValueAt("序号", 0, 0); @@ -69,7 +100,7 @@ public class ComponentTestFrame extends JFrame { table.setRowHeight(25); table.setBorder(BorderFactory.createLineBorder(Color.black)); for (int i = 0; i < model.getColumnCount(); i++) { - table.getColumnModel().getColumn(i).setPreferredWidth(100); + table.getColumnModel().getColumn(i).setPreferredWidth(80); } DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() { // 重写方法 @@ -106,11 +137,129 @@ public class ComponentTestFrame extends JFrame { }; tcr1.setHorizontalAlignment(SwingConstants.CENTER); table.setDefaultRenderer(Object.class, tcr1); - table.getColumnModel().getColumn(6).setCellEditor(new DefaultCellEditor(new JCheckBox())); + table.getColumnModel().getColumn(6).setCellEditor(new MyCellEditor4(new JTextField())); // 填写数据 + try { + list = Db.use().findAll("JD2_COMPONENT"); + bottom = list.size(); + for (int i = 0; i < bottom; i++) { + if (i > model.getRowCount() - 2) { + model.addRow(); + } + int row = i + 1; + model.setValueAt(row, row, 0); + model.setValueAt(list.get(i).getStr("TEST_TYPE"), row, 1); + model.setValueAt(list.get(i).getStr("TEST_PROJECT"), row, 2); + model.setValueAt(list.get(i).getStr("TEST_TIME"), row, 3); + model.setValueAt(list.get(i).getInt("TEST_NUM"), row, 4); + model.setValueAt(list.get(i).getInt("TEST_COST"), row, 5); + model.setValueAt(new JCheckBox(), row, 6); + + System.out.println(list.get(i).toString()); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // 按钮 + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + JButton createTest = new JButton("创建测试计划"); + createTest.addActionListener(createTest()); + JButton addTestItem = new JButton("新增测试项"); + addTestItem.addActionListener(addTestItem()); + JButton cancel = new JButton("取消"); + cancel.addActionListener(cancel()); + buttonPanel.add(createTest); + buttonPanel.add(addTestItem); + buttonPanel.add(cancel); + + ScrollPane scrollPane = new ScrollPane(); + scrollPane.add(table); + + container.add(scrollPane, BorderLayout.CENTER); + container.add(buttonPanel, BorderLayout.SOUTH); this.setVisible(true); } + private ActionListener createTest() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + TCComponentItemRevision rev = (TCComponentItemRevision) form.whereReferenced()[0].getComponent(); + + TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("Item"); + String itemId = type.getNewID(); + String itemRev = type.getNewRev(null); + TCComponentItem item = type.create(itemId, itemRev, "JD2_GTCSJH", rev.getProperty("item_id"), "", + null); + rev.add("JD2_CSJH", item); + TCComponentItemRevision rev1 = item.getLatestItemRevision(); + TCComponentForm form1 = (TCComponentForm) rev1.getRelatedComponents("IMAN_master_form_rev")[0]; + String[] colNames = new String[] { "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq", "jd2_syfy" }; + List list = new ArrayList(); + String[] row = new String[5]; + for (int i = 1; i <= bottom; i++) { + JCheckBox jb = (JCheckBox) model.getValueAt(i, 6); + if (jb.isSelected()) { + for (int ii = 2; ii < 6; ii++) { + row[ii - 2] = model.getValueAt(i, ii) == null ? "" : model.getValueAt(i, ii).toString(); + } + list.add(new String[] { session.getUserName(), row[0], row[2], row[1], row[3] }); + } + } + String[][] data = list.toArray(new String[list.size()][5]); + TCTableUtil.setTableRows(form1, "jd2_csjh", "JD2_CSJHTABLE", colNames, data); + callBack.execute(itemId); + dispose(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }; + } + + private ActionListener addTestItem() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (bottom > model.getRowCount() - 2) { + model.addRow(); + } + int num = 1; + if (bottom > 0) { + num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); + } + model.setValueAt(num + 1, ++bottom, 0); + model.setValueAt(new JCheckBox(), bottom, 6); + } + }; + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + container.removeAll(); + super.dispose(); + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }; + } + } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java index 3ad8321..12f484e 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java @@ -4,6 +4,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.ScrollPane; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -34,7 +35,7 @@ import com.teamcenter.rac.kernel.TCComponentForm; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.stylesheet.AbstractRendering; -public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { +public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implements MyCallBack { private TCComponentForm form; private CTMap model; private CTable table; @@ -52,6 +53,7 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { private String[] colNames = new String[] { "jd2_no", "jd2_name", "jd2_bgq", "jd2_bgh", "jd2_risk", "jd2_csjh", "jd2_bz" }; private String[][] rows; + private ExperimentalPowerOfAttorneyForm $this; public ExperimentalPowerOfAttorneyForm(TCComponent arg0) throws Exception { super(arg0); @@ -63,119 +65,18 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { @Override public void loadRendering() throws TCException { + $this = this; + this.setLayout(new BorderLayout()); JPanel root = new JPanel(new BorderLayout()); - root.setPreferredSize(new Dimension(800, 600)); + root.setPreferredSize(new Dimension(800, 500)); // 内容 prop = form.getProperties(); model = new CTMap(20, 11); bottom = model.getRowCount() - end; - disableEdit = new ArrayList<>();// 不允许编辑 - general = new HashMap();// 要填写的一般属性 - model.setValueAt("吉德", 0, 0); - disableEdit.add("0,0"); - model.setValueAt("试验委托书", 0, 3); - disableEdit.add("0,3"); - model.setValueAt("表号", 0, 8); - disableEdit.add("0,8"); - model.setValueAt("生效期", 1, 8); - disableEdit.add("1,8"); - general.put("jd2_bh", new int[] { 0, 9 }); - general.put("jd2_sxq", new int[] { 1, 9 }); - model.setValueAt("委托项目:", 3, 0); - disableEdit.add("3,0"); - model.setValueAt("委托部门:", 4, 0); - disableEdit.add("4,0"); - general.put("jd2_wtxm", new int[] { 3, 3 }); - general.put("jd2_wtbm", new int[] { 4, 3 }); - model.setValueAt("供货厂家:", 3, 6); - disableEdit.add("3,6"); - model.setValueAt("接受部门:", 4, 6); - disableEdit.add("4,6"); - general.put("jd2_ghcj", new int[] { 3, 8 }); - general.put("jd2_jsbm", new int[] { 4, 8 }); - model.setValueAt("变更区分:", 5, 0); - bgqf = new JCheckPanel(new String[] { "复制模", "降本", "二元化", "改善优化", "新规部品" }); - model.setValueAt(bgqf, 5, 2); - model.setValueAt("部品型号:", 7, 0); - disableEdit.add("7,0"); - general.put("jd2_bpxh", new int[] { 7, 2 }); - model.setValueAt("适用型号:", 7, 6); - disableEdit.add("7,6"); - general.put("jd2_syxh", new int[] { 7, 7 }); - model.setValueAt("变更内容", 8, 0); - disableEdit.add("8,0"); - - model.setValueAt("NO", top, 0); - disableEdit.add(top + ",0"); - model.setValueAt("名称", top, 1); - disableEdit.add(top + ",1"); - model.setValueAt("变更前", top, 2); - disableEdit.add(top + ",2"); - model.setValueAt("变更后", top, 5); - disableEdit.add(top + ",5"); - model.setValueAt("Risk", top, 8); - disableEdit.add(top + ",8"); - model.setValueAt("测试计划", top, 9); - disableEdit.add(top + ",9"); - model.setValueAt("备注", top, 10); - disableEdit.add(top + ",10"); - - model.setValueAt("预计完成日期:", bottom, 0); - disableEdit.add(bottom + ",0"); - general.put("jd2_yjwcrq", new int[] { bottom, 2 }); - model.setValueAt("编制签名:", bottom + 1, 0); - disableEdit.add(bottom + 1 + ",0"); - model.setValueAt("批准签名:", bottom + 2, 0); - disableEdit.add(bottom + 3 + ",0"); - general.put("jd2_bz", new int[] { bottom + 2, 2 }); - general.put("jd2_pz", new int[] { bottom + 3, 2 }); - model.setValueAt("编制时间:", bottom + 2, 5); - disableEdit.add(bottom + 2 + ",5"); - model.setValueAt("批准时间:", bottom + 3, 5); - disableEdit.add(bottom + 3 + ",5"); - general.put("jd2_bzrq", new int[] { bottom + 2, 8 }); - general.put("jd2_pzrq", new int[] { bottom + 3, 8 }); - model.combine(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 }); - model.combine(new int[] { 0, 1, 2 }, new int[] { 3, 4, 5, 6, 7 }); - model.combine(new int[] { 0 }, new int[] { 9, 10 }); - model.combine(new int[] { 1 }, new int[] { 9, 10 }); - model.combine(new int[] { 2 }, new int[] { 8, 9, 10 }); - model.combine(new int[] { 3 }, new int[] { 0, 1, 2 }); - model.combine(new int[] { 3 }, new int[] { 3, 4, 5 }); - model.combine(new int[] { 3 }, new int[] { 6, 7 }); - model.combine(new int[] { 3 }, new int[] { 8, 9, 10 }); - model.combine(new int[] { 4 }, new int[] { 0, 1, 2 }); - model.combine(new int[] { 4 }, new int[] { 3, 4, 5 }); - model.combine(new int[] { 4 }, new int[] { 6, 7 }); - model.combine(new int[] { 4 }, new int[] { 8, 9, 10 }); - model.combine(new int[] { 5 }, new int[] { 0, 1 }); - model.combine(new int[] { 5 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - model.combine(new int[] { 6 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - model.combine(new int[] { 7 }, new int[] { 0, 1 }); - model.combine(new int[] { 7 }, new int[] { 2, 3, 4, 5 }); - model.combine(new int[] { 7 }, new int[] { 7, 8, 9, 10 }); - model.combine(new int[] { 8, 9 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - model.combine(new int[] { top }, new int[] { 2, 3, 4 }); - model.combine(new int[] { top }, new int[] { 5, 6, 7 }); - for (int i = top + 1; i <= bottom; i++) { - model.combine(new int[] { i }, new int[] { 2, 3, 4 }); - model.combine(new int[] { i }, new int[] { 5, 6, 7 }); - model.setValueAt(i - top, i, 0); - disableEdit.add(i + ",0"); - } - model.combine(new int[] { bottom + 1 }, new int[] { 0, 1 }); - model.combine(new int[] { bottom + 1 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 }); - model.combine(new int[] { bottom + 2 }, new int[] { 2, 3, 4 }); - model.combine(new int[] { bottom + 2 }, new int[] { 5, 6, 7 }); - model.combine(new int[] { bottom + 2 }, new int[] { 8, 9, 10 }); - model.combine(new int[] { bottom + 3 }, new int[] { 0, 1 }); - model.combine(new int[] { bottom + 3 }, new int[] { 2, 3, 4 }); - model.combine(new int[] { bottom + 3 }, new int[] { 5, 6, 7 }); - model.combine(new int[] { bottom + 3 }, new int[] { 8, 9, 10 }); + initModel(); table = new CTable(model) { @Override @@ -235,6 +136,7 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { } }; tcr1.setHorizontalAlignment(SwingConstants.CENTER); + table.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN); table.setDefaultRenderer(Object.class, tcr1); table.getColumnModel().getColumn(2).setCellEditor(new MyCellEditor3(new JTextField())); table.addMouseListener(rightClick()); @@ -272,14 +174,125 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { if (top + i + 1 > bottom) { this.addRow(); } - model.setValueAt(rows[i], top + i + 1, i > 2 ? i > 3 ? i + 4 : i + 2 : i); + for (int ii = 0; ii < rows[0].length; ii++) { + model.setValueAt(rows[i][ii], top + i + 1, ii > 2 ? ii > 3 ? ii + 4 : ii + 2 : ii); + } } - root.add(table, BorderLayout.CENTER); + ScrollPane pane = new ScrollPane(); + pane.add(table); + root.add(pane); this.add(menu); this.add(root); } + private void initModel() { + disableEdit = new ArrayList<>();// 不允许编辑 + general = new HashMap();// 要填写的一般属性 + model.setValueAt("吉德", 0, 0); + disableEdit.add("0,0"); + model.setValueAt("试验委托书", 0, 3); + disableEdit.add("0,3"); + model.setValueAt("表号", 0, 8); + disableEdit.add("0,8"); + model.setValueAt("生效期", 1, 8); + disableEdit.add("1,8"); + general.put("jd2_bh", new int[] { 0, 9 }); + general.put("jd2_sxq", new int[] { 1, 9 }); + model.setValueAt("委托项目:", 3, 0); + disableEdit.add("3,0"); + model.setValueAt("委托部门:", 4, 0); + disableEdit.add("4,0"); + general.put("jd2_wtxm", new int[] { 3, 3 }); + general.put("jd2_wtbm", new int[] { 4, 3 }); + model.setValueAt("供货厂家:", 3, 6); + disableEdit.add("3,6"); + model.setValueAt("接受部门:", 4, 6); + disableEdit.add("4,6"); + general.put("jd2_ghcj", new int[] { 3, 8 }); + general.put("jd2_jsbm", new int[] { 4, 8 }); + model.setValueAt("变更区分:", 5, 0); + bgqf = new JCheckPanel(new String[] { "复制模", "降本", "二元化", "改善优化", "新规部品" }); + model.setValueAt(bgqf, 5, 2); + model.setValueAt("部品型号:", 7, 0); + disableEdit.add("7,0"); + general.put("jd2_bpxh", new int[] { 7, 2 }); + model.setValueAt("适用型号:", 7, 6); + disableEdit.add("7,6"); + general.put("jd2_syxh", new int[] { 7, 7 }); + model.setValueAt("变更内容", 8, 0); + disableEdit.add("8,0"); + + model.setValueAt("NO", top, 0); + disableEdit.add(top + ",0"); + model.setValueAt("名称", top, 1); + disableEdit.add(top + ",1"); + model.setValueAt("变更前", top, 2); + disableEdit.add(top + ",2"); + model.setValueAt("变更后", top, 5); + disableEdit.add(top + ",5"); + model.setValueAt("Risk", top, 8); + disableEdit.add(top + ",8"); + model.setValueAt("测试计划", top, 9); + disableEdit.add(top + ",9"); + model.setValueAt("备注", top, 10); + disableEdit.add(top + ",10"); + + model.setValueAt("预计完成日期:", bottom + 1, 0); + disableEdit.add(bottom + 1 + ",0"); + general.put("jd2_yjwcrq", new int[] { bottom + 1, 2 }); + model.setValueAt("编制签名:", bottom + 2, 0); + disableEdit.add(bottom + 2 + ",0"); + model.setValueAt("批准签名:", bottom + 3, 0); + disableEdit.add(bottom + 3 + ",0"); + general.put("jd2_bz", new int[] { bottom + 2, 2 }); + general.put("jd2_pz", new int[] { bottom + 3, 2 }); + model.setValueAt("编制时间:", bottom + 2, 5); + disableEdit.add(bottom + 2 + ",5"); + model.setValueAt("批准时间:", bottom + 3, 5); + disableEdit.add(bottom + 3 + ",5"); + general.put("jd2_bzrq", new int[] { bottom + 2, 8 }); + general.put("jd2_pzrq", new int[] { bottom + 3, 8 }); + model.combine(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 }); + model.combine(new int[] { 0, 1, 2 }, new int[] { 3, 4, 5, 6, 7 }); + model.combine(new int[] { 0 }, new int[] { 9, 10 }); + model.combine(new int[] { 1 }, new int[] { 9, 10 }); + model.combine(new int[] { 2 }, new int[] { 8, 9, 10 }); + model.combine(new int[] { 3 }, new int[] { 0, 1, 2 }); + model.combine(new int[] { 3 }, new int[] { 3, 4, 5 }); + model.combine(new int[] { 3 }, new int[] { 6, 7 }); + model.combine(new int[] { 3 }, new int[] { 8, 9, 10 }); + model.combine(new int[] { 4 }, new int[] { 0, 1, 2 }); + model.combine(new int[] { 4 }, new int[] { 3, 4, 5 }); + model.combine(new int[] { 4 }, new int[] { 6, 7 }); + model.combine(new int[] { 4 }, new int[] { 8, 9, 10 }); + model.combine(new int[] { 5 }, new int[] { 0, 1 }); + model.combine(new int[] { 5 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model.combine(new int[] { 6 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model.combine(new int[] { 7 }, new int[] { 0, 1 }); + model.combine(new int[] { 7 }, new int[] { 2, 3, 4, 5 }); + model.combine(new int[] { 7 }, new int[] { 7, 8, 9, 10 }); + model.combine(new int[] { 8, 9 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model.combine(new int[] { top }, new int[] { 2, 3, 4 }); + model.combine(new int[] { top }, new int[] { 5, 6, 7 }); + for (int i = top + 1; i <= bottom; i++) { + model.combine(new int[] { i }, new int[] { 2, 3, 4 }); + model.combine(new int[] { i }, new int[] { 5, 6, 7 }); + model.setValueAt(i - top, i, 0); + disableEdit.add(i + ",0"); + } + model.combine(new int[] { bottom + 1 }, new int[] { 0, 1 }); + model.combine(new int[] { bottom + 1 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 }); + model.combine(new int[] { bottom + 2 }, new int[] { 2, 3, 4 }); + model.combine(new int[] { bottom + 2 }, new int[] { 5, 6, 7 }); + model.combine(new int[] { bottom + 2 }, new int[] { 8, 9, 10 }); + model.combine(new int[] { bottom + 3 }, new int[] { 0, 1 }); + model.combine(new int[] { bottom + 3 }, new int[] { 2, 3, 4 }); + model.combine(new int[] { bottom + 3 }, new int[] { 5, 6, 7 }); + model.combine(new int[] { bottom + 3 }, new int[] { 8, 9, 10 }); + } + @Override public void saveRendering() { // TODO Auto-generated method stub @@ -318,7 +331,7 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { if (prop.containsKey("jd2_sywts")) { List data = new ArrayList(); int num = 0; - while (model.getValueAt(top + 2 + num, 1) != null && !"".equals(model.getValueAt(top + 2 + num, 1))) { + while (model.getValueAt(top + 1 + num, 1) != null && !"".equals(model.getValueAt(top + 1 + num, 1))) { String[] row = new String[7]; for (int ii = 0; ii < row.length; ii++) { Object object = model.getValueAt(top + 1 + num, ii > 2 ? ii > 3 ? ii + 4 : ii + 2 : ii); @@ -350,7 +363,7 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table.getSelectedRow() != -1) { int row = table.getSelectedRow(); - boolean flag = (row >= top && row <= bottom); + boolean flag = (row > top && row <= bottom); addR.setEnabled(flag); delR.setEnabled(flag); test.setEnabled(flag); @@ -368,9 +381,14 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { // TODO Auto-generated method stub int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); model.insertRow(++bottom); - model.setValueAt(num + 1, bottom, 0); - model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); - model.combine(new int[] { bottom }, new int[] { 5, 6, 7 }); +// model.setValueAt(num + 1, bottom, 0); +// model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); +// model.combine(new int[] { bottom }, new int[] { 5, 6, 7 }); + + System.out.println(bottom); + initModel(); + table.revalidate(); + table.repaint(); } }; } @@ -382,7 +400,7 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub int row = table.getSelectedRow(); - int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); + int num = Integer.parseInt(model.getValueAt(row, 0).toString()); model.removeRow(row); bottom--; if (row <= bottom) { @@ -390,6 +408,10 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { model.setValueAt(num + i - row, i, 0); } } + System.out.println(bottom); + initModel(); + table.revalidate(); + table.repaint(); } }; @@ -401,11 +423,17 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub - int row = table.getSelectedRow(); - ComponentTestFrame.getInstance(rows[row - top - 1]); + ComponentTestFrame.getInstance(form, $this); } }; } + @Override + public void execute(String itemId) { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + model.setValueAt(itemId, row, 9); + } + } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/MyCallBack.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/MyCallBack.java new file mode 100644 index 0000000..72f83b0 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/MyCallBack.java @@ -0,0 +1,6 @@ +package com.connor.jd.plm.form; + +public interface MyCallBack { + + public void execute(String itemId); +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index 5edb55b..9c62a68 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -132,265 +132,10 @@ public class SampleConfirmationForm extends AbstractRendering { // 设置属性 model = new CTMap(47, 20); bottom = model.getRowCount() - end; - disableEdit = new ArrayList<>();// 不允许编辑 - general = new HashMap();// 要填写的一般属性 - pic = new HashMap();// 图片 - model.setValueAt("样品确认单", 0, 0); - disableEdit.add("0,0"); - model.setValueAt("提交", 0, 14); - disableEdit.add("0,14"); - model.setValueAt("审核", 0, 16); - disableEdit.add("0,16"); - model.setValueAt("批准", 0, 18); - disableEdit.add("0,18"); - model.setValueAt("部门", 2, 0); - disableEdit.add("2,0"); - model.setValueAt("滚筒研发", 2, 2); - disableEdit.add("2,2"); - general.put("jd2_bz", new int[] { 2, 14 }); - disableEdit.add("2,14"); - general.put("jd2_sh", new int[] { 2, 16 }); - disableEdit.add("2,16"); - general.put("jd2_pz", new int[] { 2, 18 }); - disableEdit.add("2,18"); - model.setValueAt("创建日期", 4, 0); - disableEdit.add("4,0"); - general.put("creation_date", new int[] { 4, 2 }); - disableEdit.add("4,2"); - model.setValueAt("创建人", 4, 5); - disableEdit.add("4,5"); - general.put("owning_user", new int[] { 4, 7 }); - disableEdit.add("4,7"); - general.put("jd2_bzrq", new int[] { 4, 14 }); - disableEdit.add("4,14"); - general.put("jd2_shrq", new int[] { 4, 16 }); - disableEdit.add("4,16"); - general.put("jd2_pzrq", new int[] { 4, 18 }); - disableEdit.add("4,18"); - model.setValueAt("零件名", 6, 0); - disableEdit.add("6,0"); - general.put("jd2_ljm", new int[] { 6, 2 }); - general.put("jd2_ljywm", new int[] { 6, 5 }); - model.setValueAt("型号", 6, 8); - disableEdit.add("6,8"); - general.put("jd2_xh", new int[] { 6, 10 }); - model.setValueAt("分类", 6, 14); - disableEdit.add("6,14"); - general.put("jd2_fl", new int[] { 6, 17 }); - model.setValueAt("物料编码", 7, 0); - disableEdit.add("7,0"); - general.put("jd2_wlbm", new int[] { 7, 2 }); - model.setValueAt("送样数量", 7, 8); - disableEdit.add("7,8"); - yssl = new JRadioPanel(new String[] { "3", "5", "10", "30" }); - model.setValueAt(yssl, 7, 10); - model.setValueAt("状态", 7, 14); - disableEdit.add("7,14"); - general.put("jd2_zt", new int[] { 7, 17 }); - model.setValueAt("部品等级", 8, 0); - disableEdit.add("8,0"); - general.put("jd2_bpdj", new int[] { 8, 2 }); - model.setValueAt("参考物料", 8, 8); - disableEdit.add("8,8"); - model.setValueAt("jd2_ckwl", 8, 10); - general.put("jd2_ckwl", new int[] { 8, 10 }); - model.setValueAt("图号", 9, 0); - disableEdit.add("9,0"); - general.put("jd2_th", new int[] { 9, 2 }); - model.setValueAt("规格", 10, 0); - disableEdit.add("10,0"); - general.put("jd2_gg", new int[] { 10, 2 }); - model.setValueAt("供应商", 11, 0); - disableEdit.add("11,0"); - general.put("jd2_gys", new int[] { 11, 2 }); - model.setValueAt("送样原因", 9, 8); - disableEdit.add("9,8"); - general.put("jd2_syyy", new int[] { 9, 10 }); - model.setValueAt("目前阶段", 12, 0); - disableEdit.add("12,0"); - mqjd = new JCheckPanel(new String[] { "DV", "PV", "PR", "SR", "现场测试", "MP" }); - model.setValueAt(mqjd, 12, 2); - - model.setValueAt("No", top, 0); - disableEdit.add(top + ",0"); - model.setValueAt("尺寸验证", top, 1); - disableEdit.add(top + ",1"); - model.setValueAt("检查数据(#样品号/腔体号)", top, 7); - disableEdit.add(top + ",7"); - model.setValueAt("结果", top, 19); - disableEdit.add(top + ",19"); - model.setValueAt("规格", top + 1, 1); - disableEdit.add(top + 1 + ",1"); - model.setValueAt("公差", top + 1, 5); - disableEdit.add(top + 1 + ",5"); - for (int i = 1; i < 11; i++) { - model.setValueAt("#" + i, top + 1, i + 6); - disableEdit.add(top + 1 + "," + (i + 6)); - } - model.setValueAt("Min", top + 1, 17); - disableEdit.add(top + 1 + ",17"); - model.setValueAt("Max", top + 1, 18); - disableEdit.add(top + 1 + ",18"); - - for (int i = top + 2; i <= bottom; i++) { - model.setValueAt(i - 1 - top, i, 0); - disableEdit.add(i + ",0"); - model.combine(new int[] { i }, new int[] { 2, 3, 4 }); - } - - model.setValueAt("被标记为“CTQ”的尺寸非常重要", bottom + 1, 0);// 从“底部”开始 - disableEdit.add(bottom + 1 + ",0"); - model.setValueAt("SPL Picture", bottom + 2, 0); - pic.put("jd2_ypzp", new int[] { bottom + 3, 0 }); - disableEdit.add(bottom + 2 + ",0"); - model.setValueAt("注塑条件", bottom + 2, 4); - disableEdit.add(bottom + 2 + ",4"); - model.setValueAt("C/Time", bottom + 2, 5); - disableEdit.add(bottom + 2 + ",5"); - model.setValueAt("注塑", bottom + 2, 6); - disableEdit.add(bottom + 2 + ",6"); - model.setValueAt("冷却", bottom + 2, 7); - disableEdit.add(bottom + 2 + ",7"); - model.setValueAt("包装", bottom + 2, 8); - disableEdit.add(bottom + 2 + ",8"); - model.setValueAt("供方自检报告", bottom + 2, 9); - disableEdit.add(bottom + 2 + ",9"); - model.setValueAt("供方作业指导书", bottom + 2, 12); - disableEdit.add(bottom + 2 + ",12"); - model.setValueAt("供方QC工程图", bottom + 2, 15); - disableEdit.add(bottom + 2 + ",15"); - model.setValueAt("物料包装及标签", bottom + 2, 18); - disableEdit.add(bottom + 2 + ",18"); - general.put("jd2_Ctime", new int[] { bottom + 3, 5 }); - general.put("jd2_zs", new int[] { bottom + 3, 6 }); - general.put("jd2_lq", new int[] { bottom + 3, 7 }); - general.put("jd2_baoz", new int[] { bottom + 3, 8 }); - pic.put("jd2_gfzjbg", new int[] { bottom + 3, 9 }); - pic.put("jd2_gfzyzds", new int[] { bottom + 3, 12 }); - pic.put("jd2_gfqcgct", new int[] { bottom + 3, 15 }); - pic.put("jd2_wlbzjbq", new int[] { bottom + 3, 18 }); - model.setValueAt("Shot/24Hr", bottom + 4, 5); - disableEdit.add(bottom + 4 + ",5"); - model.setValueAt("吨", bottom + 4, 6); - disableEdit.add(bottom + 4 + ",6"); - general.put("jd2_Shot24Hr", new int[] { bottom + 5, 5 }); - general.put("jd2_d", new int[] { bottom + 5, 6 }); - model.setValueAt("3D重量", bottom + 6, 4); - disableEdit.add(bottom + 6 + ",4"); - model.setValueAt("jd2_3Dzl", bottom + 6, 5); - general.put("jd2_3Dzl", new int[] { bottom + 6, 5 }); - model.setValueAt("注塑工艺条件", bottom + 6, 7); - disableEdit.add(bottom + 6 + ",7"); - model.setValueAt("IQC首检报告", bottom + 6, 9); - disableEdit.add(bottom + 6 + ",9"); - model.setValueAt("测试报告", bottom + 6, 12); - disableEdit.add(bottom + 6 + ",12"); - model.setValueAt("材质报告", bottom + 6, 15); - disableEdit.add(bottom + 6 + ",15"); - model.setValueAt("模具标识", bottom + 6, 18); - disableEdit.add(bottom + 6 + ",18"); - pic.put("jd2_zsgytj", new int[] { bottom + 7, 7 }); - pic.put("jd2_icqsjbg", new int[] { bottom + 7, 9 }); - pic.put("jd2_csbg", new int[] { bottom + 7, 12 }); - pic.put("jd2_czbg", new int[] { bottom + 7, 15 }); - pic.put("jd2_mjbs", new int[] { bottom + 7, 18 }); - model.setValueAt("实测重量", bottom + 8, 4); - disableEdit.add(bottom + 8 + ",4"); - general.put("jd2_sczl", new int[] { bottom + 8, 5 }); - model.setValueAt("IQC作业指导书", bottom + 10, 4); - disableEdit.add(bottom + 10 + ",4"); - pic.put("jd2_icqjyzds", new int[] { bottom + 11, 4 }); - model.setValueAt("决定", bottom + 12, 12); - disableEdit.add(bottom + 12 + ",12"); - general.put("jd2_jued", new int[] { bottom + 12, 15 }); - pic.put("jd2_qtbg", new int[] { bottom + 10, 7 }); // 合并单元格 - model.combine(new int[] { 0, 1 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); - model.combine(new int[] { 0, 1 }, new int[] { 14, 15 }); - model.combine(new int[] { 0, 1 }, new int[] { 16, 17 }); - model.combine(new int[] { 0, 1 }, new int[] { 18, 19 }); - model.combine(new int[] { 2, 3 }, new int[] { 0, 1 }); - model.combine(new int[] { 2, 3 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); - model.combine(new int[] { 2, 3 }, new int[] { 14, 15 }); - model.combine(new int[] { 2, 3 }, new int[] { 16, 17 }); - model.combine(new int[] { 2, 3 }, new int[] { 18, 19 }); - model.combine(new int[] { 4, 5 }, new int[] { 0, 1 }); - model.combine(new int[] { 4, 5 }, new int[] { 2, 3, 4 }); - model.combine(new int[] { 4, 5 }, new int[] { 5, 6 }); - model.combine(new int[] { 4, 5 }, new int[] { 7, 8, 9, 10, 11, 12, 13 }); - model.combine(new int[] { 4, 5 }, new int[] { 14, 15 }); - model.combine(new int[] { 4, 5 }, new int[] { 16, 17 }); - model.combine(new int[] { 4, 5 }, new int[] { 18, 19 }); - model.combine(new int[] { 6 }, new int[] { 0, 1 }); - model.combine(new int[] { 6 }, new int[] { 2, 3, 4 }); - model.combine(new int[] { 6 }, new int[] { 5, 6, 7 }); - model.combine(new int[] { 6 }, new int[] { 8, 9 }); - model.combine(new int[] { 6 }, new int[] { 10, 11, 12, 13 }); - model.combine(new int[] { 6 }, new int[] { 14, 15, 16 }); - model.combine(new int[] { 6 }, new int[] { 17, 18, 19 }); - model.combine(new int[] { 7 }, new int[] { 0, 1 }); - model.combine(new int[] { 7 }, new int[] { 2, 3, 4, 5, 6, 7 }); - model.combine(new int[] { 7 }, new int[] { 8, 9 }); - model.combine(new int[] { 7 }, new int[] { 10, 11, 12, 13 }); - model.combine(new int[] { 7 }, new int[] { 14, 15, 16 }); - model.combine(new int[] { 7 }, new int[] { 17, 18, 19 }); - model.combine(new int[] { 8 }, new int[] { 0, 1 }); - model.combine(new int[] { 8 }, new int[] { 2, 3, 4, 5, 6, 7 }); - model.combine(new int[] { 8 }, new int[] { 8, 9 }); - model.combine(new int[] { 8 }, new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); - model.combine(new int[] { 9 }, new int[] { 0, 1 }); - model.combine(new int[] { 9 }, new int[] { 2, 3, 4, 5, 6, 7 }); - model.combine(new int[] { 9, 10, 11 }, new int[] { 8, 9 }); - model.combine(new int[] { 9, 10, 11 }, new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); - model.combine(new int[] { 10 }, new int[] { 0, 1 }); - model.combine(new int[] { 10 }, new int[] { 2, 3, 4, 5, 6, 7 }); - model.combine(new int[] { 11 }, new int[] { 0, 1 }); - model.combine(new int[] { 11 }, new int[] { 2, 3, 4, 5, 6, 7 }); - model.combine(new int[] { 12 }, new int[] { 0, 1 }); - model.combine(new int[] { 12 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); - model.combine(new int[] { top, 1 }, new int[] { 0 }); - model.combine(new int[] { top }, new int[] { 1, 2, 3, 4, 5, 6 }); - model.combine(new int[] { top }, new int[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); - model.combine(new int[] { top, top + 1 }, new int[] { 19 }); - model.combine(new int[] { top + 1 }, new int[] { 1, 2, 3, 4 }); - model.combine(new int[] { top + 1 }, new int[] { 5, 6 }); - model.combine(new int[] { bottom + 1 }, new int[] { 0, 1, 2, 3, 4, 5 }); - model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 }); - model.combine(new int[] { bottom + 2 }, new int[] { 2, 3 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6, bottom + 7, bottom + 8, bottom + 9, - bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 0, 1, 2, 3 }); - model.combine(new int[] { bottom + 2, bottom + 3, bottom + 4, bottom + 5 }, new int[] { 4 }); - model.combine(new int[] { bottom + 2 }, new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 2 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 2 }, new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 2 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 4, bottom + 5 }, new int[] { 7, 8 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 4 }); - model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 4 }); - model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 5 }); - model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 5 }); - model.combine(new int[] { bottom + 6, bottom + 7, bottom + 8, bottom + 9 }, new int[] { 6 }); - model.combine(new int[] { bottom + 6 }, new int[] { 7, 8 }); - model.combine(new int[] { bottom + 6 }, new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 6 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 6 }, new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 6 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 7, 8 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 10 }, new int[] { 4, 5, 6 }); - model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 }, new int[] { 4, 5, 6 }); - model.combine(new int[] { bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 7, 8, 9, 10, 11 }); - model.combine(new int[] { bottom + 10, bottom + 11 }, new int[] { 12, 13, 14, 15, 16, 17, 18, 19 }); - model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 15, 16, 17, 18, 19 }); + + initModel(); table = new CTable(model) { @Override @@ -720,30 +465,292 @@ public class SampleConfirmationForm extends AbstractRendering { menu.add(delR); delR.addActionListener(deleteRow()); - // 检验单右键菜单 - menu2.setVisible(false); - addR2 = new JMenuItem("添加行"); - addR2.setEnabled(false); - menu2.add(addR2); - addR2.addActionListener(addRow2()); - insertR2 = new JMenuItem("插入行"); - insertR2.setEnabled(false); - menu2.add(insertR2); - insertR2.addActionListener(insertRow2()); - delR2 = new JMenuItem("删除行"); - delR2.setEnabled(false); - menu2.add(delR2); - delR2.addActionListener(deleteRow2()); + // 检验单右键菜单 + menu2.setVisible(false); + addR2 = new JMenuItem("添加行"); + addR2.setEnabled(false); + menu2.add(addR2); + addR2.addActionListener(addRow2()); + insertR2 = new JMenuItem("插入行"); + insertR2.setEnabled(false); + menu2.add(insertR2); + insertR2.addActionListener(insertRow2()); + delR2 = new JMenuItem("删除行"); + delR2.setEnabled(false); + menu2.add(delR2); + delR2.addActionListener(deleteRow2()); + + center.add("confirm", confirmScrollPanel); + center.add("examine", examineScrollPanel); + root.add(buttons, BorderLayout.NORTH); + root.add(center, BorderLayout.CENTER); + this.add(menu); + this.add(menu2); + this.add(root, BorderLayout.CENTER); + + cl.show(center, "confirm"); + } + + private void initModel() { + disableEdit = new ArrayList<>();// 不允许编辑 + general = new HashMap();// 要填写的一般属性 + pic = new HashMap();// 图片 + model.setValueAt("样品确认单", 0, 0); + disableEdit.add("0,0"); + model.setValueAt("提交", 0, 14); + disableEdit.add("0,14"); + model.setValueAt("审核", 0, 16); + disableEdit.add("0,16"); + model.setValueAt("批准", 0, 18); + disableEdit.add("0,18"); + model.setValueAt("部门", 2, 0); + disableEdit.add("2,0"); + model.setValueAt("滚筒研发", 2, 2); + disableEdit.add("2,2"); + general.put("jd2_bz", new int[] { 2, 14 }); + disableEdit.add("2,14"); + general.put("jd2_sh", new int[] { 2, 16 }); + disableEdit.add("2,16"); + general.put("jd2_pz", new int[] { 2, 18 }); + disableEdit.add("2,18"); + model.setValueAt("创建日期", 4, 0); + disableEdit.add("4,0"); + general.put("creation_date", new int[] { 4, 2 }); + disableEdit.add("4,2"); + model.setValueAt("创建人", 4, 5); + disableEdit.add("4,5"); + general.put("owning_user", new int[] { 4, 7 }); + disableEdit.add("4,7"); + general.put("jd2_bzrq", new int[] { 4, 14 }); + disableEdit.add("4,14"); + general.put("jd2_shrq", new int[] { 4, 16 }); + disableEdit.add("4,16"); + general.put("jd2_pzrq", new int[] { 4, 18 }); + disableEdit.add("4,18"); + model.setValueAt("零件名", 6, 0); + disableEdit.add("6,0"); + general.put("jd2_ljm", new int[] { 6, 2 }); + general.put("jd2_ljywm", new int[] { 6, 5 }); + model.setValueAt("型号", 6, 8); + disableEdit.add("6,8"); + general.put("jd2_xh", new int[] { 6, 10 }); + model.setValueAt("分类", 6, 14); + disableEdit.add("6,14"); + general.put("jd2_fl", new int[] { 6, 17 }); + model.setValueAt("物料编码", 7, 0); + disableEdit.add("7,0"); + general.put("jd2_wlbm", new int[] { 7, 2 }); + model.setValueAt("送样数量", 7, 8); + disableEdit.add("7,8"); + yssl = new JRadioPanel(new String[] { "3", "5", "10", "30" }); + model.setValueAt(yssl, 7, 10); + model.setValueAt("状态", 7, 14); + disableEdit.add("7,14"); + general.put("jd2_zt", new int[] { 7, 17 }); + model.setValueAt("部品等级", 8, 0); + disableEdit.add("8,0"); + general.put("jd2_bpdj", new int[] { 8, 2 }); + model.setValueAt("参考物料", 8, 8); + disableEdit.add("8,8"); + model.setValueAt("jd2_ckwl", 8, 10); + general.put("jd2_ckwl", new int[] { 8, 10 }); + model.setValueAt("图号", 9, 0); + disableEdit.add("9,0"); + general.put("jd2_th", new int[] { 9, 2 }); + model.setValueAt("规格", 10, 0); + disableEdit.add("10,0"); + general.put("jd2_gg", new int[] { 10, 2 }); + model.setValueAt("供应商", 11, 0); + disableEdit.add("11,0"); + general.put("jd2_gys", new int[] { 11, 2 }); + model.setValueAt("送样原因", 9, 8); + disableEdit.add("9,8"); + general.put("jd2_syyy", new int[] { 9, 10 }); + model.setValueAt("目前阶段", 12, 0); + disableEdit.add("12,0"); + mqjd = new JCheckPanel(new String[] { "DV", "PV", "PR", "SR", "现场测试", "MP" }); + model.setValueAt(mqjd, 12, 2); + + model.setValueAt("No", top, 0); + disableEdit.add(top + ",0"); + model.setValueAt("尺寸验证", top, 1); + disableEdit.add(top + ",1"); + model.setValueAt("检查数据(#样品号/腔体号)", top, 7); + disableEdit.add(top + ",7"); + model.setValueAt("结果", top, 19); + disableEdit.add(top + ",19"); + model.setValueAt("规格", top + 1, 1); + disableEdit.add(top + 1 + ",1"); + model.setValueAt("公差", top + 1, 5); + disableEdit.add(top + 1 + ",5"); + for (int i = 1; i < 11; i++) { + model.setValueAt("#" + i, top + 1, i + 6); + disableEdit.add(top + 1 + "," + (i + 6)); + } + model.setValueAt("Min", top + 1, 17); + disableEdit.add(top + 1 + ",17"); + model.setValueAt("Max", top + 1, 18); + disableEdit.add(top + 1 + ",18"); - center.add("confirm", confirmScrollPanel); - center.add("examine", examineScrollPanel); - root.add(buttons, BorderLayout.NORTH); - root.add(center, BorderLayout.CENTER); - this.add(menu); - this.add(menu2); - this.add(root, BorderLayout.CENTER); + for (int i = top + 2; i <= bottom; i++) { + model.setValueAt(i - 1 - top, i, 0); + disableEdit.add(i + ",0"); + } - cl.show(center, "confirm"); + model.setValueAt("被标记为“CTQ”的尺寸非常重要", bottom + 1, 0);// 从“底部”开始 + disableEdit.add(bottom + 1 + ",0"); + model.setValueAt("SPL Picture", bottom + 2, 0); + pic.put("jd2_ypzp", new int[] { bottom + 3, 0 }); + disableEdit.add(bottom + 2 + ",0"); + model.setValueAt("注塑条件", bottom + 2, 4); + disableEdit.add(bottom + 2 + ",4"); + model.setValueAt("C/Time", bottom + 2, 5); + disableEdit.add(bottom + 2 + ",5"); + model.setValueAt("注塑", bottom + 2, 6); + disableEdit.add(bottom + 2 + ",6"); + model.setValueAt("冷却", bottom + 2, 7); + disableEdit.add(bottom + 2 + ",7"); + model.setValueAt("包装", bottom + 2, 8); + disableEdit.add(bottom + 2 + ",8"); + model.setValueAt("供方自检报告", bottom + 2, 9); + disableEdit.add(bottom + 2 + ",9"); + model.setValueAt("供方作业指导书", bottom + 2, 12); + disableEdit.add(bottom + 2 + ",12"); + model.setValueAt("供方QC工程图", bottom + 2, 15); + disableEdit.add(bottom + 2 + ",15"); + model.setValueAt("物料包装及标签", bottom + 2, 18); + disableEdit.add(bottom + 2 + ",18"); + general.put("jd2_Ctime", new int[] { bottom + 3, 5 }); + general.put("jd2_zs", new int[] { bottom + 3, 6 }); + general.put("jd2_lq", new int[] { bottom + 3, 7 }); + general.put("jd2_baoz", new int[] { bottom + 3, 8 }); + pic.put("jd2_gfzjbg", new int[] { bottom + 3, 9 }); + pic.put("jd2_gfzyzds", new int[] { bottom + 3, 12 }); + pic.put("jd2_gfqcgct", new int[] { bottom + 3, 15 }); + pic.put("jd2_wlbzjbq", new int[] { bottom + 3, 18 }); + model.setValueAt("Shot/24Hr", bottom + 4, 5); + disableEdit.add(bottom + 4 + ",5"); + model.setValueAt("吨", bottom + 4, 6); + disableEdit.add(bottom + 4 + ",6"); + general.put("jd2_Shot24Hr", new int[] { bottom + 5, 5 }); + general.put("jd2_d", new int[] { bottom + 5, 6 }); + model.setValueAt("3D重量", bottom + 6, 4); + disableEdit.add(bottom + 6 + ",4"); + model.setValueAt("jd2_3Dzl", bottom + 6, 5); + general.put("jd2_3Dzl", new int[] { bottom + 6, 5 }); + model.setValueAt("注塑工艺条件", bottom + 6, 7); + disableEdit.add(bottom + 6 + ",7"); + model.setValueAt("IQC首检报告", bottom + 6, 9); + disableEdit.add(bottom + 6 + ",9"); + model.setValueAt("测试报告", bottom + 6, 12); + disableEdit.add(bottom + 6 + ",12"); + model.setValueAt("材质报告", bottom + 6, 15); + disableEdit.add(bottom + 6 + ",15"); + model.setValueAt("模具标识", bottom + 6, 18); + disableEdit.add(bottom + 6 + ",18"); + pic.put("jd2_zsgytj", new int[] { bottom + 7, 7 }); + pic.put("jd2_icqsjbg", new int[] { bottom + 7, 9 }); + pic.put("jd2_csbg", new int[] { bottom + 7, 12 }); + pic.put("jd2_czbg", new int[] { bottom + 7, 15 }); + pic.put("jd2_mjbs", new int[] { bottom + 7, 18 }); + model.setValueAt("实测重量", bottom + 8, 4); + disableEdit.add(bottom + 8 + ",4"); + general.put("jd2_sczl", new int[] { bottom + 8, 5 }); + model.setValueAt("IQC作业指导书", bottom + 10, 4); + disableEdit.add(bottom + 10 + ",4"); + pic.put("jd2_icqjyzds", new int[] { bottom + 11, 4 }); + model.setValueAt("决定", bottom + 12, 12); + disableEdit.add(bottom + 12 + ",12"); + general.put("jd2_jued", new int[] { bottom + 12, 15 }); + pic.put("jd2_qtbg", new int[] { bottom + 10, 7 }); + for (int i = top + 2; i <= bottom; i++) { + model.combine(new int[] { i }, new int[] { 2, 3, 4 }); + } + model.combine(new int[] { 0, 1 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); + model.combine(new int[] { 0, 1 }, new int[] { 14, 15 }); + model.combine(new int[] { 0, 1 }, new int[] { 16, 17 }); + model.combine(new int[] { 0, 1 }, new int[] { 18, 19 }); + model.combine(new int[] { 2, 3 }, new int[] { 0, 1 }); + model.combine(new int[] { 2, 3 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); + model.combine(new int[] { 2, 3 }, new int[] { 14, 15 }); + model.combine(new int[] { 2, 3 }, new int[] { 16, 17 }); + model.combine(new int[] { 2, 3 }, new int[] { 18, 19 }); + model.combine(new int[] { 4, 5 }, new int[] { 0, 1 }); + model.combine(new int[] { 4, 5 }, new int[] { 2, 3, 4 }); + model.combine(new int[] { 4, 5 }, new int[] { 5, 6 }); + model.combine(new int[] { 4, 5 }, new int[] { 7, 8, 9, 10, 11, 12, 13 }); + model.combine(new int[] { 4, 5 }, new int[] { 14, 15 }); + model.combine(new int[] { 4, 5 }, new int[] { 16, 17 }); + model.combine(new int[] { 4, 5 }, new int[] { 18, 19 }); + model.combine(new int[] { 6 }, new int[] { 0, 1 }); + model.combine(new int[] { 6 }, new int[] { 2, 3, 4 }); + model.combine(new int[] { 6 }, new int[] { 5, 6, 7 }); + model.combine(new int[] { 6 }, new int[] { 8, 9 }); + model.combine(new int[] { 6 }, new int[] { 10, 11, 12, 13 }); + model.combine(new int[] { 6 }, new int[] { 14, 15, 16 }); + model.combine(new int[] { 6 }, new int[] { 17, 18, 19 }); + model.combine(new int[] { 7 }, new int[] { 0, 1 }); + model.combine(new int[] { 7 }, new int[] { 2, 3, 4, 5, 6, 7 }); + model.combine(new int[] { 7 }, new int[] { 8, 9 }); + model.combine(new int[] { 7 }, new int[] { 10, 11, 12, 13 }); + model.combine(new int[] { 7 }, new int[] { 14, 15, 16 }); + model.combine(new int[] { 7 }, new int[] { 17, 18, 19 }); + model.combine(new int[] { 8 }, new int[] { 0, 1 }); + model.combine(new int[] { 8 }, new int[] { 2, 3, 4, 5, 6, 7 }); + model.combine(new int[] { 8 }, new int[] { 8, 9 }); + model.combine(new int[] { 8 }, new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); + model.combine(new int[] { 9 }, new int[] { 0, 1 }); + model.combine(new int[] { 9 }, new int[] { 2, 3, 4, 5, 6, 7 }); + model.combine(new int[] { 9, 10, 11 }, new int[] { 8, 9 }); + model.combine(new int[] { 9, 10, 11 }, new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); + model.combine(new int[] { 10 }, new int[] { 0, 1 }); + model.combine(new int[] { 10 }, new int[] { 2, 3, 4, 5, 6, 7 }); + model.combine(new int[] { 11 }, new int[] { 0, 1 }); + model.combine(new int[] { 11 }, new int[] { 2, 3, 4, 5, 6, 7 }); + model.combine(new int[] { 12 }, new int[] { 0, 1 }); + model.combine(new int[] { 12 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); + model.combine(new int[] { top, 1 }, new int[] { 0 }); + model.combine(new int[] { top }, new int[] { 1, 2, 3, 4, 5, 6 }); + model.combine(new int[] { top }, new int[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); + model.combine(new int[] { top, top + 1 }, new int[] { 19 }); + model.combine(new int[] { top + 1 }, new int[] { 1, 2, 3, 4 }); + model.combine(new int[] { top + 1 }, new int[] { 5, 6 }); + model.combine(new int[] { bottom + 1 }, new int[] { 0, 1, 2, 3, 4, 5 }); + model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 }); + model.combine(new int[] { bottom + 2 }, new int[] { 2, 3 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6, bottom + 7, bottom + 8, bottom + 9, + bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 0, 1, 2, 3 }); + model.combine(new int[] { bottom + 2, bottom + 3, bottom + 4, bottom + 5 }, new int[] { 4 }); + model.combine(new int[] { bottom + 2 }, new int[] { 9, 10, 11 }); + model.combine(new int[] { bottom + 2 }, new int[] { 12, 13, 14 }); + model.combine(new int[] { bottom + 2 }, new int[] { 15, 16, 17 }); + model.combine(new int[] { bottom + 2 }, new int[] { 18, 19 }); + model.combine(new int[] { bottom + 4, bottom + 5 }, new int[] { 7, 8 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 9, 10, 11 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 12, 13, 14 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 15, 16, 17 }); + model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 18, 19 }); + model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 4 }); + model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 4 }); + model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 5 }); + model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 5 }); + model.combine(new int[] { bottom + 6, bottom + 7, bottom + 8, bottom + 9 }, new int[] { 6 }); + model.combine(new int[] { bottom + 6 }, new int[] { 7, 8 }); + model.combine(new int[] { bottom + 6 }, new int[] { 9, 10, 11 }); + model.combine(new int[] { bottom + 6 }, new int[] { 12, 13, 14 }); + model.combine(new int[] { bottom + 6 }, new int[] { 15, 16, 17 }); + model.combine(new int[] { bottom + 6 }, new int[] { 18, 19 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 7, 8 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 9, 10, 11 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 12, 13, 14 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 15, 16, 17 }); + model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 18, 19 }); + model.combine(new int[] { bottom + 10 }, new int[] { 4, 5, 6 }); + model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 }, new int[] { 4, 5, 6 }); + model.combine(new int[] { bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 7, 8, 9, 10, 11 }); + model.combine(new int[] { bottom + 10, bottom + 11 }, new int[] { 12, 13, 14, 15, 16, 17, 18, 19 }); + model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 12, 13, 14 }); + model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 15, 16, 17, 18, 19 }); } @Override @@ -925,7 +932,7 @@ public class SampleConfirmationForm extends AbstractRendering { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table.getSelectedRow() != -1) { int row = table.getSelectedRow(); - boolean flag = (row >= top && row <= bottom); + boolean flag = (row >= top + 2 && row <= bottom); addR.setEnabled(flag); insertR.setEnabled(flag); delR.setEnabled(flag); @@ -1044,8 +1051,13 @@ public class SampleConfirmationForm extends AbstractRendering { // TODO Auto-generated method stub int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); model.insertRow(++bottom); - model.setValueAt(num + 1, bottom, 0); - model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); +// model.setValueAt(num + 1, bottom, 0); +// model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); + + System.out.println(bottom); + initModel(); + table.revalidate(); + table.repaint(); } }; @@ -1081,6 +1093,11 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt(num + i - row, i, 0); } model.combine(new int[] { row }, new int[] { 2, 3, 4 }); + + System.out.println(bottom); + initModel(); + table.revalidate(); + table.repaint(); } }; return actionListener; @@ -1120,6 +1137,11 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt(num + i - row, i, 0); } } + + System.out.println(bottom); + initModel(); + table.revalidate(); + table.repaint(); } }; return actionListener; diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor4.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor4.java index 26ddcd7..73c3323 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor4.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor4.java @@ -1,5 +1,37 @@ package com.connor.jd.plm.table; -public class MyCellEditor4 { +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor4 extends DefaultCellEditor { + private int type = -1; + private JCheckBox check; + + public MyCellEditor4(JTextField arg0) { + super(arg0); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof JCheckBox) { + check = (JCheckBox) value; + type = 1; + return check; + } + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + if (type == 1) { + return check; + } + return super.getCellEditorValue(); + } } From 2b8435cb78d0fe746e5812b2efdfecc6b95bca02 Mon Sep 17 00:00:00 2001 From: zouxk Date: Fri, 3 Jan 2020 17:19:35 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=20bug=EF=BC=9A=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=87=BA=E9=94=99=20fix=EF=BC=9A=E6=9F=A5?= =?UTF-8?q?=E5=88=86=E4=B8=BA=E4=B8=A4=E4=B8=AA=E9=83=A8=E5=88=86=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=87=BA=E7=8E=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/ExperimentalPowerOfAttorneyForm.java | 167 +++++-- .../jd/plm/form/SampleConfirmationForm.java | 467 +++++++++++------- .../com/connor/jd/plm/table/MyCellEditor.java | 15 +- .../connor/jd/plm/table/MyCellEditor2.java | 38 ++ 4 files changed, 471 insertions(+), 216 deletions(-) create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java index 12f484e..d065178 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java @@ -40,11 +40,15 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement private CTMap model; private CTable table; private int top = 10; - private int end = 4; + private int end = 1; private int bottom; + private CTMap model2; + private CTable table2; private Map prop; private List disableEdit; + private List disableEdit2; private Map general; + private Map general2; private JCheckPanel bgqf; private JPopupMenu menu = new JPopupMenu(); private JMenuItem addR; @@ -76,6 +80,8 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement model = new CTMap(20, 11); bottom = model.getRowCount() - end; + model2 = new CTMap(3, 11); + initModel(); table = new CTable(model) { @@ -141,6 +147,69 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement table.getColumnModel().getColumn(2).setCellEditor(new MyCellEditor3(new JTextField())); table.addMouseListener(rightClick()); + initModel2(); + + table2 = new CTable(model2) { + @Override + public boolean isCellEditable(int row, int col) { + if (isEditorDisable(disableEdit2, row, col)) { + return false; + } + return true; + } + }; + + table2.setRowHeight(25); + table2.setBorder(BorderFactory.createLineBorder(Color.black)); + table2.getColumnModel().getColumn(0).setPreferredWidth(40); + table2.getColumnModel().getColumn(1).setPreferredWidth(100); + table2.getColumnModel().getColumn(2).setPreferredWidth(80); + table2.getColumnModel().getColumn(3).setPreferredWidth(80); + table2.getColumnModel().getColumn(4).setPreferredWidth(80); + table2.getColumnModel().getColumn(5).setPreferredWidth(80); + table2.getColumnModel().getColumn(6).setPreferredWidth(80); + table2.getColumnModel().getColumn(7).setPreferredWidth(80); + table2.getColumnModel().getColumn(8).setPreferredWidth(80); + table2.getColumnModel().getColumn(9).setPreferredWidth(150); + table2.getColumnModel().getColumn(10).setPreferredWidth(60); + + DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() { + // 重写方法 + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + + if (value instanceof JPanel) { + return (JPanel) value; + } + + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + setBackground(Color.white); +// if(points1.contains(new Point(row,column))) +// setForeground(new Color(0,0,255)); +// else + setForeground(Color.black); + if (isSelected) { + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙 + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + }; + tcr2.setHorizontalAlignment(SwingConstants.CENTER); + table2.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN); + table2.setDefaultRenderer(Object.class, tcr2); + // 右键菜单 menu.setVisible(false); addR = new JMenuItem("新增行"); @@ -164,6 +233,13 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement System.out.println("未找到属性 " + entry.getKey()); } } + for (Entry entry : general2.entrySet()) { + if (prop.containsKey(entry.getKey())) { + model2.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]); + } else { + System.out.println("未找到属性 " + entry.getKey()); + } + } if (prop.containsKey("jd2_bgqf")) { bgqf.setSelected(prop.get("jd2_bgqf")); } else { @@ -181,7 +257,10 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement ScrollPane pane = new ScrollPane(); pane.add(table); - root.add(pane); + ScrollPane pane2 = new ScrollPane(); + pane2.add(table2); + root.add(pane, BorderLayout.CENTER); + root.add(pane2, BorderLayout.SOUTH); this.add(menu); this.add(root); } @@ -238,21 +317,6 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement model.setValueAt("备注", top, 10); disableEdit.add(top + ",10"); - model.setValueAt("预计完成日期:", bottom + 1, 0); - disableEdit.add(bottom + 1 + ",0"); - general.put("jd2_yjwcrq", new int[] { bottom + 1, 2 }); - model.setValueAt("编制签名:", bottom + 2, 0); - disableEdit.add(bottom + 2 + ",0"); - model.setValueAt("批准签名:", bottom + 3, 0); - disableEdit.add(bottom + 3 + ",0"); - general.put("jd2_bz", new int[] { bottom + 2, 2 }); - general.put("jd2_pz", new int[] { bottom + 3, 2 }); - model.setValueAt("编制时间:", bottom + 2, 5); - disableEdit.add(bottom + 2 + ",5"); - model.setValueAt("批准时间:", bottom + 3, 5); - disableEdit.add(bottom + 3 + ",5"); - general.put("jd2_bzrq", new int[] { bottom + 2, 8 }); - general.put("jd2_pzrq", new int[] { bottom + 3, 8 }); model.combine(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 }); model.combine(new int[] { 0, 1, 2 }, new int[] { 3, 4, 5, 6, 7 }); model.combine(new int[] { 0 }, new int[] { 9, 10 }); @@ -281,16 +345,38 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement model.setValueAt(i - top, i, 0); disableEdit.add(i + ",0"); } - model.combine(new int[] { bottom + 1 }, new int[] { 0, 1 }); - model.combine(new int[] { bottom + 1 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); - model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 }); - model.combine(new int[] { bottom + 2 }, new int[] { 2, 3, 4 }); - model.combine(new int[] { bottom + 2 }, new int[] { 5, 6, 7 }); - model.combine(new int[] { bottom + 2 }, new int[] { 8, 9, 10 }); - model.combine(new int[] { bottom + 3 }, new int[] { 0, 1 }); - model.combine(new int[] { bottom + 3 }, new int[] { 2, 3, 4 }); - model.combine(new int[] { bottom + 3 }, new int[] { 5, 6, 7 }); - model.combine(new int[] { bottom + 3 }, new int[] { 8, 9, 10 }); + + } + + private void initModel2() { + disableEdit2 = new ArrayList(); + general2 = new HashMap(); + model2.setValueAt("预计完成日期:", 0, 0); + disableEdit2.add("0,0"); + general2.put("jd2_yjwcrq", new int[] { 0, 2 }); + model2.setValueAt("编制签名:", 1, 0); + disableEdit2.add("1,0"); + model2.setValueAt("批准签名:", 2, 0); + disableEdit2.add("2,0"); + general2.put("jd2_bz", new int[] { 1, 2 }); + general2.put("jd2_pz", new int[] { 2, 2 }); + model2.setValueAt("编制时间:", 1, 5); + disableEdit2.add("1,5"); + model2.setValueAt("批准时间:", 2, 5); + disableEdit2.add("2,5"); + general2.put("jd2_bzrq", new int[] { 1, 8 }); + general2.put("jd2_pzrq", new int[] { 2, 8 }); + + model2.combine(new int[] { 0 }, new int[] { 0, 1 }); + model2.combine(new int[] { 0 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + model2.combine(new int[] { 1 }, new int[] { 0, 1 }); + model2.combine(new int[] { 1 }, new int[] { 2, 3, 4 }); + model2.combine(new int[] { 1 }, new int[] { 5, 6, 7 }); + model2.combine(new int[] { 1 }, new int[] { 8, 9, 10 }); + model2.combine(new int[] { 2 }, new int[] { 0, 1 }); + model2.combine(new int[] { 2 }, new int[] { 2, 3, 4 }); + model2.combine(new int[] { 2 }, new int[] { 5, 6, 7 }); + model2.combine(new int[] { 2 }, new int[] { 8, 9, 10 }); } @Override @@ -312,6 +398,23 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement } } + } + for (Entry entry : general2.entrySet()) { + if (prop.containsKey(entry.getKey())) { + String value = model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString(); + try { + if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues() + .getRealValue(value); + } + System.out.println(entry.getKey() + ":" + value); + form.setProperty(entry.getKey(), value); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } if (prop.containsKey("jd2_bgqf")) { String value = bgqf.getSelectedText() == null ? "" : bgqf.getSelectedText(); @@ -403,11 +506,11 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement int num = Integer.parseInt(model.getValueAt(row, 0).toString()); model.removeRow(row); bottom--; - if (row <= bottom) { - for (int i = row; i <= bottom; i++) { - model.setValueAt(num + i - row, i, 0); - } - } +// if (row <= bottom) { +// for (int i = row; i <= bottom; i++) { +// model.setValueAt(num + i - row, i, 0); +// } +// } System.out.println(bottom); initModel(); table.revalidate(); diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index 9c62a68..387f476 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -40,6 +40,7 @@ import com.connor.jd.plm.table.JCheckPanel; import com.connor.jd.plm.table.JRadioPanel; import com.connor.jd.plm.table.MyCellEditor; import com.connor.jd.plm.table.MyCellEditor1; +import com.connor.jd.plm.table.MyCellEditor2; import com.connor.jd.plm.table.TCTableUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.kernel.AIFComponentContext; @@ -61,21 +62,26 @@ public class SampleConfirmationForm extends AbstractRendering { private JPanel center = null; private JPopupMenu menu = new JPopupMenu(); private JPopupMenu menu2 = new JPopupMenu(); + private JPopupMenu menu3 = new JPopupMenu(); private JPanel confirmPanel = new JPanel(); private JPanel examinePanel = new JPanel(); private CTMap model; private CTMap model2; + private CTMap model3; private CTable table; private CTable table2; + private CTable table3; private int top = 13;// 头部行数 private int bottom;// 中间部分结束 - private int end = 14;// 尾部行数+1 + private int end = 1;// 尾部行数+1 private int top2 = 4; private int bottom2; private int end2 = 16; private Map prop; private Map general; + private Map general3; private List disableEdit; + private List disableEdit3; private Map pic; private List disableEdit2; private JRadioPanel yssl; @@ -128,13 +134,11 @@ public class SampleConfirmationForm extends AbstractRendering { // 确认单 confirmPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1)); confirmPanel.setLayout(new BorderLayout()); + confirmPanel.setPreferredSize(new Dimension(800, 600)); // 设置属性 - model = new CTMap(47, 20); + model = new CTMap(30, 20); bottom = model.getRowCount() - end; - - // 合并单元格 - initModel(); table = new CTable(model) { @@ -166,10 +170,6 @@ public class SampleConfirmationForm extends AbstractRendering { boolean hasFocus, int row, int column) { // TODO Auto-generated method stub - if (value instanceof JLabel) { - return (JLabel) value; - } - if (value instanceof JPanel) { return (JPanel) value; } @@ -202,7 +202,71 @@ public class SampleConfirmationForm extends AbstractRendering { table.getColumnModel().getColumn(i).setCellEditor(new MyCellEditor(new JTextField(), top, end, bottom)); } table.addMouseListener(rightClick()); - confirmPanel.add(table, BorderLayout.CENTER); + + model3 = new CTMap(13, 20); + initModel3(); + table3 = new CTable(model3) { + @Override + public boolean isCellEditable(int row, int col) { + if (isEditorDisable(disableEdit3, row, col)) { + return false; + } + return true; + } + }; + table3.setRowHeight(25); + table3.setBorder(BorderFactory.createLineBorder(Color.black)); + table3.getColumnModel().getColumn(0).setPreferredWidth(40); + table3.getColumnModel().getColumn(1).setPreferredWidth(60); + table3.getColumnModel().getColumn(2).setPreferredWidth(50); + table3.getColumnModel().getColumn(3).setPreferredWidth(50); + table3.getColumnModel().getColumn(4).setPreferredWidth(50); + table3.getColumnModel().getColumn(5).setPreferredWidth(60); + table3.getColumnModel().getColumn(6).setPreferredWidth(60); + for (int i = 7; i < model3.getColumnCount() - 1; i++) { + table3.getColumnModel().getColumn(i).setPreferredWidth(45); + } + table3.getColumnModel().getColumn(model3.getColumnCount() - 1).setPreferredWidth(80); + DefaultTableCellRenderer tcr3 = new DefaultTableCellRenderer() { + // 重写方法 + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + + if (value instanceof JLabel) { + return (JLabel) value; + } + + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + setBackground(Color.white); +// if(points1.contains(new Point(row,column))) +// setForeground(new Color(0,0,255)); +// else + setForeground(Color.black); + if (isSelected) { + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙 + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + + return this; + } + }; + tcr3.setHorizontalAlignment(SwingConstants.CENTER); + table3.setDefaultRenderer(Object.class, tcr3); + for (int i = 0; i < model3.getColumnCount(); i++) { + table3.getColumnModel().getColumn(i).setCellEditor(new MyCellEditor2(new JTextField())); + } + table3.addMouseListener(rightClick3()); // 填写数据 prop = form.getProperties(); @@ -214,6 +278,14 @@ public class SampleConfirmationForm extends AbstractRendering { System.out.println("属性‘" + entry.getKey() + "’未找到"); } } + for (Entry entry : general3.entrySet()) { + if (prop.containsKey(entry.getKey())) { + model3.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]); + } else { + model3.setValueAt("", entry.getValue()[0], entry.getValue()[1]); + System.out.println("属性‘" + entry.getKey() + "’未找到"); + } + } if (prop.containsKey("jd2_yssl")) { yssl.setSelected(prop.get("jd2_yssl")); } else { @@ -244,32 +316,32 @@ public class SampleConfirmationForm extends AbstractRendering { ImageIcon icon = new ImageIcon(img.getPath()); - int[] arr = model.getSpan(row, col); + int[] arr = model3.getSpan(row, col); int width = 0; for (int i = 0; i < arr[1]; i++) { -// width+=table.getColumnModel().getColumn() +// width+=table3.getColumnModel().getColumn() } System.out.println("row:" + arr[0] + ",col:" + arr[1]); icon.setImage(icon.getImage().getScaledInstance( - table.getColumnModel().getColumn(col).getPreferredWidth() * arr[1], - table.getRowHeight() * arr[0], Image.SCALE_SMOOTH)); + table3.getColumnModel().getColumn(col).getPreferredWidth() * arr[1], + table3.getRowHeight() * arr[0], Image.SCALE_SMOOTH)); JLabel label = new JLabel(); label.setLayout(new FlowLayout(FlowLayout.CENTER)); label.setIcon(icon); label.addMouseListener(showImg(img.getPath())); label.setToolTipText(dataset.getUid()); - model.setValueAt(label, row, col); + model3.setValueAt(label, row, col); } else { - model.setValueAt(new JLabel(""), row, col); - System.out.println("未找到uid为\"" + prop.get(entry.getKey()) + "\"的数据集"); + model3.setValueAt(new JLabel(""), row, col); +// System.out.println("未找到uid为\"" + prop.get(entry.getKey()) + "\"的数据集"); } } catch (Exception e) { - model.setValueAt(new JLabel(""), row, col); - e.printStackTrace(System.out); + model3.setValueAt(new JLabel(""), row, col); + e.printStackTrace(); } } else { - model.setValueAt(new JLabel(""), row, col); + model3.setValueAt(new JLabel(""), row, col); System.out.println("属性‘" + entry.getKey() + "’未找到"); } } @@ -292,8 +364,12 @@ public class SampleConfirmationForm extends AbstractRendering { System.out.println("属性‘jd2_ypqrdtable’未找到"); } - ScrollPane confirmScrollPanel = new ScrollPane(); - confirmScrollPanel.add(confirmPanel); + ScrollPane confirmScrollPanel1 = new ScrollPane(); + confirmScrollPanel1.add(table); + ScrollPane confirmScrollPanel3 = new ScrollPane(); + confirmScrollPanel3.add(table3); + confirmPanel.add(confirmScrollPanel1, BorderLayout.CENTER); + confirmPanel.add(confirmScrollPanel3, BorderLayout.SOUTH); // 检查表 examinePanel.setBorder(BorderFactory.createLineBorder(Color.black, 1)); examinePanel.setLayout(new BorderLayout()); @@ -321,21 +397,21 @@ public class SampleConfirmationForm extends AbstractRendering { disableEdit2.add(i + ",0"); model2.combine(new int[] { i }, new int[] { 0, 1 }); } - model2.setValueAt("MIN", bottom + 1, 0); - model2.setValueAt("MAX", bottom + 2, 0); - model2.setValueAt("R", bottom + 3, 0); - model2.setValueAt("标准偏差", bottom + 4, 0); - model2.setValueAt("平均", bottom + 5, 0); - model2.setValueAt("X,BAR-3S", bottom + 6, 0); - model2.setValueAt("X,BAR+3S", bottom + 7, 0); - model2.setValueAt("CP", bottom + 8, 0); - model2.setValueAt("Cpu", bottom + 9, 0); - model2.setValueAt("Cpl", bottom + 10, 0); - model2.setValueAt("CPK", bottom + 11, 0); - model2.setValueAt("SU 预测不良", bottom + 12, 0); - model2.setValueAt("SL 预测不良", bottom + 13, 0); - model2.setValueAt("预测不良(PPM)", bottom + 14, 0); - model2.setValueAt("工程能力意义", bottom + 15, 0); + model2.setValueAt("MIN", bottom2 + 1, 0); + model2.setValueAt("MAX", bottom2 + 2, 0); + model2.setValueAt("R", bottom2 + 3, 0); + model2.setValueAt("标准偏差", bottom2 + 4, 0); + model2.setValueAt("平均", bottom2 + 5, 0); + model2.setValueAt("X,BAR-3S", bottom2 + 6, 0); + model2.setValueAt("X,BAR+3S", bottom2 + 7, 0); + model2.setValueAt("CP", bottom2 + 8, 0); + model2.setValueAt("Cpu", bottom2 + 9, 0); + model2.setValueAt("Cpl", bottom2 + 10, 0); + model2.setValueAt("CPK", bottom2 + 11, 0); + model2.setValueAt("SU 预测不良", bottom2 + 12, 0); + model2.setValueAt("SL 预测不良", bottom2 + 13, 0); + model2.setValueAt("预测不良(PPM)", bottom2 + 14, 0); + model2.setValueAt("工程能力意义", bottom2 + 15, 0); table2 = new CTable(model2) { /** @@ -444,14 +520,6 @@ public class SampleConfirmationForm extends AbstractRendering { // 确认单右键菜单 menu.setVisible(false); - addP = new JMenuItem("添加图片"); - addP.setEnabled(false); - menu.add(addP); - addP.addActionListener(addPic()); - delP = new JMenuItem("删除图片"); - delP.setEnabled(false); - menu.add(delP); - delP.addActionListener(delPic()); addR = new JMenuItem("添加行"); addR.setEnabled(false); menu.add(addR); @@ -465,6 +533,16 @@ public class SampleConfirmationForm extends AbstractRendering { menu.add(delR); delR.addActionListener(deleteRow()); + menu3.setVisible(false); + addP = new JMenuItem("添加图片"); + addP.setEnabled(false); + menu3.add(addP); + addP.addActionListener(addPic()); + delP = new JMenuItem("删除图片"); + delP.setEnabled(false); + menu3.add(delP); + delP.addActionListener(delPic()); + // 检验单右键菜单 menu2.setVisible(false); addR2 = new JMenuItem("添加行"); @@ -480,12 +558,13 @@ public class SampleConfirmationForm extends AbstractRendering { menu2.add(delR2); delR2.addActionListener(deleteRow2()); - center.add("confirm", confirmScrollPanel); + center.add("confirm", confirmPanel); center.add("examine", examineScrollPanel); root.add(buttons, BorderLayout.NORTH); root.add(center, BorderLayout.CENTER); this.add(menu); this.add(menu2); + this.add(menu3); this.add(root, BorderLayout.CENTER); cl.show(center, "confirm"); @@ -494,7 +573,6 @@ public class SampleConfirmationForm extends AbstractRendering { private void initModel() { disableEdit = new ArrayList<>();// 不允许编辑 general = new HashMap();// 要填写的一般属性 - pic = new HashMap();// 图片 model.setValueAt("样品确认单", 0, 0); disableEdit.add("0,0"); model.setValueAt("提交", 0, 14); @@ -595,77 +673,9 @@ public class SampleConfirmationForm extends AbstractRendering { for (int i = top + 2; i <= bottom; i++) { model.setValueAt(i - 1 - top, i, 0); disableEdit.add(i + ",0"); - } - - model.setValueAt("被标记为“CTQ”的尺寸非常重要", bottom + 1, 0);// 从“底部”开始 - disableEdit.add(bottom + 1 + ",0"); - model.setValueAt("SPL Picture", bottom + 2, 0); - pic.put("jd2_ypzp", new int[] { bottom + 3, 0 }); - disableEdit.add(bottom + 2 + ",0"); - model.setValueAt("注塑条件", bottom + 2, 4); - disableEdit.add(bottom + 2 + ",4"); - model.setValueAt("C/Time", bottom + 2, 5); - disableEdit.add(bottom + 2 + ",5"); - model.setValueAt("注塑", bottom + 2, 6); - disableEdit.add(bottom + 2 + ",6"); - model.setValueAt("冷却", bottom + 2, 7); - disableEdit.add(bottom + 2 + ",7"); - model.setValueAt("包装", bottom + 2, 8); - disableEdit.add(bottom + 2 + ",8"); - model.setValueAt("供方自检报告", bottom + 2, 9); - disableEdit.add(bottom + 2 + ",9"); - model.setValueAt("供方作业指导书", bottom + 2, 12); - disableEdit.add(bottom + 2 + ",12"); - model.setValueAt("供方QC工程图", bottom + 2, 15); - disableEdit.add(bottom + 2 + ",15"); - model.setValueAt("物料包装及标签", bottom + 2, 18); - disableEdit.add(bottom + 2 + ",18"); - general.put("jd2_Ctime", new int[] { bottom + 3, 5 }); - general.put("jd2_zs", new int[] { bottom + 3, 6 }); - general.put("jd2_lq", new int[] { bottom + 3, 7 }); - general.put("jd2_baoz", new int[] { bottom + 3, 8 }); - pic.put("jd2_gfzjbg", new int[] { bottom + 3, 9 }); - pic.put("jd2_gfzyzds", new int[] { bottom + 3, 12 }); - pic.put("jd2_gfqcgct", new int[] { bottom + 3, 15 }); - pic.put("jd2_wlbzjbq", new int[] { bottom + 3, 18 }); - model.setValueAt("Shot/24Hr", bottom + 4, 5); - disableEdit.add(bottom + 4 + ",5"); - model.setValueAt("吨", bottom + 4, 6); - disableEdit.add(bottom + 4 + ",6"); - general.put("jd2_Shot24Hr", new int[] { bottom + 5, 5 }); - general.put("jd2_d", new int[] { bottom + 5, 6 }); - model.setValueAt("3D重量", bottom + 6, 4); - disableEdit.add(bottom + 6 + ",4"); - model.setValueAt("jd2_3Dzl", bottom + 6, 5); - general.put("jd2_3Dzl", new int[] { bottom + 6, 5 }); - model.setValueAt("注塑工艺条件", bottom + 6, 7); - disableEdit.add(bottom + 6 + ",7"); - model.setValueAt("IQC首检报告", bottom + 6, 9); - disableEdit.add(bottom + 6 + ",9"); - model.setValueAt("测试报告", bottom + 6, 12); - disableEdit.add(bottom + 6 + ",12"); - model.setValueAt("材质报告", bottom + 6, 15); - disableEdit.add(bottom + 6 + ",15"); - model.setValueAt("模具标识", bottom + 6, 18); - disableEdit.add(bottom + 6 + ",18"); - pic.put("jd2_zsgytj", new int[] { bottom + 7, 7 }); - pic.put("jd2_icqsjbg", new int[] { bottom + 7, 9 }); - pic.put("jd2_csbg", new int[] { bottom + 7, 12 }); - pic.put("jd2_czbg", new int[] { bottom + 7, 15 }); - pic.put("jd2_mjbs", new int[] { bottom + 7, 18 }); - model.setValueAt("实测重量", bottom + 8, 4); - disableEdit.add(bottom + 8 + ",4"); - general.put("jd2_sczl", new int[] { bottom + 8, 5 }); - model.setValueAt("IQC作业指导书", bottom + 10, 4); - disableEdit.add(bottom + 10 + ",4"); - pic.put("jd2_icqjyzds", new int[] { bottom + 11, 4 }); - model.setValueAt("决定", bottom + 12, 12); - disableEdit.add(bottom + 12 + ",12"); - general.put("jd2_jued", new int[] { bottom + 12, 15 }); - pic.put("jd2_qtbg", new int[] { bottom + 10, 7 }); - for (int i = top + 2; i <= bottom; i++) { model.combine(new int[] { i }, new int[] { 2, 3, 4 }); } + model.combine(new int[] { 0, 1 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); model.combine(new int[] { 0, 1 }, new int[] { 14, 15 }); model.combine(new int[] { 0, 1 }, new int[] { 16, 17 }); @@ -715,42 +725,115 @@ public class SampleConfirmationForm extends AbstractRendering { model.combine(new int[] { top, top + 1 }, new int[] { 19 }); model.combine(new int[] { top + 1 }, new int[] { 1, 2, 3, 4 }); model.combine(new int[] { top + 1 }, new int[] { 5, 6 }); - model.combine(new int[] { bottom + 1 }, new int[] { 0, 1, 2, 3, 4, 5 }); - model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 }); - model.combine(new int[] { bottom + 2 }, new int[] { 2, 3 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6, bottom + 7, bottom + 8, bottom + 9, - bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 0, 1, 2, 3 }); - model.combine(new int[] { bottom + 2, bottom + 3, bottom + 4, bottom + 5 }, new int[] { 4 }); - model.combine(new int[] { bottom + 2 }, new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 2 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 2 }, new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 2 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 4, bottom + 5 }, new int[] { 7, 8 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 4 }); - model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 4 }); - model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 5 }); - model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 5 }); - model.combine(new int[] { bottom + 6, bottom + 7, bottom + 8, bottom + 9 }, new int[] { 6 }); - model.combine(new int[] { bottom + 6 }, new int[] { 7, 8 }); - model.combine(new int[] { bottom + 6 }, new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 6 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 6 }, new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 6 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 7, 8 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 9, 10, 11 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 15, 16, 17 }); - model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 18, 19 }); - model.combine(new int[] { bottom + 10 }, new int[] { 4, 5, 6 }); - model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 }, new int[] { 4, 5, 6 }); - model.combine(new int[] { bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 7, 8, 9, 10, 11 }); - model.combine(new int[] { bottom + 10, bottom + 11 }, new int[] { 12, 13, 14, 15, 16, 17, 18, 19 }); - model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 12, 13, 14 }); - model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 15, 16, 17, 18, 19 }); + + } + + private void initModel3() { + disableEdit3 = new ArrayList<>();// 不允许编辑 + general3 = new HashMap();// 要填写的一般属性 + pic = new HashMap();// 图片 + model3.setValueAt("被标记为“CTQ”的尺寸非常重要", 0, 0);// 从“底部”开始 + disableEdit3.add(0 + ",0"); + model3.setValueAt("SPL Picture", 1, 0); + pic.put("jd2_ypzp", new int[] { 2, 0 }); + disableEdit3.add(1 + ",0"); + model3.setValueAt("注塑条件", 1, 4); + disableEdit3.add(1 + ",4"); + model3.setValueAt("C/Time", 1, 5); + disableEdit3.add(1 + ",5"); + model3.setValueAt("注塑", 1, 6); + disableEdit3.add(1 + ",6"); + model3.setValueAt("冷却", 1, 7); + disableEdit3.add(1 + ",7"); + model3.setValueAt("包装", 1, 8); + disableEdit3.add(1 + ",8"); + model3.setValueAt("供方自检报告", 1, 9); + disableEdit3.add(1 + ",9"); + model3.setValueAt("供方作业指导书", 1, 12); + disableEdit3.add(1 + ",12"); + model3.setValueAt("供方QC工程图", 1, 15); + disableEdit3.add(1 + ",15"); + model3.setValueAt("物料包装及标签", 1, 18); + disableEdit3.add(1 + ",18"); + general3.put("jd2_Ctime", new int[] { 2, 5 }); + general3.put("jd2_zs", new int[] { 2, 6 }); + general3.put("jd2_lq", new int[] { 2, 7 }); + general3.put("jd2_baoz", new int[] { 2, 8 }); + pic.put("jd2_gfzjbg", new int[] { 2, 9 }); + pic.put("jd2_gfzyzds", new int[] { 2, 12 }); + pic.put("jd2_gfqcgct", new int[] { 2, 15 }); + pic.put("jd2_wlbzjbq", new int[] { 2, 18 }); + model3.setValueAt("Shot/24Hr", 3, 5); + disableEdit3.add(3 + ",5"); + model3.setValueAt("吨", 3, 6); + disableEdit3.add(3 + ",6"); + general3.put("jd2_Shot24Hr", new int[] { 4, 5 }); + general3.put("jd2_d", new int[] { 4, 6 }); + model3.setValueAt("3D重量", 5, 4); + disableEdit3.add(5 + ",4"); + model3.setValueAt("jd2_3Dzl", 5, 5); + general3.put("jd2_3Dzl", new int[] { 5, 5 }); + model3.setValueAt("注塑工艺条件", 5, 7); + disableEdit3.add(5 + ",7"); + model3.setValueAt("IQC首检报告", 5, 9); + disableEdit3.add(5 + ",9"); + model3.setValueAt("测试报告", 5, 12); + disableEdit3.add(5 + ",12"); + model3.setValueAt("材质报告", 5, 15); + disableEdit3.add(5 + ",15"); + model3.setValueAt("模具标识", 5, 18); + disableEdit3.add(5 + ",18"); + pic.put("jd2_zsgytj", new int[] { 6, 7 }); + pic.put("jd2_icqsjbg", new int[] { 6, 9 }); + pic.put("jd2_csbg", new int[] { 6, 12 }); + pic.put("jd2_czbg", new int[] { 6, 15 }); + pic.put("jd2_mjbs", new int[] { 6, 18 }); + model3.setValueAt("实测重量", 7, 4); + disableEdit3.add(7 + ",4"); + general3.put("jd2_sczl", new int[] { 7, 5 }); + model3.setValueAt("IQC作业指导书", 9, 4); + disableEdit3.add(9 + ",4"); + pic.put("jd2_icqjyzds", new int[] { 10, 4 }); + model3.setValueAt("决定", 11, 12); + disableEdit3.add(11 + ",12"); + general3.put("jd2_jued", new int[] { 11, 15 }); + pic.put("jd2_qtbg", new int[] { 9, 7 }); + + model3.combine(new int[] { 0 }, new int[] { 0, 1, 2, 3, 4, 5 }); + model3.combine(new int[] { 1 }, new int[] { 0, 1 }); + model3.combine(new int[] { 1 }, new int[] { 2, 3 }); + model3.combine(new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, new int[] { 0, 1, 2, 3 }); + model3.combine(new int[] { 1, 2, 3, 4 }, new int[] { 4 }); + model3.combine(new int[] { 1 }, new int[] { 9, 10, 11 }); + model3.combine(new int[] { 1 }, new int[] { 12, 13, 14 }); + model3.combine(new int[] { 1 }, new int[] { 15, 16, 17 }); + model3.combine(new int[] { 1 }, new int[] { 18, 19 }); + model3.combine(new int[] { 3, 4 }, new int[] { 7, 8 }); + model3.combine(new int[] { 2, 3, 4 }, new int[] { 9, 10, 11 }); + model3.combine(new int[] { 2, 3, 4 }, new int[] { 12, 13, 14 }); + model3.combine(new int[] { 2, 3, 4 }, new int[] { 15, 16, 17 }); + model3.combine(new int[] { 2, 3, 4 }, new int[] { 18, 19 }); + model3.combine(new int[] { 5, 6 }, new int[] { 4 }); + model3.combine(new int[] { 7, 8 }, new int[] { 4 }); + model3.combine(new int[] { 5, 6 }, new int[] { 5 }); + model3.combine(new int[] { 7, 8 }, new int[] { 5 }); + model3.combine(new int[] { 5, 6, 7, 8 }, new int[] { 6 }); + model3.combine(new int[] { 5 }, new int[] { 7, 8 }); + model3.combine(new int[] { 5 }, new int[] { 9, 10, 11 }); + model3.combine(new int[] { 5 }, new int[] { 12, 13, 14 }); + model3.combine(new int[] { 5 }, new int[] { 15, 16, 17 }); + model3.combine(new int[] { 5 }, new int[] { 18, 19 }); + model3.combine(new int[] { 6, 7, 8 }, new int[] { 7, 8 }); + model3.combine(new int[] { 6, 7, 8 }, new int[] { 9, 10, 11 }); + model3.combine(new int[] { 6, 7, 8 }, new int[] { 12, 13, 14 }); + model3.combine(new int[] { 6, 7, 8 }, new int[] { 15, 16, 17 }); + model3.combine(new int[] { 6, 7, 8 }, new int[] { 18, 19 }); + model3.combine(new int[] { 9 }, new int[] { 4, 5, 6 }); + model3.combine(new int[] { 10, 11, 12 }, new int[] { 4, 5, 6 }); + model3.combine(new int[] { 9, 10, 11, 12 }, new int[] { 7, 8, 9, 10, 11 }); + model3.combine(new int[] { 9, 10 }, new int[] { 12, 13, 14, 15, 16, 17, 18, 19 }); + model3.combine(new int[] { 11, 12 }, new int[] { 12, 13, 14 }); + model3.combine(new int[] { 11, 12 }, new int[] { 15, 16, 17, 18, 19 }); } @Override @@ -760,9 +843,9 @@ public class SampleConfirmationForm extends AbstractRendering { for (Entry entry : pic.entrySet()) { if (prop.containsKey(entry.getKey())) { System.out.println(entry.getKey()); - label = (JLabel) model.getValueAt(entry.getValue()[0], entry.getValue()[1]); + label = (JLabel) model3.getValueAt(entry.getValue()[0], entry.getValue()[1]); try { - form.setProperty(entry.getKey(), label.getToolTipText()); + form.setProperty(entry.getKey(), label.getToolTipText() == null ? "" : label.getToolTipText()); } catch (TCException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -808,6 +891,22 @@ public class SampleConfirmationForm extends AbstractRendering { e.printStackTrace(); } } + for (Entry entry : general3.entrySet()) { + try { + if (prop.containsKey(entry.getKey())) { + String value = model3.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString(); + if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues() + .getRealValue(value); + } + System.out.println(entry.getKey() + ":" + value); + form.setProperty(entry.getKey(), value); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } // 保存表格 if (prop.containsKey("jd2_ypqrdtable")) { List data = new ArrayList(); @@ -936,8 +1035,6 @@ public class SampleConfirmationForm extends AbstractRendering { addR.setEnabled(flag); insertR.setEnabled(flag); delR.setEnabled(flag); - flag = row > bottom; - addP.setEnabled(flag); menu.show(e.getComponent(), e.getX(), e.getY()); } } @@ -962,6 +1059,30 @@ public class SampleConfirmationForm extends AbstractRendering { return mouseAdapter; } + private MouseAdapter rightClick3() { + MouseAdapter mouseAdapter = new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table3.getSelectedRow() != -1) { + int row = table3.getSelectedRow(); + int col = table3.getSelectedColumn(); + boolean flag = false; + for (Entry entry : pic.entrySet()) { + if (entry.getValue()[0] == row && entry.getValue()[1] == col) { + flag = true; + break; + } + } + addP.setEnabled(flag); + delP.setEnabled(flag); + menu3.show(e.getComponent(), e.getX(), e.getY()); + + } + } + }; + return mouseAdapter; + } + private ActionListener addPic() { ActionListener actionListener = new ActionListener() { @@ -1004,19 +1125,19 @@ public class SampleConfirmationForm extends AbstractRendering { String uid = dataset.getUid(); System.out.println("uid:" + uid); ImageIcon icon = new ImageIcon(file.getPath()); - int row = table.getSelectedRow(); - int col = table.getSelectedColumn(); - int[] arr = model.getSpan(row, col); + int row = table3.getSelectedRow(); + int col = table3.getSelectedColumn(); + int[] arr = model3.getSpan(row, col); System.out.println("row:" + arr[0] + ",col:" + arr[1]); icon.setImage(icon.getImage().getScaledInstance( - table.getColumnModel().getColumn(col).getPreferredWidth() * arr[1], - table.getRowHeight() * arr[0], Image.SCALE_SMOOTH)); + table3.getColumnModel().getColumn(col).getPreferredWidth() * arr[1], + table3.getRowHeight() * arr[0], Image.SCALE_SMOOTH)); JLabel label = new JLabel(); label.setLayout(new FlowLayout(FlowLayout.CENTER)); label.setIcon(icon); label.addMouseListener(showImg(file.getPath())); label.setToolTipText(uid); - model.setValueAt(label, table.getSelectedRow(), table.getSelectedColumn()); + model3.setValueAt(label, table3.getSelectedRow(), table3.getSelectedColumn()); } catch (TCException e1) { // TODO Auto-generated catch block e1.printStackTrace(); @@ -1034,9 +1155,9 @@ public class SampleConfirmationForm extends AbstractRendering { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub - int row = table.getSelectedRow(); - int col = table.getSelectedColumn(); - model.setValueAt(new JLabel(""), row, col); + int row = table3.getSelectedRow(); + int col = table3.getSelectedColumn(); + model3.setValueAt(new JLabel(""), row, col); } }; @@ -1051,11 +1172,11 @@ public class SampleConfirmationForm extends AbstractRendering { // TODO Auto-generated method stub int num = Integer.parseInt(model.getValueAt(bottom, 0).toString()); model.insertRow(++bottom); -// model.setValueAt(num + 1, bottom, 0); -// model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); + model.setValueAt(num + 1, bottom, 0); + model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); - System.out.println(bottom); - initModel(); +// System.out.println(bottom); +// initModel(); table.revalidate(); table.repaint(); @@ -1094,8 +1215,8 @@ public class SampleConfirmationForm extends AbstractRendering { } model.combine(new int[] { row }, new int[] { 2, 3, 4 }); - System.out.println(bottom); - initModel(); +// System.out.println(bottom); +// initModel(); table.revalidate(); table.repaint(); } @@ -1138,8 +1259,8 @@ public class SampleConfirmationForm extends AbstractRendering { } } - System.out.println(bottom); - initModel(); +// System.out.println(bottom); +// initModel(); table.revalidate(); table.repaint(); } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java index 32d4037..badae70 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java @@ -3,7 +3,6 @@ package com.connor.jd.plm.table; import java.awt.Component; import javax.swing.DefaultCellEditor; -import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.JTextField; @@ -12,7 +11,6 @@ import com.teamcenter.rac.util.MessageBox; public class MyCellEditor extends DefaultCellEditor { private JRadioPanel radio = null; private JCheckPanel check = null; - private JLabel img = null; private int type = -1; private int row; private int col; @@ -44,10 +42,6 @@ public class MyCellEditor extends DefaultCellEditor { check = (JCheckPanel) value; type = 2; return check; - } else if (value instanceof JLabel) { - img = (JLabel) value; - type = 3; - return img; } this.row = row; this.col = column; @@ -59,14 +53,13 @@ public class MyCellEditor extends DefaultCellEditor { @Override public Object getCellEditorValue() { - switch (type) { - case 1: + if (type == 1) { return radio; - case 2: + } + if (type == 2) { return check; - case 3: - return img; } + Object obj = super.getCellEditorValue(); if (obj != null && !"".equals(obj.toString().trim()) && row >= top && row <= bottom && col >= 7 && col < table.getColumnCount() - 3) { diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java new file mode 100644 index 0000000..c4774b3 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java @@ -0,0 +1,38 @@ +package com.connor.jd.plm.table; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor2 extends DefaultCellEditor { + private JLabel img = null; + private int type = -1; + + public MyCellEditor2(JTextField var1) { + super(var1); + // TODO Auto-generated constructor stub + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof JLabel) { + img = (JLabel) value; + type = 1; + return img; + } + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + if (type == 1) { + return img; + } + return super.getCellEditorValue(); + } + +} From 70698083067808869a4c7f03c32ce61f65654d4f Mon Sep 17 00:00:00 2001 From: zouxk Date: Mon, 6 Jan 2020 17:17:30 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jd/plm/form/ExperimentalPowerOfAttorneyForm.java | 12 +++++++----- .../connor/jd/plm/form/SampleConfirmationForm.java | 12 ++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java index d065178..1c7bba7 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java @@ -254,13 +254,15 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement model.setValueAt(rows[i][ii], top + i + 1, ii > 2 ? ii > 3 ? ii + 4 : ii + 2 : ii); } } - + JPanel inner = new JPanel(new BorderLayout()); + inner.add(table, BorderLayout.CENTER); + inner.add(table2, BorderLayout.SOUTH); ScrollPane pane = new ScrollPane(); - pane.add(table); - ScrollPane pane2 = new ScrollPane(); - pane2.add(table2); + pane.add(inner); +// ScrollPane pane2 = new ScrollPane(); +// pane2.add(table2); root.add(pane, BorderLayout.CENTER); - root.add(pane2, BorderLayout.SOUTH); +// root.add(pane2, BorderLayout.SOUTH); this.add(menu); this.add(root); } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index 387f476..7d8d4b5 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -364,12 +364,16 @@ public class SampleConfirmationForm extends AbstractRendering { System.out.println("属性‘jd2_ypqrdtable’未找到"); } + JPanel inner = new JPanel(new BorderLayout()); + inner.add(table, BorderLayout.CENTER); + inner.add(table3, BorderLayout.SOUTH); + ScrollPane confirmScrollPanel1 = new ScrollPane(); - confirmScrollPanel1.add(table); - ScrollPane confirmScrollPanel3 = new ScrollPane(); - confirmScrollPanel3.add(table3); + confirmScrollPanel1.add(inner); +// ScrollPane confirmScrollPanel3 = new ScrollPane(); +// confirmScrollPanel3.add(table3); confirmPanel.add(confirmScrollPanel1, BorderLayout.CENTER); - confirmPanel.add(confirmScrollPanel3, BorderLayout.SOUTH); +// confirmPanel.add(confirmScrollPanel3, BorderLayout.SOUTH); // 检查表 examinePanel.setBorder(BorderFactory.createLineBorder(Color.black, 1)); examinePanel.setLayout(new BorderLayout()); From eed466075e92625baf95db8549f4457e73ee3658 Mon Sep 17 00:00:00 2001 From: zouxk Date: Mon, 13 Jan 2020 15:39:40 +0800 Subject: [PATCH 09/12] =?UTF-8?q?2020/1/13=20=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.connor.jd.plm/config/db.setting | 2 +- com.connor.jd.plm/plugin.xml | 4 - com.connor.jd.plm/src/Test.java | 4 +- .../connor/jd/plm/dialogs/CSXWHDialog.java | 70 +++-- .../src/com/connor/jd/plm/form/CSJHForm.java | 249 +++++++++++++++++- .../jd/plm/form/ComponentTestFrame.java | 19 +- .../form/ExperimentalPowerOfAttorneyForm.java | 18 +- .../jd/plm/form/NewProductTestForm.java | 162 ++++++++++++ 8 files changed, 485 insertions(+), 43 deletions(-) create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java diff --git a/com.connor.jd.plm/config/db.setting b/com.connor.jd.plm/config/db.setting index 7780db4..b6edd27 100644 --- a/com.connor.jd.plm/config/db.setting +++ b/com.connor.jd.plm/config/db.setting @@ -1,7 +1,7 @@ ## db.setting文件 # url = jdbc:oracle:thin:@localhost:1521:TC -url = jdbc:oracle:thin:@localhost:1521:TC12 +url = jdbc:oracle:thin:@10.20.4.75:1521:TC12 user = infodba pass = infodba diff --git a/com.connor.jd.plm/plugin.xml b/com.connor.jd.plm/plugin.xml index c92e6a3..8a569d5 100644 --- a/com.connor.jd.plm/plugin.xml +++ b/com.connor.jd.plm/plugin.xml @@ -242,8 +242,6 @@ - - @@ -286,8 +284,6 @@ - - diff --git a/com.connor.jd.plm/src/Test.java b/com.connor.jd.plm/src/Test.java index 907eafb..46ec1b3 100644 --- a/com.connor.jd.plm/src/Test.java +++ b/com.connor.jd.plm/src/Test.java @@ -2,7 +2,9 @@ public class Test { public static void main(String[] args) { - + String fileName = "111.xlsx"; + String[] filename = fileName.split("\\."); + System.out.println(fileName.lastIndexOf(".")); } } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java index 86e6055..632c52f 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java @@ -7,7 +7,6 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang3.math.NumberUtils; @@ -553,6 +552,7 @@ public class CSXWHDialog extends Application { primaryStage.setScene(scene); primaryStage.setTitle("测试项维护"); primaryStage.show(); + primaryStage.setAlwaysOnTop(true); } @@ -560,8 +560,15 @@ public class CSXWHDialog extends Application { ObservableList results = FXCollections.observableArrayList(); Pattern pattern = Pattern.compile(name); for (int i = 0; i < list.size(); i++) { - Matcher matcher = pattern.matcher(((ComponentBean) list.get(i)).getType()); - if (matcher.find()) { +// Matcher matcher = pattern.matcher(((ComponentBean) list.get(i)).getType()); +// if (matcher.find()) { +// results.add(list.get(i)); +// } + if (((ComponentBean) list.get(i)).getType().contains(name) + || ((ComponentBean) list.get(i)).getProject().contains(name) + || ((ComponentBean) list.get(i)).getTime().contains(name) + || ((ComponentBean) list.get(i)).getNumber().contains(name) + || ((ComponentBean) list.get(i)).getCost().contains(name)) { results.add(list.get(i)); } } @@ -572,8 +579,13 @@ public class CSXWHDialog extends Application { ObservableList results = FXCollections.observableArrayList(); Pattern pattern = Pattern.compile(name); for (int i = 0; i < list.size(); i++) { - Matcher matcher = pattern.matcher(((MachineBean) list.get(i)).getType()); - if (matcher.find()) { +// Matcher matcher = pattern.matcher(((MachineBean) list.get(i)).getType()); +// if (matcher.find()) { +// results.add(list.get(i)); +// } + if (((MachineBean) list.get(i)).getType().contains(name) + || ((MachineBean) list.get(i)).getProject().contains(name) + || ((MachineBean) list.get(i)).getCost().contains(name)) { results.add(list.get(i)); } } @@ -658,13 +670,20 @@ public class CSXWHDialog extends Application { } ps.setDouble(5, Double.valueOf(com.getCost())); int rs = ps.executeUpdate(); - if (rs == 1) + if (rs == 1) { System.out.println("添加成功"); - else + Alert alert = new Alert(AlertType.INFORMATION, "添加成功"); + alert.show(); + } else { System.out.println("添加失败"); + Alert alert = new Alert(AlertType.INFORMATION, "添加失败"); + alert.show(); + } } catch (Exception e) { System.out.println("添加失败"); + Alert alert = new Alert(AlertType.INFORMATION, "添加失败"); + alert.show(); } finally { if (ps != null) { try { @@ -697,10 +716,15 @@ public class CSXWHDialog extends Application { ps.setDouble(3, Double.valueOf(mac.getCost())); int rs = ps.executeUpdate(); System.out.println(rs); - if (rs == 1) + if (rs == 1) { System.out.println("添加成功"); - else + Alert alert = new Alert(AlertType.INFORMATION, "添加成功"); + alert.show(); + } else { System.out.println("添加失败"); + Alert alert = new Alert(AlertType.INFORMATION, "添加失败"); + alert.show(); + } } catch (Exception e) { System.out.println("添加失败"); @@ -741,10 +765,15 @@ public class CSXWHDialog extends Application { ps.setDouble(5, Double.valueOf(com.getCost())); ps.setInt(6, com.getCompId()); int rs = ps.executeUpdate(); - if (rs == 1) + if (rs == 1) { System.out.println("更新成功"); - else + Alert alert = new Alert(AlertType.INFORMATION, "更新成功"); + alert.show(); + } else { System.out.println("更新失败"); + Alert alert = new Alert(AlertType.INFORMATION, "更新失败"); + alert.show(); + } } catch (Exception e) { } finally { @@ -771,10 +800,16 @@ public class CSXWHDialog extends Application { ps = con.prepareStatement(sql); ps.setInt(1, id); int rs = ps.executeUpdate(); - if (rs > 0) + if (rs > 0) { System.out.println("成功"); - else + Alert alert = new Alert(AlertType.INFORMATION, "成功"); + alert.show(); + } else { System.out.println("失败"); + Alert alert = new Alert(AlertType.INFORMATION, "失败"); + alert.show(); + } + } catch (Exception e) { } finally { if (ps != null) { @@ -808,10 +843,15 @@ public class CSXWHDialog extends Application { ps.setDouble(3, Double.valueOf(mac.getCost())); ps.setInt(4, mac.getMacId()); int rs = ps.executeUpdate(); - if (rs == 1) + if (rs == 1) { System.out.println("更新成功"); - else + Alert alert = new Alert(AlertType.INFORMATION, "更新成功"); + alert.show(); + } else { System.out.println("更新失败"); + Alert alert = new Alert(AlertType.ERROR, "更新失败"); + alert.show(); + } } catch (Exception e) { } finally { diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java index d3389b4..3667fca 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java @@ -1,6 +1,7 @@ package com.connor.jd.plm.form; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -15,6 +16,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; import javax.swing.DefaultCellEditor; import javax.swing.JButton; @@ -59,6 +62,10 @@ public class CSJHForm extends AbstractRendering { private ObservableList componentData = FXCollections.observableArrayList(); String[] propNames = new String[] { "jd2_syxh", "jd2_symd", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq", "jd2_syfy", "jd2_jhrc", "jd2_sjrc", "jd2_syzt", "jd2_syjg", "jd2_sycs", "jd2_syry", "jd2_csbg", "jd2_bz" }; + private JLabel label3; + private List editable = new ArrayList(); + private Map res; + private Map rowNo; public CSJHForm(TCComponent form) throws Exception { super(); @@ -176,7 +183,8 @@ public class CSJHForm extends AbstractRendering { final JTable table = new JTable(model) { @Override public boolean isCellEditable(int row, int column) { - if (column == 3 || column == 4 || column == 5 || column == 6 || column == 7 || column == 14) + if (column == 3 || column == 4 || column == 5 || column == 6 || column == 7 || column == 14 + || column == 12 || editable.contains(row)) return false; else return true; @@ -191,8 +199,88 @@ public class CSJHForm extends AbstractRendering { for (int i = 0; i < 16; i++) { table.getColumn(table.getColumnName(i)).setMinWidth(60); } - table.getColumn(table.getColumnName(10)).setCellEditor(new DefaultCellEditor(testStage)); - table.getColumn(table.getColumnName(11)).setCellEditor(new DefaultCellEditor(testResult)); + + DefaultCellEditor dce1 = new DefaultCellEditor(testStage) { + + int row; + + @Override + public Component getTableCellEditorComponent(JTable paramJTable, Object paramObject, boolean paramBoolean, + int paramInt1, int paramInt2) { + // TODO Auto-generated method stub + + row = paramInt1; + return super.getTableCellEditorComponent(paramJTable, paramObject, paramBoolean, paramInt1, paramInt2); + } + + @Override + public Object getCellEditorValue() { + + Object obj = super.getCellEditorValue(); + if ("完成".equals(obj.toString())) { + editable.add(row); + } else { + if (editable.contains(row)) { + editable.remove(row); + } + } + return obj; + } + }; + + DefaultCellEditor dce2 = new DefaultCellEditor(testResult) { + JTable t; + int row; + int num; + + @Override + public Component getTableCellEditorComponent(JTable paramJTable, Object paramObject, boolean paramBoolean, + int paramInt1, int paramInt2) { + // TODO Auto-generated method stub + t = paramJTable; + row = paramInt1; + String str = t.getValueAt(row, 12) == null ? "" : t.getValueAt(row, 12).toString(); + num = Objects.equals(str, "") ? 0 : Integer.parseInt(str); + return super.getTableCellEditorComponent(paramJTable, paramObject, paramBoolean, paramInt1, paramInt2); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + + Object obj = super.getCellEditorValue(); + + if (res.containsKey(rowNo.get(row))) { + if (num >= res.get(rowNo.get(row)).getTimes()) { + res.put(rowNo.get(row), new JG(row, num, obj.toString())); + } + } else { + res.put(rowNo.get(row), new JG(row, num, obj.toString())); + } + + boolean flag = false; + for (Entry entry : res.entrySet()) { + if ("不合格".equals(entry.getValue().getJg())) { + flag = true; + break; + } + } + if (flag) { + label3.setText("结论:不合格"); + } else { + label3.setText("结论:合格"); + } + return obj; + } + }; + + table.getColumn(table.getColumnName(10)).setCellEditor(dce1); + table.getColumn(table.getColumnName(11)).setCellEditor(dce2); + if (form.isCheckedOut()) { + table.setEnabled(true); + } else { + table.setEnabled(false); + } JPanel panelLable = new JPanel(); JLabel label = new JLabel("试验费用总计:"); JLabel label2 = new JLabel(); @@ -204,8 +292,43 @@ public class CSJHForm extends AbstractRendering { allcost += Double.valueOf(value); } label2.setText(allcost + "元"); + + label3 = new JLabel("结论:合格"); + res = new HashMap(); + rowNo = new HashMap(); + String no; + String jg; + for (int i = 0; i < tables.length; i++) { + no = tables[i].getProperty("jd2_no"); + rowNo.put(i, no); + jg = tables[i].getProperty("jd2_syjg"); + int times = Integer.parseInt( + Objects.equals(tables[i].getProperty("jd2_sycs"), "") ? "0" : tables[i].getProperty("jd2_sycs")); + if ("完成".equals(tables[i].getProperty("jd2_syzt"))) { + editable.add(i); + } + if (res.containsKey(no)) { + if (times >= res.get(no).getTimes()) { + editable.add(res.get(no).getRow()); + res.put(no, new JG(i, times, jg)); + } + } else { + res.put(no, new JG(i, times, jg)); + } + } + + for (Entry entry : res.entrySet()) { + System.out.println(entry.getKey() + entry.getValue().getRow() + entry.getValue().getJg() + + entry.getValue().getTimes()); + if ("不合格".equals(entry.getValue().getJg())) { + label3.setText("结论:不合格"); + } + } + panelLable.add(label); panelLable.add(label2); + panelLable.add(label3); + JPanel panel = new JPanel(); JScrollPane pane = new JScrollPane(table); GridBagLayout gbl = new GridBagLayout(); @@ -243,11 +366,11 @@ public class CSJHForm extends AbstractRendering { if (file != null) { String filePath = file.getPath(); String fileName = file.getName(); - String[] filename = fileName.split("."); + String filename = fileName.substring(0, fileName.lastIndexOf(".")); System.out.println(filePath); System.out.println(fileName); int row = table.getSelectedRow(); - String value = (String) model.getValueAt(row, 14); + String value = model.getValueAt(row, 14) == null ? "" : model.getValueAt(row, 14).toString(); if (value.equals("")) { try { TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("JD2_GTCSBG"); @@ -263,7 +386,7 @@ public class CSJHForm extends AbstractRendering { } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { msType = "MSExcelX"; } - TCComponentDataset datasetMSExcelX = datasetType.create(filename[0], "", msType); + TCComponentDataset datasetMSExcelX = datasetType.create(filename, "", msType); datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text) item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); model.setValueAt(item.getProperty("current_id"), row, 14); @@ -272,15 +395,45 @@ public class CSJHForm extends AbstractRendering { } } else { // 添加到数据集 + boolean exist = false; try { TCComponent[] tcc = itemR.getTCProperty("JD2_CSBG").getReferenceValueArray(); for (int i = 0; i < tcc.length; i++) { if (value.equals(tcc[i].getProperty("current_id"))) { + exist = true; TCComponentItem item = (TCComponentItem) tcc[i]; TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification") .getReferenceValueArray(); TCComponentDataset dataset = (TCComponentDataset) tccitem[0]; dataset.setFiles(new String[] { file.getPath() }, new String[] { "excel" }); + dataset.setProperty("object_name", filename); + item.setProperty("object_name", filename); + item.getLatestItemRevision().setProperty("object_name", filename); + } + } + if (!exist) { + try { + TCComponentItemType itemtype = (TCComponentItemType) session + .getTypeComponent("JD2_GTCSBG"); + String itemId = itemtype.getNewID(); + String itemRev = itemtype.getNewRev(null); + TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, "描述", + null); + itemR.add("JD2_CSBG", item); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + String msType = ""; + if (filePath.endsWith(".xls")) { + msType = "MSExcel"; + } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { + msType = "MSExcelX"; + } + TCComponentDataset datasetMSExcelX = datasetType.create(filename, "", msType); + datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text) + item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); + model.setValueAt(item.getProperty("current_id"), row, 14); + } catch (TCException e1) { + e1.printStackTrace(); } } } catch (TCException e1) { @@ -303,7 +456,7 @@ public class CSJHForm extends AbstractRendering { if (file != null) { String filePath = file.getPath(); String fileName = file.getName(); - String[] filename = fileName.split("."); + String filename = fileName.substring(0, fileName.lastIndexOf(".")); System.out.println(filePath); System.out.println(fileName); if (value.equals("")) { @@ -321,25 +474,52 @@ public class CSJHForm extends AbstractRendering { } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { msType = "MSExcelX"; } - TCComponentDataset datasetMSExcelX = datasetType.create(filename[0], "", msType); + TCComponentDataset datasetMSExcelX = datasetType.create(filename, "", msType); datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text) item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); - model.setValueAt(item.getProperty("current_id"), row, 14); } catch (TCException e1) { e1.printStackTrace(); } } else { // 添加到数据集 + boolean exist = false; try { TCComponent[] tcc = itemR.getTCProperty("JD2_CSBGHZ").getReferenceValueArray(); for (int i = 0; i < tcc.length; i++) { if (value.equals(tcc[i].getProperty("current_id"))) { + exist = true; TCComponentItem item = (TCComponentItem) tcc[i]; TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification") .getReferenceValueArray(); TCComponentDataset dataset = (TCComponentDataset) tccitem[0]; dataset.setFiles(new String[] { file.getPath() }, new String[] { "excel" }); - + dataset.setProperty("object_name", filename); + item.setProperty("object_name", filename); + item.getLatestItemRevision().setProperty("object_name", filename); + } + } + if (!exist) { + try { + TCComponentItemType itemtype = (TCComponentItemType) session + .getTypeComponent("JD2_GTCSBG"); + String itemId = itemtype.getNewID(); + String itemRev = itemtype.getNewRev(null); + TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, "描述", + null); + itemR.add("JD2_CSBGHZ", item); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + String msType = ""; + if (filePath.endsWith(".xls")) { + msType = "MSExcel"; + } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { + msType = "MSExcelX"; + } + TCComponentDataset datasetMSExcelX = datasetType.create(filename, "", msType); + datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text) + item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); + } catch (TCException e1) { + e1.printStackTrace(); } } } catch (TCException e1) { @@ -370,7 +550,7 @@ public class CSJHForm extends AbstractRendering { chishu = "0"; } temp[12] = String.valueOf(Integer.valueOf(chishu) + 1); - temp[14] = (String) model.getValueAt(table.getSelectedRow(), 14); +// temp[14] = (String) model.getValueAt(table.getSelectedRow(), 14); temp[15] = (String) model.getValueAt(table.getSelectedRow(), 15); model.insertRow(table.getSelectedRow() + 1, temp); for (int i = table.getSelectedRow() + 1; i < model.getRowCount(); i++) { @@ -385,6 +565,8 @@ public class CSJHForm extends AbstractRendering { allcost2 += Double.valueOf(value); } label2.setText(allcost2 + "元"); + editable.add(table.getSelectedRow()); + rowNo.put(table.getSelectedRow() + 1, rowNo.get(table.getSelectedRow())); }); table.addMouseListener(new MouseAdapter() { @@ -433,6 +615,7 @@ public class CSJHForm extends AbstractRendering { for (int i = 0; i < model.getRowCount(); i++) { CreateIn in = new CreateIn(); Map propMap = new HashMap(); + propMap.put("jd2_no", rowNo.get(i)); for (int j = 0; j < propNames.length; j++) { propMap.put(propNames[j], model.getValueAt(i, j + 1) == null ? "" : model.getValueAt(i, j + 1).toString()); @@ -464,4 +647,48 @@ public class CSJHForm extends AbstractRendering { } } + @Override + public boolean isRenderingModified() { + // TODO Auto-generated method stub + return form.isCheckedOut(); + } + + private class JG { + int row; + int times; + String jg; + + public JG(int row, int times, String jg) { + super(); + this.row = row; + this.times = times; + this.jg = jg; + } + + public int getTimes() { + return times; + } + + public void setTimes(int times) { + this.times = times; + } + + public String getJg() { + return jg; + } + + public void setJg(String jg) { + this.jg = jg; + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + } + } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java index cb9114a..526e788 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ComponentTestFrame.java @@ -57,6 +57,7 @@ public class ComponentTestFrame extends JFrame { } else { instance.bottom = 0; instance.form = form; + instance.callBack = callBack; instance.init(); } return instance; @@ -194,28 +195,28 @@ public class ComponentTestFrame extends JFrame { TCComponentItemRevision rev = (TCComponentItemRevision) form.whereReferenced()[0].getComponent(); TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("Item"); - String itemId = type.getNewID(); - String itemRev = type.getNewRev(null); - TCComponentItem item = type.create(itemId, itemRev, "JD2_GTCSJH", rev.getProperty("item_id"), "", - null); + TCComponentItem item = type.create(null, null, "JD2_GTCSJH", "测试计划", "", null); rev.add("JD2_CSJH", item); TCComponentItemRevision rev1 = item.getLatestItemRevision(); TCComponentForm form1 = (TCComponentForm) rev1.getRelatedComponents("IMAN_master_form_rev")[0]; - String[] colNames = new String[] { "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq", "jd2_syfy" }; + String[] colNames = new String[] { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq", + "jd2_syfy", "jd2_sycs" }; List list = new ArrayList(); - String[] row = new String[5]; + String[] row = new String[7]; for (int i = 1; i <= bottom; i++) { JCheckBox jb = (JCheckBox) model.getValueAt(i, 6); if (jb.isSelected()) { for (int ii = 2; ii < 6; ii++) { row[ii - 2] = model.getValueAt(i, ii) == null ? "" : model.getValueAt(i, ii).toString(); } - list.add(new String[] { session.getUserName(), row[0], row[2], row[1], row[3] }); +// TCComponentPerson p = (TCComponentPerson) session.getUser().getUserInformation().get(0); + list.add(new String[] { i + "", form.getTCProperty("owning_user").getUIFValue(), row[0], + row[2], row[1], row[3], "1" }); } } - String[][] data = list.toArray(new String[list.size()][5]); + String[][] data = list.toArray(new String[list.size()][7]); TCTableUtil.setTableRows(form1, "jd2_csjh", "JD2_CSJHTABLE", colNames, data); - callBack.execute(itemId); + callBack.execute(item.getProperty("item_id")); dispose(); } catch (TCException e1) { // TODO Auto-generated catch block diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java index 1c7bba7..5c0edf0 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ExperimentalPowerOfAttorneyForm.java @@ -279,7 +279,7 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement model.setValueAt("生效期", 1, 8); disableEdit.add("1,8"); general.put("jd2_bh", new int[] { 0, 9 }); - general.put("jd2_sxq", new int[] { 1, 9 }); + general.put("jd2_sxr", new int[] { 1, 9 }); model.setValueAt("委托项目:", 3, 0); disableEdit.add("3,0"); model.setValueAt("委托部门:", 4, 0); @@ -403,7 +403,7 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement } for (Entry entry : general2.entrySet()) { if (prop.containsKey(entry.getKey())) { - String value = model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString(); + String value = model2.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString(); try { if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) { value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues() @@ -456,6 +456,12 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement System.out.println(Arrays.deepToString(dataArr)); TCTableUtil.setTableRows(form, "jd2_sywts", "JD2_SYWTS", colNames, dataArr); } + try { + form.refresh(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } private boolean isEditorDisable(List list, int row, int col) { @@ -538,7 +544,15 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement public void execute(String itemId) { // TODO Auto-generated method stub int row = table.getSelectedRow(); + System.out.println(itemId + " " + row); model.setValueAt(itemId, row, 9); + table.revalidate(); + table.repaint(); + } + + @Override + public boolean isRenderingModified() { + return form.isCheckedOut(); } } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java new file mode 100644 index 0000000..1a820b0 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java @@ -0,0 +1,162 @@ +package com.connor.jd.plm.form; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.util.List; +import java.util.Map; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.table.DefaultTableCellRenderer; + +import com.connor.jd.plm.table.CTMap; +import com.connor.jd.plm.table.CTable; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; + +public class NewProductTestForm extends AbstractRendering { + private TCComponentForm form; + private CTMap model1; + private CTMap model2; + private CTable table1; + private CTable table2; + private Map prop; + private List disableEdit; + private List disableEdit2; + private Map general; + private Map general2; + + public NewProductTestForm(TCComponent arg0) throws Exception { + super(arg0); + if (arg0 instanceof TCComponentForm) { + this.form = (TCComponentForm) arg0; + loadRendering(); + } + } + + @Override + public void loadRendering() throws TCException { + this.setLayout(new BorderLayout()); + JPanel root = new JPanel(new BorderLayout()); + root.setPreferredSize(new Dimension(800, 500)); + JPanel inner = new JPanel(new BorderLayout()); + + JLabel title = new JLabel("新品项目测试单"); + inner.add(title, BorderLayout.NORTH); + + prop = form.getProperties(); + + // 初始化表格 + model1 = new CTMap(6, 4); + model1.setValueAt("项目信息:", 0, 0); + disableEdit.add("0,0"); + model1.setValueAt("项目信息:", 0, 2); + disableEdit.add("0,2"); + model1.setValueAt("项目信息:", 1, 0); + disableEdit.add("1,0"); + model1.setValueAt("项目信息:", 1, 2); + disableEdit.add("1,2"); + model1.setValueAt("项目信息:", 2, 0); + disableEdit.add("2,0"); + model1.setValueAt("项目信息:", 2, 2); + disableEdit.add("2,2"); + model1.setValueAt("项目信息:", 3, 0); + disableEdit.add("3,0"); + model1.setValueAt("项目信息:", 3, 2); + disableEdit.add("3,2"); + model1.setValueAt("项目信息:", 4, 0); + disableEdit.add("4,0"); + model1.setValueAt("项目信息:", 4, 2); + disableEdit.add("4,2"); + model1.setValueAt("项目信息:", 5, 0); + disableEdit.add("5,0"); + model1.setValueAt("项目信息:", 5, 2); + disableEdit.add("5,2"); + general.put("jd2_xmxx", new int[] { 0, 1 }); + general.put("jd2_lxsj", new int[] { 0, 3 }); + general.put("jd2_jbxh", new int[] { 1, 1 }); + general.put("jd2_csxh", new int[] { 1, 3 }); + general.put("jd2_cpxh", new int[] { 2, 1 }); + general.put("jd2_xmzl", new int[] { 2, 3 }); + general.put("jd2_cpjl", new int[] { 3, 1 }); + general.put("jd2_cpbgd", new int[] { 3, 3 }); + general.put("jd2_pzjl", new int[] { 4, 1 }); + general.put("jd2_kfrc", new int[] { 4, 3 }); + general.put("jd2_kfdj", new int[] { 5, 1 }); + general.put("jd2_kfjd", new int[] { 5, 3 }); + + table1 = new CTable(model1) { + @Override + public boolean isCellEditable(int row, int col) { + if (isEditorDisable(disableEdit, row, col)) { + return false; + } + return true; + } + }; + + table1.setRowHeight(25); + table1.setBorder(BorderFactory.createLineBorder(Color.black)); + table1.getColumnModel().getColumn(0).setPreferredWidth(100); + table1.getColumnModel().getColumn(1).setPreferredWidth(100); + table1.getColumnModel().getColumn(2).setPreferredWidth(100); + table1.getColumnModel().getColumn(3).setPreferredWidth(200); + + DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() { + // 重写方法 + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + + if (value instanceof JPanel) { + return (JPanel) value; + } + + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + setBackground(Color.white); +// if(points1.contains(new Point(row,column))) +// setForeground(new Color(0,0,255)); +// else + setForeground(Color.black); + if (isSelected) { + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙 + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + }; + tcr1.setHorizontalAlignment(SwingConstants.CENTER); + table1.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN); + table1.setDefaultRenderer(Object.class, tcr1); + inner.add(table1, BorderLayout.CENTER); + + model2 = new CTMap(131, 9); + } + + @Override + public void saveRendering() { + // TODO Auto-generated method stub + + } + + private boolean isEditorDisable(List list, int row, int col) { + return list.contains(row + "," + col); + } +} From 2832140236a610e09d39d02926b3f106dddb9734 Mon Sep 17 00:00:00 2001 From: zouxk Date: Thu, 13 Feb 2020 17:55:48 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9A=201.=E6=B5=8B=E8=AF=95=E9=A1=B9=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=90=8E=E5=BC=B9=E7=AA=97=E8=A2=AB=E8=A6=86?= =?UTF-8?q?=E7=9B=96=202.=E6=B5=8B=E8=AF=95=E9=A1=B9=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E5=BD=93=E5=89=8D=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=9C=AA=E4=BF=9D=E5=AD=98=203.=E6=96=B0=E5=93=81=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=B8=85=E5=8D=95=E6=95=B0=E5=AD=97=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=BE=93=E5=85=A5=EF=BC=88=E5=AD=98=E7=96=91=EF=BC=89=204.?= =?UTF-8?q?=E6=96=B0=E5=93=81=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=97=A0=E6=8F=90=E7=A4=BA=205.=E6=96=B0=E5=93=81?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=B8=85=E5=8D=95=E4=BF=A1=E6=81=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=9C=AA=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.connor.jd.plm/.classpath | 1085 ++++++++--------- com.connor.jd.plm/config/db.setting | 2 +- com.connor.jd.plm/plugin.xml | 5 + .../src/com/connor/jd/plm/beans/JG.java | 38 + .../com/connor/jd/plm/dialog/MsgDialog.java | 7 + .../connor/jd/plm/dialogs/CSXWHDialog.java | 236 +++- .../src/com/connor/jd/plm/form/CSJHForm.java | 39 +- .../com/connor/jd/plm/form/GTCSJHForm.java | 611 ++++++++++ .../jd/plm/form/NewProductTestForm.java | 573 ++++++++- .../connor/jd/plm/handlers/CSXWHHandler.java | 6 + .../com/connor/jd/plm/table/ModelList.java | 70 ++ .../com/connor/jd/plm/table/ModelValue.java | 163 +++ .../com/connor/jd/plm/table/TCTableUtil.java | 4 + .../connor/jd/plm/utils/DBConnectionUtil.java | 1 + .../rac/stylesheet/stylesheet_user.properties | 2 + 15 files changed, 2153 insertions(+), 689 deletions(-) create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/beans/JG.java create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/dialog/MsgDialog.java create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/form/GTCSJHForm.java create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/table/ModelList.java create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/table/ModelValue.java diff --git a/com.connor.jd.plm/.classpath b/com.connor.jd.plm/.classpath index aed57d5..9988e7c 100644 --- a/com.connor.jd.plm/.classpath +++ b/com.connor.jd.plm/.classpath @@ -1,558 +1,541 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.connor.jd.plm/config/db.setting b/com.connor.jd.plm/config/db.setting index b6edd27..6ad0551 100644 --- a/com.connor.jd.plm/config/db.setting +++ b/com.connor.jd.plm/config/db.setting @@ -1,6 +1,6 @@ ## db.setting文件 -# url = jdbc:oracle:thin:@localhost:1521:TC +#url = jdbc:oracle:thin:@localhost:1521:TC url = jdbc:oracle:thin:@10.20.4.75:1521:TC12 user = infodba pass = infodba diff --git a/com.connor.jd.plm/plugin.xml b/com.connor.jd.plm/plugin.xml index 8a569d5..07a5599 100644 --- a/com.connor.jd.plm/plugin.xml +++ b/com.connor.jd.plm/plugin.xml @@ -55,6 +55,7 @@ + @@ -290,6 +291,7 @@ + @@ -323,6 +325,9 @@ + + + diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/beans/JG.java b/com.connor.jd.plm/src/com/connor/jd/plm/beans/JG.java new file mode 100644 index 0000000..cf10668 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/beans/JG.java @@ -0,0 +1,38 @@ +package com.connor.jd.plm.beans; + +public class JG { + int row; + int times; + String jg; + + public JG(int row, int times, String jg) { + super(); + this.row = row; + this.times = times; + this.jg = jg; + } + + public int getTimes() { + return times; + } + + public void setTimes(int times) { + this.times = times; + } + + public String getJg() { + return jg; + } + + public void setJg(String jg) { + this.jg = jg; + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/MsgDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/MsgDialog.java new file mode 100644 index 0000000..19da49f --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/MsgDialog.java @@ -0,0 +1,7 @@ +package com.connor.jd.plm.dialog; + +import javafx.scene.control.Dialog; + +public class MsgDialog extends Dialog { + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java index 632c52f..3e0b411 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java @@ -19,24 +19,32 @@ import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.kernel.TCException; import javafx.application.Application; +import javafx.beans.value.ChangeListener; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.event.Event; +import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; +import javafx.scene.control.Label; import javafx.scene.control.SelectionMode; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn.CellEditEvent; +import javafx.scene.control.TablePosition; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.control.cell.TextFieldTableCell; +import javafx.scene.input.KeyCode; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.FlowPane; import javafx.scene.layout.Pane; +import javafx.scene.text.Font; import javafx.stage.Stage; public class CSXWHDialog extends Application { @@ -59,15 +67,38 @@ public class CSXWHDialog extends Application { private int index = 10000; private int macindex = 10000; + private Stage msgStage; + private Label msgContent; + @Override public void start(Stage arg0) throws Exception { + msgStage = new Stage(); + msgContent = new Label(""); + msgContent.setFont(new Font(STYLESHEET_CASPIAN, 16)); + Button ok = new Button("确定"); + ok.setPrefSize(60, 25); + ok.setOnAction((arg) -> { + msgStage.close(); + }); + BorderPane msgInner = new BorderPane(); + msgInner.setStyle("-fx-padding:10px;"); + FlowPane btnFlow = new FlowPane(); + btnFlow.setAlignment(Pos.TOP_RIGHT); + btnFlow.getChildren().addAll(ok); + msgInner.setTop(msgContent); + msgInner.setBottom(btnFlow); + Scene msgScene = new Scene(msgInner, 200, 100); + msgStage.setScene(msgScene); + msgStage.setTitle("信息"); + msgStage.setAlwaysOnTop(true); + CreateTableOperation.create(); try { con = DBConnectionUtil.dbConn("infodba", "infodba"); String sqlString = "select * from JD2_Component"; if (con == null) { - Alert alert = new Alert(AlertType.ERROR, "连接失败"); - alert.show(); + msgContent.setText("连接失败"); + msgStage.show(); } else { ps = con.prepareStatement(sqlString); rs = ps.executeQuery(); @@ -118,7 +149,9 @@ public class CSXWHDialog extends Application { TableColumn type0 = new TableColumn("部品类型"); type0.setPrefWidth(90); type0.setCellValueFactory(new PropertyValueFactory<>("type")); - type0.setCellFactory(TextFieldTableCell.forTableColumn()); + type0.setCellFactory((col) -> { + return new EditableStringTableCell(); + }); type0.setOnEditCommit((CellEditEvent t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setType(t.getNewValue()); // 如果数据本身是从数据库中取出的,那么将数据状态改为2->从数据库取出但被修改了的 @@ -129,7 +162,9 @@ public class CSXWHDialog extends Application { TableColumn project0 = new TableColumn("试验项目"); project0.setPrefWidth(89); project0.setCellValueFactory(new PropertyValueFactory<>("project")); - project0.setCellFactory(TextFieldTableCell.forTableColumn()); + project0.setCellFactory((col) -> { + return new EditableStringTableCell(); + }); project0.setOnEditCommit((CellEditEvent t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setProject(t.getNewValue()); if (t.getTableView().getItems().get(t.getTablePosition().getRow()).getStage() == 0) { @@ -139,7 +174,9 @@ public class CSXWHDialog extends Application { TableColumn time = new TableColumn("试验时间"); time.setPrefWidth(92); time.setCellValueFactory(new PropertyValueFactory<>("time")); - time.setCellFactory(TextFieldTableCell.forTableColumn()); + time.setCellFactory((col) -> { + return new EditableStringTableCell(); + }); time.setOnEditCommit((CellEditEvent t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setTime(t.getNewValue()); if (t.getTableView().getItems().get(t.getTablePosition().getRow()).getStage() == 0) { @@ -149,7 +186,9 @@ public class CSXWHDialog extends Application { TableColumn number = new TableColumn("样品数量"); number.setPrefWidth(68); number.setCellValueFactory(new PropertyValueFactory<>("number")); - number.setCellFactory(TextFieldTableCell.forTableColumn()); + number.setCellFactory((col) -> { + return new EditableStringTableCell(); + }); number.setOnEditCommit((CellEditEvent t) -> { if (NumberUtils.isNumber(t.getNewValue())) { t.getTableView().getItems().get(t.getTablePosition().getRow()).setNumber(t.getNewValue()); @@ -159,15 +198,17 @@ public class CSXWHDialog extends Application { } } else { tableView0.refresh(); - Alert alert = new Alert(AlertType.ERROR, "请输入数字"); - alert.show(); + msgContent.setText("请输入数字"); + msgStage.show(); } }); TableColumn cost = new TableColumn("试验费用"); cost.setPrefWidth(71); cost.setCellValueFactory(new PropertyValueFactory<>("cost")); - cost.setCellFactory(TextFieldTableCell.forTableColumn()); + cost.setCellFactory((col) -> { + return new EditableStringTableCell(); + }); cost.setOnEditCommit((CellEditEvent t) -> { t.getNewValue(); if (NumberUtils.isNumber(t.getNewValue())) { @@ -285,6 +326,7 @@ public class CSXWHDialog extends Application { } // tableView0.refresh(); }); + Button saveBtn0 = new Button("保存"); saveBtn0.setLayoutX(161.0); saveBtn0.setLayoutY(319.0); @@ -309,13 +351,12 @@ public class CSXWHDialog extends Application { if (com.getStage() == 2) { update(com); com.setStage(0); - } } tableView0.refresh(); } else { - Alert alert = new Alert(AlertType.ERROR, "存在某行的内容全为空,请检查"); - alert.show(); + msgContent.setText("存在某行的内容全为空,请检查"); + msgStage.show(); } }); @@ -379,7 +420,9 @@ public class CSXWHDialog extends Application { TableColumn type1 = new TableColumn("类别"); type1.setPrefWidth(110.0); type1.setCellValueFactory(new PropertyValueFactory<>("type")); - type1.setCellFactory(TextFieldTableCell.forTableColumn()); + type1.setCellFactory((col) -> { + return new EditableStringTableCell(); + }); type1.setOnEditCommit((CellEditEvent t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setType(t.getNewValue()); if (t.getTableView().getItems().get(t.getTablePosition().getRow()).getStage() == 0) { @@ -389,7 +432,9 @@ public class CSXWHDialog extends Application { TableColumn project1 = new TableColumn("项目"); project1.setPrefWidth(121.0); project1.setCellValueFactory(new PropertyValueFactory<>("project")); - project1.setCellFactory(TextFieldTableCell.forTableColumn()); + project1.setCellFactory((col) -> { + return new EditableStringTableCell(); + }); project1.setOnEditCommit((CellEditEvent t) -> { t.getTableView().getItems().get(t.getTablePosition().getRow()).setProject(t.getNewValue()); if (t.getTableView().getItems().get(t.getTablePosition().getRow()).getStage() == 0) { @@ -399,7 +444,9 @@ public class CSXWHDialog extends Application { TableColumn cost1 = new TableColumn("项目费用"); cost1.setPrefWidth(118.0); cost1.setCellValueFactory(new PropertyValueFactory<>("cost")); - cost1.setCellFactory(TextFieldTableCell.forTableColumn()); + cost1.setCellFactory((col) -> { + return new EditableStringTableCell(); + }); cost1.setOnEditCommit((CellEditEvent t) -> { if (NumberUtils.isNumber(t.getNewValue())) { t.getTableView().getItems().get(t.getTablePosition().getRow()).setCost(t.getNewValue()); @@ -407,9 +454,9 @@ public class CSXWHDialog extends Application { t.getTableView().getItems().get(t.getTablePosition().getRow()).setStage(2); } } else { - tableView0.refresh(); - Alert alert = new Alert(AlertType.ERROR, "请输入数字"); - alert.show(); + tableView1.refresh(); + msgContent.setText("请输入数字"); + msgStage.show(); } }); tableView1.getColumns().addAll(num1, type1, project1, cost1); @@ -530,8 +577,8 @@ public class CSXWHDialog extends Application { } tableView1.refresh(); } else { - Alert alert = new Alert(AlertType.ERROR, "存在某行的内容全为空,请检查"); - alert.show(); + msgContent.setText("存在某行的内容全为空,请检查"); + msgStage.show(); } }); @@ -553,7 +600,6 @@ public class CSXWHDialog extends Application { primaryStage.setTitle("测试项维护"); primaryStage.show(); primaryStage.setAlwaysOnTop(true); - } public ObservableList search(String name, ObservableList list) { @@ -672,18 +718,18 @@ public class CSXWHDialog extends Application { int rs = ps.executeUpdate(); if (rs == 1) { System.out.println("添加成功"); - Alert alert = new Alert(AlertType.INFORMATION, "添加成功"); - alert.show(); + msgContent.setText("添加成功"); + msgStage.show(); } else { System.out.println("添加失败"); - Alert alert = new Alert(AlertType.INFORMATION, "添加失败"); - alert.show(); + msgContent.setText("添加失败"); + msgStage.show(); } } catch (Exception e) { System.out.println("添加失败"); - Alert alert = new Alert(AlertType.INFORMATION, "添加失败"); - alert.show(); + msgContent.setText("添加失败"); + msgStage.show(); } finally { if (ps != null) { try { @@ -718,12 +764,12 @@ public class CSXWHDialog extends Application { System.out.println(rs); if (rs == 1) { System.out.println("添加成功"); - Alert alert = new Alert(AlertType.INFORMATION, "添加成功"); - alert.show(); + msgContent.setText("添加成功"); + msgStage.show(); } else { System.out.println("添加失败"); - Alert alert = new Alert(AlertType.INFORMATION, "添加失败"); - alert.show(); + msgContent.setText("添加失败"); + msgStage.show(); } } catch (Exception e) { @@ -767,12 +813,12 @@ public class CSXWHDialog extends Application { int rs = ps.executeUpdate(); if (rs == 1) { System.out.println("更新成功"); - Alert alert = new Alert(AlertType.INFORMATION, "更新成功"); - alert.show(); + msgContent.setText("更新成功"); + msgStage.show(); } else { System.out.println("更新失败"); - Alert alert = new Alert(AlertType.INFORMATION, "更新失败"); - alert.show(); + msgContent.setText("更新失败"); + msgStage.show(); } } catch (Exception e) { @@ -801,13 +847,13 @@ public class CSXWHDialog extends Application { ps.setInt(1, id); int rs = ps.executeUpdate(); if (rs > 0) { - System.out.println("成功"); - Alert alert = new Alert(AlertType.INFORMATION, "成功"); - alert.show(); + System.out.println("更新成功"); + msgContent.setText("更新成功"); + msgStage.show(); } else { - System.out.println("失败"); - Alert alert = new Alert(AlertType.INFORMATION, "失败"); - alert.show(); + System.out.println("更新成功"); + msgContent.setText("更新失败"); + msgStage.show(); } } catch (Exception e) { @@ -845,12 +891,12 @@ public class CSXWHDialog extends Application { int rs = ps.executeUpdate(); if (rs == 1) { System.out.println("更新成功"); - Alert alert = new Alert(AlertType.INFORMATION, "更新成功"); - alert.show(); + msgContent.setText("更新成功"); + msgStage.show(); } else { System.out.println("更新失败"); - Alert alert = new Alert(AlertType.ERROR, "更新失败"); - alert.show(); + msgContent.setText("更新失败"); + msgStage.show(); } } catch (Exception e) { @@ -871,4 +917,102 @@ public class CSXWHDialog extends Application { } } } +} + +class EditableStringTableCell extends TableCell { + protected TextField textField; + protected ChangeListener changeListener = (obs, ov, nv) -> { + if (!nv) { + commitEdit(textField.getText()); + } + }; + + public EditableStringTableCell() { + + } + + @Override + public void startEdit() { + if (editableProperty().get()) { + if (!isEmpty()) { + super.startEdit(); + createTextField(); + setText(null); + setGraphic(textField); + textField.requestFocus(); + } + } + } + + @Override + public void cancelEdit() { + super.cancelEdit(); + setText(getItem()); + setGraphic(null); + } + + @Override + public void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + + if (empty) { + setText(null); + setGraphic(null); + } else { + if (isEditing()) { + if (textField != null) { + textField.setText(getString()); + textField.selectAll(); + } + setText(null); + setGraphic(textField); + } else { + setText(getString()); + setGraphic(null); + } + } + } + + protected void createTextField() { + textField = new TextField(getString()); + textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2); + textField.focusedProperty().addListener(changeListener); + textField.setOnAction(evt -> commitEdit(textField.getText())); + + textField.setOnKeyPressed((ke) -> { + if (ke.getCode().equals(KeyCode.ESCAPE)) { + textField.focusedProperty().removeListener(changeListener); + cancelEdit(); + } + if (ke.getCode().equals(KeyCode.TAB)) { + commitEdit(textField.getText()); + } + }); + } + + protected String getString() { + return getItem() == null ? "" : getItem().toString(); + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void commitEdit(String item) { + textField.focusedProperty().removeListener(changeListener); + if (isEditing()) { + super.commitEdit(item); + } else { + final TableView table = getTableView(); + if (table != null) { + TablePosition position = new TablePosition(getTableView(), getTableRow().getIndex(), getTableColumn()); + CellEditEvent editEvent = new CellEditEvent(table, position, TableColumn.editCommitEvent(), item); + Event.fireEvent(getTableColumn(), editEvent); + } + updateItem(item, false); + if (table != null) { + table.edit(-1, null); + } + + } + } + } \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java index 3667fca..9bffcf1 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java @@ -32,6 +32,7 @@ import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.DefaultTableModel; import com.connor.jd.plm.beans.ComponentBean; +import com.connor.jd.plm.beans.JG; import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aifrcp.AIFUtility; import com.teamcenter.rac.kernel.TCComponent; @@ -653,42 +654,4 @@ public class CSJHForm extends AbstractRendering { return form.isCheckedOut(); } - private class JG { - int row; - int times; - String jg; - - public JG(int row, int times, String jg) { - super(); - this.row = row; - this.times = times; - this.jg = jg; - } - - public int getTimes() { - return times; - } - - public void setTimes(int times) { - this.times = times; - } - - public String getJg() { - return jg; - } - - public void setJg(String jg) { - this.jg = jg; - } - - public int getRow() { - return row; - } - - public void setRow(int row) { - this.row = row; - } - - } - } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/GTCSJHForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/GTCSJHForm.java new file mode 100644 index 0000000..406d071 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/GTCSJHForm.java @@ -0,0 +1,611 @@ +package com.connor.jd.plm.form; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.ScrollPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.jd.plm.beans.JG; +import com.connor.jd.plm.table.TCTableUtil; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; + +public class GTCSJHForm extends AbstractRendering { + private TCComponentForm form; + private Map parentProp; + private String[] labelNames = { "项目信息:", "立项时间:", "基本型号:", "测试型号:", "产品型号:", "项目资料:", "产品经理:", "产品变更点:", "品质经理:", + "开发日程:", "开发等级:", "开发阶段:" }; + private String[] labellTexts = { "jd2_xmxx", "jd2_lxsj", "jd2_jbxh", "jd2_csxh", "jd2_cpxh", "jd2_xmzl", "jd2_cpjl", + "jd2_cpbgd", "jd2_pzjl", "jd2_kfrc", "jd2_kfdj", "jd2_kfjd" }; + private String[] colNames = { "jd2_no", "jd2_syxh", "jd2_symd", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq", + "jd2_syfy", "jd2_jhrc", "jd2_sjrc", "jd2_syzt", "jd2_syjg", "jd2_sycs", "jd2_syry", "jd2_csbg", "jd2_bz" }; + private String[] colDisplayNames = new String[] { "realNo", "NO", "试验型号", "试验目的", "委托人员", "试验项目", "试验台数", "试验周期", + "试验费用", "计划日程", "实际日程", "试验状态", "实验结果", "第_次试验", "实验人员", "测试报告", "备注" }; + private List disableRows = new ArrayList(); + private List disableColumns = Arrays.asList(4, 5, 6, 7, 8, 13, 15); + private Map resultMap = new HashMap(); + private JTable table; + private DefaultTableModel model; + private TCComponentItemRevision rev; + private TCSession session; + private JLabel cost; + private JLabel jg; + + public GTCSJHForm(TCComponent arg0) throws Exception { + super(arg0); + if (arg0 instanceof TCComponentForm) { + this.form = (TCComponentForm) arg0; + this.session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + loadRendering(); + } + } + + @Override + public void loadRendering() throws TCException { + + AIFComponentContext[] contexts = form.whereReferenced(); + for (int i = 0; i < contexts.length; i++) { + if (contexts[i].getComponent() instanceof TCComponentItemRevision) { + try { + rev = (TCComponentItemRevision) contexts[i].getComponent(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + // TODO Auto-generated method stub + this.setLayout(new BorderLayout()); + JPanel root = new JPanel(new BorderLayout()); + JPanel top = new JPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel inner = new JPanel(); + JPanel innerTop = new JPanel(); + JPanel innerCenter = new JPanel(new BorderLayout()); + root.setPreferredSize(new Dimension(1000, 500)); + inner.setLayout(null); + inner.setPreferredSize(new Dimension(1000, 420)); + innerTop.setLayout(null); + innerTop.setPreferredSize(new Dimension(880, 100)); + innerTop.setBorder(BorderFactory.createLineBorder(Color.black)); + innerTop.setBounds(10, 0, 880, 100); + innerCenter.setPreferredSize(new Dimension(880, 300)); + innerCenter.setBorder(BorderFactory.createLineBorder(Color.black)); + innerCenter.setBounds(10, 120, 880, 300); + + JLabel title = new JLabel(); + AIFComponentContext[] aif = form.whereReferenced(); + for (AIFComponentContext a : aif) { + if ("JD2_GTXPXMCSJHRevision".equals(a.getComponent().getType())) { + try { + title.setText(a.getComponent().getProperty("object_name")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + break; + } + } + + title.setFont(new Font("宋体", Font.PLAIN, 24)); + top.add(title); + + JLabel[] infoText = new JLabel[13]; + JLabel[] infoValue = new JLabel[12]; + + infoText[0] = new JLabel("基本信息:"); + infoText[0].setBounds(10, 0, 80, 25); + + for (int i = 1; i < 13; i++) { + infoText[i] = new JLabel(labelNames[i - 1]); +// infoValue[i - 1] = new JLabel(labellTexts[i - 1]); + infoValue[i - 1] = new JLabel(); + } + for (int i = 1; i < 7; i++) { + infoText[i].setBounds(25 * i + 120 * (i - 1), 30, 60, 25); + infoValue[i - 1].setBounds(85 * i + 60 * (i - 1), 30, 60, 25); + infoText[i + 6].setBounds(25 * i + 120 * (i - 1), 60, 60, 25); + infoValue[i + 5].setBounds(85 * i + 60 * (i - 1), 60, 60, 25); + } + innerTop.add(infoText[0]); + for (int i = 0; i < 12; i++) { + innerTop.add(infoText[i + 1]); + innerTop.add(infoValue[i]); + } + + model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + // TODO Auto-generated method stub + if (disableRows.contains(paramInt1) || disableColumns.contains(paramInt2)) { + return false; + } + return true; + } + }; + JComboBox status = new JComboBox(); + status.addItem("待测"); + status.addItem("进行中"); + status.addItem("完成"); + DefaultCellEditor dce1 = new DefaultCellEditor(status) { + int row; + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, + int column) { + this.row = row; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + Object obj = super.getCellEditorValue(); + if ("完成".equals(obj == null ? "" : obj.toString())) { + disableRows.add(row); + } + return obj; + } + }; + JComboBox result = new JComboBox(); + result.addItem("合格"); + result.addItem("不合格"); + DefaultCellEditor dce2 = new DefaultCellEditor(result) { + JTable table; + int row; + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, + int column) { + this.table = table; + this.row = row; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + Object obj = super.getCellEditorValue(); + String res = (obj == null ? "" : obj.toString()); + String no = table.getValueAt(row, 0).toString(); + Object temp; + int times = Integer.parseInt((temp = table.getValueAt(row, 13)) == null ? "0" : temp.toString().trim()); + addResult(no, row, times, res); + + jg.setText(getResult()); + return obj; + } + }; + table = new JTable(model); + TableColumn tc = table.getColumnModel().getColumn(0); + for (int i = 1; i < table.getColumnCount(); i++) { + table.getColumnModel().getColumn(i).setMinWidth(100); + } + hiddenColumn(table, 0); + table.getColumnModel().getColumn(11).setCellEditor(dce1); + table.getColumnModel().getColumn(12).setCellEditor(dce2); + table.setRowHeight(25); + table.setAutoscrolls(true); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + JScrollPane jsp = new JScrollPane(table); + jsp.setAutoscrolls(true); + innerCenter.add(jsp, BorderLayout.CENTER); + + JButton test = new JButton("测试报告
上传"); + JButton collect = new JButton("汇总结论
上传"); + JButton again = new JButton("再次试验"); + test.setBounds(900, 120, 100, 50); + collect.setBounds(900, 175, 100, 50); + again.setBounds(900, 230, 100, 25); + test.addActionListener(test()); + collect.addActionListener(collect()); + again.addActionListener(again()); + inner.add(test); + inner.add(collect); + inner.add(again); + + JLabel label1 = new JLabel("试验费用总计:"); + JLabel label2 = new JLabel("结论:"); + cost = new JLabel(); + jg = new JLabel(); + label1.setBounds(300, 470, 120, 25); + cost.setBounds(420, 470, 50, 25); + label2.setBounds(480, 470, 50, 25); + jg.setBounds(530, 470, 60, 25); + root.add(label1); + root.add(label2); + root.add(cost); + root.add(jg); + + // 获取信息 + AIFComponentContext[] aifs = form.whereReferenced(); + String temp; + for (AIFComponentContext a1 : aifs) { + System.out.println("测试计划版本:" + (temp = a1.getComponent().getType())); + if ("JD2_GTXPXMCSJHRevision".equals(temp)) { + TCComponentItemRevision rev = (TCComponentItemRevision) a1.getComponent(); + AIFComponentContext[] aifs2 = rev.getItem().whereReferenced(); + for (AIFComponentContext a2 : aifs2) { + System.out.println("新品测试项目清单版本:" + (temp = a2.getComponent().getType())); + if ("JD2_GTXPCSXQDRevision".equals(temp)) { + TCComponentItemRevision rev2 = (TCComponentItemRevision) a2.getComponent(); + TCComponentForm parent = (TCComponentForm) rev2.getRelatedComponents("IMAN_master_form_rev")[0]; + parentProp = parent.getProperties(); + } + } + } + } + if (parentProp != null) { + for (int i = 0; i < labellTexts.length; i++) { + if (parentProp.containsKey(labellTexts[i])) { + String str = parentProp.get(labellTexts[i]); + if ("".equals(str)) { + infoValue[i].setText(str); + } + } else { + System.out.println("属性\"" + labellTexts[i] + "\"不存在"); + } + } + } + + String[][] data = TCTableUtil.getTableRows(form, "jd2_csjhtable", colNames); + +// colNames = { "jd2_no", "jd2_syxh", "jd2_symd", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq", +// "jd2_syfy", "jd2_jhrc", "jd2_sjrc", "jd2_syzt", "jd2_syjg", "jd2_sycs", "jd2_syry", "jd2_csbg", "jd2_bz" }; +// colDisplayNames = new String[] { "realNo", "NO", "试验型号", "试验目的", "委托人员", "试验项目", "试验台数", "试验周期", +// "试验费用", "计划日程", "实际日程", "试验状态", "实验结果", "第_次试验", "实验人员", "测试报告", "备注" }; + System.out.println(Arrays.deepToString(data)); + System.out.println(data.length); + double sum = 0; + for (int i = 0; i < data.length; i++) { + String[] rowData = new String[17]; + rowData[0] = data[i][0]; + rowData[1] = i + 1 + ""; + for (int ii = 1; ii < colNames.length; ii++) { + rowData[ii + 1] = data[i][ii]; + } + Arrays.toString(rowData); + model.addRow(rowData); + + if ("完成".equals(data[i][10])) { + disableRows.add(i); + } + sum += Double.parseDouble(data[i][7]); + addResult(data[i][0], i, Integer.parseInt(data[i][12]), data[i][11]); + } + table.revalidate(); + table.repaint(); + cost.setText(sum + ""); + jg.setText(getResult()); + + inner.add(innerTop); + inner.add(innerCenter); + root.add(top, BorderLayout.NORTH); + root.add(inner, BorderLayout.CENTER); + ScrollPane sc = new ScrollPane(); + sc.add(root); + this.add(sc, BorderLayout.CENTER); + } + + @Override + public void saveRendering() { + // TODO Auto-generated method stub + String[][] data = new String[0][]; + List dataList = new ArrayList(); + Object obj; + for (int i = 0; i < table.getRowCount(); i++) { + String[] rowData = new String[colNames.length]; + for (int ii = 0; ii < colNames.length; ii++) { + rowData[ii] = (obj = table.getValueAt(i, ii > 0 ? ii + 1 : ii)) == null ? "" : obj.toString(); + } + dataList.add(rowData); + } + data = dataList.toArray(new String[dataList.size()][]); + TCTableUtil.setTableRows(form, "jd2_csjhtable", "JD2_CSJHTABLE", colNames, data); + } + + private ActionListener test() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("选择上传的测试报告"); + FileFilter filter = new FileNameExtensionFilter("Excel工作簿(.xlsx)", "xlsx"); + chooser.setFileFilter(filter); + chooser.showOpenDialog(null); + File file = chooser.getSelectedFile(); + if (file != null) { + String filePath = file.getPath(); + String fileName = file.getName(); + String filename = fileName.substring(0, fileName.lastIndexOf(".")); + System.out.println(filePath); + System.out.println(fileName); + int row = table.getSelectedRow(); + String value = model.getValueAt(row, 14) == null ? "" : model.getValueAt(row, 14).toString(); + if (value.equals("")) { + try { + TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("JD2_GTCSBG"); + String itemId = itemtype.getNewID(); + String itemRev = itemtype.getNewRev(null); + TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, "描述", null); + rev.add("JD2_CSBG", item); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + String msType = ""; + if (filePath.endsWith(".xls")) { + msType = "MSExcel"; + } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { + msType = "MSExcelX"; + } + TCComponentDataset datasetMSExcelX = datasetType.create(filename, "", msType); + datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text) + item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); + model.setValueAt(item.getProperty("current_id"), row, 15); + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + // 添加到数据集 + boolean exist = false; + try { + TCComponent[] tcc = rev.getTCProperty("JD2_CSBG").getReferenceValueArray(); + for (int i = 0; i < tcc.length; i++) { + if (value.equals(tcc[i].getProperty("current_id"))) { + exist = true; + TCComponentItem item = (TCComponentItem) tcc[i]; + TCComponent[] tccitem = item.getLatestItemRevision() + .getTCProperty("IMAN_specification").getReferenceValueArray(); + TCComponentDataset dataset = (TCComponentDataset) tccitem[0]; + dataset.setFiles(new String[] { file.getPath() }, new String[] { "excel" }); + dataset.setProperty("object_name", filename); + item.setProperty("object_name", filename); + item.getLatestItemRevision().setProperty("object_name", filename); + } + } + if (!exist) { + try { + TCComponentItemType itemtype = (TCComponentItemType) session + .getTypeComponent("JD2_GTCSBG"); + String itemId = itemtype.getNewID(); + String itemRev = itemtype.getNewRev(null); + TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, + "描述", null); + rev.add("JD2_CSBG", item); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + String msType = ""; + if (filePath.endsWith(".xls")) { + msType = "MSExcel"; + } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { + msType = "MSExcelX"; + } + TCComponentDataset datasetMSExcelX = datasetType.create(filename, "", msType); + datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text) + item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); + model.setValueAt(item.getProperty("current_id"), row, 15); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + } + } + }; + } + + private ActionListener collect() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + String value = (String) model.getValueAt(row, 15); + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("选择上传的汇总结论"); + FileFilter filter = new FileNameExtensionFilter("Excel工作簿(.xlsx)", "xlsx");// 设置文件过滤器,只列出JPG或GIF格式的图片 + chooser.setFileFilter(filter); + chooser.showOpenDialog(null); + File file = chooser.getSelectedFile(); + if (file != null) { + String filePath = file.getPath(); + String fileName = file.getName(); + String filename = fileName.substring(0, fileName.lastIndexOf(".")); + System.out.println(filePath); + System.out.println(fileName); + if (value.equals("")) { + try { + TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("JD2_GTCSBG"); + String itemId = itemtype.getNewID(); + String itemRev = itemtype.getNewRev(null); + TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, "描述", null); + rev.add("JD2_CSBGHZ", item); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + String msType = ""; + if (filePath.endsWith(".xls")) { + msType = "MSExcel"; + } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { + msType = "MSExcelX"; + } + TCComponentDataset datasetMSExcelX = datasetType.create(filename, "", msType); + datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text) + item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + // 添加到数据集 + boolean exist = false; + try { + TCComponent[] tcc = rev.getTCProperty("JD2_CSBGHZ").getReferenceValueArray(); + for (int i = 0; i < tcc.length; i++) { + if (value.equals(tcc[i].getProperty("current_id"))) { + exist = true; + TCComponentItem item = (TCComponentItem) tcc[i]; + TCComponent[] tccitem = item.getLatestItemRevision() + .getTCProperty("IMAN_specification").getReferenceValueArray(); + TCComponentDataset dataset = (TCComponentDataset) tccitem[0]; + dataset.setFiles(new String[] { file.getPath() }, new String[] { "excel" }); + dataset.setProperty("object_name", filename); + item.setProperty("object_name", filename); + item.getLatestItemRevision().setProperty("object_name", filename); + } + } + if (!exist) { + try { + TCComponentItemType itemtype = (TCComponentItemType) session + .getTypeComponent("JD2_GTCSBG"); + String itemId = itemtype.getNewID(); + String itemRev = itemtype.getNewRev(null); + TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, + "描述", null); + rev.add("JD2_CSBGHZ", item); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + String msType = ""; + if (filePath.endsWith(".xls")) { + msType = "MSExcel"; + } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { + msType = "MSExcelX"; + } + TCComponentDataset datasetMSExcelX = datasetType.create(filename, "", msType); + datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text) + item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + + } + } + } + }; + } + + private ActionListener again() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + Object obj; +// "realNo", "NO", "试验型号", "试验目的", "委托人员", "试验项目", "试验台数", "试验周期", +// "试验费用", "计划日程", "实际日程", "试验状态", "实验结果", "第_次试验", "实验人员", "测试报告", "备注" + if (row != -1) { + String realNum = (obj = table.getValueAt(row, 0)) == null ? "0" : obj.toString(); + int num = Integer.parseInt((obj = table.getValueAt(row, 1)) == null ? "0" : obj.toString()); + String[] rowData = new String[table.getColumnCount()]; + rowData[0] = realNum; + rowData[1] = num + 1 + ""; + for (int i = 2; i < 9; i++) { + rowData[i] = (obj = table.getValueAt(row, i)) == null ? "" : obj.toString(); + } + num = Integer.parseInt((obj = table.getValueAt(row, 13)) == null ? "0" : obj.toString()); + rowData[13] = num + 1 + ""; + rowData[16] = (obj = table.getValueAt(row, 16)) == null ? "" : obj.toString(); + disableRows.add(row); + model.insertRow(row + 1, rowData); + table.revalidate(); + table.repaint(); + + cost.setText(getCost() + ""); + } + } + }; + } + + private void hiddenColumn(JTable table, int columnIndex) { + TableColumnModel tcm = table.getColumnModel(); + TableColumn tc = tcm.getColumn(columnIndex); + // tc.setResizable(false); + tc.setWidth(0); + tc.setPreferredWidth(0); + tc.setMaxWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(columnIndex).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(columnIndex).setMinWidth(0); + } + + private double getCost() { + double sum = 0; + Object obj; + for (int i = 0; i < table.getRowCount(); i++) { + double num = Double.parseDouble((obj = table.getValueAt(i, 8)) == null ? "0" : obj.toString()); + sum += num; + } + return sum; + } + + private void addResult(String realNo, int row, int times, String result) { + if (resultMap.containsKey(realNo)) { + if (times >= resultMap.get(realNo).getTimes()) { + disableRows.add(resultMap.get(realNo).getRow()); + resultMap.put(realNo, new JG(row, times, result)); + } + } else { + resultMap.put(realNo, new JG(row, times, result)); + } + } + + private String getResult() { + for (Entry entry : resultMap.entrySet()) { + System.out.println("realNo:" + entry.getKey() + "row:" + entry.getValue().getRow() + "jg:" + + entry.getValue().getJg() + "times:" + entry.getValue().getTimes()); + if ("不合格".equals(entry.getValue().getJg())) { + return "不合格"; + } + } + return "合格"; + } + + @Override + public boolean isRenderingModified() { + // TODO Auto-generated method stub + return form.isCheckedOut(); + } +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java index 1a820b0..db9afc8 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java @@ -4,22 +4,50 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.ScrollPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; import javax.swing.JLabel; +import javax.swing.JMenuItem; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import javax.swing.JTable; +import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.table.DefaultTableCellRenderer; import com.connor.jd.plm.table.CTMap; import com.connor.jd.plm.table.CTable; +import com.connor.jd.plm.table.ModelList; +import com.connor.jd.plm.table.ModelValue; +import com.connor.jd.plm.table.TCTableUtil; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; + +import cn.hutool.db.Db; +import cn.hutool.db.Entity; public class NewProductTestForm extends AbstractRendering { private TCComponentForm form; @@ -28,15 +56,23 @@ public class NewProductTestForm extends AbstractRendering { private CTable table1; private CTable table2; private Map prop; - private List disableEdit; - private List disableEdit2; - private Map general; - private Map general2; + private ModelList modelList1; + private ModelList modelList2; + private List dbData = new ArrayList(); + private JPopupMenu menu = new JPopupMenu(); + private JMenuItem addR; + private String[][] data = new String[0][]; + private String[] colNames = { "jd2_no", "jd2_lb", "jd2_xm", "jd2_xmfy", "jd2_DV", "jd2_PV", "jd2_PR", "jd2_SR", + "jd2_bz" }; + private String[] colNames2 = { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syfy", "jd2_sycs" }; + private String[] jieduan = { "DV", "PV", "PR", "SR" }; + private TCSession session; public NewProductTestForm(TCComponent arg0) throws Exception { super(arg0); if (arg0 instanceof TCComponentForm) { this.form = (TCComponentForm) arg0; + this.session = (TCSession) AIFUtility.getCurrentApplication().getSession(); loadRendering(); } } @@ -48,57 +84,38 @@ public class NewProductTestForm extends AbstractRendering { root.setPreferredSize(new Dimension(800, 500)); JPanel inner = new JPanel(new BorderLayout()); + JPanel top = new JPanel(new FlowLayout(FlowLayout.CENTER)); JLabel title = new JLabel("新品项目测试单"); - inner.add(title, BorderLayout.NORTH); + title.setFont(new Font("宋体", Font.PLAIN, 24)); + top.add(title); + inner.add(top, BorderLayout.NORTH); prop = form.getProperties(); // 初始化表格 model1 = new CTMap(6, 4); - model1.setValueAt("项目信息:", 0, 0); - disableEdit.add("0,0"); - model1.setValueAt("项目信息:", 0, 2); - disableEdit.add("0,2"); - model1.setValueAt("项目信息:", 1, 0); - disableEdit.add("1,0"); - model1.setValueAt("项目信息:", 1, 2); - disableEdit.add("1,2"); - model1.setValueAt("项目信息:", 2, 0); - disableEdit.add("2,0"); - model1.setValueAt("项目信息:", 2, 2); - disableEdit.add("2,2"); - model1.setValueAt("项目信息:", 3, 0); - disableEdit.add("3,0"); - model1.setValueAt("项目信息:", 3, 2); - disableEdit.add("3,2"); - model1.setValueAt("项目信息:", 4, 0); - disableEdit.add("4,0"); - model1.setValueAt("项目信息:", 4, 2); - disableEdit.add("4,2"); - model1.setValueAt("项目信息:", 5, 0); - disableEdit.add("5,0"); - model1.setValueAt("项目信息:", 5, 2); - disableEdit.add("5,2"); - general.put("jd2_xmxx", new int[] { 0, 1 }); - general.put("jd2_lxsj", new int[] { 0, 3 }); - general.put("jd2_jbxh", new int[] { 1, 1 }); - general.put("jd2_csxh", new int[] { 1, 3 }); - general.put("jd2_cpxh", new int[] { 2, 1 }); - general.put("jd2_xmzl", new int[] { 2, 3 }); - general.put("jd2_cpjl", new int[] { 3, 1 }); - general.put("jd2_cpbgd", new int[] { 3, 3 }); - general.put("jd2_pzjl", new int[] { 4, 1 }); - general.put("jd2_kfrc", new int[] { 4, 3 }); - general.put("jd2_kfdj", new int[] { 5, 1 }); - general.put("jd2_kfjd", new int[] { 5, 3 }); + modelList1 = new ModelList(); + String[] textArr1 = { "项目信息:", "立项时间:", "基本型号:", "测试型号:", "产品型号:", "项目资料:", "产品经理:", "产品变更点:", "品质经理:", "开发日程:", + "开发等级:", "开发阶段:" }; + int[][] textLocation1 = { { 0, 0 }, { 0, 2 }, { 1, 0 }, { 1, 2 }, { 2, 0 }, { 2, 2 }, { 3, 0 }, { 3, 2 }, + { 4, 0 }, { 4, 2 }, { 5, 0 }, { 5, 2 } }; + for (int i = 0; i < textArr1.length; i++) { + modelList1.add(new ModelValue(textArr1[i], false, textLocation1[i][0], textLocation1[i][1], false)); + } + String[] propArr = { "jd2_xmxx", "jd2_lxsj", "jd2_jbxh", "jd2_csxh", "jd2_cpxh", "jd2_xmzl", "jd2_cpjl", + "jd2_cpbgd", "jd2_pzjl", "jd2_kfrc", "jd2_kfdj", "jd2_kfjd" }; + int[][] propLocation1 = { { 0, 1 }, { 0, 3 }, { 1, 1 }, { 1, 3 }, { 2, 1 }, { 2, 3 }, { 3, 1 }, { 3, 3 }, + { 4, 1 }, { 4, 3 }, { 5, 1 }, { 5, 3 } }; + for (int i = 0; i < propArr.length; i++) { + modelList1.add(new ModelValue(propArr[i], true, propLocation1[0][1], propLocation1[0][1], true)); + } + + initModel(model1, modelList1); table1 = new CTable(model1) { @Override public boolean isCellEditable(int row, int col) { - if (isEditorDisable(disableEdit, row, col)) { - return false; - } - return true; + return !modelList1.isDisableEdit(row, col); } }; @@ -116,10 +133,6 @@ public class NewProductTestForm extends AbstractRendering { boolean hasFocus, int row, int column) { // TODO Auto-generated method stub - if (value instanceof JPanel) { - return (JPanel) value; - } - int maxPreferredHeight = 0; for (int i = 0; i < table.getColumnCount(); i++) { setText("" + table.getValueAt(row, i)); @@ -147,16 +160,470 @@ public class NewProductTestForm extends AbstractRendering { table1.setDefaultRenderer(Object.class, tcr1); inner.add(table1, BorderLayout.CENTER); - model2 = new CTMap(131, 9); + modelList2 = new ModelList(); + modelList2.add(new ModelValue("NO", false, 0, 0, false, 0, 1, 0, 0)); + modelList2.add(new ModelValue("类别", false, 0, 1, false, 0, 1, 1, 1)); + modelList2.add(new ModelValue("项目", false, 0, 2, false, 0, 1, 2, 2)); + modelList2.add(new ModelValue("项目费用", false, 0, 3, false, 0, 1, 3, 3)); + modelList2.add(new ModelValue("项目阶段", false, 0, 4, false, 0, 0, 4, 7)); + modelList2.add(new ModelValue("DV", false, 1, 4, false)); + modelList2.add(new ModelValue("PV", false, 1, 5, false)); + modelList2.add(new ModelValue("PR", false, 1, 6, false)); + modelList2.add(new ModelValue("SR", false, 1, 7, false)); + modelList2.add(new ModelValue("备注", false, 0, 8, false, 0, 1, 8, 8)); + + String type = null; + int typeSpan = 0; + data = TCTableUtil.getTableRows(form, "jd2_xpcsxqd", colNames); + if (data.length == 0) { + + try { + dbData = Db.use().query("select * from JD2_Machine ORDER BY TEST_TYPE ASC"); + model2 = new CTMap(dbData.size() + 3, 9); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + for (int i = 0; i < dbData.size(); i++) { + System.out.println(dbData.get(i).toString()); + modelList2.add(new ModelValue(dbData.get(i).getStr("TEST_PROJECT"), false, i + 2, 2, false)); + modelList2.add(new ModelValue(dbData.get(i).getInt("TEST_COST") + "", false, i + 2, 3, false)); + if (i == 0) { + type = dbData.get(i).getStr("TEST_TYPE"); + } + if ((type != null && !type.equals(dbData.get(i).getStr("TEST_TYPE")))) { + System.out.println(type); + modelList2.add( + new ModelValue(type, false, i - typeSpan + 2, 1, false, i - typeSpan + 2, i + 1, 1, 1)); + type = dbData.get(i).getStr("TEST_TYPE"); + typeSpan = 0; + } + if ((i == dbData.size() - 1)) { + System.out.println(type); + modelList2.add( + new ModelValue(type, false, i - typeSpan + 2, 1, false, i - typeSpan + 2, i + 2, 1, 1)); + } + model2.setValueAt(i + 1, i + 2, 0); + for (int ii = 4; ii < 8; ii++) { + model2.setValueAt("/", i + 2, ii); + } + typeSpan++; + } + } else { + model2 = new CTMap(data.length + 3, 9); + for (int i = 0; i < data.length; i++) { + System.out.println(Arrays.toString(data[i])); + modelList2.add(new ModelValue(data[i][2], false, i + 2, 2, false)); + modelList2.add(new ModelValue(data[i][3], false, i + 2, 3, false)); + if (i == 0) { + type = data[i][1]; + } + if ((type != null && !type.equals(data[i][1]))) { + System.out.println(type); + modelList2.add( + new ModelValue(type, false, i - typeSpan + 2, 1, false, i - typeSpan + 2, i + 1, 1, 1)); + type = data[i][1]; + typeSpan = 0; + } + if ((i == data.length - 1)) { + System.out.println(type); + modelList2.add( + new ModelValue(type, false, i - typeSpan + 2, 1, false, i - typeSpan + 2, i + 2, 1, 1)); + } + model2.setValueAt(i + 1, i + 2, 0); + for (int ii = 4; ii < 9; ii++) { + model2.setValueAt(data[i][ii], i + 2, ii); + } + typeSpan++; + } + } + + int buttom = data.length == 0 ? dbData.size() + 2 : data.length + 2; + modelList2.add(new ModelValue("项目费用合计", false, buttom, 0, false, buttom, buttom, 0, 2)); + modelList2.add(new ModelValue("jd2_zfy", true, buttom, 3, false)); + modelList2.add(new ModelValue("jd2_dvfy", true, buttom, 4, false)); + modelList2.add(new ModelValue("jd2_pvfy", true, buttom, 5, false)); + modelList2.add(new ModelValue("jd2_prfy", true, buttom, 6, false)); + modelList2.add(new ModelValue("jd2_srfy", true, buttom, 7, false)); + + initModel(model2, modelList2); + + table2 = new CTable(model2) { + @Override + public boolean isCellEditable(int row, int col) { + if (modelList2.isDisableEdit(row, col) || col == 0 || row == table2.getRowCount() - 1) { + return false; + } + return true; + } + }; + + table2.setRowHeight(25); + table2.setBorder(BorderFactory.createLineBorder(Color.black)); + table2.getColumnModel().getColumn(0).setPreferredWidth(100); + table2.getColumnModel().getColumn(1).setPreferredWidth(60); + table2.getColumnModel().getColumn(2).setPreferredWidth(80); + table2.getColumnModel().getColumn(3).setPreferredWidth(60); + table2.getColumnModel().getColumn(4).setPreferredWidth(50); + table2.getColumnModel().getColumn(5).setPreferredWidth(50); + table2.getColumnModel().getColumn(6).setPreferredWidth(50); + table2.getColumnModel().getColumn(7).setPreferredWidth(50); + table2.getColumnModel().getColumn(8).setPreferredWidth(60); + + DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() { + // 重写方法 + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + setBackground(Color.white); +// if(points1.contains(new Point(row,column))) +// setForeground(new Color(0,0,255)); +// else + setForeground(Color.black); + if (isSelected) { + setBackground(new Color(0, 120, 215)); + setForeground(Color.white); + } + if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙 + table.setRowHeight(row, maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + return this; + } + }; + + DefaultCellEditor dce = new DefaultCellEditor(new JTextField()) { + JTable table; + int row; + int col; + + @Override + public Component getTableCellEditorComponent(JTable paramJTable, Object paramObject, boolean paramBoolean, + int paramInt1, int paramInt2) { + this.table = paramJTable; + this.row = paramInt1; + this.col = paramInt2; + return super.getTableCellEditorComponent(paramJTable, paramObject, paramBoolean, paramInt1, paramInt2); + } + + @Override + public Object getCellEditorValue() { + Object obj = super.getCellEditorValue(); + if (obj != null) { + String objStr = obj.toString().trim(); + try { + if ("/".equals(objStr)) { + objStr = "0"; + } + int num = Integer.parseInt(objStr); + if (num < 0) { + System.out.println("计算区域只能输入自然数或\"/\""); + MessageBox.post("计算区域只能输入自然数或\"/\"", "错误", MessageBox.ERROR); + return "/"; + } + int sum = 0; + Object sumObj; + for (int i = 2; i < row; i++) { + sumObj = table.getValueAt(i, col); + if (sumObj != null && !"/".equals(sumObj.toString().trim())) { + sum += Double.parseDouble( + (sumObj = table.getValueAt(i, 3)) == null ? "0" : sumObj.toString().trim()); + } + } + if (!"0".equals(objStr)) { + sum += Double.parseDouble( + (sumObj = table.getValueAt(row, 3)) == null ? "0" : sumObj.toString().trim()); + } + for (int i = row + 1; i < table.getRowCount() - 1; i++) { + sumObj = table.getValueAt(i, col); + if (sumObj != null && !"/".equals(sumObj.toString().trim())) { + sum += Double.parseDouble( + (sumObj = table.getValueAt(i, 3)) == null ? "0" : sumObj.toString().trim()); + } + } + table.setValueAt(sum, table.getRowCount() - 1, col); + double sum1 = Double + .parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 4)) == null ? "0" + : sumObj.toString().trim()); + double sum2 = Double + .parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 5)) == null ? "0" + : sumObj.toString().trim()); + double sum3 = Double + .parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 6)) == null ? "0" + : sumObj.toString().trim()); + double sum4 = Double + .parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 7)) == null ? "0" + : sumObj.toString().trim()); + table.setValueAt(sum1 + sum2 + sum3 + sum4, table.getRowCount() - 1, 3); + table2.revalidate(); + table2.repaint(); + } catch (NumberFormatException e1) { + System.out.println("计算区域只能输入自然数或\"/\""); + MessageBox.post("计算区域只能输入自然数或\"/\"", "错误", MessageBox.ERROR); + obj = "/"; + } catch (Exception e2) { + e2.printStackTrace(); + obj = "/"; + } + } + if ("0".equals(obj.toString().trim())) { + obj = "/"; + } + return obj; + } + }; + tcr2.setHorizontalAlignment(SwingConstants.CENTER); + table2.getColumnModel().getColumn(4).setCellEditor(dce); + table2.getColumnModel().getColumn(5).setCellEditor(dce); + table2.getColumnModel().getColumn(6).setCellEditor(dce); + table2.getColumnModel().getColumn(7).setCellEditor(dce); + table2.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN); + table2.setDefaultRenderer(Object.class, tcr2); + table2.addMouseListener(rightClick()); + inner.add(table2, BorderLayout.SOUTH); + + JPanel btns = new JPanel(new FlowLayout(FlowLayout.CENTER)); + JButton create = new JButton("创建测试计划"); + create.addActionListener(create()); + btns.add(create); + + menu.setVisible(false); + addR = new JMenuItem("新增测试项"); + addR.setEnabled(false); + addR.addActionListener(addRow()); + menu.add(addR); + + ScrollPane sc = new ScrollPane(); + sc.add(inner); + root.add(sc, BorderLayout.CENTER); + root.add(btns, BorderLayout.SOUTH); + this.add(root); } @Override public void saveRendering() { - // TODO Auto-generated method stub + savePropValue(table1, modelList1); + savePropValue(table2, modelList2); + + Object obj; + if (data.length == 0) { + if (dbData.size() == 0) { + try { + dbData = Db.use().query("select * from JD2_Machine ORDER BY TEST_TYPE ASC"); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + data = new String[table2.getRowCount() - 3][9]; + + for (int i = 0; i < dbData.size(); i++) { + data[i][0] = (obj = model2.getValueAt(i + 2, 0)) == null ? "" : obj.toString(); + data[i][1] = dbData.get(i).getStr("TEST_TYPE"); + data[i][2] = dbData.get(i).getStr("TEST_PROJECT"); + data[i][3] = dbData.get(i).getStr("TEST_COST"); + for (int ii = 4; ii < 9; ii++) { + data[i][ii] = (obj = model2.getValueAt(i + 2, ii)) == null ? "" : obj.toString(); + } + } + System.out.println("dbData.size() " + dbData.size()); + System.out.println("table2.getRowCount() " + table2.getRowCount()); + for (int i = dbData.size() + 2; i < table2.getRowCount() - 1; i++) { + for (int ii = 0; ii < 9; ii++) { + data[i][ii] = (obj = model2.getValueAt(i + 2, ii)) == null ? "" : obj.toString(); + } + } + System.out.println(Arrays.deepToString(data)); + TCTableUtil.setTableRows(form, "jd2_xpcsxqd", "JD2_XPCSXQD", colNames, data); + } else { + String[][] newData = new String[table2.getRowCount() - 3][9]; + for (int i = 0; i < data.length; i++) { + System.arraycopy(data[i], 0, newData[i], 0, 4); + for (int ii = 4; ii < 9; ii++) { + newData[i][ii] = (obj = model2.getValueAt(i + 2, ii)) == null ? "" : obj.toString(); + } + } + for (int i = data.length + 2; i < table2.getRowCount() - 1; i++) { + for (int ii = 0; ii < 9; ii++) { + newData[i][ii] = (obj = model2.getValueAt(i + 2, ii)) == null ? "" : obj.toString(); + } + } + System.out.println(Arrays.deepToString(newData)); + TCTableUtil.setTableRows(form, "jd2_xpcsxqd", "JD2_XPCSXQD", colNames, newData); + } } - private boolean isEditorDisable(List list, int row, int col) { - return list.contains(row + "," + col); + private void savePropValue(CTable table, ModelList ml) { + for (ModelValue mv : ml) { + if (mv.isProp()) { + Object obj = table.getValueAt(mv.getRow(), mv.getCol()); + try { + if (prop.containsKey(mv.getValue())) { + form.setProperty(mv.getValue(), obj == null ? "" : obj.toString()); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } } + + private MouseAdapter rightClick() { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table2.getSelectedRow() != -1) { + int row = table2.getSelectedRow(); + boolean flag = (row > 1 && row < table2.getRowCount() - 1); + addR.setEnabled(flag); + menu.show(e.getComponent(), e.getX(), e.getY()); + } + } + }; + } + + private ActionListener addRow() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent paramActionEvent) { + // TODO Auto-generated method stub + int row = model2.getRowCount() - 2; + int num = Integer.parseInt(model2.getValueAt(row, 0).toString()); + model2.insertRow(model2.getRowCount() - 1); + model2.setValueAt(num + 1, row + 1, 0); + table2.revalidate(); + table2.repaint(); + } + }; + } + + private ActionListener create() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent paramActionEvent) { + // TODO Auto-generated method stub + try { + AIFComponentContext[] comps = form.whereReferenced(); + StringBuilder msg = new StringBuilder(); + A1: for (AIFComponentContext aif : comps) { + System.out.println("ref type:" + aif.getComponent().getType()); + if ("JD2_GTXPCSXQDRevision".equals(aif.getComponent().getType())) { + TCComponentItemRevision rev = (TCComponentItemRevision) aif.getComponent(); + TCComponent[] compArr = rev.getTCProperty("JD2_CSJH").getReferenceValueArray(); + String exist = ""; + for (TCComponent t : compArr) { + exist += t.getProperty("object_name"); + } + List colData = new ArrayList(); + String ownner = form.getTCProperty("owning_user").getUIFValue(); + for (int i = 0; i < 4; i++) { + if (exist.contains(jieduan[i])) { + System.out.println("已存在阶段\"" + jieduan[i] + "\"测试计划,请检查!"); + MessageBox.post("已存在阶段\"" + jieduan[i] + "\"测试计划,请检查!", "错误", MessageBox.ERROR); + break A1; + } + Object obj; + Object temp; + int rowNum = 0; + for (int ii = 2; ii < table2.getRowCount() - 1; ii++) { + obj = table2.getValueAt(ii, i + 4); + if (obj != null && !"/".equals(obj.toString().trim())) { + // colNames2 = { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syfy", + // "jd2_sycs" }; + String[] row = new String[6]; + row[0] = rowNum + ""; + row[1] = ownner; + row[2] = (temp = table2.getValueAt(ii, 2)) == null ? "" : temp.toString(); + row[3] = obj.toString().trim(); + row[4] = (temp = table2.getValueAt(ii, 3)) == null ? "0" + : temp.toString().trim(); + row[5] = "1"; + System.out.println(Arrays.toString(row)); + colData.add(row); + rowNum++; + } + } + if (colData.size() != 0) { + TCComponentItemType type = (TCComponentItemType) session + .getTypeComponent("JD2_GTXPXMCSJH"); + TCComponentItem item = type.create(null, null, "JD2_GTXPXMCSJH", + jieduan[i] + "阶段测试计划", "", null); + rev.add("JD2_CSJH", item); + TCComponentItemRevision rev1 = item.getLatestItemRevision(); + TCComponentForm form1 = (TCComponentForm) rev1 + .getRelatedComponents("IMAN_master_form_rev")[0]; + String[][] dataArr = colData.toArray(new String[colData.size()][6]); + System.out.println(Arrays.deepToString(dataArr)); + TCTableUtil.setTableRows(form1, "jd2_csjhtable", "JD2_CSJHTABLE", colNames2, + dataArr); + msg.append(jieduan[i] + "阶段测试计划创建成功\n"); + } + colData.clear(); + } + } + } + MessageBox.post(msg.toString(), "提示", MessageBox.WARNING); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }; + } + + @Override + public boolean isRenderingModified() { + // TODO Auto-generated method stub + return form.isCheckedOut(); + } + + private void initModel(CTMap model, ModelList modelList) { + for (ModelValue mv : modelList) { + if (mv.isProp()) { + if (prop.containsKey(mv.getValue())) { + model.setValueAt(prop.get(mv.getValue()), mv.getRow(), mv.getCol()); + } else { + System.out.println("属性‘" + mv.getValue() + "’不存在"); + } + } else { + model.setValueAt(mv.getValue(), mv.getRow(), mv.getCol()); + } + if (mv.isCombine()) { + model.combine(mv.getCombineRows(), mv.getCombineColumns()); + } + } + } + + private void saveModel(ModelList modelList) { + Object obj; + for (ModelValue mv : modelList) { + if (mv.isProp()) { + if (prop.containsKey(mv.getValue())) { + obj = table2.getValueAt(mv.getRow(), mv.getCol()); + try { + form.setProperty(mv.getValue(), obj == null ? "" : obj.toString()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + System.out.println("属性\"" + mv.getValue() + "\"不存在"); + } + } + } + }; + } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java index 5a050f2..138a1e4 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CSXWHHandler.java @@ -24,6 +24,12 @@ public class CSXWHHandler extends AbstractHandler { TCSession session = (TCSession) app.getSession(); String[] userIdList = JDMethodUtil.getPrefStrArray("JD2_CSXWH", session); Boolean tag = true; + try { + System.out.println("当前用户id:" + session.getUser().getUserId()); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } for (int i = 0; i < userIdList.length; i++) { try { if (session.getUser().getUserId().equals(userIdList[i])) { diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/ModelList.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/ModelList.java new file mode 100644 index 0000000..c7d690a --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/ModelList.java @@ -0,0 +1,70 @@ +package com.connor.jd.plm.table; + +import java.util.ArrayList; +import java.util.List; + +public class ModelList extends ArrayList { + + private List disableEdit = new ArrayList(); + + @Override + public boolean add(ModelValue e) { + // TODO Auto-generated method stub + if (!e.isEditable()) { + disableEdit.add(e.getRow() + "," + e.getCol()); + } + return super.add(e); + } + + public ModelValue getModelValue(int row, int col) { + for (ModelValue mv : this) { + if (mv.getRow() == row && mv.getCol() == col) { + return mv; + } + } + return null; + } + + public ModelValue getModelValueInRange(int row, int col) { + int rowStart; + int colStart; + int rowEnd; + int colEnd; + for (ModelValue mv : this) { + if (mv.isCombine()) { + rowStart = mv.getCombineRows()[0]; + rowEnd = rowStart + mv.getRowSpan() - 1; + colStart = mv.getCombineColumns()[0]; + colEnd = colStart + mv.getColSpan() - 1; + if (row >= rowStart && row <= rowEnd && col >= colStart && col <= colEnd) { + return mv; + } + } + } + return null; + } + + public boolean addDisableEdit(int row, int col) { + String str = row + "," + col; + if (disableEdit.contains(str)) { + disableEdit.add(disableEdit.indexOf(str), str); + return true; + } + disableEdit.add(str); + return false; + } + + public boolean removeDisableEdit(int row, int col) { + String str = row + "," + col; + if (disableEdit.contains(str)) { + disableEdit.remove(disableEdit.indexOf(str)); + return true; + } + return false; + } + + public boolean isDisableEdit(int row, int col) { + return disableEdit.contains(row + "," + col); + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/ModelValue.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/ModelValue.java new file mode 100644 index 0000000..3f05b8b --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/ModelValue.java @@ -0,0 +1,163 @@ +package com.connor.jd.plm.table; + +import java.util.Objects; + +public class ModelValue { + + private String value; + private boolean isProp; + private int row; + private int col; + private boolean editable; + private int[] combineRows; + private int rowSpan; + private int[] combineColumns; + private int colSpan; + + public ModelValue(String value, boolean isProp, int row, int col, boolean editable, int[] combineRows, + int[] combineColumns, String type) { + super(); + this.value = value; + this.isProp = isProp; + this.row = row; + this.col = col; + this.editable = editable; + this.combineRows = combineRows; + this.combineColumns = combineColumns; + } + + public ModelValue(boolean editable, int[] combineRows, int[] combineColumns) { + super(); + this.editable = editable; + this.combineRows = combineRows; + this.combineColumns = combineColumns; + } + + public ModelValue(String value, boolean isProp, int row, int col, boolean editable) { + super(); + this.value = value; + this.isProp = isProp; + this.row = row; + this.col = col; + this.editable = editable; + } + + public ModelValue(String value, boolean isProp, int row, int col, boolean editable, int[] combineRows, + int[] combineColumns) { + super(); + this.value = value; + this.isProp = isProp; + this.row = row; + this.col = col; + this.editable = editable; + this.combineRows = combineRows; + this.combineColumns = combineColumns; + } + + public ModelValue(String value, boolean isProp, int row, int col, boolean editable, int rowStart, int rowEnd, + int colStart, int colEnd) { + super(); + this.value = value; + this.isProp = isProp; + this.row = row; + this.col = col; + this.editable = editable; + setCombineRows(rowStart, rowEnd); + setCombineColumns(colStart, colEnd); + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getCol() { + return col; + } + + public void setCol(int col) { + this.col = col; + } + + public boolean isEditable() { + return editable; + } + + public void setEditable(boolean editable) { + this.editable = editable; + } + + public int[] getCombineRows() { + return combineRows; + } + + public void setCombineRows(int[] combineRows) { + this.rowSpan = combineRows.length; + this.combineRows = combineRows; + } + + public void setCombineRows(int start, int end) { + if (start <= end) { + this.rowSpan = end - start + 1; + this.combineRows = new int[rowSpan]; + for (int i = 0; i < rowSpan; i++) { + combineRows[i] = start + i; + } + } + } + + public int[] getCombineColumns() { + return combineColumns; + } + + public void setCombineColumns(int[] combineColumns) { + this.colSpan = combineColumns.length; + this.combineColumns = combineColumns; + } + + public void setCombineColumns(int start, int end) { + if (start <= end) { + this.colSpan = end - start + 1; + this.combineColumns = new int[colSpan]; + for (int i = 0; i < colSpan; i++) { + combineColumns[i] = start + i; + } + } + } + + public int getRowSpan() { + return rowSpan; + } + + public int getColSpan() { + return colSpan; + } + + public boolean isProp() { + return isProp; + } + + public void setProp(boolean isProp) { + this.isProp = isProp; + } + + public boolean hasValue() { + return Objects.nonNull(value); + } + + public boolean isCombine() { + return rowSpan != 0 && colSpan != 0; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java index 2f81d5b..1046c49 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/TCTableUtil.java @@ -28,8 +28,12 @@ public class TCTableUtil { } } return res; + } catch (NullPointerException e) { + System.out.println("属性\"" + prop + "\"不存在"); + e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block + e.printStackTrace(); } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/utils/DBConnectionUtil.java b/com.connor.jd.plm/src/com/connor/jd/plm/utils/DBConnectionUtil.java index 11c279b..6b21821 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/utils/DBConnectionUtil.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/utils/DBConnectionUtil.java @@ -16,6 +16,7 @@ public class DBConnectionUtil { } try { c = DriverManager.getConnection("jdbc:oracle:thin:@10.20.4.75:1521:TC12", name, pass); +// c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:TC", name, pass); // 连接数据的方法有四种, 这个属于最简单的,一般用网页程序 TC是你的数据库实例名称,在下载的文件test.sql中可以执行语句查看 // "jdbc:oracle:thin:@计算机名称:监听端口:系统实例名", username, password, // 计算机名称,要是自己不知道可以在计算机属性查知. diff --git a/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties index f3fe444..c80cffc 100644 --- a/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties +++ b/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -2,3 +2,5 @@ JD2_GTYPQRDRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.SampleConfirm JD2_GTSYWTSRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.ExperimentalPowerOfAttorneyForm SF6_ElecElementRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.CSJHForm JD2_GTCSJHRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.CSJHForm +JD2_GTXPCSXQDRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.NewProductTestForm +JD2_GTXPXMCSJHRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.GTCSJHForm \ No newline at end of file From 2156c4f8ff38351b0534e9ca711b5895d218d576 Mon Sep 17 00:00:00 2001 From: zouxk Date: Tue, 18 Feb 2020 17:52:23 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E9=9C=80=E6=B1=82=E7=BB=86=E8=8A=82?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=EF=BC=9A=201.=E9=93=BE=E6=8E=A5=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=98=E6=9B=B4=202.=E6=8F=90=E7=A4=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=8F=98=E6=9B=B4=203.=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=9F=A5=E9=87=8D=E9=80=BB=E8=BE=91=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=20=E9=83=A8=E5=88=86=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.connor.jd.plm/plugin.xml | 4 +- .../com/connor/jd/plm/form/GTCSJHForm.java | 38 ++++++++++++++++--- .../jd/plm/form/NewProductTestForm.java | 30 ++++++++------- 3 files changed, 50 insertions(+), 22 deletions(-) diff --git a/com.connor.jd.plm/plugin.xml b/com.connor.jd.plm/plugin.xml index 07a5599..6b58354 100644 --- a/com.connor.jd.plm/plugin.xml +++ b/com.connor.jd.plm/plugin.xml @@ -325,9 +325,6 @@ - - - @@ -349,6 +346,7 @@ + diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/GTCSJHForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/GTCSJHForm.java index 406d071..6b2de77 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/GTCSJHForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/GTCSJHForm.java @@ -9,6 +9,8 @@ import java.awt.Font; import java.awt.ScrollPane; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -221,6 +223,34 @@ public class GTCSJHForm extends AbstractRendering { table.setRowHeight(25); table.setAutoscrolls(true); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (table.getSelectedColumn() == 15) { + if (e.getClickCount() == 2) { + System.out.println("双击了"); + int selectedRow = table.getSelectedRow(); // 获得选中行索引 + String value = (String) model.getValueAt(selectedRow, 15); + if (value == null) + value = ""; + if (!value.equals("")) { + try { + TCComponent[] result = session.search("零组件 ID", new String[] { "零组件 ID" }, + new String[] { value }); + TCComponentItem item = (TCComponentItem) result[0]; + TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification") + .getReferenceValueArray(); + TCComponentDataset dataset = (TCComponentDataset) tccitem[0]; + dataset.open(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + } + + } + }); JScrollPane jsp = new JScrollPane(table); jsp.setAutoscrolls(true); innerCenter.add(jsp, BorderLayout.CENTER); @@ -273,9 +303,7 @@ public class GTCSJHForm extends AbstractRendering { for (int i = 0; i < labellTexts.length; i++) { if (parentProp.containsKey(labellTexts[i])) { String str = parentProp.get(labellTexts[i]); - if ("".equals(str)) { - infoValue[i].setText(str); - } + infoValue[i].setText(str); } else { System.out.println("属性\"" + labellTexts[i] + "\"不存在"); } @@ -357,7 +385,7 @@ public class GTCSJHForm extends AbstractRendering { System.out.println(filePath); System.out.println(fileName); int row = table.getSelectedRow(); - String value = model.getValueAt(row, 14) == null ? "" : model.getValueAt(row, 14).toString(); + String value = model.getValueAt(row, 15) == null ? "" : model.getValueAt(row, 15).toString(); if (value.equals("")) { try { TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("JD2_GTCSBG"); @@ -583,7 +611,7 @@ public class GTCSJHForm extends AbstractRendering { private void addResult(String realNo, int row, int times, String result) { if (resultMap.containsKey(realNo)) { - if (times >= resultMap.get(realNo).getTimes()) { + if (times > resultMap.get(realNo).getTimes()) { disableRows.add(resultMap.get(realNo).getRow()); resultMap.put(realNo, new JG(row, times, result)); } diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java index db9afc8..764bb13 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/NewProductTestForm.java @@ -107,7 +107,7 @@ public class NewProductTestForm extends AbstractRendering { int[][] propLocation1 = { { 0, 1 }, { 0, 3 }, { 1, 1 }, { 1, 3 }, { 2, 1 }, { 2, 3 }, { 3, 1 }, { 3, 3 }, { 4, 1 }, { 4, 3 }, { 5, 1 }, { 5, 3 } }; for (int i = 0; i < propArr.length; i++) { - modelList1.add(new ModelValue(propArr[i], true, propLocation1[0][1], propLocation1[0][1], true)); + modelList1.add(new ModelValue(propArr[i], true, propLocation1[i][0], propLocation1[i][1], true)); } initModel(model1, modelList1); @@ -325,6 +325,7 @@ public class NewProductTestForm extends AbstractRendering { objStr = "0"; } int num = Integer.parseInt(objStr); + System.out.println("值:" + num); if (num < 0) { System.out.println("计算区域只能输入自然数或\"/\""); MessageBox.post("计算区域只能输入自然数或\"/\"", "错误", MessageBox.ERROR); @@ -352,21 +353,22 @@ public class NewProductTestForm extends AbstractRendering { } table.setValueAt(sum, table.getRowCount() - 1, col); double sum1 = Double - .parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 4)) == null ? "0" - : sumObj.toString().trim()); + .parseDouble(((sumObj = table.getValueAt(table.getRowCount() - 1, 4)) == null + || "".equals(sumObj.toString().trim())) ? "0" : sumObj.toString().trim()); double sum2 = Double - .parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 5)) == null ? "0" - : sumObj.toString().trim()); + .parseDouble(((sumObj = table.getValueAt(table.getRowCount() - 1, 5)) == null + || "".equals(sumObj.toString().trim())) ? "0" : sumObj.toString().trim()); double sum3 = Double - .parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 6)) == null ? "0" - : sumObj.toString().trim()); + .parseDouble(((sumObj = table.getValueAt(table.getRowCount() - 1, 6)) == null + || "".equals(sumObj.toString().trim())) ? "0" : sumObj.toString().trim()); double sum4 = Double - .parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 7)) == null ? "0" - : sumObj.toString().trim()); + .parseDouble(((sumObj = table.getValueAt(table.getRowCount() - 1, 7)) == null + || "".equals(sumObj.toString().trim())) ? "0" : sumObj.toString().trim()); table.setValueAt(sum1 + sum2 + sum3 + sum4, table.getRowCount() - 1, 3); table2.revalidate(); table2.repaint(); } catch (NumberFormatException e1) { + e1.printStackTrace(); System.out.println("计算区域只能输入自然数或\"/\""); MessageBox.post("计算区域只能输入自然数或\"/\"", "错误", MessageBox.ERROR); obj = "/"; @@ -518,7 +520,7 @@ public class NewProductTestForm extends AbstractRendering { try { AIFComponentContext[] comps = form.whereReferenced(); StringBuilder msg = new StringBuilder(); - A1: for (AIFComponentContext aif : comps) { + for (AIFComponentContext aif : comps) { System.out.println("ref type:" + aif.getComponent().getType()); if ("JD2_GTXPCSXQDRevision".equals(aif.getComponent().getType())) { TCComponentItemRevision rev = (TCComponentItemRevision) aif.getComponent(); @@ -531,9 +533,9 @@ public class NewProductTestForm extends AbstractRendering { String ownner = form.getTCProperty("owning_user").getUIFValue(); for (int i = 0; i < 4; i++) { if (exist.contains(jieduan[i])) { - System.out.println("已存在阶段\"" + jieduan[i] + "\"测试计划,请检查!"); - MessageBox.post("已存在阶段\"" + jieduan[i] + "\"测试计划,请检查!", "错误", MessageBox.ERROR); - break A1; + System.out.println("\"" + jieduan[i] + "阶段\"测试计划已创建"); + msg.append("\"" + jieduan[i] + "阶段\"测试计划已创建\n"); + continue; } Object obj; Object temp; @@ -569,7 +571,7 @@ public class NewProductTestForm extends AbstractRendering { System.out.println(Arrays.deepToString(dataArr)); TCTableUtil.setTableRows(form1, "jd2_csjhtable", "JD2_CSJHTABLE", colNames2, dataArr); - msg.append(jieduan[i] + "阶段测试计划创建成功\n"); + msg.append("\"" + jieduan[i] + "阶段\"测试计划创建成功\n"); } colData.clear(); } From 1260a85868ccdd0bdd1965b7a3e728841e6224a9 Mon Sep 17 00:00:00 2001 From: zouxk Date: Wed, 18 Mar 2020 14:45:14 +0800 Subject: [PATCH 12/12] 3/18 --- .../jd/plm/action/WLTZReviseAction.java | 6 +- .../jd/plm/dialog/DocumentTemplate.java | 39 +++++ .../plm/dialog/EditClassificationDialog.java | 3 + .../jd/plm/form/SampleConfirmationForm.java | 161 ++++++++++++++++-- .../com/connor/jd/plm/table/MyCellEditor.java | 9 + .../connor/jd/plm/table/MyCellEditor2.java | 10 ++ 6 files changed, 214 insertions(+), 14 deletions(-) create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/dialog/DocumentTemplate.java diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java b/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java index ffcfac1..02ddfb6 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java @@ -19,8 +19,6 @@ import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.ics.ICSProperty; import com.teamcenter.rac.util.MessageBox; -import cn.hutool.http.HttpUtil; - public class WLTZReviseAction extends AbstractAIFAction { private AbstractAIFApplication app; private TCSession session; @@ -51,7 +49,9 @@ public class WLTZReviseAction extends AbstractAIFAction { return; } TCComponentItem item = rev.getItem(); + session.getUserService().call("bs_bypass", new Object[] { true }); TCComponentItemRevision newRev = rev.saveAs(item.getNewRev()); + session.getUserService().call("bs_bypass", new Object[] { false }); TCComponentICO ico = rev.getClassificationObjects()[0]; ICSProperty[] oldICSProps = ico.getICSProperties(true); int[] ids = new int[oldICSProps.length]; @@ -88,7 +88,7 @@ public class WLTZReviseAction extends AbstractAIFAction { @Override public void run() { // TODO Auto-generated method stub - HttpUtil.post(URL, PARAMMAP); + cn.hutool.http.HttpUtil.post(URL, PARAMMAP); System.out.println("success"); } }).start(); diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/DocumentTemplate.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/DocumentTemplate.java new file mode 100644 index 0000000..60a256a --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/DocumentTemplate.java @@ -0,0 +1,39 @@ +package com.connor.jd.plm.dialog; + +public class DocumentTemplate { + private String type;// 模板类型 + private String[] relation;// 数据集关系 + private String uid;// 模板uid + + public DocumentTemplate(String type, String uid, String[] relation) { + super(); + this.type = type; + this.relation = relation; + this.uid = uid; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String[] getRelation() { + return relation; + } + + public void setRelation(String[] relation) { + this.relation = relation; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java index 372419d..76f3a88 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java @@ -52,6 +52,9 @@ public class EditClassificationDialog extends AbstractAIFDialog { this.session = (TCSession) app.getSession(); this.myService = session.getClassificationService(); this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + System.out.println(target.getType()); + System.out.println(target instanceof TCComponentItemRevision ? "是" : "否"); + if (target instanceof TCComponentItemRevision) { try { initUI(); diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index 7d8d4b5..dd0a7df 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -23,6 +23,7 @@ import java.util.Map.Entry; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JMenuItem; @@ -31,6 +32,7 @@ import javax.swing.JPopupMenu; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; import javax.swing.filechooser.FileFilter; import javax.swing.table.DefaultTableCellRenderer; @@ -86,6 +88,10 @@ public class SampleConfirmationForm extends AbstractRendering { private List disableEdit2; private JRadioPanel yssl; private JCheckPanel mqjd; + private JComboBox bpdj; + private JComboBox fl; + private JComboBox zt; + private JComboBox jued; private String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", "jd2_1", "jd2_2", "jd2_3", "jd2_4", "jd2_5", "jd2_6", "jd2_7", "jd2_8", "jd2_9", "jd2_10", "jd2_min", "jd2_max", "jd2_jg" }; private String[] colNames1 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", @@ -94,6 +100,7 @@ public class SampleConfirmationForm extends AbstractRendering { "jd2_ctq7", "jd2_ctq8" }; private String[] colNames3 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", "jd2_ctq8" }; + private Map jgItems = new HashMap(); private JMenuItem addP; private JMenuItem delP; private JMenuItem addR; @@ -102,6 +109,7 @@ public class SampleConfirmationForm extends AbstractRendering { private JMenuItem addR2; private JMenuItem insertR2; private JMenuItem delR2; + private TCComponentItemRevision rev; public SampleConfirmationForm(TCComponent arg0) throws Exception { super(arg0); @@ -115,9 +123,17 @@ public class SampleConfirmationForm extends AbstractRendering { @Override public void loadRendering() throws TCException { + jgItems.put("合格", "0"); + jgItems.put("拒绝", "1"); + jgItems.put("保留", "2"); + jgItems.put("更改图纸", "3"); + AIFComponentContext[] ref = form.whereReferenced(); + rev = (TCComponentItemRevision) ref[0].getComponent(); + setLayout(new BorderLayout()); JPanel root = new JPanel(new BorderLayout()); root.setPreferredSize(new Dimension(800, 600)); + root.setBorder(new EmptyBorder(0, 0, 0, 25)); // 头部 JPanel buttons = new JPanel(new FlowLayout(FlowLayout.LEFT)); JButton confirm = new JButton("样品确认单"); @@ -173,6 +189,9 @@ public class SampleConfirmationForm extends AbstractRendering { if (value instanceof JPanel) { return (JPanel) value; } + if (value instanceof JComboBox) { + return (JComboBox) value; + } int maxPreferredHeight = 0; for (int i = 0; i < table.getColumnCount(); i++) { @@ -237,6 +256,9 @@ public class SampleConfirmationForm extends AbstractRendering { if (value instanceof JLabel) { return (JLabel) value; } + if (value instanceof JComboBox) { + return (JComboBox) value; + } int maxPreferredHeight = 0; for (int i = 0; i < table.getColumnCount(); i++) { @@ -348,6 +370,7 @@ public class SampleConfirmationForm extends AbstractRendering { if (prop.containsKey("jd2_ypqrdtable")) { String[][] tableRows = TCTableUtil.getTableRows(form, "jd2_ypqrdtable", colNames); System.out.println(Arrays.deepToString(tableRows)); + for (int i = 0; i < tableRows.length; i++) { for (int ii = 0; ii < tableRows[0].length; ii++) { if (i + top + 2 > bottom) { @@ -357,7 +380,16 @@ public class SampleConfirmationForm extends AbstractRendering { model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); bottom = model.getRowCount() - end; } - model.setValueAt(tableRows[i][ii], i + top + 2, ii > 2 ? ii + 2 : ii); + if (ii == tableRows[0].length - 1) { + JComboBox jgComBox = new JComboBox(); + for (Entry entry : jgItems.entrySet()) { + jgComBox.addItem(entry.getKey()); + } + jgComBox.setSelectedItem(tableRows[i][ii]); + model.setValueAt(jgComBox, i + top + 2, ii + 2); + } else { + model.setValueAt(tableRows[i][ii], i + top + 2, ii > 2 ? ii + 2 : ii); + } } } } else { @@ -618,7 +650,18 @@ public class SampleConfirmationForm extends AbstractRendering { general.put("jd2_xh", new int[] { 6, 10 }); model.setValueAt("分类", 6, 14); disableEdit.add("6,14"); - general.put("jd2_fl", new int[] { 6, 17 }); + fl = new JComboBox(); + try { + String[] items = form.getTCProperty("jd2_fl").getLOV().getListOfValues().getLOVDisplayValues(); + for (String s : items) { + fl.addItem(s); + } + fl.setSelectedItem(form.getProperty("jd2_fl")); + model.setValueAt(fl, 6, 17); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } model.setValueAt("物料编码", 7, 0); disableEdit.add("7,0"); general.put("jd2_wlbm", new int[] { 7, 2 }); @@ -628,10 +671,32 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt(yssl, 7, 10); model.setValueAt("状态", 7, 14); disableEdit.add("7,14"); - general.put("jd2_zt", new int[] { 7, 17 }); + zt = new JComboBox(); + try { + String[] items = form.getTCProperty("jd2_zt").getLOV().getListOfValues().getLOVDisplayValues(); + for (String s : items) { + zt.addItem(s); + } + zt.setSelectedItem(form.getProperty("jd2_zt")); + model.setValueAt(zt, 7, 17); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } model.setValueAt("部品等级", 8, 0); disableEdit.add("8,0"); - general.put("jd2_bpdj", new int[] { 8, 2 }); + bpdj = new JComboBox(); + try { + String[] items = form.getTCProperty("jd2_bpdj").getLOV().getListOfValues().getLOVDisplayValues(); + for (String s : items) { + bpdj.addItem(s); + } + bpdj.setSelectedItem(form.getProperty("jd2_bpdj")); + model.setValueAt(bpdj, 8, 2); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } model.setValueAt("参考物料", 8, 8); disableEdit.add("8,8"); model.setValueAt("jd2_ckwl", 8, 10); @@ -678,6 +743,11 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt(i - 1 - top, i, 0); disableEdit.add(i + ",0"); model.combine(new int[] { i }, new int[] { 2, 3, 4 }); + JComboBox jgComBox = new JComboBox(); + for (Entry entry : jgItems.entrySet()) { + jgComBox.addItem(entry.getKey()); + } + model.setValueAt(jgComBox, i, model.getColumnCount() - 1); } model.combine(new int[] { 0, 1 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); @@ -800,7 +870,18 @@ public class SampleConfirmationForm extends AbstractRendering { pic.put("jd2_icqjyzds", new int[] { 10, 4 }); model3.setValueAt("决定", 11, 12); disableEdit3.add(11 + ",12"); - general3.put("jd2_jued", new int[] { 11, 15 }); + jued = new JComboBox(); + try { + String[] items = form.getTCProperty("jd2_jued").getLOV().getListOfValues().getLOVDisplayValues(); + for (String s : items) { + jued.addItem(s); + } + jued.setSelectedItem(form.getProperty("jd2_jued")); + model3.setValueAt(jued, 11, 15); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } pic.put("jd2_qtbg", new int[] { 9, 7 }); model3.combine(new int[] { 0 }, new int[] { 0, 1, 2, 3, 4, 5 }); @@ -873,6 +954,34 @@ public class SampleConfirmationForm extends AbstractRendering { } form.setProperty("jd2_mqjd", value); } + if (prop.containsKey("jd2_bpdj")) { + String value = bpdj.getSelectedItem() == null ? "" : bpdj.getSelectedItem().toString(); + if (form.getTCProperty("jd2_bpdj").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_bpdj").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_bpdj", value); + } + if (prop.containsKey("jd2_fl")) { + String value = fl.getSelectedItem() == null ? "" : fl.getSelectedItem().toString(); + if (form.getTCProperty("jd2_fl").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_fl").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_fl", value); + } + if (prop.containsKey("jd2_zt")) { + String value = zt.getSelectedItem() == null ? "" : zt.getSelectedItem().toString(); + if (form.getTCProperty("jd2_zt").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_zt").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_zt", value); + } + if (prop.containsKey("jd2_jued")) { + String value = jued.getSelectedItem() == null ? "" : jued.getSelectedItem().toString(); + if (form.getTCProperty("jd2_jued").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_jued").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_jued", value); + } } catch (TCException e) { // TODO Auto-generated catch block @@ -919,10 +1028,11 @@ public class SampleConfirmationForm extends AbstractRendering { String[] row = new String[18]; for (int ii = 0; ii < row.length; ii++) { Object object = model.getValueAt(top + 2 + num, ii > 2 ? ii + 2 : ii); - if (object == null) { - row[ii] = ""; + if (ii == row.length - 1) { + object = ((JComboBox) object).getSelectedItem(); + row[ii] = object == null ? "" : jgItems.get(object.toString()); } else { - row[ii] = object.toString(); + row[ii] = object == null ? "" : object.toString(); } } data.add(row); @@ -1123,14 +1233,23 @@ public class SampleConfirmationForm extends AbstractRendering { TCComponentDataset dataset = datasetType.create(file.getName(), "", "Image"); dataset.setFiles(as1, as2); TCComponent[] comps = form.getRelatedComponents(); - AIFComponentContext[] ref = form.whereReferenced(); - TCComponentItemRevision rev = (TCComponentItemRevision) ref[0].getComponent(); rev.add("IMAN_specification", dataset); String uid = dataset.getUid(); System.out.println("uid:" + uid); ImageIcon icon = new ImageIcon(file.getPath()); int row = table3.getSelectedRow(); int col = table3.getSelectedColumn(); + String str = ((JLabel) model3.getValueAt(row, col)).getToolTipText(); + if (str != null && !"".equals(str)) { + try { + TCComponentDataset oldDataset = (TCComponentDataset) session.stringToComponent(str); + rev.cutOperation("IMAN_specification", new TCComponent[] { oldDataset }); + oldDataset.delete(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } int[] arr = model3.getSpan(row, col); System.out.println("row:" + arr[0] + ",col:" + arr[1]); icon.setImage(icon.getImage().getScaledInstance( @@ -1142,6 +1261,8 @@ public class SampleConfirmationForm extends AbstractRendering { label.addMouseListener(showImg(file.getPath())); label.setToolTipText(uid); model3.setValueAt(label, table3.getSelectedRow(), table3.getSelectedColumn()); + table3.revalidate(); + table3.repaint(); } catch (TCException e1) { // TODO Auto-generated catch block e1.printStackTrace(); @@ -1161,7 +1282,20 @@ public class SampleConfirmationForm extends AbstractRendering { // TODO Auto-generated method stub int row = table3.getSelectedRow(); int col = table3.getSelectedColumn(); + String uid = ((JLabel) model3.getValueAt(row, col)).getToolTipText(); + if (uid != null && !"".equals(uid)) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(uid); + rev.cutOperation("IMAN_specification", new TCComponent[] { dataset }); + dataset.delete(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } model3.setValueAt(new JLabel(""), row, col); + table3.revalidate(); + table3.repaint(); } }; @@ -1183,7 +1317,6 @@ public class SampleConfirmationForm extends AbstractRendering { // initModel(); table.revalidate(); table.repaint(); - } }; return actionListener; @@ -1199,6 +1332,8 @@ public class SampleConfirmationForm extends AbstractRendering { model2.insertRow(++bottom2); model2.setValueAt(num + 1, bottom2, 0); model2.combine(new int[] { bottom2 }, new int[] { 0, 1 }); + table2.revalidate(); + table2.repaint(); } }; return actionListener; @@ -1242,6 +1377,8 @@ public class SampleConfirmationForm extends AbstractRendering { model2.setValueAt(num + i - row, i, 0); } model2.combine(new int[] { row }, new int[] { 0, 1 }); + table2.revalidate(); + table2.repaint(); } }; return actionListener; @@ -1287,6 +1424,8 @@ public class SampleConfirmationForm extends AbstractRendering { model2.setValueAt(num + i - row, i, 0); } } + table2.revalidate(); + table2.repaint(); } }; return actionListener; diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java index badae70..241a37f 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java @@ -3,6 +3,7 @@ package com.connor.jd.plm.table; import java.awt.Component; import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; import javax.swing.JTable; import javax.swing.JTextField; @@ -11,6 +12,7 @@ import com.teamcenter.rac.util.MessageBox; public class MyCellEditor extends DefaultCellEditor { private JRadioPanel radio = null; private JCheckPanel check = null; + private JComboBox comboBox = null; private int type = -1; private int row; private int col; @@ -42,6 +44,10 @@ public class MyCellEditor extends DefaultCellEditor { check = (JCheckPanel) value; type = 2; return check; + } else if (value instanceof JComboBox) { + comboBox = (JComboBox) value; + type = 3; + return comboBox; } this.row = row; this.col = column; @@ -59,6 +65,9 @@ public class MyCellEditor extends DefaultCellEditor { if (type == 2) { return check; } + if (type == 3) { + return comboBox; + } Object obj = super.getCellEditorValue(); if (obj != null && !"".equals(obj.toString().trim()) && row >= top && row <= bottom && col >= 7 diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java index c4774b3..ccdef61 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java @@ -3,12 +3,14 @@ package com.connor.jd.plm.table; import java.awt.Component; import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.JTextField; public class MyCellEditor2 extends DefaultCellEditor { private JLabel img = null; + private JComboBox jued = null; private int type = -1; public MyCellEditor2(JTextField var1) { @@ -23,6 +25,11 @@ public class MyCellEditor2 extends DefaultCellEditor { type = 1; return img; } + if (value instanceof JComboBox) { + jued = (JComboBox) value; + type = 2; + return jued; + } type = 0; return super.getTableCellEditorComponent(table, value, isSelected, row, column); } @@ -32,6 +39,9 @@ public class MyCellEditor2 extends DefaultCellEditor { if (type == 1) { return img; } + if (type == 2) { + return jued; + } return super.getCellEditorValue(); }