样品确认单基本完成

main
zouxk 6 years ago
parent 86a546e814
commit 415a949fb8

File diff suppressed because it is too large Load Diff

@ -22,7 +22,7 @@ Export-Package: com.connor.jd.plm.action,
com.connor.jd.plm.handlers, com.connor.jd.plm.handlers,
com.connor.jd.plm.table, com.connor.jd.plm.table,
com.connor.jd.plm.util, com.connor.jd.plm.util,
com.teamcenter.rac.form com.teamcenter.rac.stylesheet
Import-Package: com.teamcenter.services, Import-Package: com.teamcenter.services,
com.teamcenter.services.rac, com.teamcenter.services.rac,
com.teamcenter.services.rac.core, com.teamcenter.services.rac.core,

@ -0,0 +1,8 @@
public class Test {
public static void main(String[] args) {
}
}

@ -151,9 +151,11 @@ public class EditClassificationDialog extends AbstractAIFDialog {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
TCComponentItemRevision rev = (TCComponentItemRevision) target; TCComponentItemRevision rev = (TCComponentItemRevision) target;
saveClassification(rev); saveClassification(rev);
try { 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"); TCComponent[] comps = rev.getReferenceListProperty("TC_Is_Represented_By");
System.out.println(comps.length); System.out.println(comps.length);
for (int i = 0; i < comps.length; i++) { for (int i = 0; i < comps.length; i++) {

@ -39,6 +39,7 @@ import com.connor.jd.plm.table.CTable;
import com.connor.jd.plm.table.JCheckPanel; import com.connor.jd.plm.table.JCheckPanel;
import com.connor.jd.plm.table.JRadioPanel; import com.connor.jd.plm.table.JRadioPanel;
import com.connor.jd.plm.table.MyCellEditor; import com.connor.jd.plm.table.MyCellEditor;
import com.connor.jd.plm.table.MyCellEditor1;
import com.connor.jd.plm.table.TCTableUtil; import com.connor.jd.plm.table.TCTableUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.AIFComponentContext;
@ -80,9 +81,14 @@ public class SampleConfirmationForm extends AbstractRendering {
private List<String> disableEdit2; private List<String> disableEdit2;
private JRadioPanel sysl; private JRadioPanel sysl;
private JCheckPanel mqjd; private JCheckPanel mqjd;
String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", "jd2_1", "jd2_2", "jd2_3", "jd2_4",
"jd2_1", "jd2_2", "jd2_3", "jd2_4", "jd2_5", "jd2_6", "jd2_7", "jd2_5", "jd2_6", "jd2_7", "jd2_8", "jd2_9", "jd2_10", "jd2_min", "jd2_max", "jd2_jg" };
"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 { public SampleConfirmationForm(TCComponent arg0) throws Exception {
super(arg0); super(arg0);
@ -195,8 +201,7 @@ public class SampleConfirmationForm extends AbstractRendering {
general.put("jd2_syyy", new int[] { 9, 10 }); general.put("jd2_syyy", new int[] { 9, 10 });
model.setValueAt("目前阶段", 12, 0); model.setValueAt("目前阶段", 12, 0);
disableEdit.add("12,0"); disableEdit.add("12,0");
mqjd = new JCheckPanel( mqjd = new JCheckPanel(new String[] { "DV", "PV", "PR", "SR", "ÏÖ³¡²âÊÔ", "MP" });
new String[] { "DV", "PV", "PR", "SR", "ÏÖ³¡²âÊÔ", "MP" });
model.setValueAt(mqjd, 12, 2); model.setValueAt(mqjd, 12, 2);
model.setValueAt("No", top, 0); model.setValueAt("No", top, 0);
@ -294,22 +299,19 @@ public class SampleConfirmationForm extends AbstractRendering {
pic.put("jd2_qtbg", new int[] { bottom + 10, 7 }); pic.put("jd2_qtbg", new int[] { bottom + 10, 7 });
// 合并单元格 // 合并单元格
model.combine(new int[] { 0, 1 }, model.combine(new int[] { 0, 1 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
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[] { 14, 15 });
model.combine(new int[] { 0, 1 }, new int[] { 16, 17 }); model.combine(new int[] { 0, 1 }, new int[] { 16, 17 });
model.combine(new int[] { 0, 1 }, new int[] { 18, 19 }); 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[] { 0, 1 });
model.combine(new int[] { 2, 3 }, model.combine(new int[] { 2, 3 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
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[] { 14, 15 });
model.combine(new int[] { 2, 3 }, new int[] { 16, 17 }); model.combine(new int[] { 2, 3 }, new int[] { 16, 17 });
model.combine(new int[] { 2, 3 }, new int[] { 18, 19 }); 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[] { 0, 1 });
model.combine(new int[] { 4, 5 }, new int[] { 2, 3, 4 }); 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[] { 5, 6 });
model.combine(new int[] { 4, 5 }, model.combine(new int[] { 4, 5 }, new int[] { 7, 8, 9, 10, 11, 12, 13 });
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[] { 14, 15 });
model.combine(new int[] { 4, 5 }, new int[] { 16, 17 }); model.combine(new int[] { 4, 5 }, new int[] { 16, 17 });
model.combine(new int[] { 4, 5 }, new int[] { 18, 19 }); 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[] { 0, 1 });
model.combine(new int[] { 8 }, new int[] { 2, 3, 4, 5, 6, 7 }); 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[] { 8, 9 });
model.combine(new int[] { 8 }, model.combine(new int[] { 8 }, new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 });
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[] { 0, 1 });
model.combine(new int[] { 9 }, new int[] { 2, 3, 4, 5, 6, 7 }); 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[] { 8, 9 });
model.combine(new int[] { 9, 10, 11 }, model.combine(new int[] { 9, 10, 11 }, new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 });
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[] { 0, 1 });
model.combine(new int[] { 10 }, new int[] { 2, 3, 4, 5, 6, 7 }); 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[] { 0, 1 });
model.combine(new int[] { 11 }, new int[] { 2, 3, 4, 5, 6, 7 }); 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[] { 0, 1 });
model.combine(new int[] { 12 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 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 });
11, 12, 13, 14, 15, 16, 17, 18, 19 });
model.combine(new int[] { top, 1 }, new int[] { 0 }); 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[] { 1, 2, 3, 4, 5, 6 });
model.combine(new int[] { top }, model.combine(new int[] { top }, new int[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 });
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, 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[] { 1, 2, 3, 4 });
model.combine(new int[] { top + 1 }, new int[] { 5, 6 }); 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 + 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[] { 0, 1 });
model.combine(new int[] { bottom + 2 }, new int[] { 2, 3 }); model.combine(new int[] { bottom + 2 }, new int[] { 2, 3 });
model.combine( model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6, bottom + 7, bottom + 8, bottom + 9,
new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6, bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 0, 1, 2, 3 });
bottom + 7, bottom + 8, bottom + 9, bottom + 10, model.combine(new int[] { bottom + 2, bottom + 3, bottom + 4, bottom + 5 }, new int[] { 4 });
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[] { 9, 10, 11 });
model.combine(new int[] { bottom + 2 }, new int[] { 12, 13, 14 }); 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[] { 15, 16, 17 });
model.combine(new int[] { bottom + 2 }, new int[] { 18, 19 }); 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 + 4, bottom + 5 }, new int[] { 7, 8 });
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 9, 10, 11 });
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 }, model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 15, 16, 17 });
new int[] { 12, 13, 14 }); 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[] { 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 + 6, bottom + 7 }, new int[] { 4 });
model.combine(new int[] { bottom + 8, bottom + 9 }, 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 + 6, bottom + 7 }, new int[] { 5 });
model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 5 }); model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 5 });
model.combine( model.combine(new int[] { bottom + 6, bottom + 7, bottom + 8, bottom + 9 }, new int[] { 6 });
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[] { 7, 8 });
model.combine(new int[] { bottom + 6 }, new int[] { 9, 10, 11 }); 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[] { 12, 13, 14 });
model.combine(new int[] { bottom + 6 }, new int[] { 15, 16, 17 }); 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 + 6 }, new int[] { 18, 19 });
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 7, 8 });
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 }, model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 12, 13, 14 });
new int[] { 9, 10, 11 }); 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 }, model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 18, 19 });
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 + 10 }, new int[] { 4, 5, 6 });
model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 }, model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 }, new int[] { 4, 5, 6 });
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, bottom + 12, model.combine(new int[] { bottom + 10, bottom + 11 }, new int[] { 12, 13, 14, 15, 16, 17, 18, 19 });
bottom + 13 }, new int[] { 7, 8, 9, 10, 11 }); model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 12, 13, 14 });
model.combine(new int[] { bottom + 10, bottom + 11 }, model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 15, 16, 17, 18, 19 });
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) { table = new CTable(model) {
@Override @Override
@ -429,14 +406,12 @@ public class SampleConfirmationForm extends AbstractRendering {
for (int i = 7; i < model.getColumnCount() - 1; i++) { for (int i = 7; i < model.getColumnCount() - 1; i++) {
table.getColumnModel().getColumn(i).setPreferredWidth(45); table.getColumnModel().getColumn(i).setPreferredWidth(45);
} }
table.getColumnModel().getColumn(model.getColumnCount() - 1) table.getColumnModel().getColumn(model.getColumnCount() - 1).setPreferredWidth(80);
.setPreferredWidth(80);
DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() { DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() {
// 重写方法 // 重写方法
@Override @Override
public Component getTableCellRendererComponent(JTable table, public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
Object value, boolean isSelected, boolean hasFocus, int row, boolean hasFocus, int row, int column) {
int column) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
if (value instanceof JLabel) { if (value instanceof JLabel) {
@ -450,10 +425,8 @@ public class SampleConfirmationForm extends AbstractRendering {
int maxPreferredHeight = 0; int maxPreferredHeight = 0;
for (int i = 0; i < table.getColumnCount(); i++) { for (int i = 0; i < table.getColumnCount(); i++) {
setText("" + table.getValueAt(row, i)); setText("" + table.getValueAt(row, i));
setSize(table.getColumnModel().getColumn(column).getWidth(), setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
0); maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
maxPreferredHeight = Math.max(maxPreferredHeight,
getPreferredSize().height);
} }
setBackground(Color.white); setBackground(Color.white);
// if(points1.contains(new Point(row,column))) // if(points1.contains(new Point(row,column)))
@ -474,8 +447,7 @@ public class SampleConfirmationForm extends AbstractRendering {
tcr1.setHorizontalAlignment(SwingConstants.CENTER); tcr1.setHorizontalAlignment(SwingConstants.CENTER);
table.setDefaultRenderer(Object.class, tcr1); table.setDefaultRenderer(Object.class, tcr1);
for (int i = 0; i < model.getColumnCount(); i++) { for (int i = 0; i < model.getColumnCount(); i++) {
table.getColumnModel().getColumn(i) table.getColumnModel().getColumn(i).setCellEditor(new MyCellEditor(new JTextField()));
.setCellEditor(new MyCellEditor(new JTextField()));
} }
table.addMouseListener(rightClick()); table.addMouseListener(rightClick());
confirmPanel.add(table, BorderLayout.CENTER); confirmPanel.add(table, BorderLayout.CENTER);
@ -484,11 +456,9 @@ public class SampleConfirmationForm extends AbstractRendering {
prop = form.getProperties(); prop = form.getProperties();
for (Entry<String, int[]> entry : general.entrySet()) { for (Entry<String, int[]> entry : general.entrySet()) {
if (prop.containsKey(entry.getKey())) { if (prop.containsKey(entry.getKey())) {
model.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], model.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]);
entry.getValue()[1]);
} else { } else {
model.setValueAt(entry.getKey(), entry.getValue()[0], model.setValueAt(entry.getKey(), entry.getValue()[0], entry.getValue()[1]);
entry.getValue()[1]);
System.out.println("属性‘" + entry.getKey() + "’未找到"); System.out.println("属性‘" + entry.getKey() + "’未找到");
} }
} }
@ -509,11 +479,9 @@ public class SampleConfirmationForm extends AbstractRendering {
TCComponentDataset dataset = (TCComponentDataset) comp; TCComponentDataset dataset = (TCComponentDataset) comp;
String temp = System.getenv("temp"); String temp = System.getenv("temp");
System.out.println(temp); System.out.println(temp);
String[] types = dataset.getProperty("ref_names") String[] types = dataset.getProperty("ref_names").split(",");
.split(",");
System.out.println(Arrays.toString(types)); System.out.println(Arrays.toString(types));
System.out.println(Arrays System.out.println(Arrays.toString(dataset.getFileNames(types[0])));
.toString(dataset.getFileNames(types[0])));
File img = dataset.getFiles(types[0], temp)[0]; File img = dataset.getFiles(types[0], temp)[0];
System.out.println(img.getPath()); System.out.println(img.getPath());
@ -527,10 +495,8 @@ public class SampleConfirmationForm extends AbstractRendering {
} }
System.out.println("row:" + arr[0] + ",col:" + arr[1]); System.out.println("row:" + arr[0] + ",col:" + arr[1]);
icon.setImage(icon.getImage().getScaledInstance( icon.setImage(icon.getImage().getScaledInstance(
table.getColumnModel().getColumn(col) table.getColumnModel().getColumn(col).getPreferredWidth() * arr[1],
.getPreferredWidth() * arr[1], table.getRowHeight() * arr[0], Image.SCALE_SMOOTH));
table.getRowHeight() * arr[0],
Image.SCALE_SMOOTH));
JLabel label = new JLabel(); JLabel label = new JLabel();
label.setLayout(new FlowLayout(FlowLayout.CENTER)); label.setLayout(new FlowLayout(FlowLayout.CENTER));
label.setIcon(icon); label.setIcon(icon);
@ -543,28 +509,23 @@ public class SampleConfirmationForm extends AbstractRendering {
} }
} else { } else {
model.setValueAt(new JLabel(entry.getKey()), model.setValueAt(new JLabel(entry.getKey()), entry.getValue()[0], entry.getValue()[1]);
entry.getValue()[0], entry.getValue()[1]);
System.out.println("属性‘" + entry.getKey() + "’未找到"); System.out.println("属性‘" + entry.getKey() + "’未找到");
} }
} }
if (prop.containsKey("jd2_ypqrdtable")) { if (prop.containsKey("jd2_ypqrdtable")) {
String[][] tableRows = TCTableUtil.getTableRows(form, String[][] tableRows = TCTableUtil.getTableRows(form, "jd2_ypqrdtable", colNames);
"jd2_ypqrdtable", colNames);
System.out.println(Arrays.deepToString(tableRows)); System.out.println(Arrays.deepToString(tableRows));
for (int i = 0; i < tableRows.length; i++) { for (int i = 0; i < tableRows.length; i++) {
for (int ii = 0; ii < tableRows[0].length; ii++) { for (int ii = 0; ii < tableRows[0].length; ii++) {
if (i + top + 2 > bottom) { if (i + top + 2 > bottom) {
int num = Integer.parseInt( int num = Integer.parseInt(model.getValueAt(bottom, 0).toString());
model.getValueAt(bottom, 0).toString());
model.insertRow(bottom); model.insertRow(bottom);
model.setValueAt(num + 1, bottom, 0); model.setValueAt(num + 1, bottom, 0);
model.combine(new int[] { bottom }, model.combine(new int[] { bottom }, new int[] { 2, 3, 4 });
new int[] { 2, 3, 4 });
bottom = model.getRowCount() - end; bottom = model.getRowCount() - end;
} }
model.setValueAt(tableRows[i][ii], i + top + 2, model.setValueAt(tableRows[i][ii], i + top + 2, ii > 2 ? ii + 2 : ii);
ii > 2 ? ii + 2 : ii);
} }
} }
} }
@ -577,6 +538,7 @@ public class SampleConfirmationForm extends AbstractRendering {
model2 = new CTMap(49, 10); model2 = new CTMap(49, 10);
bottom2 = model2.getRowCount() - end2; bottom2 = model2.getRowCount() - end2;
disableEdit2 = new ArrayList<String>();
model2.setValueAt("SPL No", 0, 0); model2.setValueAt("SPL No", 0, 0);
disableEdit2.add("0,0"); disableEdit2.add("0,0");
model2.combine(new int[] { 0, 1, 2, 3 }, new int[] { 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"); disableEdit2.add("0,1");
model2.combine(new int[] { 0, 1 }, new int[] { 1 }); model2.combine(new int[] { 0, 1 }, new int[] { 1 });
for (int i = 0; i < 8; i++) { 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)); disableEdit2.add("0," + (i + 2));
} }
model2.setValueAt("LOW", 2, 1); model2.setValueAt("LOW", 2, 1);
@ -592,8 +554,8 @@ public class SampleConfirmationForm extends AbstractRendering {
model2.setValueAt("UP", 3, 1); model2.setValueAt("UP", 3, 1);
disableEdit2.add("3,1"); disableEdit2.add("3,1");
for (int i = top2; i <= model2.getRowCount(); i++) { for (int i = top2; i < model2.getRowCount(); i++) {
model2.setValueAt(i - top2, i, 0); model2.setValueAt(i - top2 + 1, i, 0);
disableEdit2.add(i + ",0"); disableEdit2.add(i + ",0");
model2.combine(new int[] { i }, new int[] { 0, 1 }); model2.combine(new int[] { i }, new int[] { 0, 1 });
} }
@ -614,6 +576,11 @@ public class SampleConfirmationForm extends AbstractRendering {
model2.setValueAt("工程能力意义", bottom + 15, 0); model2.setValueAt("工程能力意义", bottom + 15, 0);
table2 = new CTable(model2) { table2 = new CTable(model2) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override @Override
public boolean isCellEditable(int row, int col) { public boolean isCellEditable(int row, int col) {
if (isEditorDisable(disableEdit2, row, col)) { if (isEditorDisable(disableEdit2, row, col)) {
@ -624,23 +591,20 @@ public class SampleConfirmationForm extends AbstractRendering {
}; };
table2.setRowHeight(25); table2.setRowHeight(25);
table2.setBorder(BorderFactory.createLineBorder(Color.black)); 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); table2.getColumnModel().getColumn(i).setPreferredWidth(80);
} }
DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() { DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() {
// 重写方法 // 重写方法
@Override @Override
public Component getTableCellRendererComponent(JTable table, public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
Object value, boolean isSelected, boolean hasFocus, int row, boolean hasFocus, int row, int column) {
int column) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
int maxPreferredHeight = 0; int maxPreferredHeight = 0;
for (int i = 0; i < table.getColumnCount(); i++) { for (int i = 0; i < table.getColumnCount(); i++) {
setText("" + table.getValueAt(row, i)); setText("" + table.getValueAt(row, i));
setSize(table.getColumnModel().getColumn(column).getWidth(), setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
0); maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
maxPreferredHeight = Math.max(maxPreferredHeight,
getPreferredSize().height);
} }
setBackground(Color.white); setBackground(Color.white);
// if(points1.contains(new Point(row,column))) // if(points1.contains(new Point(row,column)))
@ -660,8 +624,58 @@ public class SampleConfirmationForm extends AbstractRendering {
}; };
tcr2.setHorizontalAlignment(SwingConstants.CENTER); tcr2.setHorizontalAlignment(SwingConstants.CENTER);
table2.setDefaultRenderer(Object.class, tcr2); 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()); table2.addMouseListener(rightClick2());
examinePanel.add(table2, BorderLayout.CENTER); 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(); ScrollPane examineScrollPanel = new ScrollPane();
examineScrollPanel.add(examinePanel); examineScrollPanel.add(examinePanel);
@ -715,8 +729,7 @@ public class SampleConfirmationForm extends AbstractRendering {
JLabel label = null; JLabel label = null;
for (Entry<String, int[]> entry : pic.entrySet()) { for (Entry<String, int[]> entry : pic.entrySet()) {
if (prop.containsKey(entry.getKey())) { if (prop.containsKey(entry.getKey())) {
label = (JLabel) model.getValueAt(entry.getValue()[0], label = (JLabel) model.getValueAt(entry.getValue()[0], entry.getValue()[1]);
entry.getValue()[1]);
try { try {
form.setProperty(entry.getKey(), label.getToolTipText()); form.setProperty(entry.getKey(), label.getToolTipText());
} catch (TCException e) { } catch (TCException e) {
@ -729,12 +742,10 @@ public class SampleConfirmationForm extends AbstractRendering {
// 保存选择 // 保存选择
try { try {
if (prop.containsKey("jd2_sysl")) { if (prop.containsKey("jd2_sysl")) {
form.setProperty("jd2_sysl", sysl.getSelected() == null ? "" form.setProperty("jd2_sysl", sysl.getSelected() == null ? "" : sysl.getSelected().getText());
: sysl.getSelected().getText());
} }
if (prop.containsKey("jd2_mqjd")) { if (prop.containsKey("jd2_mqjd")) {
form.setProperty("jd2_mqjd", mqjd.getSelectedText() == null ? "" form.setProperty("jd2_mqjd", mqjd.getSelectedText() == null ? "" : mqjd.getSelectedText());
: mqjd.getSelectedText());
} }
} catch (TCException e) { } catch (TCException e) {
@ -746,8 +757,7 @@ public class SampleConfirmationForm extends AbstractRendering {
try { try {
if (prop.containsKey(entry.getKey())) { if (prop.containsKey(entry.getKey())) {
form.setProperty(entry.getKey(), form.setProperty(entry.getKey(),
model.getValueAt(entry.getValue()[0], model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString());
entry.getValue()[1]).toString());
} }
} catch (TCException e) { } catch (TCException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -758,25 +768,91 @@ public class SampleConfirmationForm extends AbstractRendering {
if (prop.containsKey("jd2_ypqrdtable")) { if (prop.containsKey("jd2_ypqrdtable")) {
List<String[]> data = new ArrayList<String[]>(); List<String[]> data = new ArrayList<String[]>();
int num = 0; int num = 0;
while (model.getValueAt(top + 2 + num, 1) != null while (model.getValueAt(top + 2 + num, 1) != null && !"".equals(model.getValueAt(top + 2 + num, 1))) {
&& !"".equals(model.getValueAt(top + 2 + num, 1))) {
String[] row = new String[18]; String[] row = new String[18];
for (int ii = 0; ii < 18; ii++) { for (int ii = 0; ii < row.length; ii++) {
Object object = model.getValueAt(top + 2 + num, Object object = model.getValueAt(top + 2 + num, ii > 2 ? ii + 2 : ii);
ii > 2 ? ii + 2 : ii);
if (object == null) { if (object == null) {
row[ii] = ""; row[ii] = "";
} else { } else {
row[ii] = object.toString(); row[ii] = object.toString();
} }
System.out.println(row[ii]);
} }
data.add(row); data.add(row);
num++; 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<String[]> data = new ArrayList<String[]>();
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<String[]> data = new ArrayList<String[]>();
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<String[]> data = new ArrayList<String[]>();
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()][]); String[][] dataArr = data.toArray(new String[data.size()][]);
System.out.println(Arrays.deepToString(dataArr)); 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() { MouseAdapter mouseAdapter = new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table.getSelectedRow() != -1) {
&& table.getSelectedRow() != -1) {
menu.show(e.getComponent(), e.getX(), e.getY()); menu.show(e.getComponent(), e.getX(), e.getY());
} }
} }
@ -823,8 +898,7 @@ public class SampleConfirmationForm extends AbstractRendering {
MouseAdapter mouseAdapter = new MouseAdapter() { MouseAdapter mouseAdapter = new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table2.getSelectedRow() != -1) {
&& table2.getSelectedRow() != -1) {
menu2.show(e.getComponent(), e.getX(), e.getY()); menu2.show(e.getComponent(), e.getX(), e.getY());
} }
} }
@ -852,10 +926,8 @@ public class SampleConfirmationForm extends AbstractRendering {
@Override @Override
public boolean accept(File var1) { public boolean accept(File var1) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return var1.getName().endsWith(".png") return var1.getName().endsWith(".png") || var1.getName().endsWith(".jpg")
|| var1.getName().endsWith(".jpg") || var1.getName().endsWith(".jpeg") || var1.getName().endsWith(".bmp");
|| var1.getName().endsWith(".jpeg")
|| var1.getName().endsWith(".bmp");
} }
}); });
fileChooser.showOpenDialog(menu);// 参数表示定位 fileChooser.showOpenDialog(menu);// 参数表示定位
@ -866,15 +938,12 @@ public class SampleConfirmationForm extends AbstractRendering {
String as2[] = { "Image" }; String as2[] = { "Image" };
TCComponentDatasetType datasetType; TCComponentDatasetType datasetType;
try { try {
datasetType = (TCComponentDatasetType) session datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset");
.getTypeComponent("Dataset"); TCComponentDataset dataset = datasetType.create(file.getName(), "", "Image");
TCComponentDataset dataset = datasetType
.create(file.getName(), "", "Image");
dataset.setFiles(as1, as2); dataset.setFiles(as1, as2);
TCComponent[] comps = form.getRelatedComponents(); TCComponent[] comps = form.getRelatedComponents();
AIFComponentContext[] ref = form.whereReferenced(); AIFComponentContext[] ref = form.whereReferenced();
TCComponentItemRevision rev = (TCComponentItemRevision) ref[0] TCComponentItemRevision rev = (TCComponentItemRevision) ref[0].getComponent();
.getComponent();
rev.add("IMAN_specification", dataset); rev.add("IMAN_specification", dataset);
String uid = dataset.getUid(); String uid = dataset.getUid();
System.out.println("uid:" + uid); System.out.println("uid:" + uid);
@ -884,17 +953,14 @@ public class SampleConfirmationForm extends AbstractRendering {
int[] arr = model.getSpan(row, col); int[] arr = model.getSpan(row, col);
System.out.println("row:" + arr[0] + ",col:" + arr[1]); System.out.println("row:" + arr[0] + ",col:" + arr[1]);
icon.setImage(icon.getImage().getScaledInstance( icon.setImage(icon.getImage().getScaledInstance(
table.getColumnModel().getColumn(col) table.getColumnModel().getColumn(col).getPreferredWidth() * arr[1],
.getPreferredWidth() * arr[1], table.getRowHeight() * arr[0], Image.SCALE_SMOOTH));
table.getRowHeight() * arr[0],
Image.SCALE_SMOOTH));
JLabel label = new JLabel(); JLabel label = new JLabel();
label.setLayout(new FlowLayout(FlowLayout.CENTER)); label.setLayout(new FlowLayout(FlowLayout.CENTER));
label.setIcon(icon); label.setIcon(icon);
label.addMouseListener(showImg(file.getPath())); label.addMouseListener(showImg(file.getPath()));
label.setToolTipText(uid); label.setToolTipText(uid);
model.setValueAt(label, table.getSelectedRow(), model.setValueAt(label, table.getSelectedRow(), table.getSelectedColumn());
table.getSelectedColumn());
} catch (TCException e1) { } catch (TCException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
@ -913,13 +979,11 @@ public class SampleConfirmationForm extends AbstractRendering {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
int row = table.getSelectedRow(); int row = table.getSelectedRow();
if (row > top + 1 && row < bottom + 1) { if (row >= top && row <= bottom) {
int num = Integer int num = Integer.parseInt(model.getValueAt(bottom, 0).toString());
.parseInt(model.getValueAt(bottom, 0).toString()); model.insertRow(++bottom);
model.insertRow(bottom);
model.setValueAt(num + 1, bottom, 0); 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;
} else { } else {
// 提示 // 提示
} }
@ -936,12 +1000,10 @@ public class SampleConfirmationForm extends AbstractRendering {
// TODO Auto-generated method stub // TODO Auto-generated method stub
int row = table2.getSelectedRow(); int row = table2.getSelectedRow();
if (row >= top2 && row <= bottom2) { if (row >= top2 && row <= bottom2) {
int num = Integer int num = Integer.parseInt(model2.getValueAt(bottom2, 0).toString());
.parseInt(model2.getValueAt(bottom2, 0).toString()); model2.insertRow(++bottom2);
model2.insertRow(bottom2);
model2.setValueAt(num + 1, bottom2, 0); model2.setValueAt(num + 1, bottom2, 0);
model2.combine(new int[] { bottom2 }, new int[] { 0, 1 }); model2.combine(new int[] { bottom2 }, new int[] { 0, 1 });
bottom2 = model2.getRowCount() - end2;
} else { } else {
// 提示 // 提示
} }
@ -957,15 +1019,14 @@ public class SampleConfirmationForm extends AbstractRendering {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
int row = table.getSelectedRow(); int row = table.getSelectedRow();
if (row > top + 1 && row < bottom + 1) { if (row >= top && row <= bottom) {
int num = Integer int num = Integer.parseInt(model.getValueAt(row, 0).toString());
.parseInt(model.getValueAt(row, 0).toString());
model.insertRow(row); model.insertRow(row);
for (int i = row; i < model.getRowCount(); i++) { bottom++;
model.setValueAt(num + i + 1 - row, row, 0); for (int i = row; i <= bottom; i++) {
model.setValueAt(num + i - row, i, 0);
} }
model.combine(new int[] { row }, new int[] { 2, 3, 4 }); model.combine(new int[] { row }, new int[] { 2, 3, 4 });
bottom = model.getRowCount() - end;
} else { } else {
// 提示 // 提示
} }
@ -982,14 +1043,13 @@ public class SampleConfirmationForm extends AbstractRendering {
// TODO Auto-generated method stub // TODO Auto-generated method stub
int row = table2.getSelectedRow(); int row = table2.getSelectedRow();
if (row >= top2 && row <= bottom2) { if (row >= top2 && row <= bottom2) {
int num = Integer int num = Integer.parseInt(model2.getValueAt(row, 0).toString());
.parseInt(model2.getValueAt(row, 0).toString());
model2.insertRow(row); model2.insertRow(row);
for (int i = row; i < model2.getRowCount(); i++) { bottom2++;
model2.setValueAt(num + i + 1 - row, row, 0); for (int i = row; i <= bottom2; i++) {
model2.setValueAt(num + i - row, i, 0);
} }
model2.combine(new int[] { row }, new int[] { 0, 1 }); model2.combine(new int[] { row }, new int[] { 0, 1 });
bottom2 = model2.getRowCount() - end2;
} else { } else {
// 提示 // 提示
} }

@ -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<Double> 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<Double>();
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;
}
}

@ -17,16 +17,14 @@ import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
public class TCTableUtil { public class TCTableUtil {
public static String[][] getTableRows(TCComponentForm form, String prop, public static String[][] getTableRows(TCComponentForm form, String prop, String[] colNames) {
String[] colNames) {
try { try {
TCProperty tcProperty = form.getTCProperty(prop); TCProperty tcProperty = form.getTCProperty(prop);
TCComponent[] components = tcProperty.getReferenceValueArray(); TCComponent[] components = tcProperty.getReferenceValueArray();
String[][] res = new String[components.length][colNames.length]; String[][] res = new String[components.length][colNames.length];
for (int i = 0; i < components.length; i++) { for (int i = 0; i < components.length; i++) {
for (int ii = 0; ii < colNames.length; ii++) { for (int ii = 0; ii < colNames.length; ii++) {
res[i][ii] = components[i] res[i][ii] = components[i].getPropertyDisplayableValue(colNames[ii]);
.getPropertyDisplayableValue(colNames[ii]);
} }
} }
return res; return res;
@ -38,13 +36,13 @@ public class TCTableUtil {
return null; return null;
} }
public static boolean setTableRows(TCComponentForm form, String prop, public static boolean setTableRows(TCComponentForm form, String prop, String refName, String[] colNames,
String[] colNames, String[][] rows) { String[][] rows) {
List<TCComponent> list = new ArrayList<TCComponent>(); List<TCComponent> list = new ArrayList<TCComponent>();
DataManagementService service = DataManagementService.getService( DataManagementService service = DataManagementService
(TCSession) AIFUtility.getCurrentApplication().getSession()); .getService((TCSession) AIFUtility.getCurrentApplication().getSession());
CreateIn ci = new CreateIn(); CreateIn ci = new CreateIn();
ci.data.boName = "JD2_table"; ci.data.boName = refName;
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < rows.length; i++) { for (int i = 0; i < rows.length; i++) {
for (int ii = 0; ii < colNames.length; ii++) { for (int ii = 0; ii < colNames.length; ii++) {
@ -53,12 +51,13 @@ public class TCTableUtil {
System.out.println(map.size()); System.out.println(map.size());
ci.data.stringProps = map; ci.data.stringProps = map;
try { try {
CreateResponse response = service CreateResponse response = service.createObjects(new CreateIn[] { ci });
.createObjects(new CreateIn[] { ci }); System.out.println("CreateResponse size:" + response.serviceData.sizeOfCreatedObjects());
System.out.println("CreateResponse size:"
+ response.serviceData.sizeOfCreatedObjects());
if (response.serviceData.sizeOfCreatedObjects() > 0) { if (response.serviceData.sizeOfCreatedObjects() > 0) {
list.add(response.output[0].objects[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) { } catch (ServiceException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -66,8 +65,7 @@ public class TCTableUtil {
} }
} }
try { try {
form.getTCProperty(prop).setReferenceValueArray( form.getTCProperty(prop).setReferenceValueArray(list.toArray(new TCComponent[list.size()]));
list.toArray(new TCComponent[list.size()]));
System.out.println("±£´ætable³É¹¦"); System.out.println("±£´ætable³É¹¦");
return true; return true;
} catch (TCException e) { } catch (TCException e) {

Loading…
Cancel
Save