diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java index 14a90da7b2..e6130ca3da 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java @@ -15,6 +15,7 @@ import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.List; import java.util.Vector; /** @@ -131,6 +132,21 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser return new Dimension(super.getPreferredSize().width + SIZE5, SIZE); } + public void refreshBoxItems(List list) { + Object ob = getSelectedItem(); + + removeAllItems(); + for (Object o : list) { + addItem(o); + } + + getModel().setSelectedItem(ob); + } + + public void clearBoxItems() { + removeAllItems(); + } + /** * 鼠标进入事件 */ diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java index 3fb9d6a63e..69cf88286f 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java @@ -21,15 +21,7 @@ public class DataPaneHelper { return; } - Object ob = box.getSelectedItem(); - box.removeAllItems(); - - int length = list.size(); - for (int i = 0; i < length; i++) { - box.addItem(list.get(i)); - } - - box.getModel().setSelectedItem(ob); + box.refreshBoxItems(list); } /** @@ -39,7 +31,7 @@ public class DataPaneHelper { */ public static void clearBoxItems(UIComboBox box) { if (box != null) { - box.removeAllItems(); + box.clearBoxItems(); } } diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java index 0ac4546345..e0bf8de70a 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java @@ -10,13 +10,14 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.general.GeneralUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; import java.util.Arrays; import java.util.List; -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.SwingConstants; /** * Created by shine on 2018/3/2. @@ -52,8 +53,8 @@ public abstract class AbstractExtendedChartTableDataPane fieldList = new ArrayList(); - public ExtendedCustomFieldComboBoxPane(boolean hasNoneItem) { - this.hasNoneItem = hasNoneItem; - } - @Override protected void initLayout() { this.setLayout(new BorderLayout(0, 6)); @@ -76,6 +70,10 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane