Browse Source

REPORT-68949 控件-预定义控件-预定义控件新建后控件列表中没有刷新出来

bugfix/11.0
lucian 3 years ago
parent
commit
7bd8d5b613
  1. 30
      designer-realize/src/main/java/com/fr/design/widget/WidgetPane.java

30
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<Item> getWidgetsName(boolean userDefined) {
WidgetOption[] reportWidgetInstance = getWidgetOptions();
Vector<Item> items = new Vector<Item>();
@ -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) {
}
});
}
}

Loading…
Cancel
Save