From 64c33589da5a5aca6d74fa70848abd5d3851d4c6 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 7 Sep 2021 19:06:54 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-58036=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E5=8F=91=E5=B8=83=E5=89=8D=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9A=84=E6=B5=8B=E8=AF=95=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=8E=BB=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 11.0版本需要以插件形式发布导出和清除按钮 【改动思路】 同上 --- .../dialog/TemplateThemeManageDialog.java | 57 +++++++++++++++--- .../dialog/TemplateThemeProfileDialog.java | 58 ++++++++++++++----- .../AbstractThemeManageActionProvider.java | 23 ++++++++ .../AbstractThemeProfileActionProvider.java | 23 ++++++++ .../provider/ThemeManageActionProvider.java | 28 +++++++++ .../provider/ThemeProfileActionProvider.java | 27 +++++++++ 6 files changed, 191 insertions(+), 25 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/theme/provider/AbstractThemeManageActionProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/theme/provider/AbstractThemeProfileActionProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/theme/provider/ThemeManageActionProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/theme/provider/ThemeProfileActionProvider.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java index f306fcacfc..0049092a01 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java @@ -1,17 +1,20 @@ package com.fr.design.mainframe.theme.dialog; import com.fr.base.theme.FormTheme; +import com.fr.base.theme.FormThemeConfig; import com.fr.base.theme.ReportTheme; +import com.fr.base.theme.ReportThemeConfig; import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateThemeConfig; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.JTemplate; -import com.fr.design.mainframe.theme.TemplateThemeListPane; import com.fr.design.mainframe.theme.TemplateThemeManagePane; +import com.fr.design.mainframe.theme.provider.ThemeManageActionProvider; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -20,6 +23,9 @@ import java.awt.Dimension; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; /** * @author Starryi @@ -35,7 +41,37 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog { TemplateThemeManageDialogContentPane.CONTENT_WIDTH, TemplateThemeManageDialogContentPane.CONTENT_HEIGHT); contentPane = new TemplateThemeManageDialogContentPane(); - setContentPane(createDialogContentPane(contentPane, new UIButton[]{ createCompleteButton() })); + setContentPane(createDialogContentPane(contentPane, createActionButtons())); + } + + @Override + public void exit(){ + contentPane.exit(); + super.exit(); + } + + private UIButton[] createActionButtons() { + List uiButtonList = new ArrayList<>(); + + Set providers = ExtraDesignClassManager.getInstance().getArray(ThemeManageActionProvider.MARK_STRING); + for (ThemeManageActionProvider provider : providers) { + uiButtonList.add(provider.createButton(new ThemeManageActionProvider.ThemeManageActionContext() { + + @Override + public TemplateThemeDialog getDialog() { + return TemplateThemeManageDialog.this; + } + + @Override + public TemplateThemeConfig getConfig() { + return contentPane.getConfig(); + } + })); + } + + uiButtonList.add(createCompleteButton()); + + return uiButtonList.toArray(new UIButton[]{}); } private UIButton createCompleteButton() { @@ -49,16 +85,11 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog { return button; } - @Override - public void exit(){ - contentPane.exit(); - super.exit(); - } - public static class TemplateThemeManageDialogContentPane extends JPanel { public static final int CONTENT_WIDTH = TemplateThemeManagePane.CONTENT_WIDTH + 24; public static final int CONTENT_HEIGHT = TemplateThemeManagePane.CONTENT_HEIGHT + 40; + private final UITabbedPane tabbedPane; private final TemplateThemeManagePane formThemesManagerPane; private final TemplateThemeManagePane reportThemesManagerPane; @@ -67,7 +98,7 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog { setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); - UITabbedPane tabbedPane = new UITabbedPane(); + tabbedPane = new UITabbedPane(); add(tabbedPane, BorderLayout.NORTH); formThemesManagerPane = TemplateThemeManagePane.createFormThemesManagerPane(); @@ -88,6 +119,14 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog { } } + public TemplateThemeConfig getConfig() { + if (tabbedPane.getSelectedIndex() == 0) { + return FormThemeConfig.getInstance(); + } else { + return ReportThemeConfig.getInstance(); + } + } + public void exit() { formThemesManagerPane.stopListenThemeConfig(); formThemesManagerPane.stopAsyncFetchTheme(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java index 0ddabe0762..3a6a9d3838 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java @@ -1,10 +1,12 @@ package com.fr.design.mainframe.theme.dialog; import com.fr.base.theme.TemplateTheme; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.theme.TemplateThemeProfilePane; +import com.fr.design.mainframe.theme.provider.ThemeProfileActionProvider; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -13,7 +15,9 @@ import java.awt.Dimension; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * @author Starryi @@ -34,26 +38,11 @@ public class TemplateThemeProfileDialog extends Templat content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); content.add(profilePane, BorderLayout.CENTER); - setContentPane(createDialogContentPane(content, new UIButton[]{ - profilePane.createSaveButton(), - profilePane.createSaveAsButton(this), - createCancelButton() - })); + setContentPane(createDialogContentPane(content, createActionButtons(profilePane))); currentVisibleProfilePane = profilePane; } - private UIButton createCancelButton() { - UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - exit(); - } - }); - return button; - } - @Override public void exit() { currentVisibleProfilePane = null; @@ -74,4 +63,41 @@ public class TemplateThemeProfileDialog extends Templat protected int getPaddingVertical(){ return PADDING_VERTICAL; } + + + private UIButton[] createActionButtons(final TemplateThemeProfilePane profilePane) { + List uiButtonList = new ArrayList<>(); + + Set providers = ExtraDesignClassManager.getInstance().getArray(ThemeProfileActionProvider.MARK_STRING); + for (ThemeProfileActionProvider provider : providers) { + uiButtonList.add(provider.createButton(new ThemeProfileActionProvider.ThemeProfileActionContext() { + @Override + public TemplateThemeDialog getDialog() { + return TemplateThemeProfileDialog.this; + } + + @Override + public TemplateThemeProfilePane getProfilePane() { + return profilePane; + } + })); + } + + uiButtonList.add(profilePane.createSaveButton()); + uiButtonList.add(profilePane.createSaveAsButton(TemplateThemeProfileDialog.this)); + uiButtonList.add(createCancelButton()); + + return uiButtonList.toArray(new UIButton[]{}); + } + + private UIButton createCancelButton() { + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + exit(); + } + }); + return button; + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/AbstractThemeManageActionProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/AbstractThemeManageActionProvider.java new file mode 100644 index 0000000000..6d9744693c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/AbstractThemeManageActionProvider.java @@ -0,0 +1,23 @@ +package com.fr.design.mainframe.theme.provider; + +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/9/7 + */ +@API(level = ThemeManageActionProvider.CURRENT_LEVEL) +public abstract class AbstractThemeManageActionProvider extends AbstractProvider implements ThemeManageActionProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/AbstractThemeProfileActionProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/AbstractThemeProfileActionProvider.java new file mode 100644 index 0000000000..0ff446e800 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/AbstractThemeProfileActionProvider.java @@ -0,0 +1,23 @@ +package com.fr.design.mainframe.theme.provider; + +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/9/7 + */ +@API(level = ThemeProfileActionProvider.CURRENT_LEVEL) +public abstract class AbstractThemeProfileActionProvider extends AbstractProvider implements ThemeProfileActionProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/ThemeManageActionProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/ThemeManageActionProvider.java new file mode 100644 index 0000000000..fd9f452f56 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/ThemeManageActionProvider.java @@ -0,0 +1,28 @@ +package com.fr.design.mainframe.theme.provider; + +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.theme.dialog.TemplateThemeDialog; +import com.fr.stable.fun.mark.Mutable; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/9/7 + */ +public interface ThemeManageActionProvider extends Mutable { + + String MARK_STRING = "ThemeManageActionProvider"; + + int CURRENT_LEVEL = 1; + + UIButton createButton(ThemeManageActionContext context); + + interface ThemeManageActionContext { + + TemplateThemeDialog getDialog(); + + TemplateThemeConfig getConfig(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/ThemeProfileActionProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/ThemeProfileActionProvider.java new file mode 100644 index 0000000000..cabf0a13a3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/provider/ThemeProfileActionProvider.java @@ -0,0 +1,27 @@ +package com.fr.design.mainframe.theme.provider; + +import com.fr.base.theme.TemplateTheme; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.theme.TemplateThemeProfilePane; +import com.fr.design.mainframe.theme.dialog.TemplateThemeDialog; +import com.fr.stable.fun.mark.Mutable; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/9/7 + */ +public interface ThemeProfileActionProvider extends Mutable { + + String MARK_STRING = "ThemeProfileActionProvider"; + + int CURRENT_LEVEL = 1; + + UIButton createButton(ThemeProfileActionContext context); + + interface ThemeProfileActionContext { + TemplateThemeDialog getDialog(); + + TemplateThemeProfilePane getProfilePane(); + } +}