diff --git a/com.connor.jd.plm/.classpath b/com.connor.jd.plm/.classpath
index b862a29..bf69a48 100644
--- a/com.connor.jd.plm/.classpath
+++ b/com.connor.jd.plm/.classpath
@@ -3,5 +3,556 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.connor.jd.plm/.gitignore b/com.connor.jd.plm/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/com.connor.jd.plm/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF
index 7f362a3..4b7e1b0 100644
--- a/com.connor.jd.plm/META-INF/MANIFEST.MF
+++ b/com.connor.jd.plm/META-INF/MANIFEST.MF
@@ -4,13 +4,51 @@ Bundle-Name: JDProject
Bundle-SymbolicName: com.connor.jd.plm;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.ui,
- com.teamcenter.rac.common;bundle-version="12000.1.0",
- com.teamcenter.rac.ui.commands;bundle-version="12000.1.0",
- com.teamcenter.rac.util;bundle-version="12000.1.0",
- com.teamcenter.rac.aifrcp;bundle-version="12000.1.0",
- com.teamcenter.rac.tcapps;bundle-version="12000.1.0",
- com.teamcenter.rac.kernel;bundle-version="12000.1.0",
- org.eclipse.core.runtime;bundle-version="3.12.0"
+ com.teamcenter.rac.common;bundle-version="11000.2.0",
+ com.teamcenter.rac.tcapps;bundle-version="11000.2.0",
+ com.teamcenter.rac.util;bundle-version="11000.2.0",
+ com.teamcenter.rac.aifrcp;bundle-version="11000.2.0",
+ com.teamcenter.rac.ui.commands;bundle-version="11000.2.0",
+ com.teamcenter.rac.kernel;bundle-version="11000.2.0",
+ com.teamcenter.rac.ui.views;bundle-version="11000.2.0",
+ org.eclipse.core.runtime;bundle-version="3.8.0",
+ org.eclipse.ui.forms;bundle-version="3.5.200"
Automatic-Module-Name: JDProject
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: com.jdproject.handlers
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Export-Package: com.connor.jd.plm.form,
+ com.connor.jd.plm.handlers,
+ com.teamcenter.rac.form
+Import-Package: javafx.animation,
+ javafx.application,
+ javafx.beans,
+ javafx.beans.binding,
+ javafx.beans.property,
+ javafx.beans.property.adapter,
+ javafx.beans.value,
+ javafx.collections,
+ javafx.collections.transformation,
+ javafx.concurrent,
+ javafx.css,
+ javafx.embed.swing,
+ javafx.event,
+ javafx.fxml,
+ javafx.geometry,
+ javafx.print,
+ javafx.scene,
+ javafx.scene.canvas,
+ javafx.scene.chart,
+ javafx.scene.control,
+ javafx.scene.control.cell,
+ javafx.scene.effect,
+ javafx.scene.image,
+ javafx.scene.input,
+ javafx.scene.layout,
+ javafx.scene.media,
+ javafx.scene.paint,
+ javafx.scene.shape,
+ javafx.scene.text,
+ javafx.scene.transform,
+ javafx.scene.web,
+ javafx.stage,
+ javafx.util,
+ javafx.util.converter
diff --git a/com.connor.jd.plm/plugin.xml b/com.connor.jd.plm/plugin.xml
index b7c1a7a..1a0c133 100644
--- a/com.connor.jd.plm/plugin.xml
+++ b/com.connor.jd.plm/plugin.xml
@@ -143,136 +143,136 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/PhotoFrame.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/PhotoFrame.java
new file mode 100644
index 0000000..dba4a99
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/PhotoFrame.java
@@ -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);
+ }
+
+}
\ No newline at end of file
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java
new file mode 100644
index 0000000..8c9d2ac
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java
@@ -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 general;
+ private List disableEdit;
+ private Map prop;
+ private Map 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();// 要填写的一般属性
+ pic = new HashMap();// 图片
+ 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 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 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 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 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;
+ }
+}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/ZPanel.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/ZPanel.java
new file mode 100644
index 0000000..041251b
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/ZPanel.java
@@ -0,0 +1,65 @@
+package com.connor.jd.plm.form;
+
+import java.awt.Graphics;
+import java.awt.Image;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+public class ZPanel extends javax.swing.JPanel {
+
+ private static final long serialVersionUID = 1L;
+ private Image image;
+ private int imgWidth;
+ private int imgHeight;
+
+ public int getImgWidth() {
+ return imgWidth;
+ }
+
+ public void setImgWidth(int imgWidth) {
+ this.imgWidth = imgWidth;
+ }
+
+ public int getImgHeight() {
+ return imgHeight;
+ }
+
+ public void setImgHeight(int imgHeight) {
+ this.imgHeight = imgHeight;
+ }
+
+ public ZPanel() {
+ }
+
+ public void setImagePath(String imgPath) {
+ // 该方法不推荐使用,该方法是懒加载,图像并不加载到内存,当拿图像的宽和高时会返回-1;
+ // image = Toolkit.getDefaultToolkit().getImage(imgPath);
+ try {
+ // 该方法会将图像加载到内存,从而拿到图像的详细信息。
+ image = ImageIO.read(new FileInputStream(imgPath));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ setImgWidth(image.getWidth(this));
+ setImgHeight(image.getHeight(this));
+ }
+
+ @Override
+ public void paintComponent(Graphics g1) {
+ int x = 0;
+ int y = 0;
+ Graphics g = g1;
+ if (null == image) {
+ return;
+ }
+
+ g.drawImage(image, x, y, image.getWidth(this), image.getHeight(this),
+ this);
+ g = null;
+ }
+}
\ No newline at end of file
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CreateItemHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CreateItemHandler.java
index df43322..1432abc 100644
--- a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CreateItemHandler.java
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/CreateItemHandler.java
@@ -1,4 +1,4 @@
-package com.jdproject.handlers;
+package com.connor.jd.plm.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
@@ -38,7 +38,8 @@ import com.teamcenter.rac.util.UIUtilities;
import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog;
import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper;
-public class SampleHandler extends AbstractHandler implements IExecutableExtension {
+public class CreateItemHandler extends AbstractHandler
+ implements IExecutableExtension {
private TCSession session;
private String name;
private AbstractAIFApplication app;
@@ -57,7 +58,8 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
protected NewBOModel m_boModel;
@Override
- public Object execute(ExecutionEvent executionevent) throws ExecutionException {
+ public Object execute(ExecutionEvent executionevent)
+ throws ExecutionException {
System.out.println("开始执行-----------");
app = AIFUtility.getCurrentApplication();
TCComponent comp = (TCComponent) app.getTargetComponent();
@@ -101,7 +103,8 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
throw new IllegalArgumentException("Event can't be null");
boolean flag = false;
- if (executionevent.getParameters() != null && executionevent.getParameters().containsKey("selection")) {
+ if (executionevent.getParameters() != null
+ && executionevent.getParameters().containsKey("selection")) {
Object obj = executionevent.getParameters().get("selection");
if (obj instanceof InterfaceAIFComponent[]) {
selectedCmps = (InterfaceAIFComponent[]) obj;
@@ -110,8 +113,10 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
}
}
if (!flag) {
- m_currentSelection = HandlerUtil.getCurrentSelection(executionevent);
- selectedCmps = SelectionHelper.getTargetComponents(m_currentSelection);
+ m_currentSelection = HandlerUtil
+ .getCurrentSelection(executionevent);
+ selectedCmps = SelectionHelper
+ .getTargetComponents(m_currentSelection);
}
m_boModel = getBOModel();
launchWizard(executionevent);
@@ -123,12 +128,13 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
*
* if (opType .equals("")) { TCComponentItemType itemType =
* (TCComponentItemType) session.getTypeComponent(opType); // create参数:
- * ID、版本、类型、名称、描述、单位 TCComponentItem item = itemType.create(itemType.getNewID(),
- * itemType.getNewRev(null), opType, name + "表", "", null);
+ * ID、版本、类型、名称、描述、单位 TCComponentItem item =
+ * itemType.create(itemType.getNewID(), itemType.getNewRev(null), opType,
+ * name + "表", "", null);
*
* comp.add("contents", item); MessageBox.post(name + "表对象创建成功", "成功",
- * MessageBox.INFORMATION); } } catch (TCException e) { // TODO Auto-generated
- * catch block e.printStackTrace(); } }
+ * MessageBox.INFORMATION); } } catch (TCException e) { // TODO
+ * Auto-generated catch block e.printStackTrace(); } }
*/
private class CreateNewBOSWTDialog implements Runnable {
@@ -199,24 +205,26 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
private final Shell m_shell;
private final String m_type;
- final SampleHandler this$0;
+ final CreateItemHandler this$0;
private CreateNewBOSWTDialog(Shell shell, String s) {
super();
- this$0 = SampleHandler.this;
+ this$0 = CreateItemHandler.this;
m_shell = shell;
m_type = s;
}
- CreateNewBOSWTDialog(Shell shell, String s, CreateNewBOSWTDialog createnewboswtdialog) {
+ CreateNewBOSWTDialog(Shell shell, String s,
+ CreateNewBOSWTDialog createnewboswtdialog) {
this(shell, s);
}
}
@Override
- public void setInitializationData(IConfigurationElement iconfigurationelement, String s, Object obj)
+ public void setInitializationData(
+ IConfigurationElement iconfigurationelement, String s, Object obj)
throws CoreException {
}
@@ -255,10 +263,12 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
protected void initWizardModel(ExecutionEvent executionevent) {
boolean flag = false;
Object obj = null;
- ISessionService isessionservice = (ISessionService) OSGIUtil.getService(RACUICommandsActivator.getDefault(),
+ ISessionService isessionservice = (ISessionService) OSGIUtil.getService(
+ RACUICommandsActivator.getDefault(),
com.teamcenter.rac.services.ISessionService.class);
try {
- session = (TCSession) isessionservice.getSession(com.teamcenter.rac.kernel.TCSession.class.getName());
+ session = (TCSession) isessionservice.getSession(
+ com.teamcenter.rac.kernel.TCSession.class.getName());
} catch (Exception _ex) {
session = (TCSession) AIFUtility.getDefaultSession();
}
@@ -267,9 +277,11 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
m_boModel.setFrame(AIFUtility.getActiveDesktop());
if (executionevent != null) {
if (executionevent.getParameters().containsKey("revisionFlag"))
- flag = ((Boolean) executionevent.getParameters().get("revisionFlag")).booleanValue();
+ flag = ((Boolean) executionevent.getParameters()
+ .get("revisionFlag")).booleanValue();
if (executionevent.getParameters().containsKey("pasteRelation")) {
- String s = (String) executionevent.getParameters().get("pasteRelation");
+ String s = (String) executionevent.getParameters()
+ .get("pasteRelation");
if (s != null) {
String as[] = null;
as = s.split(",");
@@ -277,7 +289,8 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
m_boModel.setPreAssignedRelType(as);
}
}
- if (executionevent.getParameters().containsKey("parentComponents")) {
+ if (executionevent.getParameters()
+ .containsKey("parentComponents")) {
InterfaceAIFComponent ainterfaceaifcomponent[] = (InterfaceAIFComponent[]) executionevent
.getParameters().get("parentComponents");
m_boModel.setTargetArray(ainterfaceaifcomponent);
@@ -294,7 +307,8 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
m_boModel.setCurrentSelection(m_currentSelection);
}
- protected void readDisplayParameters(NewBOWizard newbowizard, WizardDialog wizarddialog) {
+ protected void readDisplayParameters(NewBOWizard newbowizard,
+ WizardDialog wizarddialog) {
newbowizard.retrievePersistedDialogSettings(wizarddialog);
}
@@ -303,7 +317,8 @@ public class SampleHandler extends AbstractHandler implements IExecutableExtensi
try {
TCTypeService service = session.getTypeService();
- TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
+ TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service
+ .getTypeComponent("BOMWindow");
window = winType.create(null);
line = window.setWindowTopLine(rev.getItem(), rev, null, null);
// window.close();//如果不关闭,会导致BOM被占用,乃至包含BOM的版本不能删除,除非重启TC
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/createProjectHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/createProjectHandler.java
deleted file mode 100644
index ac0425a..0000000
--- a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/createProjectHandler.java
+++ /dev/null
@@ -1,316 +0,0 @@
-package com.jdproject.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-//import com.connor.jk.plm.report.SqlUtil;
-import com.teamcenter.rac.aif.AIFDesktop;
-import com.teamcenter.rac.aif.AbstractAIFApplication;
-import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
-import com.teamcenter.rac.aifrcp.AIFUtility;
-import com.teamcenter.rac.aifrcp.SelectionHelper;
-import com.teamcenter.rac.kernel.TCComponent;
-import com.teamcenter.rac.kernel.TCComponentBOMLine;
-import com.teamcenter.rac.kernel.TCComponentBOMWindow;
-import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
-import com.teamcenter.rac.kernel.TCComponentItemRevision;
-import com.teamcenter.rac.kernel.TCException;
-import com.teamcenter.rac.kernel.TCSession;
-import com.teamcenter.rac.kernel.TCTypeService;
-import com.teamcenter.rac.services.ISessionService;
-import com.teamcenter.rac.ui.commands.Messages;
-import com.teamcenter.rac.ui.commands.RACUICommandsActivator;
-import com.teamcenter.rac.ui.commands.create.bo.NewBOModel;
-import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard;
-import com.teamcenter.rac.util.OSGIUtil;
-import com.teamcenter.rac.util.SWTUIUtilities;
-import com.teamcenter.rac.util.UIUtilities;
-import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog;
-import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper;
-
-public class createProjectHandler extends AbstractHandler implements IExecutableExtension {
- private TCSession session;
- private String name;
- private AbstractAIFApplication app;
- private String opType = "";
- protected InterfaceAIFComponent selectedCmps[];
- protected ISelection m_currentSelection;
- protected String wizardId;
- protected WizardDialog dialog;
- TCComponentBOMWindow window = null;
- // private static HashMap map;
-
- /**
- * @deprecated Field session is deprecated
- */
- @Deprecated
- protected NewBOModel m_boModel;
-
- @Override
- public Object execute(ExecutionEvent executionevent) throws ExecutionException {
- System.out.println("开始执行-----------");
- app = AIFUtility.getCurrentApplication();
- TCComponent comp = (TCComponent) app.getTargetComponent();
-
- session = (TCSession) app.getSession();
-
-// TCComponentUser user=session.getUser();
-// try {
-// TCComponent person=user.getReferenceProperty("person");
-// System.out.println(person.getProperty("PA6"));
-// if(person.getProperty("PA6").equals("")) {
-// System.out.println("1");
-// }else if(person.getProperty("PA6")==null) {
-// System.out.println("2");
-// }
-// } catch (TCException e1) {
-// // TODO Auto-generated catch block
-// e1.printStackTrace();
-// }
-//
-//
-// if(true) {
-// return null;
-// }
-
- // 必须是folder,其他的文件夹类型不能建
-// if (comp instanceof TCComponentFolder) {
-// System.out.println(comp.getType());
-// if (comp.getType().equals("Hxc8XMWJJ")) {
-// MessageBox.post("请选中文件夹再新建项目", "", MessageBox.INFORMATION);
-// return null;
-// }
-// } else {
-// MessageBox.post("请选中文件夹再新建项目", "", MessageBox.INFORMATION);
-// return null;
-//
-// }
-
- opType = executionevent.getCommand().getId();
- if (executionevent == null)
- throw new IllegalArgumentException("Event can't be null");
-
- boolean flag = false;
- if (executionevent.getParameters() != null && executionevent.getParameters().containsKey("selection")) {
- Object obj = executionevent.getParameters().get("selection");
- if (obj instanceof InterfaceAIFComponent[]) {
- selectedCmps = (InterfaceAIFComponent[]) obj;
- m_currentSelection = new StructuredSelection(selectedCmps);
- flag = true;
- }
- }
- if (!flag) {
- m_currentSelection = HandlerUtil.getCurrentSelection(executionevent);
- selectedCmps = SelectionHelper.getTargetComponents(m_currentSelection);
- }
- m_boModel = getBOModel();
- launchWizard(executionevent);
- return null;
- }
-
- /*
- * private void createItem(TCComponent comp) { try {
- *
- * if (opType .equals("")) { TCComponentItemType itemType =
- * (TCComponentItemType) session.getTypeComponent(opType); // create参数:
- * ID、版本、类型、名称、描述、单位 TCComponentItem item = itemType.create(itemType.getNewID(),
- * itemType.getNewRev(null), opType, name + "表", "", null);
- *
- * comp.add("contents", item); MessageBox.post(name + "表对象创建成功", "成功",
- * MessageBox.INFORMATION); } } catch (TCException e) { // TODO Auto-generated
- * catch block e.printStackTrace(); } }
- */
-
- private class CreateNewBOSWTDialog implements Runnable {
-
- @Override
- public void run() {
- NewBOWizard newbowizard = (NewBOWizard) getWizard();
- if (newbowizard == null)
- newbowizard = new NewBOWizard(wizardId);
- newbowizard.setBOModel(m_boModel);
- newbowizard.setWindowTitle(getWizardTitle());
- newbowizard.setRevisionFlag(m_boModel.getRevisionFlag());
- newbowizard.setDefaultType(m_type);
- Shell shell = UIUtilities.getCurrentModalShell();
- dialog = new BaseExternalWizardDialog(m_shell, newbowizard);
- dialog.create();
- newbowizard.retrievePersistedDialogSettings(dialog);
- newbowizard.setWizardDialog(dialog);
- UIUtilities.setCurrentModalShell(dialog.getShell());
- dialog.open();
- dialog = null;
-
-// InterfaceAIFComponent[] compS = m_boModel.getTargetArray();
-//
-// if (compS != null && compS.length != 0) {
-// System.out.println(" length =" + compS.length);
-// if (compS[0] instanceof TCComponentItem) {
-//
-// System.out.println("ITEM");
-// } else if (compS[0] instanceof TCComponentFolder) {
-//
-// System.out.println("FOLDER");
-// }
-// TCComponent compT = (TCComponent) compS[0];
-// try {
-// System.out.println("object_name =>" + compT.getStringProperty("object_name"));
-// } catch (TCException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// } else {
-// System.out.println(" null ");
-// }
-//
-// System.out.println("=====>");
-// List contextList = m_boModel.getCompContext();
-// if (contextList != null) {
-// for (AIFComponentContext context : contextList) {
-// InterfaceAIFComponent comp = context.getComponent();
-// try {
-// System.out.println(">" + ((TCComponent) comp).getStringProperty("object_name"));
-// } catch (TCException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// }
-//
-// }
-// System.out.println("=====>");
-// m_boModel = null;
-//
-// UIUtilities.setCurrentModalShell(shell);
-//
-// System.out.println("dialog ==> " + opType + " | " + m_type);
- }
-
- private final Shell m_shell;
- private final String m_type;
- final createProjectHandler this$0;
-
- private CreateNewBOSWTDialog(Shell shell, String s) {
- super();
- this$0 = createProjectHandler.this;
-
- m_shell = shell;
- m_type = s;
- }
-
- CreateNewBOSWTDialog(Shell shell, String s, CreateNewBOSWTDialog createnewboswtdialog) {
- this(shell, s);
- }
-
- }
-
- @Override
- public void setInitializationData(IConfigurationElement iconfigurationelement, String s, Object obj)
- throws CoreException {
- }
-
- protected NewBOModel getBOModel() {
- if (m_boModel == null)
- m_boModel = new NewBOModel(this);
- return m_boModel;
- }
-
- public Wizard getWizard() {
- if (wizardId == null || wizardId.length() == 0)
- wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard";
- return WizardExtensionHelper.getWizard(wizardId);
- }
-
- public String getWizardTitle() {
- return Messages.getString("wizard.TITLE");
- }
-
- public void launchWizard() {
- launchWizard(null);
- }
-
- public void launchWizard(ExecutionEvent executionevent) {
- String s = this.opType;
- initWizardModel(executionevent);
- // if (executionevent != null)
- // s = (String) executionevent.getParameters().get("objectType");
- AIFDesktop aifdesktop = AIFUtility.getActiveDesktop();
- Shell shell = aifdesktop.getShell();
- if (shell != null)
- SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, s, null));
- System.out.println("999999999999999");
- }
-
- protected void initWizardModel(ExecutionEvent executionevent) {
- boolean flag = false;
- Object obj = null;
- ISessionService isessionservice = (ISessionService) OSGIUtil.getService(RACUICommandsActivator.getDefault(),
- com.teamcenter.rac.services.ISessionService.class);
- try {
- session = (TCSession) isessionservice.getSession(com.teamcenter.rac.kernel.TCSession.class.getName());
- } catch (Exception _ex) {
- session = (TCSession) AIFUtility.getDefaultSession();
- }
- m_boModel.setSession(session);
- m_boModel.reInitializeTransientData();
- m_boModel.setFrame(AIFUtility.getActiveDesktop());
- if (executionevent != null) {
- if (executionevent.getParameters().containsKey("revisionFlag"))
- flag = ((Boolean) executionevent.getParameters().get("revisionFlag")).booleanValue();
- if (executionevent.getParameters().containsKey("pasteRelation")) {
- String s = (String) executionevent.getParameters().get("pasteRelation");
- if (s != null) {
- String as[] = null;
- as = s.split(",");
- m_boModel.setRelType(as[0]);
- m_boModel.setPreAssignedRelType(as);
- }
- }
- if (executionevent.getParameters().containsKey("parentComponents")) {
- InterfaceAIFComponent ainterfaceaifcomponent[] = (InterfaceAIFComponent[]) executionevent
- .getParameters().get("parentComponents");
- m_boModel.setTargetArray(ainterfaceaifcomponent);
- } else {
- m_boModel.setTargetArray(selectedCmps);
- }
- } else {
- m_boModel.setTargetArray(selectedCmps);
- }
- m_boModel.setRevisionFlag(flag);
- AIFDesktop aifdesktop = AIFUtility.getActiveDesktop();
- Shell shell = aifdesktop.getShell();
- m_boModel.setShell(shell);
- m_boModel.setCurrentSelection(m_currentSelection);
- }
-
- protected void readDisplayParameters(NewBOWizard newbowizard, WizardDialog wizarddialog) {
- newbowizard.retrievePersistedDialogSettings(wizarddialog);
- }
-
- public TCComponentBOMLine getTopLineByRev(TCComponentItemRevision rev) {// 获得顶层bomline
- TCComponentBOMLine line = null;
-
- try {
- TCTypeService service = session.getTypeService();
- TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
- window = winType.create(null);
- line = window.setWindowTopLine(rev.getItem(), rev, null, null);
-// window.close();//如果不关闭,会导致BOM被占用,乃至包含BOM的版本不能删除,除非重启TC
- } catch (TCException e) {
- e.printStackTrace();
- }
-
- return line;
- }
-}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/ButtonEditor.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/ButtonEditor.java
new file mode 100644
index 0000000..9166dc0
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/ButtonEditor.java
@@ -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());
+ }
+
+}
\ No newline at end of file
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/ButtonEditor2.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/ButtonEditor2.java
new file mode 100644
index 0000000..6baef65
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/ButtonEditor2.java
@@ -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());
+ }
+
+
+}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/CTMap.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/CTMap.java
new file mode 100644
index 0000000..9d8044e
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/CTMap.java
@@ -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();
+ }
+}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/CTUI.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/CTUI.java
new file mode 100644
index 0000000..4ecbe1c
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/CTUI.java
@@ -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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/CTable.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/CTable.java
new file mode 100644
index 0000000..57fedd2
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/CTable.java
@@ -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 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);
+ }
+}
\ No newline at end of file
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/CTest.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/CTest.java
new file mode 100644
index 0000000..3304923
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/CTest.java
@@ -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();
+ }
+}
\ No newline at end of file
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/CellSpan.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/CellSpan.java
new file mode 100644
index 0000000..dedb6dd
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/CellSpan.java
@@ -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);
+
+}
\ No newline at end of file
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/DefaultModel.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/DefaultModel.java
new file mode 100644
index 0000000..ca0cb1a
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/DefaultModel.java
@@ -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));
+ }
+
+}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java
new file mode 100644
index 0000000..6b62352
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/JCheckPanel.java
@@ -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 getSelected() {
+ List list = new ArrayList();
+ 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));
+ }
+ }
+}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java
new file mode 100644
index 0000000..a343b2c
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/JRadioPanel.java
@@ -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));
+ }
+ }
+
+}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MessageBox2.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MessageBox2.java
new file mode 100644
index 0000000..4aa3313
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MessageBox2.java
@@ -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);
+ }
+
+}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java
new file mode 100644
index 0000000..8bf1cfe
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java
@@ -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();
+ }
+
+}
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/TableCellTextAreaRenderer.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/TableCellTextAreaRenderer.java
new file mode 100644
index 0000000..453af83
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/TableCellTextAreaRenderer.java
@@ -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;
+// }
+}
\ No newline at end of file
diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/TempTest.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/TempTest.java
new file mode 100644
index 0000000..b55a762
--- /dev/null
+++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/TempTest.java
@@ -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="";;
+ String[] name=new String[]{"设计潜在失效模式和后果分析","小试过程流程图","初始产品特殊特性清单","控制计划","小试产品验证方案","新原料开发申请表","物料信息调查表","供应商基本资料调查表","原料进料检验评定表","供应商初审评价表","原料转阶段评审表","项目开发技术思路及总结","试验配方单","小试试验操作单","常规性检测单","可靠性项目验证报告","小试配色记录单","小试试验工艺记录单","试验检测数据表","可靠性验证报告","实验性能总结报告","小试试验工艺单","小试试验安排计划表","产品研究汇总表","车间生产申请单","中试产品验证方案","注塑工艺记录表","试验料检测报告","项目发货技术评审记录表","试料前风险预判与行动计划表","客户处试料工艺记录表","客户处试料总结与分析表","小试阶段评审表"};
+ String t="";
+ String te="";
+ String[] name2=new String[]{"原料清单","产品特殊特性清单","BOM表","中试产品验证方案","车间生产申请表","生产过程流程图","过程特殊特性清单","PFMEA","初始过程能力研究计划","生产过程确认计划","生产线平衡分析计划","中试生产工艺卡","新产品上线评审表","生产过程记录总结表","工艺设计目标分析表","中试工艺验证报告","初始过程能力研究报告","生产线平衡分析报告","中试生产过程评审表","试验性能总结报告","可靠性验证报告","技术证明书","检测报告","项目发货技术评审记录表","试料前风险预判与行动计划表","客户处试料工艺记录表","客户处试料总结与分析表","中试阶段评审表"};
+ String[] name3=new String[]{"量试控制计划","量试生产工艺卡","PSW","生产过程记录总结表","工艺设计目标分析表","量试PFMEA","量试生产过程流程图","量试工艺优化计划","量试工艺优化方案及总结","客户使用稳定性分析报告","生产原料稳定性分析报告","产品质量稳定性分析报告","生产过程稳定性分析报告","量试阶段评审表"};
+ for(int i=0;i