refactor(dialog): 优化 CreateTempDrawingDialog 类

- 注释掉一些不必要的打印语句,减少日志输出
- 修复 JTreeComboBox 在某些情况下的显示问题- 优化 getLovTrueValue 方法,增加参数有效性检查
-调整 checkRequiredProp 方法中的调试输出
mian
熊朝柱 1 month ago
parent 82985f1ff1
commit 7a602bcb7f

@ -104,14 +104,14 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
private static Map<String, Map<String, String>> rMap = new HashMap<String, Map<String,String>>(); private static Map<String, Map<String, String>> rMap = new HashMap<String, Map<String,String>>();
public static void printRMap() { public static void printRMap() {
System.out.println("begin 打印rMap集合"); // System.out.println("begin 打印rMap集合");
for (Map.Entry<String, Map<String, String>> outerEntry : rMap.entrySet()) { for (Map.Entry<String, Map<String, String>> outerEntry : rMap.entrySet()) {
String key = outerEntry.getKey(); String key = outerEntry.getKey();
Map<String, String> innerMap = outerEntry.getValue(); Map<String, String> innerMap = outerEntry.getValue();
System.out.println("Key: " + key); // System.out.println("Key: " + key);
for (Map.Entry<String, String> innerEntry : innerMap.entrySet()) { for (Map.Entry<String, String> innerEntry : innerMap.entrySet()) {
System.out.println(">>> Inner Key: " + innerEntry.getKey() + ", Value: " + innerEntry.getValue()); // System.out.println(">>> Inner Key: " + innerEntry.getKey() + ", Value: " + innerEntry.getValue());
} }
} }
} }
@ -316,7 +316,7 @@ 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()) { for (Map.Entry<String, JComponent> entry : this.propComponentMap.entrySet()) {
String key = entry.getKey();//编辑的属性条目名称 String key = entry.getKey();//编辑的属性条目名称
String value = getComponentValue(entry.getValue());//根据组件获取选中、输入的值 String value = getComponentValue(entry.getValue());//根据组件获取选中、输入的值
@ -459,6 +459,11 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
* @return lov * @return lov
*/ */
private String getLovTrueValue(String configName, String lovShowName, List<LovProperty> lovPropertyList2) { 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; String trueNameString = null;
//通过lov属性集合遍历获取lov真实值 //通过lov属性集合遍历获取lov真实值
for (LovProperty lovProperty : lovPropertyList2) { for (LovProperty lovProperty : lovPropertyList2) {
@ -710,7 +715,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
* @return * @return
*/ */
private boolean checkRequiredProp() { private boolean checkRequiredProp() {
System.out.println("propComponentMap.size="+propComponentMap.size()); // System.out.println("propComponentMap.size="+propComponentMap.size());
if (propComponentMap.size()>0) { if (propComponentMap.size()>0) {
for (Map.Entry<String, JComponent> entry : propComponentMap.entrySet()) { for (Map.Entry<String, JComponent> entry : propComponentMap.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
@ -742,19 +747,24 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
System.out.println("JTextField"); System.out.println("JTextField");
return ((JTextField) component).getText(); return ((JTextField) component).getText();
} else if (component instanceof JComboBox) { } else if (component instanceof JComboBox) {
System.out.println("JComboBox");
String returnValue = null; String returnValue = null;
// JComboBox<String> comboBox = (JComboBox<String>) component; if (component instanceof JTreeComboBox){
// return (String)comboBox.getSelectedItem(); System.out.println("JTreeComboBox");
JTreeComboBox treeComboBox = (JTreeComboBox) component;
JTreeComboBox treeComboBox = (JTreeComboBox ) component; DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) treeComboBox.getSelectedItem();
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) treeComboBox.getSelectedItem(); if (selectedNode != null) {
if (selectedNode != null) { Object userObject = selectedNode.getUserObject();
Object userObject = selectedNode.getUserObject(); returnValue = userObject.toString();
returnValue = userObject.toString(); }else {
System.out.println("选中节点selectedNode = null");
}
} else {
System.out.println("JComboBox");
JComboBox<String> comboBox = (JComboBox<String>) component;
returnValue = (String)comboBox.getSelectedItem();
} }
return returnValue; return returnValue;
} else if (component instanceof DateButton) { }else if (component instanceof DateButton) {
System.out.println("DateButton"); System.out.println("DateButton");
DateButton dateButton = (DateButton) component; DateButton dateButton = (DateButton) component;
Date date = dateButton.getDate(); Date date = dateButton.getDate();
@ -936,13 +946,13 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
rMap.clear(); rMap.clear();
Map<String, String> lovMap = getLOVDisplay_value(tcSession, lovName); Map<String, String> lovMap = getLOVDisplay_value(tcSession, lovName);
System.out.println("开始打印第一层lov"); // System.out.println("开始打印第一层lov");
for (String displayValue : lovMap.keySet()){ // for (String displayValue : lovMap.keySet()){
System.out.println(" lovMap:"+displayValue+"--"+lovMap.get(displayValue)); // System.out.println(" lovMap:"+displayValue+"--"+lovMap.get(displayValue));
} // }
printRMap(); // printRMap();
String[] displayLovName = lovMap.keySet().toArray(new String[0]);//lov显示值 // String[] displayLovName = lovMap.keySet().toArray(new String[0]);//lov显示值
LovProperty lovProperty = new LovProperty();//自定义的lov类型的属性类 LovProperty lovProperty = new LovProperty();//自定义的lov类型的属性类
lovProperty.setPropName(name); lovProperty.setPropName(name);
lovProperty.setPropTrueName(trueName); lovProperty.setPropTrueName(trueName);
@ -1107,7 +1117,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
*/ */
public static Map<String, String> getLOVDisplay_value(TCSession seesion,String lovProp) throws TCException public static Map<String, String> getLOVDisplay_value(TCSession seesion,String lovProp) throws TCException
{ {
System.out.println("getLOVDisplay_value方法入参lov名称="+lovProp); // System.out.println("getLOVDisplay_value方法入参lov名称="+lovProp);
Map<String, String> Display_values = new HashMap<String, String>(); Map<String, String> Display_values = new HashMap<String, String>();
TCComponentListOfValues unitLov = TCLOVUtil.findLOVByName(seesion, lovProp); TCComponentListOfValues unitLov = TCLOVUtil.findLOVByName(seesion, lovProp);
@ -1124,7 +1134,7 @@ public class CreateTempDrawingDialog extends JFrame implements ActionListener{
} }
}else { }else {
System.out.println("未找到LOV名称=["+lovProp+"]的lov对象"); // System.out.println("未找到LOV名称=["+lovProp+"]的lov对象");
} }
if (!Display_values.isEmpty()){ if (!Display_values.isEmpty()){
rMap.put(lovProp, Display_values); rMap.put(lovProp, Display_values);

@ -108,6 +108,8 @@ public class JTreeComboBox extends JComboBox<Object> {
TreePath path = new TreePath(node.getPath()); TreePath path = new TreePath(node.getPath());
tree.setSelectionPath(path); tree.setSelectionPath(path);
} }
revalidate(); // 触发布局更新
repaint(); // 触发重绘
} }
public JTree getTree() { public JTree getTree() {

Loading…
Cancel
Save