From e0f894f244b99e6d19ba172e237bfc85aa27d7a1 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 3 Apr 2020 09:51:34 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-29149=20=E5=9F=BA=E7=A1=80=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6-=E5=A4=8D=E9=80=89=E4=B8=8B=E6=8B=89=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8F=AF=E4=B8=8D=E6=98=BE=E7=A4=BA=E2=80=9C=E5=85=A8?= =?UTF-8?q?=E9=80=89=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/icombocheckbox/UICheckListPopup.java | 16 ++++++++++++---- .../gui/icombocheckbox/UIComboCheckBox.java | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java index b0b57f29c..9592eb517 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java +++ b/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 Color mouseEnteredColor = UIConstants.CHECKBOX_HOVER_SELECTED; private int maxDisplayNumber = 8; + private boolean supportSelectAll = true; 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; - public UICheckListPopup(Object[] value) { + public UICheckListPopup(Object[] values) { + this(values, true); + } + + public UICheckListPopup(Object[] value, boolean supportSelectAll) { super(); values = value; + this.supportSelectAll = supportSelectAll; initComponent(); } @@ -73,7 +79,9 @@ public class UICheckListPopup extends UIPopupMenu { checkBoxList.clear(); //全选加在第一个位置 - addOneCheckValue(SELECT_ALL); + if (supportSelectAll) { + addOneCheckValue(SELECT_ALL); + } for (Object checkValue : value) { addOneCheckValue(checkValue); } @@ -146,7 +154,7 @@ public class UICheckListPopup extends UIPopupMenu { private void addSelectListener() { for (int i = 0; i < checkBoxList.size(); i++) { JCheckBox checkBox = checkBoxList.get(i); - if (i == 0) { + if (supportSelectAll && i == 0) { checkBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java index e2a5719d4..6eba4a6da 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java +++ b/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 boolean showOmitText = true; + private boolean supportSelectAll = true; + 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 valueSperator */ - public UIComboCheckBox(Object[] value, String valueSperator) { + public UIComboCheckBox(Object[] value, String valueSperator, boolean supportSelectAll) { values = value; + this.supportSelectAll = supportSelectAll; this.valueSperator = valueSperator; initComponent(); } @@ -102,7 +113,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam private void initComponent() { 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.editor = createEditor(); this.arrowButton = createArrowButton();