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)); } }