From ecce754c425a8047735dca87916d659f8f402577 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 20 Oct 2021 15:02:08 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-61267=20=E3=80=90FR11=E3=80=91=E3=80=90?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8-=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=9B=BE=E6=A1=88=E7=9A=84=E2=80=9C=E5=9B=BE?= =?UTF-8?q?=E6=A1=88=E7=9B=B8=E5=AF=B9=E4=BD=8D=E7=BD=AE=E2=80=9D=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E4=B8=8D=E7=94=9F=E6=95=88=E4=BA=86=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E5=9C=A8=E9=87=8D=E6=96=B0=E4=B8=8A=E4=BC=A0=E5=9B=BE?= =?UTF-8?q?=E6=A1=88=E7=9A=84=E6=97=B6=E5=80=99=E6=89=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=EF=BC=9B=E2=80=9C=E4=BD=8D=E7=BD=AE=E2=80=9D=E4=B9=9F=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 UIButtonGroup在点击控件时会触发多次内部ToggleButton的fireStateChange,所以需要在所有按钮内部状态改变时, 统一只触发一次fireStateChange. UIButtonGroup也需要实现UIObserver接口,否则外部不会挂载监听器,导致 不生效。 【改动思路】 同上 --- .../fr/design/gui/ibutton/UIButtonGroup.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java index 34a7a0012..cbebaf9d8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java @@ -3,6 +3,8 @@ package com.fr.design.gui.ibutton; import com.fr.design.constants.UIConstants; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; @@ -24,7 +26,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class UIButtonGroup extends JPanel implements GlobalNameObserver { +public class UIButtonGroup extends JPanel implements GlobalNameObserver, UIObserver { private static final long serialVersionUID = 1L; private static final int TEXT_LENGTH = 3; private static final int BUTTON_SIZE = 2; @@ -37,6 +39,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { private boolean isToolBarComponent = false; private boolean isClick; + private UIObserverListener uiObserverListener; private boolean autoFireStateChanged = true; public UIButtonGroup(String[] textArray) { @@ -326,6 +329,9 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { ((ChangeListener) listeners[i + 1]).stateChanged(e); } } + if (uiObserverListener != null) { + uiObserverListener.doChange(); + } } /** @@ -368,6 +374,16 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { return true; } + @Override + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + /** * @param l