|
|
|
@ -1,7 +1,14 @@
|
|
|
|
|
package com.connor.kwc.createTemplate;
|
|
|
|
|
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
import java.awt.Toolkit;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.swing.DefaultComboBoxModel;
|
|
|
|
|
import javax.swing.GroupLayout;
|
|
|
|
@ -22,10 +29,19 @@ import com.connor.kwc.createBom.CheckBoxTreeNode;
|
|
|
|
|
import com.connor.kwc.createBom.CheckBoxTreeNodeSelectionListener;
|
|
|
|
|
import com.connor.kwc.createBom.Util;
|
|
|
|
|
import com.teamcenter.rac.aif.AIFPortal;
|
|
|
|
|
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.TCComponentFolder;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentFolderType;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCProperty;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
|
|
|
|
@ -39,238 +55,270 @@ import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
*/
|
|
|
|
|
public class CreateTemplateDialg extends JFrame {
|
|
|
|
|
|
|
|
|
|
private TCSession session;
|
|
|
|
|
private TCComponent target;
|
|
|
|
|
private JButton jButton3;
|
|
|
|
|
private JLabel jLabel3;
|
|
|
|
|
private JPanel jPanel1;
|
|
|
|
|
private JPanel jPanel2;
|
|
|
|
|
private JPanel jPanel4;
|
|
|
|
|
private JScrollPane jScrollPane1;
|
|
|
|
|
private JTextField jTextField3;
|
|
|
|
|
private JTree jTree1;
|
|
|
|
|
private String[] sxxdate;
|
|
|
|
|
private TCSession session;
|
|
|
|
|
private TCComponent target;
|
|
|
|
|
private JButton jButton3;
|
|
|
|
|
private JLabel jLabel3;
|
|
|
|
|
private JPanel jPanel1;
|
|
|
|
|
private JPanel jPanel2;
|
|
|
|
|
private JPanel jPanel4;
|
|
|
|
|
private JScrollPane jScrollPane1;
|
|
|
|
|
private JTextField jTextField3;
|
|
|
|
|
private JTree jTree1;
|
|
|
|
|
private String[] sxxdate;
|
|
|
|
|
private String[] sxxAttrDate;
|
|
|
|
|
private Map<TCComponent,CheckBoxTreeNode> isSelectMap = new HashMap<TCComponent, CheckBoxTreeNode>();
|
|
|
|
|
private Map<String,Map<TCComponent,CheckBoxTreeNode>> isSelectByNodeMap = new HashMap<String, Map<TCComponent,CheckBoxTreeNode>>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates new form NewJFrame2
|
|
|
|
|
*/
|
|
|
|
|
public CreateTemplateDialg(TCSession session, TCComponent folder) {
|
|
|
|
|
this.session = session;
|
|
|
|
|
this.target = folder;
|
|
|
|
|
getData();
|
|
|
|
|
try {
|
|
|
|
|
initComponents();
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Creates new form NewJFrame2
|
|
|
|
|
*/
|
|
|
|
|
public CreateTemplateDialg(TCSession session, TCComponent folder) {
|
|
|
|
|
this.session = session;
|
|
|
|
|
this.target = folder;
|
|
|
|
|
getData();
|
|
|
|
|
try {
|
|
|
|
|
initComponents();
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void getData() {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
sxxdate = Util.getSXX(session, "KWC_CreateDOCtemplate");
|
|
|
|
|
private void getData() {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
sxxdate = Util.getSXX(session, "KWC_CreateDOCtemplate");
|
|
|
|
|
sxxAttrDate = Util.getSXX(session, "KWC_CreateDOC_attribute");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">
|
|
|
|
|
private void initComponents() throws TCException {
|
|
|
|
|
this.setTitle("依据模板创建");
|
|
|
|
|
jPanel1 = new JPanel();
|
|
|
|
|
jPanel2 = new JPanel();
|
|
|
|
|
jLabel3 = new JLabel();
|
|
|
|
|
jScrollPane1 = new JScrollPane();
|
|
|
|
|
jTree1 = new JTree();
|
|
|
|
|
// 初始化Jtree
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">
|
|
|
|
|
private void initComponents() throws TCException {
|
|
|
|
|
this.setTitle("依据模板创建");
|
|
|
|
|
jPanel1 = new JPanel();
|
|
|
|
|
jPanel2 = new JPanel();
|
|
|
|
|
jLabel3 = new JLabel();
|
|
|
|
|
jScrollPane1 = new JScrollPane();
|
|
|
|
|
jTree1 = new JTree();
|
|
|
|
|
// 初始化Jtree
|
|
|
|
|
initTree(jTree1);
|
|
|
|
|
jTree1.setCellRenderer(new CheckBoxTreeCellRenderer());
|
|
|
|
|
jButton3 = new JButton();
|
|
|
|
|
jTextField3 = new JTextField();
|
|
|
|
|
jTextField3.setText(target.getStringProperty("item_id"));
|
|
|
|
|
jPanel4 = new JPanel();
|
|
|
|
|
|
|
|
|
|
jTree1.setCellRenderer(new CheckBoxTreeCellRenderer());
|
|
|
|
|
jButton3 = new JButton();
|
|
|
|
|
jTextField3 = new JTextField();
|
|
|
|
|
jTextField3.setText(target.getStringProperty("item_id"));
|
|
|
|
|
jPanel4 = new JPanel();
|
|
|
|
|
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
|
|
|
|
setBackground(new java.awt.Color(240, 240, 240));
|
|
|
|
|
|
|
|
|
|
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
|
|
|
|
setBackground(new java.awt.Color(240, 240, 240));
|
|
|
|
|
jPanel1.setBackground(new java.awt.Color(240, 240, 240));
|
|
|
|
|
|
|
|
|
|
jPanel1.setBackground(new java.awt.Color(240, 240, 240));
|
|
|
|
|
jPanel2.setBackground(new java.awt.Color(240, 240, 240));
|
|
|
|
|
|
|
|
|
|
jPanel2.setBackground(new java.awt.Color(240, 240, 240));
|
|
|
|
|
jLabel3.setText("产品代号:");
|
|
|
|
|
|
|
|
|
|
jLabel3.setText("产品代号:");
|
|
|
|
|
jScrollPane1.setViewportView(jTree1);
|
|
|
|
|
|
|
|
|
|
jScrollPane1.setViewportView(jTree1);
|
|
|
|
|
jButton3.setText("确定");
|
|
|
|
|
|
|
|
|
|
jButton3.setText("确定");
|
|
|
|
|
jTextField3.setText("");
|
|
|
|
|
|
|
|
|
|
jTextField3.setText("");
|
|
|
|
|
GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
|
|
|
|
|
jPanel2.setLayout(jPanel2Layout);
|
|
|
|
|
jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel2Layout.createSequentialGroup().addGap(53, 53, 53).addComponent(jLabel3)
|
|
|
|
|
.addGap(18, 18, 18)
|
|
|
|
|
.addComponent(jTextField3, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGap(18, 18, 18).addComponent(jButton3)
|
|
|
|
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
|
|
.addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 526, Short.MAX_VALUE).addContainerGap()));
|
|
|
|
|
jPanel2Layout
|
|
|
|
|
.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel2Layout.createSequentialGroup().addGap(13, 13, 13)
|
|
|
|
|
.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jButton3)
|
|
|
|
|
.addComponent(jTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
|
|
GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addComponent(jLabel3))
|
|
|
|
|
.addGap(18, 18, 18)
|
|
|
|
|
.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 544, GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
|
|
|
|
|
|
|
GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
|
|
|
|
|
jPanel2.setLayout(jPanel2Layout);
|
|
|
|
|
jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel2Layout.createSequentialGroup().addGap(53, 53, 53).addComponent(jLabel3)
|
|
|
|
|
.addGap(18, 18, 18)
|
|
|
|
|
.addComponent(jTextField3, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGap(18, 18, 18).addComponent(jButton3)
|
|
|
|
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
|
|
.addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 526, Short.MAX_VALUE).addContainerGap()));
|
|
|
|
|
jPanel2Layout
|
|
|
|
|
.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel2Layout.createSequentialGroup().addGap(13, 13, 13)
|
|
|
|
|
.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jButton3)
|
|
|
|
|
.addComponent(jTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
|
|
GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addComponent(jLabel3))
|
|
|
|
|
.addGap(18, 18, 18)
|
|
|
|
|
.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 544, GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
|
|
jPanel4.setBackground(new java.awt.Color(255, 255, 255));
|
|
|
|
|
|
|
|
|
|
jPanel4.setBackground(new java.awt.Color(255, 255, 255));
|
|
|
|
|
GroupLayout jPanel4Layout = new GroupLayout(jPanel4);
|
|
|
|
|
jPanel4.setLayout(jPanel4Layout);
|
|
|
|
|
jPanel4Layout.setHorizontalGroup(
|
|
|
|
|
jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 538, Short.MAX_VALUE));
|
|
|
|
|
jPanel4Layout.setVerticalGroup(
|
|
|
|
|
jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
|
|
|
|
|
|
|
|
|
|
GroupLayout jPanel4Layout = new GroupLayout(jPanel4);
|
|
|
|
|
jPanel4.setLayout(jPanel4Layout);
|
|
|
|
|
jPanel4Layout.setHorizontalGroup(
|
|
|
|
|
jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 538, Short.MAX_VALUE));
|
|
|
|
|
jPanel4Layout.setVerticalGroup(
|
|
|
|
|
jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
|
|
|
|
|
GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
|
|
|
|
|
jPanel1.setLayout(jPanel1Layout);
|
|
|
|
|
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addComponent(jPanel2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
|
|
Short.MAX_VALUE)
|
|
|
|
|
.addComponent(jPanel4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
|
|
Short.MAX_VALUE))
|
|
|
|
|
.addContainerGap()));
|
|
|
|
|
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
|
|
GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGap(73, 73, 73)
|
|
|
|
|
.addComponent(jPanel4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addContainerGap()));
|
|
|
|
|
|
|
|
|
|
GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
|
|
|
|
|
jPanel1.setLayout(jPanel1Layout);
|
|
|
|
|
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addComponent(jPanel2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
|
|
Short.MAX_VALUE)
|
|
|
|
|
.addComponent(jPanel4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
|
|
Short.MAX_VALUE))
|
|
|
|
|
.addContainerGap()));
|
|
|
|
|
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
|
|
|
|
|
GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGap(73, 73, 73)
|
|
|
|
|
.addComponent(jPanel4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addContainerGap()));
|
|
|
|
|
GroupLayout layout = new GroupLayout(getContentPane());
|
|
|
|
|
getContentPane().setLayout(layout);
|
|
|
|
|
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addContainerGap()));
|
|
|
|
|
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, 619, GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
|
|
|
|
|
|
|
GroupLayout layout = new GroupLayout(getContentPane());
|
|
|
|
|
getContentPane().setLayout(layout);
|
|
|
|
|
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addContainerGap()));
|
|
|
|
|
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(layout.createSequentialGroup().addContainerGap()
|
|
|
|
|
.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, 619, GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
|
|
pack();
|
|
|
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
|
|
|
|
|
int screenWidth = screenSize.width; // 获取屏幕宽度
|
|
|
|
|
int screenHeight = screenSize.height; // 获取屏幕高度
|
|
|
|
|
int x = (screenWidth - this.getWidth()) / 2; // 计算Frame的左上角x坐标
|
|
|
|
|
int y = (screenHeight - this.getHeight()) / 2; // 计算Frame的左上角y坐标
|
|
|
|
|
this.setLocation(x, y); // 设置Frame的位置
|
|
|
|
|
this.setDefaultCloseOperation(2);
|
|
|
|
|
|
|
|
|
|
pack();
|
|
|
|
|
this.jButton3.addActionListener(new ActionListener() {
|
|
|
|
|
|
|
|
|
|
this.jButton3.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
String name = jTextField3.getText();
|
|
|
|
|
if (name.isEmpty()) {
|
|
|
|
|
MessageBox.post("产品代号不能为空!", "提示 ", MessageBox.INFORMATION);
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
Util.setByPass(true);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
String name = jTextField3.getText();
|
|
|
|
|
if (name.isEmpty()) {
|
|
|
|
|
MessageBox.post("产品代号不能为空!", "提示 ", MessageBox.INFORMATION);
|
|
|
|
|
} else {
|
|
|
|
|
TCComponentFolderType folderType;
|
|
|
|
|
try {
|
|
|
|
|
Util.setByPass(true);
|
|
|
|
|
folderType = (TCComponentFolderType) session.getTypeComponent("LD6_CusProdFolder");
|
|
|
|
|
TCComponentFolder folder = Util.createFolderBySOA(folderType.getTypeName(), name);
|
|
|
|
|
//TCComponentFolder folder = folderType.create(name, "", "LD6_CusProdFolder");
|
|
|
|
|
target.add("contents", folder);
|
|
|
|
|
CheckBoxTreeNode root = (CheckBoxTreeNode) jTree1.getModel().getRoot();
|
|
|
|
|
createFolderStruct(root,folder,(TCComponentFolderType) session.getTypeComponent("LD6_ProjMaFolder"),true);
|
|
|
|
|
Util.setByPass(false);
|
|
|
|
|
dispose();
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
CheckBoxTreeNode root = (CheckBoxTreeNode) jTree1.getModel().getRoot();
|
|
|
|
|
//根据当前文件夹下的关系匹配树节点的选中状态创建对象
|
|
|
|
|
for(AIFComponentContext comp : target.getChildren()) {
|
|
|
|
|
TCComponent component = (TCComponent)comp.getComponent();
|
|
|
|
|
if(isSelectByNodeMap.containsKey(component.getStringProperty("object_name"))) {
|
|
|
|
|
Map<TCComponent, CheckBoxTreeNode> map = isSelectByNodeMap.get(component.getStringProperty("object_name"));
|
|
|
|
|
for (Map.Entry<TCComponent, CheckBoxTreeNode> entry : map.entrySet()) {
|
|
|
|
|
if(entry.getValue().isSelected()) {
|
|
|
|
|
//另存文件,复制属性规则
|
|
|
|
|
TCComponentItem item = (TCComponentItem)entry.getKey();
|
|
|
|
|
TCComponentItem saveAsItem = item.getLatestItemRevision().saveAsItem(jTextField3.getText(), "A", item.getStringProperty("object_name"), "", true, null);
|
|
|
|
|
// 替换属性
|
|
|
|
|
for (String attrStr : sxxAttrDate) {
|
|
|
|
|
if (attrStr.startsWith(saveAsItem.getStringProperty("object_type"))) {
|
|
|
|
|
try {
|
|
|
|
|
String[] replaces = attrStr.split("=")[1].split(";");
|
|
|
|
|
for(String replace : replaces) {
|
|
|
|
|
String[] getValues = replace.split("\\.");
|
|
|
|
|
Object val = "";
|
|
|
|
|
if(getValues[0].equals("item")) {
|
|
|
|
|
val = Util.getTCPropertyValue(item, getValues[1]);
|
|
|
|
|
Util.setTCPropertyValue(saveAsItem, getValues[1], val);
|
|
|
|
|
//val = item.getProperty(getValues[1]);
|
|
|
|
|
}else if(getValues[0].equals("rev")) {
|
|
|
|
|
val = Util.getTCPropertyValue(item.getLatestItemRevision(), getValues[1]);
|
|
|
|
|
Util.setTCPropertyValue(saveAsItem.getLatestItemRevision(), getValues[1], val);
|
|
|
|
|
//val = rev.getProperty(getValues[1]);
|
|
|
|
|
}else if(getValues[0].equals("rm")) {
|
|
|
|
|
TCComponent[] oldreferenceListProperty = item.getLatestItemRevision().getReferenceListProperty("IMAN_master_form_rev");
|
|
|
|
|
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0];
|
|
|
|
|
val = Util.getTCPropertyValue(oldform, getValues[1]);
|
|
|
|
|
TCComponent[] newreferenceListProperty = saveAsItem.getLatestItemRevision().getReferenceListProperty("IMAN_master_form_rev");
|
|
|
|
|
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
|
|
|
|
|
Util.setTCPropertyValue(newform, getValues[1], val);
|
|
|
|
|
//val = form.getProperty(getValues[1]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
component.add("contents", saveAsItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建树
|
|
|
|
|
* @param tree
|
|
|
|
|
*/
|
|
|
|
|
private void initTree(JTree tree){
|
|
|
|
|
String puids = sxxdate[0].split("=")[1];
|
|
|
|
|
TCComponent component;
|
|
|
|
|
try {
|
|
|
|
|
CheckBoxTreeNode rootNode = new CheckBoxTreeNode("模板");
|
|
|
|
|
String[] puid = puids.split(";");
|
|
|
|
|
for(String uid : puid) {
|
|
|
|
|
component = session.stringToComponent(uid);
|
|
|
|
|
if(component == null || !(component instanceof TCComponentFolder)) {
|
|
|
|
|
MessageBox.post(puid + " 该puid在TC中不存在对象或者该puid对应的不是‘文件夹’对象!", "异常", MessageBox.ERROR);
|
|
|
|
|
return;
|
|
|
|
|
}else {
|
|
|
|
|
buildTree(component,rootNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Util.setByPass(false);
|
|
|
|
|
dispose();
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DefaultTreeModel model = new DefaultTreeModel(rootNode);
|
|
|
|
|
tree.addMouseListener(new CheckBoxTreeNodeSelectionListener());
|
|
|
|
|
tree.setModel(model);
|
|
|
|
|
tree.setCellRenderer(new CheckBoxTreeCellRenderer());
|
|
|
|
|
//展开所有节点并选中
|
|
|
|
|
for (int i = 0; i < tree.getRowCount(); i++) {
|
|
|
|
|
tree.expandRow(i);
|
|
|
|
|
}
|
|
|
|
|
rootNode.setSelected(true);
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 创建树
|
|
|
|
|
*
|
|
|
|
|
* @param tree
|
|
|
|
|
*/
|
|
|
|
|
private void initTree(JTree tree) {
|
|
|
|
|
String puids = sxxdate[0].split("=")[1];
|
|
|
|
|
TCComponent component;
|
|
|
|
|
try {
|
|
|
|
|
CheckBoxTreeNode rootNode = new CheckBoxTreeNode("模板");
|
|
|
|
|
String[] puid = puids.split(";");
|
|
|
|
|
for (String uid : puid) {
|
|
|
|
|
component = session.stringToComponent(uid);
|
|
|
|
|
if (component == null || !(component instanceof TCComponentFolder)) {
|
|
|
|
|
MessageBox.post(puid + " 该puid在TC中不存在对象或者该puid对应的不是‘文件夹’对象!", "异常", MessageBox.ERROR);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
buildTree(component, rootNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归创建树的子节点
|
|
|
|
|
* @param component
|
|
|
|
|
* @param rootNode
|
|
|
|
|
* @throws TCException
|
|
|
|
|
*/
|
|
|
|
|
private void buildTree(TCComponent component, CheckBoxTreeNode rootNode) throws TCException {
|
|
|
|
|
TCComponent[] relatedComponent = component.getRelatedComponents("contents");
|
|
|
|
|
if(relatedComponent != null) {
|
|
|
|
|
for (TCComponent child : relatedComponent) {
|
|
|
|
|
CheckBoxTreeNode childNode = new CheckBoxTreeNode(child.getStringProperty("object_name"));
|
|
|
|
|
rootNode.add(childNode);
|
|
|
|
|
buildTree(child,childNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DefaultTreeModel model = new DefaultTreeModel(rootNode);
|
|
|
|
|
tree.addMouseListener(new CheckBoxTreeNodeSelectionListener());
|
|
|
|
|
tree.setModel(model);
|
|
|
|
|
tree.setCellRenderer(new CheckBoxTreeCellRenderer());
|
|
|
|
|
// 展开所有节点并选中
|
|
|
|
|
for (int i = 0; i < tree.getRowCount(); i++) {
|
|
|
|
|
tree.expandRow(i);
|
|
|
|
|
}
|
|
|
|
|
rootNode.setSelected(true);
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 循环创建树的子节点
|
|
|
|
|
*
|
|
|
|
|
* @param component
|
|
|
|
|
* @param rootNode
|
|
|
|
|
* @throws TCException
|
|
|
|
|
*/
|
|
|
|
|
private void buildTree(TCComponent component, CheckBoxTreeNode rootNode) throws TCException {
|
|
|
|
|
CheckBoxTreeNode topNode = new CheckBoxTreeNode(component.getStringProperty("object_name"));
|
|
|
|
|
rootNode.add(topNode);
|
|
|
|
|
TCComponent[] relatedComponent = component.getRelatedComponents("contents");
|
|
|
|
|
if (relatedComponent != null) {
|
|
|
|
|
for (TCComponent child : relatedComponent) {
|
|
|
|
|
CheckBoxTreeNode childNode = new CheckBoxTreeNode(child.getStringProperty("object_name"));
|
|
|
|
|
isSelectMap.put(child, childNode);
|
|
|
|
|
topNode.add(childNode);
|
|
|
|
|
}
|
|
|
|
|
isSelectByNodeMap.put(component.getStringProperty("object_name"), isSelectMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归新建文件夹结构
|
|
|
|
|
* @param root 父节点
|
|
|
|
|
* @param folder 父节点生成的文件夹
|
|
|
|
|
* @param folderType
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private void createFolderStruct(CheckBoxTreeNode root, TCComponentFolder parentFolder,
|
|
|
|
|
TCComponentFolderType folderType,boolean ifTop) throws Exception {
|
|
|
|
|
if(root.isSelected()) {
|
|
|
|
|
if(ifTop) {
|
|
|
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
|
|
|
CheckBoxTreeNode child = (CheckBoxTreeNode) root.getChildAt(i);
|
|
|
|
|
createFolderStruct(child,parentFolder,folderType,false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
TCComponentFolder folder = Util.createFolderBySOA(folderType.getTypeName(), root.toString());
|
|
|
|
|
parentFolder.add("contents", folder);
|
|
|
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
|
|
|
CheckBoxTreeNode child = (CheckBoxTreeNode) root.getChildAt(i);
|
|
|
|
|
createFolderStruct(child,folder,folderType,false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|