|
|
|
@ -4,22 +4,50 @@ import java.awt.BorderLayout;
|
|
|
|
|
import java.awt.Color;
|
|
|
|
|
import java.awt.Component;
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
import java.awt.FlowLayout;
|
|
|
|
|
import java.awt.Font;
|
|
|
|
|
import java.awt.ScrollPane;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.awt.event.MouseAdapter;
|
|
|
|
|
import java.awt.event.MouseEvent;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory;
|
|
|
|
|
import javax.swing.DefaultCellEditor;
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
|
import javax.swing.JMenuItem;
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
import javax.swing.JPopupMenu;
|
|
|
|
|
import javax.swing.JTable;
|
|
|
|
|
import javax.swing.JTextField;
|
|
|
|
|
import javax.swing.SwingConstants;
|
|
|
|
|
import javax.swing.table.DefaultTableCellRenderer;
|
|
|
|
|
|
|
|
|
|
import com.connor.jd.plm.table.CTMap;
|
|
|
|
|
import com.connor.jd.plm.table.CTable;
|
|
|
|
|
import com.connor.jd.plm.table.ModelList;
|
|
|
|
|
import com.connor.jd.plm.table.ModelValue;
|
|
|
|
|
import com.connor.jd.plm.table.TCTableUtil;
|
|
|
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
|
|
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemType;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
import com.teamcenter.rac.stylesheet.AbstractRendering;
|
|
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.db.Db;
|
|
|
|
|
import cn.hutool.db.Entity;
|
|
|
|
|
|
|
|
|
|
public class NewProductTestForm extends AbstractRendering {
|
|
|
|
|
private TCComponentForm form;
|
|
|
|
@ -28,15 +56,23 @@ public class NewProductTestForm extends AbstractRendering {
|
|
|
|
|
private CTable table1;
|
|
|
|
|
private CTable table2;
|
|
|
|
|
private Map<String, String> prop;
|
|
|
|
|
private List<String> disableEdit;
|
|
|
|
|
private List<String> disableEdit2;
|
|
|
|
|
private Map<String, int[]> general;
|
|
|
|
|
private Map<String, int[]> general2;
|
|
|
|
|
private ModelList modelList1;
|
|
|
|
|
private ModelList modelList2;
|
|
|
|
|
private List<Entity> dbData = new ArrayList<Entity>();
|
|
|
|
|
private JPopupMenu menu = new JPopupMenu();
|
|
|
|
|
private JMenuItem addR;
|
|
|
|
|
private String[][] data = new String[0][];
|
|
|
|
|
private String[] colNames = { "jd2_no", "jd2_lb", "jd2_xm", "jd2_xmfy", "jd2_DV", "jd2_PV", "jd2_PR", "jd2_SR",
|
|
|
|
|
"jd2_bz" };
|
|
|
|
|
private String[] colNames2 = { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syfy", "jd2_sycs" };
|
|
|
|
|
private String[] jieduan = { "DV", "PV", "PR", "SR" };
|
|
|
|
|
private TCSession session;
|
|
|
|
|
|
|
|
|
|
public NewProductTestForm(TCComponent arg0) throws Exception {
|
|
|
|
|
super(arg0);
|
|
|
|
|
if (arg0 instanceof TCComponentForm) {
|
|
|
|
|
this.form = (TCComponentForm) arg0;
|
|
|
|
|
this.session = (TCSession) AIFUtility.getCurrentApplication().getSession();
|
|
|
|
|
loadRendering();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -48,57 +84,38 @@ public class NewProductTestForm extends AbstractRendering {
|
|
|
|
|
root.setPreferredSize(new Dimension(800, 500));
|
|
|
|
|
JPanel inner = new JPanel(new BorderLayout());
|
|
|
|
|
|
|
|
|
|
JPanel top = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
|
|
|
|
JLabel title = new JLabel("新品项目测试单");
|
|
|
|
|
inner.add(title, BorderLayout.NORTH);
|
|
|
|
|
title.setFont(new Font("宋体", Font.PLAIN, 24));
|
|
|
|
|
top.add(title);
|
|
|
|
|
inner.add(top, BorderLayout.NORTH);
|
|
|
|
|
|
|
|
|
|
prop = form.getProperties();
|
|
|
|
|
|
|
|
|
|
// 初始化表格
|
|
|
|
|
model1 = new CTMap(6, 4);
|
|
|
|
|
model1.setValueAt("项目信息:", 0, 0);
|
|
|
|
|
disableEdit.add("0,0");
|
|
|
|
|
model1.setValueAt("项目信息:", 0, 2);
|
|
|
|
|
disableEdit.add("0,2");
|
|
|
|
|
model1.setValueAt("项目信息:", 1, 0);
|
|
|
|
|
disableEdit.add("1,0");
|
|
|
|
|
model1.setValueAt("项目信息:", 1, 2);
|
|
|
|
|
disableEdit.add("1,2");
|
|
|
|
|
model1.setValueAt("项目信息:", 2, 0);
|
|
|
|
|
disableEdit.add("2,0");
|
|
|
|
|
model1.setValueAt("项目信息:", 2, 2);
|
|
|
|
|
disableEdit.add("2,2");
|
|
|
|
|
model1.setValueAt("项目信息:", 3, 0);
|
|
|
|
|
disableEdit.add("3,0");
|
|
|
|
|
model1.setValueAt("项目信息:", 3, 2);
|
|
|
|
|
disableEdit.add("3,2");
|
|
|
|
|
model1.setValueAt("项目信息:", 4, 0);
|
|
|
|
|
disableEdit.add("4,0");
|
|
|
|
|
model1.setValueAt("项目信息:", 4, 2);
|
|
|
|
|
disableEdit.add("4,2");
|
|
|
|
|
model1.setValueAt("项目信息:", 5, 0);
|
|
|
|
|
disableEdit.add("5,0");
|
|
|
|
|
model1.setValueAt("项目信息:", 5, 2);
|
|
|
|
|
disableEdit.add("5,2");
|
|
|
|
|
general.put("jd2_xmxx", new int[] { 0, 1 });
|
|
|
|
|
general.put("jd2_lxsj", new int[] { 0, 3 });
|
|
|
|
|
general.put("jd2_jbxh", new int[] { 1, 1 });
|
|
|
|
|
general.put("jd2_csxh", new int[] { 1, 3 });
|
|
|
|
|
general.put("jd2_cpxh", new int[] { 2, 1 });
|
|
|
|
|
general.put("jd2_xmzl", new int[] { 2, 3 });
|
|
|
|
|
general.put("jd2_cpjl", new int[] { 3, 1 });
|
|
|
|
|
general.put("jd2_cpbgd", new int[] { 3, 3 });
|
|
|
|
|
general.put("jd2_pzjl", new int[] { 4, 1 });
|
|
|
|
|
general.put("jd2_kfrc", new int[] { 4, 3 });
|
|
|
|
|
general.put("jd2_kfdj", new int[] { 5, 1 });
|
|
|
|
|
general.put("jd2_kfjd", new int[] { 5, 3 });
|
|
|
|
|
modelList1 = new ModelList();
|
|
|
|
|
String[] textArr1 = { "项目信息:", "立项时间:", "基本型号:", "测试型号:", "产品型号:", "项目资料:", "产品经理:", "产品变更点:", "品质经理:", "开发日程:",
|
|
|
|
|
"开发等级:", "开发阶段:" };
|
|
|
|
|
int[][] textLocation1 = { { 0, 0 }, { 0, 2 }, { 1, 0 }, { 1, 2 }, { 2, 0 }, { 2, 2 }, { 3, 0 }, { 3, 2 },
|
|
|
|
|
{ 4, 0 }, { 4, 2 }, { 5, 0 }, { 5, 2 } };
|
|
|
|
|
for (int i = 0; i < textArr1.length; i++) {
|
|
|
|
|
modelList1.add(new ModelValue(textArr1[i], false, textLocation1[i][0], textLocation1[i][1], false));
|
|
|
|
|
}
|
|
|
|
|
String[] propArr = { "jd2_xmxx", "jd2_lxsj", "jd2_jbxh", "jd2_csxh", "jd2_cpxh", "jd2_xmzl", "jd2_cpjl",
|
|
|
|
|
"jd2_cpbgd", "jd2_pzjl", "jd2_kfrc", "jd2_kfdj", "jd2_kfjd" };
|
|
|
|
|
int[][] propLocation1 = { { 0, 1 }, { 0, 3 }, { 1, 1 }, { 1, 3 }, { 2, 1 }, { 2, 3 }, { 3, 1 }, { 3, 3 },
|
|
|
|
|
{ 4, 1 }, { 4, 3 }, { 5, 1 }, { 5, 3 } };
|
|
|
|
|
for (int i = 0; i < propArr.length; i++) {
|
|
|
|
|
modelList1.add(new ModelValue(propArr[i], true, propLocation1[0][1], propLocation1[0][1], true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initModel(model1, modelList1);
|
|
|
|
|
|
|
|
|
|
table1 = new CTable(model1) {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isCellEditable(int row, int col) {
|
|
|
|
|
if (isEditorDisable(disableEdit, row, col)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
return !modelList1.isDisableEdit(row, col);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -116,10 +133,6 @@ public class NewProductTestForm extends AbstractRendering {
|
|
|
|
|
boolean hasFocus, int row, int column) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
if (value instanceof JPanel) {
|
|
|
|
|
return (JPanel) value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int maxPreferredHeight = 0;
|
|
|
|
|
for (int i = 0; i < table.getColumnCount(); i++) {
|
|
|
|
|
setText("" + table.getValueAt(row, i));
|
|
|
|
@ -147,16 +160,470 @@ public class NewProductTestForm extends AbstractRendering {
|
|
|
|
|
table1.setDefaultRenderer(Object.class, tcr1);
|
|
|
|
|
inner.add(table1, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
|
|
model2 = new CTMap(131, 9);
|
|
|
|
|
modelList2 = new ModelList();
|
|
|
|
|
modelList2.add(new ModelValue("NO", false, 0, 0, false, 0, 1, 0, 0));
|
|
|
|
|
modelList2.add(new ModelValue("类别", false, 0, 1, false, 0, 1, 1, 1));
|
|
|
|
|
modelList2.add(new ModelValue("项目", false, 0, 2, false, 0, 1, 2, 2));
|
|
|
|
|
modelList2.add(new ModelValue("项目费用", false, 0, 3, false, 0, 1, 3, 3));
|
|
|
|
|
modelList2.add(new ModelValue("项目阶段", false, 0, 4, false, 0, 0, 4, 7));
|
|
|
|
|
modelList2.add(new ModelValue("DV", false, 1, 4, false));
|
|
|
|
|
modelList2.add(new ModelValue("PV", false, 1, 5, false));
|
|
|
|
|
modelList2.add(new ModelValue("PR", false, 1, 6, false));
|
|
|
|
|
modelList2.add(new ModelValue("SR", false, 1, 7, false));
|
|
|
|
|
modelList2.add(new ModelValue("备注", false, 0, 8, false, 0, 1, 8, 8));
|
|
|
|
|
|
|
|
|
|
String type = null;
|
|
|
|
|
int typeSpan = 0;
|
|
|
|
|
data = TCTableUtil.getTableRows(form, "jd2_xpcsxqd", colNames);
|
|
|
|
|
if (data.length == 0) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
dbData = Db.use().query("select * from JD2_Machine ORDER BY TEST_TYPE ASC");
|
|
|
|
|
model2 = new CTMap(dbData.size() + 3, 9);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dbData.size(); i++) {
|
|
|
|
|
System.out.println(dbData.get(i).toString());
|
|
|
|
|
modelList2.add(new ModelValue(dbData.get(i).getStr("TEST_PROJECT"), false, i + 2, 2, false));
|
|
|
|
|
modelList2.add(new ModelValue(dbData.get(i).getInt("TEST_COST") + "", false, i + 2, 3, false));
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
type = dbData.get(i).getStr("TEST_TYPE");
|
|
|
|
|
}
|
|
|
|
|
if ((type != null && !type.equals(dbData.get(i).getStr("TEST_TYPE")))) {
|
|
|
|
|
System.out.println(type);
|
|
|
|
|
modelList2.add(
|
|
|
|
|
new ModelValue(type, false, i - typeSpan + 2, 1, false, i - typeSpan + 2, i + 1, 1, 1));
|
|
|
|
|
type = dbData.get(i).getStr("TEST_TYPE");
|
|
|
|
|
typeSpan = 0;
|
|
|
|
|
}
|
|
|
|
|
if ((i == dbData.size() - 1)) {
|
|
|
|
|
System.out.println(type);
|
|
|
|
|
modelList2.add(
|
|
|
|
|
new ModelValue(type, false, i - typeSpan + 2, 1, false, i - typeSpan + 2, i + 2, 1, 1));
|
|
|
|
|
}
|
|
|
|
|
model2.setValueAt(i + 1, i + 2, 0);
|
|
|
|
|
for (int ii = 4; ii < 8; ii++) {
|
|
|
|
|
model2.setValueAt("/", i + 2, ii);
|
|
|
|
|
}
|
|
|
|
|
typeSpan++;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
model2 = new CTMap(data.length + 3, 9);
|
|
|
|
|
for (int i = 0; i < data.length; i++) {
|
|
|
|
|
System.out.println(Arrays.toString(data[i]));
|
|
|
|
|
modelList2.add(new ModelValue(data[i][2], false, i + 2, 2, false));
|
|
|
|
|
modelList2.add(new ModelValue(data[i][3], false, i + 2, 3, false));
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
type = data[i][1];
|
|
|
|
|
}
|
|
|
|
|
if ((type != null && !type.equals(data[i][1]))) {
|
|
|
|
|
System.out.println(type);
|
|
|
|
|
modelList2.add(
|
|
|
|
|
new ModelValue(type, false, i - typeSpan + 2, 1, false, i - typeSpan + 2, i + 1, 1, 1));
|
|
|
|
|
type = data[i][1];
|
|
|
|
|
typeSpan = 0;
|
|
|
|
|
}
|
|
|
|
|
if ((i == data.length - 1)) {
|
|
|
|
|
System.out.println(type);
|
|
|
|
|
modelList2.add(
|
|
|
|
|
new ModelValue(type, false, i - typeSpan + 2, 1, false, i - typeSpan + 2, i + 2, 1, 1));
|
|
|
|
|
}
|
|
|
|
|
model2.setValueAt(i + 1, i + 2, 0);
|
|
|
|
|
for (int ii = 4; ii < 9; ii++) {
|
|
|
|
|
model2.setValueAt(data[i][ii], i + 2, ii);
|
|
|
|
|
}
|
|
|
|
|
typeSpan++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int buttom = data.length == 0 ? dbData.size() + 2 : data.length + 2;
|
|
|
|
|
modelList2.add(new ModelValue("项目费用合计", false, buttom, 0, false, buttom, buttom, 0, 2));
|
|
|
|
|
modelList2.add(new ModelValue("jd2_zfy", true, buttom, 3, false));
|
|
|
|
|
modelList2.add(new ModelValue("jd2_dvfy", true, buttom, 4, false));
|
|
|
|
|
modelList2.add(new ModelValue("jd2_pvfy", true, buttom, 5, false));
|
|
|
|
|
modelList2.add(new ModelValue("jd2_prfy", true, buttom, 6, false));
|
|
|
|
|
modelList2.add(new ModelValue("jd2_srfy", true, buttom, 7, false));
|
|
|
|
|
|
|
|
|
|
initModel(model2, modelList2);
|
|
|
|
|
|
|
|
|
|
table2 = new CTable(model2) {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isCellEditable(int row, int col) {
|
|
|
|
|
if (modelList2.isDisableEdit(row, col) || col == 0 || row == table2.getRowCount() - 1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
table2.setRowHeight(25);
|
|
|
|
|
table2.setBorder(BorderFactory.createLineBorder(Color.black));
|
|
|
|
|
table2.getColumnModel().getColumn(0).setPreferredWidth(100);
|
|
|
|
|
table2.getColumnModel().getColumn(1).setPreferredWidth(60);
|
|
|
|
|
table2.getColumnModel().getColumn(2).setPreferredWidth(80);
|
|
|
|
|
table2.getColumnModel().getColumn(3).setPreferredWidth(60);
|
|
|
|
|
table2.getColumnModel().getColumn(4).setPreferredWidth(50);
|
|
|
|
|
table2.getColumnModel().getColumn(5).setPreferredWidth(50);
|
|
|
|
|
table2.getColumnModel().getColumn(6).setPreferredWidth(50);
|
|
|
|
|
table2.getColumnModel().getColumn(7).setPreferredWidth(50);
|
|
|
|
|
table2.getColumnModel().getColumn(8).setPreferredWidth(60);
|
|
|
|
|
|
|
|
|
|
DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() {
|
|
|
|
|
// 重写方法
|
|
|
|
|
@Override
|
|
|
|
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
|
|
|
|
boolean hasFocus, int row, int column) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
int maxPreferredHeight = 0;
|
|
|
|
|
for (int i = 0; i < table.getColumnCount(); i++) {
|
|
|
|
|
setText("" + table.getValueAt(row, i));
|
|
|
|
|
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
|
|
|
|
|
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
|
|
|
|
|
}
|
|
|
|
|
setBackground(Color.white);
|
|
|
|
|
// if(points1.contains(new Point(row,column)))
|
|
|
|
|
// setForeground(new Color(0,0,255));
|
|
|
|
|
// else
|
|
|
|
|
setForeground(Color.black);
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
setBackground(new Color(0, 120, 215));
|
|
|
|
|
setForeground(Color.white);
|
|
|
|
|
}
|
|
|
|
|
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
|
|
|
|
|
table.setRowHeight(row, maxPreferredHeight);
|
|
|
|
|
|
|
|
|
|
setText(value == null ? "" : value.toString());
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DefaultCellEditor dce = new DefaultCellEditor(new JTextField()) {
|
|
|
|
|
JTable table;
|
|
|
|
|
int row;
|
|
|
|
|
int col;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Component getTableCellEditorComponent(JTable paramJTable, Object paramObject, boolean paramBoolean,
|
|
|
|
|
int paramInt1, int paramInt2) {
|
|
|
|
|
this.table = paramJTable;
|
|
|
|
|
this.row = paramInt1;
|
|
|
|
|
this.col = paramInt2;
|
|
|
|
|
return super.getTableCellEditorComponent(paramJTable, paramObject, paramBoolean, paramInt1, paramInt2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object getCellEditorValue() {
|
|
|
|
|
Object obj = super.getCellEditorValue();
|
|
|
|
|
if (obj != null) {
|
|
|
|
|
String objStr = obj.toString().trim();
|
|
|
|
|
try {
|
|
|
|
|
if ("/".equals(objStr)) {
|
|
|
|
|
objStr = "0";
|
|
|
|
|
}
|
|
|
|
|
int num = Integer.parseInt(objStr);
|
|
|
|
|
if (num < 0) {
|
|
|
|
|
System.out.println("计算区域只能输入自然数或\"/\"");
|
|
|
|
|
MessageBox.post("计算区域只能输入自然数或\"/\"", "错误", MessageBox.ERROR);
|
|
|
|
|
return "/";
|
|
|
|
|
}
|
|
|
|
|
int sum = 0;
|
|
|
|
|
Object sumObj;
|
|
|
|
|
for (int i = 2; i < row; i++) {
|
|
|
|
|
sumObj = table.getValueAt(i, col);
|
|
|
|
|
if (sumObj != null && !"/".equals(sumObj.toString().trim())) {
|
|
|
|
|
sum += Double.parseDouble(
|
|
|
|
|
(sumObj = table.getValueAt(i, 3)) == null ? "0" : sumObj.toString().trim());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!"0".equals(objStr)) {
|
|
|
|
|
sum += Double.parseDouble(
|
|
|
|
|
(sumObj = table.getValueAt(row, 3)) == null ? "0" : sumObj.toString().trim());
|
|
|
|
|
}
|
|
|
|
|
for (int i = row + 1; i < table.getRowCount() - 1; i++) {
|
|
|
|
|
sumObj = table.getValueAt(i, col);
|
|
|
|
|
if (sumObj != null && !"/".equals(sumObj.toString().trim())) {
|
|
|
|
|
sum += Double.parseDouble(
|
|
|
|
|
(sumObj = table.getValueAt(i, 3)) == null ? "0" : sumObj.toString().trim());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
table.setValueAt(sum, table.getRowCount() - 1, col);
|
|
|
|
|
double sum1 = Double
|
|
|
|
|
.parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 4)) == null ? "0"
|
|
|
|
|
: sumObj.toString().trim());
|
|
|
|
|
double sum2 = Double
|
|
|
|
|
.parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 5)) == null ? "0"
|
|
|
|
|
: sumObj.toString().trim());
|
|
|
|
|
double sum3 = Double
|
|
|
|
|
.parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 6)) == null ? "0"
|
|
|
|
|
: sumObj.toString().trim());
|
|
|
|
|
double sum4 = Double
|
|
|
|
|
.parseDouble((sumObj = table.getValueAt(table.getRowCount() - 1, 7)) == null ? "0"
|
|
|
|
|
: sumObj.toString().trim());
|
|
|
|
|
table.setValueAt(sum1 + sum2 + sum3 + sum4, table.getRowCount() - 1, 3);
|
|
|
|
|
table2.revalidate();
|
|
|
|
|
table2.repaint();
|
|
|
|
|
} catch (NumberFormatException e1) {
|
|
|
|
|
System.out.println("计算区域只能输入自然数或\"/\"");
|
|
|
|
|
MessageBox.post("计算区域只能输入自然数或\"/\"", "错误", MessageBox.ERROR);
|
|
|
|
|
obj = "/";
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
e2.printStackTrace();
|
|
|
|
|
obj = "/";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ("0".equals(obj.toString().trim())) {
|
|
|
|
|
obj = "/";
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
tcr2.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
table2.getColumnModel().getColumn(4).setCellEditor(dce);
|
|
|
|
|
table2.getColumnModel().getColumn(5).setCellEditor(dce);
|
|
|
|
|
table2.getColumnModel().getColumn(6).setCellEditor(dce);
|
|
|
|
|
table2.getColumnModel().getColumn(7).setCellEditor(dce);
|
|
|
|
|
table2.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN);
|
|
|
|
|
table2.setDefaultRenderer(Object.class, tcr2);
|
|
|
|
|
table2.addMouseListener(rightClick());
|
|
|
|
|
inner.add(table2, BorderLayout.SOUTH);
|
|
|
|
|
|
|
|
|
|
JPanel btns = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
|
|
|
|
JButton create = new JButton("创建测试计划");
|
|
|
|
|
create.addActionListener(create());
|
|
|
|
|
btns.add(create);
|
|
|
|
|
|
|
|
|
|
menu.setVisible(false);
|
|
|
|
|
addR = new JMenuItem("新增测试项");
|
|
|
|
|
addR.setEnabled(false);
|
|
|
|
|
addR.addActionListener(addRow());
|
|
|
|
|
menu.add(addR);
|
|
|
|
|
|
|
|
|
|
ScrollPane sc = new ScrollPane();
|
|
|
|
|
sc.add(inner);
|
|
|
|
|
root.add(sc, BorderLayout.CENTER);
|
|
|
|
|
root.add(btns, BorderLayout.SOUTH);
|
|
|
|
|
this.add(root);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void saveRendering() {
|
|
|
|
|
|
|
|
|
|
savePropValue(table1, modelList1);
|
|
|
|
|
savePropValue(table2, modelList2);
|
|
|
|
|
|
|
|
|
|
Object obj;
|
|
|
|
|
if (data.length == 0) {
|
|
|
|
|
if (dbData.size() == 0) {
|
|
|
|
|
try {
|
|
|
|
|
dbData = Db.use().query("select * from JD2_Machine ORDER BY TEST_TYPE ASC");
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
data = new String[table2.getRowCount() - 3][9];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dbData.size(); i++) {
|
|
|
|
|
data[i][0] = (obj = model2.getValueAt(i + 2, 0)) == null ? "" : obj.toString();
|
|
|
|
|
data[i][1] = dbData.get(i).getStr("TEST_TYPE");
|
|
|
|
|
data[i][2] = dbData.get(i).getStr("TEST_PROJECT");
|
|
|
|
|
data[i][3] = dbData.get(i).getStr("TEST_COST");
|
|
|
|
|
for (int ii = 4; ii < 9; ii++) {
|
|
|
|
|
data[i][ii] = (obj = model2.getValueAt(i + 2, ii)) == null ? "" : obj.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println("dbData.size() " + dbData.size());
|
|
|
|
|
System.out.println("table2.getRowCount() " + table2.getRowCount());
|
|
|
|
|
for (int i = dbData.size() + 2; i < table2.getRowCount() - 1; i++) {
|
|
|
|
|
for (int ii = 0; ii < 9; ii++) {
|
|
|
|
|
data[i][ii] = (obj = model2.getValueAt(i + 2, ii)) == null ? "" : obj.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println(Arrays.deepToString(data));
|
|
|
|
|
TCTableUtil.setTableRows(form, "jd2_xpcsxqd", "JD2_XPCSXQD", colNames, data);
|
|
|
|
|
} else {
|
|
|
|
|
String[][] newData = new String[table2.getRowCount() - 3][9];
|
|
|
|
|
for (int i = 0; i < data.length; i++) {
|
|
|
|
|
System.arraycopy(data[i], 0, newData[i], 0, 4);
|
|
|
|
|
for (int ii = 4; ii < 9; ii++) {
|
|
|
|
|
newData[i][ii] = (obj = model2.getValueAt(i + 2, ii)) == null ? "" : obj.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = data.length + 2; i < table2.getRowCount() - 1; i++) {
|
|
|
|
|
for (int ii = 0; ii < 9; ii++) {
|
|
|
|
|
newData[i][ii] = (obj = model2.getValueAt(i + 2, ii)) == null ? "" : obj.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println(Arrays.deepToString(newData));
|
|
|
|
|
TCTableUtil.setTableRows(form, "jd2_xpcsxqd", "JD2_XPCSXQD", colNames, newData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void savePropValue(CTable table, ModelList ml) {
|
|
|
|
|
for (ModelValue mv : ml) {
|
|
|
|
|
if (mv.isProp()) {
|
|
|
|
|
Object obj = table.getValueAt(mv.getRow(), mv.getCol());
|
|
|
|
|
try {
|
|
|
|
|
if (prop.containsKey(mv.getValue())) {
|
|
|
|
|
form.setProperty(mv.getValue(), obj == null ? "" : obj.toString());
|
|
|
|
|
}
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MouseAdapter rightClick() {
|
|
|
|
|
return new MouseAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table2.getSelectedRow() != -1) {
|
|
|
|
|
int row = table2.getSelectedRow();
|
|
|
|
|
boolean flag = (row > 1 && row < table2.getRowCount() - 1);
|
|
|
|
|
addR.setEnabled(flag);
|
|
|
|
|
menu.show(e.getComponent(), e.getX(), e.getY());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ActionListener addRow() {
|
|
|
|
|
return new ActionListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent paramActionEvent) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
int row = model2.getRowCount() - 2;
|
|
|
|
|
int num = Integer.parseInt(model2.getValueAt(row, 0).toString());
|
|
|
|
|
model2.insertRow(model2.getRowCount() - 1);
|
|
|
|
|
model2.setValueAt(num + 1, row + 1, 0);
|
|
|
|
|
table2.revalidate();
|
|
|
|
|
table2.repaint();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ActionListener create() {
|
|
|
|
|
return new ActionListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent paramActionEvent) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
try {
|
|
|
|
|
AIFComponentContext[] comps = form.whereReferenced();
|
|
|
|
|
StringBuilder msg = new StringBuilder();
|
|
|
|
|
A1: for (AIFComponentContext aif : comps) {
|
|
|
|
|
System.out.println("ref type:" + aif.getComponent().getType());
|
|
|
|
|
if ("JD2_GTXPCSXQDRevision".equals(aif.getComponent().getType())) {
|
|
|
|
|
TCComponentItemRevision rev = (TCComponentItemRevision) aif.getComponent();
|
|
|
|
|
TCComponent[] compArr = rev.getTCProperty("JD2_CSJH").getReferenceValueArray();
|
|
|
|
|
String exist = "";
|
|
|
|
|
for (TCComponent t : compArr) {
|
|
|
|
|
exist += t.getProperty("object_name");
|
|
|
|
|
}
|
|
|
|
|
List<String[]> colData = new ArrayList<String[]>();
|
|
|
|
|
String ownner = form.getTCProperty("owning_user").getUIFValue();
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
if (exist.contains(jieduan[i])) {
|
|
|
|
|
System.out.println("已存在阶段\"" + jieduan[i] + "\"测试计划,请检查!");
|
|
|
|
|
MessageBox.post("已存在阶段\"" + jieduan[i] + "\"测试计划,请检查!", "错误", MessageBox.ERROR);
|
|
|
|
|
break A1;
|
|
|
|
|
}
|
|
|
|
|
Object obj;
|
|
|
|
|
Object temp;
|
|
|
|
|
int rowNum = 0;
|
|
|
|
|
for (int ii = 2; ii < table2.getRowCount() - 1; ii++) {
|
|
|
|
|
obj = table2.getValueAt(ii, i + 4);
|
|
|
|
|
if (obj != null && !"/".equals(obj.toString().trim())) {
|
|
|
|
|
// colNames2 = { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syfy",
|
|
|
|
|
// "jd2_sycs" };
|
|
|
|
|
String[] row = new String[6];
|
|
|
|
|
row[0] = rowNum + "";
|
|
|
|
|
row[1] = ownner;
|
|
|
|
|
row[2] = (temp = table2.getValueAt(ii, 2)) == null ? "" : temp.toString();
|
|
|
|
|
row[3] = obj.toString().trim();
|
|
|
|
|
row[4] = (temp = table2.getValueAt(ii, 3)) == null ? "0"
|
|
|
|
|
: temp.toString().trim();
|
|
|
|
|
row[5] = "1";
|
|
|
|
|
System.out.println(Arrays.toString(row));
|
|
|
|
|
colData.add(row);
|
|
|
|
|
rowNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (colData.size() != 0) {
|
|
|
|
|
TCComponentItemType type = (TCComponentItemType) session
|
|
|
|
|
.getTypeComponent("JD2_GTXPXMCSJH");
|
|
|
|
|
TCComponentItem item = type.create(null, null, "JD2_GTXPXMCSJH",
|
|
|
|
|
jieduan[i] + "阶段测试计划", "", null);
|
|
|
|
|
rev.add("JD2_CSJH", item);
|
|
|
|
|
TCComponentItemRevision rev1 = item.getLatestItemRevision();
|
|
|
|
|
TCComponentForm form1 = (TCComponentForm) rev1
|
|
|
|
|
.getRelatedComponents("IMAN_master_form_rev")[0];
|
|
|
|
|
String[][] dataArr = colData.toArray(new String[colData.size()][6]);
|
|
|
|
|
System.out.println(Arrays.deepToString(dataArr));
|
|
|
|
|
TCTableUtil.setTableRows(form1, "jd2_csjhtable", "JD2_CSJHTABLE", colNames2,
|
|
|
|
|
dataArr);
|
|
|
|
|
msg.append(jieduan[i] + "阶段测试计划创建成功\n");
|
|
|
|
|
}
|
|
|
|
|
colData.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MessageBox.post(msg.toString(), "提示", MessageBox.WARNING);
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isRenderingModified() {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return form.isCheckedOut();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initModel(CTMap model, ModelList modelList) {
|
|
|
|
|
for (ModelValue mv : modelList) {
|
|
|
|
|
if (mv.isProp()) {
|
|
|
|
|
if (prop.containsKey(mv.getValue())) {
|
|
|
|
|
model.setValueAt(prop.get(mv.getValue()), mv.getRow(), mv.getCol());
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("属性‘" + mv.getValue() + "’不存在");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
model.setValueAt(mv.getValue(), mv.getRow(), mv.getCol());
|
|
|
|
|
}
|
|
|
|
|
if (mv.isCombine()) {
|
|
|
|
|
model.combine(mv.getCombineRows(), mv.getCombineColumns());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isEditorDisable(List<String> list, int row, int col) {
|
|
|
|
|
return list.contains(row + "," + col);
|
|
|
|
|
private void saveModel(ModelList modelList) {
|
|
|
|
|
Object obj;
|
|
|
|
|
for (ModelValue mv : modelList) {
|
|
|
|
|
if (mv.isProp()) {
|
|
|
|
|
if (prop.containsKey(mv.getValue())) {
|
|
|
|
|
obj = table2.getValueAt(mv.getRow(), mv.getCol());
|
|
|
|
|
try {
|
|
|
|
|
form.setProperty(mv.getValue(), obj == null ? "" : obj.toString());
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("属性\"" + mv.getValue() + "\"不存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|