|
|
|
@ -17,6 +17,7 @@ import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
import javax.mail.Folder;
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
|
|
|
|
|
|
|
|
import org.apache.log4j.LogManager;
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
@ -30,6 +31,7 @@ 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.TCComponentItemType;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentListOfValues;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCPreferenceService;
|
|
|
|
@ -51,8 +53,12 @@ import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
|
|
|
|
|
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput;
|
|
|
|
|
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut;
|
|
|
|
|
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
|
|
|
|
|
import com.teamcenter.soaictstubs.BooleanHolder;
|
|
|
|
|
import com.teamcenter.soaictstubs.ICCTItem;
|
|
|
|
|
import com.teamcenter.soaictstubs.StringHolder;
|
|
|
|
|
|
|
|
|
|
import cn.net.connor.createTempDrawings.pojo.LovProperty;
|
|
|
|
|
import cn.net.connor.createTempDrawings.utils.JTreeComboBox;
|
|
|
|
|
import cn.net.connor.createTempDrawings.utils.TCLOVUtil;
|
|
|
|
|
|
|
|
|
|
public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
@ -76,6 +82,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
private List<String> showPropsInfoList = new ArrayList<>();
|
|
|
|
|
private JButton closeButton;
|
|
|
|
|
private JButton buildButton;
|
|
|
|
|
private TCComponentItemType tccomponentitemtype;
|
|
|
|
|
// 添加日期格式化工具
|
|
|
|
|
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
/**
|
|
|
|
@ -95,6 +102,13 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
*/
|
|
|
|
|
private List<LovProperty> lovPropertyList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 专门用于存放lov子项的map集合
|
|
|
|
|
* @key:lov真实值(lov名称)
|
|
|
|
|
* @Value:存放lov的显示值-真实值集合
|
|
|
|
|
*/
|
|
|
|
|
private static Map<String, Map<String, String>> rMap = new HashMap<String, Map<String,String>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 类构造函数
|
|
|
|
@ -357,7 +371,6 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
String trueValue = getLovTrueValue(trueName,value,this.lovPropertyList);
|
|
|
|
|
itemRevisionDef.stringProps.put(trueName, trueValue);
|
|
|
|
|
}
|
|
|
|
|
// itemRevisionDef.stringProps.put(trueName, value);
|
|
|
|
|
}else if (location.equals("Form")) {
|
|
|
|
|
//此处对表单属性暂时不做赋值,先暂存到一个Map集合中
|
|
|
|
|
// itemRevisionDef.stringProps.put(trueName, value);
|
|
|
|
@ -417,19 +430,21 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
else if (obj instanceof TCComponentItemRevision) {
|
|
|
|
|
itemRev = (TCComponentItemRevision) obj;
|
|
|
|
|
String[] formPropInfos = {"sb6_ifls","是","lov"};
|
|
|
|
|
formList.add(formPropInfos);
|
|
|
|
|
if (!setFormProperty(itemRev,formList)) {
|
|
|
|
|
System.out.println("表单属性设置失败!");
|
|
|
|
|
}
|
|
|
|
|
itemRev.lock();
|
|
|
|
|
try {
|
|
|
|
|
itemRev.setStringProperty("sb6_ifls", "是");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.out.println("itemRev处理异常:");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally {
|
|
|
|
|
itemRev.save();
|
|
|
|
|
itemRev.unlock();
|
|
|
|
|
}
|
|
|
|
|
// itemRev.lock();
|
|
|
|
|
// try {
|
|
|
|
|
// itemRev.setStringProperty("sb6_ifls", "是");
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// System.out.println("itemRev处理异常:");
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }finally {
|
|
|
|
|
// itemRev.save();
|
|
|
|
|
// itemRev.unlock();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
else if (obj instanceof TCComponentForm) {
|
|
|
|
|
form = (TCComponentForm) obj;
|
|
|
|
@ -450,27 +465,47 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据属性真实名称在lov属性集合中get对应的lov集合,通过lov显示值获取lov对应的真实值
|
|
|
|
|
* @param configName 首选项中配置的属性真实名称
|
|
|
|
|
* 根据属性真实名称在lov属性集合中get对应的lov集合 - 通过lov显示值获取lov对应的真实值
|
|
|
|
|
* @param configName 属性真实名称
|
|
|
|
|
* @param lovShowName lov的显示值
|
|
|
|
|
* @param lovPropertyList2 lov属性集合
|
|
|
|
|
* @return lov的真实值
|
|
|
|
|
*/
|
|
|
|
|
private String getLovTrueValue(String configName, String lovShowName, List<LovProperty> lovPropertyList2) {
|
|
|
|
|
String trueNameString = null;
|
|
|
|
|
//通过lov属性集合遍历,获取lov真实值
|
|
|
|
|
for (LovProperty lovProperty : lovPropertyList2) {
|
|
|
|
|
String propName = lovProperty.getPropTrueName();
|
|
|
|
|
if (configName.equals(propName)) {
|
|
|
|
|
if (configName.equals(propName)) {//属性真实名称与lov属性集合匹配
|
|
|
|
|
Map<String, String> lovMap = lovProperty.getLovMap();
|
|
|
|
|
return lovMap.get(lovShowName);
|
|
|
|
|
trueNameString = lovMap.get(lovShowName);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//通过lov子项集合遍历,获取lov真实值
|
|
|
|
|
if (trueNameString == null && rMap != null && rMap.size()>0){
|
|
|
|
|
for (Map.Entry<String, Map<String, String>> entry : rMap.entrySet()){
|
|
|
|
|
Map<String, String> childLovMaps = entry.getValue();//获取lov子项《显示值-真实值》集合
|
|
|
|
|
if (childLovMaps != null && childLovMaps.size()>0){
|
|
|
|
|
for (Map.Entry<String, String> entry1 : childLovMaps.entrySet()){
|
|
|
|
|
String showValueString = entry1.getKey();
|
|
|
|
|
String realValueString = entry1.getValue();
|
|
|
|
|
if (lovShowName.equals(showValueString)) {
|
|
|
|
|
trueNameString = realValueString;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (trueNameString == null) {
|
|
|
|
|
System.out.println("未获取到lov-[" + lovShowName + "]的真实值");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return trueNameString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* 为表单对象设置属性
|
|
|
|
|
* @param component
|
|
|
|
|
* @param formList
|
|
|
|
|
* @return
|
|
|
|
@ -686,6 +721,8 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验必填属性,弹出提示窗口
|
|
|
|
|
* @return
|
|
|
|
@ -771,7 +808,10 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
this.idTextField = new JTextField(idValue);
|
|
|
|
|
}
|
|
|
|
|
this.revLabel = new JLabel("版本");
|
|
|
|
|
String[] revs = {"S01"};//版本下拉框数组
|
|
|
|
|
// String[] revs = {"S01"};//版本下拉框数组
|
|
|
|
|
//参考编码器获取新的版本
|
|
|
|
|
String newRev = tccomponentitemtype.getNewRev(null);
|
|
|
|
|
String[] revs = {newRev};
|
|
|
|
|
this.revComboBox = new JComboBox<String>(revs);
|
|
|
|
|
// this.revComboBox.setEditable(true);
|
|
|
|
|
|
|
|
|
@ -902,16 +942,21 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
System.out.println("未获取到属性["+name+"]配置的lov名称,请检查配置!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rMap.clear();
|
|
|
|
|
Map<String, String> lovMap = getLOVDisplay_value(tcSession, lovName);
|
|
|
|
|
String[] displayLovName = lovMap.keySet().toArray(new String[0]);//lov显示值
|
|
|
|
|
LovProperty lovProperty = new LovProperty();
|
|
|
|
|
LovProperty lovProperty = new LovProperty();//自定义的lov类型的属性类
|
|
|
|
|
lovProperty.setPropName(name);
|
|
|
|
|
lovProperty.setPropTrueName(trueName);
|
|
|
|
|
lovProperty.setLov(true);
|
|
|
|
|
lovProperty.setLovMap(lovMap);
|
|
|
|
|
this.lovPropertyList.add(lovProperty);
|
|
|
|
|
|
|
|
|
|
JComboBox<String> propComboBox = new JComboBox<String>(displayLovName);
|
|
|
|
|
// JComboBox<String> propComboBox = new JComboBox<String>(displayLovName);
|
|
|
|
|
DefaultMutableTreeNode root = generateLovTreeNode(lovMap,rMap);
|
|
|
|
|
JTreeComboBox propComboBox = new JTreeComboBox(root);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GridBagConstraints gbcPropCombo = new GridBagConstraints();
|
|
|
|
@ -970,6 +1015,47 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param lovMap lov第一层的<显示值-真实值>Map集合
|
|
|
|
|
* @param rMap2 第一层lov的<真实值>对应的子项lov集合
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private DefaultMutableTreeNode generateLovTreeNode(Map<String, String> lovMap, Map<String, Map<String, String>> rMap2) {
|
|
|
|
|
// 创建树的根节点
|
|
|
|
|
DefaultMutableTreeNode root = new DefaultMutableTreeNode(" ");
|
|
|
|
|
|
|
|
|
|
// 为每个顶层LOV创建子树
|
|
|
|
|
for (Map.Entry<String, String> entry : lovMap.entrySet()) {
|
|
|
|
|
DefaultMutableTreeNode subTree = createLovSubTree(entry.getKey(), entry.getValue(), rMap2);
|
|
|
|
|
root.add(subTree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return root;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 递归创建LOV子树
|
|
|
|
|
*/
|
|
|
|
|
private DefaultMutableTreeNode createLovSubTree(String displayValue, String realValue, Map<String, Map<String, String>> rMap2) {
|
|
|
|
|
// 创建当前节点
|
|
|
|
|
DefaultMutableTreeNode node = new DefaultMutableTreeNode(displayValue);
|
|
|
|
|
|
|
|
|
|
// 获取当前节点的子节点
|
|
|
|
|
Map<String, String> childLovMap = rMap2.get(realValue);
|
|
|
|
|
|
|
|
|
|
if (childLovMap != null && !childLovMap.isEmpty()) {
|
|
|
|
|
// 为每个子节点递归创建子树
|
|
|
|
|
for (Map.Entry<String, String> childEntry : childLovMap.entrySet()) {
|
|
|
|
|
DefaultMutableTreeNode childNode = createLovSubTree(childEntry.getKey(), childEntry.getValue(), rMap2);
|
|
|
|
|
node.add(childNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据选中对象(业务逻辑)获取ID输入框中的默认值
|
|
|
|
|
* @param selectComponent2 选中对象
|
|
|
|
@ -1008,27 +1094,34 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
return str.replaceAll("\\*", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获得TC LOV值的显示值-真实值集合
|
|
|
|
|
* @param seesion
|
|
|
|
|
* @param lovProp lov名称 / 真实值
|
|
|
|
|
* @return
|
|
|
|
|
* @throws TCException
|
|
|
|
|
*/
|
|
|
|
|
public static Map<String, String> getLOVDisplay_value(TCSession seesion,String lovProp) throws TCException
|
|
|
|
|
{
|
|
|
|
|
Map<String, String> Display_values = new HashMap<String, String>();
|
|
|
|
|
|
|
|
|
|
TCComponentListOfValues unitLov = TCLOVUtil.findLOVByName(seesion, lovProp);
|
|
|
|
|
if(unitLov != null)
|
|
|
|
|
{
|
|
|
|
|
ListOfValuesInfo listOfValues = unitLov.getListOfValues();
|
|
|
|
|
String[] realval = listOfValues.getStringListOfValues();
|
|
|
|
|
String[] realval = unitLov.getListOfValues().getStringListOfValues();
|
|
|
|
|
|
|
|
|
|
String value="";
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
for (int i = 0; i < realval.length; i++) {
|
|
|
|
|
String disval = listOfValues.getDisplayableValue(realval[i]);
|
|
|
|
|
String disval = unitLov.getListOfValues().getDisplayableValue(realval[i]);
|
|
|
|
|
Display_values.put(disval, realval[i]);
|
|
|
|
|
//递归:传入lov真实值作为lov名称,获取lov的显示值-真实值集合
|
|
|
|
|
Map<String, String> lovDisplay_value = getLOVDisplay_value(seesion, realval[i]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rMap.put(lovProp, Display_values);
|
|
|
|
|
return Display_values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|