diff --git a/bin/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.class b/bin/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.class index c87d6e4..05f4f8c 100644 Binary files a/bin/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.class and b/bin/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.class differ diff --git a/src/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.java b/src/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.java index 1a72244..f2d003c 100644 --- a/src/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.java +++ b/src/cn/net/connor/createTempDrawings/dialogs/CreateTempDrawingDialog.java @@ -300,9 +300,9 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ for (Map.Entry 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 } } @@ -473,15 +473,22 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ } String trueNameString = null; //通过lov属性集合遍历,获取lov真实值 + //1.先根据普通(一层)lov和动态lov,分别获取lov真实值 for (LovProperty lovProperty : lovPropertyList2) { String propName = lovProperty.getPropTrueName(); + String lovType = lovProperty.getLovType(); if (configName.equals(propName)) {//属性真实名称与lov属性集合匹配 - Map lovMap = lovProperty.getLovMap(); - trueNameString = lovMap.get(lovShowName); + if (lovType.equals("LOV")){//普通单层lov取值 + Map lovMap = lovProperty.getLovMap(); + trueNameString = lovMap.get(lovShowName); + }else if (lovType.equals("DLOV")){//动态lov取值:获取lov下拉框的显示值即可,不存在key-value结构 + trueNameString = lovShowName; + } + break; } } - //通过lov子项集合遍历,获取lov真实值 + //2.如果未获取成功,则通过lov子项(多层)集合遍历,获取lov真实值 if (trueNameString == null && rMap != null && rMap.size()>0){ for (Map.Entry> entry : rMap.entrySet()){ Map childLovMaps = entry.getValue();//获取lov子项《显示值-真实值》集合 @@ -491,6 +498,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ String realValueString = entry1.getValue(); if (lovShowName.equals(showValueString)) { trueNameString = realValueString; + break; } } @@ -726,7 +734,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ if (propComponentMap.size()>0) { for (Map.Entry 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+"】包含必选项!"); @@ -760,7 +768,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ String lovType = null; for (LovProperty lovProperty : this.lovPropertyList) { if (lovProperty.getPropName().equals(propShowName)) { - lovType = lovProperty.getlovType(); + lovType = lovProperty.getLovType(); break; } @@ -828,13 +836,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ if (idValue != null){ this.idTextField = new JTextField(idValue); } - this.revLabel = new JLabel("版本"); - String[] revs = {"DX01"};//版本下拉框数组 -// //todo 参考编码器获取新的版本 -// String newRev = tccomponentitemtype.getNewRev(null); -// String[] revs = {newRev}; - this.revComboBox = new JComboBox(revs); -// this.revComboBox.setEditable(true); + //布局 // ID Label @@ -858,31 +860,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 preferenceInfoList = getPreferenceInfos(preferenceName); if (preferenceInfoList != null && preferenceInfoList.size()>0) { @@ -894,7 +873,40 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ } System.out.println("配置的属性数量 = "+this.preferencePropList.size()); - for(String propInfo : this.preferencePropList){//propInfo格式为:*名称=Item.object_name=string +// 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(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;//属性条目(除去符号*后)的有效值 @@ -969,18 +981,22 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ 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 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 dlovList = new ArrayList<>(); - for (int i = 0; i < dynamicLOV.length; i++) { - dlovList.add(dynamicLOV[i]); + for (int i1 = 0; i1 < dynamicLOV.length; i1++) { + dlovList.add(dynamicLOV[i1]); } lovProperty.setDlovList(dlovList); + }else { + System.out.println("获取属性["+name+"]的LOV类型为:未知类型"); } }else { continue; @@ -1014,7 +1030,8 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ continue; } }else { - String[] dlov = (String[]) lovProperty.getDlovList().toArray(); + String[] dlov = lovProperty.getDlovList().toArray(new String[0]); + JComboBox jComboBox = new JComboBox(dlov); GridBagConstraints gbcPropCombo = new GridBagConstraints(); @@ -1031,10 +1048,10 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{ } } + propIndex ++; }else { System.out.println("首选项中配置的属性["+name+"]信息中,未正确配置属性类型!"); } - propIndex ++; }else { System.out.println("首选项["+preferenceName+"]配置格式不正确,请检查!"); } diff --git a/src/cn/net/connor/createTempDrawings/pojo/LovProperty.java b/src/cn/net/connor/createTempDrawings/pojo/LovProperty.java index 2a80b5c..a7358f4 100644 --- a/src/cn/net/connor/createTempDrawings/pojo/LovProperty.java +++ b/src/cn/net/connor/createTempDrawings/pojo/LovProperty.java @@ -27,6 +27,15 @@ public class LovProperty { public String getLovType() { return lovType; } + /** + * 存放lov类型属性的“显示值-真实值”单层lov集合 + */ + private Map lovMap; + + //专门用于存放动态lov的list集合 + private List dlovList; + + /** * @param lovType 要设置的 lovType @@ -35,10 +44,7 @@ public class LovProperty { this.lovType = lovType; } - /** - * lov类型属性的“显示值-真实值”集合 - */ - private Map lovMap; + /** * @return dlovList @@ -54,7 +60,7 @@ public class LovProperty { this.dlovList = dlovList; } - private List dlovList; + public String getPropName() { return propName; diff --git a/src/cn/net/connor/createTempDrawings/utils/JTreeComboBox.java b/src/cn/net/connor/createTempDrawings/utils/JTreeComboBox.java index a425cbf..3a6e51c 100644 --- a/src/cn/net/connor/createTempDrawings/utils/JTreeComboBox.java +++ b/src/cn/net/connor/createTempDrawings/utils/JTreeComboBox.java @@ -195,7 +195,8 @@ public class JTreeComboBox extends JComboBox { // 设置弹出框大小 Dimension preferredSize = tree.getPreferredSize(); preferredSize.width = Math.max(preferredSize.width, 200); - preferredSize.height = Math.min(preferredSize.height, 800); + preferredSize.height = Math.min(preferredSize.height, 200); + preferredSize.height = 150; setPreferredSize(preferredSize); }