From 6f38809306f5c74529ee067a80acdf19a5e389fa Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 18 Aug 2021 19:18:44 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-56548=20=E4=B8=BB=E9=A2=98=E5=88=87?= =?UTF-8?q?=E6=8D=A2-=E4=B8=BB=E9=A2=98=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/PreferencePane.java | 5 +- .../fr/design/gui/ibutton/UIColorButton.java | 18 +- .../gui/ibutton/UINoThemeColorButton.java | 36 +++ .../fr/design/mainframe/DesignerFrame.java | 17 ++ .../ColorBackgroundQuickPane.java | 5 +- .../ui/detail/background/ColorDetailPane.java | 53 +--- .../com/fr/design/report/WatermarkPane.java | 2 +- .../com/fr/design/style/CustomSelectBox.java | 6 +- .../style/background/BackgroundPane.java | 9 +- .../background/impl/ColorBackgroundPane.java | 6 +- .../impl/ColorNoThemeBackgroundPane.java | 10 + .../design/style/color/ColorAdjustPane.java | 7 +- .../fr/design/style/color/ColorButton.java | 10 +- .../style/color/ColorControlWindow.java | 12 +- .../color/ColorControlWindowWithAuto.java | 2 +- .../fr/design/style/color/ColorSelectBox.java | 12 +- .../style/color/ColorSelectDetailPane.java | 14 +- .../design/style/color/ColorSelectDialog.java | 1 + .../design/style/color/ColorSelectPane.java | 1 + .../style/color/DetailColorSelectPane.java | 10 +- .../fr/design/style/color/FineColorCell.java | 24 ++ .../design/style/color/NewColorSelectBox.java | 4 +- .../style/color/NewColorSelectPane.java | 237 ++++++++++++++---- .../gui/ColorSelectBoxWithOutTransparent.java | 4 +- .../ColorSelectPaneWithOutTransparent.java | 16 +- .../style/series/UIColorPickerPane4Map.java | 22 +- .../server/ServerConfigManagerAction.java | 12 +- .../fr/design/webattr/WriteToolBarPane.java | 3 +- 28 files changed, 365 insertions(+), 193 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java create mode 100644 designer-base/src/main/java/com/fr/design/style/background/impl/ColorNoThemeBackgroundPane.java create mode 100644 designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 133bbb03f2..0cb1f214c6 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -12,6 +12,7 @@ import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UINoThemeColorButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIDictionaryComboBox; @@ -457,10 +458,10 @@ public class PreferencePane extends BasicPane { JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors")); generalPane.add(colorSettingPane); - gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); + gridLineColorTBButton = new UINoThemeColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); gridLineColorTBButton.setEnabled(this.isEnabled()); - paginationLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); + paginationLineColorTBButton = new UINoThemeColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); paginationLineColorTBButton.setEnabled(this.isEnabled()); JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java index 28f5830619..8171f31cb7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java @@ -154,18 +154,22 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G protected ColorControlWindow getColorControlWindow() { //find parant. if (this.popupWin == null) { - this.popupWin = new ColorControlWindow(UIColorButton.this) { - @Override - protected void colorChanged() { - UIColorButton.this.setColor(this.getColor()); - } - - }; + this.popupWin = initColorControlWindow(); } return popupWin; } + protected ColorControlWindow initColorControlWindow(){ + return new ColorControlWindow(UIColorButton.this) { + @Override + protected void colorChanged() { + UIColorButton.this.setColor(this.getColor()); + } + + }; + } + /** * 添加监听 * diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java new file mode 100644 index 0000000000..da071458a1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java @@ -0,0 +1,36 @@ +package com.fr.design.gui.ibutton; + +import com.fr.design.gui.ipoppane.PopupHider; +import com.fr.design.style.color.ColorControlWindow; + +import javax.swing.Icon; + + +public class UINoThemeColorButton extends UIColorButton{ + + public UINoThemeColorButton(Icon icon) { + super(icon); + } + + protected ColorControlWindow initColorControlWindow(){ + return new NoThemeColorControlWindow(this); + } + + private class NoThemeColorControlWindow extends ColorControlWindow{ + + + public NoThemeColorControlWindow(PopupHider popupHider) { + super(popupHider); + } + + protected boolean supportThemeColor(){ + return false; + } + + + @Override + protected void colorChanged() { + UINoThemeColorButton.this.setColor(this.getColor()); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index b7bc518385..6d50b592ca 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -177,6 +177,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta //用于判断设计器是否打开了 private boolean designerOpened = false; + private boolean serverConfig = false; + private int contentWidth = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth()); private int contentHeight = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight()); @@ -1339,4 +1341,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta return designerOpened; } + /** + * 判断是否正在进行服务器配置 + * @return boolean + */ + public boolean isServerConfig() { + return serverConfig; + } + + /** + * 设置是否正在进行服务器配置 + * @param serverConfig + */ + public void setServerConfig(boolean serverConfig) { + this.serverConfig = serverConfig; + } } 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 f9b4c160e5..8426a5b6df 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 @@ -6,9 +6,6 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.style.color.NewColorSelectPane; import com.fr.general.Background; - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Color; @@ -23,7 +20,7 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane { public ColorBackgroundQuickPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - detailColorSelectPane = new NewColorSelectPane(); + detailColorSelectPane = new NewColorSelectPane(false); this.add(detailColorSelectPane, BorderLayout.NORTH); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java index b7034fd669..43d20d1bde 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java @@ -3,20 +3,10 @@ package com.fr.design.mainframe.predefined.ui.detail.background; import com.fr.base.background.ColorBackground; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; import com.fr.general.Background; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; /** * Created by kerry on 2020-08-31 @@ -50,48 +40,9 @@ public class ColorDetailPane extends AbstractBackgroundDetailPane cacheMap = new HashMap<>(); - + //需求说: 如果是浏览器背景, 隐藏掉几个button public BackgroundPane() { + BackgroundFactory.getWrapper(ColorBackground.class).setType( + DesignerContext.getDesignerFrame().isServerConfig() ? ColorNoThemeBackgroundPane.class : ColorBackgroundPane.class); this.initComponents(); this.setPreferredSize(new Dimension(400, 300)); } - protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/ColorBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/ColorBackgroundPane.java index 62a08a948a..37fef6e613 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/impl/ColorBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/ColorBackgroundPane.java @@ -19,10 +19,14 @@ public class ColorBackgroundPane extends BackgroundDetailPane { public ColorBackgroundPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - detailColorSelectPane = new DetailColorSelectPane(); + detailColorSelectPane = createColorSelectPane(); this.add(detailColorSelectPane, BorderLayout.CENTER); } + protected DetailColorSelectPane createColorSelectPane(){ + return new DetailColorSelectPane(); + } + public void populate(Background background) { if (background instanceof ColorBackground) { ColorBackground colorBackgroud = (ColorBackground) background; diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/ColorNoThemeBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/ColorNoThemeBackgroundPane.java new file mode 100644 index 0000000000..01ee19a67e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/ColorNoThemeBackgroundPane.java @@ -0,0 +1,10 @@ +package com.fr.design.style.background.impl; + +import com.fr.design.style.color.DetailColorSelectPane; + +public class ColorNoThemeBackgroundPane extends ColorBackgroundPane{ + + protected DetailColorSelectPane createColorSelectPane(){ + return new DetailColorSelectPane(false); + } +} diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java index fcdc594b5f..2903df72f4 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java @@ -202,10 +202,7 @@ public class ColorAdjustPane extends JPanel implements UIObserver { public JPanel initWindowPane(double preferredWidth) { // 下拉的时候重新生成面板,刷新最近使用颜色 - ColorSelectPane colorPane = new ColorSelectPane(false) { - public void setVisible(boolean b) { - super.setVisible(b); - } + NewColorSelectPane colorPane = new NewColorSelectPane(false) { protected boolean selectRealTime() { return false; @@ -214,7 +211,7 @@ public class ColorAdjustPane extends JPanel implements UIObserver { colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { hidePopupMenu(); - Color color = ((ColorSelectPane) e.getSource()).getColor(); + Color color = ((NewColorSelectPane) e.getSource()).getColor(); fireDisplayComponent(ColorBackground.getInstance(color)); if(colorButtons.size() < MAX_BUTTON) { colorButtons.add(createColorButton(color)); diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java b/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java index a052f99f13..02e113b7ab 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java @@ -34,7 +34,7 @@ public class ColorButton extends AbstractSelectBox { private boolean isMoveOn = false; - private ColorSelectPane colorPane; + private NewColorSelectPane colorPane; private boolean lastButton; @@ -121,11 +121,7 @@ public class ColorButton extends AbstractSelectBox { public JPanel initWindowPane(double preferredWidth) { // 下拉的时候重新生成面板,刷新最近使用颜色 - colorPane = new ColorSelectPane(false) { - @Override - public void setVisible(boolean b) { - super.setVisible(b); - } + colorPane = new NewColorSelectPane(false) { @Override protected boolean selectRealTime() { @@ -135,7 +131,7 @@ public class ColorButton extends AbstractSelectBox { colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { hidePopupMenu(); - color = ((ColorSelectPane) e.getSource()).getColor(); + color = ((NewColorSelectPane) e.getSource()).getColor(); fireDisplayComponent(ColorBackground.getInstance(color)); ColorButton.this.stateChanged(); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java index 4ee3a119ea..43f994a65b 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java @@ -58,15 +58,19 @@ public abstract class ColorControlWindow extends JPopupMenu { } protected void initSelectionPopupPane(boolean isSupportTransparent) { - selectionPopupPane = new ColorSelectionPopupPane(isSupportTransparent); + selectionPopupPane = new ColorSelectionPopupPane(isSupportTransparent, supportThemeColor()); this.add(selectionPopupPane, BorderLayout.CENTER); } + protected boolean supportThemeColor(){ + return true; + } + class ColorSelectionPopupPane extends NewColorSelectPane { private static final long serialVersionUID = 7822856562329146354L; - public ColorSelectionPopupPane(boolean isSupportTransparent) { - super(isSupportTransparent); + public ColorSelectionPopupPane(boolean isSupportTransparent, boolean isSupportThemeColor) { + super(isSupportTransparent, isSupportThemeColor); this.addChangeListener(new ChangeListener() { @Override @@ -77,7 +81,7 @@ public abstract class ColorControlWindow extends JPopupMenu { } @Override - protected void doTransparent() { + public void doTransparent() { popupHider.hidePopupMenu(); super.doTransparent(); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java index cbb0e97eaa..b12d95e4e4 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java @@ -61,7 +61,7 @@ public abstract class ColorControlWindowWithAuto extends ColorControlWindow { }); } - protected void doTransparent() { + public void doTransparent() { getPopupHider().hidePopupMenu(); setColor(null); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java index d2a8245445..e8e1f9f9bb 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java @@ -17,7 +17,7 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv private static final long serialVersionUID = 2782150678943960557L; private Color color; - private ColorSelectPane colorPane; + private NewColorSelectPane colorPane; private UIObserverListener uiObserverListener; public ColorSelectBox(int preferredWidth) { @@ -40,12 +40,8 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv } } - protected ColorSelectPane getColorSelectPane(){ - return new ColorSelectPane() { - public void setVisible(boolean b) { - super.setVisible(b); - } - }; + protected NewColorSelectPane getColorSelectPane(){ + return new NewColorSelectPane(); } /** @@ -59,7 +55,7 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { hidePopupMenu(); - color = ((ColorSelectPane) e.getSource()).getColor(); + color = ((NewColorSelectPane) e.getSource()).getColor(); fireDisplayComponent(ColorBackground.getInstance(color)); } }); diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java index 13d8998222..3756fc627e 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java @@ -36,6 +36,10 @@ public class ColorSelectDetailPane extends BasicPane { return selectedPanel; } + private SwatchChooserPanel swatchChooserPanel; + + private CustomChooserPanel customChooserPanel; + public void setSelectedPanel(JColorChooser selectedPanel) { this.selectedPanel = selectedPanel; } @@ -69,9 +73,9 @@ public class ColorSelectDetailPane extends BasicPane { selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), SELECT_PANEL_HEIGHT)); selectedPanel.setPreviewPanel(new JPanel()); - AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel(); - AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel(); - selectedPanel.setChooserPanels(new AbstractColorChooserPanel[]{swatchChooserPanel, customChooserPanel}); + swatchChooserPanel = new SwatchChooserPanel(); + customChooserPanel = new CustomChooserPanel(); + selectedPanel.setChooserPanels(new AbstractColorChooserPanel[]{customChooserPanel, swatchChooserPanel}); this.add(selectedPanel, BorderLayout.NORTH); // 最近使用面板 @@ -98,4 +102,8 @@ public class ColorSelectDetailPane extends BasicPane { previewPanel.add(colorChooserPreview); this.add(previewPanel, BorderLayout.SOUTH); } + + public void populate(Color color){ + customChooserPanel.setColor(color); + } } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java index 33eb6dbf15..56bc9aa655 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java @@ -77,6 +77,7 @@ public class ColorSelectDialog extends MiddleChartDialog{ this.okListener = (ColorTracker) okListener; this.seletePane = seletePane; initComponent(); + this.pane.populate(initialColor); } private void initComponent() { diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java index 68c1b2b992..452c5fe30a 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java @@ -30,6 +30,7 @@ import java.awt.event.MouseEvent; /** * The pane used to select color */ +@Deprecated public class ColorSelectPane extends TransparentPane implements ColorSelectable { private static final long serialVersionUID = -8634152305687249392L; diff --git a/designer-base/src/main/java/com/fr/design/style/color/DetailColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/DetailColorSelectPane.java index 4245c1293b..5d7e81487e 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/DetailColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/DetailColorSelectPane.java @@ -29,10 +29,14 @@ import com.fr.design.dialog.BasicPane; * Often used for foreground selection. */ public class DetailColorSelectPane extends BasicPane { - private ColorSelectPane colorSelectPane; + private NewColorSelectPane colorSelectPane; private UILabel colorPreviewLabel; - public DetailColorSelectPane() { + public DetailColorSelectPane(){ + this(true); + } + + public DetailColorSelectPane(boolean supportTheme) { this.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -44,7 +48,7 @@ public class DetailColorSelectPane extends BasicPane { defaultPane.add(Box.createHorizontalStrut(4)); JPanel colorSelectContainPane =FRGUIPaneFactory.createBorderLayout_L_Pane(); defaultPane.add(colorSelectContainPane); - colorSelectPane = new ColorSelectPane(); + colorSelectPane = NewColorSelectPane.createColorSelectPaneWithTheme(supportTheme); colorSelectContainPane.add(colorSelectPane, BorderLayout.NORTH); defaultPane.add(Box.createHorizontalStrut(8)); diff --git a/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java b/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java new file mode 100644 index 0000000000..62cc4e340d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java @@ -0,0 +1,24 @@ +package com.fr.design.style.color; + +import com.fr.base.FineColor; + +import java.awt.Color; + +public class FineColorCell extends ColorCell { + private final int x; + private final int y; + + public FineColorCell(Color color, ColorSelectable colorSelectable, int x, int y) { + super(color, colorSelectable); + this.x = x; + this.y = y; + } + + public Color getColor() { + Color color = super.getColor(); + FineColor fineColor = new FineColor(x, y, color); + return fineColor; + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectBox.java b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectBox.java index 4f291c6398..3ac7eff79a 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectBox.java +++ b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectBox.java @@ -20,7 +20,7 @@ public class NewColorSelectBox extends AbstractSelectBox implements UIObs private static final long serialVersionUID = 2782150678943960557L; private Color color; - private NewColorSelectPane colorPane = new NewColorSelectPane(); + private NewColorSelectPane colorPane = new NewColorSelectPane(false); private UIObserverListener uiObserverListener; private String newColorSelectBoxName = ""; private GlobalNameListener globalNameListener = null; @@ -58,7 +58,7 @@ public class NewColorSelectBox extends AbstractSelectBox implements UIObs */ public JPanel initWindowPane(double preferredWidth) { // 下拉的时候重新生成面板,以刷新最近使用颜色 - colorPane = new NewColorSelectPane(); + colorPane = new NewColorSelectPane(false); colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { hidePopupMenu(); diff --git a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java index 6c21c10cba..96378e7fe4 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java @@ -1,16 +1,18 @@ package com.fr.design.style.color; +import com.fr.base.FineColor; import com.fr.design.DesignerEnvManager; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import javax.swing.BorderFactory; -import javax.swing.Box; +import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -19,8 +21,6 @@ import java.awt.Color; import java.awt.Cursor; import java.awt.Dimension; import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -32,57 +32,67 @@ import java.util.ArrayList; */ public class NewColorSelectPane extends BasicPane implements ColorSelectable { private static final long serialVersionUID = -8634152305687249392L; + private static final float BRIGHTNESS_VALUE = 0.15F; + private static final float PURITY_VALUE = 0.1F; - private Color color = null; // color + private FineColor color = null; // color // color setting action. - private ArrayList colorChangeListenerList = new ArrayList(); + private final ArrayList colorChangeListenerList = new ArrayList<>(); // 是否支持透明 private boolean isSupportTransparent; + private boolean isSupportThemeColor; + public final static int TRANSPARENT_WINDOW_HEIGHT = 165; public final static int WINDOW_HEIGHT = 150; // 最近使用颜色 - private UsedColorPane usedColorPane; + private final NewUsedColorPane usedColorPane; + + public static NewColorSelectPane createColorSelectPaneWithTheme(boolean supportTheme){ + return new NewColorSelectPane(true, supportTheme); + } /** * Constructor. */ public NewColorSelectPane() { - this(false); + this(true); + } + + public NewColorSelectPane(boolean isSupportTransparent) { + this(isSupportTransparent, true); } /** * Constructor. */ - NewColorSelectPane(boolean isSupportTransparent) { + public NewColorSelectPane(boolean isSupportTransparent, boolean isSupportThemeColor) { + this.isSupportThemeColor = isSupportThemeColor; initSelectButton(isSupportTransparent); - // center JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0 ,4)); this.add(centerPane, BorderLayout.CENTER); - // 第一行 - JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); - row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); - row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7 - centerPane.add(row1Pane); - // 最近使用 - usedColorPane = new UsedColorPane(1, 8, 1, this, true, false); - usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); - row1Pane.add(usedColorPane.getPane()); - - JPanel menuColorPane1 = new JPanel(); + JPanel menuColorPane1 = getMenuColorPane(); centerPane.add(menuColorPane1); - - menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1)); - menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); - for (int i = 0; i < ColorFactory.MenuColors.length; i++) { - menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this)); + if(isSupportThemeColor){ + initThemeColorPane(menuColorPane1); + }else { + initMenuColorPane(menuColorPane1); } - centerPane.add(Box.createVerticalStrut(1)); + // 增加最近使用 pane + JPanel row1Pane = new JPanel(new BorderLayout(0, 5)); + row1Pane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + row1Pane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Used")), BorderLayout.NORTH); + centerPane.add(row1Pane); + // 最近使用 + usedColorPane = new NewUsedColorPane(8, this, selectRealTime()); + usedColorPane.setPreferredSize(new Dimension(168, 16)); + row1Pane.add(usedColorPane.getPane(), BorderLayout.CENTER); // mod by anchore 16/11/16 final UIButton customButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_More_Color")); @@ -99,12 +109,58 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { }); customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); - JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); - centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8)); - centerPane1.add(customButton, BorderLayout.NORTH); + JPanel centerPane1 = new JPanel(new BorderLayout(0, 0)); + centerPane1.setBorder(BorderFactory.createEmptyBorder(9, 0, 11, 0)); + centerPane1.add(customButton, BorderLayout.CENTER); + customButton.setPreferredSize(new Dimension(197, 20)); centerPane.add(centerPane1); } + private void initThemeColorPane(JPanel menuColorPane){ + menuColorPane.setLayout(new GridLayout(1, 8, 3, 0)); + //todo 暂时先写死,后续对接的时候从主体里面拿主题配色 + Color[] colorArray = new Color[]{Color.decode("#FFFFFF"), Color.decode("#CCCCCC"), + Color.decode("#E6A48A"), Color.decode("#E68A8A"), Color.gray, Color.green, Color.DARK_GRAY, Color.CYAN, Color.YELLOW, Color.lightGray}; + for (int i = 0; i < colorArray.length; i++) { + Color color = colorArray[i]; + boolean isDefaultColor = (i == 0 || i ==1); + JPanel jPanel = new JPanel(new GridLayout(5, 1, 0, 3)); + jPanel.add(new FineColorCell(color, this, i, 0)); + jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 1)); + jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 2)); + jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 3)); + jPanel.add(new FineColorCell(saturationDown(color, isDefaultColor), this, i, 4)); + menuColorPane.add(jPanel); + } + + } + + /** + * 调整明度和纯度,默认色只调整明度 + * @param color + * @param isDefaultColor + * @return + */ + public static Color saturationDown(Color color, boolean isDefaultColor) { + float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]); + if (!isDefaultColor) { + hsb[1] += PURITY_VALUE; + } + hsb[2] -= BRIGHTNESS_VALUE; + return Color.getHSBColor(hsb[0], hsb[1], hsb[2]); + } + + private void initMenuColorPane(JPanel menuColorPane){ + menuColorPane.setLayout(new GridLayout(5, 8, 1, 1)); + menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); + Color[] colorArray = this.getColorArray(); + for (int i = 0; i < colorArray.length; i++) { + Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i]; + menuColorPane.add(new ColorCell(color, this)); + } + + } + public boolean isSupportTransparent() { return isSupportTransparent; } @@ -113,6 +169,10 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { isSupportTransparent = supportTransparent; } + protected boolean selectRealTime() { + return true; + } + protected void initSelectButton(boolean isSupportTransparent){ this.isSupportTransparent = isSupportTransparent; this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -120,21 +180,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { if (isSupportTransparent) { UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); this.add(transparentButton, BorderLayout.NORTH); - transparentButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - doTransparent(); - } - }); + transparentButton.addActionListener(e -> doTransparent()); } } /** * 添加监听 - * - * @param 监听列表 Add change listener. + * @param changeListener 监听 */ public void addChangeListener(ChangeListener changeListener) { this.colorChangeListenerList.add(changeListener); @@ -151,7 +204,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { * @return 颜色 * Return the color. */ - public Color getColor() { + public FineColor getColor() { return color; } @@ -163,7 +216,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { public Color getNotNoneColor() { if (color == null) { setColor(Color.WHITE); - return Color.WHITE; } return color; } @@ -175,27 +227,33 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { */ @Override public void setColor(Color color) { - this.color = color; + FineColor fineColor; + if (color == null) { + fineColor = null; + } else { + fineColor = color instanceof FineColor ? (FineColor) color : new FineColor(color); + } + setFineColor(fineColor); + } + + private void setFineColor(FineColor fineColor){ + this.color = fineColor; // fire color change. if (!colorChangeListenerList.isEmpty()) { ChangeEvent evt = new ChangeEvent(this); - for (int i = 0; i < colorChangeListenerList.size(); i++) { - this.colorChangeListenerList.get(i).stateChanged(evt); + for (ChangeListener changeListener : colorChangeListenerList) { + changeListener.stateChanged(evt); } } DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); this.repaint(); } - /** - * 设置颜色 - * - * @param 颜色位置 - */ @Override public void colorSetted(ColorCell colorCell) { + this.updateUsedColor(); colorCell.repaint(); } @@ -203,18 +261,28 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { setColor(null); } + protected Color[] getColorArray() { + return ColorFactory.MenuColors; + } + + protected JPanel getMenuColorPane() { + return new JPanel(); + } + + protected void customButtonPressed() { // 颜色选择器 ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); + Color color = getColor() == null ? Color.WHITE : getColor().getColor(); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, color, this); } @Override public Dimension getPreferredSize() { if (isSupportTransparent) { - return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT); + return new Dimension(197, 207); } - return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT); + return new Dimension(197, 192); } /** @@ -224,5 +292,72 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { usedColorPane.updateUsedColor(); } + class NewUsedColorPane extends BasicPane { + + // 最近使用面板列数 + private int columns; + + // 最近使用面板 + private JPanel pane; + + private ColorSelectable selectable; + + private boolean setColorRealTime; + + public JPanel getPane(){ + return this.pane; + } + + + public NewUsedColorPane(int columns, ColorSelectable selectable, boolean setColorRealTime){ + this.columns = columns; + this.selectable = selectable; + this.setColorRealTime = setColorRealTime; + initialComponents(); + } + + + private void initialComponents() { + int total = columns; + JPanel panel = new JPanel(); + panel.setLayout(new GridLayout(1, columns + 2, 3, 3)); + panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + //最近使用颜色 + Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors(); + int size = colors.length; + for (int i = 0; i < total; i++) { + Color color = i < size ? colors[size - i - 1] : + UsedColorPane.DEFAULT_COLOR; + panel.add(new ColorCell(color == null ? UsedColorPane.DEFAULT_COLOR : color, selectable)); + } + // 取色按钮 + JButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime); + panel.add(pickColorButton); + + ColorCell cc = new ColorCell(UsedColorPane.DEFAULT_COLOR, selectable); + cc.setVisible(false); + panel.add(cc); + this.pane = panel; + } + + /** + * 更新最近使用颜色 + */ + public void updateUsedColor() { + int total = columns ; + Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors(); + int size = colors.length; + for (int i = 0; i < total; i++) { + ColorCell cell = (ColorCell) this.pane.getComponent(i); + Color color = i < size ? colors[size - i - 1] : UsedColorPane.DEFAULT_COLOR; + cell.setColor(color == null ? UsedColorPane.DEFAULT_COLOR : color); + } + } + + @Override + protected String title4PopupWindow() { + return null; + } + } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java index ba0b032411..33498d39a0 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.chart.gui; import com.fr.design.style.color.ColorSelectBox; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; /** * Created by Fangjie on 2016/4/8. @@ -14,7 +14,7 @@ public class ColorSelectBoxWithOutTransparent extends ColorSelectBox { @Override - protected ColorSelectPane getColorSelectPane(){ + protected NewColorSelectPane getColorSelectPane(){ return new ColorSelectPaneWithOutTransparent(); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java index beab8a7a5f..81c31661f8 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java @@ -1,8 +1,7 @@ package com.fr.design.mainframe.chart.gui; import com.fr.chart.base.ChartConstants; -import com.fr.design.style.color.ColorCell; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; import javax.swing.*; import java.awt.*; @@ -10,23 +9,12 @@ import java.awt.*; /** * Created by Fangjie on 2016/4/8. */ -public class ColorSelectPaneWithOutTransparent extends ColorSelectPane { +public class ColorSelectPaneWithOutTransparent extends NewColorSelectPane { public ColorSelectPaneWithOutTransparent(){ super(false); } - public void initCenterPaneChildren(JPanel centerPane) { - JPanel menuColorPane1 = new JPanel(); - centerPane.add(menuColorPane1); - menuColorPane1.setLayout(new GridLayout(3, 8, 5, 5)); - for (int i = 0; i < ChartConstants.MAP_COLOR_ARRAY.length; i++) { - menuColorPane1.add(new ColorCell(ChartConstants.MAP_COLOR_ARRAY[i], this)); - } - centerPane.add(Box.createVerticalStrut(5)); - centerPane.add(new JSeparator()); - } - protected Color[] getColorArray(){ return ChartConstants.MAP_COLOR_ARRAY; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane4Map.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane4Map.java index 8606ffab9d..217b01d8b8 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane4Map.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane4Map.java @@ -2,15 +2,10 @@ package com.fr.design.mainframe.chart.gui.style.series; import com.fr.chart.base.ChartConstants; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorSelectBox; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; -import javax.swing.Box; -import javax.swing.JPanel; -import javax.swing.JSeparator; import java.awt.Color; -import java.awt.GridLayout; /** * Created by IntelliJ IDEA. @@ -27,23 +22,12 @@ public class UIColorPickerPane4Map extends UIColorPickerPane { return new ColorSelectBox4Map(100); } - private class ColorSelectPane4Map extends ColorSelectPane { + private class ColorSelectPane4Map extends NewColorSelectPane { public ColorSelectPane4Map(){ super(false); } - public void initCenterPaneChildren(JPanel centerPane) { - JPanel menuColorPane1 = new JPanel(); - centerPane.add(menuColorPane1); - menuColorPane1.setLayout(new GridLayout(5, 8, 5, 5)); - for (int i = 0; i < ChartConstants.MAP_COLOR_ARRAY.length; i++) { - menuColorPane1.add(new ColorCell(ChartConstants.MAP_COLOR_ARRAY[i], this)); - } - centerPane.add(Box.createVerticalStrut(5)); - centerPane.add(new JSeparator()); - } - protected Color[] getColorArray(){ return ChartConstants.MAP_COLOR_ARRAY; } @@ -54,7 +38,7 @@ public class UIColorPickerPane4Map extends UIColorPickerPane { super(preferredWidth); } - protected ColorSelectPane getColorSelectPane(){ + protected NewColorSelectPane getColorSelectPane(){ return new ColorSelectPane4Map(); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/server/ServerConfigManagerAction.java b/designer-realize/src/main/java/com/fr/design/actions/server/ServerConfigManagerAction.java index 601605418c..daca25ae4a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/server/ServerConfigManagerAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/server/ServerConfigManagerAction.java @@ -3,7 +3,6 @@ */ package com.fr.design.actions.server; -import com.fr.base.svg.IconUtils; import com.fr.config.Configuration; import com.fr.config.ServerPreferenceConfig; import com.fr.design.actions.UpdateAction; @@ -20,6 +19,8 @@ import com.fr.web.attr.ReportWebAttr; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; /** * Server Config Manager @@ -41,6 +42,7 @@ public class ServerConfigManagerAction extends UpdateAction { * @param e 事件 */ public void actionPerformed(ActionEvent e) { + DesignerContext.getDesignerFrame().setServerConfig(true); final ServerPreferenceConfig config = ServerPreferenceConfig.getInstance(); final EditReportServerParameterPane editReportServerParameterPane = new EditReportServerParameterPane() { @Override @@ -69,7 +71,13 @@ public class ServerConfigManagerAction extends UpdateAction { return new Class[]{ReportWebAttr.class, ServerPreferenceConfig.class}; } }); - + } + }); + editReportServerParameterDialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + super.windowClosed(e); + DesignerContext.getDesignerFrame().setServerConfig(false); } }); editReportServerParameterDialog.setVisible(true); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java index 25ba62708c..06b1671675 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java @@ -9,6 +9,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UINoThemeColorButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -76,7 +77,7 @@ public class WriteToolBarPane extends AbstractEditToolBarPane { colorBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Face_Write_Current_Edit_Row_Background") + ":"); colorBox.setSelected(false); colorBox.addActionListener(colorListener); - colorButton = new UIColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/background.png")); + colorButton = new UINoThemeColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/background.png")); northPane.add(GUICoreUtils.createFlowPane(new Component[]{colorBox, colorButton}, FlowLayout.LEFT)); unloadCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unload_Check"));