Browse Source

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

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

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

@ -20,6 +20,7 @@ import com.fr.form.ui.*;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
@ -274,9 +275,12 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
// 下拉刷新下列表
Object selectedItem = getSelectedItem();
setModel(new DefaultComboBoxModel(getWidgetsName(userDefined)));
setSelectedItem(selectedItem);
Vector<Item> widgetsName = getWidgetsName(userDefined);
if (modelChanged(widgetsName)) {
Object selectedItem = getSelectedItem();
setModel(new DefaultComboBoxModel<>(widgetsName));
setSelectedItem(selectedItem);
}
}
@Override
@ -290,6 +294,20 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener
}
});
}
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