Merge pull request 'zouxk' (#2) from zouxk into master
commit
ff23109716
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.connor.jd.plm</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
||||
## db.setting文件
|
||||
|
||||
#url = jdbc:oracle:thin:@localhost:1521:TC
|
||||
url = jdbc:oracle:thin:@10.20.4.75:1521:TC12
|
||||
user = infodba
|
||||
pass = infodba
|
||||
|
||||
## 可选配置
|
||||
# 是否在日志中显示执行的SQL
|
||||
showSql = true
|
||||
# 是否格式化显示的SQL
|
||||
formatSql = false
|
||||
# 是否显示SQL参数
|
||||
showParams = true
|
@ -0,0 +1,10 @@
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String fileName = "111.xlsx";
|
||||
String[] filename = fileName.split("\\.");
|
||||
System.out.println(fileName.lastIndexOf("."));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.connor.jd.plm.beans;
|
||||
|
||||
public class JG {
|
||||
int row;
|
||||
int times;
|
||||
String jg;
|
||||
|
||||
public JG(int row, int times, String jg) {
|
||||
super();
|
||||
this.row = row;
|
||||
this.times = times;
|
||||
this.jg = jg;
|
||||
}
|
||||
|
||||
public int getTimes() {
|
||||
return times;
|
||||
}
|
||||
|
||||
public void setTimes(int times) {
|
||||
this.times = times;
|
||||
}
|
||||
|
||||
public String getJg() {
|
||||
return jg;
|
||||
}
|
||||
|
||||
public void setJg(String jg) {
|
||||
this.jg = jg;
|
||||
}
|
||||
|
||||
public int getRow() {
|
||||
return row;
|
||||
}
|
||||
|
||||
public void setRow(int row) {
|
||||
this.row = row;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.connor.jd.plm.dialog;
|
||||
|
||||
public class DocumentTemplate {
|
||||
private String type;// 模板类型
|
||||
private String[] relation;// 数据集关系
|
||||
private String uid;// 模板uid
|
||||
|
||||
public DocumentTemplate(String type, String uid, String[] relation) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.relation = relation;
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String[] getRelation() {
|
||||
return relation;
|
||||
}
|
||||
|
||||
public void setRelation(String[] relation) {
|
||||
this.relation = relation;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.connor.jd.plm.dialog;
|
||||
|
||||
import javafx.scene.control.Dialog;
|
||||
|
||||
public class MsgDialog extends Dialog<String> {
|
||||
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
package com.connor.jd.plm.form;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
import com.connor.jd.plm.table.CTMap;
|
||||
import com.connor.jd.plm.table.CTable;
|
||||
import com.connor.jd.plm.table.MyCellEditor4;
|
||||
import com.connor.jd.plm.table.TCTableUtil;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
|
||||
import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
|
||||
public class ComponentTestFrame extends JFrame {
|
||||
private CTMap model;
|
||||
private CTable table;
|
||||
private List<Entity> list;
|
||||
private int bottom;
|
||||
private Container container;
|
||||
private TCComponentForm form;
|
||||
private TCSession session;
|
||||
private MyCallBack callBack;
|
||||
|
||||
private static ComponentTestFrame instance;
|
||||
|
||||
public static ComponentTestFrame getInstance(TCComponentForm form, MyCallBack callBack) {
|
||||
if (instance == null) {
|
||||
instance = new ComponentTestFrame(form);
|
||||
instance.callBack = callBack;
|
||||
} else {
|
||||
instance.bottom = 0;
|
||||
instance.form = form;
|
||||
instance.callBack = callBack;
|
||||
instance.init();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ComponentTestFrame(TCComponentForm form) {
|
||||
this.form = form;
|
||||
this.session = (TCSession) AIFUtility.getCurrentApplication().getSession();
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.setTitle("部件测试项目");
|
||||
this.setSize(560, 400);
|
||||
this.setResizable(true);
|
||||
this.setAlwaysOnTop(true);
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
container = this.getContentPane();
|
||||
container.setLayout(new BorderLayout());
|
||||
container.setPreferredSize(new Dimension(600, 400));
|
||||
|
||||
model = new CTMap(10, 7);
|
||||
model.setValueAt("序号", 0, 0);
|
||||
model.setValueAt("部品类型", 0, 1);
|
||||
model.setValueAt("试验项目", 0, 2);
|
||||
model.setValueAt("试验时间", 0, 3);
|
||||
model.setValueAt("样品数量", 0, 4);
|
||||
model.setValueAt("试验费用", 0, 5);
|
||||
model.setValueAt("是否选择", 0, 6);
|
||||
|
||||
table = new CTable(model) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
if (row == 0 || col == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
table.setRowHeight(25);
|
||||
table.setBorder(BorderFactory.createLineBorder(Color.black));
|
||||
for (int i = 0; i < model.getColumnCount(); i++) {
|
||||
table.getColumnModel().getColumn(i).setPreferredWidth(80);
|
||||
}
|
||||
DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() {
|
||||
// 重写方法
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||
boolean hasFocus, int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (value instanceof JCheckBox) {
|
||||
return (JCheckBox) value;
|
||||
}
|
||||
|
||||
int maxPreferredHeight = 0;
|
||||
for (int i = 0; i < table.getColumnCount(); i++) {
|
||||
setText("" + table.getValueAt(row, i));
|
||||
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
|
||||
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
|
||||
}
|
||||
setBackground(Color.white);
|
||||
// if(points1.contains(new Point(row,column)))
|
||||
// setForeground(new Color(0,0,255));
|
||||
// else
|
||||
setForeground(Color.black);
|
||||
if (isSelected) {
|
||||
setBackground(new Color(0, 120, 215));
|
||||
setForeground(Color.white);
|
||||
}
|
||||
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
|
||||
table.setRowHeight(row, maxPreferredHeight);
|
||||
|
||||
setText(value == null ? "" : value.toString());
|
||||
return this;
|
||||
}
|
||||
};
|
||||
tcr1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
table.setDefaultRenderer(Object.class, tcr1);
|
||||
table.getColumnModel().getColumn(6).setCellEditor(new MyCellEditor4(new JTextField()));
|
||||
|
||||
// 填写数据
|
||||
try {
|
||||
list = Db.use().findAll("JD2_COMPONENT");
|
||||
bottom = list.size();
|
||||
for (int i = 0; i < bottom; i++) {
|
||||
if (i > model.getRowCount() - 2) {
|
||||
model.addRow();
|
||||
}
|
||||
int row = i + 1;
|
||||
model.setValueAt(row, row, 0);
|
||||
model.setValueAt(list.get(i).getStr("TEST_TYPE"), row, 1);
|
||||
model.setValueAt(list.get(i).getStr("TEST_PROJECT"), row, 2);
|
||||
model.setValueAt(list.get(i).getStr("TEST_TIME"), row, 3);
|
||||
model.setValueAt(list.get(i).getInt("TEST_NUM"), row, 4);
|
||||
model.setValueAt(list.get(i).getInt("TEST_COST"), row, 5);
|
||||
model.setValueAt(new JCheckBox(), row, 6);
|
||||
|
||||
System.out.println(list.get(i).toString());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 按钮
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
JButton createTest = new JButton("创建测试计划");
|
||||
createTest.addActionListener(createTest());
|
||||
JButton addTestItem = new JButton("新增测试项");
|
||||
addTestItem.addActionListener(addTestItem());
|
||||
JButton cancel = new JButton("取消");
|
||||
cancel.addActionListener(cancel());
|
||||
buttonPanel.add(createTest);
|
||||
buttonPanel.add(addTestItem);
|
||||
buttonPanel.add(cancel);
|
||||
|
||||
ScrollPane scrollPane = new ScrollPane();
|
||||
scrollPane.add(table);
|
||||
|
||||
container.add(scrollPane, BorderLayout.CENTER);
|
||||
container.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private ActionListener createTest() {
|
||||
return new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
TCComponentItemRevision rev = (TCComponentItemRevision) form.whereReferenced()[0].getComponent();
|
||||
|
||||
TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("Item");
|
||||
TCComponentItem item = type.create(null, null, "JD2_GTCSJH", "测试计划", "", null);
|
||||
rev.add("JD2_CSJH", item);
|
||||
TCComponentItemRevision rev1 = item.getLatestItemRevision();
|
||||
TCComponentForm form1 = (TCComponentForm) rev1.getRelatedComponents("IMAN_master_form_rev")[0];
|
||||
String[] colNames = new String[] { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq",
|
||||
"jd2_syfy", "jd2_sycs" };
|
||||
List<String[]> list = new ArrayList<String[]>();
|
||||
String[] row = new String[7];
|
||||
for (int i = 1; i <= bottom; i++) {
|
||||
JCheckBox jb = (JCheckBox) model.getValueAt(i, 6);
|
||||
if (jb.isSelected()) {
|
||||
for (int ii = 2; ii < 6; ii++) {
|
||||
row[ii - 2] = model.getValueAt(i, ii) == null ? "" : model.getValueAt(i, ii).toString();
|
||||
}
|
||||
// TCComponentPerson p = (TCComponentPerson) session.getUser().getUserInformation().get(0);
|
||||
list.add(new String[] { i + "", form.getTCProperty("owning_user").getUIFValue(), row[0],
|
||||
row[2], row[1], row[3], "1" });
|
||||
}
|
||||
}
|
||||
String[][] data = list.toArray(new String[list.size()][7]);
|
||||
TCTableUtil.setTableRows(form1, "jd2_csjh", "JD2_CSJHTABLE", colNames, data);
|
||||
callBack.execute(item.getProperty("item_id"));
|
||||
dispose();
|
||||
} catch (TCException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private ActionListener addTestItem() {
|
||||
return new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
if (bottom > model.getRowCount() - 2) {
|
||||
model.addRow();
|
||||
}
|
||||
int num = 1;
|
||||
if (bottom > 0) {
|
||||
num = Integer.parseInt(model.getValueAt(bottom, 0).toString());
|
||||
}
|
||||
model.setValueAt(num + 1, ++bottom, 0);
|
||||
model.setValueAt(new JCheckBox(), bottom, 6);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
container.removeAll();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private ActionListener cancel() {
|
||||
return new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
dispose();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,558 @@
|
||||
package com.connor.jd.plm.form;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
import com.connor.jd.plm.table.CTMap;
|
||||
import com.connor.jd.plm.table.CTable;
|
||||
import com.connor.jd.plm.table.JCheckPanel;
|
||||
import com.connor.jd.plm.table.MyCellEditor3;
|
||||
import com.connor.jd.plm.table.TCTableUtil;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.stylesheet.AbstractRendering;
|
||||
|
||||
public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implements MyCallBack {
|
||||
private TCComponentForm form;
|
||||
private CTMap model;
|
||||
private CTable table;
|
||||
private int top = 10;
|
||||
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;
|
||||
private JMenuItem delR;
|
||||
private JMenuItem test;
|
||||
private String[] colNames = new String[] { "jd2_no", "jd2_name", "jd2_bgq", "jd2_bgh", "jd2_risk", "jd2_csjh",
|
||||
"jd2_bz" };
|
||||
private String[][] rows;
|
||||
private ExperimentalPowerOfAttorneyForm $this;
|
||||
|
||||
public ExperimentalPowerOfAttorneyForm(TCComponent arg0) throws Exception {
|
||||
super(arg0);
|
||||
if (arg0 instanceof TCComponentForm) {
|
||||
this.form = (TCComponentForm) arg0;
|
||||
loadRendering();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadRendering() throws TCException {
|
||||
$this = this;
|
||||
|
||||
this.setLayout(new BorderLayout());
|
||||
JPanel root = new JPanel(new BorderLayout());
|
||||
root.setPreferredSize(new Dimension(800, 500));
|
||||
|
||||
// 内容
|
||||
prop = form.getProperties();
|
||||
model = new CTMap(20, 11);
|
||||
bottom = model.getRowCount() - end;
|
||||
|
||||
model2 = new CTMap(3, 11);
|
||||
|
||||
initModel();
|
||||
|
||||
table = new CTable(model) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
if (isEditorDisable(disableEdit, row, col)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
table.setRowHeight(25);
|
||||
table.setBorder(BorderFactory.createLineBorder(Color.black));
|
||||
table.getColumnModel().getColumn(0).setPreferredWidth(40);
|
||||
table.getColumnModel().getColumn(1).setPreferredWidth(100);
|
||||
table.getColumnModel().getColumn(2).setPreferredWidth(80);
|
||||
table.getColumnModel().getColumn(3).setPreferredWidth(80);
|
||||
table.getColumnModel().getColumn(4).setPreferredWidth(80);
|
||||
table.getColumnModel().getColumn(5).setPreferredWidth(80);
|
||||
table.getColumnModel().getColumn(6).setPreferredWidth(80);
|
||||
table.getColumnModel().getColumn(7).setPreferredWidth(80);
|
||||
table.getColumnModel().getColumn(8).setPreferredWidth(80);
|
||||
table.getColumnModel().getColumn(9).setPreferredWidth(150);
|
||||
table.getColumnModel().getColumn(10).setPreferredWidth(60);
|
||||
|
||||
DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() {
|
||||
// 重写方法
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||
boolean hasFocus, int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (value instanceof JPanel) {
|
||||
return (JPanel) value;
|
||||
}
|
||||
|
||||
int maxPreferredHeight = 0;
|
||||
for (int i = 0; i < table.getColumnCount(); i++) {
|
||||
setText("" + table.getValueAt(row, i));
|
||||
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
|
||||
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
|
||||
}
|
||||
setBackground(Color.white);
|
||||
// if(points1.contains(new Point(row,column)))
|
||||
// setForeground(new Color(0,0,255));
|
||||
// else
|
||||
setForeground(Color.black);
|
||||
if (isSelected) {
|
||||
setBackground(new Color(0, 120, 215));
|
||||
setForeground(Color.white);
|
||||
}
|
||||
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
|
||||
table.setRowHeight(row, maxPreferredHeight);
|
||||
|
||||
setText(value == null ? "" : value.toString());
|
||||
return this;
|
||||
}
|
||||
};
|
||||
tcr1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
table.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN);
|
||||
table.setDefaultRenderer(Object.class, tcr1);
|
||||
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("新增行");
|
||||
addR.setEnabled(false);
|
||||
menu.add(addR);
|
||||
addR.addActionListener(addRow());
|
||||
delR = new JMenuItem("删除行");
|
||||
delR.setEnabled(false);
|
||||
menu.add(delR);
|
||||
delR.addActionListener(delRow());
|
||||
test = new JMenuItem("测试项");
|
||||
test.setEnabled(false);
|
||||
menu.add(test);
|
||||
test.addActionListener(test());
|
||||
|
||||
// 填写数据
|
||||
for (Entry<String, int[]> entry : general.entrySet()) {
|
||||
if (prop.containsKey(entry.getKey())) {
|
||||
model.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]);
|
||||
} else {
|
||||
System.out.println("未找到属性 " + entry.getKey());
|
||||
}
|
||||
}
|
||||
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 {
|
||||
System.out.println("未找到属性 jd2_bgqf");
|
||||
}
|
||||
rows = TCTableUtil.getTableRows(form, "jd2_sywts", colNames);
|
||||
for (int i = 0; i < rows.length; i++) {
|
||||
if (top + i + 1 > bottom) {
|
||||
this.addRow();
|
||||
}
|
||||
for (int ii = 0; ii < rows[0].length; ii++) {
|
||||
model.setValueAt(rows[i][ii], top + i + 1, ii > 2 ? ii > 3 ? ii + 4 : ii + 2 : ii);
|
||||
}
|
||||
}
|
||||
JPanel inner = new JPanel(new BorderLayout());
|
||||
inner.add(table, BorderLayout.CENTER);
|
||||
inner.add(table2, BorderLayout.SOUTH);
|
||||
ScrollPane pane = new ScrollPane();
|
||||
pane.add(inner);
|
||||
// ScrollPane pane2 = new ScrollPane();
|
||||
// pane2.add(table2);
|
||||
root.add(pane, BorderLayout.CENTER);
|
||||
// root.add(pane2, BorderLayout.SOUTH);
|
||||
this.add(menu);
|
||||
this.add(root);
|
||||
}
|
||||
|
||||
private void initModel() {
|
||||
disableEdit = new ArrayList<>();// 不允许编辑
|
||||
general = new HashMap<String, int[]>();// 要填写的一般属性
|
||||
model.setValueAt("吉德", 0, 0);
|
||||
disableEdit.add("0,0");
|
||||
model.setValueAt("试验委托书", 0, 3);
|
||||
disableEdit.add("0,3");
|
||||
model.setValueAt("表号", 0, 8);
|
||||
disableEdit.add("0,8");
|
||||
model.setValueAt("生效期", 1, 8);
|
||||
disableEdit.add("1,8");
|
||||
general.put("jd2_bh", new int[] { 0, 9 });
|
||||
general.put("jd2_sxr", new int[] { 1, 9 });
|
||||
model.setValueAt("委托项目:", 3, 0);
|
||||
disableEdit.add("3,0");
|
||||
model.setValueAt("委托部门:", 4, 0);
|
||||
disableEdit.add("4,0");
|
||||
general.put("jd2_wtxm", new int[] { 3, 3 });
|
||||
general.put("jd2_wtbm", new int[] { 4, 3 });
|
||||
model.setValueAt("供货厂家:", 3, 6);
|
||||
disableEdit.add("3,6");
|
||||
model.setValueAt("接受部门:", 4, 6);
|
||||
disableEdit.add("4,6");
|
||||
general.put("jd2_ghcj", new int[] { 3, 8 });
|
||||
general.put("jd2_jsbm", new int[] { 4, 8 });
|
||||
model.setValueAt("变更区分:", 5, 0);
|
||||
bgqf = new JCheckPanel(new String[] { "复制模", "降本", "二元化", "改善优化", "新规部品" });
|
||||
model.setValueAt(bgqf, 5, 2);
|
||||
model.setValueAt("部品型号:", 7, 0);
|
||||
disableEdit.add("7,0");
|
||||
general.put("jd2_bpxh", new int[] { 7, 2 });
|
||||
model.setValueAt("适用型号:", 7, 6);
|
||||
disableEdit.add("7,6");
|
||||
general.put("jd2_syxh", new int[] { 7, 7 });
|
||||
model.setValueAt("变更内容", 8, 0);
|
||||
disableEdit.add("8,0");
|
||||
|
||||
model.setValueAt("NO", top, 0);
|
||||
disableEdit.add(top + ",0");
|
||||
model.setValueAt("名称", top, 1);
|
||||
disableEdit.add(top + ",1");
|
||||
model.setValueAt("变更前", top, 2);
|
||||
disableEdit.add(top + ",2");
|
||||
model.setValueAt("变更后", top, 5);
|
||||
disableEdit.add(top + ",5");
|
||||
model.setValueAt("Risk", top, 8);
|
||||
disableEdit.add(top + ",8");
|
||||
model.setValueAt("测试计划", top, 9);
|
||||
disableEdit.add(top + ",9");
|
||||
model.setValueAt("备注", top, 10);
|
||||
disableEdit.add(top + ",10");
|
||||
|
||||
model.combine(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 });
|
||||
model.combine(new int[] { 0, 1, 2 }, new int[] { 3, 4, 5, 6, 7 });
|
||||
model.combine(new int[] { 0 }, new int[] { 9, 10 });
|
||||
model.combine(new int[] { 1 }, new int[] { 9, 10 });
|
||||
model.combine(new int[] { 2 }, new int[] { 8, 9, 10 });
|
||||
model.combine(new int[] { 3 }, new int[] { 0, 1, 2 });
|
||||
model.combine(new int[] { 3 }, new int[] { 3, 4, 5 });
|
||||
model.combine(new int[] { 3 }, new int[] { 6, 7 });
|
||||
model.combine(new int[] { 3 }, new int[] { 8, 9, 10 });
|
||||
model.combine(new int[] { 4 }, new int[] { 0, 1, 2 });
|
||||
model.combine(new int[] { 4 }, new int[] { 3, 4, 5 });
|
||||
model.combine(new int[] { 4 }, new int[] { 6, 7 });
|
||||
model.combine(new int[] { 4 }, new int[] { 8, 9, 10 });
|
||||
model.combine(new int[] { 5 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 5 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||
model.combine(new int[] { 6 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||
model.combine(new int[] { 7 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 7 }, new int[] { 2, 3, 4, 5 });
|
||||
model.combine(new int[] { 7 }, new int[] { 7, 8, 9, 10 });
|
||||
model.combine(new int[] { 8, 9 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||
model.combine(new int[] { top }, new int[] { 2, 3, 4 });
|
||||
model.combine(new int[] { top }, new int[] { 5, 6, 7 });
|
||||
for (int i = top + 1; i <= bottom; i++) {
|
||||
model.combine(new int[] { i }, new int[] { 2, 3, 4 });
|
||||
model.combine(new int[] { i }, new int[] { 5, 6, 7 });
|
||||
model.setValueAt(i - top, i, 0);
|
||||
disableEdit.add(i + ",0");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
public void saveRendering() {
|
||||
// TODO Auto-generated method stub
|
||||
for (Entry<String, int[]> entry : general.entrySet()) {
|
||||
if (prop.containsKey(entry.getKey())) {
|
||||
String value = model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString();
|
||||
try {
|
||||
if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) {
|
||||
value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues()
|
||||
.getRealValue(value);
|
||||
}
|
||||
System.out.println(entry.getKey() + ":" + value);
|
||||
form.setProperty(entry.getKey(), value);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (Entry<String, int[]> entry : general2.entrySet()) {
|
||||
if (prop.containsKey(entry.getKey())) {
|
||||
String value = model2.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString();
|
||||
try {
|
||||
if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) {
|
||||
value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues()
|
||||
.getRealValue(value);
|
||||
}
|
||||
System.out.println(entry.getKey() + ":" + value);
|
||||
form.setProperty(entry.getKey(), value);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (prop.containsKey("jd2_bgqf")) {
|
||||
String value = bgqf.getSelectedText() == null ? "" : bgqf.getSelectedText();
|
||||
try {
|
||||
if (form.getTCProperty("jd2_bgqf").getLOV() != null && !"".equals(value)) {
|
||||
value = (String) form.getTCProperty("jd2_bgqf").getLOV().getListOfValues().getRealValue(value);
|
||||
}
|
||||
System.out.println("jd2_bgqf:" + value);
|
||||
form.setProperty("jd2_bgqf", value);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (prop.containsKey("jd2_sywts")) {
|
||||
List<String[]> data = new ArrayList<String[]>();
|
||||
int num = 0;
|
||||
while (model.getValueAt(top + 1 + num, 1) != null && !"".equals(model.getValueAt(top + 1 + num, 1))) {
|
||||
String[] row = new String[7];
|
||||
for (int ii = 0; ii < row.length; ii++) {
|
||||
Object object = model.getValueAt(top + 1 + num, ii > 2 ? ii > 3 ? ii + 4 : ii + 2 : ii);
|
||||
if (object == null) {
|
||||
row[ii] = "";
|
||||
} else {
|
||||
row[ii] = object.toString();
|
||||
}
|
||||
}
|
||||
data.add(row);
|
||||
num++;
|
||||
if (top + 1 + num > bottom) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
String[][] dataArr = data.toArray(new String[data.size()][]);
|
||||
System.out.println(Arrays.deepToString(dataArr));
|
||||
TCTableUtil.setTableRows(form, "jd2_sywts", "JD2_SYWTS", colNames, dataArr);
|
||||
}
|
||||
try {
|
||||
form.refresh();
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEditorDisable(List<String> list, int row, int col) {
|
||||
return list.contains(row + "," + col);
|
||||
}
|
||||
|
||||
private MouseAdapter rightClick() {
|
||||
return new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table.getSelectedRow() != -1) {
|
||||
int row = table.getSelectedRow();
|
||||
boolean flag = (row > top && row <= bottom);
|
||||
addR.setEnabled(flag);
|
||||
delR.setEnabled(flag);
|
||||
test.setEnabled(flag);
|
||||
menu.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private ActionListener addRow() {
|
||||
return new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
int num = Integer.parseInt(model.getValueAt(bottom, 0).toString());
|
||||
model.insertRow(++bottom);
|
||||
// model.setValueAt(num + 1, bottom, 0);
|
||||
// model.combine(new int[] { bottom }, new int[] { 2, 3, 4 });
|
||||
// model.combine(new int[] { bottom }, new int[] { 5, 6, 7 });
|
||||
|
||||
System.out.println(bottom);
|
||||
initModel();
|
||||
table.revalidate();
|
||||
table.repaint();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private ActionListener delRow() {
|
||||
return new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
int row = table.getSelectedRow();
|
||||
int num = Integer.parseInt(model.getValueAt(row, 0).toString());
|
||||
model.removeRow(row);
|
||||
bottom--;
|
||||
// if (row <= bottom) {
|
||||
// for (int i = row; i <= bottom; i++) {
|
||||
// model.setValueAt(num + i - row, i, 0);
|
||||
// }
|
||||
// }
|
||||
System.out.println(bottom);
|
||||
initModel();
|
||||
table.revalidate();
|
||||
table.repaint();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private ActionListener test() {
|
||||
return new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
ComponentTestFrame.getInstance(form, $this);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String itemId) {
|
||||
// TODO Auto-generated method stub
|
||||
int row = table.getSelectedRow();
|
||||
System.out.println(itemId + " " + row);
|
||||
model.setValueAt(itemId, row, 9);
|
||||
table.revalidate();
|
||||
table.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenderingModified() {
|
||||
return form.isCheckedOut();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.connor.jd.plm.form;
|
||||
|
||||
public interface MyCallBack {
|
||||
|
||||
public void execute(String itemId);
|
||||
}
|
@ -0,0 +1,631 @@
|
||||
package com.connor.jd.plm.form;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.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;
|
||||
private CTMap model1;
|
||||
private CTMap model2;
|
||||
private CTable table1;
|
||||
private CTable table2;
|
||||
private Map<String, String> prop;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadRendering() throws TCException {
|
||||
this.setLayout(new BorderLayout());
|
||||
JPanel root = new JPanel(new BorderLayout());
|
||||
root.setPreferredSize(new Dimension(800, 500));
|
||||
JPanel inner = new JPanel(new BorderLayout());
|
||||
|
||||
JPanel top = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||
JLabel title = new JLabel("新品项目测试单");
|
||||
title.setFont(new Font("宋体", Font.PLAIN, 24));
|
||||
top.add(title);
|
||||
inner.add(top, BorderLayout.NORTH);
|
||||
|
||||
prop = form.getProperties();
|
||||
|
||||
// 初始化表格
|
||||
model1 = new CTMap(6, 4);
|
||||
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[i][0], propLocation1[i][1], true));
|
||||
}
|
||||
|
||||
initModel(model1, modelList1);
|
||||
|
||||
table1 = new CTable(model1) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
return !modelList1.isDisableEdit(row, col);
|
||||
}
|
||||
};
|
||||
|
||||
table1.setRowHeight(25);
|
||||
table1.setBorder(BorderFactory.createLineBorder(Color.black));
|
||||
table1.getColumnModel().getColumn(0).setPreferredWidth(100);
|
||||
table1.getColumnModel().getColumn(1).setPreferredWidth(100);
|
||||
table1.getColumnModel().getColumn(2).setPreferredWidth(100);
|
||||
table1.getColumnModel().getColumn(3).setPreferredWidth(200);
|
||||
|
||||
DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() {
|
||||
// 重写方法
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||
boolean hasFocus, int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
int maxPreferredHeight = 0;
|
||||
for (int i = 0; i < table.getColumnCount(); i++) {
|
||||
setText("" + table.getValueAt(row, i));
|
||||
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
|
||||
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
|
||||
}
|
||||
setBackground(Color.white);
|
||||
// if(points1.contains(new Point(row,column)))
|
||||
// setForeground(new Color(0,0,255));
|
||||
// else
|
||||
setForeground(Color.black);
|
||||
if (isSelected) {
|
||||
setBackground(new Color(0, 120, 215));
|
||||
setForeground(Color.white);
|
||||
}
|
||||
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
|
||||
table.setRowHeight(row, maxPreferredHeight);
|
||||
|
||||
setText(value == null ? "" : value.toString());
|
||||
return this;
|
||||
}
|
||||
};
|
||||
tcr1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
table1.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN);
|
||||
table1.setDefaultRenderer(Object.class, tcr1);
|
||||
inner.add(table1, BorderLayout.CENTER);
|
||||
|
||||
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);
|
||||
System.out.println("值:" + num);
|
||||
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
|
||||
|| "".equals(sumObj.toString().trim())) ? "0" : sumObj.toString().trim());
|
||||
double sum2 = Double
|
||||
.parseDouble(((sumObj = table.getValueAt(table.getRowCount() - 1, 5)) == null
|
||||
|| "".equals(sumObj.toString().trim())) ? "0" : sumObj.toString().trim());
|
||||
double sum3 = Double
|
||||
.parseDouble(((sumObj = table.getValueAt(table.getRowCount() - 1, 6)) == null
|
||||
|| "".equals(sumObj.toString().trim())) ? "0" : sumObj.toString().trim());
|
||||
double sum4 = Double
|
||||
.parseDouble(((sumObj = table.getValueAt(table.getRowCount() - 1, 7)) == null
|
||||
|| "".equals(sumObj.toString().trim())) ? "0" : sumObj.toString().trim());
|
||||
table.setValueAt(sum1 + sum2 + sum3 + sum4, table.getRowCount() - 1, 3);
|
||||
table2.revalidate();
|
||||
table2.repaint();
|
||||
} catch (NumberFormatException e1) {
|
||||
e1.printStackTrace();
|
||||
System.out.println("计算区域只能输入自然数或\"/\"");
|
||||
MessageBox.post("计算区域只能输入自然数或\"/\"", "错误", MessageBox.ERROR);
|
||||
obj = "/";
|
||||
} 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();
|
||||
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] + "阶段\"测试计划已创建");
|
||||
msg.append("\"" + jieduan[i] + "阶段\"测试计划已创建\n");
|
||||
continue;
|
||||
}
|
||||
Object obj;
|
||||
Object temp;
|
||||
int rowNum = 0;
|
||||
for (int ii = 2; ii < table2.getRowCount() - 1; ii++) {
|
||||
obj = table2.getValueAt(ii, i + 4);
|
||||
if (obj != null && !"/".equals(obj.toString().trim())) {
|
||||
// colNames2 = { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syfy",
|
||||
// "jd2_sycs" };
|
||||
String[] row = new String[6];
|
||||
row[0] = rowNum + "";
|
||||
row[1] = ownner;
|
||||
row[2] = (temp = table2.getValueAt(ii, 2)) == null ? "" : temp.toString();
|
||||
row[3] = obj.toString().trim();
|
||||
row[4] = (temp = table2.getValueAt(ii, 3)) == null ? "0"
|
||||
: temp.toString().trim();
|
||||
row[5] = "1";
|
||||
System.out.println(Arrays.toString(row));
|
||||
colData.add(row);
|
||||
rowNum++;
|
||||
}
|
||||
}
|
||||
if (colData.size() != 0) {
|
||||
TCComponentItemType type = (TCComponentItemType) session
|
||||
.getTypeComponent("JD2_GTXPXMCSJH");
|
||||
TCComponentItem item = type.create(null, null, "JD2_GTXPXMCSJH",
|
||||
jieduan[i] + "阶段测试计划", "", null);
|
||||
rev.add("JD2_CSJH", item);
|
||||
TCComponentItemRevision rev1 = item.getLatestItemRevision();
|
||||
TCComponentForm form1 = (TCComponentForm) rev1
|
||||
.getRelatedComponents("IMAN_master_form_rev")[0];
|
||||
String[][] dataArr = colData.toArray(new String[colData.size()][6]);
|
||||
System.out.println(Arrays.deepToString(dataArr));
|
||||
TCTableUtil.setTableRows(form1, "jd2_csjhtable", "JD2_CSJHTABLE", colNames2,
|
||||
dataArr);
|
||||
msg.append("\"" + jieduan[i] + "阶段\"测试计划创建成功\n");
|
||||
}
|
||||
colData.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
MessageBox.post(msg.toString(), "提示", MessageBox.WARNING);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenderingModified() {
|
||||
// TODO Auto-generated method stub
|
||||
return form.isCheckedOut();
|
||||
}
|
||||
|
||||
private void initModel(CTMap model, ModelList modelList) {
|
||||
for (ModelValue mv : modelList) {
|
||||
if (mv.isProp()) {
|
||||
if (prop.containsKey(mv.getValue())) {
|
||||
model.setValueAt(prop.get(mv.getValue()), mv.getRow(), mv.getCol());
|
||||
} else {
|
||||
System.out.println("属性‘" + mv.getValue() + "’不存在");
|
||||
}
|
||||
} else {
|
||||
model.setValueAt(mv.getValue(), mv.getRow(), mv.getCol());
|
||||
}
|
||||
if (mv.isCombine()) {
|
||||
model.combine(mv.getCombineRows(), mv.getCombineColumns());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveModel(ModelList modelList) {
|
||||
Object obj;
|
||||
for (ModelValue mv : modelList) {
|
||||
if (mv.isProp()) {
|
||||
if (prop.containsKey(mv.getValue())) {
|
||||
obj = table2.getValueAt(mv.getRow(), mv.getCol());
|
||||
try {
|
||||
form.setProperty(mv.getValue(), obj == null ? "" : obj.toString());
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("属性\"" + mv.getValue() + "\"不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,70 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModelList extends ArrayList<ModelValue> {
|
||||
|
||||
private List<String> disableEdit = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public boolean add(ModelValue e) {
|
||||
// TODO Auto-generated method stub
|
||||
if (!e.isEditable()) {
|
||||
disableEdit.add(e.getRow() + "," + e.getCol());
|
||||
}
|
||||
return super.add(e);
|
||||
}
|
||||
|
||||
public ModelValue getModelValue(int row, int col) {
|
||||
for (ModelValue mv : this) {
|
||||
if (mv.getRow() == row && mv.getCol() == col) {
|
||||
return mv;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ModelValue getModelValueInRange(int row, int col) {
|
||||
int rowStart;
|
||||
int colStart;
|
||||
int rowEnd;
|
||||
int colEnd;
|
||||
for (ModelValue mv : this) {
|
||||
if (mv.isCombine()) {
|
||||
rowStart = mv.getCombineRows()[0];
|
||||
rowEnd = rowStart + mv.getRowSpan() - 1;
|
||||
colStart = mv.getCombineColumns()[0];
|
||||
colEnd = colStart + mv.getColSpan() - 1;
|
||||
if (row >= rowStart && row <= rowEnd && col >= colStart && col <= colEnd) {
|
||||
return mv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean addDisableEdit(int row, int col) {
|
||||
String str = row + "," + col;
|
||||
if (disableEdit.contains(str)) {
|
||||
disableEdit.add(disableEdit.indexOf(str), str);
|
||||
return true;
|
||||
}
|
||||
disableEdit.add(str);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeDisableEdit(int row, int col) {
|
||||
String str = row + "," + col;
|
||||
if (disableEdit.contains(str)) {
|
||||
disableEdit.remove(disableEdit.indexOf(str));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDisableEdit(int row, int col) {
|
||||
return disableEdit.contains(row + "," + col);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ModelValue {
|
||||
|
||||
private String value;
|
||||
private boolean isProp;
|
||||
private int row;
|
||||
private int col;
|
||||
private boolean editable;
|
||||
private int[] combineRows;
|
||||
private int rowSpan;
|
||||
private int[] combineColumns;
|
||||
private int colSpan;
|
||||
|
||||
public ModelValue(String value, boolean isProp, int row, int col, boolean editable, int[] combineRows,
|
||||
int[] combineColumns, String type) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.isProp = isProp;
|
||||
this.row = row;
|
||||
this.col = col;
|
||||
this.editable = editable;
|
||||
this.combineRows = combineRows;
|
||||
this.combineColumns = combineColumns;
|
||||
}
|
||||
|
||||
public ModelValue(boolean editable, int[] combineRows, int[] combineColumns) {
|
||||
super();
|
||||
this.editable = editable;
|
||||
this.combineRows = combineRows;
|
||||
this.combineColumns = combineColumns;
|
||||
}
|
||||
|
||||
public ModelValue(String value, boolean isProp, int row, int col, boolean editable) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.isProp = isProp;
|
||||
this.row = row;
|
||||
this.col = col;
|
||||
this.editable = editable;
|
||||
}
|
||||
|
||||
public ModelValue(String value, boolean isProp, int row, int col, boolean editable, int[] combineRows,
|
||||
int[] combineColumns) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.isProp = isProp;
|
||||
this.row = row;
|
||||
this.col = col;
|
||||
this.editable = editable;
|
||||
this.combineRows = combineRows;
|
||||
this.combineColumns = combineColumns;
|
||||
}
|
||||
|
||||
public ModelValue(String value, boolean isProp, int row, int col, boolean editable, int rowStart, int rowEnd,
|
||||
int colStart, int colEnd) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.isProp = isProp;
|
||||
this.row = row;
|
||||
this.col = col;
|
||||
this.editable = editable;
|
||||
setCombineRows(rowStart, rowEnd);
|
||||
setCombineColumns(colStart, colEnd);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getRow() {
|
||||
return row;
|
||||
}
|
||||
|
||||
public void setRow(int row) {
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
public int getCol() {
|
||||
return col;
|
||||
}
|
||||
|
||||
public void setCol(int col) {
|
||||
this.col = col;
|
||||
}
|
||||
|
||||
public boolean isEditable() {
|
||||
return editable;
|
||||
}
|
||||
|
||||
public void setEditable(boolean editable) {
|
||||
this.editable = editable;
|
||||
}
|
||||
|
||||
public int[] getCombineRows() {
|
||||
return combineRows;
|
||||
}
|
||||
|
||||
public void setCombineRows(int[] combineRows) {
|
||||
this.rowSpan = combineRows.length;
|
||||
this.combineRows = combineRows;
|
||||
}
|
||||
|
||||
public void setCombineRows(int start, int end) {
|
||||
if (start <= end) {
|
||||
this.rowSpan = end - start + 1;
|
||||
this.combineRows = new int[rowSpan];
|
||||
for (int i = 0; i < rowSpan; i++) {
|
||||
combineRows[i] = start + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getCombineColumns() {
|
||||
return combineColumns;
|
||||
}
|
||||
|
||||
public void setCombineColumns(int[] combineColumns) {
|
||||
this.colSpan = combineColumns.length;
|
||||
this.combineColumns = combineColumns;
|
||||
}
|
||||
|
||||
public void setCombineColumns(int start, int end) {
|
||||
if (start <= end) {
|
||||
this.colSpan = end - start + 1;
|
||||
this.combineColumns = new int[colSpan];
|
||||
for (int i = 0; i < colSpan; i++) {
|
||||
combineColumns[i] = start + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getRowSpan() {
|
||||
return rowSpan;
|
||||
}
|
||||
|
||||
public int getColSpan() {
|
||||
return colSpan;
|
||||
}
|
||||
|
||||
public boolean isProp() {
|
||||
return isProp;
|
||||
}
|
||||
|
||||
public void setProp(boolean isProp) {
|
||||
this.isProp = isProp;
|
||||
}
|
||||
|
||||
public boolean hasValue() {
|
||||
return Objects.nonNull(value);
|
||||
}
|
||||
|
||||
public boolean isCombine() {
|
||||
return rowSpan != 0 && colSpan != 0;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,285 @@
|
||||
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;
|
||||
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
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 Object getCellEditorValue() {
|
||||
// TODO Auto-generated method stub
|
||||
Object obj = super.getCellEditorValue();
|
||||
if (obj != null && !"".equals(obj.toString().trim()) && row >= top && row <= bottom) {
|
||||
try {
|
||||
Double.parseDouble(obj.toString().trim());
|
||||
} catch (Exception e) {
|
||||
MessageBox.post("计算区域只能输入数字", "错误", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopCellEditing() {
|
||||
// TODO Auto-generated method stub
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class MyCellEditor2 extends DefaultCellEditor {
|
||||
private JLabel img = null;
|
||||
private JComboBox<String> jued = 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;
|
||||
}
|
||||
if (value instanceof JComboBox) {
|
||||
jued = (JComboBox<String>) value;
|
||||
type = 2;
|
||||
return jued;
|
||||
}
|
||||
type = 0;
|
||||
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
if (type == 1) {
|
||||
return img;
|
||||
}
|
||||
if (type == 2) {
|
||||
return jued;
|
||||
}
|
||||
return super.getCellEditorValue();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class MyCellEditor3 extends DefaultCellEditor {
|
||||
private JCheckPanel check = null;
|
||||
private int type = -1;
|
||||
|
||||
public MyCellEditor3(JTextField arg0) {
|
||||
super(arg0);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
if (value instanceof JCheckPanel) {
|
||||
check = (JCheckPanel) value;
|
||||
type = 1;
|
||||
return check;
|
||||
}
|
||||
type = 0;
|
||||
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
// TODO Auto-generated method stub
|
||||
if (type == 1) {
|
||||
return check;
|
||||
}
|
||||
return super.getCellEditorValue();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class MyCellEditor4 extends DefaultCellEditor {
|
||||
private int type = -1;
|
||||
private JCheckBox check;
|
||||
|
||||
public MyCellEditor4(JTextField arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
if (value instanceof JCheckBox) {
|
||||
check = (JCheckBox) value;
|
||||
type = 1;
|
||||
return check;
|
||||
}
|
||||
type = 0;
|
||||
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
if (type == 1) {
|
||||
return check;
|
||||
}
|
||||
return super.getCellEditorValue();
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
JD2_GTYPQRDRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.SampleConfirmationForm
|
||||
JD2_GTSYWTSRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.ExperimentalPowerOfAttorneyForm
|
||||
SF6_ElecElementRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.CSJHForm
|
||||
JD2_GTCSJHRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.CSJHForm
|
||||
JD2_GTXPCSXQDRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.NewProductTestForm
|
||||
JD2_GTXPXMCSJHRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.GTCSJHForm
|
Loading…
Reference in new issue