From 8bccab743c4c91d735d258cc7a460e12825d7198 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 19 Dec 2019 15:11:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-24206=5F=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=5F=E4=BF=AE=E6=94=B9=E8=BE=B9=E6=A1=86=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E8=83=8C=E6=99=AF=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E4=BC=9A=E5=8F=98=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/style/BackgroundPane.java | 5 ++-- .../com/fr/design/gui/style/BorderPane.java | 26 +++++++++---------- .../backgroundpane/BackgroundQuickPane.java | 26 +++++++++++++++++++ .../ColorBackgroundQuickPane.java | 15 ++--------- .../GradientBackgroundQuickPane.java | 13 +++------- .../ImageBackgroundQuickPane.java | 7 +---- .../NullBackgroundQuickPane.java | 4 +++ .../PatternBackgroundQuickPane.java | 19 +++----------- .../TextureBackgroundQuickPane.java | 7 ++--- 9 files changed, 57 insertions(+), 65 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java index 3ad75044c2..88ee482cb8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java @@ -32,7 +32,7 @@ public class BackgroundPane extends AbstractBasicStylePane { protected BackgroundQuickPane[] paneList; //获取当前面板 - protected JPanel currentPane = null; + protected BackgroundQuickPane currentPane = null; public BackgroundPane() { @@ -43,7 +43,6 @@ public class BackgroundPane extends AbstractBasicStylePane { this.setLayout(new BorderLayout(0, 6)); typeComboBox = new UIComboBox(); final CardLayout cardlayout = new CardLayout(); -// this.add(typeComboBox, BorderLayout.NORTH); paneList = supportKindsOfBackgroundUI(); @@ -58,12 +57,12 @@ public class BackgroundPane extends AbstractBasicStylePane { typeComboBox.addItem(pane.title4PopupWindow()); centerPane.add(pane, pane.title4PopupWindow()); } -// this.add(centerPane, BorderLayout.CENTER); typeComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem()); + currentPane = paneList[typeComboBox.getSelectedIndex()]; fireStateChanged(); } }); diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java index ce3940bf2a..ea2ed65d5c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java @@ -16,11 +16,14 @@ import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; import com.fr.design.style.color.NewColorSelectBox; +import com.fr.general.Background; import com.fr.stable.Constants; import com.fr.stable.CoreConstants; +import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -28,6 +31,7 @@ import javax.swing.event.ChangeListener; import java.awt.*; import java.util.Arrays; import java.util.HashSet; +import java.util.Set; /** * @author zhou @@ -37,6 +41,7 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse private static final String[] BORDERARRAY = {"currentLineCombo", "currentLineColorPane", "outerToggleButton", "topToggleButton", "leftToggleButton", "bottomToggleButton", "rightToggleButton", "innerToggleButton", "horizontalToggleButton", "verticalToggleButton"}; + private static final Set BORDER_SET = new HashSet<>(Arrays.asList(BORDERARRAY)); private boolean insideMode = false; private UIToggleButton topToggleButton; @@ -193,25 +198,20 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse this.verticalToggleButton.setEnabled(this.insideMode); } + @Override public Style update(Style style) { if (style == null) { style = Style.DEFAULT_STYLE; } - CellBorderStyle cellBorderStyle = this.update(); - HashSet borderSet = new HashSet(Arrays.asList(BORDERARRAY)); - style = style.deriveBackground(backgroundPane.update()); - if (backgroundPane.currentPane != backgroundPane.paneList[1]){ - if (borderSet.contains(globalNameListener.getGlobalName())) { - style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(), - cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor()); - } - }else { - if (borderSet.contains(globalNameListener.getGlobalName()) && !((ColorBackgroundQuickPane) backgroundPane.currentPane).isBackGroundColor()){ - style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(), - cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor()); - } + if (backgroundPane.currentPane.isBackgroundChange()) { + style = style.deriveBackground(backgroundPane.update()); + } + if (BORDER_SET.contains(globalNameListener.getGlobalName())) { + CellBorderStyle cellBorderStyle = this.update(); + style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(), + cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor()); } return style; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java index 850132d863..99e482355c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java @@ -2,14 +2,20 @@ package com.fr.design.mainframe.backgroundpane; import com.fr.design.beans.BasicBeanPane; import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; import com.fr.general.Background; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + /** * @author zhou * @since 2012-5-29下午1:12:28 */ public abstract class BackgroundQuickPane extends BasicBeanPane implements UIObserver { + private boolean backgroundChange; + public abstract boolean accept(Background background); @Override @@ -23,6 +29,10 @@ public abstract class BackgroundQuickPane extends BasicBeanPane impl public abstract void reset(); + public boolean isBackgroundChange() { + return backgroundChange; + } + /** * 组件是否需要响应添加的观察者事件 * @@ -32,4 +42,20 @@ public abstract class BackgroundQuickPane extends BasicBeanPane impl return true; } + + class ChangeListenerImpl implements ChangeListener { + + private UIObserverListener listener; + + public ChangeListenerImpl(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public void stateChanged(ChangeEvent e) { + backgroundChange = true; + this.listener.doChange(); + backgroundChange = false; + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java index 89c61ec9d0..f9b4c160e5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java @@ -19,7 +19,6 @@ import java.awt.Color; public class ColorBackgroundQuickPane extends BackgroundQuickPane { private NewColorSelectPane detailColorSelectPane; - private boolean isBackGroundColor; public ColorBackgroundQuickPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -39,7 +38,6 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane { public void populateColor(Color color) { this.detailColorSelectPane.setColor(color); - isBackGroundColor = false; } public Color updateColor() { @@ -47,23 +45,14 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane { return this.detailColorSelectPane.getNotNoneColor(); } - public boolean isBackGroundColor() { - return isBackGroundColor; - } - /** * 给组件登记一个观察者监听事件 * * @param listener 观察者监听事件 */ + @Override public void registerChangeListener(final UIObserverListener listener) { - detailColorSelectPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - isBackGroundColor = true; - listener.doChange(); - isBackGroundColor = false; - } - }); + detailColorSelectPane.addChangeListener(new ChangeListenerImpl(listener)); } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java index 09be6771cf..6c3ea9e727 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java @@ -96,17 +96,10 @@ public class GradientBackgroundQuickPane extends BackgroundQuickPane { * * @param listener 观察者监听事件 */ + @Override public void registerChangeListener(final UIObserverListener listener) { - gradientBar.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - directionPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); + gradientBar.addChangeListener(new ChangeListenerImpl(listener)); + directionPane.addChangeListener(new ChangeListenerImpl(listener)); } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java index afa6fc9077..e1496ff3d6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java @@ -127,12 +127,7 @@ public class ImageBackgroundQuickPane extends BackgroundQuickPane { */ @Override public void registerChangeListener(final UIObserverListener listener) { - changeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }; + changeListener = new ChangeListenerImpl(listener); imageLayoutPane.addChangeListener(changeListener); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java index 8aa6573f51..9a86a38c11 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java @@ -33,6 +33,10 @@ public class NullBackgroundQuickPane extends BackgroundQuickPane { } + @Override + public boolean isBackgroundChange() { + return true; + } /** * 是否接受 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java index 9da1344dcd..8f4c2ecfbf 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java @@ -112,23 +112,12 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane { * * @param listener 观察者监听事件 */ + @Override public void registerChangeListener(final UIObserverListener listener) { - foregroundColorPane.addSelectChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - backgroundColorPane.addSelectChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); + foregroundColorPane.addSelectChangeListener(new ChangeListenerImpl(listener)); + backgroundColorPane.addSelectChangeListener(new ChangeListenerImpl(listener)); for (int i = 0, count = patternButtonArray.length; i < count; i++) { - patternButtonArray[i].addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); + patternButtonArray[i].addChangeListener(new ChangeListenerImpl(listener)); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java index 0d94bf3bce..e9aed06acd 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java @@ -68,13 +68,10 @@ public class TextureBackgroundQuickPane extends BackgroundQuickPane { * * @param listener 观察者监听事件 */ + @Override public void registerChangeListener(final UIObserverListener listener) { for (int i = 0, count = textureButtonArray.length; i < count; i++) { - textureButtonArray[i].addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); + textureButtonArray[i].addChangeListener(new ChangeListenerImpl(listener)); } } From 6f27c10428be5070c8292e30788376950693bb30 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 19 Dec 2019 15:17:35 +0800 Subject: [PATCH 2/2] fix import --- .../src/main/java/com/fr/design/gui/style/BorderPane.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java index ea2ed65d5c..da0cd32ed5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java @@ -16,14 +16,10 @@ import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; -import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; import com.fr.design.style.color.NewColorSelectBox; -import com.fr.general.Background; import com.fr.stable.Constants; import com.fr.stable.CoreConstants; -import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.event.ChangeEvent;