|
|
|
@ -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;
|
|
|
|
@ -41,18 +43,21 @@ import com.teamcenter.rac.util.PropertyLayout;
|
|
|
|
|
import com.teamcenter.rac.util.UIUtilities;
|
|
|
|
|
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
|
|
|
|
|
import com.teamcenter.services.rac.core.DataManagementService;
|
|
|
|
|
//导入类
|
|
|
|
|
//import com.teamcenter.services.rac.core.DataManagementService;
|
|
|
|
|
//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.services.rac.core.LOVService;
|
|
|
|
|
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.services.rac.core._2013_05.LOV.InitialLovData;
|
|
|
|
|
import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults;
|
|
|
|
|
import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow;
|
|
|
|
|
import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData;
|
|
|
|
|
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,11 +81,13 @@ 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");
|
|
|
|
|
/**
|
|
|
|
|
* 根据选中的对象类型,获取对象类型对应的首选项配置的属性信息
|
|
|
|
|
* 例如:*名称=Item.object_name=string
|
|
|
|
|
* 注意:首选项配置的属性信息中,首行是特殊的:配置的版本号(多个时用;隔开)
|
|
|
|
|
*/
|
|
|
|
|
private List<String> preferencePropList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
@ -94,7 +101,26 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
* 存放lov属性对象
|
|
|
|
|
*/
|
|
|
|
|
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>>();
|
|
|
|
|
|
|
|
|
|
public static void printRMap() {
|
|
|
|
|
// System.out.println("begin 打印rMap集合");
|
|
|
|
|
for (Map.Entry<String, Map<String, String>> outerEntry : rMap.entrySet()) {
|
|
|
|
|
String key = outerEntry.getKey();
|
|
|
|
|
Map<String, String> innerMap = outerEntry.getValue();
|
|
|
|
|
|
|
|
|
|
// System.out.println("Key: " + key);
|
|
|
|
|
for (Map.Entry<String, String> innerEntry : innerMap.entrySet()) {
|
|
|
|
|
// System.out.println(">>> Inner Key: " + innerEntry.getKey() + ", Value: " + innerEntry.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 类构造函数
|
|
|
|
@ -122,7 +148,6 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
initUI();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -276,9 +301,9 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
for (Map.Entry<String, JComponent> entry : this.propComponentMap.entrySet()) {
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
if (key.equals("ID*")){
|
|
|
|
|
item_id = getComponentValue(entry.getValue());
|
|
|
|
|
item_id = getComponentValue(key,entry.getValue());
|
|
|
|
|
} else if (key.equals("版本")) {
|
|
|
|
|
item_revision_id = getComponentValue(entry.getValue());//item_revision_id
|
|
|
|
|
item_revision_id = getComponentValue(key,entry.getValue());//item_revision_id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -297,13 +322,14 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("已有属性条目-组件数量="+this.propComponentMap.size());
|
|
|
|
|
// System.out.println("已有属性条目-组件数量="+this.propComponentMap.size());
|
|
|
|
|
for (Map.Entry<String, JComponent> entry : this.propComponentMap.entrySet()) {
|
|
|
|
|
String key = entry.getKey();//编辑的属性条目名称
|
|
|
|
|
String value = getComponentValue(entry.getValue());//根据组件获取选中、输入的值
|
|
|
|
|
String value = getComponentValue(key,entry.getValue());//根据组件获取选中、输入的值
|
|
|
|
|
int tag = 0;
|
|
|
|
|
//遍历首选项配置,获取属性真实值和位置、类型等信息
|
|
|
|
|
for (String prop : preferencePropList){
|
|
|
|
|
for (int i = 1; i < preferencePropList.size(); i++){
|
|
|
|
|
String prop = preferencePropList.get(i);
|
|
|
|
|
String[] split = prop.split("=");
|
|
|
|
|
if (split != null && split.length > 0) {
|
|
|
|
|
String propName = split[0];
|
|
|
|
@ -342,6 +368,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
itemDef.data.dateProps.put(trueName, calendar);
|
|
|
|
|
}else if (typeString.split(":")[0].equals("lov")) {
|
|
|
|
|
String trueValue = getLovTrueValue(trueName,value,this.lovPropertyList);
|
|
|
|
|
System.out.println("属性:"+propName+",最终赋值:"+trueValue);
|
|
|
|
|
itemDef.data.stringProps.put(trueName, trueValue);
|
|
|
|
|
}
|
|
|
|
|
}else if (location.equals("Rev")) {
|
|
|
|
@ -355,9 +382,9 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
itemRevisionDef.dateProps.put(trueName, calendar);
|
|
|
|
|
}else if (typeString.split(":")[0].equals("lov")) {
|
|
|
|
|
String trueValue = getLovTrueValue(trueName,value,this.lovPropertyList);
|
|
|
|
|
System.out.println("属性:"+propName+",最终赋值:"+trueValue);
|
|
|
|
|
itemRevisionDef.stringProps.put(trueName, trueValue);
|
|
|
|
|
}
|
|
|
|
|
// itemRevisionDef.stringProps.put(trueName, value);
|
|
|
|
|
}else if (location.equals("Form")) {
|
|
|
|
|
//此处对表单属性暂时不做赋值,先暂存到一个Map集合中
|
|
|
|
|
// itemRevisionDef.stringProps.put(trueName, value);
|
|
|
|
@ -417,60 +444,80 @@ 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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (obj instanceof TCComponentForm) {
|
|
|
|
|
form = (TCComponentForm) obj;
|
|
|
|
|
/*
|
|
|
|
|
* form.lock(); try { if (formList.size()>0) { System.out.println("开始处理表单数据");
|
|
|
|
|
* for (String[] forms : formList) { if (forms.length == 3) { String tNameString
|
|
|
|
|
* = forms[0]; String tValueString = forms[1]; String tTypeString = forms[2];
|
|
|
|
|
*
|
|
|
|
|
* setTCPropertyValue(form,tNameString,tValueString); } } } } catch (Exception
|
|
|
|
|
* e) { System.out.println("表单处理异常:"); e.printStackTrace(); }finally {
|
|
|
|
|
* form.save(); form.unlock(); }
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MessageBox.post("对象【"+item_id+"】创建完成!" , "提示", MessageBox.INFORMATION);
|
|
|
|
|
}else {
|
|
|
|
|
MessageBox.post("对象【"+item_id+"】创建失败!" , "提示", MessageBox.ERROR);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据属性真实名称在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) {
|
|
|
|
|
//判断入参是否有效
|
|
|
|
|
if (configName == null || lovShowName == null || lovPropertyList2 == null){
|
|
|
|
|
System.out.println("getLovTrueValue入参无效!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
String trueNameString = null;
|
|
|
|
|
//通过lov属性集合遍历,获取lov真实值
|
|
|
|
|
//1.先根据普通(一层)lov和动态lov,分别获取lov真实值
|
|
|
|
|
for (LovProperty lovProperty : lovPropertyList2) {
|
|
|
|
|
String propName = lovProperty.getPropTrueName();
|
|
|
|
|
if (configName.equals(propName)) {
|
|
|
|
|
Map<String, String> lovMap = lovProperty.getLovMap();
|
|
|
|
|
return lovMap.get(lovShowName);
|
|
|
|
|
String lovType = lovProperty.getLovType();
|
|
|
|
|
if (configName.equals(propName)) {//属性真实名称与lov属性集合匹配
|
|
|
|
|
if (lovType.equals("LOV")){//普通单层lov取值
|
|
|
|
|
Map<String, String> lovMap = lovProperty.getLovMap();
|
|
|
|
|
trueNameString = lovMap.get(lovShowName);
|
|
|
|
|
}else if (lovType.equals("DLOV")){//动态lov取值:获取lov下拉框的显示值即可,不存在key-value结构
|
|
|
|
|
trueNameString = lovShowName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println("未获取到lov-["+lovShowName+"]的真实值");
|
|
|
|
|
return null;
|
|
|
|
|
//2.如果未获取成功,则通过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 trueNameString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* 为表单对象设置属性
|
|
|
|
|
* @param component
|
|
|
|
|
* @param formList
|
|
|
|
|
* @return
|
|
|
|
@ -494,9 +541,11 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
finalPropValue = tValueString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("设置表单属性["+tNameString+"]="+finalPropValue);
|
|
|
|
|
setTCPropertyValue(form,tNameString,finalPropValue);
|
|
|
|
|
if (finalPropValue != null) {
|
|
|
|
|
System.out.println("设置表单属性["+tNameString+"]="+finalPropValue);
|
|
|
|
|
setTCPropertyValue(form,tNameString,finalPropValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println("表单属性赋值完成!");
|
|
|
|
@ -512,7 +561,6 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
form.unlock();
|
|
|
|
|
}
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
// TODO 自动生成的 catch 块
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -534,6 +582,9 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
* @throws
|
|
|
|
|
*/
|
|
|
|
|
public static void setTCPropertyValue(TCComponent item, String propertyName, Object value) {
|
|
|
|
|
if (item == null || propertyName == null || value == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
String type2 = item.getType();
|
|
|
|
|
TCProperty tcProperty = item.getTCProperty(propertyName);
|
|
|
|
@ -576,7 +627,6 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -639,7 +689,6 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
// TODO 自动生成的方法存根
|
|
|
|
|
Object s = e.getSource();
|
|
|
|
|
try {
|
|
|
|
|
if (s.equals(this.okButton)) {
|
|
|
|
@ -650,7 +699,6 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
try {
|
|
|
|
|
buildDrawingObjTypeFrame();
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
e2.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -669,7 +717,6 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
try {
|
|
|
|
|
createItem();
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
e2.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -680,22 +727,24 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
e2.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验必填属性,弹出提示窗口
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean checkRequiredProp() {
|
|
|
|
|
System.out.println("propComponentMap.size="+propComponentMap.size());
|
|
|
|
|
// System.out.println("propComponentMap.size="+propComponentMap.size());
|
|
|
|
|
if (propComponentMap.size()>0) {
|
|
|
|
|
for (Map.Entry<String, JComponent> entry : propComponentMap.entrySet()) {
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
Object value = getComponentValue(entry.getValue());
|
|
|
|
|
Object value = getComponentValue(key,entry.getValue());
|
|
|
|
|
// System.out.println("开始校验属性:"+key);
|
|
|
|
|
if (key.contains("*")) {
|
|
|
|
|
// System.out.println("属性【"+key+"】包含必选项!");
|
|
|
|
@ -713,20 +762,47 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @根据不同类型的组件获取组件的值
|
|
|
|
|
* @param component
|
|
|
|
|
*
|
|
|
|
|
* 根据不同类型的组件获取组件的值
|
|
|
|
|
* @param propShowName 属性条目在看板上展示的名称
|
|
|
|
|
* @param component 看板上属性条目对应的组件
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String getComponentValue(JComponent component) {
|
|
|
|
|
public String getComponentValue(String propShowName, JComponent component) {
|
|
|
|
|
System.out.println("开始根据不同类型的组件取值");
|
|
|
|
|
if (component instanceof JTextField) {
|
|
|
|
|
System.out.println("JTextField");
|
|
|
|
|
return ((JTextField) component).getText();
|
|
|
|
|
} else if (component instanceof JComboBox) {
|
|
|
|
|
System.out.println("JComboBox");
|
|
|
|
|
JComboBox<String> comboBox = (JComboBox<String>) component;
|
|
|
|
|
return (String)comboBox.getSelectedItem();
|
|
|
|
|
} else if (component instanceof DateButton) {
|
|
|
|
|
//通过显示名称判断该属性是否是lov
|
|
|
|
|
String lovType = null;
|
|
|
|
|
for (LovProperty lovProperty : this.lovPropertyList) {
|
|
|
|
|
if (lovProperty.getPropName().equals(propShowName)) {
|
|
|
|
|
lovType = lovProperty.getLovType();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println("属性"+propShowName+"的lovtype="+(lovType == null ? "非lov属性" : lovType));
|
|
|
|
|
String chooseDisplay= null;
|
|
|
|
|
if (component instanceof JTreeComboBox){
|
|
|
|
|
System.out.println("JTreeComboBox");
|
|
|
|
|
JTreeComboBox treeComboBox = (JTreeComboBox) component;
|
|
|
|
|
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) treeComboBox.getSelectedItem();
|
|
|
|
|
|
|
|
|
|
if (selectedNode != null) {
|
|
|
|
|
Object userObject = selectedNode.getUserObject();
|
|
|
|
|
chooseDisplay = userObject.toString();
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("选中节点selectedNode = null");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("JComboBox");
|
|
|
|
|
JComboBox<String> comboBox = (JComboBox<String>) component;
|
|
|
|
|
chooseDisplay = (String)comboBox.getSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
return chooseDisplay;
|
|
|
|
|
}else if (component instanceof DateButton) {
|
|
|
|
|
System.out.println("DateButton");
|
|
|
|
|
DateButton dateButton = (DateButton) component;
|
|
|
|
|
Date date = dateButton.getDate();
|
|
|
|
@ -746,9 +822,9 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
/**
|
|
|
|
|
* 绘制对象类型的创建对话框
|
|
|
|
|
* @return
|
|
|
|
|
* @throws TCException
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public JFrame buildDrawingObjTypeFrame() throws TCException{
|
|
|
|
|
public JFrame buildDrawingObjTypeFrame() throws Exception{
|
|
|
|
|
System.out.println("创建新图纸界面!");
|
|
|
|
|
this.propComponentMap.clear();
|
|
|
|
|
this.lovPropertyList.clear();
|
|
|
|
@ -759,8 +835,19 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
frame.setTitle("临时图纸创建界面");
|
|
|
|
|
this.setSize(400, 500);
|
|
|
|
|
this.setLayout(new BorderLayout());
|
|
|
|
|
|
|
|
|
|
// 创建滚动面板
|
|
|
|
|
JScrollPane scrollPane = new JScrollPane();
|
|
|
|
|
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // 垂直滚动条始终显示
|
|
|
|
|
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); // 禁用水平滚动条
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel centerPanel1 = new JPanel(new GridBagLayout());
|
|
|
|
|
// 设置内容面板的最小高度(确保滚动条生效)
|
|
|
|
|
centerPanel1.setMinimumSize(new Dimension(380, 800)); // 根据实际内容调整高度
|
|
|
|
|
scrollPane.setViewportView(centerPanel1); // 将内容面板放入滚动面板
|
|
|
|
|
|
|
|
|
|
JPanel buttomPanel1 = new JPanel(new FlowLayout());
|
|
|
|
|
|
|
|
|
|
//1.属性条目区域
|
|
|
|
@ -770,10 +857,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
if (idValue != null){
|
|
|
|
|
this.idTextField = new JTextField(idValue);
|
|
|
|
|
}
|
|
|
|
|
this.revLabel = new JLabel("版本");
|
|
|
|
|
String[] revs = {"S01"};//版本下拉框数组
|
|
|
|
|
this.revComboBox = new JComboBox<String>(revs);
|
|
|
|
|
// this.revComboBox.setEditable(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//布局
|
|
|
|
|
// ID Label
|
|
|
|
@ -797,31 +881,8 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
centerPanel1.add(this.idTextField, gbcIdField);
|
|
|
|
|
propComponentMap.put("ID*", idTextField);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 版本 Label
|
|
|
|
|
GridBagConstraints gbcRevLabel = new GridBagConstraints();
|
|
|
|
|
gbcRevLabel.gridx = 0;
|
|
|
|
|
gbcRevLabel.gridy = 1;
|
|
|
|
|
gbcRevLabel.anchor = GridBagConstraints.WEST;
|
|
|
|
|
gbcRevLabel.insets = new Insets(5, 5, 5, 5);
|
|
|
|
|
centerPanel1.add(this.revLabel, gbcRevLabel);
|
|
|
|
|
|
|
|
|
|
// 版本 ComboBox
|
|
|
|
|
GridBagConstraints gbcRevCombo = new GridBagConstraints();
|
|
|
|
|
gbcRevCombo.gridx = 1;
|
|
|
|
|
gbcRevCombo.gridy = 1;
|
|
|
|
|
gbcRevCombo.anchor = GridBagConstraints.WEST;
|
|
|
|
|
|
|
|
|
|
// 设置自定义宽度
|
|
|
|
|
Dimension comboBoxSize = new Dimension(200, revComboBox.getPreferredSize().height); // 将200设为所需的宽度
|
|
|
|
|
revComboBox.setPreferredSize(comboBoxSize);
|
|
|
|
|
|
|
|
|
|
centerPanel1.add(this.revComboBox, gbcRevCombo);
|
|
|
|
|
propComponentMap.put("版本", revComboBox);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String preferenceName = getSelectTypePreferenceName();
|
|
|
|
|
int propIndex = 2;
|
|
|
|
|
int propIndex = 1;
|
|
|
|
|
if (preferenceName != null){
|
|
|
|
|
List<String> preferenceInfoList = getPreferenceInfos(preferenceName);
|
|
|
|
|
if (preferenceInfoList != null && preferenceInfoList.size()>0) {
|
|
|
|
@ -833,10 +894,42 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("配置的属性数量 = "+this.preferencePropList.size());
|
|
|
|
|
for(String propInfo : this.preferencePropList){//propInfo格式为:*名称=Item.object_name=string
|
|
|
|
|
String[] revIDs = this.preferencePropList.get(0).split(";");//版本下拉框的数组
|
|
|
|
|
|
|
|
|
|
if (revIDs != null && revIDs.length > 0) {
|
|
|
|
|
this.revLabel = new JLabel("版本");
|
|
|
|
|
this.revComboBox = new JComboBox<String>(revIDs);
|
|
|
|
|
// 版本 Label
|
|
|
|
|
GridBagConstraints gbcRevLabel = new GridBagConstraints();
|
|
|
|
|
gbcRevLabel.gridx = 0;
|
|
|
|
|
gbcRevLabel.gridy = 1;
|
|
|
|
|
gbcRevLabel.anchor = GridBagConstraints.WEST;
|
|
|
|
|
gbcRevLabel.insets = new Insets(5, 5, 5, 5);
|
|
|
|
|
centerPanel1.add(this.revLabel, gbcRevLabel);
|
|
|
|
|
|
|
|
|
|
// 版本 ComboBox
|
|
|
|
|
GridBagConstraints gbcRevCombo = new GridBagConstraints();
|
|
|
|
|
gbcRevCombo.gridx = 1;
|
|
|
|
|
gbcRevCombo.gridy = 1;
|
|
|
|
|
gbcRevCombo.anchor = GridBagConstraints.WEST;
|
|
|
|
|
|
|
|
|
|
// 设置自定义宽度
|
|
|
|
|
Dimension comboBoxSize = new Dimension(200, revComboBox.getPreferredSize().height); // 将200设为所需的宽度
|
|
|
|
|
revComboBox.setPreferredSize(comboBoxSize);
|
|
|
|
|
|
|
|
|
|
centerPanel1.add(this.revComboBox, gbcRevCombo);
|
|
|
|
|
propComponentMap.put("版本", revComboBox);
|
|
|
|
|
|
|
|
|
|
propIndex ++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 首选项中配置的preferencePropList中,第一个是版本号数组,所以从第二个配置信息开始逐个渲染组件和属性
|
|
|
|
|
for (int i = 1; i < this.preferencePropList.size(); i++) {
|
|
|
|
|
String propInfo = this.preferencePropList.get(i);//propInfo格式为:*名称=Item.object_name=string
|
|
|
|
|
System.out.println("开始处理首选项配置的属性信息:"+propInfo);
|
|
|
|
|
String[] propConfigInfoArray= propInfo.split("=");
|
|
|
|
|
String validPropName = null;
|
|
|
|
|
String validPropName = null;//属性条目(除去符号*后)的有效值
|
|
|
|
|
if (propConfigInfoArray.length >= 3){
|
|
|
|
|
String name = propConfigInfoArray[0];//“图纸类型”
|
|
|
|
|
System.out.println("开始获取首选项配置属性["+name+"]的信息");
|
|
|
|
@ -897,40 +990,88 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
centerPanel1.add(dateButton, gbcPropCombo);
|
|
|
|
|
propComponentMap.put(validPropName, dateButton);
|
|
|
|
|
} else if (typeValue.equals("lov")) {
|
|
|
|
|
//TODO 根据冒号后面的LOV名称获取多个lov值,封装成数组添加到propComboBox中
|
|
|
|
|
// 根据冒号后面的LOV名称获取多个lov值,封装成数组添加到propComboBox中
|
|
|
|
|
if (lovName == null) {
|
|
|
|
|
System.out.println("未获取到属性["+name+"]配置的lov名称,请检查配置!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
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类型的属性类:存放lov类型的属性信息
|
|
|
|
|
TCComponentListOfValues unitLov = TCLOVUtil.findLOVByName(tcSession, lovName);
|
|
|
|
|
String lovType = null;
|
|
|
|
|
if(unitLov != null){
|
|
|
|
|
lovType = unitLov.getType();
|
|
|
|
|
if (lovType != null && lovType.equals("ListOfValuesString")) {//传统lov:key-value
|
|
|
|
|
System.out.println("获取属性["+name+"]的LOV类型为:traditional LOV");
|
|
|
|
|
rMap.clear();
|
|
|
|
|
Map<String, String> lovMap = getLOVDisplay_value(tcSession, lovName);
|
|
|
|
|
lovProperty.setLovMap(lovMap);
|
|
|
|
|
lovProperty.setLovType("LOV");
|
|
|
|
|
} else if (lovType != null && lovType.equals("Fnd0ListOfValuesDynamic")) {//动态lov:数组
|
|
|
|
|
System.out.println("获取属性["+name+"]的LOV类型为:dynamic LOV");
|
|
|
|
|
String[] dynamicLOV = getDynamicLOV(unitLov);
|
|
|
|
|
lovProperty.setLovType("DLOV");
|
|
|
|
|
List<String> dlovList = new ArrayList<>();
|
|
|
|
|
for (int i1 = 0; i1 < dynamicLOV.length; i1++) {
|
|
|
|
|
dlovList.add(dynamicLOV[i1]);
|
|
|
|
|
}
|
|
|
|
|
lovProperty.setDlovList(dlovList);
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("获取属性["+name+"]的LOV类型为:未知类型");
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lovProperty.setPropName(name);
|
|
|
|
|
lovProperty.setPropTrueName(trueName);
|
|
|
|
|
lovProperty.setLov(true);
|
|
|
|
|
lovProperty.setLovMap(lovMap);
|
|
|
|
|
|
|
|
|
|
this.lovPropertyList.add(lovProperty);
|
|
|
|
|
|
|
|
|
|
JComboBox<String> propComboBox = new JComboBox<String>(displayLovName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GridBagConstraints gbcPropCombo = new GridBagConstraints();
|
|
|
|
|
gbcPropCombo.gridx = 1;
|
|
|
|
|
gbcPropCombo.gridy = propIndex;
|
|
|
|
|
gbcPropCombo.anchor = GridBagConstraints.WEST;
|
|
|
|
|
|
|
|
|
|
// 设置自定义宽度
|
|
|
|
|
Dimension propValueSize = new Dimension(200, propComboBox.getPreferredSize().height); // 将200设为所需的宽度
|
|
|
|
|
propComboBox.setPreferredSize(propValueSize);
|
|
|
|
|
|
|
|
|
|
centerPanel1.add(propComboBox, gbcPropCombo);
|
|
|
|
|
propComponentMap.put(validPropName, propComboBox);
|
|
|
|
|
//根据lov的类型,渲染不同的lov组件
|
|
|
|
|
if (lovType.equals("ListOfValuesString")) {
|
|
|
|
|
DefaultMutableTreeNode root = generateLovTreeNode(lovProperty.getLovMap(),rMap);
|
|
|
|
|
JTreeComboBox propComboBox = null;
|
|
|
|
|
if(root != null) {
|
|
|
|
|
propComboBox = new JTreeComboBox(root);
|
|
|
|
|
GridBagConstraints gbcPropCombo = new GridBagConstraints();
|
|
|
|
|
gbcPropCombo.gridx = 1;
|
|
|
|
|
gbcPropCombo.gridy = propIndex;
|
|
|
|
|
gbcPropCombo.anchor = GridBagConstraints.WEST;
|
|
|
|
|
|
|
|
|
|
// 设置自定义宽度
|
|
|
|
|
Dimension propValueSize = new Dimension(200, propComboBox.getPreferredSize().height); // 将200设为所需的宽度
|
|
|
|
|
propComboBox.setPreferredSize(propValueSize);
|
|
|
|
|
|
|
|
|
|
centerPanel1.add(propComboBox, gbcPropCombo);
|
|
|
|
|
propComponentMap.put(validPropName, propComboBox);
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("绘制多层lov失败!");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
String[] dlov = lovProperty.getDlovList().toArray(new String[0]);
|
|
|
|
|
|
|
|
|
|
JComboBox<String> jComboBox = new JComboBox<String>(dlov);
|
|
|
|
|
|
|
|
|
|
GridBagConstraints gbcPropCombo = new GridBagConstraints();
|
|
|
|
|
gbcPropCombo.gridx = 1;
|
|
|
|
|
gbcPropCombo.gridy = propIndex;
|
|
|
|
|
gbcPropCombo.anchor = GridBagConstraints.WEST;
|
|
|
|
|
|
|
|
|
|
// 设置自定义宽度
|
|
|
|
|
Dimension propValueSize = new Dimension(200, jComboBox.getPreferredSize().height); // 将200设为所需的宽度
|
|
|
|
|
jComboBox.setPreferredSize(propValueSize);
|
|
|
|
|
|
|
|
|
|
centerPanel1.add(jComboBox, gbcPropCombo);
|
|
|
|
|
propComponentMap.put(validPropName, jComboBox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
propIndex ++;
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("首选项中配置的属性["+name+"]信息中,未正确配置属性类型!");
|
|
|
|
|
}
|
|
|
|
|
propIndex ++;
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("首选项["+preferenceName+"]配置格式不正确,请检查!");
|
|
|
|
|
}
|
|
|
|
@ -949,7 +1090,8 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
this.closeButton.addActionListener(this);
|
|
|
|
|
this.buildButton.addActionListener(this);
|
|
|
|
|
|
|
|
|
|
frame.add(centerPanel1, BorderLayout.CENTER);
|
|
|
|
|
// 将滚动面板添加到框架中央
|
|
|
|
|
frame.add(scrollPane, BorderLayout.CENTER);
|
|
|
|
|
frame.add(buttomPanel1, BorderLayout.SOUTH);
|
|
|
|
|
|
|
|
|
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
|
|
@ -970,6 +1112,80 @@ 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取动态LOV值
|
|
|
|
|
* @param lov LOV对象
|
|
|
|
|
* @return LOV选项数组
|
|
|
|
|
*/
|
|
|
|
|
public String[] getDynamicLOV(TCComponentListOfValues lov) throws Exception {
|
|
|
|
|
Vector<String> lovDisplayValueList = new Vector<>();
|
|
|
|
|
// lovDisplayValueList.add("");
|
|
|
|
|
// Vector<String> lovValueList = new Vector<>();
|
|
|
|
|
com.teamcenter.services.rac.core.LOVService lovService = LOVService.getService(tcSession);
|
|
|
|
|
InitialLovData input = new InitialLovData();
|
|
|
|
|
LovFilterData filter = new LovFilterData();
|
|
|
|
|
filter.sortPropertyName = "object_name";
|
|
|
|
|
filter.order = 1;
|
|
|
|
|
filter.numberToReturn = 100;
|
|
|
|
|
filter.maxResults = 100;
|
|
|
|
|
|
|
|
|
|
input.lov = lov;
|
|
|
|
|
input.filterData = filter;
|
|
|
|
|
LOVSearchResults result = lovService.getInitialLOVValues(input);
|
|
|
|
|
for (LOVValueRow row : result.lovValues) {
|
|
|
|
|
Map<String, String[]> map = row.propDisplayValues;
|
|
|
|
|
// Map<String, String[]> realmap = row.propInternalValues;
|
|
|
|
|
for (String key : map.keySet()) {
|
|
|
|
|
lovDisplayValueList.add(map.get(key)[0]);
|
|
|
|
|
// lovValueList.add(realmap.get(key)[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return lovDisplayValueList.toArray(new String[lovDisplayValueList.size()]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据选中对象(业务逻辑)获取ID输入框中的默认值
|
|
|
|
|
* @param selectComponent2 选中对象
|
|
|
|
@ -1007,28 +1223,39 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
|
|
|
|
|
// 替换掉所有的 * 符号
|
|
|
|
|
return str.replaceAll("\\*", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获得TC LOV值的显示值-真实值集合
|
|
|
|
|
* @param seesion
|
|
|
|
|
* @return
|
|
|
|
|
* @param lovProp lov名称 / 真实值
|
|
|
|
|
* @return 第一层lov的<显示值-真实值>集合
|
|
|
|
|
* @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();
|
|
|
|
|
if(unitLov != null){
|
|
|
|
|
String[] realval = unitLov.getListOfValues().getStringListOfValues();
|
|
|
|
|
|
|
|
|
|
String value="";
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
for (int i = 0; i < realval.length; i++) {
|
|
|
|
|
String disval = listOfValues.getDisplayableValue(realval[i]);
|
|
|
|
|
Display_values.put(disval, 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]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
// System.out.println("未找到LOV名称=["+lovProp+"]的lov对象!");
|
|
|
|
|
}
|
|
|
|
|
if (!Display_values.isEmpty()){
|
|
|
|
|
rMap.put(lovProp, Display_values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Display_values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|