You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

864 lines
29 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.connor.dfl.plm.dfl003;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.border.LineBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import com.connor.dfl.plm.util.CodeBean;
import com.connor.dfl.plm.util.CopyPropsBean;
import com.connor.dfl.plm.util.DataBaseControl;
import com.connor.dfl.plm.util.GetCodeBean;
import com.connor.dfl.plm.util.MenuBean;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.ServiceData;
import com.teamcenter.rac.kernel.SoaUtil;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCComponentProject;
import com.teamcenter.rac.kernel.TCComponentQuery;
import com.teamcenter.rac.kernel.TCComponentQueryType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.rac.util.Utilities;
public class Dfl003AIFDialog extends AbstractAIFDialog {
private TCSession session;
private TCPreferenceService service;
private InterfaceAIFComponent targetComp;
private String name;
private MenuBean menuBean;
private JPanel jp1;
private JPanel jp2;
private JTextField jtext1;
private JTextField jtext2;
private JTextField jtext3;
private JTextField jtext4;
private JTextField jtext5;
private JTextField jtext6;
private JTextArea jtext8;
private JTextField jtext10;
// private List<CodeBean> codeBeanList;
private CodeBean selCodeBean;
private JButton okBut = new JButton(<><C8B7>");
private JButton celBut = new JButton(<><C8A1>");
private GetCodeBean getcode;
private String selnodename = "";
private JComboBox<String> jcomname=new JComboBox<String>();
private Map<String, String> nameMap=new HashMap<String, String>();
private Map<String, String> unitMap=new HashMap<String, String>();
private JComboBox<String> jcomproject=new JComboBox<String>();
private JComboBox<String> jcomunit=new JComboBox<String>();
private boolean islov=false;
private Map<String, String> groupMap=new HashMap<String, String>();
private Map<String, String> sourceMap=new HashMap<String, String>();
private Map<String, String> ImportanceMap=new HashMap<String, String>();
private JComboBox groupCode_combobox;
private JComboBox sourceCode_combobox;
private JComboBox Importantce_combobox;
public Dfl003AIFDialog(TCSession session, InterfaceAIFComponent targetComp,
String name) {
this.session = session;
this.service = session.getPreferenceService();
this.targetComp = targetComp;
this.name = name;
}
@Override
public void run() {
// TODO Auto-generated method stub
getcode = new GetCodeBean(session);
menuBean = getcode.getMenuBean(name);
// codeBeanList = bean.getCodeBeanList();
try {
init();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>lov
*/
private void getNameLov(String type) {
// TODO Auto-generated method stub
try {
TCComponentItemType tctype = (TCComponentItemType) session
.getTypeComponent(type);
TCPropertyDescriptor propertyDescriptor = tctype.getPropertyDescriptor("object_name");
TCComponentListOfValues lov = propertyDescriptor.getLOV();
if (lov!=null) {
islov=true;
String[] strs=lov.getListOfValues().getStringListOfValues();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵֵ
for(String s1:strs){
String a1 = lov.getListOfValues().getDisplayableValue(s1);//<2F><><EFBFBD><EFBFBD>ʵֵ<CAB5><D6B5>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>ʾֵ
jcomname.addItem(a1);
System.out.println(s1+"-----"+a1);
nameMap.put(a1, s1);//<2F><>ʾ:<3A><>ʵ
}
}else{
islov=false;
}
if (islov) {
jcomname.setBounds(60, 100, 120, 30);
jp2.add(jcomname);
}else{
jtext3.setBounds(60, 100, 120, 30);
jp2.add(jtext3);
}
String[] values = new String[]{};
String lovname=service.getStringValue("T2_unitsLOV");//"T2_unitsLOV"
System.out.println("lovname="+lovname);
TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues");
TCComponentListOfValues[] lov1 = lovType.find(lovname);
System.out.println("lov1="+lov1.length);
if(lov1.length > 0){
ListOfValuesInfo value = lov1[0].getListOfValues();
values = value.getStringListOfValues();
for (int i = 0; i < values.length; i++) {
String disval = value.getDisplayableValue(values[i]);
jcomunit.addItem(disval);
unitMap.put(disval, values[i]);
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* <20><>ҳ<EFBFBD><D2B3>
* @throws TCException
*/
private void init() throws TCException {
// TODO Auto-generated method stub
this.setTitle("<22><><EFBFBD><EFBFBD>" + name);
this.setAlwaysOnTop(true);
this.setPreferredSize(new Dimension(550, 630));
this.setLayout(new PropertyLayout());
jp1 = new JPanel(new BorderLayout());
jp2 = new JPanel(new PropertyLayout());
jp1.setPreferredSize(new Dimension(250, 450));
jp2.setPreferredSize(new Dimension(390, 570));
JTree tree = getTree(menuBean);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) e
.getPath().getLastPathComponent();
int childCount = treeNode.getChildCount();
System.out.println("<22><>ǰ<EFBFBD><C7B0>ѡ<EFBFBD>еĽڵ<C4BD>: " + treeNode + " <20>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD><EFBFBD>:"
+ childCount);
selnodename = "";
if (childCount > 0) {
jp2.setVisible(false);
} else {
jp2.setVisible(true);
setTextStr(treeNode);
}
}
});
JScrollPane scrollPane = new JScrollPane(tree);
scrollPane.setPreferredSize(new Dimension(250, 250));
;
// <20><><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
jp1.add(scrollPane, BorderLayout.CENTER);
JLabel jl1 = new JLabel("ID<49><44>");
JLabel jl2 = new JLabel("<22><EFBFBD><E6B1BE>");
JLabel jl3 = new JLabel("<22><><EFBFBD>ƣ<EFBFBD>");
JLabel jl5 = new JLabel("<22><><EFBFBD>ʣ<EFBFBD>");
JLabel jl6 = new JLabel("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
JLabel jl7 = new JLabel("<22><>λ<EFBFBD><CEBB>");
JLabel jl8 = new JLabel("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
JLabel jl9 = new JLabel("<22><>Ŀ<EFBFBD><C4BF>");
JLabel jl10 = new JLabel("<22><>Ʒ<EFBFBD><C6B7>:");
JLabel groupCode_lable = new JLabel("<22><>Ⱥ<EFBFBD><C8BA>:");
JLabel sourceCode_lable = new JLabel("<22><>Դ<EFBFBD><D4B4>:");
JLabel Important_lable = new JLabel("<22>ؼ<EFBFBD><D8BC><EFBFBD>:");
groupCode_combobox = new JComboBox();groupCode_combobox.addItem(name);
sourceCode_combobox = new JComboBox();sourceCode_combobox.addItem("<22><><EFBFBD>Ƽ<EFBFBD>");
Importantce_combobox = new JComboBox();Importantce_combobox.addItem("A");
jtext1 = new JTextField();
jtext2 = new JTextField();
jtext3 = new JTextField();
jtext4 = new JTextField();
jtext5 = new JTextField();
jtext6 = new JTextField();
jtext8 = new JTextArea();
jtext8.setLineWrap(true);
jtext8.setWrapStyleWord(true);
jtext8.setBorder(new LineBorder(new java.awt.Color(127,157,185), 1, false));
jtext10 = new JTextField();
jcomproject.addItem(" ");
TCComponentUser user = session.getUser();
try {
String user_id = user.getStringProperty("user_id");
System.out.println("user_id=============="+user_id);
String[] keys = new String[]{"ID"};
String[] values = new String[]{user_id};
List<TCComponent> compList = queryObject("<22><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>Ŀ", keys, values);
if(compList != null && compList.size() > 0) {
for (int i = 0; i < compList.size(); i++) {
TCComponent comp = compList.get(i);
if(comp instanceof TCComponentProject) {
TCComponentProject project = (TCComponentProject) comp;
try {
String id = project.getStringProperty("project_id");
jcomproject.addItem(id);
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
} catch (TCException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
jtext1.setEnabled(false);
jtext2.setEnabled(true);
jcomname.setEnabled(false);
jp2.setLayout(null);
jl1.setBounds(20, 20, 30, 30);
jtext1.setBounds(60, 20, 70, 30);
jl2.setBounds(20, 60, 40, 30);
jtext2.setBounds(60, 60, 30, 30);
jl3.setBounds(20, 100, 40, 30);
jl5.setBounds(20, 140, 40, 30);
jtext5.setBounds(60, 140, 120, 30);
jl6.setBounds(20, 180, 40, 30);
jtext6.setBounds(60, 180, 120, 30);
jl7.setBounds(20, 220, 40, 30);
jcomunit.setBounds(60, 220, 120, 30);
jl8.setBounds(20, 260, 40, 30);
jtext8.setBounds(60, 260, 200, 100);
jl9.setBounds(20, 370, 40, 30);
jcomproject.setBounds(60, 370, 120, 30);
jl10.setBounds(20, 410, 40, 30);
jtext10.setBounds(60, 410, 120, 30);
groupCode_lable.setBounds(20, 450, 40, 30);
groupCode_combobox.setBounds(60, 450, 120, 30);
sourceCode_lable.setBounds(20, 490, 40, 30);
sourceCode_combobox.setBounds(60, 490, 120, 30);
Important_lable.setBounds(20, 530, 40, 30);
Importantce_combobox.setBounds(60, 530, 120, 30);
jp2.add(groupCode_lable);jp2.add(groupCode_combobox);jp2.add(sourceCode_lable);
jp2.add(sourceCode_combobox);jp2.add(Important_lable);jp2.add(Importantce_combobox);
jp2.add(jl1);
jp2.add(jtext1);
jp2.add(jl2);
jp2.add(jtext2);
jp2.add(jl3);
//jp2.add(jtext3);
jp2.add(jl5);
jp2.add(jtext5);
jp2.add(jl6);
jp2.add(jtext6);
jp2.add(jl7);
jp2.add(jcomunit);
jp2.add(jl8);
jp2.add(jtext8);
jp2.add(jl9);
jp2.add(jcomproject);
jp2.add(jl10);
jp2.add(jtext10);
// jp2.add("1.1.left.center", new JLabel(""));
// jp2.add("2.1.center.center", jl1);
// jp2.add("2.2.left.center", jtext1);
// jp2.add("3.1.left.center", new JLabel(""));
// jp2.add("4.1.center.center", jl2);
// jp2.add("4.2.left.center", jtext2);
// jp2.add("5.1.left.center", new JLabel(""));
// jp2.add("6.1.center.center", jl3);
// jp2.add("7.1.left.center", new JLabel(""));
// jp2.add("8.1.center.center", jl4);
// jp2.add("8.2.left.center", jtext4);
// jp2.add("9.1.left.center", new JLabel(""));
// jp2.add("10.1.center.center", jl5);
// jp2.add("10.2.left.center", jtext5);
// jp2.add("11.1.left.center", new JLabel(""));
// jp2.add("12.1.center.center", jl6);
// jp2.add("12.2.left.center", jtext6);
// jp2.add("13.1.left.center", new JLabel(""));
// jp2.add("14.1.center.center", jl7);
// jp2.add("14.2.left.center", jtext7);
// jp2.add("15.1.left.center", new JLabel(""));
// jp2.add("16.1.center.center", jl8);
// jp2.add("16.2.left.center", jtext8);
// jp2.add("17.1.left.center", new JLabel(""));
// jp2.add("18.1.center.center", jl9);
// jp2.add("18.2.left.center", jcomproject);
jp2.setVisible(false);
add("1.1.center.center", jp1);
add("1.2.center.center", jp2);
add("2.1.center.center", okBut);
add("2.2.center.center", celBut);
String oldId = jtext10.getText();
//
String[] groupvalues = new String[]{};
String lovgroupname=service.getStringValue("T2_waixiejianlov");//<2F><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>Ⱥ<EFBFBD><C8BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
System.out.println("lovname="+lovgroupname);
TCComponentListOfValuesType lovType0 = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues");
TCComponentListOfValues[] lov1 = lovType0.find(lovgroupname);
System.out.println("lov1="+lov1.length);
if(lov1.length > 0){
ListOfValuesInfo value = lov1[0].getListOfValues();
groupvalues = value.getStringListOfValues();
for (int i = 0; i < groupvalues.length; i++) {
String disval = value.getDisplayableValue(groupvalues[i]);
groupCode_combobox.addItem(disval);
groupMap.put(disval, groupvalues[i]);
}
}
//
String[] sourcevalues = new String[]{};
String lovsourcename=service.getStringValue("T2_sourceCode");//"T2_unitsLOV"
System.out.println("lovname="+lovsourcename);
TCComponentListOfValuesType lovType1 = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues");
TCComponentListOfValues[] lov2 = lovType1.find(lovsourcename);
System.out.println("lov2="+lov2.length);
if(lov2.length > 0){
ListOfValuesInfo value = lov2[0].getListOfValues();
sourcevalues = value.getStringListOfValues();
for (int i = 0; i < sourcevalues.length; i++) {
String disval = value.getDisplayableValue(sourcevalues[i]);
sourceCode_combobox.addItem(disval);
sourceMap.put(disval, sourcevalues[i]);
}
}
//
//
String[] importancevalues = new String[]{};
String lovimportancename=service.getStringValue("T2_Importance");
System.out.println("lovname="+lovimportancename);
TCComponentListOfValuesType lovType2 = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues");
TCComponentListOfValues[] lov3 = lovType2.find(lovimportancename);
System.out.println("lov3="+lov3.length);
if(lov3.length > 0){
ListOfValuesInfo value = lov3[0].getListOfValues();
importancevalues = value.getStringListOfValues();
for (int i = 0; i < importancevalues.length; i++) {
String disval = value.getDisplayableValue(importancevalues[i]);
Importantce_combobox.addItem(disval);
ImportanceMap.put(disval, importancevalues[i]);
}
}
okBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.out.println(<><C8B7>");
if (jp2.isVisible()) {
String itemName="";
if (islov) {
itemName=(String) jcomname.getSelectedItem();
if (!nameMap.containsKey(itemName)) {
MessageBox.post("<22><><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>ѡ<EFBFBD><D1A1>!", "<22><>ʾ", MessageBox.INFORMATION);
}
}else{
StringBuilder sb = new StringBuilder(name);
sb.append("-");
sb.append(jtext3.getText());
itemName=sb.toString();
}
String groupCode = (String) groupCode_combobox.getSelectedItem();
String souceCode = (String) sourceCode_combobox.getSelectedItem();
System.out.println("=========group" + groupCode);
System.out.println("=========source" + souceCode);
if ( !(" ".equals(itemName)) && !( " ".equals(groupCode)) && !(" ".equals(souceCode))) {
createItem();
} else {
MessageBox.post("<22><><EFBFBD>ơ<EFBFBD><C6A1><EFBFBD>Դ<EFBFBD><EFBFBD><EBA1A2>Ⱥ<EFBFBD><EFBFBD><EBB2BB>Ϊ<EFBFBD><CEAA>!", "<22><>ʾ", MessageBox.INFORMATION);
}
if(itemName.contains("\\")) {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2>ܺ<EFBFBD><DCBA>з<EFBFBD>б<EFBFBD><D0B1>!", "<22><>ʾ", MessageBox.INFORMATION);
return;
}
} else {
MessageBox.post("<22><>ѡ<EFBFBD>񴴽<EFBFBD><F1B4B4BD><EFBFBD><EFBFBD><EFBFBD>!", "<22><>ʾ", MessageBox.INFORMATION);
}
}
});
celBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.out.println(<><C8A1>");
setVisible(false);
}
});
this.setVisible(true);
this.centerToScreen();
// this.pack();
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
*/
protected void createItem() {
// TODO Auto-generated method stub
try {
String type = selCodeBean.getType();
DataBaseControl data = new DataBaseControl(session);
TCComponentItemType tctype = (TCComponentItemType) session
.getTypeComponent(type);
try {
String newID = data.getNewCode("PLMCODE", selCodeBean);
System.out.println("newID1==============="+newID);
TCComponentItem find = tctype.find(newID);
if (find != null) {
newID = data.getMaxCode("PLMCODE", selCodeBean);
System.out.println("newID2==============="+newID);
find = tctype.find(newID);
}
if (find != null) {
MessageBox.post("<22><>ǰ<EFBFBD><C7B0>ˮID:" + newID + "<22>Ѵ<EFBFBD><D1B4>ڶ<EFBFBD><DAB6><EFBFBD>,<2C>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>!", "<22><><EFBFBD><EFBFBD>",
MessageBox.ERROR);
} else {
this.setVisible(false);
String itemName="";
if (islov) {
itemName=(String) jcomname.getSelectedItem();
itemName=nameMap.get(itemName);
}else{
itemName=jtext3.getText();
}
TCComponentItem item = tctype.create(newID,
jtext2.getText(), type, itemName, "", null);
// String oldId = jtext4.getText();
String material = jtext5.getText();
String weight = jtext6.getText();
String key = (String) jcomunit.getSelectedItem();
String oldId = jtext10.getText();
String group = groupMap.get(groupCode_combobox.getSelectedItem());
String source = sourceMap.get( sourceCode_combobox.getSelectedItem());
String impotance =ImportanceMap.get(Importantce_combobox.getSelectedItem());
//<2F><><EFBFBD>ؾ<EFBFBD>Ʒ<EFBFBD><C6B7>
String[] keys2 = new String[]{"CNwaixie"};
String[] values2 = new String[]{oldId};
List<TCComponent> compList2 = queryObject("<22><><EFBFBD>ݾ<EFBFBD>Ʒ<EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD>", keys2, values2);
System.out.println("<22><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>------"+compList2);
System.out.println("<22><>Ʒ<EFBFBD><C6B7>--------"+oldId);
if(compList2!=null) {
MessageBox.post("<22><>Ʒ<EFBFBD><C6B7>["+oldId+ "]<5D>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", "<22><><EFBFBD><EFBFBD>",MessageBox.ERROR);
return ;
}
String unit = "";
if(unitMap.containsKey(key)) {
unit = unitMap.get(key);
}
String Specifications = jtext8.getText();
TCComponentItemRevision rev = item.getLatestItemRevision();
//
if(group != null && group != "" && group != " " ) {
rev.setStringProperty("t2_groupCode", group);
}
if(source != null && source != "" && source != "") {
rev.setStringProperty("t2_sourceCode", source);
}
if(impotance != null && impotance != "" && impotance != " " ) {
rev.setStringProperty("t2_Importance", impotance);
}
if(itemName != null && itemName != "" && itemName != " " ) {
item.setStringProperty("object_desc", itemName);
rev.setStringProperty("object_desc", itemName);
}
// if(oldId != null && oldId != "" && oldId != " " ) {
// rev.setStringProperty("t2_OLDMerchandiseID", oldId);
// }
if(oldId != null && oldId != "" && oldId != " " ) {
String oldId2 = oldId.trim();
System.out.println("<22><><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD>Ʒ<EFBFBD><C6B7>-----"+oldId2);
rev.setStringProperty("t2_OldId", oldId2);
}
if(material.contains("\\")) {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2>ܺ<EFBFBD><DCBA>з<EFBFBD>б<EFBFBD><D0B1>!" ,"<22><>ʾ",
MessageBox.INFORMATION);
return ;
}
if(weight.contains("\\")) {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2>ܺ<EFBFBD><DCBA>з<EFBFBD>б<EFBFBD><D0B1>!" ,"<22><>ʾ",
MessageBox.INFORMATION);
return ;
}
if(Specifications.contains("\\")) {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2>ܺ<EFBFBD><DCBA>з<EFBFBD>б<EFBFBD><D0B1>!" ,"<22><>ʾ",
MessageBox.INFORMATION);
return ;
}
if(material != null && material != "" && material != " " ) {
rev.setStringProperty("t2_material", material);
}
if(weight != null && weight != "" && oldId != " " ) {
rev.setStringProperty("t2_MASS", weight);
}
if(unit != null && unit != "" && unit != " " ) {
rev.setStringProperty("t2_unit", unit);
}
if(Specifications != null && Specifications != "" && Specifications != " ") {
rev.setStringProperty("t2_Specifications", Specifications);
}
String classid = selCodeBean.getClassID();
if(classid != null && classid != "" && classid != " ") {
rev.setStringProperty("t2_ClassID", classid);
}
if(targetComp instanceof TCComponent) {
TCComponent comp = (TCComponent) targetComp;
String targetType = comp.getType();
System.out.println("targetType================="+targetType);
if("T2_outsourceRevision".equals(targetType)) {
String id = comp.getStringProperty("item_id");
rev.setStringProperty("t2_ReferenceOldId", id);
rev.add("T2_RelationPart", comp);
}else if("Fnd0HomeFolder".equals(targetType) ||
"Folder".equals(targetType) ||
"Newstuff Folder".equals(targetType) ){
}else
{
MessageBox.post("ѡ<>еĶ<D0B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><E6B1BE><EFBFBD>󣡣<EFBFBD><F3A3A1A3><EFBFBD>" ,"<22><>ʾ",
MessageBox.INFORMATION);
}
}
String proID = (String) jcomproject.getSelectedItem();
if(proID != null & proID !=" ") {
String[] keys = new String[]{"<22><>Ŀ ID"};
String[] values = new String[]{proID};
List<TCComponent> compList = queryObject("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĿID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ", keys, values);
if(compList != null && compList.size() > 0) {
TCComponent comp = compList.get(0);
if(comp instanceof TCComponentProject) {
TCComponentProject project = (TCComponentProject) comp;
TCComponentUser atccomponentuser[] = new TCComponentUser[1];
com.teamcenter.services.internal.rac.core.DataManagementService datamanagementservice = com.teamcenter.services.internal.rac.core.DataManagementService.getService(session);
ServiceData servicedata = datamanagementservice.setDefaultProjectForProjectMembers(project,atccomponentuser);
// if (servicedata != null && servicedata.sizeOfPartialErrors() > 0) {
// com.teamcenter.rac.kernel.TCExceptionPartial tcexceptionpartial = SoaUtil
// .checkPartialErrorsNoThrow(servicedata);
// MessageBox.post(Utilities.getCurrentFrame(),
// tcexceptionpartial);
// }
project.assignToProject(new TCComponent[] {item});
}
}
}
System.out.println("<22><>ʼͬ<CABC><CDAC>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
CopyPropsBean copyPropBean = selCodeBean.getCopyPropBean();
if (copyPropBean!=null) {
String type2 = copyPropBean.getType();
List<String> props = copyPropBean.getProps();
if (targetComp!=null&&targetComp.getType().equals(type2)) {
boolean isok=true;
TCComponentItemRevision furev=null;
if (targetComp instanceof TCComponentItemRevision) {
furev=(TCComponentItemRevision) targetComp;
}else if (targetComp instanceof TCComponentItem) {
furev=((TCComponentItem)targetComp).getLatestItemRevision();
}else{
isok=false;
System.out.println("ֻ֧<D6BB>ְ汾<D6B0>Ͷ<EFBFBD><CDB6><EFBFBD>");
}
if (props!=null&&props.size()>0&&isok) {
for (int i = 0; i < props.size(); i++) {
String[] split = props.get(i).split("=");
if (split != null && split.length == 2) {
String propstr = "";
if (split[0].startsWith("ITEM.")) {
TCComponentItem com = furev.getItem();
propstr = com.getTCProperty(split[0].substring(5)).getStringValue();
} else if (split[0].startsWith("REV.")) {
TCComponentItemRevision com = furev;
propstr = com.getTCProperty(split[0].substring(4)).getStringValue();
} else if (split[0].startsWith("FORM.")) {
TCComponentForm com = (TCComponentForm) furev.getReferenceListProperty("IMAN_master_form_rev")[0];
propstr = com.getTCProperty(split[0].substring(5)).getStringValue();
}
if (propstr != null&& !propstr.equals("")) {
if (split[1].startsWith("ITEM.")) {
TCComponentItem com = item;
com.getTCProperty(split[1].substring(5)).setStringValue(propstr);
} else if (split[1].startsWith("REV.")) {
TCComponentItemRevision com = rev;
com.getTCProperty(split[1].substring(4)).setStringValue(propstr);
} else if (split[1].startsWith("FORM.")) {
TCComponentForm com = (TCComponentForm) rev
.getReferenceListProperty("IMAN_master_form_rev")[0];
com.getTCProperty(split[1].substring(5)).setStringValue(propstr);
}
}
}
}
}
}
}else{
System.out.println(<><CEB4><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>");
}
if (targetComp == null) {
session.getUser().getNewStuffFolder().add("contents", item);
MessageBox.post("<22><><EFBFBD><EFBFBD>" + item + "<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD>NewStuff<66>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>²鿴!",
"<22>ɹ<EFBFBD>", MessageBox.INFORMATION);
} else if (targetComp instanceof TCComponentFolder) {
((TCComponentFolder) targetComp).add("contents", item);
MessageBox.post("<22><><EFBFBD><EFBFBD>" + item + "<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>²鿴!", "<22>ɹ<EFBFBD>",
MessageBox.INFORMATION);
}else {
session.getUser().getNewStuffFolder().add("contents", item);
MessageBox.post("<22><><EFBFBD><EFBFBD>" + item + "<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD>NewStuff<66>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>²鿴!",
"<22>ɹ<EFBFBD>", MessageBox.INFORMATION);
}
//if (classid != null && !classid.equals("")) {
//Dfl003Operation op=new Dfl003Operation(session, classid, rev, new Integer[] {}, new String[] {});
//session.queueOperation(op);
//} else {
//System.out.println("δ<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵ķ<CDB5><C4B7><EFBFBD>id,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
//}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
MessageBox.post("<22><><EFBFBD><EFBFBD>:" + e.getMessage(), "<22><><EFBFBD><EFBFBD>",
MessageBox.INFORMATION);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* ѡ<>еײ<D0B5><D7B2>¼<EFBFBD>
*
*/
protected void setTextStr(DefaultMutableTreeNode treeNode) {
// TODO Auto-generated method stub
selnodename = treeNode.toString();
if (islov) {
if (nameMap.containsKey(selnodename)) {
jcomname.setSelectedItem(selnodename);
}
}else{
jtext3.setText("");
}
String names = getNode(treeNode, "");
selCodeBean = getcode.getCodebean(names);
if (selCodeBean != null) {
String type = selCodeBean.getType();
String code = selCodeBean.getCode();
code = code + " [L]";
getNameLov(type);
try {
TCComponentItemType tctype = (TCComponentItemType) session
.getTypeComponent(type);
jtext1.setText(code);
jtext2.setText(tctype.getNewRev(null));
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰTreeNode<64>ĸ<EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>
*
* @param treeNode
* <20><><EFBFBD>ڵ<EFBFBD>
* @param names
* <20><><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>
* @return
*/
private String getNode(TreeNode treeNode, String names) {
// TODO Auto-generated method stub
if (!names.equals("")) {
names = "&" + names;
}
names = treeNode.toString() + names;
TreeNode parent = treeNode.getParent();
if (parent != null) {
return getNode(parent, names);
}
return names;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @param menuBean1
* @return
*/
private JTree getTree(MenuBean menuBean1) {
// TODO Auto-generated method stub
String treenodename = menuBean1.getName();
List<MenuBean> list = menuBean1.getList();
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(
treenodename);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
getRecursion(list.get(i), rootNode);
}
}
JTree tree = new JTree(rootNode);
tree.setShowsRootHandles(true);
// tree.setEditable(true);
return tree;
}
/**
* <20>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
*
* @param menuBean1
* @param rootNode
*/
private void getRecursion(MenuBean menuBean1,
DefaultMutableTreeNode rootNode) {
// TODO Auto-generated method stub
String treenodename = menuBean1.getName();
List<MenuBean> list = menuBean1.getList();
DefaultMutableTreeNode node = new DefaultMutableTreeNode(treenodename);
rootNode.add(node);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
getRecursion(list.get(i), node);
}
}
}
/**
* ͨ<><CDA8><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
* @param queryName <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
* @param keys <09><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
* @param values <09><>ѯֵ
* @return
*/
public List<TCComponent> queryObject(String queryName ,String[] keys,String[] values){
TCComponent[] components = null;
try {
TCComponentQueryType queryType= (TCComponentQueryType) session.getTypeComponent("ImanQuery");
TCComponentQuery query = (TCComponentQuery) queryType.find(queryName);
if(query == null){
MessageBox.post(<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ѯ:"+queryName,"<22><><EFBFBD><EFBFBD>",MessageBox.ERROR);
return null;
}
components = query.execute(keys, values);
} catch (TCException e) {
e.printStackTrace();
}
if(components != null && components.length > 0){
List<TCComponent> compList = Arrays.asList(components);
return compList;
}else{
return null;
}
}
}