parent
2a45b91196
commit
ed8d1154b2
@ -0,0 +1,36 @@
|
||||
package com.connor.jd.plm.beans;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
|
||||
public class TransformBomBean {
|
||||
public String displayName;
|
||||
public TCComponentBOMLine line;
|
||||
public TCComponentItemRevision selectRev;
|
||||
public Map<String, TCComponentItemRevision> 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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue