diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetPane.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetPane.java index d746c4066..6bbc84ad3 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetPane.java @@ -22,6 +22,8 @@ import com.fr.general.ComparatorUtils; import com.fr.stable.ArrayUtils; import javax.swing.*; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -198,6 +200,7 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener } }); this.setPreferredSize(new Dimension(100, 20)); + this.initPopupMenuListener(userDefined); } public void setSelectedItemByWidgetClass(Class clazz) { @@ -218,7 +221,7 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener super.setSelectedItem(anObject); } - private Vector getWidgetsName(boolean userDefined) { + private Vector getWidgetsName(boolean userDefined) { WidgetOption[] reportWidgetInstance = getWidgetOptions(); Vector items = new Vector(); @@ -262,7 +265,30 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener } private WidgetOption[] getWidgetOptions() { - return (WidgetOption[]) ArrayUtils.addAll(WidgetOption.getReportWidgetInstance(), ExtraDesignClassManager.getInstance().getCellWidgetOptions()); + return ArrayUtils.addAll(WidgetOption.getReportWidgetInstance(), ExtraDesignClassManager.getInstance().getCellWidgetOptions()); + } + + private void initPopupMenuListener(boolean userDefined) { + this.addPopupMenuListener(new PopupMenuListener() { + + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + // 下拉刷新下列表 + Object selectedItem = getSelectedItem(); + setModel(new DefaultComboBoxModel(getWidgetsName(userDefined))); + setSelectedItem(selectedItem); + } + + @Override + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + + } + + @Override + public void popupMenuCanceled(PopupMenuEvent e) { + + } + }); } }