parent
65ebc48e70
commit
6592228021
@ -0,0 +1 @@
|
||||
/bin/
|
@ -0,0 +1,68 @@
|
||||
package com.connor.jd.plm.form;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
public class PhotoFrame extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = -2216276219179107707L;
|
||||
private Container con;
|
||||
|
||||
private ZPanel zPanel;
|
||||
private JScrollPane imgSp;
|
||||
private static PhotoFrame instance;
|
||||
|
||||
public static PhotoFrame getInstance(String imgPath) {
|
||||
if (instance == null) {
|
||||
instance = new PhotoFrame(imgPath);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private PhotoFrame(String imgPath) {
|
||||
con = getContentPane();
|
||||
|
||||
zPanel = new ZPanel();
|
||||
zPanel.setImagePath(imgPath);
|
||||
zPanel.setPreferredSize(
|
||||
new Dimension(zPanel.getImgWidth(), zPanel.getImgHeight()));
|
||||
|
||||
imgSp = new JScrollPane();
|
||||
imgSp.setViewportView(zPanel);
|
||||
imgSp.setHorizontalScrollBarPolicy(
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
imgSp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
|
||||
con.add(imgSp, BorderLayout.CENTER);
|
||||
|
||||
finalSetting();
|
||||
}
|
||||
|
||||
private void finalSetting() {
|
||||
setTitle("ZakiSoft ZFileRenamerV0.2");
|
||||
|
||||
Image image = Toolkit.getDefaultToolkit()
|
||||
.getImage(this.getClass().getResource("/title.gif"));
|
||||
setIconImage(image);
|
||||
|
||||
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||
Dimension screenSize = kit.getScreenSize();
|
||||
int screenHeight = screenSize.height;
|
||||
int screenWidth = screenSize.width;
|
||||
int frameH = getHeight();
|
||||
int frameW = getWidth();
|
||||
setLocation((screenWidth - frameW) / 2 - 250,
|
||||
(screenHeight - frameH) / 2 - 250);
|
||||
setSize(500, 350);
|
||||
setVisible(true);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,757 @@
|
||||
package com.connor.jd.plm.form;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Image;
|
||||
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.io.File;
|
||||
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.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
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.filechooser.FileFilter;
|
||||
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.JRadioPanel;
|
||||
import com.connor.jd.plm.table.MyCellEditor;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentDataset;
|
||||
import com.teamcenter.rac.kernel.TCComponentDatasetType;
|
||||
import com.teamcenter.rac.kernel.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.stylesheet.AbstractRendering;
|
||||
|
||||
public class SampleConfirmationForm extends AbstractRendering {
|
||||
private AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||
private TCComponentForm form;
|
||||
private TCSession session;
|
||||
private CardLayout cl = new CardLayout();
|
||||
private JPanel center = null;
|
||||
private JPopupMenu menu = new JPopupMenu();
|
||||
private JPanel confirmPanel = new JPanel();
|
||||
private JPanel examinePanel = new JPanel();
|
||||
private CTMap model;
|
||||
private CTMap model2;
|
||||
private CTable table;
|
||||
private CTable table2;
|
||||
private int bottom;
|
||||
private int top = 13;
|
||||
private Map<String, int[]> general;
|
||||
private List<String> disableEdit;
|
||||
private Map<String, String> prop;
|
||||
private Map<String, int[]> pic;
|
||||
|
||||
public SampleConfirmationForm(TCComponent arg0) throws Exception {
|
||||
super(arg0);
|
||||
|
||||
if (arg0 instanceof TCComponentForm) {
|
||||
this.form = (TCComponentForm) arg0;
|
||||
this.session = (TCSession) app.getSession();
|
||||
loadRendering();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadRendering() throws TCException {
|
||||
setLayout(new BorderLayout());
|
||||
JPanel root = new JPanel(new BorderLayout());
|
||||
root.setPreferredSize(new Dimension(800, 600));
|
||||
// 头部
|
||||
JPanel buttons = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
JButton confirm = new JButton("样品确认单");
|
||||
JButton examine = new JButton("CTQ检查表");
|
||||
|
||||
confirm.addActionListener(confirm());
|
||||
examine.addActionListener(examine());
|
||||
buttons.add(confirm);
|
||||
buttons.add(examine);
|
||||
|
||||
// 内容
|
||||
center = new JPanel(cl);
|
||||
|
||||
// 确认单
|
||||
confirmPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
|
||||
confirmPanel.setLayout(new BorderLayout());
|
||||
|
||||
// 设置属性
|
||||
model = new CTMap(47, 20);
|
||||
bottom = model.getRowCount() - 14;
|
||||
disableEdit = new ArrayList<>();// 不允许编辑
|
||||
general = new HashMap<String, int[]>();// 要填写的一般属性
|
||||
pic = new HashMap<String, int[]>();// 图片
|
||||
model.setValueAt("样品确认单", 0, 0);
|
||||
disableEdit.add("0,0");
|
||||
model.setValueAt("提交", 0, 14);
|
||||
disableEdit.add("0,14");
|
||||
model.setValueAt("审核", 0, 16);
|
||||
disableEdit.add("0,16");
|
||||
model.setValueAt("批准", 0, 18);
|
||||
disableEdit.add("0,18");
|
||||
model.setValueAt("部门", 2, 0);
|
||||
disableEdit.add("2,0");
|
||||
model.setValueAt("滚筒研发", 2, 2);
|
||||
disableEdit.add("2,2");
|
||||
general.put("jd2_bz", new int[] { 2, 14 });
|
||||
general.put("jd2_sh", new int[] { 2, 16 });
|
||||
general.put("jd2_pz", new int[] { 2, 18 });
|
||||
model.setValueAt("创建日期", 4, 0);
|
||||
disableEdit.add("4,0");
|
||||
general.put("creation_date", new int[] { 4, 2 });
|
||||
model.setValueAt("创建人", 4, 5);
|
||||
disableEdit.add("4,5");
|
||||
general.put("owning_user", new int[] { 4, 7 });
|
||||
general.put("jd2_bzrq", new int[] { 4, 14 });
|
||||
general.put("jd2_shrq", new int[] { 4, 16 });
|
||||
general.put("jd2_pzrq", new int[] { 4, 18 });
|
||||
model.setValueAt("零件名", 6, 0);
|
||||
disableEdit.add("6,0");
|
||||
general.put("jd2_ljm", new int[] { 6, 2 });
|
||||
general.put("jd2_ljywm", new int[] { 6, 5 });
|
||||
model.setValueAt("型号", 6, 8);
|
||||
disableEdit.add("6,8");
|
||||
general.put("jd2_xh", new int[] { 6, 10 });
|
||||
model.setValueAt("分类", 6, 14);
|
||||
disableEdit.add("6,14");
|
||||
general.put("jd2_fl", new int[] { 6, 17 });
|
||||
model.setValueAt("物料编码", 7, 0);
|
||||
disableEdit.add("7,0");
|
||||
general.put("jd2_wlbm", new int[] { 7, 2 });
|
||||
model.setValueAt("送样数量", 7, 8);
|
||||
disableEdit.add("7,8");
|
||||
JRadioPanel sysl = new JRadioPanel(
|
||||
new String[] { "3", "5", "10", "30" });
|
||||
model.setValueAt(sysl, 7, 10);
|
||||
model.setValueAt("状态", 7, 14);
|
||||
disableEdit.add("7,14");
|
||||
general.put("jd2_zt", new int[] { 7, 17 });
|
||||
model.setValueAt("部品等级", 8, 0);
|
||||
disableEdit.add("8,0");
|
||||
general.put("jd2_bpdj", new int[] { 8, 2 });
|
||||
model.setValueAt("参考物料", 8, 8);
|
||||
disableEdit.add("8,8");
|
||||
model.setValueAt("jd2_ckwl", 8, 10);
|
||||
general.put("jd2_ckwl", new int[] { 8, 10 });
|
||||
model.setValueAt("图号", 9, 0);
|
||||
disableEdit.add("9,0");
|
||||
general.put("jd2_th", new int[] { 9, 2 });
|
||||
model.setValueAt("规格", 10, 0);
|
||||
disableEdit.add("10,0");
|
||||
general.put("jd2_gg", new int[] { 10, 2 });
|
||||
model.setValueAt("供应商", 11, 0);
|
||||
disableEdit.add("11,0");
|
||||
general.put("jd2_gys", new int[] { 11, 2 });
|
||||
model.setValueAt("送样原因", 9, 8);
|
||||
disableEdit.add("9,8");
|
||||
general.put("jd2_syyy", new int[] { 9, 10 });
|
||||
model.setValueAt("目前阶段", 12, 0);
|
||||
disableEdit.add("12,0");
|
||||
JCheckPanel mqjd = new JCheckPanel(
|
||||
new String[] { "DV", "PV", "PR", "SR", "现场测试", "MP" });
|
||||
model.setValueAt(mqjd, 12, 2);
|
||||
|
||||
model.setValueAt("No", top, 0);
|
||||
disableEdit.add(top + ",0");
|
||||
model.setValueAt("尺寸验证", top, 1);
|
||||
disableEdit.add(top + ",1");
|
||||
model.setValueAt("检查数据(#样品号/腔体号)", top, 7);
|
||||
disableEdit.add(top + ",7");
|
||||
model.setValueAt("结果", top, 19);
|
||||
disableEdit.add(top + ",19");
|
||||
model.setValueAt("规格", top + 1, 1);
|
||||
disableEdit.add(top + 1 + ",1");
|
||||
model.setValueAt("公差", top + 1, 5);
|
||||
disableEdit.add(top + 1 + ",5");
|
||||
for (int i = 1; i < 11; i++) {
|
||||
model.setValueAt("#" + i, top + 1, i + 6);
|
||||
disableEdit.add(top + 1 + "," + (i + 6));
|
||||
}
|
||||
model.setValueAt("Min", top + 1, 17);
|
||||
disableEdit.add(top + 1 + ",17");
|
||||
model.setValueAt("Max", top + 1, 18);
|
||||
disableEdit.add(top + 1 + ",18");
|
||||
|
||||
for (int i = top + 2; i <= bottom; i++) {
|
||||
model.setValueAt(i - 1, i, 0);
|
||||
disableEdit.add(i + ",0");
|
||||
model.combine(new int[] { i }, new int[] { 2, 3, 4 });
|
||||
}
|
||||
|
||||
model.setValueAt("被标记为“CTQ”的尺寸非常重要", bottom + 1, 0);// 从“底部”开始
|
||||
disableEdit.add(bottom + 1 + ",0");
|
||||
model.setValueAt("SPL Picture", bottom + 2, 0);
|
||||
pic.put("jd2_ypzp", new int[] { bottom + 3, 0 });
|
||||
disableEdit.add(bottom + 2 + ",0");
|
||||
model.setValueAt("注塑条件", bottom + 2, 4);
|
||||
disableEdit.add(bottom + 2 + ",4");
|
||||
model.setValueAt("C/Time", bottom + 2, 5);
|
||||
disableEdit.add(bottom + 2 + ",5");
|
||||
model.setValueAt("注塑", bottom + 2, 6);
|
||||
disableEdit.add(bottom + 2 + ",6");
|
||||
model.setValueAt("冷却", bottom + 2, 7);
|
||||
disableEdit.add(bottom + 2 + ",7");
|
||||
model.setValueAt("包装", bottom + 2, 8);
|
||||
disableEdit.add(bottom + 2 + ",8");
|
||||
model.setValueAt("供方自检报告", bottom + 2, 9);
|
||||
disableEdit.add(bottom + 2 + ",9");
|
||||
model.setValueAt("供方作业指导书", bottom + 2, 12);
|
||||
disableEdit.add(bottom + 2 + ",12");
|
||||
model.setValueAt("供方QC工程图", bottom + 2, 15);
|
||||
disableEdit.add(bottom + 2 + ",15");
|
||||
model.setValueAt("物料包装及标签", bottom + 2, 18);
|
||||
disableEdit.add(bottom + 2 + ",18");
|
||||
general.put("jd2_CTime", new int[] { bottom + 3, 5 });
|
||||
general.put("jd2_zs", new int[] { bottom + 3, 6 });
|
||||
general.put("jd2_lq", new int[] { bottom + 3, 7 });
|
||||
general.put("jd2_baoz", new int[] { bottom + 3, 8 });
|
||||
pic.put("jd2_gfzjbg", new int[] { bottom + 3, 9 });
|
||||
pic.put("jd2_gfzyzds", new int[] { bottom + 3, 12 });
|
||||
pic.put("jd2_gfqcgct", new int[] { bottom + 3, 15 });
|
||||
pic.put("jd2_wlbzjbg", new int[] { bottom + 3, 18 });
|
||||
model.setValueAt("Shot/24Hr", bottom + 4, 5);
|
||||
disableEdit.add(bottom + 4 + ",5");
|
||||
model.setValueAt("吨", bottom + 4, 6);
|
||||
disableEdit.add(bottom + 4 + ",6");
|
||||
general.put("jd2_Shot24Hr", new int[] { bottom + 5, 5 });
|
||||
general.put("jd2_d", new int[] { bottom + 5, 6 });
|
||||
model.setValueAt("3D重量", bottom + 6, 4);
|
||||
disableEdit.add(bottom + 6 + ",4");
|
||||
model.setValueAt("jd2_3dzl", bottom + 6, 5);
|
||||
general.put("jd2_3dzl", new int[] { bottom + 6, 5 });
|
||||
model.setValueAt("注塑工艺条件", bottom + 6, 7);
|
||||
disableEdit.add(bottom + 6 + ",7");
|
||||
model.setValueAt("IQC首检报告", bottom + 6, 9);
|
||||
disableEdit.add(bottom + 6 + ",9");
|
||||
model.setValueAt("测试报告", bottom + 6, 12);
|
||||
disableEdit.add(bottom + 6 + ",12");
|
||||
model.setValueAt("材质报告", bottom + 6, 15);
|
||||
disableEdit.add(bottom + 6 + ",15");
|
||||
model.setValueAt("模具标识", bottom + 6, 18);
|
||||
disableEdit.add(bottom + 6 + ",18");
|
||||
pic.put("jd2_gytj", new int[] { bottom + 7, 7 });
|
||||
pic.put("jd2_iqcsjbg", new int[] { bottom + 7, 9 });
|
||||
pic.put("jd2_csbg", new int[] { bottom + 7, 12 });
|
||||
pic.put("jd2_czbf", new int[] { bottom + 7, 15 });
|
||||
pic.put("jd2_mjbs", new int[] { bottom + 7, 18 });
|
||||
model.setValueAt("实测重量", bottom + 8, 4);
|
||||
disableEdit.add(bottom + 8 + ",4");
|
||||
general.put("jd2_sczl", new int[] { bottom + 8, 5 });
|
||||
model.setValueAt("IQC作业指导书", bottom + 10, 4);
|
||||
disableEdit.add(bottom + 10 + ",4");
|
||||
pic.put("jd2_icqjyzyzds", new int[] { bottom + 11, 4 });
|
||||
model.setValueAt("决定", bottom + 12, 12);
|
||||
disableEdit.add(bottom + 12 + ",12");
|
||||
general.put("jd2_jued", new int[] { bottom + 12, 15 });
|
||||
pic.put("jd2_qtbg", new int[] { bottom + 10, 7 });
|
||||
|
||||
// 合并单元格
|
||||
model.combine(new int[] { 0, 1 },
|
||||
new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
|
||||
model.combine(new int[] { 0, 1 }, new int[] { 14, 15 });
|
||||
model.combine(new int[] { 0, 1 }, new int[] { 16, 17 });
|
||||
model.combine(new int[] { 0, 1 }, new int[] { 18, 19 });
|
||||
model.combine(new int[] { 2, 3 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 2, 3 },
|
||||
new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
|
||||
model.combine(new int[] { 2, 3 }, new int[] { 14, 15 });
|
||||
model.combine(new int[] { 2, 3 }, new int[] { 16, 17 });
|
||||
model.combine(new int[] { 2, 3 }, new int[] { 18, 19 });
|
||||
model.combine(new int[] { 4, 5 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 4, 5 }, new int[] { 2, 3, 4 });
|
||||
model.combine(new int[] { 4, 5 }, new int[] { 5, 6 });
|
||||
model.combine(new int[] { 4, 5 },
|
||||
new int[] { 7, 8, 9, 10, 11, 12, 13 });
|
||||
model.combine(new int[] { 4, 5 }, new int[] { 14, 15 });
|
||||
model.combine(new int[] { 4, 5 }, new int[] { 16, 17 });
|
||||
model.combine(new int[] { 4, 5 }, new int[] { 18, 19 });
|
||||
model.combine(new int[] { 6 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 6 }, new int[] { 2, 3, 4 });
|
||||
model.combine(new int[] { 6 }, new int[] { 5, 6, 7 });
|
||||
model.combine(new int[] { 6 }, new int[] { 8, 9 });
|
||||
model.combine(new int[] { 6 }, new int[] { 10, 11, 12, 13 });
|
||||
model.combine(new int[] { 6 }, new int[] { 14, 15, 16 });
|
||||
model.combine(new int[] { 6 }, new int[] { 17, 18, 19 });
|
||||
model.combine(new int[] { 7 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 7 }, new int[] { 2, 3, 4, 5, 6, 7 });
|
||||
model.combine(new int[] { 7 }, new int[] { 8, 9 });
|
||||
model.combine(new int[] { 7 }, new int[] { 10, 11, 12, 13 });
|
||||
model.combine(new int[] { 7 }, new int[] { 14, 15, 16 });
|
||||
model.combine(new int[] { 7 }, new int[] { 17, 18, 19 });
|
||||
model.combine(new int[] { 8 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 8 }, new int[] { 2, 3, 4, 5, 6, 7 });
|
||||
model.combine(new int[] { 8 }, new int[] { 8, 9 });
|
||||
model.combine(new int[] { 8 },
|
||||
new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 });
|
||||
model.combine(new int[] { 9 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 9 }, new int[] { 2, 3, 4, 5, 6, 7 });
|
||||
model.combine(new int[] { 9, 10, 11 }, new int[] { 8, 9 });
|
||||
model.combine(new int[] { 9, 10, 11 },
|
||||
new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 });
|
||||
model.combine(new int[] { 10 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 10 }, new int[] { 2, 3, 4, 5, 6, 7 });
|
||||
model.combine(new int[] { 11 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 11 }, new int[] { 2, 3, 4, 5, 6, 7 });
|
||||
model.combine(new int[] { 12 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { 12 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
11, 12, 13, 14, 15, 16, 17, 18, 19 });
|
||||
model.combine(new int[] { top, 1 }, new int[] { 0 });
|
||||
model.combine(new int[] { top }, new int[] { 1, 2, 3, 4, 5, 6 });
|
||||
model.combine(new int[] { top },
|
||||
new int[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 });
|
||||
model.combine(new int[] { top, top + 1 }, new int[] { 19 });
|
||||
model.combine(new int[] { top + 1 }, new int[] { 1, 2, 3, 4 });
|
||||
model.combine(new int[] { top + 1 }, new int[] { 5, 6 });
|
||||
model.combine(new int[] { bottom + 1 }, new int[] { 0, 1, 2, 3, 4, 5 });
|
||||
model.combine(new int[] { bottom + 2 }, new int[] { 0, 1 });
|
||||
model.combine(new int[] { bottom + 2 }, new int[] { 2, 3 });
|
||||
model.combine(
|
||||
new int[] { bottom + 3, bottom + 4, bottom + 5, bottom + 6,
|
||||
bottom + 7, bottom + 8, bottom + 9, bottom + 10,
|
||||
bottom + 11, bottom + 12, bottom + 13 },
|
||||
new int[] { 0, 1, 2, 3 });
|
||||
model.combine(
|
||||
new int[] { bottom + 2, bottom + 3, bottom + 4, bottom + 5 },
|
||||
new int[] { 4 });
|
||||
model.combine(new int[] { bottom + 2 }, new int[] { 9, 10, 11 });
|
||||
model.combine(new int[] { bottom + 2 }, new int[] { 12, 13, 14 });
|
||||
model.combine(new int[] { bottom + 2 }, new int[] { 15, 16, 17 });
|
||||
model.combine(new int[] { bottom + 2 }, new int[] { 18, 19 });
|
||||
model.combine(new int[] { bottom + 4, bottom + 5 }, new int[] { 7, 8 });
|
||||
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 },
|
||||
new int[] { 9, 10, 11 });
|
||||
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 },
|
||||
new int[] { 12, 13, 14 });
|
||||
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 },
|
||||
new int[] { 15, 16, 17 });
|
||||
model.combine(new int[] { bottom + 3, bottom + 4, bottom + 5 },
|
||||
new int[] { 18, 19 });
|
||||
model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 4 });
|
||||
model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 4 });
|
||||
model.combine(new int[] { bottom + 6, bottom + 7 }, new int[] { 5 });
|
||||
model.combine(new int[] { bottom + 8, bottom + 9 }, new int[] { 5 });
|
||||
model.combine(
|
||||
new int[] { bottom + 6, bottom + 7, bottom + 8, bottom + 9 },
|
||||
new int[] { 6 });
|
||||
model.combine(new int[] { bottom + 6 }, new int[] { 7, 8 });
|
||||
model.combine(new int[] { bottom + 6 }, new int[] { 9, 10, 11 });
|
||||
model.combine(new int[] { bottom + 6 }, new int[] { 12, 13, 14 });
|
||||
model.combine(new int[] { bottom + 6 }, new int[] { 15, 16, 17 });
|
||||
model.combine(new int[] { bottom + 6 }, new int[] { 18, 19 });
|
||||
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 },
|
||||
new int[] { 7, 8 });
|
||||
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 },
|
||||
new int[] { 9, 10, 11 });
|
||||
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 },
|
||||
new int[] { 12, 13, 14 });
|
||||
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 },
|
||||
new int[] { 15, 16, 17 });
|
||||
model.combine(new int[] { bottom + 7, bottom + 8, bottom + 9 },
|
||||
new int[] { 18, 19 });
|
||||
model.combine(new int[] { bottom + 10 }, new int[] { 4, 5, 6 });
|
||||
model.combine(new int[] { bottom + 11, bottom + 12, bottom + 13 },
|
||||
new int[] { 4, 5, 6 });
|
||||
model.combine(new int[] { bottom + 10, bottom + 11, bottom + 12,
|
||||
bottom + 13 }, new int[] { 7, 8, 9, 10, 11 });
|
||||
model.combine(new int[] { bottom + 10, bottom + 11 },
|
||||
new int[] { 12, 13, 14, 15, 16, 17, 18, 19 });
|
||||
model.combine(new int[] { bottom + 12, bottom + 13 },
|
||||
new int[] { 12, 13, 14 });
|
||||
model.combine(new int[] { bottom + 12, bottom + 13 },
|
||||
new int[] { 15, 16, 17, 18, 19 });
|
||||
|
||||
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(60);
|
||||
table.getColumnModel().getColumn(2).setPreferredWidth(50);
|
||||
table.getColumnModel().getColumn(3).setPreferredWidth(50);
|
||||
table.getColumnModel().getColumn(4).setPreferredWidth(50);
|
||||
table.getColumnModel().getColumn(5).setPreferredWidth(60);
|
||||
table.getColumnModel().getColumn(6).setPreferredWidth(60);
|
||||
for (int i = 7; i < model.getColumnCount() - 1; i++) {
|
||||
table.getColumnModel().getColumn(i).setPreferredWidth(40);
|
||||
}
|
||||
table.getColumnModel().getColumn(model.getColumnCount() - 1)
|
||||
.setPreferredWidth(80);
|
||||
DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() {
|
||||
// 重写方法
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (value instanceof JLabel) {
|
||||
return (JLabel) value;
|
||||
}
|
||||
|
||||
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.setDefaultRenderer(Object.class, tcr1);
|
||||
for (int i = 0; i < model.getColumnCount(); i++) {
|
||||
table.getColumnModel().getColumn(i)
|
||||
.setCellEditor(new MyCellEditor(new JTextField()));
|
||||
}
|
||||
table.addMouseListener(rightClick());
|
||||
confirmPanel.add(table, BorderLayout.CENTER);
|
||||
|
||||
// 填写数据
|
||||
prop = form.getProperties();
|
||||
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 {
|
||||
model.setValueAt(entry.getKey(), entry.getValue()[0],
|
||||
entry.getValue()[1]);
|
||||
System.out.println("属性‘" + entry.getKey() + "’未找到");
|
||||
}
|
||||
}
|
||||
if (prop.containsKey("jd2_sysl")) {
|
||||
sysl.setSelected(prop.get("jd2_sysl"));
|
||||
}
|
||||
if (prop.containsKey("jd2_mqjd")) {
|
||||
mqjd.setSelected(prop.get("jd2_mqjd"));
|
||||
}
|
||||
pic.put("user_data_1", new int[] { bottom + 3, 0 });
|
||||
for (Entry<String, int[]> entry : pic.entrySet()) {
|
||||
if (prop.containsKey(entry.getKey())) {
|
||||
TCComponent comp = null;
|
||||
try {
|
||||
comp = session.stringToComponent(prop.get(entry.getKey()));
|
||||
if (comp != null) {
|
||||
TCComponentDataset dataset = (TCComponentDataset) comp;
|
||||
String temp = System.getenv("temp");
|
||||
System.out.println(temp);
|
||||
String[] types = dataset.getProperty("ref_names")
|
||||
.split(",");
|
||||
System.out.println(Arrays.toString(types));
|
||||
System.out.println(Arrays
|
||||
.toString(dataset.getFileNames(types[0])));
|
||||
File img = dataset.getFiles(types[0], temp)[0];
|
||||
System.out.println(img.getPath());
|
||||
|
||||
ImageIcon icon = new ImageIcon(img.getPath());
|
||||
int row = entry.getValue()[0];
|
||||
int col = entry.getValue()[1];
|
||||
int[] arr = model.getSpan(row, col);
|
||||
int width = 0;
|
||||
for(int i=0;i<arr[1];i++) {
|
||||
// width+=table.getColumnModel().getColumn()
|
||||
}
|
||||
System.out.println("row:" + arr[0] + ",col:" + arr[1]);
|
||||
icon.setImage(icon.getImage().getScaledInstance(
|
||||
table.getColumnModel().getColumn(col)
|
||||
.getPreferredWidth() * arr[1],
|
||||
table.getRowHeight() * arr[0],
|
||||
Image.SCALE_SMOOTH));
|
||||
JLabel label = new JLabel();
|
||||
label.setLayout(new FlowLayout(FlowLayout.CENTER));
|
||||
label.setIcon(icon);
|
||||
label.addMouseListener(showImg(img.getPath()));
|
||||
label.setToolTipText(dataset.getUid());
|
||||
model.setValueAt(label, row, col);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.out);
|
||||
}
|
||||
|
||||
} else {
|
||||
model.setValueAt(new JLabel(entry.getKey()),
|
||||
entry.getValue()[0], entry.getValue()[1]);
|
||||
System.out.println("属性‘" + entry.getKey() + "’未找到");
|
||||
}
|
||||
}
|
||||
|
||||
ScrollPane confirmScrollPanel = new ScrollPane();
|
||||
confirmScrollPanel.add(confirmPanel);
|
||||
// 检查表
|
||||
JTextField text2 = new JTextField("examine");
|
||||
examinePanel.add(text2);
|
||||
|
||||
// 右键菜单
|
||||
menu.setVisible(false);
|
||||
JMenuItem addP;
|
||||
addP = new JMenuItem("添加图片");
|
||||
menu.add(addP);
|
||||
addP.addActionListener(addPic());
|
||||
JMenuItem addR;
|
||||
addR = new JMenuItem("添加行");
|
||||
menu.add(addR);
|
||||
addR.addActionListener(addRow());
|
||||
JMenuItem insertR;
|
||||
insertR = new JMenuItem("插入行");
|
||||
menu.add(insertR);
|
||||
insertR.addActionListener(insertRow());
|
||||
|
||||
center.add("confirm", confirmScrollPanel);
|
||||
center.add("examine", examinePanel);
|
||||
root.add(buttons, BorderLayout.NORTH);
|
||||
root.add(center, BorderLayout.CENTER);
|
||||
this.add(menu);
|
||||
this.add(root, BorderLayout.CENTER);
|
||||
|
||||
cl.show(center, "confirm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveRendering() {
|
||||
// TODO Auto-generated method stub
|
||||
JLabel label = null;
|
||||
for (Entry<String, int[]> entry : pic.entrySet()) {
|
||||
if (prop.containsKey(entry.getKey())) {
|
||||
label = (JLabel) model.getValueAt(entry.getValue()[0],
|
||||
entry.getValue()[1]);
|
||||
try {
|
||||
form.setProperty(entry.getKey(), label.getToolTipText());
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ActionListener confirm() {
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println("confirm");
|
||||
cl.show(center, "confirm");
|
||||
}
|
||||
};
|
||||
return actionListener;
|
||||
}
|
||||
|
||||
private ActionListener examine() {
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println("examine");
|
||||
cl.show(center, "examine");
|
||||
}
|
||||
};
|
||||
return actionListener;
|
||||
}
|
||||
|
||||
private MouseAdapter rightClick() {
|
||||
MouseAdapter mouseAdapter = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut()
|
||||
&& table.getSelectedRow() != -1) {
|
||||
menu.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
};
|
||||
return mouseAdapter;
|
||||
}
|
||||
|
||||
private ActionListener addPic() {
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fileChooser.setMultiSelectionEnabled(false);
|
||||
fileChooser.setFileFilter(new FileFilter() {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
// TODO Auto-generated method stub
|
||||
return "(图片)*.png;*.jpg;*.jpeg;*.bmp;";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(File var1) {
|
||||
// TODO Auto-generated method stub
|
||||
return var1.getName().endsWith(".png")
|
||||
|| var1.getName().endsWith(".jpg")
|
||||
|| var1.getName().endsWith(".jpeg")
|
||||
|| var1.getName().endsWith(".bmp");
|
||||
}
|
||||
});
|
||||
fileChooser.showOpenDialog(menu);// 参数表示定位
|
||||
File file = fileChooser.getSelectedFile();
|
||||
if (file != null) {
|
||||
System.out.println("fileName:" + file.getName());
|
||||
String as1[] = { file.getPath() };// 文件的物理路径
|
||||
String as2[] = { "Image" };
|
||||
TCComponentDatasetType datasetType;
|
||||
try {
|
||||
datasetType = (TCComponentDatasetType) session
|
||||
.getTypeComponent("Dataset");
|
||||
|
||||
TCComponentDataset dataset = datasetType
|
||||
.create(file.getName(), "", "Image");
|
||||
dataset.setFiles(as1, as2);
|
||||
TCComponent[] comps = form.getRelatedComponents();
|
||||
AIFComponentContext[] ref = form.whereReferenced();
|
||||
TCComponentItemRevision rev = (TCComponentItemRevision) ref[0]
|
||||
.getComponent();
|
||||
rev.add("IMAN_specification", dataset);
|
||||
String uid = dataset.getUid();
|
||||
System.out.println("uid:" + uid);
|
||||
ImageIcon icon = new ImageIcon(file.getPath());
|
||||
int row = table.getSelectedRow();
|
||||
int col = table.getSelectedColumn();
|
||||
int[] arr = model.getSpan(row, col);
|
||||
System.out.println("row:" + arr[0] + ",col:" + arr[1]);
|
||||
icon.setImage(icon.getImage().getScaledInstance(
|
||||
table.getColumnModel().getColumn(col)
|
||||
.getPreferredWidth() * arr[1],
|
||||
table.getRowHeight() * arr[0],
|
||||
Image.SCALE_SMOOTH));
|
||||
JLabel label = new JLabel();
|
||||
label.setLayout(new FlowLayout(FlowLayout.CENTER));
|
||||
label.setIcon(icon);
|
||||
label.addMouseListener(showImg(file.getPath()));
|
||||
label.setToolTipText(uid);
|
||||
model.setValueAt(label, table.getSelectedRow(),
|
||||
table.getSelectedColumn());
|
||||
} catch (TCException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return actionListener;
|
||||
}
|
||||
|
||||
private ActionListener addRow() {
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
int row = table.getSelectedRow();
|
||||
if (row > top + 1 && row < bottom + 1) {
|
||||
int num = Integer
|
||||
.parseInt(model.getValueAt(bottom, 0).toString());
|
||||
model.insertRow(bottom);
|
||||
model.setValueAt(num + 1, bottom, 0);
|
||||
model.combine(new int[] { bottom }, new int[] { 2, 3, 4 });
|
||||
bottom = model.getRowCount() - 14;
|
||||
} else {
|
||||
// 提示
|
||||
}
|
||||
}
|
||||
};
|
||||
return actionListener;
|
||||
}
|
||||
|
||||
private ActionListener insertRow() {
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
int row = table.getSelectedRow();
|
||||
if (row > top + 1 && row < bottom + 1) {
|
||||
int num = Integer
|
||||
.parseInt(model.getValueAt(row, 0).toString());
|
||||
model.insertRow(row);
|
||||
for (int i = row; i < model.getRowCount(); i++) {
|
||||
model.setValueAt(num + i + 1 - row, row, 0);
|
||||
}
|
||||
model.combine(new int[] { row }, new int[] { 2, 3, 4 });
|
||||
bottom = model.getRowCount() - 14;
|
||||
} else {
|
||||
// 提示
|
||||
}
|
||||
}
|
||||
};
|
||||
return actionListener;
|
||||
}
|
||||
|
||||
private boolean isEditorDisable(List<String> list, int row, int col) {
|
||||
return list.contains(row + "," + col);
|
||||
}
|
||||
|
||||
private MouseAdapter showImg(String path) {
|
||||
MouseAdapter adapter = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2) {
|
||||
PhotoFrame.getInstance(path);
|
||||
}
|
||||
}
|
||||
};
|
||||
return adapter;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import com.teamcenter.rac.util.DateButton;
|
||||
|
||||
public class ButtonEditor extends DefaultCellEditor {
|
||||
protected DateButton button;
|
||||
private String label;
|
||||
private boolean isPushed;
|
||||
|
||||
public ButtonEditor(JCheckBox checkBox) {
|
||||
super(checkBox);
|
||||
button = new DateButton();
|
||||
|
||||
}
|
||||
|
||||
public Component getTableCellEditorComponent(JTable table, Object value,
|
||||
boolean isSelected, int row, int column) {
|
||||
if (isSelected) {
|
||||
button.setForeground(table.getSelectionForeground());
|
||||
button.setBackground(table.getSelectionBackground());
|
||||
} else {
|
||||
button.setForeground(table.getForeground());
|
||||
button.setBackground(table.getBackground());
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
public Object getCellEditorValue() {
|
||||
//yyyyÄêMMÔÂddÈÕ
|
||||
SimpleDateFormat format=new SimpleDateFormat("yyyyÄêMMÔÂddÈÕ");
|
||||
SimpleDateFormat format2=new SimpleDateFormat("MMÔÂ");
|
||||
SimpleDateFormat format3=new SimpleDateFormat("ddÈÕ");
|
||||
Date data = new Date();
|
||||
System.out.println("aaa===>"+format2.format(data));
|
||||
System.out.println("bbb===>"+format3.format(data));
|
||||
System.out.println("ccc===>"+format.format(data));
|
||||
|
||||
return format.format(button.getDate());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import com.teamcenter.rac.util.DateButton;
|
||||
|
||||
public class ButtonEditor2 extends DefaultCellEditor {
|
||||
|
||||
protected DateButton button;
|
||||
private String label;
|
||||
private boolean isPushed;
|
||||
|
||||
public ButtonEditor2(JCheckBox checkBox) {
|
||||
super(checkBox);
|
||||
button = new DateButton();
|
||||
|
||||
}
|
||||
|
||||
public Component getTableCellEditorComponent(JTable table, Object value,
|
||||
boolean isSelected, int row, int column) {
|
||||
if (isSelected) {
|
||||
button.setForeground(table.getSelectionForeground());
|
||||
button.setBackground(table.getSelectionBackground());
|
||||
} else {
|
||||
button.setForeground(table.getForeground());
|
||||
button.setBackground(table.getBackground());
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
public Object getCellEditorValue() {
|
||||
//yyyyÄêMMÔÂddÈÕ HH:mm
|
||||
SimpleDateFormat format=new SimpleDateFormat("HH:mm");
|
||||
Date data = new Date();
|
||||
System.out.println("ccc===>"+format.format(data));
|
||||
|
||||
return format.format(button.getDate());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,207 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Point;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
public class CTMap extends DefaultTableModel implements CellSpan {
|
||||
protected int rowSize;
|
||||
protected int columnSize;
|
||||
protected int[][][] span; // CellSpan
|
||||
|
||||
@Override
|
||||
public int[] getSpan(int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
if (isOutOfBounds(row, column)) {
|
||||
int[] ret_code = { 1, 1 };
|
||||
return ret_code;
|
||||
}
|
||||
return span[row][column];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpan(int[] span, int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
if (isOutOfBounds(row, column))
|
||||
return;
|
||||
this.span[row][column] = span;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
if (isOutOfBounds(row, column))
|
||||
return false;
|
||||
if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void combine(int[] rows, int[] columns) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
int rowSpan = rows.length;
|
||||
int columnSpan = columns.length;
|
||||
int startRow = rows[0];
|
||||
int startColumn = columns[0];
|
||||
for (int i = 0; i < rowSpan; i++) {
|
||||
for (int j = 0; j < columnSpan; j++) {
|
||||
if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1)
|
||||
|| (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) {
|
||||
// System.out.println("can't combine");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0, ii = 0; i < rowSpan; i++, ii--) {
|
||||
for (int j = 0, jj = 0; j < columnSpan; j++, jj--) {
|
||||
span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj;
|
||||
span[startRow + i][startColumn + j][CellSpan.ROW] = ii;
|
||||
// System.out.println("r " +ii +" c " +jj);
|
||||
}
|
||||
}
|
||||
span[startRow][startColumn][CellSpan.COLUMN] = columnSpan;
|
||||
span[startRow][startColumn][CellSpan.ROW] = rowSpan;
|
||||
}
|
||||
|
||||
public void setSize(Dimension size) {
|
||||
columnSize = size.width;
|
||||
rowSize = size.height;
|
||||
span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW
|
||||
initValue();
|
||||
}
|
||||
|
||||
protected boolean isOutOfBounds(int row, int column) {
|
||||
if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addRow() {
|
||||
|
||||
Vector newData = new Vector(getColumnCount());
|
||||
dataVector.add(newData);
|
||||
|
||||
//
|
||||
newRowsAdded(new TableModelEvent(this, getRowCount() - 1, getRowCount() - 1, TableModelEvent.ALL_COLUMNS,
|
||||
TableModelEvent.INSERT));
|
||||
int[][][] oldSpan = span;
|
||||
int numRows = oldSpan.length;
|
||||
int numColumns = oldSpan[0].length;
|
||||
span = new int[numRows + 1][numColumns][2];
|
||||
System.arraycopy(oldSpan, 0, span, 0, numRows);
|
||||
for (int i = 0; i < numColumns; i++) {
|
||||
span[numRows][i][CellSpan.COLUMN] = 1;
|
||||
span[numRows][i][CellSpan.ROW] = 1;
|
||||
}
|
||||
rowSize = span.length;
|
||||
}
|
||||
public void addColumn(Object columnName) {
|
||||
|
||||
int[][][] oldSpan = span;
|
||||
int numRows = oldSpan.length;
|
||||
int numColumns = oldSpan[0].length;
|
||||
span = new int[numRows][numColumns + 1][2];
|
||||
for (int i = 0; i < span.length; i++) {
|
||||
for (int j = 0; j < span[0].length; j++) {
|
||||
span[i][j][CellSpan.COLUMN] = 1;
|
||||
span[i][j][CellSpan.ROW] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
columnSize = span[0].length;
|
||||
addColumn(columnName, (Vector) null);
|
||||
}
|
||||
|
||||
|
||||
public void insertRow(int row) {
|
||||
Vector rowData = new Vector(getColumnCount());
|
||||
|
||||
dataVector.insertElementAt(rowData, row);
|
||||
System.out.println("size:" + dataVector.size());
|
||||
|
||||
//
|
||||
newRowsAdded(new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
|
||||
int[][][] newSpan = new int[span.length + 1][span[0].length][2];
|
||||
|
||||
int numRows = span.length;
|
||||
int numColumns = span[0].length;
|
||||
for (int i = 0; i < newSpan.length; i++) {
|
||||
if (i < row) {
|
||||
for (int j = 0; j < numColumns; j++) {
|
||||
newSpan[i][j][0] = span[i][j][0];
|
||||
newSpan[i][j][1] = span[i][j][1];
|
||||
}
|
||||
} else if (i == row) {
|
||||
for (int j = 0; j < numColumns; j++) {
|
||||
newSpan[i][j][0] = 1;
|
||||
newSpan[i][j][1] = 1;
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < numColumns; j++) {
|
||||
newSpan[i][j][0] = span[i - 1][j][0];
|
||||
newSpan[i][j][1] = span[i - 1][j][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
span = newSpan;
|
||||
rowSize = span.length;
|
||||
}
|
||||
|
||||
|
||||
public CTMap(int numRows, int numColumns) {
|
||||
Vector names = new Vector(numColumns);
|
||||
names.setSize(numColumns);
|
||||
setColumnIdentifiers(names);
|
||||
dataVector = new Vector();
|
||||
setNumRows(numRows);
|
||||
setSize(new Dimension(numColumns, numRows));
|
||||
}
|
||||
|
||||
protected void initValue() {
|
||||
System.out.println(span.length);
|
||||
for (int i = 0; i < span.length; i++) {
|
||||
for (int j = 0; j < span[i].length; j++) {
|
||||
span[i][j][CellSpan.COLUMN] = 1;
|
||||
span[i][j][CellSpan.ROW] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void split(int row, int column) {
|
||||
if (isOutOfBounds(row, column))
|
||||
return;
|
||||
int columnSpan = span[row][column][CellSpan.COLUMN];
|
||||
int rowSpan = span[row][column][CellSpan.ROW];
|
||||
for (int i = 0; i < rowSpan; i++) {
|
||||
for (int j = 0; j < columnSpan; j++) {
|
||||
span[row + i][column + j][CellSpan.COLUMN] = 1;
|
||||
span[row + i][column + j][CellSpan.ROW] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCol() {
|
||||
|
||||
columnIdentifiers.removeElementAt(columnIdentifiers.size()-1);
|
||||
dataVector.setSize(getRowCount());
|
||||
|
||||
for (int i = 0; i < getRowCount()-1; i++) {
|
||||
|
||||
((Vector)dataVector.elementAt(i)).setSize(getColumnCount());
|
||||
}
|
||||
fireTableStructureChanged();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.basic.BasicTableUI;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
public class CTUI extends BasicTableUI {
|
||||
|
||||
public void paint(Graphics g, JComponent c){
|
||||
Rectangle oldClipBounds = g.getClipBounds();
|
||||
Rectangle clipBounds = new Rectangle(oldClipBounds);
|
||||
int tableWidth = table.getColumnModel().getTotalColumnWidth();
|
||||
clipBounds.width = Math.min(clipBounds.width, tableWidth);
|
||||
g.setClip(clipBounds);
|
||||
|
||||
int firstIndex = table.rowAtPoint(new Point(0, clipBounds.y));
|
||||
int lastIndex = table.getRowCount() - 1;
|
||||
Rectangle rowRect = new Rectangle(0, 0, tableWidth, table.getRowHeight() + table.getRowMargin());
|
||||
rowRect.y = firstIndex * rowRect.height;
|
||||
for (int index = firstIndex; index <= lastIndex; index++) {
|
||||
if (rowRect.intersects(clipBounds)) {
|
||||
// System.out.println(); // debug
|
||||
// System.out.print("" + index +": "); // row
|
||||
paintRow(g, index);
|
||||
}
|
||||
rowRect.y += rowRect.height;
|
||||
}
|
||||
g.setClip(oldClipBounds);
|
||||
}
|
||||
|
||||
private void paintRow(Graphics g, int row) {
|
||||
Rectangle rect = g.getClipBounds();
|
||||
boolean drawn = false;
|
||||
CellSpan cellAtt = (CellSpan) table.getModel();
|
||||
int numColumns = table.getColumnCount();
|
||||
|
||||
for (int column = 0; column < numColumns; column++) {
|
||||
Rectangle cellRect = table.getCellRect(row, column, true);
|
||||
|
||||
int cellRow, cellColumn;
|
||||
if (cellAtt.isVisible(row, column)) {
|
||||
cellRow = row;
|
||||
cellColumn = column;
|
||||
// System.out.print(" "+column+" "); // debug
|
||||
} else {
|
||||
cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW];
|
||||
cellColumn = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN];
|
||||
// System.out.print(" ("+column+")"); // debug
|
||||
}
|
||||
if (cellRect.intersects(rect)) {
|
||||
drawn = true;
|
||||
paintCell(g, cellRect, cellRow, cellColumn);
|
||||
} else {
|
||||
if (drawn)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void paintCell(Graphics g, Rectangle cellRect, int row, int column) {
|
||||
int spacingHeight = table.getRowMargin();
|
||||
int spacingWidth = table.getColumnModel().getColumnMargin();
|
||||
|
||||
Color c = g.getColor();
|
||||
g.setColor(table.getGridColor());
|
||||
g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, cellRect.height - 1);
|
||||
g.setColor(c);
|
||||
|
||||
cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + spacingHeight / 2, cellRect.width - spacingWidth,
|
||||
cellRect.height - spacingHeight);
|
||||
|
||||
if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) {
|
||||
Component component = table.getEditorComponent();
|
||||
component.setBounds(cellRect);
|
||||
component.validate();
|
||||
} else {
|
||||
TableCellRenderer renderer = table.getCellRenderer(row, column);
|
||||
Component component = table.prepareRenderer(renderer, row, column);
|
||||
|
||||
if (component.getParent() == null) {
|
||||
rendererPane.add(component);
|
||||
}
|
||||
rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
public class CTable extends JTable {
|
||||
Map<Point,TableCellEditor> map;
|
||||
public CTable(TableModel model) {
|
||||
super(model);
|
||||
setUI(new CTUI());
|
||||
getTableHeader().setReorderingAllowed(false);
|
||||
setCellSelectionEnabled(true);
|
||||
setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||
map=new HashMap();
|
||||
}
|
||||
public String getToolTipText(MouseEvent e) {
|
||||
int row=this.rowAtPoint(e.getPoint());
|
||||
int col=this.columnAtPoint(e.getPoint());
|
||||
String tiptextString=null;
|
||||
if(row>-1 && col>-1){
|
||||
Object value=this.getValueAt(row, col);
|
||||
if(null!=value && !"".equals(value))
|
||||
tiptextString=value.toString();//Ðü¸¡ÏÔʾµ¥Ôª¸ñÄÚÈÝ
|
||||
}
|
||||
return tiptextString;
|
||||
}
|
||||
public Rectangle getCellRect(int row, int column, boolean includeSpacing) {
|
||||
Rectangle sRect = super.getCellRect(row, column, includeSpacing);
|
||||
if ((row < 0) || (column < 0) || (getRowCount() <= row) || (getColumnCount() <= column)) {
|
||||
return sRect;
|
||||
}
|
||||
CellSpan cellAtt = (CellSpan) getModel();
|
||||
if (!cellAtt.isVisible(row, column)) {
|
||||
int temp_row = row;
|
||||
int temp_column = column;
|
||||
row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW];
|
||||
column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN];
|
||||
}
|
||||
int[] n = cellAtt.getSpan(row, column);
|
||||
|
||||
int index = 0;
|
||||
int columnMargin = getColumnModel().getColumnMargin();
|
||||
Rectangle cellFrame = new Rectangle();
|
||||
int aCellHeight = rowHeight + rowMargin;
|
||||
cellFrame.y = row * aCellHeight;
|
||||
cellFrame.height = n[CellSpan.ROW] * aCellHeight;
|
||||
|
||||
Enumeration eeration = getColumnModel().getColumns();
|
||||
while (eeration.hasMoreElements()) {
|
||||
TableColumn aColumn = (TableColumn) eeration.nextElement();
|
||||
cellFrame.width = aColumn.getWidth() + columnMargin;
|
||||
if (index == column)
|
||||
break;
|
||||
cellFrame.x += cellFrame.width;
|
||||
index++;
|
||||
}
|
||||
for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) {
|
||||
TableColumn aColumn = (TableColumn) eeration.nextElement();
|
||||
cellFrame.width += aColumn.getWidth() + columnMargin;
|
||||
}
|
||||
|
||||
if (!includeSpacing) {
|
||||
Dimension spacing = getIntercellSpacing();
|
||||
cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + spacing.height / 2,
|
||||
cellFrame.width - spacing.width, cellFrame.height - spacing.height);
|
||||
}
|
||||
return cellFrame;
|
||||
}
|
||||
|
||||
private int[] rowColumnAtPoint(Point point) {
|
||||
int[] retValue = { -1, -1 };
|
||||
int row = point.y / (rowHeight + rowMargin);
|
||||
if ((row < 0) || (getRowCount() <= row))
|
||||
return retValue;
|
||||
int column = getColumnModel().getColumnIndexAtX(point.x);
|
||||
|
||||
CellSpan cellAtt = (CellSpan) getModel();
|
||||
|
||||
if (cellAtt.isVisible(row, column)) {
|
||||
retValue[CellSpan.COLUMN] = column;
|
||||
retValue[CellSpan.ROW] = row;
|
||||
return retValue;
|
||||
}
|
||||
retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN];
|
||||
retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW];
|
||||
return retValue;
|
||||
}
|
||||
|
||||
public int rowAtPoint(Point point) {
|
||||
return rowColumnAtPoint(point)[CellSpan.ROW];
|
||||
}
|
||||
|
||||
public int columnAtPoint(Point point) {
|
||||
return rowColumnAtPoint(point)[CellSpan.COLUMN];
|
||||
}
|
||||
|
||||
public void columnSelectionChanged(ListSelectionEvent e) {
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
int firstIndex = e.getFirstIndex();
|
||||
int lastIndex = e.getLastIndex();
|
||||
if (firstIndex == -1 && lastIndex == -1) { // Selection cleared.
|
||||
repaint();
|
||||
}
|
||||
Rectangle dirtyRegion = getCellRect(firstIndex, 0, false);
|
||||
int numCoumns = getColumnCount();
|
||||
int index = firstIndex;
|
||||
for (int i = 0; i < numCoumns; i++) {
|
||||
dirtyRegion.add(getCellRect(index, i, false));
|
||||
}
|
||||
index = lastIndex;
|
||||
for (int i = 0; i < numCoumns; i++) {
|
||||
dirtyRegion.add(getCellRect(index, i, false));
|
||||
}
|
||||
repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height);
|
||||
}
|
||||
public void setCombo(int row,int col,TableCellEditor ce){
|
||||
map.put(new Point(row,col), ce);
|
||||
}
|
||||
public TableCellEditor getCellEditor(int row, int column){
|
||||
Point point = new Point(row,column);
|
||||
if(map.containsKey(point)){
|
||||
return map.get(point);
|
||||
}else{
|
||||
return super.getCellEditor(row, column);
|
||||
}
|
||||
}
|
||||
public void setRowHeight(int row, int rowHeight) {
|
||||
super.setRowHeight(row, rowHeight);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class CTest {
|
||||
static int[] rows;
|
||||
static JScrollPane pane;
|
||||
|
||||
public static void main(String args[]) {
|
||||
final CTMap map = new CTMap(5, 5);
|
||||
final CTable table = new CTable(map);
|
||||
table.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer());
|
||||
pane = new JScrollPane(table);
|
||||
JButton button = new JButton("add");
|
||||
table.setShowGrid(false);
|
||||
final JDialog dialog = new JDialog();
|
||||
dialog.setLayout(new BorderLayout());
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
table.setRowHeight(2, 50);
|
||||
table.revalidate();
|
||||
table.repaint();
|
||||
|
||||
}
|
||||
});
|
||||
dialog.add(pane, BorderLayout.CENTER);
|
||||
dialog.add(button, BorderLayout.SOUTH);
|
||||
dialog.setPreferredSize(new Dimension(500, 500));
|
||||
dialog.show();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
interface CellSpan {
|
||||
public final int ROW = 0;
|
||||
public final int COLUMN = 1;
|
||||
|
||||
public int[] getSpan(int row, int column);
|
||||
public void setSpan(int[] span, int row, int column);
|
||||
|
||||
public boolean isVisible(int row, int column);
|
||||
|
||||
public void combine(int[] rows, int[] columns);
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
public class DefaultModel extends DefaultTableModel implements CellSpan {
|
||||
protected int rowSize;
|
||||
protected int columnSize;
|
||||
protected int[][][] span; // CellSpan
|
||||
@Override
|
||||
public int[] getSpan(int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
if (isOutOfBounds(row, column)) {
|
||||
int[] ret_code = { 1, 1 };
|
||||
return ret_code;
|
||||
}
|
||||
return span[row][column];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpan(int[] span, int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
if (isOutOfBounds(row, column))
|
||||
return;
|
||||
this.span[row][column] = span;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
if (isOutOfBounds(row, column))
|
||||
return false;
|
||||
if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void combine(int[] rows, int[] columns) {
|
||||
// TODO Auto-generated method stub
|
||||
int rowSpan = rows.length;
|
||||
int columnSpan = columns.length;
|
||||
int startRow = rows[0];
|
||||
int startColumn = columns[0];
|
||||
for (int i = 0; i < rowSpan; i++) {
|
||||
for (int j = 0; j < columnSpan; j++) {
|
||||
if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1)
|
||||
|| (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) {
|
||||
// System.out.println("can't combine");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0, ii = 0; i < rowSpan; i++, ii--) {
|
||||
for (int j = 0, jj = 0; j < columnSpan; j++, jj--) {
|
||||
span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj;
|
||||
span[startRow + i][startColumn + j][CellSpan.ROW] = ii;
|
||||
// System.out.println("r " +ii +" c " +jj);
|
||||
}
|
||||
}
|
||||
span[startRow][startColumn][CellSpan.COLUMN] = columnSpan;
|
||||
span[startRow][startColumn][CellSpan.ROW] = rowSpan;
|
||||
}
|
||||
|
||||
public void setSize(Dimension size) {
|
||||
columnSize = size.width;
|
||||
rowSize = size.height;
|
||||
span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW
|
||||
initValue();
|
||||
}
|
||||
|
||||
protected void initValue() {
|
||||
System.out.println(span.length);
|
||||
for (int i = 0; i < span.length; i++) {
|
||||
for (int j = 0; j < span[i].length; j++) {
|
||||
span[i][j][CellSpan.COLUMN] = 1;
|
||||
span[i][j][CellSpan.ROW] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isOutOfBounds(int row, int column) {
|
||||
if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public DefaultModel(int numRows, int numColumns) {
|
||||
Vector names = new Vector(numColumns);
|
||||
names.setSize(numColumns);
|
||||
setColumnIdentifiers(names);
|
||||
dataVector = new Vector();
|
||||
setNumRows(numRows);
|
||||
setSize(new Dimension(numColumns, numRows));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class JCheckPanel extends JPanel {
|
||||
private JCheckBox[] buttons = null;
|
||||
|
||||
public JCheckPanel(String[] text) {
|
||||
super();
|
||||
buttons = new JCheckBox[text.length];
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
buttons[i] = new JCheckBox(text[i]);
|
||||
buttons[i].setPreferredSize(new Dimension(100, 25));
|
||||
add(buttons[i]);
|
||||
}
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
}
|
||||
|
||||
public JCheckBox[] getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public List<JCheckBox> getSelected() {
|
||||
List<JCheckBox> list = new ArrayList<JCheckBox>();
|
||||
for (JCheckBox check : buttons) {
|
||||
if (check.isSelected()) {
|
||||
list.add(check);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setSelected(int index) {
|
||||
buttons[index].setSelected(true);
|
||||
}
|
||||
|
||||
public void setSelected(String value) {
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
buttons[i].setSelected(buttons[i].getText().equals(value));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
public class JRadioPanel extends JPanel {
|
||||
private JRadioButton[] buttons = null;
|
||||
private ButtonGroup buttonGroup = new ButtonGroup();
|
||||
|
||||
public JRadioPanel(String[] text) {
|
||||
super();
|
||||
buttons = new JRadioButton[text.length];
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
buttons[i] = new JRadioButton(text[i]);
|
||||
buttonGroup.add(buttons[i]);
|
||||
add(buttons[i]);
|
||||
}
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
}
|
||||
|
||||
public JRadioButton[] getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public JRadioButton getSelected() {
|
||||
return (JRadioButton) buttonGroup.getSelection()
|
||||
.getSelectedObjects()[0];
|
||||
}
|
||||
|
||||
public void setSelected(int index) {
|
||||
buttons[index].setSelected(true);
|
||||
}
|
||||
|
||||
public void setSelected(String value) {
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
buttons[i].setSelected(buttons[i].getText().equals(value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class MessageBox2 {
|
||||
|
||||
private static String Title = "Ìáʾ";
|
||||
public static final int DEFAULT_OPTION = -1;
|
||||
public static final int YES_NO_OPTION = 10;
|
||||
public static final int YES_NO_CANCEL_OPTION = 11;
|
||||
public static final int OK_CANCEL_OPTION = 12;
|
||||
public static final int YES_OPTION = 0;
|
||||
public static final int NO_OPTION = 1;
|
||||
public static final int CANCEL_OPTION = 2;
|
||||
public static final int OK_OPTION = 0;
|
||||
public static final int CLOSED_OPTION = -1;
|
||||
public static final int ERROR_MESSAGE = 0;
|
||||
public static final int INFORMATION_MESSAGE = 1;
|
||||
public static final int WARNING_MESSAGE = 2;
|
||||
public static final int QUESTION_MESSAGE = 3;
|
||||
public static final int PLAIN_MESSAGE = -1;
|
||||
|
||||
public static int Show(String Msg, int Option) {
|
||||
switch (Option) {
|
||||
case YES_NO_OPTION:
|
||||
case YES_NO_CANCEL_OPTION:
|
||||
case OK_CANCEL_OPTION:
|
||||
return JOptionPane.showConfirmDialog(null, Msg, Title, Option - 10);
|
||||
default:
|
||||
JOptionPane.showMessageDialog(null, Msg, Title, Option);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int Show(String Msg) {
|
||||
return Show(Msg, INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class MyCellEditor extends DefaultCellEditor {
|
||||
private JRadioPanel radio = null;
|
||||
private JCheckPanel check = null;
|
||||
private JLabel img = null;
|
||||
private int type = -1;
|
||||
|
||||
public MyCellEditor(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 JRadioPanel) {
|
||||
System.out.println("radio");
|
||||
radio = (JRadioPanel) value;
|
||||
type = 1;
|
||||
return radio;
|
||||
} else if (value instanceof JCheckPanel) {
|
||||
System.out.println("check");
|
||||
check = (JCheckPanel) value;
|
||||
type = 2;
|
||||
return check;
|
||||
} else if (value instanceof JLabel) {
|
||||
System.out.println("image");
|
||||
img = (JLabel) value;
|
||||
type = 3;
|
||||
return img;
|
||||
}
|
||||
type = 0;
|
||||
System.out.println("default");
|
||||
return super.getTableCellEditorComponent(table, value, isSelected, row,
|
||||
column);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
switch (type) {
|
||||
case 1:
|
||||
return radio;
|
||||
case 2:
|
||||
return check;
|
||||
case 3:
|
||||
return img;
|
||||
}
|
||||
return super.getCellEditorValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopCellEditing() {
|
||||
// TODO Auto-generated method stub
|
||||
// System.out.println("stop");
|
||||
return super.stopCellEditing();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
public class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer {
|
||||
public TableCellTextAreaRenderer() {
|
||||
setLineWrap(true);
|
||||
setWrapStyleWord(true);
|
||||
|
||||
}
|
||||
|
||||
@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);
|
||||
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;
|
||||
}
|
||||
|
||||
// @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);
|
||||
// }
|
||||
// setBorder(BorderFactory.createLineBorder(Color.white));
|
||||
// setBackground(Color.white);
|
||||
// setForeground(Color.black);
|
||||
// if(isSelected){
|
||||
// setBackground(new Color(0, 120, 215));
|
||||
// setForeground(Color.white);
|
||||
// }
|
||||
// String val=(String) table.getValueAt(row, column);
|
||||
// int w=0;
|
||||
// if(val!=null){
|
||||
// w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth();
|
||||
// }
|
||||
// if(w!=0){
|
||||
// //System.out.println("height:"+table.getRowHeight()*(w+1));
|
||||
// table.setRowHeight(row,table.getRowHeight()*(w+1));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// setText(value == null ? "" : value.toString());
|
||||
// return this;
|
||||
// }
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.connor.jd.plm.table;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
|
||||
public class TempTest {
|
||||
public static void main(String[] args) {
|
||||
String temp="<command name=\"";
|
||||
String temp2="\" categoryId=\"com.connor.bs.plm.commands.category\" id=\"FinalTestCommand";
|
||||
String temp3="\"></command>";;
|
||||
String[] name=new String[]{"设计潜在失效模式和后果分析","小试过程流程图","初始产品特殊特性清单","控制计划","小试产品验证方案","新原料开发申请表","物料信息调查表","供应商基本资料调查表","原料进料检验评定表","供应商初审评价表","原料转阶段评审表","项目开发技术思路及总结","试验配方单","小试试验操作单","常规性检测单","可靠性项目验证报告","小试配色记录单","小试试验工艺记录单","试验检测数据表","可靠性验证报告","实验性能总结报告","小试试验工艺单","小试试验安排计划表","产品研究汇总表","车间生产申请单","中试产品验证方案","注塑工艺记录表","试验料检测报告","项目发货技术评审记录表","试料前风险预判与行动计划表","客户处试料工艺记录表","客户处试料总结与分析表","小试阶段评审表"};
|
||||
String t="<handler commandId=\"FinalTestCommand";
|
||||
String t2="\" class=\"com.connor.bs.plm.handlers.SampleHandler\"></handler>";
|
||||
String te="<command commandId=\"FinalTestCommand";
|
||||
String te2="\" mnemonic=\"S\" id=\"com.connor.bs.plm.menus.FinalTestCommand";
|
||||
String te3="\"></command>";
|
||||
String[] name2=new String[]{"原料清单","产品特殊特性清单","BOM表","中试产品验证方案","车间生产申请表","生产过程流程图","过程特殊特性清单","PFMEA","初始过程能力研究计划","生产过程确认计划","生产线平衡分析计划","中试生产工艺卡","新产品上线评审表","生产过程记录总结表","工艺设计目标分析表","中试工艺验证报告","初始过程能力研究报告","生产线平衡分析报告","中试生产过程评审表","试验性能总结报告","可靠性验证报告","技术证明书","检测报告","项目发货技术评审记录表","试料前风险预判与行动计划表","客户处试料工艺记录表","客户处试料总结与分析表","中试阶段评审表"};
|
||||
String[] name3=new String[]{"量试控制计划","量试生产工艺卡","PSW","生产过程记录总结表","工艺设计目标分析表","量试PFMEA","量试生产过程流程图","量试工艺优化计划","量试工艺优化方案及总结","客户使用稳定性分析报告","生产原料稳定性分析报告","产品质量稳定性分析报告","生产过程稳定性分析报告","量试阶段评审表"};
|
||||
for(int i=0;i<name3.length;i++)
|
||||
System.out.println(te+i+te2+i+te3);
|
||||
JDialog dialog=new JDialog();
|
||||
CTMap model2=new CTMap(11,10);
|
||||
CTable table2=new CTable(model2);
|
||||
table2.getColumnModel().getColumn(0).setPreferredWidth(20);
|
||||
JButton button1=new JButton("导出");
|
||||
model2.combine(new int[]{0, 1, 2},new int[]{0});
|
||||
model2.combine(new int[]{3, 4, 5, 6, 7, 8},new int[]{0});
|
||||
model2.combine(new int[]{9, 10},new int[]{0, 1});
|
||||
model2.combine(new int[]{0},new int[]{1, 2, 3});
|
||||
model2.combine(new int[]{0},new int[]{4, 5, 6, 7});
|
||||
model2.combine(new int[]{1},new int[]{1, 2, 3});
|
||||
model2.combine(new int[]{2},new int[]{1, 2, 3});
|
||||
model2.combine(new int[]{3},new int[]{1, 2, 3});
|
||||
model2.combine(new int[]{4},new int[]{1, 2, 3});
|
||||
model2.combine(new int[]{5},new int[]{1, 2, 3});
|
||||
model2.combine(new int[]{6},new int[]{1, 2, 3});
|
||||
model2.combine(new int[]{7, 8},new int[]{1, 2, 3});
|
||||
model2.combine(new int[]{7, 8},new int[]{4, 5, 6, 7});
|
||||
model2.combine(new int[]{1},new int[]{4, 5, 6, 7});
|
||||
model2.combine(new int[]{2},new int[]{4, 5, 6, 7});
|
||||
model2.combine(new int[]{3},new int[]{4, 5, 6, 7});
|
||||
model2.combine(new int[]{4},new int[]{4, 5, 6, 7});
|
||||
model2.combine(new int[]{5},new int[]{4, 5, 6, 7});
|
||||
model2.combine(new int[]{6},new int[]{4, 5, 6, 7});
|
||||
model2.combine(new int[]{1, 2},new int[]{9});
|
||||
model2.combine(new int[]{4, 5, 6, 7, 8},new int[]{9});
|
||||
model2.combine(new int[]{9},new int[]{4, 5, 6, 7, 8, 9});
|
||||
model2.combine(new int[]{10},new int[]{4, 5, 6, 7, 8, 9});
|
||||
model2.combine(new int[]{9},new int[]{2, 3});
|
||||
model2.combine(new int[]{10},new int[]{2, 3});
|
||||
model2.combine(new int[]{7, 8},new int[]{8});
|
||||
dialog.add(table2);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
JD2ConfirmFormRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.SampleConfirmationForm
|
Loading…
Reference in new issue