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