Browse Source

Merge pull request #1555 in DESIGN/design from ~HADES/design:feature/10.0 to feature/10.0

* commit 'e0f894f244b99e6d19ba172e237bfc85aa27d7a1':
  REPORT-29149 基础控件-复选下拉列表可不显示“全选”
research/11.0
Hades 5 years ago
parent
commit
3a54c4f73f
  1. 14
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  2. 17
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

14
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -36,14 +36,20 @@ public class UICheckListPopup extends UIPopupMenu {
private UIScrollPane jScrollPane; private UIScrollPane jScrollPane;
private Color mouseEnteredColor = UIConstants.CHECKBOX_HOVER_SELECTED; private Color mouseEnteredColor = UIConstants.CHECKBOX_HOVER_SELECTED;
private int maxDisplayNumber = 8; private int maxDisplayNumber = 8;
private boolean supportSelectAll = true;
public static final String COMMIT_EVENT = "commit"; public static final String COMMIT_EVENT = "commit";
public static final String SELECT_ALL = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All"); private static final String SELECT_ALL = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All");
private static final int CHECKBOX_HEIGHT = 25; private static final int CHECKBOX_HEIGHT = 25;
public UICheckListPopup(Object[] value) { public UICheckListPopup(Object[] values) {
this(values, true);
}
public UICheckListPopup(Object[] value, boolean supportSelectAll) {
super(); super();
values = value; values = value;
this.supportSelectAll = supportSelectAll;
initComponent(); initComponent();
} }
@ -73,7 +79,9 @@ public class UICheckListPopup extends UIPopupMenu {
checkBoxList.clear(); checkBoxList.clear();
//全选加在第一个位置 //全选加在第一个位置
if (supportSelectAll) {
addOneCheckValue(SELECT_ALL); addOneCheckValue(SELECT_ALL);
}
for (Object checkValue : value) { for (Object checkValue : value) {
addOneCheckValue(checkValue); addOneCheckValue(checkValue);
} }
@ -146,7 +154,7 @@ public class UICheckListPopup extends UIPopupMenu {
private void addSelectListener() { private void addSelectListener() {
for (int i = 0; i < checkBoxList.size(); i++) { for (int i = 0; i < checkBoxList.size(); i++) {
JCheckBox checkBox = checkBoxList.get(i); JCheckBox checkBox = checkBoxList.get(i);
if (i == 0) { if (supportSelectAll && i == 0) {
checkBox.addItemListener(new ItemListener() { checkBox.addItemListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {

17
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -59,8 +59,18 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private String multiComboName = StringUtils.EMPTY; private String multiComboName = StringUtils.EMPTY;
private boolean showOmitText = true; private boolean showOmitText = true;
private boolean supportSelectAll = true;
public UIComboCheckBox(Object[] value) { public UIComboCheckBox(Object[] value) {
this(value, DEFAULT_VALUE_SPERATOR); this(value, DEFAULT_VALUE_SPERATOR, true);
}
public UIComboCheckBox(Object[] value, boolean supportSelectAll) {
this(value, DEFAULT_VALUE_SPERATOR, supportSelectAll);
}
public UIComboCheckBox(Object[] values, String valueSperator) {
this(values, valueSperator, true);
} }
/** /**
@ -69,8 +79,9 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
* @param value * @param value
* @param valueSperator * @param valueSperator
*/ */
public UIComboCheckBox(Object[] value, String valueSperator) { public UIComboCheckBox(Object[] value, String valueSperator, boolean supportSelectAll) {
values = value; values = value;
this.supportSelectAll = supportSelectAll;
this.valueSperator = valueSperator; this.valueSperator = valueSperator;
initComponent(); initComponent();
} }
@ -102,7 +113,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private void initComponent() { private void initComponent() {
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
this.popup = new UICheckListPopup(values); this.popup = new UICheckListPopup(values, supportSelectAll);
this.popup.addActionListener(new PopupAction()); this.popup.addActionListener(new PopupAction());
this.editor = createEditor(); this.editor = createEditor();
this.arrowButton = createArrowButton(); this.arrowButton = createArrowButton();

Loading…
Cancel
Save