From 4b8366749a5f821db116db9eb1509bee4b8027a4 Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 27 Aug 2021 16:28:12 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-58289=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E7=BC=A9=E7=95=A5=E5=9B=BE=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 删除无用的白色背景 【改动思路】 同上 --- .../fr/design/mainframe/theme/TemplateThemePreviewPane.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java index 68c858f27..ef9ad4469 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java @@ -63,10 +63,6 @@ public abstract class TemplateThemePreviewPane extends g2d.dispose(); g2d = image.createGraphics(); - // 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image, - // 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0) - // 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图 - g2d.setColor(new Color(255, 255, 255, 1)); g2d.fillRect(0, 0, width, height); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); From 9810eb255a72d4589acefc1cebc943e443056e28 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 27 Aug 2021 19:51:03 +0800 Subject: [PATCH 2/7] =?UTF-8?q?REPORT-58225=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E9=99=A4=E5=9B=BE=E8=A1=A8=E5=A4=96?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=B8=90=E5=8F=98=E8=89=B2=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E6=89=93=E5=BC=80=E9=A2=9C=E8=89=B2=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/detail/ColorFillStylePane.java | 8 +-- .../edit/chart/ChartSeriesStylePane.java | 6 +-- .../gradient/FixedGradientBarNoTheme.java | 39 ++++++++++++++ .../gradient/FixedGradientBarWithPopMenu.java | 53 ------------------- .../background/gradient/GradientBar.java | 45 ++++++++++------ 5 files changed, 74 insertions(+), 77 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java delete mode 100644 designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarWithPopMenu.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java index 9e2a0d5ef..823dd6ff3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java @@ -15,7 +15,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.style.background.gradient.FixedGradientBar; +import com.fr.design.style.background.gradient.FixedGradientBarNoTheme; import com.fr.design.style.color.ColorAdjustPane; import com.fr.stable.StringUtils; @@ -40,7 +40,7 @@ public class ColorFillStylePane extends BasicBeanPane { private ColorSchemeComboBox styleSelectBox; private JPanel customPane; private JPanel changeColorSetPane; - private FixedGradientBar colorGradient; + private FixedGradientBarNoTheme colorGradient; private CardLayout cardLayout; @@ -69,8 +69,8 @@ public class ColorFillStylePane extends BasicBeanPane { }; changeColorSetPane = new JPanel(cardLayout = new CardLayout()); - changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); - gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER}; + changeColorSetPane.add(colorGradient = new FixedGradientBarNoTheme(4, 130), "gradient"); + gradientColors = new Color[]{Color.WHITE, FixedGradientBarNoTheme.NEW_CHARACTER}; changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc"); accColors = ColorAdjustPane.DEFAULT_COLORS; cardLayout.show(changeColorSetPane, "acc"); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java index c451117bd..fbb8f6489 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java @@ -5,7 +5,7 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; -import com.fr.design.style.background.gradient.FixedGradientBarWithPopMenu; +import com.fr.design.style.background.gradient.FixedGradientBar; import java.util.List; import java.awt.Color; @@ -22,12 +22,12 @@ import java.awt.event.ActionListener; public class ChartSeriesStylePane extends AbstractChartStylePane { private UIButtonGroup colorTypeButton; - private FixedGradientBarWithPopMenu gradientBar; + private FixedGradientBar gradientBar; protected void initComponents() { colorTypeButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Custom_Color"), Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual")}); - gradientBar = new FixedGradientBarWithPopMenu(4, 130); + gradientBar = new FixedGradientBar(4, 130); initListener(); } diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java new file mode 100644 index 000000000..f3393366d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java @@ -0,0 +1,39 @@ +package com.fr.design.style.background.gradient; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.style.color.ColorSelectDetailPane; +import com.fr.design.style.color.ColorSelectDialog; + +import javax.swing.JPanel; +import java.awt.Color; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2021-08-19 + */ +public class FixedGradientBarNoTheme extends FixedGradientBar { + + + public FixedGradientBarNoTheme(int minvalue, int maxvalue) { + super(minvalue, maxvalue); + } + + protected void clickButton(int select) { + ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); + Color selectColor = getList().get(select).getColorInner() == null ? Color.WHITE : getList().get(select).getColorInner(); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, FixedGradientBarNoTheme.this); + Color color = FixedGradientBarNoTheme.this.getColor(); + if (color != null) { + DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); + getList().get(select).setColorInner(color); + stateChanged(); + FixedGradientBarNoTheme.this.repaint(); + } + } + + public JPanel initWindowPane(double preWidth) { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarWithPopMenu.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarWithPopMenu.java deleted file mode 100644 index aeff7f06c..000000000 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarWithPopMenu.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.fr.design.style.background.gradient; - -import com.fr.base.background.ColorBackground; -import com.fr.design.style.color.NewColorSelectPane; - -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -/** - * @author Bjorn - * @version 10.0 - * Created by Bjorn on 2021-08-19 - */ -public class FixedGradientBarWithPopMenu extends FixedGradientBar { - - private NewColorSelectPane colorPane; - - public FixedGradientBarWithPopMenu(int minvalue, int maxvalue) { - super(minvalue, maxvalue); - } - - protected void clickButton(int select) { - setIndex(select); - showPopupMenu(); - } - - public JPanel initWindowPane(double preferredWidth) { - // 下拉的时候重新生成面板,刷新最近使用颜色 - colorPane = new NewColorSelectPane(false) { - @Override - public void setVisible(boolean b) { - super.setVisible(b); - } - - @Override - protected boolean selectRealTime() { - return false; - } - }; - colorPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - hidePopupMenu(); - setColor(((NewColorSelectPane) e.getSource()).getColor()); - getList().get(getIndex()).setColorInner(getColor()); - fireDisplayComponent(ColorBackground.getInstance(getColor())); - FixedGradientBarWithPopMenu.this.stateChanged(); - } - }); - return colorPane; - } - -} diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index e6c2e4dbd..aac5c837a 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -1,14 +1,12 @@ package com.fr.design.style.background.gradient; -import com.fr.design.DesignerEnvManager; +import com.fr.base.background.ColorBackground; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.itextfield.UINumberField; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.style.color.ColorCell; -import com.fr.design.style.color.ColorSelectDetailPane; -import com.fr.design.style.color.ColorSelectDialog; import com.fr.design.style.color.ColorSelectable; +import com.fr.design.style.color.NewColorSelectPane; import com.fr.stable.AssistUtils; import com.fr.stable.os.OperatingSystem; @@ -34,7 +32,7 @@ import java.awt.geom.Point2D; * TODO:面板缩放的功能没有考虑(就是尾值过大,导致超过界面显示的情况),原来的那个实现完全是个BUG。要缩放的情况也比较少,就干脆以后弄吧 */ public class GradientBar extends AbstractComponentPopBox implements UIObserver, ColorSelectable { - + private NewColorSelectPane colorPane; /** * */ @@ -131,20 +129,33 @@ public class GradientBar extends AbstractComponentPopBox implements UIObserver, } protected void clickButton(int select) { - ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); - Color selectColor = list.get(select).getColorInner() == null ? Color.WHITE : list.get(select).getColorInner(); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, GradientBar.this); - Color color = GradientBar.this.getColor(); - if (color != null) { - DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); - list.get(select).setColorInner(color); - stateChanged(); - GradientBar.this.repaint(); - } + setIndex(select); + showPopupMenu(); } - public JPanel initWindowPane(double preWidth) { - return null; + public JPanel initWindowPane(double preferredWidth) { + // 下拉的时候重新生成面板,刷新最近使用颜色 + colorPane = new NewColorSelectPane(false) { + @Override + public void setVisible(boolean b) { + super.setVisible(b); + } + + @Override + protected boolean selectRealTime() { + return false; + } + }; + colorPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + hidePopupMenu(); + setColor(((NewColorSelectPane) e.getSource()).getColor()); + getList().get(getIndex()).setColorInner(getColor()); + fireDisplayComponent(ColorBackground.getInstance(getColor())); + GradientBar.this.stateChanged(); + } + }); + return colorPane; } protected void addMouseDragListener() { From e08a30471164eeb45871a4a07b4e2b9cc033023b Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 27 Aug 2021 20:03:04 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/style/color/ColorControlWindowWithAuto.java | 5 +---- .../chart/gui/ColorSelectPaneWithOutTransparent.java | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) 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 b12d95e4e..4d6f45a67 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 @@ -115,10 +115,7 @@ public abstract class ColorControlWindowWithAuto extends ColorControlWindow { } public Dimension getPreferredSize() { - if (isSupportTransparent()) { - return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT + BUTTON_HEIGHT); - } - return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT + BUTTON_HEIGHT); + return super.getPreferredSize(); } } 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 81c31661f..73c9d7339 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 @@ -24,8 +24,6 @@ public class ColorSelectPaneWithOutTransparent extends NewColorSelectPane { menuColorPane.setLayout(new GridLayout(0, 8, 1, 1)); menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); - menuColorPane.setPreferredSize(new Dimension(205, 62)); - return menuColorPane; } } From 708443c19c00c45cd62b53d5f0a31fdc9820f0aa Mon Sep 17 00:00:00 2001 From: Starryi Date: Sat, 28 Aug 2021 14:25:12 +0800 Subject: [PATCH 4/7] =?UTF-8?q?REPORT-58301=20=E3=80=90=E5=86=B3=E7=AD=96?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E3=80=91=E5=B8=83=E5=B1=80=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=EF=BC=8Cbody=E8=83=8C=E6=99=AF=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=B8=8D=E4=BF=9D=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 切换布局类型时,保留body背景样式 【改动思路】 同上 --- .../ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java | 7 +++++++ .../widget/ui/designer/layout/FRFitLayoutDefinePane.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java index 31291d748..769eb2944 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java @@ -27,6 +27,7 @@ import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBodyLayoutType; +import com.fr.form.ui.container.WFitLayout; import com.fr.general.act.BorderPacker; import com.fr.report.core.ReportUtils; @@ -173,6 +174,12 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { if (state == WBodyLayoutType.FIT.getTypeValue()) { XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent()); xwFitLayout.switch2FitBodyLayout(creator); + WFitLayout wFitLayout = xwFitLayout.toData(); + // 切换布局类型时,保留body背景样式 + if (wFitLayout != null) { + wFitLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); + wFitLayout.setBorderStyle(layout.getBorderStyle()); + } copyLayoutAttr(layout, xwFitLayout.toData()); } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java index 3e23b8050..af09f027c 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java @@ -215,9 +215,13 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane Date: Sat, 28 Aug 2021 15:16:09 +0800 Subject: [PATCH 5/7] =?UTF-8?q?REPORT-58276=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E7=BB=86=E8=8A=82=E5=AE=9A=E5=88=B6?= =?UTF-8?q?-FRM=E7=BB=84=E4=BB=B6=E6=A0=B7=E5=BC=8F-=E4=B8=BB=E4=BD=93?= =?UTF-8?q?=E5=A1=AB=E5=85=85=E4=BF=AE=E6=94=B9=E5=90=8E=EF=BC=8C=E8=81=94?= =?UTF-8?q?=E5=8A=A8=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 将bodyCreator的相关绘制样式调整到XWTitleLayout前,需要 先初始化bodyCreator的绘制样式,否则调整无效 【改动思路】 同上 --- .../main/java/com/fr/design/designer/creator/XWTitleLayout.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index ed59fa9ee..1628b6cdd 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java @@ -76,7 +76,7 @@ public class XWTitleLayout extends DedicateLayoutContainer { // 初始化后(如打开旧模版),需要重新调整组件/标题/边框的显示效果 XCreator xCreator = getBodyCreator(); if (xCreator instanceof XBorderStyleWidgetCreator) { - ((XBorderStyleWidgetCreator) xCreator).reshuffleBorderAndBackgroundPaintingEffectIfTitleExists(); + ((XBorderStyleWidgetCreator) xCreator).initStyle(); } } From 8622576dcad12a65cd0672429488c438c9c27a0c Mon Sep 17 00:00:00 2001 From: Starryi Date: Sun, 29 Aug 2021 01:55:01 +0800 Subject: [PATCH 6/7] =?UTF-8?q?REPORT-58064=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E6=82=AC=E6=B5=AE=E5=85=83=E7=B4=A0?= =?UTF-8?q?-=E6=A0=B7=E5=BC=8F=E7=9A=84=E6=98=BE=E7=A4=BA=E5=90=8C?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E7=A8=BF=E4=B8=8D=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 实现表格悬浮元素样式设置面板的主题化 【改动思路】 同上 --- .../com/fr/design/report/ReportStylePane.java | 605 +++++++++++++++++- 1 file changed, 572 insertions(+), 33 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java index 558cf4291..e65e25949 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java @@ -1,52 +1,591 @@ package com.fr.design.report; -import com.fr.config.ServerPreferenceConfig; +import com.fr.base.NameStyle; +import com.fr.base.ScreenResolution; +import com.fr.base.Style; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.gui.imenu.UIMenuItem; -import com.fr.design.style.StylePane; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.ComparatorUtils; +import com.fr.design.fun.StyleUIConfigProvider; +import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.cell.settingpane.style.ThemedCellStyleListPane; +import com.fr.design.mainframe.theme.ui.NoEdgeTitleBorder; +import com.fr.design.style.AlignmentPane; +import com.fr.design.style.BorderPane; +import com.fr.design.style.BorderUtils; +import com.fr.design.style.FRFontPane; +import com.fr.design.style.FormatPane; +import com.fr.design.style.background.BackgroundPane; +import com.fr.general.FRFont; +import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.FloatSelection; +import com.fr.grid.selection.Selection; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.FloatElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.elementcase.ElementCase; +import com.fr.report.elementcase.TemplateElementCase; - -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.border.Border; +import javax.swing.border.TitledBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; -public class ReportStylePane extends StylePane { +public class ReportStylePane extends BasicPane { + public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{ + Toolkit.i18nText("Fine-Design_Style_Follow_Theme"), + Toolkit.i18nText("Fine-Design_Style_Not_Follow_Theme"), + }; + public static final int DEFAULT_SELECTED_INDEX = 0; - private static final int Y_OFFSET = 8; + private final PreviewArea previewArea; + private final UIButtonGroup followingThemeButtonGroup; + private final CustomFloatStyleSettingPane customStylePane; + private final ThemedCellStyleListPane themedCellStyleListPane; + private final CardLayout cardLayout; + private final JComponent[] panes = new JComponent[2]; + private final JPanel contentPane; public ReportStylePane() { - super(); - getPreviewArea().addMouseListener(new MouseAdapter() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); + + previewArea = new PreviewArea(); + followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + customStylePane = new CustomFloatStyleSettingPane(); + themedCellStyleListPane = new ThemedCellStyleListPane(); + panes[0] = createThemedStylePane(); + panes[1] = createCustomStylePane(); + cardLayout = new CardLayout(); + contentPane = createTabbedContentPane(); + + initializePane(); + + themedCellStyleListPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + updatePreviewArea(); + } + }); + customStylePane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + updatePreviewArea(); + } + }); + } + + private void initializePane() { + add(createPreviewPane(), BorderLayout.NORTH); + + JPanel settingContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel followingThemePane = createFollowingThemePane(); + followingThemePane.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0)); + settingContainer.add(followingThemePane, BorderLayout.NORTH); + settingContainer.add(contentPane, BorderLayout.CENTER); + + add(settingContainer, BorderLayout.CENTER); + } + + private JPanel createPreviewPane() { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setBorder(createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Preview"))); + container.setPreferredSize(new Dimension(container.getPreferredSize().width, 60)); + JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); + content.setBorder(BorderFactory.createEmptyBorder(4, 4, 2, 2)); + previewArea.setPreferredSize(new Dimension(container.getPreferredSize().width, 42)); + content.add(previewArea, BorderLayout.NORTH); + container.add(content, BorderLayout.NORTH); + return container; + } + + private JPanel createFollowingThemePane() { + followingThemeButtonGroup.setSelectedIndex(DEFAULT_SELECTED_INDEX); + followingThemeButtonGroup.addActionListener(new ActionListener() { @Override - public void mousePressed(MouseEvent evt) { - if (!SwingUtilities.isRightMouseButton(evt)) { - return; - } - - JPopupMenu popupMenu = new JPopupMenu(); - UIMenuItem menuItem = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Save_As_Global_Style")); - popupMenu.add(menuItem); - menuItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String name = FineJOptionPane.showInputDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Input_The_Name_Of_Gloabel_Style")); - if (ComparatorUtils.equals(name, "")) { - return; + public void actionPerformed(ActionEvent e) { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); + if (selectedIndex == 1) { + // 对于同一个单元格,跟随主题切换到自定义,若跟随主题面板有选中项,则自定义中的配置与其保持一致,否则自定义中配置保持不变 + NameStyle lastSelectedNameStyle = themedCellStyleListPane.updateBean(); + if (lastSelectedNameStyle != null) { + Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); + try { + lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); + if (lastSelectedRealStyle != null) { + customStylePane.populateBean(lastSelectedRealStyle); + } + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); } - if (ServerPreferenceConfig.getInstance().getStyle(name) == null) { - ServerPreferenceConfig.getInstance().putStyle(name, ReportStylePane.this.updateBean()); - } else { - FineJOptionPane.showMessageDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_This_Name_Has_Exsit") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Warning"), JOptionPane.WARNING_MESSAGE); + } + } else { + // 对于同一个单元格,自定义切换到跟随主题,跟随主题应当清除选中项,即没有选中任何主题中的单元格样式, + // 因为还未选中,所以自定义中的配置保持不变,此时若用户切换会自定义,配置应当与之前一样 + themedCellStyleListPane.populateBean(null); + } + } + }); + + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Setting")); + + double p = TableLayout.PREFERRED; + + return TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{ new Component[] { uiLabel, followingThemeButtonGroup} }, + new double[] { p }, new double[] { p, 160}, + IntervalConstants.INTERVAL_L1, 0); + } + + protected JPanel createTabbedContentPane() { + JPanel contentPane = new JPanel(cardLayout) { + @Override + public Dimension getPreferredSize() { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + if (selectedIndex < 0) { + return super.getPreferredSize(); + } else { + return panes[selectedIndex].getPreferredSize(); + } + } + }; + for (int i = 0; i < FOLLOWING_THEME_STRING_ARRAYS.length; i++) { + contentPane.add(panes[i], FOLLOWING_THEME_STRING_ARRAYS[i]); + } + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[DEFAULT_SELECTED_INDEX]); + + return contentPane; + } + + private JPanel createThemedStylePane() { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setBorder(createTitleBorder(Toolkit.i18nText("Fine-Design_Style_Selecting"))); + themedCellStyleListPane.setBorder(BorderFactory.createEmptyBorder()); + UIScrollPane scrollPane = new UIScrollPane(themedCellStyleListPane); + scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 0)); + scrollPane.setPreferredSize(new Dimension(620, scrollPane.getPreferredSize().height)); + container.add(scrollPane, BorderLayout.CENTER); + return container; + } + + private JPanel createCustomStylePane() { + return customStylePane; + } + + public void setSelectedIndex(int index) { + if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) { + followingThemeButtonGroup.setSelectedIndex(index); + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]); + } + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); + } + + public int getSelectedIndex() { + return followingThemeButtonGroup.getSelectedIndex(); + } + + public void populate(ElementCasePane reportPane) { + populateBean(this.analyzeCurrentStyle(reportPane)); + updatePreviewArea(); + } + + private Style analyzeCurrentStyle(ElementCasePane reportPane) { + Style style = null; + + // p:从选中的CellElement那里先获得原始的Style. + Selection sel = reportPane.getSelection(); + if (sel instanceof FloatSelection) { + // got simple cell element from column and row. + ElementCase report = reportPane.getEditingElementCase(); + + FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection) sel).getSelectedFloatName()); + style = selectedFloatElement.getStyle(); + } else { + CellSelection cs = (CellSelection) sel; + + // got simple cell element from column and row. + ElementCase report = reportPane.getEditingElementCase(); + CellElement editCellElement = report.getCellElement(cs.getColumn(), cs.getRow()); + + if (editCellElement != null && editCellElement.getStyle() != null) {// editCellElement + // cellstyle. + try { + style = (Style) editCellElement.getStyle().clone(); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + + if (style == null) { + // peter:获取默认的Style. + style = Style.DEFAULT_STYLE; + } + + return style; + } + + public boolean update(ElementCasePane reportPane) { + return applyStyle(reportPane, updateBean()); + } + + private boolean applyStyle(ElementCasePane reportPane, Style style) { + TemplateElementCase report = reportPane.getEditingElementCase(); + Selection sel = reportPane.getSelection(); + if (sel instanceof FloatSelection) { + FloatElement floatElement = report.getFloatElement(((FloatSelection) sel).getSelectedFloatName()); + + // Apply style. + floatElement.setStyle(style); + } else { + CellSelection cs = (CellSelection) sel; + // Got editCellElement. + TemplateCellElement editCellElement; + + // 需要先行后列地增加新元素。 + for (int j = 0; j < cs.getRowSpan(); j++) { + for (int i = 0; i < cs.getColumnSpan(); i++) { + int column = i + cs.getColumn(); + int row = j + cs.getRow(); + + editCellElement = report.getTemplateCellElement(column, row); + if (editCellElement == null) { + editCellElement = new DefaultTemplateCellElement(column, row); + report.addCellElement(editCellElement); + } + + // Apply cellstyle. + editCellElement.setStyle(style); + } + } + } + + if (getSelectedIndex() == 1) { + // p:因为borderpane特殊,update borderpane + customStylePane.dealBorder(reportPane); + } + reportPane.repaint(); + return true; + } + + public Style updateBean() { + if (getSelectedIndex() == 0) { + NameStyle nameStyle = themedCellStyleListPane.updateBean(); + if (nameStyle != null) { + // 只有当前样式面板是跟随主题面板,且跟随主题面板中存在选中项,才使用该样式设置单元格 + return nameStyle; + } + } + return customStylePane.updateBean(); + } + + public void populateBean(Style style) { + if (style instanceof NameStyle) { + NameStyle nameStyle = (NameStyle) style; + setSelectedIndex(0); + themedCellStyleListPane.populateBean(nameStyle); + Style realStyle = nameStyle.getRealStyle(); + try { + realStyle = (Style) realStyle.clone(); + customStylePane.populateBean(realStyle); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + } else { + setSelectedIndex(1); + customStylePane.populateBean(style); + } + } + + public void updatePreviewArea() { + previewArea.setStyle(updateBean()); + } + + private static class PreviewArea extends JComponent { + + private static final String paintText = "Report"; + private Style style = Style.DEFAULT_STYLE; + + public void setStyle(Style style) { + this.style = style; + repaint(); + } + + @Override + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + int resolution = ScreenResolution.getScreenResolution(); + + if (style == Style.DEFAULT_STYLE) { + // 如果是默认的style,就只写"Report"上去 + Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution); + return; + } + + Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3); + + Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution); + + Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3); + } + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + } + + private static class CustomFloatStyleSettingPane extends BasicPane implements ChangeListener { + private static final int ALIGNMENT_INDEX = 1; + private static final int FONT_INDEX = 2; + private static final int BORDER_INDEX = 3; + private static final int BACKGROUND_INDEX = 4; + private static final int NEXT_TAB_INDEX = 5; + protected Style editing; + private FormatPane formatPane = null; + private AlignmentPane alignmentPane = null; + private FRFontPane frFontPane = null; + private BorderPane borderPane = null; + private BackgroundPane backgroundPane = null; + private static final List configList = PluginSandboxCollections.newSandboxList(); + private final List changeListeners = new ArrayList<>(); + + public CustomFloatStyleSettingPane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + + UITabbedPane mainTabbedPane = new UITabbedPane(); + mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Format"), this.getFormatPane()); + mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alignment"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sytle_FRFont"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + + for (StyleUIConfigProvider config : configList) { + mainTabbedPane.addTab(config.configName(), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + } + mainTabbedPane.addChangeListener(new ChangeListener() { + + public void stateChanged(ChangeEvent evt) { + Object tabObj = evt.getSource(); + if (!(tabObj instanceof JTabbedPane)) { + return; + } + JTabbedPane tabbedPane = (JTabbedPane) tabObj; + + int selectedIndex = tabbedPane.getSelectedIndex(); + if (tabbedPane.getComponentAt(selectedIndex).getClass() == JPanel.class) {// 是JPanel,需要替换 + if (selectedIndex == ALIGNMENT_INDEX) { + tabbedPane.setComponentAt(selectedIndex, getAlignmentPane()); + } else if (selectedIndex == FONT_INDEX) { + tabbedPane.setComponentAt(selectedIndex, getFRFontPane()); + } else if (selectedIndex == BORDER_INDEX) { + tabbedPane.setComponentAt(selectedIndex, getBorderPane()); + } else if (selectedIndex == BACKGROUND_INDEX) { + tabbedPane.setComponentAt(selectedIndex, getBackgroundPane()); + } else if (configList.size() + NEXT_TAB_INDEX > selectedIndex && configList.get(selectedIndex - NEXT_TAB_INDEX) != null) { + tabbedPane.setComponentAt(selectedIndex, configList.get(selectedIndex - NEXT_TAB_INDEX).uiComponent(this)); + configList.get(selectedIndex - NEXT_TAB_INDEX).populateConfig(editing); } } - }); - GUICoreUtils.showPopupMenu(popupMenu, ReportStylePane.this, evt.getX() - 1, evt.getY() + Y_OFFSET); + stateChanged(evt); + } + }); + + add(mainTabbedPane, BorderLayout.CENTER); + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListeners.add(changeListener); + } + + protected FormatPane getFormatPane() { + if (this.formatPane == null) { + this.formatPane = new FormatPane(); + if (this.editing != null) { + this.formatPane.populate(this.editing.getFormat()); + } + } + + return this.formatPane; + } + + private AlignmentPane getAlignmentPane() { + if (this.alignmentPane == null) { + this.alignmentPane = new AlignmentPane(); + this.alignmentPane.addChangeListener(this); + if (this.editing != null) { + this.alignmentPane.populate(this.editing); + } } - }); + return this.alignmentPane; + } + + private FRFontPane getFRFontPane() { + if (this.frFontPane == null) { + this.frFontPane = new FRFontPane(); + this.frFontPane.addChangeListener(this); + if (this.editing != null) { + this.frFontPane.populate(this.editing.getFRFont()); + } + } + + return this.frFontPane; + } + + private BorderPane getBorderPane() { + if (this.borderPane == null) { + this.borderPane = new BorderPane(); + this.borderPane.addChangeListener(this); + + if (this.editing != null) { + this.borderPane.populate(this.editing); + } + } + + return this.borderPane; + } + + private BackgroundPane getBackgroundPane() { + if (this.backgroundPane == null) { + this.backgroundPane = new BackgroundPane(); + this.backgroundPane.addChangeListener(this); + if (this.editing != null) { + this.backgroundPane.populate(this.editing.getBackground()); + } + } + + return this.backgroundPane; + } + + public void populateBean(Style ob) { + this.editing = ob == null ? Style.getInstance() : ob; + + if (this.formatPane != null) { + this.formatPane.populate(editing.getFormat()); + } + if (this.alignmentPane != null) { + this.alignmentPane.populate(editing); + } + if (this.frFontPane != null) { + this.frFontPane.populate(editing.getFRFont()); + } + if (this.borderPane != null) { + this.borderPane.populate(editing); + } + if (this.backgroundPane != null) { + this.backgroundPane.populate(editing.getBackground()); + } + for(StyleUIConfigProvider tabConfig : configList){ + tabConfig.populateConfig(this.editing); + } + } + + public Style updateBean() { + // need the check the valid of CellAlignment pane. + try { + if (this.alignmentPane != null) { + this.alignmentPane.checkValid(); + } + } catch (Exception exp) { + FineJOptionPane.showMessageDialog(this, exp.getMessage()); + return editing; + } + + Style style = editing; + if (this.formatPane != null) { + style = style.deriveFormat(this.formatPane.update()); + } + if (this.alignmentPane != null) { + style = this.alignmentPane.update(style); + } + if (this.frFontPane != null) { + style = style.deriveFRFont(this.frFontPane.update()); + } + if (this.borderPane != null) { + style = this.borderPane.update(style); + } + if (this.backgroundPane != null) { + style = style.deriveBackground(this.backgroundPane.update()); + } + for(StyleUIConfigProvider tabConfig : configList){ + style = tabConfig.updateConfig(); + } + + return style; + } + + public void dealBorder(ElementCasePane reportPane) { + if (this.borderPane != null) { + BorderUtils.update(reportPane, this.borderPane.update()); + } + } + + @Override + protected String title4PopupWindow() { + return null; + } + + @Override + public void stateChanged(ChangeEvent e) { + for (ChangeListener changeListener: changeListeners) { + changeListener.stateChanged(e); + } + } + } + + private Border createTitleBorder(String title) { + return new NoEdgeTitleBorder( + BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder( + 0, + 0, + 0, + 0), + new UIRoundedBorder( + UIConstants.TITLED_BORDER_COLOR, + 1, + 10) + ), + title, + TitledBorder.LEADING, + TitledBorder.TOP, + FRFont.getInstance().deriveFont(12F), + new Color(0x2F8EF1) + ); } } From 8b25ab72c94bbfaa159d07005dd30de749f1ba4e Mon Sep 17 00:00:00 2001 From: Starryi Date: Sat, 28 Aug 2021 15:20:46 +0800 Subject: [PATCH 7/7] =?UTF-8?q?REPORT-58212=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E8=BF=9C=E7=A8=8B10.0=E5=8D=87?= =?UTF-8?q?=E4=B8=8A=E6=9D=A5=E7=9A=84=E5=B7=A5=E7=A8=8B=EF=BC=8C=E7=89=B9?= =?UTF-8?q?=E5=AE=9A=E6=93=8D=E4=BD=9C=E4=B8=8B=E6=96=B0=E5=BB=BA=E7=9A=84?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E9=A2=84=E8=A7=88500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 删除无必要的本地缓存相关的代码 2. 字段数据更新后调用invalidateCache使远程服务器数据层面缓存失效,避免服务器使用了旧的错误数据 【改动思路】 同上 --- .../mainframe/theme/AsyncThemeFetcher.java | 26 +++++-------------- .../theme/TemplateThemeManagePane.java | 26 ++++++++----------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java index add47d6a0..265043283 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java @@ -34,30 +34,28 @@ public class AsyncThemeFetcher { } public void submit(String themeName, AsyncThemeFetchCallback callback) { - callback.beforeCachedFetch(); + if (callback != null) { + callback.beforeCachedFetch(); + } executorService.submit(new Runnable() { @Override public void run() { if (executorService.isShutdown()) { return; } - T theme = config.cachedFetch(themeName, new TemplateThemeConfig.CacheCondition() { - @Override - public boolean shouldCacheTheme(T theme) { - return callback.shouldCache(AsyncThemeFetcher.this, theme); - } - }); + T theme = config.cachedFetch(themeName); if (executorService.isShutdown()) { return; } - callback.afterCachedFetch(theme); + if (callback != null) { + callback.afterCachedFetch(theme); + } } }); } public interface AsyncThemeFetchCallback { void beforeCachedFetch(); - boolean shouldCache(AsyncThemeFetcher fetcher, T theme); void afterCachedFetch(T theme); } @@ -68,16 +66,6 @@ public class AsyncThemeFetcher { } - @Override - public boolean shouldCache(AsyncThemeFetcher fetcher, T theme) { - // 如果Fetcher已经关闭就不放进缓存里了 - // 因为可切换工作目录,所以submit时的工作目录环境与最终获取到主题数据时的工作目录环境可能不是同一个, - // 如果仍然放进缓存中,会污染当前工作目录环境的主题缓存. - // TODO: 除了根据asyncThemeFetch的关闭情况来判断是否缓存主题,也可以更加精细的判断前后的工作目录环境是否时同一个 - // TODO: 后续看情况再优化吧. - return !fetcher.isShutdown(); - } - @Override public void afterCachedFetch(T theme) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java index 24358a29e..8da77c378 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java @@ -191,8 +191,8 @@ public class TemplateThemeManagePane extends BasicPane MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add")); menuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); menuDef.setRePaint(true); - menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getLightThemeName4New())); - menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDarkThemeName4New())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getDefaultLightThemeName())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDefaultDarkThemeName())); return menuDef; } @@ -232,31 +232,27 @@ public class TemplateThemeManagePane extends BasicPane } private class AddThemeAction extends UpdateAction { - private T prototypeTheme; + private final String prototypeThemeName; public AddThemeAction(String name, String prototypeThemeName) { setName(name); setMnemonic('R'); - asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter() { - @Override - public void beforeCachedFetch() { - super.beforeCachedFetch(); - prototypeTheme = null; - } + this.prototypeThemeName = prototypeThemeName; + asyncThemeFetcher.submit(prototypeThemeName, null); + } + @Override + public void actionPerformed(ActionEvent e) { + asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter() { @Override public void afterCachedFetch(T theme) { super.afterCachedFetch(theme); - prototypeTheme = theme; + createNewTheme(theme); } }); } - @Override - public void actionPerformed(ActionEvent e) { - if (prototypeTheme == null) { - return; - } + private void createNewTheme(T prototypeTheme) { Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this); TemplateThemeProfileDialog profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); try {