From 7bd8d5b6137cf270eb32c3bc99cb6a30f67c8c43 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 18 Apr 2022 11:44:39 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-68949=20=E6=8E=A7=E4=BB=B6-=E9=A2=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=8E=A7=E4=BB=B6-=E9=A2=84=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8E=A7=E4=BB=B6=E6=96=B0=E5=BB=BA=E5=90=8E=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E5=88=97=E8=A1=A8=E4=B8=AD=E6=B2=A1=E6=9C=89=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/widget/WidgetPane.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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 d746c4066b..6bbc84ad35 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) { + + } + }); } }