表单问题修复:

bug:格式渲染出错
fix:查分为两个部分避免出现问题
main
zouxk 6 years ago
parent f52f71e4cc
commit 2b8435cb78

@ -40,11 +40,15 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
private CTMap model;
private CTable table;
private int top = 10;
private int end = 4;
private int end = 1;
private int bottom;
private CTMap model2;
private CTable table2;
private Map<String, String> prop;
private List<String> disableEdit;
private List<String> disableEdit2;
private Map<String, int[]> general;
private Map<String, int[]> general2;
private JCheckPanel bgqf;
private JPopupMenu menu = new JPopupMenu();
private JMenuItem addR;
@ -76,6 +80,8 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
model = new CTMap(20, 11);
bottom = model.getRowCount() - end;
model2 = new CTMap(3, 11);
initModel();
table = new CTable(model) {
@ -141,6 +147,69 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
table.getColumnModel().getColumn(2).setCellEditor(new MyCellEditor3(new JTextField()));
table.addMouseListener(rightClick());
initModel2();
table2 = new CTable(model2) {
@Override
public boolean isCellEditable(int row, int col) {
if (isEditorDisable(disableEdit2, row, col)) {
return false;
}
return true;
}
};
table2.setRowHeight(25);
table2.setBorder(BorderFactory.createLineBorder(Color.black));
table2.getColumnModel().getColumn(0).setPreferredWidth(40);
table2.getColumnModel().getColumn(1).setPreferredWidth(100);
table2.getColumnModel().getColumn(2).setPreferredWidth(80);
table2.getColumnModel().getColumn(3).setPreferredWidth(80);
table2.getColumnModel().getColumn(4).setPreferredWidth(80);
table2.getColumnModel().getColumn(5).setPreferredWidth(80);
table2.getColumnModel().getColumn(6).setPreferredWidth(80);
table2.getColumnModel().getColumn(7).setPreferredWidth(80);
table2.getColumnModel().getColumn(8).setPreferredWidth(80);
table2.getColumnModel().getColumn(9).setPreferredWidth(150);
table2.getColumnModel().getColumn(10).setPreferredWidth(60);
DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() {
// 重写方法
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
// TODO Auto-generated method stub
if (value instanceof JPanel) {
return (JPanel) value;
}
int maxPreferredHeight = 0;
for (int i = 0; i < table.getColumnCount(); i++) {
setText("" + table.getValueAt(row, i));
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
}
setBackground(Color.white);
// if(points1.contains(new Point(row,column)))
// setForeground(new Color(0,0,255));
// else
setForeground(Color.black);
if (isSelected) {
setBackground(new Color(0, 120, 215));
setForeground(Color.white);
}
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
table.setRowHeight(row, maxPreferredHeight);
setText(value == null ? "" : value.toString());
return this;
}
};
tcr2.setHorizontalAlignment(SwingConstants.CENTER);
table2.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN);
table2.setDefaultRenderer(Object.class, tcr2);
// 右键菜单
menu.setVisible(false);
addR = new JMenuItem("新增行");
@ -164,6 +233,13 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
System.out.println("未找到属性 " + entry.getKey());
}
}
for (Entry<String, int[]> entry : general2.entrySet()) {
if (prop.containsKey(entry.getKey())) {
model2.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]);
} else {
System.out.println("未找到属性 " + entry.getKey());
}
}
if (prop.containsKey("jd2_bgqf")) {
bgqf.setSelected(prop.get("jd2_bgqf"));
} else {
@ -181,7 +257,10 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
ScrollPane pane = new ScrollPane();
pane.add(table);
root.add(pane);
ScrollPane pane2 = new ScrollPane();
pane2.add(table2);
root.add(pane, BorderLayout.CENTER);
root.add(pane2, BorderLayout.SOUTH);
this.add(menu);
this.add(root);
}
@ -238,21 +317,6 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
model.setValueAt("备注", top, 10);
disableEdit.add(top + ",10");
model.setValueAt("预计完成日期:", bottom + 1, 0);
disableEdit.add(bottom + 1 + ",0");
general.put("jd2_yjwcrq", new int[] { bottom + 1, 2 });
model.setValueAt("编制签名:", bottom + 2, 0);
disableEdit.add(bottom + 2 + ",0");
model.setValueAt("批准签名:", bottom + 3, 0);
disableEdit.add(bottom + 3 + ",0");
general.put("jd2_bz", new int[] { bottom + 2, 2 });
general.put("jd2_pz", new int[] { bottom + 3, 2 });
model.setValueAt("编制时间:", bottom + 2, 5);
disableEdit.add(bottom + 2 + ",5");
model.setValueAt("批准时间:", bottom + 3, 5);
disableEdit.add(bottom + 3 + ",5");
general.put("jd2_bzrq", new int[] { bottom + 2, 8 });
general.put("jd2_pzrq", new int[] { bottom + 3, 8 });
model.combine(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 });
model.combine(new int[] { 0, 1, 2 }, new int[] { 3, 4, 5, 6, 7 });
model.combine(new int[] { 0 }, new int[] { 9, 10 });
@ -281,16 +345,38 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
model.setValueAt(i - top, i, 0);
disableEdit.add(i + ",0");
}
model.combine(new int[] { bottom + 1 }, new int[] { 0, 1 });
model.combine(new int[] { bottom + 1 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 });
model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 });
model.combine(new int[] { bottom + 2 }, new int[] { 2, 3, 4 });
model.combine(new int[] { bottom + 2 }, new int[] { 5, 6, 7 });
model.combine(new int[] { bottom + 2 }, new int[] { 8, 9, 10 });
model.combine(new int[] { bottom + 3 }, new int[] { 0, 1 });
model.combine(new int[] { bottom + 3 }, new int[] { 2, 3, 4 });
model.combine(new int[] { bottom + 3 }, new int[] { 5, 6, 7 });
model.combine(new int[] { bottom + 3 }, new int[] { 8, 9, 10 });
}
private void initModel2() {
disableEdit2 = new ArrayList<String>();
general2 = new HashMap<String, int[]>();
model2.setValueAt("预计完成日期:", 0, 0);
disableEdit2.add("0,0");
general2.put("jd2_yjwcrq", new int[] { 0, 2 });
model2.setValueAt("编制签名:", 1, 0);
disableEdit2.add("1,0");
model2.setValueAt("批准签名:", 2, 0);
disableEdit2.add("2,0");
general2.put("jd2_bz", new int[] { 1, 2 });
general2.put("jd2_pz", new int[] { 2, 2 });
model2.setValueAt("编制时间:", 1, 5);
disableEdit2.add("1,5");
model2.setValueAt("批准时间:", 2, 5);
disableEdit2.add("2,5");
general2.put("jd2_bzrq", new int[] { 1, 8 });
general2.put("jd2_pzrq", new int[] { 2, 8 });
model2.combine(new int[] { 0 }, new int[] { 0, 1 });
model2.combine(new int[] { 0 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 });
model2.combine(new int[] { 1 }, new int[] { 0, 1 });
model2.combine(new int[] { 1 }, new int[] { 2, 3, 4 });
model2.combine(new int[] { 1 }, new int[] { 5, 6, 7 });
model2.combine(new int[] { 1 }, new int[] { 8, 9, 10 });
model2.combine(new int[] { 2 }, new int[] { 0, 1 });
model2.combine(new int[] { 2 }, new int[] { 2, 3, 4 });
model2.combine(new int[] { 2 }, new int[] { 5, 6, 7 });
model2.combine(new int[] { 2 }, new int[] { 8, 9, 10 });
}
@Override
@ -312,6 +398,23 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
}
}
}
for (Entry<String, int[]> entry : general2.entrySet()) {
if (prop.containsKey(entry.getKey())) {
String value = model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString();
try {
if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) {
value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues()
.getRealValue(value);
}
System.out.println(entry.getKey() + ":" + value);
form.setProperty(entry.getKey(), value);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
if (prop.containsKey("jd2_bgqf")) {
String value = bgqf.getSelectedText() == null ? "" : bgqf.getSelectedText();
@ -403,11 +506,11 @@ public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implement
int num = Integer.parseInt(model.getValueAt(row, 0).toString());
model.removeRow(row);
bottom--;
if (row <= bottom) {
for (int i = row; i <= bottom; i++) {
model.setValueAt(num + i - row, i, 0);
}
}
// if (row <= bottom) {
// for (int i = row; i <= bottom; i++) {
// model.setValueAt(num + i - row, i, 0);
// }
// }
System.out.println(bottom);
initModel();
table.revalidate();

@ -40,6 +40,7 @@ import com.connor.jd.plm.table.JCheckPanel;
import com.connor.jd.plm.table.JRadioPanel;
import com.connor.jd.plm.table.MyCellEditor;
import com.connor.jd.plm.table.MyCellEditor1;
import com.connor.jd.plm.table.MyCellEditor2;
import com.connor.jd.plm.table.TCTableUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
@ -61,21 +62,26 @@ public class SampleConfirmationForm extends AbstractRendering {
private JPanel center = null;
private JPopupMenu menu = new JPopupMenu();
private JPopupMenu menu2 = new JPopupMenu();
private JPopupMenu menu3 = new JPopupMenu();
private JPanel confirmPanel = new JPanel();
private JPanel examinePanel = new JPanel();
private CTMap model;
private CTMap model2;
private CTMap model3;
private CTable table;
private CTable table2;
private CTable table3;
private int top = 13;// 头部行数
private int bottom;// 中间部分结束
private int end = 14;// 尾部行数+1
private int end = 1;// 尾部行数+1
private int top2 = 4;
private int bottom2;
private int end2 = 16;
private Map<String, String> prop;
private Map<String, int[]> general;
private Map<String, int[]> general3;
private List<String> disableEdit;
private List<String> disableEdit3;
private Map<String, int[]> pic;
private List<String> disableEdit2;
private JRadioPanel yssl;
@ -128,13 +134,11 @@ public class SampleConfirmationForm extends AbstractRendering {
// 确认单
confirmPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
confirmPanel.setLayout(new BorderLayout());
confirmPanel.setPreferredSize(new Dimension(800, 600));
// 设置属性
model = new CTMap(47, 20);
model = new CTMap(30, 20);
bottom = model.getRowCount() - end;
// 合并单元格
initModel();
table = new CTable(model) {
@ -166,10 +170,6 @@ public class SampleConfirmationForm extends AbstractRendering {
boolean hasFocus, int row, int column) {
// TODO Auto-generated method stub
if (value instanceof JLabel) {
return (JLabel) value;
}
if (value instanceof JPanel) {
return (JPanel) value;
}
@ -202,7 +202,71 @@ public class SampleConfirmationForm extends AbstractRendering {
table.getColumnModel().getColumn(i).setCellEditor(new MyCellEditor(new JTextField(), top, end, bottom));
}
table.addMouseListener(rightClick());
confirmPanel.add(table, BorderLayout.CENTER);
model3 = new CTMap(13, 20);
initModel3();
table3 = new CTable(model3) {
@Override
public boolean isCellEditable(int row, int col) {
if (isEditorDisable(disableEdit3, row, col)) {
return false;
}
return true;
}
};
table3.setRowHeight(25);
table3.setBorder(BorderFactory.createLineBorder(Color.black));
table3.getColumnModel().getColumn(0).setPreferredWidth(40);
table3.getColumnModel().getColumn(1).setPreferredWidth(60);
table3.getColumnModel().getColumn(2).setPreferredWidth(50);
table3.getColumnModel().getColumn(3).setPreferredWidth(50);
table3.getColumnModel().getColumn(4).setPreferredWidth(50);
table3.getColumnModel().getColumn(5).setPreferredWidth(60);
table3.getColumnModel().getColumn(6).setPreferredWidth(60);
for (int i = 7; i < model3.getColumnCount() - 1; i++) {
table3.getColumnModel().getColumn(i).setPreferredWidth(45);
}
table3.getColumnModel().getColumn(model3.getColumnCount() - 1).setPreferredWidth(80);
DefaultTableCellRenderer tcr3 = new DefaultTableCellRenderer() {
// 重写方法
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
// TODO Auto-generated method stub
if (value instanceof JLabel) {
return (JLabel) value;
}
int maxPreferredHeight = 0;
for (int i = 0; i < table.getColumnCount(); i++) {
setText("" + table.getValueAt(row, i));
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
}
setBackground(Color.white);
// if(points1.contains(new Point(row,column)))
// setForeground(new Color(0,0,255));
// else
setForeground(Color.black);
if (isSelected) {
setBackground(new Color(0, 120, 215));
setForeground(Color.white);
}
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
table.setRowHeight(row, maxPreferredHeight);
setText(value == null ? "" : value.toString());
return this;
}
};
tcr3.setHorizontalAlignment(SwingConstants.CENTER);
table3.setDefaultRenderer(Object.class, tcr3);
for (int i = 0; i < model3.getColumnCount(); i++) {
table3.getColumnModel().getColumn(i).setCellEditor(new MyCellEditor2(new JTextField()));
}
table3.addMouseListener(rightClick3());
// 填写数据
prop = form.getProperties();
@ -214,6 +278,14 @@ public class SampleConfirmationForm extends AbstractRendering {
System.out.println("属性‘" + entry.getKey() + "’未找到");
}
}
for (Entry<String, int[]> entry : general3.entrySet()) {
if (prop.containsKey(entry.getKey())) {
model3.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]);
} else {
model3.setValueAt("", entry.getValue()[0], entry.getValue()[1]);
System.out.println("属性‘" + entry.getKey() + "’未找到");
}
}
if (prop.containsKey("jd2_yssl")) {
yssl.setSelected(prop.get("jd2_yssl"));
} else {
@ -244,32 +316,32 @@ public class SampleConfirmationForm extends AbstractRendering {
ImageIcon icon = new ImageIcon(img.getPath());
int[] arr = model.getSpan(row, col);
int[] arr = model3.getSpan(row, col);
int width = 0;
for (int i = 0; i < arr[1]; i++) {
// width+=table.getColumnModel().getColumn()
// width+=table3.getColumnModel().getColumn()
}
System.out.println("row:" + arr[0] + ",col:" + arr[1]);
icon.setImage(icon.getImage().getScaledInstance(
table.getColumnModel().getColumn(col).getPreferredWidth() * arr[1],
table.getRowHeight() * arr[0], Image.SCALE_SMOOTH));
table3.getColumnModel().getColumn(col).getPreferredWidth() * arr[1],
table3.getRowHeight() * arr[0], Image.SCALE_SMOOTH));
JLabel label = new JLabel();
label.setLayout(new FlowLayout(FlowLayout.CENTER));
label.setIcon(icon);
label.addMouseListener(showImg(img.getPath()));
label.setToolTipText(dataset.getUid());
model.setValueAt(label, row, col);
model3.setValueAt(label, row, col);
} else {
model.setValueAt(new JLabel(""), row, col);
System.out.println("未找到uid为\"" + prop.get(entry.getKey()) + "\"的数据集");
model3.setValueAt(new JLabel(""), row, col);
// System.out.println("未找到uid为\"" + prop.get(entry.getKey()) + "\"的数据集");
}
} catch (Exception e) {
model.setValueAt(new JLabel(""), row, col);
e.printStackTrace(System.out);
model3.setValueAt(new JLabel(""), row, col);
e.printStackTrace();
}
} else {
model.setValueAt(new JLabel(""), row, col);
model3.setValueAt(new JLabel(""), row, col);
System.out.println("属性‘" + entry.getKey() + "’未找到");
}
}
@ -292,8 +364,12 @@ public class SampleConfirmationForm extends AbstractRendering {
System.out.println("属性jd2_ypqrdtable未找到");
}
ScrollPane confirmScrollPanel = new ScrollPane();
confirmScrollPanel.add(confirmPanel);
ScrollPane confirmScrollPanel1 = new ScrollPane();
confirmScrollPanel1.add(table);
ScrollPane confirmScrollPanel3 = new ScrollPane();
confirmScrollPanel3.add(table3);
confirmPanel.add(confirmScrollPanel1, BorderLayout.CENTER);
confirmPanel.add(confirmScrollPanel3, BorderLayout.SOUTH);
// 检查表
examinePanel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
examinePanel.setLayout(new BorderLayout());
@ -321,21 +397,21 @@ public class SampleConfirmationForm extends AbstractRendering {
disableEdit2.add(i + ",0");
model2.combine(new int[] { i }, new int[] { 0, 1 });
}
model2.setValueAt("MIN", bottom + 1, 0);
model2.setValueAt("MAX", bottom + 2, 0);
model2.setValueAt("R", bottom + 3, 0);
model2.setValueAt("标准偏差", bottom + 4, 0);
model2.setValueAt("平均", bottom + 5, 0);
model2.setValueAt("X,BAR-3S", bottom + 6, 0);
model2.setValueAt("X,BAR+3S", bottom + 7, 0);
model2.setValueAt("CP", bottom + 8, 0);
model2.setValueAt("Cpu", bottom + 9, 0);
model2.setValueAt("Cpl", bottom + 10, 0);
model2.setValueAt("CPK", bottom + 11, 0);
model2.setValueAt("SU 预测不良", bottom + 12, 0);
model2.setValueAt("SL 预测不良", bottom + 13, 0);
model2.setValueAt("预测不良(PPM)", bottom + 14, 0);
model2.setValueAt("工程能力意义", bottom + 15, 0);
model2.setValueAt("MIN", bottom2 + 1, 0);
model2.setValueAt("MAX", bottom2 + 2, 0);
model2.setValueAt("R", bottom2 + 3, 0);
model2.setValueAt("标准偏差", bottom2 + 4, 0);
model2.setValueAt("平均", bottom2 + 5, 0);
model2.setValueAt("X,BAR-3S", bottom2 + 6, 0);
model2.setValueAt("X,BAR+3S", bottom2 + 7, 0);
model2.setValueAt("CP", bottom2 + 8, 0);
model2.setValueAt("Cpu", bottom2 + 9, 0);
model2.setValueAt("Cpl", bottom2 + 10, 0);
model2.setValueAt("CPK", bottom2 + 11, 0);
model2.setValueAt("SU 预测不良", bottom2 + 12, 0);
model2.setValueAt("SL 预测不良", bottom2 + 13, 0);
model2.setValueAt("预测不良(PPM)", bottom2 + 14, 0);
model2.setValueAt("工程能力意义", bottom2 + 15, 0);
table2 = new CTable(model2) {
/**
@ -444,14 +520,6 @@ public class SampleConfirmationForm extends AbstractRendering {
// 确认单右键菜单
menu.setVisible(false);
addP = new JMenuItem("添加图片");
addP.setEnabled(false);
menu.add(addP);
addP.addActionListener(addPic());
delP = new JMenuItem("删除图片");
delP.setEnabled(false);
menu.add(delP);
delP.addActionListener(delPic());
addR = new JMenuItem("添加行");
addR.setEnabled(false);
menu.add(addR);
@ -465,6 +533,16 @@ public class SampleConfirmationForm extends AbstractRendering {
menu.add(delR);
delR.addActionListener(deleteRow());
menu3.setVisible(false);
addP = new JMenuItem("添加图片");
addP.setEnabled(false);
menu3.add(addP);
addP.addActionListener(addPic());
delP = new JMenuItem("删除图片");
delP.setEnabled(false);
menu3.add(delP);
delP.addActionListener(delPic());
// 检验单右键菜单
menu2.setVisible(false);
addR2 = new JMenuItem("添加行");
@ -480,12 +558,13 @@ public class SampleConfirmationForm extends AbstractRendering {
menu2.add(delR2);
delR2.addActionListener(deleteRow2());
center.add("confirm", confirmScrollPanel);
center.add("confirm", confirmPanel);
center.add("examine", examineScrollPanel);
root.add(buttons, BorderLayout.NORTH);
root.add(center, BorderLayout.CENTER);
this.add(menu);
this.add(menu2);
this.add(menu3);
this.add(root, BorderLayout.CENTER);
cl.show(center, "confirm");
@ -494,7 +573,6 @@ public class SampleConfirmationForm extends AbstractRendering {
private void initModel() {
disableEdit = new ArrayList<>();// 不允许编辑
general = new HashMap<String, int[]>();// 要填写的一般属性
pic = new HashMap<String, int[]>();// 图片
model.setValueAt("样品确认单", 0, 0);
disableEdit.add("0,0");
model.setValueAt("提交", 0, 14);
@ -595,77 +673,9 @@ public class SampleConfirmationForm extends AbstractRendering {
for (int i = top + 2; i <= bottom; i++) {
model.setValueAt(i - 1 - top, i, 0);
disableEdit.add(i + ",0");
}
model.setValueAt("被标记为“CTQ”的尺寸非常重要", bottom + 1, 0);// 从“底部”开始
disableEdit.add(bottom + 1 + ",0");
model.setValueAt("SPL Picture", bottom + 2, 0);
pic.put("jd2_ypzp", new int[] { bottom + 3, 0 });
disableEdit.add(bottom + 2 + ",0");
model.setValueAt("注塑条件", bottom + 2, 4);
disableEdit.add(bottom + 2 + ",4");
model.setValueAt("C/Time", bottom + 2, 5);
disableEdit.add(bottom + 2 + ",5");
model.setValueAt("注塑", bottom + 2, 6);
disableEdit.add(bottom + 2 + ",6");
model.setValueAt("冷却", bottom + 2, 7);
disableEdit.add(bottom + 2 + ",7");
model.setValueAt("包装", bottom + 2, 8);
disableEdit.add(bottom + 2 + ",8");
model.setValueAt("供方自检报告", bottom + 2, 9);
disableEdit.add(bottom + 2 + ",9");
model.setValueAt("供方作业指导书", bottom + 2, 12);
disableEdit.add(bottom + 2 + ",12");
model.setValueAt("供方QC工程图", bottom + 2, 15);
disableEdit.add(bottom + 2 + ",15");
model.setValueAt("物料包装及标签", bottom + 2, 18);
disableEdit.add(bottom + 2 + ",18");
general.put("jd2_Ctime", new int[] { bottom + 3, 5 });
general.put("jd2_zs", new int[] { bottom + 3, 6 });
general.put("jd2_lq", new int[] { bottom + 3, 7 });
general.put("jd2_baoz", new int[] { bottom + 3, 8 });
pic.put("jd2_gfzjbg", new int[] { bottom + 3, 9 });
pic.put("jd2_gfzyzds", new int[] { bottom + 3, 12 });
pic.put("jd2_gfqcgct", new int[] { bottom + 3, 15 });
pic.put("jd2_wlbzjbq", new int[] { bottom + 3, 18 });
model.setValueAt("Shot/24Hr", bottom + 4, 5);
disableEdit.add(bottom + 4 + ",5");
model.setValueAt("吨", bottom + 4, 6);
disableEdit.add(bottom + 4 + ",6");
general.put("jd2_Shot24Hr", new int[] { bottom + 5, 5 });
general.put("jd2_d", new int[] { bottom + 5, 6 });
model.setValueAt("3D重量", bottom + 6, 4);
disableEdit.add(bottom + 6 + ",4");
model.setValueAt("jd2_3Dzl", bottom + 6, 5);
general.put("jd2_3Dzl", new int[] { bottom + 6, 5 });
model.setValueAt("注塑工艺条件", bottom + 6, 7);
disableEdit.add(bottom + 6 + ",7");
model.setValueAt("IQC首检报告", bottom + 6, 9);
disableEdit.add(bottom + 6 + ",9");
model.setValueAt("测试报告", bottom + 6, 12);
disableEdit.add(bottom + 6 + ",12");
model.setValueAt("材质报告", bottom + 6, 15);
disableEdit.add(bottom + 6 + ",15");
model.setValueAt("模具标识", bottom + 6, 18);
disableEdit.add(bottom + 6 + ",18");
pic.put("jd2_zsgytj", new int[] { bottom + 7, 7 });
pic.put("jd2_icqsjbg", new int[] { bottom + 7, 9 });
pic.put("jd2_csbg", new int[] { bottom + 7, 12 });
pic.put("jd2_czbg", new int[] { bottom + 7, 15 });
pic.put("jd2_mjbs", new int[] { bottom + 7, 18 });
model.setValueAt("实测重量", bottom + 8, 4);
disableEdit.add(bottom + 8 + ",4");
general.put("jd2_sczl", new int[] { bottom + 8, 5 });
model.setValueAt("IQC作业指导书", bottom + 10, 4);
disableEdit.add(bottom + 10 + ",4");
pic.put("jd2_icqjyzds", new int[] { bottom + 11, 4 });
model.setValueAt("决定", bottom + 12, 12);
disableEdit.add(bottom + 12 + ",12");
general.put("jd2_jued", new int[] { bottom + 12, 15 });
pic.put("jd2_qtbg", new int[] { bottom + 10, 7 });
for (int i = top + 2; i <= bottom; i++) {
model.combine(new int[] { i }, new int[] { 2, 3, 4 });
}
model.combine(new int[] { 0, 1 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
model.combine(new int[] { 0, 1 }, new int[] { 14, 15 });
model.combine(new int[] { 0, 1 }, new int[] { 16, 17 });
@ -715,42 +725,115 @@ public class SampleConfirmationForm extends AbstractRendering {
model.combine(new int[] { top, top + 1 }, new int[] { 19 });
model.combine(new int[] { top + 1 }, new int[] { 1, 2, 3, 4 });
model.combine(new int[] { top + 1 }, new int[] { 5, 6 });
model.combine(new int[] { bottom + 1 }, new int[] { 0, 1, 2, 3, 4, 5 });
model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 });
model.combine(new int[] { bottom + 2 }, new int[] { 2, 3 });
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6, bottom + 7, bottom + 8, bottom + 9,
bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 0, 1, 2, 3 });
model.combine(new int[] { bottom + 2, bottom + 3, bottom + 4, bottom + 5 }, new int[] { 4 });
model.combine(new int[] { bottom + 2 }, new int[] { 9, 10, 11 });
model.combine(new int[] { bottom + 2 }, new int[] { 12, 13, 14 });
model.combine(new int[] { bottom + 2 }, new int[] { 15, 16, 17 });
model.combine(new int[] { bottom + 2 }, new int[] { 18, 19 });
model.combine(new int[] { bottom + 4, bottom + 5 }, new int[] { 7, 8 });
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 9, 10, 11 });
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 12, 13, 14 });
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 15, 16, 17 });
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 }, new int[] { 18, 19 });
model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 4 });
model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 4 });
model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 5 });
model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 5 });
model.combine(new int[] { bottom + 6, bottom + 7, bottom + 8, bottom + 9 }, new int[] { 6 });
model.combine(new int[] { bottom + 6 }, new int[] { 7, 8 });
model.combine(new int[] { bottom + 6 }, new int[] { 9, 10, 11 });
model.combine(new int[] { bottom + 6 }, new int[] { 12, 13, 14 });
model.combine(new int[] { bottom + 6 }, new int[] { 15, 16, 17 });
model.combine(new int[] { bottom + 6 }, new int[] { 18, 19 });
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 7, 8 });
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 9, 10, 11 });
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 12, 13, 14 });
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 15, 16, 17 });
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 }, new int[] { 18, 19 });
model.combine(new int[] { bottom + 10 }, new int[] { 4, 5, 6 });
model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 }, new int[] { 4, 5, 6 });
model.combine(new int[] { bottom + 10, bottom + 11, bottom + 12, bottom + 13 }, new int[] { 7, 8, 9, 10, 11 });
model.combine(new int[] { bottom + 10, bottom + 11 }, new int[] { 12, 13, 14, 15, 16, 17, 18, 19 });
model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 12, 13, 14 });
model.combine(new int[] { bottom + 12, bottom + 13 }, new int[] { 15, 16, 17, 18, 19 });
}
private void initModel3() {
disableEdit3 = new ArrayList<>();// 不允许编辑
general3 = new HashMap<String, int[]>();// 要填写的一般属性
pic = new HashMap<String, int[]>();// 图片
model3.setValueAt("被标记为“CTQ”的尺寸非常重要", 0, 0);// 从“底部”开始
disableEdit3.add(0 + ",0");
model3.setValueAt("SPL Picture", 1, 0);
pic.put("jd2_ypzp", new int[] { 2, 0 });
disableEdit3.add(1 + ",0");
model3.setValueAt("注塑条件", 1, 4);
disableEdit3.add(1 + ",4");
model3.setValueAt("C/Time", 1, 5);
disableEdit3.add(1 + ",5");
model3.setValueAt("注塑", 1, 6);
disableEdit3.add(1 + ",6");
model3.setValueAt("冷却", 1, 7);
disableEdit3.add(1 + ",7");
model3.setValueAt("包装", 1, 8);
disableEdit3.add(1 + ",8");
model3.setValueAt("供方自检报告", 1, 9);
disableEdit3.add(1 + ",9");
model3.setValueAt("供方作业指导书", 1, 12);
disableEdit3.add(1 + ",12");
model3.setValueAt("供方QC工程图", 1, 15);
disableEdit3.add(1 + ",15");
model3.setValueAt("物料包装及标签", 1, 18);
disableEdit3.add(1 + ",18");
general3.put("jd2_Ctime", new int[] { 2, 5 });
general3.put("jd2_zs", new int[] { 2, 6 });
general3.put("jd2_lq", new int[] { 2, 7 });
general3.put("jd2_baoz", new int[] { 2, 8 });
pic.put("jd2_gfzjbg", new int[] { 2, 9 });
pic.put("jd2_gfzyzds", new int[] { 2, 12 });
pic.put("jd2_gfqcgct", new int[] { 2, 15 });
pic.put("jd2_wlbzjbq", new int[] { 2, 18 });
model3.setValueAt("Shot/24Hr", 3, 5);
disableEdit3.add(3 + ",5");
model3.setValueAt("吨", 3, 6);
disableEdit3.add(3 + ",6");
general3.put("jd2_Shot24Hr", new int[] { 4, 5 });
general3.put("jd2_d", new int[] { 4, 6 });
model3.setValueAt("3D重量", 5, 4);
disableEdit3.add(5 + ",4");
model3.setValueAt("jd2_3Dzl", 5, 5);
general3.put("jd2_3Dzl", new int[] { 5, 5 });
model3.setValueAt("注塑工艺条件", 5, 7);
disableEdit3.add(5 + ",7");
model3.setValueAt("IQC首检报告", 5, 9);
disableEdit3.add(5 + ",9");
model3.setValueAt("测试报告", 5, 12);
disableEdit3.add(5 + ",12");
model3.setValueAt("材质报告", 5, 15);
disableEdit3.add(5 + ",15");
model3.setValueAt("模具标识", 5, 18);
disableEdit3.add(5 + ",18");
pic.put("jd2_zsgytj", new int[] { 6, 7 });
pic.put("jd2_icqsjbg", new int[] { 6, 9 });
pic.put("jd2_csbg", new int[] { 6, 12 });
pic.put("jd2_czbg", new int[] { 6, 15 });
pic.put("jd2_mjbs", new int[] { 6, 18 });
model3.setValueAt("实测重量", 7, 4);
disableEdit3.add(7 + ",4");
general3.put("jd2_sczl", new int[] { 7, 5 });
model3.setValueAt("IQC作业指导书", 9, 4);
disableEdit3.add(9 + ",4");
pic.put("jd2_icqjyzds", new int[] { 10, 4 });
model3.setValueAt("决定", 11, 12);
disableEdit3.add(11 + ",12");
general3.put("jd2_jued", new int[] { 11, 15 });
pic.put("jd2_qtbg", new int[] { 9, 7 });
model3.combine(new int[] { 0 }, new int[] { 0, 1, 2, 3, 4, 5 });
model3.combine(new int[] { 1 }, new int[] { 0, 1 });
model3.combine(new int[] { 1 }, new int[] { 2, 3 });
model3.combine(new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, new int[] { 0, 1, 2, 3 });
model3.combine(new int[] { 1, 2, 3, 4 }, new int[] { 4 });
model3.combine(new int[] { 1 }, new int[] { 9, 10, 11 });
model3.combine(new int[] { 1 }, new int[] { 12, 13, 14 });
model3.combine(new int[] { 1 }, new int[] { 15, 16, 17 });
model3.combine(new int[] { 1 }, new int[] { 18, 19 });
model3.combine(new int[] { 3, 4 }, new int[] { 7, 8 });
model3.combine(new int[] { 2, 3, 4 }, new int[] { 9, 10, 11 });
model3.combine(new int[] { 2, 3, 4 }, new int[] { 12, 13, 14 });
model3.combine(new int[] { 2, 3, 4 }, new int[] { 15, 16, 17 });
model3.combine(new int[] { 2, 3, 4 }, new int[] { 18, 19 });
model3.combine(new int[] { 5, 6 }, new int[] { 4 });
model3.combine(new int[] { 7, 8 }, new int[] { 4 });
model3.combine(new int[] { 5, 6 }, new int[] { 5 });
model3.combine(new int[] { 7, 8 }, new int[] { 5 });
model3.combine(new int[] { 5, 6, 7, 8 }, new int[] { 6 });
model3.combine(new int[] { 5 }, new int[] { 7, 8 });
model3.combine(new int[] { 5 }, new int[] { 9, 10, 11 });
model3.combine(new int[] { 5 }, new int[] { 12, 13, 14 });
model3.combine(new int[] { 5 }, new int[] { 15, 16, 17 });
model3.combine(new int[] { 5 }, new int[] { 18, 19 });
model3.combine(new int[] { 6, 7, 8 }, new int[] { 7, 8 });
model3.combine(new int[] { 6, 7, 8 }, new int[] { 9, 10, 11 });
model3.combine(new int[] { 6, 7, 8 }, new int[] { 12, 13, 14 });
model3.combine(new int[] { 6, 7, 8 }, new int[] { 15, 16, 17 });
model3.combine(new int[] { 6, 7, 8 }, new int[] { 18, 19 });
model3.combine(new int[] { 9 }, new int[] { 4, 5, 6 });
model3.combine(new int[] { 10, 11, 12 }, new int[] { 4, 5, 6 });
model3.combine(new int[] { 9, 10, 11, 12 }, new int[] { 7, 8, 9, 10, 11 });
model3.combine(new int[] { 9, 10 }, new int[] { 12, 13, 14, 15, 16, 17, 18, 19 });
model3.combine(new int[] { 11, 12 }, new int[] { 12, 13, 14 });
model3.combine(new int[] { 11, 12 }, new int[] { 15, 16, 17, 18, 19 });
}
@Override
@ -760,9 +843,9 @@ public class SampleConfirmationForm extends AbstractRendering {
for (Entry<String, int[]> entry : pic.entrySet()) {
if (prop.containsKey(entry.getKey())) {
System.out.println(entry.getKey());
label = (JLabel) model.getValueAt(entry.getValue()[0], entry.getValue()[1]);
label = (JLabel) model3.getValueAt(entry.getValue()[0], entry.getValue()[1]);
try {
form.setProperty(entry.getKey(), label.getToolTipText());
form.setProperty(entry.getKey(), label.getToolTipText() == null ? "" : label.getToolTipText());
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -808,6 +891,22 @@ public class SampleConfirmationForm extends AbstractRendering {
e.printStackTrace();
}
}
for (Entry<String, int[]> entry : general3.entrySet()) {
try {
if (prop.containsKey(entry.getKey())) {
String value = model3.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString();
if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) {
value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues()
.getRealValue(value);
}
System.out.println(entry.getKey() + ":" + value);
form.setProperty(entry.getKey(), value);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 保存表格
if (prop.containsKey("jd2_ypqrdtable")) {
List<String[]> data = new ArrayList<String[]>();
@ -936,8 +1035,6 @@ public class SampleConfirmationForm extends AbstractRendering {
addR.setEnabled(flag);
insertR.setEnabled(flag);
delR.setEnabled(flag);
flag = row > bottom;
addP.setEnabled(flag);
menu.show(e.getComponent(), e.getX(), e.getY());
}
}
@ -962,6 +1059,30 @@ public class SampleConfirmationForm extends AbstractRendering {
return mouseAdapter;
}
private MouseAdapter rightClick3() {
MouseAdapter mouseAdapter = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table3.getSelectedRow() != -1) {
int row = table3.getSelectedRow();
int col = table3.getSelectedColumn();
boolean flag = false;
for (Entry<String, int[]> entry : pic.entrySet()) {
if (entry.getValue()[0] == row && entry.getValue()[1] == col) {
flag = true;
break;
}
}
addP.setEnabled(flag);
delP.setEnabled(flag);
menu3.show(e.getComponent(), e.getX(), e.getY());
}
}
};
return mouseAdapter;
}
private ActionListener addPic() {
ActionListener actionListener = new ActionListener() {
@ -1004,19 +1125,19 @@ public class SampleConfirmationForm extends AbstractRendering {
String uid = dataset.getUid();
System.out.println("uid:" + uid);
ImageIcon icon = new ImageIcon(file.getPath());
int row = table.getSelectedRow();
int col = table.getSelectedColumn();
int[] arr = model.getSpan(row, col);
int row = table3.getSelectedRow();
int col = table3.getSelectedColumn();
int[] arr = model3.getSpan(row, col);
System.out.println("row:" + arr[0] + ",col:" + arr[1]);
icon.setImage(icon.getImage().getScaledInstance(
table.getColumnModel().getColumn(col).getPreferredWidth() * arr[1],
table.getRowHeight() * arr[0], Image.SCALE_SMOOTH));
table3.getColumnModel().getColumn(col).getPreferredWidth() * arr[1],
table3.getRowHeight() * arr[0], Image.SCALE_SMOOTH));
JLabel label = new JLabel();
label.setLayout(new FlowLayout(FlowLayout.CENTER));
label.setIcon(icon);
label.addMouseListener(showImg(file.getPath()));
label.setToolTipText(uid);
model.setValueAt(label, table.getSelectedRow(), table.getSelectedColumn());
model3.setValueAt(label, table3.getSelectedRow(), table3.getSelectedColumn());
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
@ -1034,9 +1155,9 @@ public class SampleConfirmationForm extends AbstractRendering {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
int row = table.getSelectedRow();
int col = table.getSelectedColumn();
model.setValueAt(new JLabel(""), row, col);
int row = table3.getSelectedRow();
int col = table3.getSelectedColumn();
model3.setValueAt(new JLabel(""), row, col);
}
};
@ -1051,11 +1172,11 @@ public class SampleConfirmationForm extends AbstractRendering {
// TODO Auto-generated method stub
int num = Integer.parseInt(model.getValueAt(bottom, 0).toString());
model.insertRow(++bottom);
// model.setValueAt(num + 1, bottom, 0);
// model.combine(new int[] { bottom }, new int[] { 2, 3, 4 });
model.setValueAt(num + 1, bottom, 0);
model.combine(new int[] { bottom }, new int[] { 2, 3, 4 });
System.out.println(bottom);
initModel();
// System.out.println(bottom);
// initModel();
table.revalidate();
table.repaint();
@ -1094,8 +1215,8 @@ public class SampleConfirmationForm extends AbstractRendering {
}
model.combine(new int[] { row }, new int[] { 2, 3, 4 });
System.out.println(bottom);
initModel();
// System.out.println(bottom);
// initModel();
table.revalidate();
table.repaint();
}
@ -1138,8 +1259,8 @@ public class SampleConfirmationForm extends AbstractRendering {
}
}
System.out.println(bottom);
initModel();
// System.out.println(bottom);
// initModel();
table.revalidate();
table.repaint();
}

@ -3,7 +3,6 @@ package com.connor.jd.plm.table;
import java.awt.Component;
import javax.swing.DefaultCellEditor;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JTextField;
@ -12,7 +11,6 @@ import com.teamcenter.rac.util.MessageBox;
public class MyCellEditor extends DefaultCellEditor {
private JRadioPanel radio = null;
private JCheckPanel check = null;
private JLabel img = null;
private int type = -1;
private int row;
private int col;
@ -44,10 +42,6 @@ public class MyCellEditor extends DefaultCellEditor {
check = (JCheckPanel) value;
type = 2;
return check;
} else if (value instanceof JLabel) {
img = (JLabel) value;
type = 3;
return img;
}
this.row = row;
this.col = column;
@ -59,14 +53,13 @@ public class MyCellEditor extends DefaultCellEditor {
@Override
public Object getCellEditorValue() {
switch (type) {
case 1:
if (type == 1) {
return radio;
case 2:
}
if (type == 2) {
return check;
case 3:
return img;
}
Object obj = super.getCellEditorValue();
if (obj != null && !"".equals(obj.toString().trim()) && row >= top && row <= bottom && col >= 7
&& col < table.getColumnCount() - 3) {

@ -0,0 +1,38 @@
package com.connor.jd.plm.table;
import java.awt.Component;
import javax.swing.DefaultCellEditor;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JTextField;
public class MyCellEditor2 extends DefaultCellEditor {
private JLabel img = null;
private int type = -1;
public MyCellEditor2(JTextField var1) {
super(var1);
// TODO Auto-generated constructor stub
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (value instanceof JLabel) {
img = (JLabel) value;
type = 1;
return img;
}
type = 0;
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
@Override
public Object getCellEditorValue() {
if (type == 1) {
return img;
}
return super.getCellEditorValue();
}
}
Loading…
Cancel
Save