diff --git a/com.connor.jd.plm/META-INF/MANIFEST.MF b/com.connor.jd.plm/META-INF/MANIFEST.MF index ad8d3d3..a1e8267 100644 --- a/com.connor.jd.plm/META-INF/MANIFEST.MF +++ b/com.connor.jd.plm/META-INF/MANIFEST.MF @@ -16,12 +16,16 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.108.0", com.teamcenter.rac.schedule;bundle-version="12000.1.0" Automatic-Module-Name: JDProject Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: com.connor.jd.plm.action, +Export-Package: com.connor.jd.operations, + com.connor.jd.plm.action, + com.connor.jd.plm.beans, com.connor.jd.plm.dialog, + com.connor.jd.plm.dialogs, com.connor.jd.plm.form, com.connor.jd.plm.handlers, com.connor.jd.plm.table, com.connor.jd.plm.util, + com.connor.jd.plm.utils, com.teamcenter.rac.stylesheet Import-Package: com.teamcenter.services, com.teamcenter.services.rac, diff --git a/com.connor.jd.plm/config/db.setting b/com.connor.jd.plm/config/db.setting index dbbfc73..7780db4 100644 --- a/com.connor.jd.plm/config/db.setting +++ b/com.connor.jd.plm/config/db.setting @@ -1,6 +1,7 @@ ## db.settingÎļþ -url = jdbc:oracle:thin:@localhost:1521:TC +# url = jdbc:oracle:thin:@localhost:1521:TC +url = jdbc:oracle:thin:@localhost:1521:TC12 user = infodba pass = infodba diff --git a/com.connor.jd.plm/plugin.xml b/com.connor.jd.plm/plugin.xml index 900a37a..c92e6a3 100644 --- a/com.connor.jd.plm/plugin.xml +++ b/com.connor.jd.plm/plugin.xml @@ -151,6 +151,7 @@ + @@ -297,7 +298,7 @@ - + @@ -515,6 +516,13 @@ label="修改分类属性" id="com.connor.jd.editClassification"> true + + + true map=new HashMap<>(); + + public TransformBomBean(TCComponentBOMLine line) { + // TODO Auto-generated constructor stub + try { + this.line = line; + this.displayName=line.getProperty("object_string"); + } catch (TCException e) { + // TODO Auto-generated catch blocks + e.printStackTrace(); + } + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return displayName; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java index a334a53..86e6055 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CSXWHDialog.java @@ -269,7 +269,7 @@ public class CSXWHDialog extends Application { if (delCompList.get(i) == findList.get(j).getCompId()) { String sql = "delete from JD2_Component where test_id=?"; update(sql, findList.get(j).getCompId()); - // System.out.println("ÒÆ³ýÁËÔ­±¾Êý¾Ý¿â¾ÍÓеÄ"); + System.out.println("ÒÆ³ýÁËÔ­±¾Êý¾Ý¿â¾ÍÓеÄ"); findList.remove(j); } Iterator compIt = componentData.iterator(); @@ -277,7 +277,7 @@ public class CSXWHDialog extends Application { int compid = compIt.next().getCompId(); if (delCompList.get(i) == compid) { compIt.remove(); - // System.out.println("³õʼ½á¹û¼¯ÒƳýÁËÒ»Ìõ"); + System.out.println("³õʼ½á¹û¼¯ÒƳýÁËÒ»Ìõ"); } } } @@ -300,14 +300,17 @@ public class CSXWHDialog extends Application { } if (flag) { for (ComponentBean com : findList) { - System.out.println("״̬" + com.getStage()); + // System.out.println("״̬" + com.getStage()); if (com.getStage() == 1) { insert(com); com.setStage(0); + selectId(com); + System.out.println("comµÄId" + com.getCompId()); } if (com.getStage() == 2) { update(com); com.setStage(0); + } } tableView0.refresh(); @@ -519,6 +522,7 @@ public class CSXWHDialog extends Application { if (mac.getStage() == 1) { insertMac(mac); mac.setStage(0); + selectMacId(mac); } if (mac.getStage() == 2) { updateMac(mac); @@ -576,6 +580,66 @@ public class CSXWHDialog extends Application { return results; } + private void selectId(ComponentBean com) { + String sql = "select component_id_seq.nextval from dual"; + con = DBConnectionUtil.dbConn("infodba", "infodba"); + try { + ps = con.prepareStatement(sql); + rs = ps.executeQuery(); + while (rs.next()) { + int id = rs.getInt(1) - 1; + System.out.println("id" + id); + com.setCompId(id); + } + } catch (Exception e) { + System.out.println("²éÕÒʧ°Ü"); + } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (con != null) { + try { + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + + private void selectMacId(MachineBean com) { + String sql = "select machine_id_seq.nextval from dual"; + con = DBConnectionUtil.dbConn("infodba", "infodba"); + try { + ps = con.prepareStatement(sql); + rs = ps.executeQuery(); + while (rs.next()) { + int id = rs.getInt(1); + com.setMacId(id); + } + } catch (Exception e) { + } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (con != null) { + try { + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + private void insert(ComponentBean com) { String sql = "insert into JD2_Component(test_type,test_project,test_time,test_num,test_cost) values(?,?,?,?,?)"; con = DBConnectionUtil.dbConn("infodba", "infodba"); @@ -602,6 +666,20 @@ public class CSXWHDialog extends Application { } catch (Exception e) { System.out.println("Ìí¼Óʧ°Ü"); } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (con != null) { + try { + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } } } @@ -627,6 +705,20 @@ public class CSXWHDialog extends Application { } catch (Exception e) { System.out.println("Ìí¼Óʧ°Ü"); } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (con != null) { + try { + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } } } @@ -656,6 +748,20 @@ public class CSXWHDialog extends Application { } catch (Exception e) { } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (con != null) { + try { + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } } } @@ -709,6 +815,20 @@ public class CSXWHDialog extends Application { } catch (Exception e) { } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (con != null) { + try { + con.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } } } } \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.java new file mode 100644 index 0000000..bc4a752 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeCellRenderer.java @@ -0,0 +1,107 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.net.URL; + +import javax.swing.ImageIcon; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; +import javax.swing.tree.TreeCellRenderer; + +import com.connor.jd.plm.beans.TransformBomBean; +import com.teamcenter.rac.kernel.TCException; + +public class CheckBoxTreeCellRenderer extends JPanel implements TreeCellRenderer { + protected JCheckBox check; + protected CheckBoxTreeLabel label; + + public CheckBoxTreeCellRenderer() { + setLayout(null); + add(check = new JCheckBox()); + add(label = new CheckBoxTreeLabel()); + // ÉèÖò»¿É±à¼­ + check.setEnabled(false); + check.setBackground(UIManager.getColor("Tree.textBackground")); + label.setForeground(UIManager.getColor("Tree.textForeground")); + } + + /** + * ·µ»ØµÄÊÇÒ»¸öJPanel¶ÔÏ󣬸öÔÏóÖаüº¬Ò»¸öJCheckBox¶ÔÏó + * ºÍÒ»¸öJLabel¶ÔÏó¡£²¢ÇÒ¸ù¾Ýÿ¸ö½áµãÊÇ·ñ±»Ñ¡ÖÐÀ´¾ö¶¨JCheckBox ÊÇ·ñ±»Ñ¡ÖС£ + */ + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, + boolean leaf, int row, boolean hasFocus) { + String stringValue = tree.convertValueToText(value, selected, expanded, leaf, row, hasFocus); + setEnabled(tree.isEnabled()); + check.setSelected(((CheckBoxTreeNode) value).isSelected()); + label.setFont(tree.getFont()); + label.setText(stringValue); + label.setSelected(selected); + label.setFocus(hasFocus); + + CheckBoxTreeNode node = (CheckBoxTreeNode) value; + TransformBomBean bean = (TransformBomBean) node.getUserObject(); + try { + String type = bean.line.getItemRevision().getType(); + if (type.equals("WX3_ZPTRevision")) { + URL resource = CheckBoxTreeCellRenderer.class.getResource("/com/connor/wxplm/utils/WX3_zptrev.png"); + label.setIcon(new ImageIcon(resource)); + } else if (type.equals("WX3_LJTRevision")) { + URL resource = CheckBoxTreeCellRenderer.class.getResource("/com/connor/wxplm/utils/WX3_ljtrev.png"); + label.setIcon(new ImageIcon(resource)); + } else if (type.equals("WX3_WLRevision")) { + URL resource = CheckBoxTreeCellRenderer.class.getResource("/com/connor/wxplm/utils/WX3_WLRev.png"); + label.setIcon(new ImageIcon(resource)); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + /* + * if(leaf) label.setIcon(UIManager.getIcon("Tree.leafIcon")); else if(expanded) + * label.setIcon(UIManager.getIcon("Tree.expandedIcon")); else + * label.setIcon(UIManager.getIcon("Tree.closedIcon")); + */ + + return this; + } + + @Override + public Dimension getPreferredSize() { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + return new Dimension(dCheck.width + dLabel.width, + dCheck.height < dLabel.height ? dLabel.height : dCheck.height); + } + + @Override + public void doLayout() { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + int yCheck = 0; + int yLabel = 0; + if (dCheck.height < dLabel.height) + yCheck = (dLabel.height - dCheck.height) / 2; + else + yLabel = (dCheck.height - dLabel.height) / 2; + check.setLocation(0, yCheck); + check.setBounds(0, yCheck, dCheck.width, dCheck.height); + label.setLocation(dCheck.width, yLabel); + label.setBounds(dCheck.width, yLabel, dLabel.width, dLabel.height); + } + + @Override + public void setBackground(Color color) { + if (color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.java new file mode 100644 index 0000000..2c8b26c --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeLabel.java @@ -0,0 +1,66 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; + +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; + +public class CheckBoxTreeLabel extends JLabel { + private boolean isSelected; + private boolean hasFocus; + + public CheckBoxTreeLabel() { + } + + @Override + public void setBackground(Color color) { + if (color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } + + @Override + public void paint(Graphics g) { + String str; + if ((str = getText()) != null) { + if (0 < str.length()) { + if (isSelected) + g.setColor(UIManager.getColor("Tree.selectionBackground")); + else + g.setColor(UIManager.getColor("Tree.textBackground")); + Dimension d = getPreferredSize(); + int imageOffset = 0; + Icon currentIcon = getIcon(); + if (currentIcon != null) + imageOffset = currentIcon.getIconWidth() + Math.max(0, getIconTextGap() - 1); + g.fillRect(imageOffset, 0, d.width - 1 - imageOffset, d.height); + if (hasFocus) { + g.setColor(UIManager.getColor("Tree.selectionBorderColor")); + g.drawRect(imageOffset, 0, d.width - 1 - imageOffset, d.height - 1); + } + } + } + super.paint(g); + } + + @Override + public Dimension getPreferredSize() { + Dimension retDimension = super.getPreferredSize(); + if (retDimension != null) + retDimension = new Dimension(retDimension.width + 3, retDimension.height); + return retDimension; + } + + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + } + + public void setFocus(boolean hasFocus) { + this.hasFocus = hasFocus; + } + +} \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeNode.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeNode.java new file mode 100644 index 0000000..65e71b9 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeNode.java @@ -0,0 +1,92 @@ +package com.connor.jd.plm.dialogs; + +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.MutableTreeNode; +import javax.swing.tree.TreeNode; + +public class CheckBoxTreeNode extends DefaultMutableTreeNode { + protected boolean isSelected; + protected boolean isSelectable = true; + public CheckBoxTreeNode() { + this(null); + } + + public CheckBoxTreeNode(Object userObject) { + this(userObject, true, false); + } + + public CheckBoxTreeNode(Object userObject, boolean allowsChildren, boolean isSelected) { + super(userObject, allowsChildren); + this.isSelected = isSelected; + } + + public boolean isSelected() { + return isSelected; + } + + public void setSelected(boolean _isSelected) { + this.isSelected = _isSelected; + + /*if (_isSelected) { + // Èç¹ûÑ¡ÖУ¬Ôò½«ÆäËùÓеÄ×Ó½áµã¶¼Ñ¡ÖÐ + if (children != null) { + for (Object obj : children) { + CheckBoxTreeNode node = (CheckBoxTreeNode) obj; + if (_isSelected != node.isSelected()) + node.setSelected(_isSelected); + } + } + // ÏòÉϼì²é£¬Èç¹û¸¸½áµãµÄËùÓÐ×Ó½áµã¶¼±»Ñ¡ÖУ¬ÄÇô½«¸¸½áµãҲѡÖÐ + CheckBoxTreeNode pNode = (CheckBoxTreeNode) parent; + // ¿ªÊ¼¼ì²épNodeµÄËùÓÐ×Ó½ÚµãÊÇ·ñ¶¼±»Ñ¡ÖÐ + if (pNode != null) { + int index = 0; + for (; index < pNode.children.size(); ++index) { + CheckBoxTreeNode pChildNode = (CheckBoxTreeNode) pNode.children.get(index); + if (!pChildNode.isSelected()) + break; + } + + * ±íÃ÷pNodeËùÓÐ×Ó½áµã¶¼ÒѾ­Ñ¡ÖУ¬ÔòÑ¡Öи¸½áµã£¬ ¸Ã·½·¨ÊÇÒ»¸öµÝ¹é·½·¨£¬Òò´ËÔڴ˲»ÐèÒª½øÐеü´ú£¬ÒòΪ + * µ±Ñ¡Öи¸½áµãºó£¬¸¸½áµã±¾Éí»áÏòÉϼì²éµÄ¡£ + + if (index == pNode.children.size()) { + if (pNode.isSelected() != _isSelected) + pNode.setSelected(_isSelected); + } + } + } else { + + * Èç¹ûÊÇÈ¡Ïû¸¸½áµãµ¼ÖÂ×Ó½áµãÈ¡Ïû£¬ÄÇô´ËʱËùÓеÄ×Ó½áµã¶¼Ó¦¸ÃÊÇÑ¡ÔñÉϵģ» + * ·ñÔò¾ÍÊÇ×Ó½áµãÈ¡Ïûµ¼Ö¸¸½áµãÈ¡Ïû£¬È»ºó¸¸½áµãÈ¡Ïûµ¼ÖÂÐèҪȡÏû×Ó½áµã£¬µ« ÊÇÕâʱºòÊDz»ÐèҪȡÏû×Ó½áµãµÄ¡£ + + if (children != null) { + int index = 0; + for (; index < children.size(); ++index) { + CheckBoxTreeNode childNode = (CheckBoxTreeNode) children.get(index); + if (!childNode.isSelected()) + break; + } + // ´ÓÉÏÏòÏÂÈ¡ÏûµÄʱºò + if (index == children.size()) { + for (int i = 0; i < children.size(); ++i) { + CheckBoxTreeNode node = (CheckBoxTreeNode) children.get(i); + if (node.isSelected() != _isSelected) + node.setSelected(_isSelected); + } + } + } + + // ÏòÉÏÈ¡Ïû£¬Ö»Òª´æÔÚÒ»¸ö×ӽڵ㲻ÊÇÑ¡Éϵģ¬ÄÇô¸¸½Úµã¾Í²»Ó¦¸Ã±»Ñ¡ÉÏ¡£ + CheckBoxTreeNode pNode = (CheckBoxTreeNode) parent; + if (pNode != null && pNode.isSelected() != _isSelected) + pNode.setSelected(_isSelected); + }*/ + } + + // ²»¿É±à¼­ + public boolean setSelectable(boolean bol) { + + return isSelectable = bol; + } +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.java new file mode 100644 index 0000000..6631a27 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/CheckBoxTreeNodeSelectionListener.java @@ -0,0 +1,30 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; + + + +public class CheckBoxTreeNodeSelectionListener extends MouseAdapter { + @Override + public void mouseClicked(MouseEvent event) { + + JTree tree = (JTree) event.getSource(); + int x = event.getX(); + int y = event.getY(); + int row = tree.getRowForLocation(x, y); + TreePath path = tree.getPathForRow(row); + if (path != null) { + CheckBoxTreeNode node = (CheckBoxTreeNode) path.getLastPathComponent(); + if (node != null&&node.isSelectable) { + boolean isSelected = !node.isSelected(); + node.setSelected(isSelected); + ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node); + } + } + } +} \ No newline at end of file diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.java new file mode 100644 index 0000000..8b1de4a --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialogs/TransformDesignToPartDialog.java @@ -0,0 +1,829 @@ +package com.connor.jd.plm.dialogs; + +import java.awt.BorderLayout; +import java.awt.Checkbox; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.HeadlessException; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.swing.BorderFactory; +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.ScrollPaneConstants; +import javax.swing.event.MenuKeyEvent; +import javax.swing.event.MenuKeyListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; + +import com.connor.jd.plm.beans.TransformBomBean; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMViewRevision; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +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.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.soaictstubs.transientTicketInfo_s; + + +public class TransformDesignToPartDialog extends AbstractAIFDialog implements ActionListener { + private AbstractAIFApplication app; + private TCSession session; + private TCComponentBOMLine topBomline; + private JButton okButton; + private JButton celButton; + private JTree tree; + private CheckBoxTreeNode topTree; + private List> comboxList; + private JPanel rightJPanel; + private Map> checkBoxTreeNodelMap; + private Map, JButton> boxJButtonMap; + private JPanel leftJPanel; + private int index = 1; + private String[] types; + TCComponentBOMWindow win; + public TransformDesignToPartDialog(AbstractAIFApplication app, TCComponentBOMLine topBomline,String[] types) { + // TODO Auto-generated constructor stub + System.out.println("step:-3------------------"); + comboxList = new ArrayList<>(); + this.app = app; + this.session = (TCSession) app.getSession(); + this.topBomline = topBomline; + this.types=types; + createWindow(); + + initUI(); + } + private void createWindow() { + try { + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + win = winType.create(null); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ½çÃæ³õʼ»¯ + */ + private void initUI() { + this.setTitle("DBOMתEBOM"); + this.setSize(new Dimension(700, 400)); + JPanel rightroot = new JPanel(new BorderLayout()); + rightJPanel = new JPanel(new PropertyLayout()); + rightroot.setBorder(BorderFactory.createTitledBorder("ÎïÁÏ")); + leftJPanel = new JPanel(new BorderLayout()); + leftJPanel.setBorder(BorderFactory.createTitledBorder("ͼֽ")); + leftJPanel.setPreferredSize(new Dimension(350, 300)); + rightroot.setPreferredSize(new Dimension(350, 300)); + getBOMTreeAndwl(); + JScrollPane leftpane = new JScrollPane(tree); + leftpane.setBorder(null); + leftJPanel.add(leftpane); + JScrollPane rightpane = new JScrollPane(rightJPanel); + rightroot.add(rightpane); + rightpane.setBorder(null); + final JScrollBar bar2 = rightpane.getVerticalScrollBar(); + final JScrollBar bar1 = leftpane.getVerticalScrollBar(); + rightpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + leftpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + bar2.addAdjustmentListener(new AdjustmentListener() { + + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + // TODO Auto-generated method stub + if (e.getValueIsAdjusting()) { + bar1.setValue(e.getValue()); + } + } + }); + + bar1.addAdjustmentListener(new AdjustmentListener() { + + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + // TODO Auto-generated method stub + if (e.getValueIsAdjusting()) { + bar2.setValue(e.getValue()); + } + } + }); + + leftpane.getVerticalScrollBar().setUnitIncrement(10); + leftpane.addMouseWheelListener(new MouseWheelListener() { + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + if (e.getScrollType() == e.WHEEL_UNIT_SCROLL && bar1.getValue() >= 0 + && bar1.getValue() <= bar1.getVisibleAmount()) { + int scroll = e.getUnitsToScroll(); + bar2.setValue(scroll * bar1.getUnitIncrement()); + + } + } + }); + + rightpane.getVerticalScrollBar().setUnitIncrement(10); + rightpane.addMouseWheelListener(new MouseWheelListener() { + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + if (e.getScrollType() == e.WHEEL_UNIT_SCROLL && bar1.getValue() >= 0 + && bar1.getValue() <= bar1.getVisibleAmount()) { + int scroll = e.getUnitsToScroll(); + bar1.setValue(scroll * bar2.getUnitIncrement()); + + } + } + }); + + JPanel botomJPanel = new JPanel(new ButtonLayout()); + okButton = new JButton("ת»»"); + okButton.addActionListener(this); + celButton = new JButton("Í˳ö"); + celButton.addActionListener(this); + + botomJPanel.add("1.1.left.top", okButton); + botomJPanel.add("1.2.left.top", new JLabel(" ")); + botomJPanel.add("1.3.left.top", celButton); + JPanel rootJPanel = new JPanel(new PropertyLayout()); + rootJPanel.add("1.1.left.top", leftJPanel); + rootJPanel.add("1.2.left.top", rightroot); + + this.setLayout(new BorderLayout()); + this.add(rootJPanel, BorderLayout.CENTER); + this.add(botomJPanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + this.setResizable(false); + } + + /** + * @param line + * ËùÓÐBOMÌí¼Óµ½Ê÷½á¹¹ + * @param node + * @throws TCException + */ + public void treeModel(TCComponentBOMLine line, CheckBoxTreeNode node) throws TCException { + System.out.println(line.getProperty("object_string") + "-------------------"); + AIFComponentContext[] children = line.getChildren(); + for (AIFComponentContext conetext : children) { + TCComponentBOMLine childLine = (TCComponentBOMLine) conetext.getComponent(); + final CheckBoxTreeNode childNode = new CheckBoxTreeNode(new TransformBomBean(childLine)); + childNode.setSelectable(false); + node.add(childNode); + setCombox(childLine, childNode); + treeModel(childLine, childNode); + } + } + + private void getBOMTreeAndwl() { + try { + checkBoxTreeNodelMap = new HashMap<>(); + boxJButtonMap = new HashMap<>(); + topTree = new CheckBoxTreeNode(new TransformBomBean(topBomline)); + setCombox(topBomline, topTree); + System.out.println("##########" + topTree.toString() + "##########"); + treeModel(topBomline, topTree); + tree = new JTree(); + tree.setEnabled(false); + tree.setRowHeight(30); + DefaultTreeModel model = new DefaultTreeModel(topTree); + tree.addMouseListener(new CheckBoxTreeNodeSelectionListener()); + tree.setModel(model); + tree.setCellRenderer(new CheckBoxTreeCellRenderer()); + tree.putClientProperty("JTree.lineStyle", "Angled"); + topTree.setSelectable(false); + tree.expandPath(new TreePath(topTree.getPath())); + Enumeration enumeration = topTree.preorderEnumeration(); + while (enumeration.hasMoreElements()) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement(); + if (!node.isLeaf()) { + TreePath path = new TreePath(node.getPath()); + tree.expandPath(path); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if (e.getSource().equals(okButton)) { + try { + System.out.println("½øÐÐת»»"); + if(win==null) + createWindow(); + createMaterialBom(topTree); + MessageBox.post("ת»»bom³É¹¦", "Ìáʾ", MessageBox.INFORMATION); + this.dispose(); + } catch (TCException e1) { + + // TODO Auto-generated catch block + MessageBox.post(e1.getMessage(),"ת»»bomʧ°Ü" , MessageBox.INFORMATION); + e1.printStackTrace(); + }finally { + try { + + win.close(); + win=null; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } else if (e.getSource().equals(celButton)) { + + dispose(); + } + + } + + /** + * ½²Tree¶ÔÓ¦µÄitemÑ¡ÖÐ + * + * @param wl + *//* + * private void checkSelected(String wl) { for (TransformBomBean bean : + * bomlist) { if (bean.map.containsKey(wl)) { bean.selectCount++; if + * (bean.selectCount > 1) { MessageBox.post("Ö»ÄÜΪµ±Ç°Í¼Ö½Ñ¡ÔñÒ»¸öÎïÁϽøÐÐÉè¼ÆBOMµÄת»»£¡", + * "¾¯¸æ", MessageBox.WARNING); return; } + * System.out.println(bean.displayName + "Ñ¡ÖÐÏÔʾÃû"); + * System.out.println(checkBoxTreeNodelMap.containsKey(bean.displayName) + * ); checkBoxTreeNodelMap.get(bean.displayName).setSelected(true); + * findInTree(bean.displayName); TransformBomBean bean1 = + * (TransformBomBean) + * checkBoxTreeNodelMap.get(bean.displayName).getUserObject(); + * bean1.selectRev = (TCComponentItemRevision) bean.map.get(wl); } } } + */ + + /** + * ½²Tree¶ÔÓ¦µÄitemÈ¡ÏûÑ¡ÖÐ + * + * @param wl + *//* + * private void checkDisSelected(String wl) { for (TransformBomBean bean + * : bomlist) { if (bean.map.containsKey(wl)) { bean.selectCount--; + * checkBoxTreeNodelMap.get(bean.displayName).setSelected(false); } } } + */ + + /** + * ´î½¨BOM + * + * @param node + * @throws TCException + */ + private void createMaterialBom(CheckBoxTreeNode node) throws TCException { + // System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); + TransformBomBean bean = (TransformBomBean) node.getUserObject(); + TCComponentItemRevision materialRev = bean.selectRev; + // ´æÔÚÒѾ­·¢²¼µÄÎïÁϵÄbom + /* + * if (WXMethodUtil.isRevBomReleased(materialRev)) { + * System.out.println("·¢²¼"); return; } + */ + + if (isLoopBom(node)) { + MessageBox.post("´æÔÚÑ­»·BOM½á¹¹", "¾¯¸æ", MessageBox.WARNING); + return; + } + int childCount = node.getChildCount(); + List childrenList = new ArrayList<>(); + List quantityList = new ArrayList<>(); + for (int i = 0; i < childCount; i++) { + CheckBoxTreeNode childNode = (CheckBoxTreeNode) node.getChildAt(i); + if (childNode.isSelected()) { + TransformBomBean bean1 = (TransformBomBean) childNode.getUserObject(); + childrenList.add(bean1.selectRev); + quantityList.add(bean1.line.getProperty("bl_quantity")); + // ÅжÏÊÇ·ñ·¢²¼ + if (isRevBomReleased(bean1.selectRev)) { + // ·¢²¼¾Í´î½¨Ô­À´µÄbom + System.out.println("Ô­À´´î½¨¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·"); + if (isLoopBom(childNode)) { + MessageBox.post("´æÔÚÑ­»·BOM½á¹¹", "¾¯¸æ", MessageBox.WARNING); + return; + } + } else { + createMaterialBom(childNode); + } + } + } + createBom(materialRev, childrenList, null, quantityList); + } + + private TreePath findInPath(TreePath treePath, String str) { + Object object = treePath.getLastPathComponent(); + if (object == null) { + return null; + } + + String value = object.toString(); + if (str.equals(value)) { + return treePath; + } else { + TreeModel model = tree.getModel(); + int n = model.getChildCount(object); + for (int i = 0; i < n; i++) { + Object child = model.getChild(object, i); + TreePath path = treePath.pathByAddingChild(child); + path = findInPath(path, str); + if (path != null) { + return path; + } + } + return null; + } + } + + private void findInTree(String str) { + Object root = tree.getModel().getRoot(); + TreePath treePath = new TreePath(root); + treePath = findInPath(treePath, str); + if (treePath != null) { + tree.setSelectionPath(treePath); + CheckBoxTreeNode node = (CheckBoxTreeNode) tree.getLastSelectedPathComponent(); + tree.scrollPathToVisible(treePath); + } + } + + /** + * @param line + * @param childNode + * @return ·µ»Ø¹ØÁªÎïÁÏÊý×é + */ + public String[] getBomRef(TCComponentBOMLine line, CheckBoxTreeNode childNode) { + try { + if (line == null) { + return null; + } + AIFComponentContext[] aifContext = line.getItemRevision().whereReferencedByTypeRelation( + types, new String[] { "TC_Is_Represented_By" }); + if (aifContext == null || aifContext.length == 0) { + return new String[] { "" }; + } else { + AIFComponentContext[] newContext = isNewRev(aifContext); + String[] wl = new String[newContext.length]; + TransformBomBean bean = (TransformBomBean) childNode.getUserObject(); + for (int i = 0; i < wl.length; i++) { + TCComponentItemRevision comp = (TCComponentItemRevision) newContext[i].getComponent(); + wl[i] = comp.getProperty("object_string"); + bean.map.put(wl[i], comp); + } + + return wl; + } + } catch (TCException e) { + e.printStackTrace(); + } + return new String[] { "" }; + } + + /** + * ÏÂÀ­¿òÑ¡ÔñÎïÁÏ + * + * @param childLine + * @param childNode + */ + private void setCombox(TCComponentBOMLine childLine, final CheckBoxTreeNode childNode) { + try { + System.out.println(childLine.getItemRevision().getType() + "<<<<<<<<<<"); + final String[] bomRef = getBomRef(childLine, childNode); + final DefaultComboBoxModel model = new DefaultComboBoxModel(); + model.addElement(""); + for (String str : bomRef) { + model.addElement(str); + } + + final JComboBox childbox = new JComboBox(); + + // Ä£ºýËÑË÷°´Å¥ + final JButton search = new JButton("ËÑË÷"); + checkBoxTreeNodelMap.put(childNode, childbox); + boxJButtonMap.put(childbox, search); + childbox.setModel(model); + childbox.setSelectedIndex(-1); + childbox.setEditable(true); + + if (childbox.getItemCount() <= 2 && !childbox.getItemAt(1).equals("")) { + childbox.setSelectedIndex(1); + childbox.setEditable(false); + childNode.setSelected(true); + search.setEnabled(false); + childbox.enable(false); + TransformBomBean bean = (TransformBomBean) childNode.getUserObject(); + bean.selectRev = bean.map.get(childbox.getSelectedItem().toString()); + } else if (childbox.getItemCount() <= 2) { + childbox.setEditable(false); + search.setEnabled(false); + childbox.enable(false); + } + if (childLine.getItemRevision().getType().equals("PartRevision")) { + childbox.setEditable(false); + search.setEnabled(false); + childNode.setSelected(true); + childbox.enable(false); + TransformBomBean bean = (TransformBomBean) childNode.getUserObject(); + bean.selectRev = childLine.getItemRevision(); + } + childbox.setPreferredSize(new Dimension(240, 23)); + search.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + if (childbox.isEditable() && search.isEnabled()) { + String str = childbox.getEditor().getItem().toString(); + model.removeAllElements(); + model.addElement(""); + for (int i = 0; i < bomRef.length; i++) { + if (bomRef[i].contains(str)) { + model.addElement(bomRef[i]); + } + } + childbox.setModel(model); + childbox.setPopupVisible(true); + } + } + }); + + childbox.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + try { + if (e.getStateChange() == 1) { + if (childbox.getSelectedIndex() > 0) { + TransformBomBean bean = (TransformBomBean) childNode.getUserObject(); + bean.selectRev = bean.map.get(childbox.getSelectedItem().toString()); + childNode.setSelected(true); + System.out.println("-----------" + bean.displayName); + // ÅжÏÊÇ·ñ²¼ ·¢²¼×ÓÀàÈ«²¿²»¿ÉÑ¡Ôñ + boolean released = isReleased(bean.selectRev, childNode); + System.out.println("<<<<<<<<<<ÊÇ·ñ·¢²¼:" + released); + tree.repaint(); + } else { + System.out.println("<<<<<<<<<<Ñ¡Ôñ¿Õ:"); + restoreSelect(childNode); + childNode.setSelected(false); + tree.repaint(); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + comboxList.add(childbox); + rightJPanel.add((index) + ".1.left.top", childbox); + rightJPanel.add((index++) + ".2.left.top", search); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ÅжÏÊÇ·ñ·¢²¼ + * + * @param rev + * @param childNode + * @return + */ + private boolean isReleased(TCComponentItemRevision rev, CheckBoxTreeNode childNode) { + + try { + System.out.println("Ö´ÐÐÅжÏ" + rev.getProperty("object_name")); + if (rev != null && isRevBomReleased(rev)) { + setUnable(childNode); + return true; + } else { + restoreSelect(childNode); + return false; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + + private void setUnable(CheckBoxTreeNode childNode) { + int childCount = childNode.getChildCount(); + for (int i = 0; i < childCount; i++) { + CheckBoxTreeNode node = (CheckBoxTreeNode) childNode.getChildAt(i); + JComboBox box = checkBoxTreeNodelMap.get(node); + box.setSelectedIndex(-1); + box.setEditable(false); + box.setEnabled(false); + node.setSelected(false); + boxJButtonMap.get(box).setEnabled(false); + setUnable(node); + } + } + + /** + * ¸´Ô­ + * + * @param childNode + * @throws TCException + */ + private void restoreSelect(CheckBoxTreeNode childNode) throws TCException { + int childCount = childNode.getChildCount(); + for (int i = 0; i < childCount; i++) { + CheckBoxTreeNode node = (CheckBoxTreeNode) childNode.getChildAt(i); + JComboBox childbox = checkBoxTreeNodelMap.get(node); + TransformBomBean bean = (TransformBomBean) node.getUserObject(); + childbox.setEditable(true); + childbox.setEnabled(true); + childbox.setSelectedIndex(-1); + if (childbox.getItemCount() <= 2 && !childbox.getItemAt(1).equals("")) { + childbox.setSelectedIndex(1); + childbox.setEditable(false); + childbox.setEnabled(false); + node.setSelected(true); + boxJButtonMap.get(childbox).setEnabled(false); + bean.selectRev = bean.map.get(childbox.getSelectedItem().toString()); + } else if (childbox.getItemCount() <= 2) { + childbox.setEditable(false); + childbox.setEnabled(false); + boxJButtonMap.get(childbox).setEnabled(false); + } + if (bean.line.getItemRevision().isTypeOf("PartRevision")) { + childbox.setEditable(false); + boxJButtonMap.get(childbox).setEnabled(false); + node.setSelected(true); + childbox.setEnabled(false); + bean.selectRev = bean.line.getItemRevision(); + } + restoreSelect(node); + } + + } + + /** + * ÅжÏÊÇ·ñΪ×îа汾 ÌÞ³ý¾É°æ±¾ + * + * @param aifContext + * @return + */ + private AIFComponentContext[] isNewRev(AIFComponentContext[] aifContext) { + try { + List list = new ArrayList<>(); + for (int i = 0; i < aifContext.length; i++) { + TCComponentItemRevision rev = (TCComponentItemRevision) aifContext[i].getComponent(); + if (rev.getItem().getLatestItemRevision().equals(rev)) { + list.add(aifContext[i]); + } + } + AIFComponentContext[] newContext = new AIFComponentContext[list.size()]; + for (int i = 0; i < list.size(); i++) { + newContext[i] = list.get(i); + } + return newContext; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * ÅжÏÑ­»· + * @param node + * @return + */ + private boolean isLoopBom(CheckBoxTreeNode node) { + try { + HashSet loopSet = new HashSet<>(); + boolean checkLoop = checkLoop(node, loopSet); + return checkLoop; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + + /** + * ÏòÉÏÕÒ¸¸Àà,ÅжÏÊÇ·ñÓÐÏàͬµÄÎïÁÏ + * @param node + * @param loopSet + * @return + * @throws TCException + */ + private boolean checkLoop(CheckBoxTreeNode node, HashSet loopSet) throws TCException { + TransformBomBean bean = (TransformBomBean) node.getUserObject(); + TCComponentItemRevision materialRev = bean.selectRev; + boolean add = loopSet.add(materialRev); + if (!add) { + return true; + } else { + CheckBoxTreeNode parent = (CheckBoxTreeNode) node.getParent(); + if (parent == null) { + return false; + } else { + return checkLoop(parent, loopSet); + } + } + } + + + + public void getAllBomItemByBomline(TCComponentBOMLine line, List itemList) + throws TCException { + if (line == null) { + return; + } + itemList.add(line.getItem()); + AIFComponentContext[] contextS = line.getChildren(); + for (AIFComponentContext context : contextS) { + TCComponentBOMLine child = (TCComponentBOMLine) context.getComponent(); + getAllBomItemByBomline(child, itemList); + } + } + + + + + + /** + * ´î½¨bom + * + * @param selectIndex + * @throws TCException + */ + public void createBom(TCComponentItemRevision parentRev, List childRevList, + List queryNoList, List countNoList) throws TCException { + if (childRevList == null || childRevList.size() == 0) { + return; + } + if (parentRev == null) { + return; + } + String[] setProps = { "bl_quantity" }; + TCComponentBOMLine line = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + AIFComponentContext[] childrenContext = line.getChildren(); + + win.lock(); + // ÒÆ³öËùÓеÄ×Óbomline + if (childrenContext.length != 0) { + for (AIFComponentContext child : childrenContext) { + line.lock(); + line.remove("", (TCComponent) child.getComponent()); + line.save(); + line.unlock(); + } + // return; + } + for (int i = 0; i < childRevList.size(); i++) { + TCComponentItemRevision rev = childRevList.get(i); + line.lock(); + TCComponentBOMLine childBomLine = line.add(rev.getItem(), rev, null, false, ""); + line.save(); + line.unlock(); + + if (countNoList.get(i) != null && !countNoList.get(i).equals("")) { + childBomLine.lock(); + childBomLine.setProperties(setProps, new String[] { countNoList.get(i) }); + childBomLine.save(); + childBomLine.unlock(); + } + + + + } + win.save(); + win.unlock(); + + } + + + + /** + * ¼ì²é¶ÔÏóÊÇ·ñÒѾ­·¢²¼ + * + * @param comp + * @return + * @throws TCException + */ + public boolean isCompReleased(TCComponent comp) throws TCException { + TCComponent[] comps = comp.getRelatedComponents("release_status_list"); + if (comps != null && comps.length > 0) { + return true; + } + return false; + } + + /** + * ÊÇ·ñÓÐBOM + * + * @param rev + * @return + */ + public boolean isRevHadBom(TCComponentItemRevision rev) { + boolean isHad = false; + if (rev != null) { + try { + TCComponentBOMLine topLine = win.setWindowTopLine(rev.getItem(), rev, null, null); + if (topLine != null) { + if (topLine.getChildren().length > 0) { + isHad = true; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + return isHad; + } + + /** + * ÅжÏÒѾ­·¢²¼µÄ¶ÔÏóÊÇ·ñÓÐBOM + * + * @param rev + * @return + */ + public boolean isRevBomReleased(TCComponentItemRevision rev) { + boolean isReleased = false; + try { + if (isCompReleased(rev)) { + win.setWindowTopLine(rev.getItem(), rev, null, null); + // TCComponentBOMLine line = window.getTopBOMLine(); + // if(line.getChildren().length!=0){ + // isReleased = true; + // } + if ( isRevHadBom(rev)) { + TCComponentBOMViewRevision bvr = win.askBvr(); + if (bvr != null) { + TCComponent[] status = bvr.getReferenceListProperty("release_status_list"); + if (status != null && status.length != 0) { + isReleased = true; + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + isReleased = true; + } + return isReleased; + + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java new file mode 100644 index 0000000..31bdb3d --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/CSJHForm.java @@ -0,0 +1,467 @@ +package com.connor.jd.plm.form; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.DefaultTableModel; + +import com.connor.jd.plm.beans.ComponentBean; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; + +public class CSJHForm extends AbstractRendering { + + TCComponent form; + DefaultTableModel model; + TCSession session; + TCComponentItemRevision itemR; + private static Connection con = null; + private static PreparedStatement ps = null; + private static ResultSet rs = null; + private ObservableList componentData = FXCollections.observableArrayList(); + String[] propNames = new String[] { "jd2_syxh", "jd2_symd", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq", + "jd2_syfy", "jd2_jhrc", "jd2_sjrc", "jd2_syzt", "jd2_syjg", "jd2_sycs", "jd2_syry", "jd2_csbg", "jd2_bz" }; + + public CSJHForm(TCComponent form) throws Exception { + super(); + this.form = form; + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + System.out.println("¼ÓÔØ"); + loadRendering(); + } + + int index = 1; + + @Override + public void loadRendering() throws TCException { +// try { +// con = DBConnectionUtil.dbConn("infodba", "infodba"); +// String sqlString = "select * from JD2_Component"; +// if (con == null) { +// Alert alert = new Alert(AlertType.ERROR, "Á¬½Óʧ°Ü"); +// alert.show(); +// } else { +// ps = con.prepareStatement(sqlString); +// rs = ps.executeQuery(); +// while (rs.next()) { +// ComponentBean comBean = new ComponentBean(); +// // System.out.println("µÚÒ»ÁÐÄÚÈÝ£º" + rs.getString(1)); +// comBean.setType(rs.getString(1)); +// comBean.setProject(rs.getString(2)); +// comBean.setTime(rs.getString(3)); +// comBean.setNumber(String.valueOf(rs.getInt(4))); +// comBean.setCost(String.valueOf(rs.getDouble(5))); +// comBean.setCompId(rs.getInt(6)); +// comBean.setAddId(0); +// comBean.setStage(0);// ¸Õ´ÓÊý¾Ý¿âÈ¡³ö +// componentData.add(comBean); +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// try { +// rs.close(); +// } catch (SQLException e1) { +// e1.printStackTrace(); +// } +// } +// if (ps != null) { +// try { +// ps.close(); +// } catch (SQLException e1) { +// e1.printStackTrace(); +// } +// } +// if (con != null) { +// try { +// con.close(); +// } catch (SQLException e1) { +// e1.printStackTrace(); +// } +// } +// } + this.setPreferredSize(new Dimension(1000, 250)); + TCComponent[] tables = form.getTCProperty("jd2_csjh").getReferenceValueArray(); + AIFComponentContext[] contexts = form.whereReferenced(); + for (int i = 0; i < contexts.length; i++) { + if (contexts[i].getComponent() instanceof TCComponentItemRevision) { + try { + itemR = (TCComponentItemRevision) contexts[i].getComponent(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + String[] info = new String[] { "NO", "ʵÑéÐͺÅ", "ʵÑéÄ¿µÄ", "ίÍÐÈËÔ±", "ʵÑéÏîÄ¿", "ʵÑę́Êý", "ʵÑéÖÜÆÚ", "ÊÔÑé·ÑÓÃ", "¼Æ»®ÈÕÆÚ", "ʵ¼ÊÈÕÆÚ", + "ʵÑé״̬", "ʵÑé½á¹û", "µÚ_´ÎʵÑé", "ʵÑéÈËÔ±", "²âÊÔ±¨¸æ", "±¸×¢" }; + model = new DefaultTableModel(info, 0); + JComboBox testStage = new JComboBox(); + JComboBox testResult = new JComboBox(); + String[] stageInfo = { "´ý²â", "½øÐÐÖÐ", "Íê³É" }; + for (int i = 0; i < stageInfo.length; i++) { + testStage.addItem(stageInfo[i]); + } + testResult.addItem("²»ºÏ¸ñ"); + testResult.addItem("ºÏ¸ñ"); + for (int i = 0; i < tables.length; i++) { + String[] temp = new String[16]; + temp[0] = Integer.toString(index++); + String[] props = tables[i].getProperties(propNames); + for (int j = 0; j < props.length; j++) { + temp[j + 1] = props[j]; + } + model.addRow(temp); + } +// for (int i = 0; i < componentData.size(); i++) { +// // for (int j = 0; j < tables.length; j++) { +// String project = componentData.get(i).getProject(); +// String number = componentData.get(i).getNumber(); +// String time = componentData.get(i).getTime(); +// String cost = componentData.get(i).getCost(); +//// if (!project.equals(tables[j].getProperty("jd2_syxm")) +//// && !number.equals(tables[j].getProperty("jd2_syts")) +//// && !time.equals(tables[j].getProperty("jd2_syzq")) +//// && !cost.equals(tables[j].getProperty("jd2_syfy"))) { +// String[] temp = new String[16]; +// temp[0] = Integer.toString(index++); +// temp[4] = componentData.get(i).getProject(); +// temp[5] = componentData.get(i).getNumber(); +// temp[6] = componentData.get(i).getTime(); +// temp[7] = componentData.get(i).getCost(); +// model.addRow(temp); +//// } +//// } + // } + + final JTable table = new JTable(model) { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 4 || column == 5 || column == 6 || column == 7 || column == 15) + return false; + else + return true; + } + }; + + table.addPropertyChangeListener(e -> { + if (e.getPropertyName().equals("tableCellEditor")) { + // System.out.println("change"); + } + }); + for (int i = 0; i < 16; i++) { + table.getColumn(table.getColumnName(i)).setMinWidth(60); + } + table.getColumn(table.getColumnName(10)).setCellEditor(new DefaultCellEditor(testStage)); + table.getColumn(table.getColumnName(11)).setCellEditor(new DefaultCellEditor(testResult)); + JPanel panelLable = new JPanel(); + JLabel label = new JLabel("ÊÔÑé·ÑÓÃ×ܼƣº"); + JLabel label2 = new JLabel(); + Double allcost = 0.0; + for (int i = 0; i < model.getRowCount(); i++) { + String value = (String) model.getValueAt(i, 7); + if (value.equals("")) + value = "0"; + allcost += Double.valueOf(value); + } + label2.setText(allcost + "Ôª"); + panelLable.add(label); + panelLable.add(label2); + JPanel panel = new JPanel(); + JScrollPane pane = new JScrollPane(table); + GridBagLayout gbl = new GridBagLayout(); + JPanel bottom = new JPanel(gbl); + GridBagConstraints gbs = new GridBagConstraints(); + gbs.anchor = GridBagConstraints.SOUTHEAST; + gbs.fill = GridBagConstraints.HORIZONTAL; + gbs.insets = new Insets(10, 20, 5, 10); + gbs.weighty = 0.2; + gbs.gridheight = 1; + gbs.gridwidth = GridBagConstraints.REMAINDER; + gbs.weightx = 1; + JButton testButton = new JButton("²âÊÔ±¨¸æÉÏ´«"); + gbl.setConstraints(testButton, gbs); + JButton huizongButton = new JButton("»ã×ܽáÂÛÉÏ´«"); + gbl.setConstraints(huizongButton, gbs); + JButton againButton = new JButton("ÔÙ´ÎÊÔÑé"); + gbl.setConstraints(againButton, gbs); + bottom.add(testButton); + bottom.add(huizongButton); + bottom.add(againButton); + + setLayout(new BorderLayout()); + panel.add(pane, BorderLayout.CENTER); + add(bottom, BorderLayout.EAST); + add(panelLable, BorderLayout.SOUTH); + add(pane, BorderLayout.CENTER); + testButton.addActionListener(e -> { + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("Ñ¡ÔñÉÏ´«µÄ²âÊÔ±¨¸æ"); + FileFilter filter = new FileNameExtensionFilter("Excel¹¤×÷²¾(.xlsx)", "xlsx");// ÉèÖÃÎļþ¹ýÂËÆ÷£¬Ö»ÁгöJPG»òGIF¸ñʽµÄͼƬ + chooser.setFileFilter(filter); + chooser.showOpenDialog(null); + File file = chooser.getSelectedFile(); + if (file != null) { + String filePath = file.getPath(); + String fileName = file.getName(); + String[] filename = fileName.split("."); + System.out.println(filePath); + System.out.println(fileName); + int row = table.getSelectedRow(); + String value = (String) model.getValueAt(row, 13); + if (value.equals("")) { + try { + TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("JD2_GTCSBG"); + String itemId = itemtype.getNewID(); + String itemRev = itemtype.getNewRev(null); + TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, "ÃèÊö", null); + itemR.add("JD2_CSBG", item); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + String msType = ""; + if (filePath.endsWith(".xls")) { + msType = "MSExcel"; + } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { + msType = "MSExcelX"; + } + TCComponentDataset datasetMSExcelX = datasetType.create(filename[0], "", msType); + datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// Á½²Î£ºÎļþ·¾¶£¬ÃüÃûÓ¦Óã¨text£© + item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); + model.setValueAt(item.getProperty("current_id"), row, 13); + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + // Ìí¼Óµ½Êý¾Ý¼¯ + try { + TCComponent[] tcc = itemR.getTCProperty("JD2_CSBG").getReferenceValueArray(); + for (int i = 0; i < tcc.length; i++) { + if (value.equals(tcc[i].getProperty("current_id"))) { + TCComponentItem item = (TCComponentItem) tcc[i]; + TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification") + .getReferenceValueArray(); + TCComponentDataset dataset = (TCComponentDataset) tccitem[0]; + dataset.setFiles(new String[] { file.getPath() }, new String[] { "excel" }); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + } + + }); + huizongButton.addActionListener(e -> { + int row = table.getSelectedRow(); + String value = (String) model.getValueAt(row, 13); + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle("Ñ¡ÔñÉÏ´«µÄ»ã×ܽáÂÛ"); + FileFilter filter = new FileNameExtensionFilter("Excel¹¤×÷²¾(.xlsx)", "xlsx");// ÉèÖÃÎļþ¹ýÂËÆ÷£¬Ö»ÁгöJPG»òGIF¸ñʽµÄͼƬ + chooser.setFileFilter(filter); + chooser.showOpenDialog(null); + File file = chooser.getSelectedFile(); + if (file != null) { + String filePath = file.getPath(); + String fileName = file.getName(); + String[] filename = fileName.split("."); + System.out.println(filePath); + System.out.println(fileName); + if (value.equals("")) { + try { + TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("JD2_GTCSBG"); + String itemId = itemtype.getNewID(); + String itemRev = itemtype.getNewRev(null); + TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, "ÃèÊö", null); + itemR.add("JD2_CSBGHZ", item); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + String msType = ""; + if (filePath.endsWith(".xls")) { + msType = "MSExcel"; + } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) { + msType = "MSExcelX"; + } + TCComponentDataset datasetMSExcelX = datasetType.create(filename[0], "", msType); + datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// Á½²Î£ºÎļþ·¾¶£¬ÃüÃûÓ¦Óã¨text£© + item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX); + model.setValueAt(item.getProperty("current_id"), row, 13); + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + // Ìí¼Óµ½Êý¾Ý¼¯ + try { + TCComponent[] tcc = itemR.getTCProperty("JD2_CSBGHZ").getReferenceValueArray(); + for (int i = 0; i < tcc.length; i++) { + if (value.equals(tcc[i].getProperty("current_id"))) { + TCComponentItem item = (TCComponentItem) tcc[i]; + TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification") + .getReferenceValueArray(); + TCComponentDataset dataset = (TCComponentDataset) tccitem[0]; + dataset.setFiles(new String[] { file.getPath() }, new String[] { "excel" }); + + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + + } + } + }); + + againButton.addActionListener(e -> { + String[] temp = new String[16]; + int num = Integer.valueOf((String) model.getValueAt(table.getSelectedRow(), 0)) + 1; + // temp[0] = String.valueOf(num); + temp[1] = (String) model.getValueAt(table.getSelectedRow(), 1); + temp[2] = (String) model.getValueAt(table.getSelectedRow(), 2); + temp[3] = (String) model.getValueAt(table.getSelectedRow(), 3); + temp[4] = (String) model.getValueAt(table.getSelectedRow(), 4); + temp[5] = (String) model.getValueAt(table.getSelectedRow(), 5); + temp[6] = (String) model.getValueAt(table.getSelectedRow(), 6); + temp[7] = (String) model.getValueAt(table.getSelectedRow(), 7); + String chishu = (String) model.getValueAt(table.getSelectedRow(), 12); + if ("".equals(chishu)) { + chishu = "0"; + System.out.println(chishu); + } + if (chishu == null) { + chishu = "0"; + } + temp[12] = String.valueOf(Integer.valueOf(chishu) + 1); + temp[14] = (String) model.getValueAt(table.getSelectedRow(), 14); + temp[15] = (String) model.getValueAt(table.getSelectedRow(), 15); + model.insertRow(table.getSelectedRow() + 1, temp); + for (int i = table.getSelectedRow() + 1; i < model.getRowCount(); i++) { + + model.setValueAt(String.valueOf(num++), i, 0); + } + Double allcost2 = 0.0; + for (int i = 0; i < model.getRowCount(); i++) { + String value = (String) model.getValueAt(i, 7); + if (value.equals("")) + value = "0"; + allcost2 += Double.valueOf(value); + } + label2.setText(allcost2 + "Ôª"); + }); + + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (table.getSelectedColumn() == 15) { + if (e.getClickCount() == 2) { + System.out.println("Ë«»÷ÁË"); + int selectedRow = table.getSelectedRow(); // »ñµÃÑ¡ÖÐÐÐË÷Òý + String value = (String) model.getValueAt(selectedRow, 15); + if (value == null) + value = ""; + if (!value.equals("")) { + try { + TCComponent[] result = session.search("Áã×é¼þ ID", new String[] { "Áã×é¼þ ID" }, + new String[] { value }); + TCComponentItem item = (TCComponentItem) result[0]; + TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification") + .getReferenceValueArray(); + TCComponentDataset dataset = (TCComponentDataset) tccitem[0]; + dataset.open(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + } + + } + }); + + } + + @Override + public void saveRendering() { + try { + List c = new ArrayList(); + +// TCComponent[] com = form.getTCProperty("sf6_EplanBOMLineTable").getReferenceValueArray(); +// for (int j = 0; j < com.length; j++) { +// c.add(com[j]); +// } + DataManagementService service = DataManagementService + .getService((TCSession) AIFUtility.getCurrentApplication().getSession()); + CreateIn[] newIn = new CreateIn[model.getRowCount()]; + for (int i = 0; i < model.getRowCount(); i++) { + CreateIn in = new CreateIn(); + Map propMap = new HashMap(); + for (int j = 0; j < propNames.length; j++) { + propMap.put(propNames[j], + model.getValueAt(i, j + 1) == null ? "" : model.getValueAt(i, j + 1).toString()); + } + // System.out.println("prop:" + propMap); + in.data.boName = "JD2_CSJHTABLE"; + in.data.stringProps = propMap; + newIn[i] = in; + } + try { + CreateResponse response = service.createObjects(newIn); + System.out.println(response.serviceData.sizeOfCreatedObjects()); + if (response.serviceData.sizeOfCreatedObjects() > 0) { + // System.out.println("´´½¨CreateResponse"); + int length = response.serviceData.sizeOfCreatedObjects(); + for (int i = 0; i < length; i++) { + c.add(response.output[i].objects[0]); + } + + } + } catch (Exception e) { + e.printStackTrace(); + } + + form.getTCProperty("jd2_csjh").setReferenceValueArray(c.toArray(new TCComponent[c.size()])); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/handlers/TransformDesignToPartHandler.java b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/TransformDesignToPartHandler.java new file mode 100644 index 0000000..85adc37 --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/handlers/TransformDesignToPartHandler.java @@ -0,0 +1,148 @@ +package com.connor.jd.plm.handlers; + +import java.awt.BorderLayout; +import java.awt.Label; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.jd.plm.dialogs.TransformDesignToPartDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +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.util.ButtonLayout; + +public class TransformDesignToPartHandler extends AbstractHandler { + private StringBuffer errorMsgSb; + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + try { + errorMsgSb=new StringBuffer(); + System.out.println("111"); + final AbstractAIFApplication app= AIFUtility.getCurrentApplication(); + TCSession session=(TCSession) app.getSession(); + final String[] types=session.getPreferenceService().getStringValues("connor_wl_type"); + TCComponentItemRevision rev = (TCComponentItemRevision) app.getTargetComponent(); + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType bomwindow = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow window = bomwindow.create(null); + final TCComponentBOMLine topBomline = window.setWindowTopLine(rev.getItem(), rev, null, null); + checkBomRef(topBomline,types); + checkBomLine(topBomline,types); + System.out.println("step:-2------------------"); + if (!errorMsgSb.toString().equals("")) { + final JFrame sFrame = new JFrame("È·È϶Ի°¿ò"); + sFrame.setSize(350, 200); + JLabel title = new JLabel(" ¾¯ ¸æ "); + JTextArea area = new JTextArea(4, 30); + area.setText("" + errorMsgSb.append("ÎÞ¹ØÁªÎïÁÏ£¬Èô²»Ðè¹ØÁªÔòµãÈ·¶¨£¬ÈôÐèÒª¹ØÁªÔòµãÍ˳ö!")); + area.setWrapStyleWord(true); + area.setLineWrap(true); + area.setEditable(false); + JButton okButton = new JButton("È·¶¨"); + okButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + try { + sFrame.dispose(); + new TransformDesignToPartDialog(app, topBomline,types); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + JButton celButton = new JButton("Í˳ö"); + celButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + sFrame.dispose(); + return; + } + }); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(area, BorderLayout.CENTER); + panel.add(title, BorderLayout.NORTH); + JPanel buttonPanel = new JPanel(new ButtonLayout()); + buttonPanel.add("1.1.left,top", okButton); + buttonPanel.add("1.2.left,top", new Label(" ")); + buttonPanel.add("1.3.left,top", celButton); + JPanel rootPanel = new JPanel(new BorderLayout()); + rootPanel.add(buttonPanel, BorderLayout.SOUTH); + rootPanel.add(panel, BorderLayout.CENTER); + sFrame.setLayout(new BorderLayout()); + sFrame.add(rootPanel); + sFrame.setLocationRelativeTo(null); + sFrame.setVisible(true); + sFrame.setResizable(false); + } else { + new Thread(new TransformDesignToPartDialog(app, topBomline,types)).start();; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * ¼ì²ébomºÍÆä×Óbom + * @param line + * @throws TCException + */ + public void checkBomLine(TCComponentBOMLine line,String[] types) throws TCException { + if (line == null) { + return; + } + AIFComponentContext[] children = line.getChildren(); + for (int i = 0; i < children.length; i++) { + TCComponentBOMLine childLine = (TCComponentBOMLine) children[i].getComponent(); + checkBomRef(childLine,types); + checkBomLine(childLine,types); + } + + } + + // ¼ì²éÓÐûÓйØÁªÎïÁÏ + public void checkBomRef(TCComponentBOMLine line,String[] types) { + try { + if (line == null) { + return; + } + if (line.getItemRevision().isTypeOf("PartRevision")) { + //#ÎïÁÏ ²»²Ù×÷ + } else { + System.out.println("check"); + AIFComponentContext[] aifContext = line.getItemRevision().whereReferencedByTypeRelation( + types, new String[] { "TC_Is_Represented_By" }); + if (aifContext == null || aifContext.length == 0) { + this.errorMsgSb.append(line.getProperty("object_string") + ","); + } + } + } catch ( + + TCException e) { + e.printStackTrace(); + } + } + +} diff --git a/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties index a159986..f3fe444 100644 --- a/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties +++ b/com.connor.jd.plm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -1,2 +1,4 @@ JD2_GTYPQRDRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.SampleConfirmationForm -JD2_GTSYWTSRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.ExperimentalPowerOfAttorneyForm \ No newline at end of file +JD2_GTSYWTSRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.ExperimentalPowerOfAttorneyForm +SF6_ElecElementRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.CSJHForm +JD2_GTCSJHRevisionMaster.FORMJAVARENDERING=com.connor.jd.plm.form.CSJHForm