Browse Source

Pull request #8603: REPORT-68949 控件-预定义控件-预定义控件新建后控件列表中没有刷新出来

Merge in DESIGN/design from ~LUCIAN.CHEN/design:release/11.0 to release/11.0

* commit '7baae38c8582d1953805bb3a97e733ff86a28eb4':
  REPORT-68949 控件-预定义控件-预定义控件新建后控件列表中没有刷新出来
  REPORT-68949 控件-预定义控件-预定义控件新建后控件列表中没有刷新出来
  REPORT-68949 控件-预定义控件-预定义控件新建后控件列表中没有刷新出来
bugfix/11.0
Lucian.Chen 3 years ago
parent
commit
2993e30721
  1. 46
      designer-realize/src/main/java/com/fr/design/widget/WidgetPane.java

46
designer-realize/src/main/java/com/fr/design/widget/WidgetPane.java

@ -20,8 +20,11 @@ import com.fr.form.ui.*;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*; import java.awt.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
@ -198,6 +201,7 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener
} }
}); });
this.setPreferredSize(new Dimension(100, 20)); this.setPreferredSize(new Dimension(100, 20));
this.initPopupMenuListener(userDefined);
} }
public void setSelectedItemByWidgetClass(Class clazz) { public void setSelectedItemByWidgetClass(Class clazz) {
@ -218,7 +222,7 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener
super.setSelectedItem(anObject); super.setSelectedItem(anObject);
} }
private Vector getWidgetsName(boolean userDefined) { private Vector<Item> getWidgetsName(boolean userDefined) {
WidgetOption[] reportWidgetInstance = getWidgetOptions(); WidgetOption[] reportWidgetInstance = getWidgetOptions();
Vector<Item> items = new Vector<Item>(); Vector<Item> items = new Vector<Item>();
@ -262,7 +266,45 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener
} }
private WidgetOption[] getWidgetOptions() { 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) {
// 下拉刷新下列表
Vector<Item> widgetsName = getWidgetsName(userDefined);
if (modelChanged(widgetsName)) {
refreshBoxItems(widgetsName);
}
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
});
}
private boolean modelChanged(Vector<Item> widgetsName) {
DefaultComboBoxModel model = (DefaultComboBoxModel) getModel();
int modelSize = model.getSize();
if (modelSize != widgetsName.size()) {
return true;
}
for (int i = 0; i < modelSize; i++) {
if (!AssistUtils.equals(model.getElementAt(i), widgetsName.elementAt(i))) {
return true;
}
}
return false;
} }
} }

Loading…
Cancel
Save