Browse Source

Pull request #15095: REPORT-137698 fix:修复数据字典数据查询无法展开数据列选择问题

Merge in DESIGN/design from ~RICHARD.FANG/design:fbp/release to fbp/release

* commit 'eabaf76e279611ff62d9384fc1f13d246e3ba1af':
  REPORT-137698 fix修复数据字典数据查询无法展开数据列选择问题
fbp/release
Richard.Fang-方超 1 month ago
parent
commit
dbd11a26ba
  1. 26
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataComboBox.java

26
designer-base/src/main/java/com/fr/design/data/datapane/TableDataComboBox.java

@ -1,6 +1,8 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.design.constants.UIConstants;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -43,22 +45,29 @@ public class TableDataComboBox extends UIComboBox implements Prepare4DataSourceC
this.treeName = treeName; this.treeName = treeName;
this.setRenderer(new UIComboBoxRenderer() { this.setRenderer(new UIComboBoxRenderer() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private boolean labelVisible = true;
@Override @Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); JLabel renderer = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (index == -1 && value == null) { if (value instanceof TableDataWrapper) {
// 显示空白 labelVisible = true;
TableDataWrapper tableDataWrapper = (TableDataWrapper)value;
renderer.setIcon(tableDataWrapper.getIcon());
renderer.setText(tableDataWrapper.getTableDataName());
renderer.setToolTipText(tableDataWrapper.getTableDataName());
} else {
labelVisible = false;
renderer.setIcon(null); renderer.setIcon(null);
renderer.setText(StringUtils.EMPTY); renderer.setText(StringUtils.EMPTY);
}else if (value instanceof TableDataWrapper) {
TableDataWrapper tabledatawrappe = (TableDataWrapper)value;
renderer.setIcon(tabledatawrappe.getIcon());
renderer.setText(tabledatawrappe.getTableDataName());
renderer.setToolTipText(tabledatawrappe.getTableDataName());
} }
return renderer; return renderer;
} }
@Override
public Dimension getPreferredSize() {
return labelVisible ? super.getPreferredSize() : new Dimension(super.getPreferredSize().width, 0);
}
}); });
refresh(source); refresh(source);
registerDSChangeListener(); registerDSChangeListener();
@ -75,6 +84,7 @@ public class TableDataComboBox extends UIComboBox implements Prepare4DataSourceC
setDsMap(); setDsMap();
DefaultComboBoxModel model = new DefaultComboBoxModel(); DefaultComboBoxModel model = new DefaultComboBoxModel();
this.setModel(model); this.setModel(model);
model.addElement(UIConstants.PENDING);
// 遍历添加所有数据项到模型 // 遍历添加所有数据项到模型
Iterator<Entry<String, TableDataWrapper>> entryIt = dsMap.entrySet().iterator(); Iterator<Entry<String, TableDataWrapper>> entryIt = dsMap.entrySet().iterator();
while (entryIt.hasNext()) { while (entryIt.hasNext()) {
@ -83,8 +93,6 @@ public class TableDataComboBox extends UIComboBox implements Prepare4DataSourceC
model.addElement(tableDataWrapper); model.addElement(tableDataWrapper);
} }
} }
// 设置默认选项为空白
this.setSelectedItem(null);
if (dataWrapper != null) { if (dataWrapper != null) {
if (DesignTableDataManager.isDsNameChanged(dataWrapper.getTableDataName())) { if (DesignTableDataManager.isDsNameChanged(dataWrapper.getTableDataName())) {
this.setSelectedTableDataByName(DesignTableDataManager.getChangedDsNameByOldDsName(dataWrapper.getTableDataName())); this.setSelectedTableDataByName(DesignTableDataManager.getChangedDsNameByOldDsName(dataWrapper.getTableDataName()));

Loading…
Cancel
Save