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.

1278 lines
46 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.langtech.plm.mpart;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentProcessType;
import com.teamcenter.rac.kernel.TCComponentScheduleTask;
import com.teamcenter.rac.kernel.TCComponentTaskTemplate;
import com.teamcenter.rac.kernel.TCComponentTaskTemplateType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import k.util.KOrgDialog;
public class MpartDialog extends JFrame implements ActionListener {
private TCSession session;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
private ArrayList<TCComponentItemRevision> list;
private JTextField find = new JTextField();
private JTextField replace = new JTextField();
private JButton xrButton = new JButton("ѡ<><D1A1>");
private JButton createButton = new JButton("Mpart<72><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>");
private JButton viewlButton = new JButton("<22><EFBFBD><E9BFB4><EFBFBD><EFBFBD>M");
private JTable t_part;
private JComboBox<String> gsdwComboBox = new JComboBox<String>();
protected DefaultTableModel tm_part;
public static final String[] HEADER = new String[] { "", "<22><><EFBFBD><EFBFBD>", "ID", "<22><><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD>", "<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>", "<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>M", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ","<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" };
public static final int[] HEADERWIDTH = new int[] { 30, 40, 60, 120, 100, 60, 60, 60, 100 };
private JTable t_part2;
protected DefaultTableModel tm_part2;
public static final String[] HEADER2 = new String[] { "<22><><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD>" };
public static final int[] HEADERWIDTH2 = new int[] { 10, 100 };
private ArrayList<ArrayList<Object>> valueList = new ArrayList<ArrayList<Object>>();
private HashMap<String, TCComponentItemRevision> objectMap = new HashMap<String, TCComponentItemRevision>();
private ArrayList<TCComponentItemRevision> table2RevList = new ArrayList<TCComponentItemRevision>();
TCComponentBOMWindowType viewType;
TCComponentBOMWindow view;
TCComponentItemType type;
private String[] groupSplit;
private HashMap<String, String> fieldsMap = new HashMap<String, String>();
private HashMap<String, String> typesMap = new HashMap<String, String>();
private boolean isInitialized = false;
//static TCComponentGroup group;
//static TCComponentUser user;
public MpartDialog(TCSession session, ArrayList<TCComponentItemRevision> list) throws TCException {
// TODO Auto-generated constructor stub
this.session = session;
this.list = list;
viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
view = viewType.create(null);
initUI();
}
private void initUI() {
// TODO Auto-generated method stub
try {
String[] fields = session.getPreferenceService().getStringValues("LY6_EPartToMPartType");
for (int i = 0; i < fields.length; i++) {
String[] split = fields[i].split("=");
fieldsMap.put(split[0], split[1]);
String[] split2 = split[0].split(":");
typesMap.put(split2[0], split2[1]);
}
gsdwComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (!isInitialized) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>г<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7>أ<EFBFBD><D8A3><EFBFBD>ִ<EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return;
}
if (e.getStateChange() == ItemEvent.SELECTED) {
String selectedItem = (String) gsdwComboBox.getSelectedItem();
System.out.println("Selected Item: " + selectedItem);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int count = 0;
System.out.println("==========tm_part.getRowCount()=========="+tm_part.getRowCount());
for (int i = 0; i < tm_part.getRowCount(); i++) {
System.out.println("tm_part.getValueAt(i, 0).toString()========"+tm_part.getValueAt(i, 0).toString());
if (tm_part.getValueAt(i, 0).toString().equals("1")) {
tm_part.setValueAt(selectedItem, i, 7);
count++;
}
}
if (count == 0) {
MessageBox.post("<22>ѡ<EBB9B4><D1A1><EFBFBD>ݣ<EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
}
}
});
find.setPreferredSize(new Dimension(200, 30));
replace.setPreferredSize(new Dimension(200, 30));
this.setTitle("Mpart<72><74><EFBFBD><EFBFBD>");
this.setLayout(new BorderLayout());
JPanel topPanel = getTopPanel();
JPanel btnPanel = getBtnPanel();
this.add(topPanel, BorderLayout.NORTH);
// this.add(pane,BorderLayout.CENTER);
this.add(btnPanel, BorderLayout.SOUTH);
this.setPreferredSize(new Dimension(1400, 730));
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // <20><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD>ߴ<EFBFBD>
int screenWidth = screenSize.width; // <20><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
int screenHeight = screenSize.height; // <20><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD>߶<EFBFBD>
int x = (screenWidth - 1400) / 2; // <20><><EFBFBD><EFBFBD>Frame<6D><65><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>
int y = (screenHeight - 800) / 2; // <20><><EFBFBD><EFBFBD>Frame<6D><65><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD>
this.setLocation(x, y); // <20><><EFBFBD><EFBFBD>Frame<6D><65>λ<EFBFBD><CEBB>
// this.setLocationRelativeTo(null);
this.createActionEvent();
this.pack();
// this.validate();
this.setVisible(true);
String groupID = getGroupID();
System.out.println("groupID==========" + groupID);
String factory = "";
// gsdwComboBox.addItem("<22><>ѡ<EFBFBD><D1A1>...");
String[] userCompany = session.getPreferenceService().getStringValues("LY6_UserCompany");
for (int i = 0; i < userCompany.length; i++) {
String[] split = userCompany[i].split("=");
if (split[0].equals(groupID)) {
factory = split[1];
}
}
gsdwComboBox.addItem("");
if (factory != null && !factory.isEmpty()) {
groupSplit = factory.split(";");
for (int j = 0; j < groupSplit.length; j++) {
gsdwComboBox.addItem(groupSplit[j]);
}
}
// this.setAlwaysOnTop(true);
// <20><>ֵ
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>
for (int i = 0; i < list.size(); i++) {
ArrayList<Object> tempList = new ArrayList<Object>();
tempList.add(0);
tempList.add(i + 1);
TCComponentItemRevision tcComponentItemRevision = list.get(i);
String revId = tcComponentItemRevision.getStringProperty("item_id");
String object_name = tcComponentItemRevision.getStringProperty("object_name");
String ly6_partNum = tcComponentItemRevision.getStringProperty("ly6_partNum");
String ly6_homemadeStatus = tcComponentItemRevision.getStringProperty("ly6_homemadeStatus");
tempList.add(revId);
tempList.add(object_name);
tempList.add(ly6_partNum);
tempList.add(ly6_homemadeStatus);
if (factory != null && !factory.isEmpty()) {
ArrayList<TCComponentItemRevision> mrevList = new ArrayList<TCComponentItemRevision>();
String[] split = factory.split(";");
for (int j = 0; j < split.length; j++) {
TCComponent[] search = session.search("_SearchMFKProperties", new String[] { "ID", "<22><><EFBFBD><EFBFBD>" },
new String[] { revId, split[j] });
if (search.length > 0) {
for (int k = 0; k < search.length; k++) {
TCComponentItem item = (TCComponentItem) search[k];
mrevList.add(item.getLatestItemRevision());
}
}
}
if (mrevList.size() <= 0) {
tempList.add("");
tempList.add("");
tempList.add(null);
tempList.add(tcComponentItemRevision);
} else {
tempList.add("<22><><EFBFBD><EFBFBD>");
tempList.add("");
tempList.add(mrevList);
tempList.add(tcComponentItemRevision);
}
} else {
tempList.add("");
tempList.add("");
tempList.add(null);
tempList.add(tcComponentItemRevision);
}
System.out.println("tempList.size============" + tempList.size());
valueList.add(tempList);
}
System.out.println("valueList================" + valueList.size());
for (int j = 0; j < valueList.size(); j++) {
ArrayList<Object> arrayList = valueList.get(j);
tm_part.addRow(new Object[] { arrayList.get(0), arrayList.get(1), arrayList.get(2), arrayList.get(3),
arrayList.get(4), arrayList.get(5), arrayList.get(6), arrayList.get(7), "", "" });
}
isInitialized = true;
} catch (Exception e) {
e.printStackTrace();
return;
}
}
// <20><><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>
public void createActionEvent() {
this.createButton.addActionListener(this);
this.viewlButton.addActionListener(this);
this.xrButton.addActionListener(this);
this.gsdwComboBox.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Object source = e.getSource();
System.out.println("source==>+" + source);
if (this.createButton.equals(source)) {
// <20><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
String[] workflows = session.getPreferenceService().getStringValues("LY6_EPartToMPartWorkflow");
String workflowTemplate = "";
if (workflows != null && workflows.length > 0) {
workflowTemplate = workflows[0];
} else {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>LY6_EPartToMPartWorkflow<6F><77>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //ѭ<><D1AD>
int count = 0;
// <20><>ѭ<EFBFBD><D1AD>һ<EFBFBD><D2BB><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i = 0; i < tm_part.getRowCount(); i++) {
if (tm_part.getValueAt(i, 0).toString().equals("1")) {
if (tm_part.getValueAt(i, 7) == null || tm_part.getValueAt(i, 7).toString().isEmpty()) {
MessageBox.post("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>" + (i + 1) + "<22>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
if (tm_part.getValueAt(i, 8) == null || tm_part.getValueAt(i, 8).toString().isEmpty()) {
MessageBox.post("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>" + (i + 1) + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
count++;
}
}
if (count == 0) {
MessageBox.post("<22>ѡ<EBB9B4><D1A1><EFBFBD>ݣ<EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
for (int i = 0; i < tm_part.getRowCount(); i++) {
if (tm_part.getValueAt(i, 0).toString().equals("1")) {
try {
ArrayList<Object> arrayList = valueList.get(i);
TCComponentItemRevision rev = (TCComponentItemRevision) arrayList.get(9);
TCComponentItem eItem = rev.getItem();
String eType = eItem.getType();
System.out.println("etype=============" + eType);
type = (TCComponentItemType) session.getTypeComponent(typesMap.get(eType));
TCComponentBOMLine topLine = view.setWindowTopLine(rev.getItem(), rev, null, null);
int childrenCount = topLine.getChildrenCount();
System.out.println("childrenCount========" + childrenCount);
TCComponent[] searchLs = session.search("_SearchMFKProperties", new String[] { "ID", "<22><><EFBFBD><EFBFBD>" },
new String[] { (String) arrayList.get(2), (String) tm_part.getValueAt(i, 7) });
String ly6_sequenceNum = "0";
// ȥ<><C8A5><EFBFBD>ò<EFBFBD>ѯ<EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ
// if(searchLs != null && searchLs.length > 0) {
// TCComponentItem mItem = (TCComponentItem)searchLs[0];
// ly6_sequenceNum = mItem.getStringProperty("ly6_sequenceNum");
// System.out.println("ly6_sequenceNum==="+ly6_sequenceNum);
// System.out.println("pxuid==========="+mItem.getUid());
// }
//
for (int j = 0; j < searchLs.length; j++) {
TCComponentItem mItem = (TCComponentItem) searchLs[j];
System.out.println(mItem.getUid() + "===========mItem.uid");
String num = mItem.getStringProperty("ly6_sequenceNum");
System.out.println("num===" + num);
System.out.println("ly6_sequenceNum===" + ly6_sequenceNum);
ly6_sequenceNum = getLargerNumber(num, ly6_sequenceNum);
}
if (childrenCount == 0) {
// ֱ<>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
String newID = (String) arrayList.get(2);
String newRev = type.getNewRev(null);
TCComponentItem item = type.create(newID, newRev, typesMap.get(eType), "", "", null);
TCComponentItemRevision mRev = item.getLatestItemRevision();
item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString());
System.out.println("itemUid2============" + item.getUid());
if (ly6_sequenceNum.isEmpty() || ly6_sequenceNum.equals("0")) {
item.setProperty("ly6_sequenceNum", "01");
} else {
item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum));
System.out.println("itemUid3============" + item.getUid());
}
// ɾ<><C9BE>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TCComponent delItem1 = session.stringToComponent((String) arrayList.get(2));
if (delItem1 != null) {
System.out.println("delItem1.getUid()====" + delItem1.getUid());
delItem1.delete();
}
TCComponent delItem2 = session
.stringToComponent((String) arrayList.get(2) + (String) tm_part.getValueAt(i, 7));
if (delItem1 != null) {
System.out.println("delItem2.getUid()====" + delItem2.getUid());
delItem2.delete();
}
// <20><><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD>ֵ
String fiedsStr = fieldsMap.get(eType + ":" + typesMap.get(eType));
System.out.println("fiedsStr===================" + fiedsStr);
if (fiedsStr != null && !fiedsStr.isEmpty()) {
if (fiedsStr.contains(",")) {
String[] split = fiedsStr.split(",");
System.out.println("split.length===========" + split.length);
for (int j = 0; j < split.length; j++) {
// :<3A>ָ<EFBFBD>
String[] split2 = split[j].split(":");
System.out.println("split2.length=================" + split2.length);
if (split2.length == 2) {
// .<2E>ָ<EFBFBD>
String[] split3 = split2[0].split("\\.");
System.out.println("split3.length=================" + split3.length);
if (split3.length == 2) {
if (split3[0].equals("item")) {
String[] split4 = split2[1].split("\\.");
if (split4.length == 2) {
if (split4[0].equals("item")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], eItem.getProperty(split3[1]));
} else if (split4[0].equals("rev")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], eItem.getProperty(split3[1]));
}
}
} else if (split3[0].equals("rev")) {
String[] split4 = split2[1].split("\\.");
if (split4.length == 2) {
if (split4[0].equals("item")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], rev.getProperty(split3[1]));
} else if (split4[0].equals("rev")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
System.out.println("value==========================="+rev.getProperty(split3[1]));
mRev.setProperty(split4[1], rev.getProperty(split3[1]));
}
}
}
}
}
}
} else {
// :<3A>ָ<EFBFBD>
String[] split2 = fiedsStr.split(":");
if (split2.length == 2) {
// .<2E>ָ<EFBFBD>
String[] split3 = split2[0].split("\\.");
System.out.println("split3.length=================" + split3.length);
if (split3.length == 2) {
if (split3[0].equals("item")) {
String[] split4 = split2[1].split("\\.");
if (split4.length == 2) {
if (split4[0].equals("item")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], eItem.getProperty(split3[1]));
} else if (split4[0].equals("rev")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], eItem.getProperty(split3[1]));
}
}
} else if (split3[0].equals("rev")) {
String[] split4 = split2[1].split("\\.");
if (split4.length == 2) {
if (split4[0].equals("item")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], rev.getProperty(split3[1]));
} else if (split4[0].equals("rev")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], rev.getProperty(split3[1]));
}
}
}
}
}
}
}
//<2F><><EFBFBD><EFBFBD> ly6_homemadeStatus
mRev.setProperty("ly6_homemadeStatus", "<22><><EFBFBD><EFBFBD>");
String personId = tm_part.getValueAt(i, 8).toString();
String[] split = personId.split("_");
System.out.println("personId========"+split[1]);
mRev.setProperty("ly6_assignUser", split[1] == null || split[1].isEmpty() ? "" : split[1]);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (workflowTemplate != null || !workflowTemplate.isEmpty()) {
CreateProcess(session, mRev, workflowTemplate);
}
// <20>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
rev.add("LY6_relatedMPart", item);
TCComponent[] relatedComponents = rev.getRelatedComponents("TC_Is_Represented_By");
for (int j = 0; j < relatedComponents.length; j++) {
relatedComponents[j].add("representation_for",mRev);
}
item.getLatestItemRevision().refresh();
} else {
AIFComponentContext[] children = topLine.getChildren();
ArrayList<TCComponentItemRevision> addList = new ArrayList<TCComponentItemRevision>();// mbom<6F><6D><EFBFBD><EFBFBD>
ArrayList<String> childrenList = new ArrayList<String>();// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD>ֵ
HashMap<String, TCComponentItemRevision> revMap = new HashMap<String, TCComponentItemRevision>();// object_String
StringBuilder errMsg = new StringBuilder();
for (int j = 0; j < children.length; j++) {
TCComponentBOMLine eLine = (TCComponentBOMLine) children[j].getComponent();
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
TCComponentItemRevision eRev = eLine.getItemRevision();
String tcProperty = eRev.getTCProperty("ly6_homemadeStatus").toString();
System.out.println("ly6_homemadeStatus=======" + tcProperty);
String eId = eRev.getStringProperty("item_id");
if (tcProperty.equals("<22><><EFBFBD><EFBFBD>")) {
// <20>ж<EFBFBD>e<EFBFBD><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m<EFBFBD>Ƿ<EFBFBD>Ψһ
//<2F><>ѭ<EFBFBD><D1AD>һ<EFBFBD><D2BB><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>û<EFBFBD><C3BB> mpart
ArrayList<TCComponentItemRevision> list = new ArrayList<TCComponentItemRevision>();
for (int k = 0; k < groupSplit.length; k++) {
TCComponent[] search = session.search("_SearchMFKProperties",
new String[] { "ID", "<22><><EFBFBD><EFBFBD>" }, new String[] { eId, groupSplit[k] });
for (int l = 0; l < search.length; l++) {
TCComponentItem tempItem = (TCComponentItem) search[l];
list.add(tempItem.getLatestItemRevision());
}
}
if (list.size() == 0) {
errMsg.append(eId + "<22><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>MPart"+System.lineSeparator());
}
}
}
if(errMsg.length() > 0) {
MessageBox.post(errMsg.toString(), "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
// <20>Ͷ<EFBFBD>Ӧ<EFBFBD>
for (int j = 0; j < children.length; j++) {
TCComponentBOMLine eLine = (TCComponentBOMLine) children[j].getComponent();
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
TCComponentItemRevision eRev = eLine.getItemRevision();
String tcProperty = eRev.getTCProperty("ly6_homemadeStatus").toString();
System.out.println("ly6_homemadeStatus=======" + tcProperty);
String eId = eRev.getStringProperty("item_id");
if (tcProperty.equals("<22><><EFBFBD><EFBFBD>")) {
//ѭ<><D1AD> ѡ<><D1A1>mpart
ArrayList<TCComponentItemRevision> tempMrevList = new ArrayList<TCComponentItemRevision>();
for (int k = 0; k < groupSplit.length; k++) {
TCComponent[] search = session.search("_SearchMFKProperties",
new String[] { "ID", "<22><><EFBFBD><EFBFBD>" }, new String[] { eId, groupSplit[k] });
for (int l = 0; l < search.length; l++) {
TCComponentItem tempItem = (TCComponentItem) search[l];
tempMrevList.add(tempItem.getLatestItemRevision());
}
}
// if (tempMrevList.size() == 0) {
// MessageBox.post(eId + "<22><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>MPart<72><74>", "<22><>ʾ ", MessageBox.INFORMATION);
// return;
// } else
if (tempMrevList.size() == 1) {
// <20><>M<EFBFBD><4D>bom<6F><6D>
addList.add(tempMrevList.get(0));
} else if (tempMrevList.size() > 1) {
// <20><><EFBFBD>û<EFBFBD>ѡһ<D1A1><D2BB>M<EFBFBD><4D>bom<6F><6D>
JComboBox<String> jComboBox = new JComboBox<String>();
for (int k = 0; k < tempMrevList.size(); k++) {
String stringProperty = tempMrevList.get(k)
.getStringProperty("object_string");
revMap.put(stringProperty, tempMrevList.get(k));
jComboBox.addItem(stringProperty);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾģ̬<C4A3>Ի<EFBFBD><D4BB><EFBFBD>
DialogFrame dialog = new DialogFrame(MpartDialog.this, jComboBox, childrenList);
dialog.setVisible(true);
// <20>ȴ<EFBFBD><C8B4>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD>رպ<D8B1>ִ<EFBFBD>еIJ<D0B5><C4B2><EFBFBD>
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosed(java.awt.event.WindowEvent e) {
}
});
}
} else {
// <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӽ<EFBFBD>EPart<72><EFBFBD><EEBDA8><EFBFBD><EFBFBD>MBOM<4F><4D>
addList.add(eRev);
}
}
// ֱ<>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
String newID = (String) arrayList.get(2);
String newRev = type.getNewRev(null);
TCComponentItem item = type.create(newID, newRev, typesMap.get(eType), "", "", null);
TCComponentItemRevision mRev = item.getLatestItemRevision();
item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString());
if (ly6_sequenceNum.isEmpty() || ly6_sequenceNum.equals("0")) {
item.setProperty("ly6_sequenceNum", "01");
} else {
item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum));
}
// ɾ<><C9BE>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TCComponent delItem1 = session.stringToComponent((String) arrayList.get(2));
if (delItem1 != null) {
System.out.println("delItem1.getUid()====" + delItem1.getUid());
delItem1.delete();
}
TCComponent delItem2 = session
.stringToComponent((String) arrayList.get(2) + (String) tm_part.getValueAt(i, 7));
if (delItem1 != null) {
System.out.println("delItem2.getUid()====" + delItem2.getUid());
delItem2.delete();
}
// <20><><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD>ֵ
String fiedsStr = fieldsMap.get(eType + ":" + typesMap.get(eType));
System.out.println("fiedsStr===================" + fiedsStr);
if (fiedsStr != null && !fiedsStr.isEmpty()) {
if (fiedsStr.contains(",")) {
String[] split = fiedsStr.split(",");
System.out.println("split.length===========" + split.length);
for (int j = 0; j < split.length; j++) {
// :<3A>ָ<EFBFBD>
String[] split2 = split[j].split(":");
System.out.println("split2.length=================" + split2.length);
if (split2.length == 2) {
// .<2E>ָ<EFBFBD>
String[] split3 = split2[0].split("\\.");
System.out.println("split3.length=================" + split3.length);
if (split3.length == 2) {
if (split3[0].equals("item")) {
String[] split4 = split2[1].split("\\.");
if (split4.length == 2) {
if (split4[0].equals("item")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], eItem.getProperty(split3[1]));
} else if (split4[0].equals("rev")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], eItem.getProperty(split3[1]));
}
}
} else if (split3[0].equals("rev")) {
String[] split4 = split2[1].split("\\.");
if (split4.length == 2) {
if (split4[0].equals("item")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], rev.getProperty(split3[1]));
} else if (split4[0].equals("rev")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
System.out.println("value==========================="+rev.getProperty(split3[1]));
mRev.setProperty(split4[1], rev.getProperty(split3[1]));
}
}
}
}
}
}
} else {
// :<3A>ָ<EFBFBD>
String[] split2 = fiedsStr.split(":");
if (split2.length == 2) {
// .<2E>ָ<EFBFBD>
String[] split3 = split2[0].split("\\.");
System.out.println("split3.length=================" + split3.length);
if (split3.length == 2) {
if (split3[0].equals("item")) {
String[] split4 = split2[1].split("\\.");
if (split4.length == 2) {
if (split4[0].equals("item")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], eItem.getProperty(split3[1]));
} else if (split4[0].equals("rev")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], eItem.getProperty(split3[1]));
}
}
} else if (split3[0].equals("rev")) {
String[] split4 = split2[1].split("\\.");
if (split4.length == 2) {
if (split4[0].equals("item")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], rev.getProperty(split3[1]));
} else if (split4[0].equals("rev")) {
System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], rev.getProperty(split3[1]));
}
}
}
}
}
}
}
//<2F><><EFBFBD><EFBFBD> ly6_homemadeStatus
mRev.setProperty("ly6_homemadeStatus", "<22><><EFBFBD><EFBFBD>");
String personId = tm_part.getValueAt(i, 8).toString();
String[] split = personId.split("_");
System.out.println("personId========"+split[1]);
mRev.setProperty("ly6_assignUser", split[1] == null || split[1].isEmpty() ? "" : split[1]);
// <20>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
rev.add("LY6_relatedMPart", item);
TCComponent[] relatedComponents = rev.getRelatedComponents("TC_Is_Represented_By");
for (int j = 0; j < relatedComponents.length; j++) {
relatedComponents[j].add("representation_for",mRev);
}
item.getLatestItemRevision().refresh();
// <20>mBOM
TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = viewType.create(null);
TCComponentBOMLine mTopLine = view.setWindowTopLine(item, item.getLatestItemRevision(),
null, null);
System.out.println("childrenList.size()=======" + childrenList.size());
for (int j = 0; j < childrenList.size(); j++) {
addList.add(revMap.get(childrenList.get(j)));
}
System.out.println("addList.size()============" + addList.size());
for (int j = 0; j < addList.size(); j++) {
mTopLine.add(addList.get(j).getItem(), addList.get(j), null, false, "");
}
mTopLine.save();
view.save();
view.close();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (workflowTemplate != null || !workflowTemplate.isEmpty()) {
CreateProcess(session, mRev, workflowTemplate);
}
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
} else if (this.viewlButton.equals(source)) {
// <20>򿪶<EFBFBD><F2BFAAB6>󵽽ṹ<F3B5BDBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
System.out.println("ѡ<>е<EFBFBD><D0B5><EFBFBD>===" + t_part2.getSelectedRow());
if (t_part2.getSelectedRow() == -1) {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD>ұ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ҫ<EFBFBD>򿪵Ķ<F2BFAAB5><C4B6><EFBFBD><EFBFBD>У<EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
} else {
if (table2RevList != null && table2RevList.size() > 0) {
ArrayList<Object> arrayList = valueList.get(t_part.getSelectedRow());
Object object = arrayList.get(8);
com.teamcenter.rac.common.Activator.getDefault()
.openPerspective("com.teamcenter.rac.pse.PSEPerspective");
try {
com.teamcenter.rac.common.Activator.getDefault().openComponents(
"com.teamcenter.rac.pse.PSEPerspective",
new InterfaceAIFComponent[] { table2RevList.get(t_part2.getSelectedRow()).getItem() });
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
} else if (this.xrButton.equals(source)) {
//KOrgDialog kOrgDialog = new KOrgDialog("");
TCComponentUser user = new KOrgDialog("").getUser();
// TCComponentGroup group = kOrgDialog.getGroup();
//user = kOrgDialog.getUser();
//group = kOrgDialog.getGroup();
//System.out.println("Select User: " + user + "group===" + group);
String userName = "";
try {
userName = user.getUserName()+"_"+user.getUserId();
} catch (TCException e1) {
// TODO Auto-generated catch block
MessageBox.post("<22><>ѡ<EFBFBD><D1A1><EFBFBD>û<EFBFBD><C3BB><EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
int count = 0;
for (int i = 0; i < tm_part.getRowCount(); i++) {
if (tm_part.getValueAt(i, 0).toString().equals("1")) {
tm_part.setValueAt(userName, i, 8);
count++;
}
}
if (count == 0) {
MessageBox.post("<22>ѡ<EBB9B4><D1A1><EFBFBD>ݣ<EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
}
}
private JPanel getBtnPanel() {
JPanel topPanel = new JPanel();
topPanel.setLayout(new PropertyLayout());
topPanel.add("1.1.center", new JLabel(" "));
topPanel.add("2.1.center", xrButton);
topPanel.add("2.2.center", new JLabel(" "));
topPanel.add("2.3.center", new JLabel("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>"));
topPanel.add("2.4.center", new JLabel(" "));
topPanel.add("2.5.center", gsdwComboBox);
topPanel.add("2.6.center", new JLabel(" "));
topPanel.add("2.7.center", createButton);
topPanel.add("2.8.center", new JLabel(" "));
topPanel.add("2.9.center", viewlButton);
topPanel.add("3.1.center", new JLabel(" "));
return topPanel;
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
private JPanel getTopPanel() {
// TODO Auto-generated method stub
JPanel topPanel = new JPanel();
topPanel.setLayout(new BorderLayout());
topPanel.add(getTablePanel(), BorderLayout.WEST);
topPanel.add(getTablePanel2(), BorderLayout.CENTER);
return topPanel;
}
private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(1100, 600));
tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isCellEditable(int row, int column) {
// <20><><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2>ɱ༭
String value = (String) getValueAt(row, 5);
System.out.println("value==========" + value);
if (value.equals("<22><><EFBFBD><EFBFBD>")) {
if (column == 5) {// <20>ɱ༭<C9B1><E0BCAD><EFBFBD><EFBFBD>
return true;
} else {
return false;
}
} else {
if (column == 5) {// <20>ɱ༭<C9B1><E0BCAD><EFBFBD><EFBFBD>
return true;
} else {
return false;
}
}
}
};
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
t_part.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2 || e.getClickCount() == 1) {
// TODO Auto-generated method stub
int selectColumn = t_part.getTableHeader().columnAtPoint(e.getPoint());
int selectedRow = t_part.rowAtPoint(e.getPoint());
if (selectColumn != 0) {
t_part2.removeAll();
tm_part2.setRowCount(0);
table2RevList.clear();
ArrayList<Object> arrayList = valueList.get(selectedRow);
Object object = arrayList.get(8);
if (object != null) {
ArrayList<TCComponentItemRevision> tempList = (ArrayList<TCComponentItemRevision>) object;
for (int i = 0; i < tempList.size(); i++) {
table2RevList.add(tempList.get(i));
}
System.out.println("tempList======" + tempList.size());
for (int i = 0; i < tempList.size(); i++) {
TCComponentItemRevision tcComponentItemRevision = tempList.get(i);
try {
// String id = tcComponentItemRevision.getStringProperty("item_id");
// System.out.println("item_id======" + id);
String objectName = tcComponentItemRevision
.getStringProperty("object_string");
tm_part2.addRow(new Object[] { i + 1, objectName });
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
} else {
if (t_part.getValueAt(selectedRow, 5).equals("<22><><EFBFBD><EFBFBD>")) {
Object valueAt = t_part.getValueAt(selectedRow, selectColumn);
if (valueAt.toString().equals("1")) {
t_part.setValueAt("0", selectedRow, selectColumn);
} else {
t_part.setValueAt("1", selectedRow, selectColumn);
}
}
}
}
}
});
}
});
// t_part.addMouseListener(new MouseListener() {
//
// @Override
// public void mouseReleased(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mousePressed(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseExited(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseEntered(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseClicked(MouseEvent e) {
// // TODO Auto-generated method stub
// int selectColumn = t_part.getTableHeader().columnAtPoint(e.getPoint());
// int selectedRow = t_part.rowAtPoint(e.getPoint());
//
// if(selectColumn != 0)
// {
// t_part2.removeAll();
// tm_part2.setRowCount(0);
// table2RevList.clear();
// ArrayList<Object> arrayList = valueList.get(selectedRow);
// Object object = arrayList.get(8);
// System.out.println("11111111111111111111111111111111");
// if(object != null) {
//
// ArrayList<TCComponentItemRevision> tempList = (ArrayList<TCComponentItemRevision>)object;
// for (int i = 0; i < tempList.size(); i++) {
// table2RevList.add(tempList.get(i));
// }
// System.out.println("tempList======"+tempList.size());
// for (int i = 0; i < tempList.size(); i++) {
// TCComponentItemRevision tcComponentItemRevision = tempList.get(i);
// try {
// String id = tcComponentItemRevision.getStringProperty("item_id");
// System.out.println("item_id======"+id);
// String objectName = tcComponentItemRevision.getStringProperty("object_name");
// tm_part2.addRow(new Object[] {i+1,id+"_"+objectName});
// } catch (TCException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
// }
// }
// }else {
// Object valueAt = t_part.getValueAt(selectedRow, selectColumn);
// if(valueAt.toString().equals("1")) {
// t_part.setValueAt("0", selectedRow, selectColumn);
// }else {
// t_part.setValueAt("1", selectedRow, selectColumn);
// }
// }
// }
// });
tm_part.setDataVector(null, HEADER);
t_part.getTableHeader().setReorderingAllowed(false); // <20><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>󣨵<EFBFBD><F3A3A8B5><EFBFBD><EFBFBD>У<EFBFBD>
this.t_part.setRowHeight(30);
TableColumnModel colModel = this.t_part.getColumnModel();
int colCnt = HEADERWIDTH.length;
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
t_part.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(t_part));
t_part.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(t_part));
JComboBox<String> jComboBox1 = new JComboBox<String>();
jComboBox1.addItem("<22>⹺");
jComboBox1.addItem("<22><><EFBFBD><EFBFBD>");
t_part.getColumnModel().getColumn(5).setCellEditor(new DefaultCellEditor(jComboBox1));
// <20><>ȡ<EFBFBD><C8A1>ѡ<EFBFBD><D1A1>ֵ
// String[] ld_taskNature = session.getPreferenceService().getStringValues("ld_taskNature");// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// String[] ld_taskDifficulty = session.getPreferenceService().getStringValues("ld_taskDifficulty");// <20><><EFBFBD>׳̶<D7B3>
// String[] ld_urgency = session.getPreferenceService().getStringValues("ld_urgency");// <20><><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD>
//
// Map<String, Double> ld_taskNatureMap = new HashMap<String, Double>();
// Map<String, Double> ld_taskDifficultyMap = new HashMap<String, Double>();
// Map<String, Double> ld_urgencyMap = new HashMap<String, Double>();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
// for (int i = 0; i < ld_taskNature.length; i++) {
// String[] split = ld_taskNature[i].split("=");
// ld_taskNatureMap.put(split[0], Double.parseDouble(split[1]));
// jComboBox1.addItem(split[0]);
// }
//
// for (int i = 0; i < ld_taskDifficulty.length; i++) {
// String[] split = ld_taskDifficulty[i].split("=");
// ld_taskDifficultyMap.put(split[0], Double.parseDouble(split[1]));
// jComboBox2.addItem(split[0]);
// }
//
// for (int i = 0; i < ld_urgency.length; i++) {
// String[] split = ld_urgency[i].split("=");
// ld_urgencyMap.put(split[0], Double.parseDouble(split[1]));
// jComboBox3.addItem(split[0]);
// }
//
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// t_part.addMouseListener(new MouseAdapter() {
// @Override
// public void mouseClicked(MouseEvent e) {
// if (e.getClickCount() == 2 && t_part.columnAtPoint(e.getPoint()) == 2) { // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵڶ<DAB5><DAB6><EFBFBD>
// int row = t_part.rowAtPoint(e.getPoint());
// int column = t_part.columnAtPoint(e.getPoint());
// if (column == 2) {
// // <20><>ȡ<EFBFBD><C8A1>˫<EFBFBD><CBAB><EFBFBD>ĵ<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// String value = (String) t_part.getModel().getValueAt(row, column);
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFB4A6>˫<EFBFBD><CBAB><EFBFBD>¼<EFBFBD>
// System.out.println("Double-clicked on cell: Row=" + row + ", Column=" + column + ", Value=" + value);
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD><D3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˫<EFBFBD><CBAB><EFBFBD>¼<EFBFBD>
//
// }
//
// }
// }
// });
// this.t_part.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel;
}
private JPanel getTablePanel2() {
JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(200, 600));
tm_part2 = new DefaultTableModel();
t_part2 = new JTable(tm_part2) {
/**
*
*/
@Override
public boolean isCellEditable(int row, int column) {
if (column == 0) {// <20>ɱ༭<C9B1><E0BCAD><EFBFBD><EFBFBD>
return true;
} else {
return false;
}
}
};
tm_part2.setDataVector(null, HEADER2);
t_part2.getTableHeader().setReorderingAllowed(false); // <20><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>󣨵<EFBFBD><F3A3A8B5><EFBFBD><EFBFBD>У<EFBFBD>
this.t_part2.setRowHeight(23);
TableColumnModel colModel = this.t_part2.getColumnModel();
int colCnt = HEADERWIDTH2.length;
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH2[i]);
}
// t_part2.getTableHeader().setDefaultRenderer(new
// CheckHeaderCellRenderer(t_part2));
// t_part2.getColumnModel().getColumn(0).setCellRenderer(new
// TableCellCheckboxRenderer(t_part2));
// t_part2.addMouseListener(new MouseListener() {
//
// @Override
// public void mouseReleased(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mousePressed(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseExited(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseEntered(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseClicked(MouseEvent e) {
// // TODO Auto-generated method stub
// int selectColumn = t_part2.getTableHeader().columnAtPoint(e.getPoint());
// int selectedRow = t_part2.rowAtPoint(e.getPoint());
//// System.out.println("selectColumn==>"+selectColumn);
// if(selectColumn != 0)
// {
// return;
// }else {
// Object valueAt = t_part2.getValueAt(selectedRow, selectColumn);
// if(valueAt.toString().equals("1")) {
// t_part2.setValueAt("0", selectedRow, selectColumn);
// }else {
// t_part2.setValueAt("1", selectedRow, selectColumn);
// }
// }
// }
// });
// <20><><EFBFBD>õ<EFBFBD>һ<EFBFBD>еĵ<D0B5>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD>ͱ༭<CDB1><E0BCAD>
//
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// t_part.addMouseListener(new MouseAdapter() {
// @Override
// public void mouseClicked(MouseEvent e) {
// if (e.getClickCount() == 2 && t_part.columnAtPoint(e.getPoint()) == 2) { // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵڶ<DAB5><DAB6><EFBFBD>
// int row = t_part.rowAtPoint(e.getPoint());
// int column = t_part.columnAtPoint(e.getPoint());
// if (column == 2) {
// // <20><>ȡ<EFBFBD><C8A1>˫<EFBFBD><CBAB><EFBFBD>ĵ<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// String value = (String) t_part.getModel().getValueAt(row, column);
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFB4A6>˫<EFBFBD><CBAB><EFBFBD>¼<EFBFBD>
// System.out.println("Double-clicked on cell: Row=" + row + ", Column=" + column + ", Value=" + value);
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD><D3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˫<EFBFBD><CBAB><EFBFBD>¼<EFBFBD>
//
// }
//
// }
// }
// });
// this.t_part2.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part2);
panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel;
}
public String getGroupID() throws TCException {
TCComponentGroup group = session.getCurrentGroup();
String name = group.getTCProperty("full_name").getStringValue();
if (name.contains(".")) {
String[] split = name.split("\\.");
name = split[split.length - 1];
System.out.println("name==============" + name);
}
return name;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>10<31><30><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ּ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
*
* @param numberStr <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽΪ "01", "02", ..., "10"
* @return <20><>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
*/
public String incrementNumber(String numberStr) {
// <20><>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD>ڸ<EFBFBD>ʽ
if (!numberStr.matches("^0[1-9]|10$")) {
throw new IllegalArgumentException("Input must be a string representing a number between 01 and 10.");
}
// <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
int number = Integer.parseInt(numberStr);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
number++;
// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
String formattedNumber = String.format("%02d", number);
return formattedNumber;
}
public static void CreateProcess(TCSession session, TCComponent target, String processName) throws TCException {
try {
TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");
TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session
.getTypeComponent("EPMTaskTemplate");
TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0);
if (taskTemplate != null) {
String name = target.getProperty("object_string");
TCComponent create = processType.create(processName + "<22><>" + name, "", taskTemplate,
new TCComponent[] { target }, new int[] { 1 });
System.out.println("uid===================" + create.getUid());
System.out.println("type==" + create.getType());
System.out.println("type==" + create.getStringProperty("object_type"));
}
} catch (TCException var7) {
var7.printStackTrace();
throw var7;
}
}
public String getLargerNumber(String num1, String num2) {
if (num1 == null || num1.isEmpty()) {
return num2;
}
// <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
int n1 = Integer.parseInt(num1);
int n2 = Integer.parseInt(num2);
// <20>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؽϴ<D8BD><CFB4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʽ
if (n1 > n2) {
return num1;
} else {
return num2;
}
}
}