From 7249227b0afea298be29eb4ad901c6752c93e865 Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 19 Aug 2021 15:00:56 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-51919=20=E4=B8=BB=E9=A2=98=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 新增模版主题功能 【改动思路】 同上 --- .../gui/style/ComponentTitleStylePane.java | 133 ++++++++--- .../design/gui/style/FollowingThemePane.java | 140 ++++++++++++ .../style/ReportBackgroundSpecialPane.java | 102 +++++++++ .../com/fr/design/mainframe/JTemplate.java | 5 +- .../mainframe/theme/TemplateThemeBlock.java | 53 +++-- .../theme/TemplateThemeListPane.java | 29 ++- .../theme/TemplateThemeManagePane.java | 64 +++++- .../theme/TemplateThemeProfilePane.java | 8 +- .../theme/dialog/TemplateThemeDialog.java | 6 +- .../dialog/TemplateThemeManageDialog.java | 13 ++ .../dialog/TemplateThemeUsingDialog.java | 62 ++++- .../theme/edit/ComponentStyleEditPane.java | 28 ++- .../theme/edit/FormBodyStyleEditPane.java | 2 +- .../theme/edit/ReportBodyStyleEditPane.java | 39 +++- .../theme/edit/ui/ColorListExtendedPane.java | 5 +- .../ElementEditorExtendDefinePane.java | 31 ++- .../fr/design/gui/xpane/LayoutStylePane.java | 31 ++- .../mainframe/FormCreatorDropTarget.java | 30 ++- .../layout/ChartEditorDefinePane.java | 51 +++-- .../layout/ElementEditorDefinePane.java | 29 ++- .../FRAbsoluteBodyLayoutDefinePane.java | 30 ++- .../layout/FRFitLayoutDefinePane.java | 28 ++- .../layout/WTitleLayoutDefinePane.java | 32 ++- .../report/ReportBackgroundAction.java | 13 +- .../server/TemplateThemeManagerAction.java | 7 +- .../report/NewReportBackgroundPane.java | 211 ++++++++++++++++++ .../main/java/com/fr/start/MainDesigner.java | 2 - 27 files changed, 1019 insertions(+), 165 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java create mode 100644 designer-realize/src/main/java/com/fr/design/report/NewReportBackgroundPane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java index 86fdf67a8..9e8f8dca3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java @@ -13,7 +13,6 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.WidgetTitle; import com.fr.general.FRFont; @@ -29,7 +28,6 @@ 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; import java.awt.Font; @@ -40,6 +38,7 @@ import java.awt.Font; */ public class ComponentTitleStylePane extends AbstractBorderPackerPane { private static final Dimension BUTTON_SIZE = new Dimension(20, 20); + public static final TitlePacker DEFAULT_TITLE_PACKER = new WidgetTitle(); // 标题可见 protected UICheckBox visibleCheckbox; @@ -62,22 +61,27 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { //标题整体背景 protected TitleTranslucentBackgroundSpecialPane backgroundPane; + // 是否支持用户编辑这些属性(不支持时: 设置面板总是不可见) + private boolean isSupportTitleVisible = true; + private boolean isSupportTitleContent = true; + private boolean isSupportTitleOtherSetting = true; + + // 用于控制各部分设置的可见性 + private JPanel titleVisiblePane; + private JPanel titleContentPane; + private JPanel titleOtherSettingPane; + private final int uiLabelWidth; private final int uiSettingWidth; - private final boolean supportTitleVisible; - protected final boolean supportTitleContent; public ComponentTitleStylePane(int uiLabelWidth) { - this(uiLabelWidth, -1, true, true); + this(uiLabelWidth, -1); } public ComponentTitleStylePane( - int uiLabelWidth, int uiSettingWidth, - boolean supportTitleVisible, boolean supportTitleContent) { + int uiLabelWidth, int uiSettingWidth) { this.uiLabelWidth = uiLabelWidth; this.uiSettingWidth = uiSettingWidth; - this.supportTitleVisible = supportTitleVisible; - this.supportTitleContent = supportTitleContent; this.initializePane(); } @@ -87,7 +91,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { textContentPane = new TinyFormulaPane(); fontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); - FRFont frFont = new WidgetTitle().getFrFont(); + FRFont frFont = DEFAULT_TITLE_PACKER.getFrFont(); if (frFont != null) { String fontFamily = frFont.getFamily(); // 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性 @@ -132,6 +136,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right") }); + alignPane.setSelectedItem(DEFAULT_TITLE_PACKER.getPosition()); backgroundPane = new TitleTranslucentBackgroundSpecialPane(this.uiLabelWidth, this.uiSettingWidth); } @@ -140,20 +145,21 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { this.setLayout(new BorderLayout(0, 0)); this.initializeComponents(); - JPanel titleVisiblePane = this.createTitleVisiblePane(); - JPanel detailedTitleStylePane = this.createDetailedTitleStylePane(); - detailedTitleStylePane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + titleVisiblePane = this.createTitleVisiblePane(); + titleContentPane = this.createTitleContentPane(); + titleOtherSettingPane = this.createTitleOtherSettingPane(); - if (this.supportTitleVisible) { + if (isSupportTitleVisible) { titleVisiblePane.setVisible(true); - detailedTitleStylePane.setVisible(false); - } else { - titleVisiblePane.setVisible(false); - detailedTitleStylePane.setVisible(true); + } + if (isSupportTitleVisible) { + titleContentPane.setVisible(false); + } + if (isSupportTitleVisible) { + titleOtherSettingPane.setVisible(false); } - add(titleVisiblePane, BorderLayout.NORTH, 0); - add(detailedTitleStylePane, BorderLayout.CENTER, 1); + addComponents(titleVisiblePane, titleContentPane, titleOtherSettingPane); } private JPanel createTitleVisiblePane() { @@ -167,16 +173,30 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { visibleCheckbox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - Component detailedTitleStylePane = getComponent(1); - if (detailedTitleStylePane != null) { - detailedTitleStylePane.setVisible(visibleCheckbox.isSelected()); + boolean visible = visibleCheckbox.isSelected(); + if (titleContentPane != null) { + titleContentPane.setVisible(visible && isSupportTitleContent); + } + if (titleOtherSettingPane != null) { + titleOtherSettingPane.setVisible(visible && isSupportTitleOtherSetting); } } }); return container; } - private JPanel createDetailedTitleStylePane() { + private JPanel createTitleContentPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; + + return TableLayoutHelper.createCommonTableLayoutPane( + new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}}, + rowSize, columnSize, IntervalConstants.INTERVAL_L1); + } + + private JPanel createTitleOtherSettingPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] rowSize = {p, p, p, p, p}; @@ -190,18 +210,6 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { {backgroundPane, null} }; - if (this.supportTitleContent) { - rowSize = new double[]{p, p, p, p, p, p}; - components = new JComponent[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), fontFamilyComboBox}, - {null, createTitleFontButtonPane()}, - {insetImagePane, null}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), alignPane}, - {backgroundPane, null} - }; - } - return TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, IntervalConstants.INTERVAL_L1); } @@ -225,7 +233,10 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { public void populateBean(BorderPacker style) { TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle(); widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; - visibleCheckbox.setSelected(style.getType() != LayoutBorderStyle.STANDARD); + boolean titleVisible = style != null && style.getType() != LayoutBorderStyle.STANDARD; + visibleCheckbox.setSelected(isSupportTitleContent && titleVisible); + titleContentPane.setVisible(titleVisible); + titleOtherSettingPane.setVisible(isSupportTitleOtherSetting && titleVisible); this.textContentPane.populateBean(widgetTitle.getTextObject().toString()); @@ -286,4 +297,52 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { frFont = frFont.applyStyle(italic_bold); return frFont; } + + private void addComponents(JComponent... components) { + if (components == null) { + return; + } + JPanel container = this; + for (JComponent component: components) { + if (component != null) { + container.add(component, BorderLayout.NORTH); + JPanel nextContainer = new JPanel(FRGUIPaneFactory.createBorderLayout()); + component.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + container.add(nextContainer, BorderLayout.CENTER); + container = nextContainer; + } + } + } + + + public void setSupportTitleVisible(boolean supporting) { + isSupportTitleVisible = supporting; + if (titleVisiblePane != null) { + titleVisiblePane.setVisible(supporting); + } + } + + public void setSupportTitleContent(boolean supporting) { + isSupportTitleContent = supporting; + if (titleContentPane != null) { + boolean titleVisible = visibleCheckbox.isSelected(); + if (isSupportTitleContent) { + titleContentPane.setVisible(titleVisible); + } else { + titleContentPane.setVisible(false); + } + } + } + + public void setSupportOtherSetting(boolean supporting) { + isSupportTitleOtherSetting = supporting; + if (titleOtherSettingPane != null) { + boolean titleVisible = visibleCheckbox.isSelected(); + if (isSupportTitleOtherSetting) { + titleOtherSettingPane.setVisible(titleVisible); + } else { + titleOtherSettingPane.setVisible(false); + } + } + } } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java new file mode 100644 index 000000000..9a4c4181c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java @@ -0,0 +1,140 @@ +package com.fr.design.gui.style; + +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.design.dialog.BasicPane; +import com.fr.design.event.GlobalNameListener; +import com.fr.design.event.GlobalNameObserver; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.ibutton.UIButtonGroup; +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.JTemplate; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/19 + */ +public class FollowingThemePane extends BasicPane implements UIObserver { + public static final int SETTING_LABEL_WIDTH = 60; + + 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"), + }; + + private final UIButtonGroup followingThemeButtonGroup; + private final List changeListeners = new ArrayList<>(); + private UIObserverListener uiObserverListener; + + private JPanel container; + + public FollowingThemePane(String name) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + + followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + followingThemeButtonGroup.setSelectedIndex(1); + followingThemeButtonGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + for (FollowingThemeActionChangeListener changeListener : changeListeners) { + changeListener.onFollowingTheme(isFollowingTheme()); + } + + // 与主题相关的属性面板更新完毕后,再通知外层更新数据 + if (uiObserverListener != null) { + uiObserverListener.doChange(); + } + } + }); + + UILabel followingThemeLabel = new UILabel(name); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + JPanel followingThemePane = + TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[] { followingThemeLabel, followingThemeButtonGroup}}, + new double[] { p }, new double[] { SETTING_LABEL_WIDTH, f }, 10, 0); + followingThemePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + followingThemePane.setVisible(false); + + add(followingThemePane, BorderLayout.NORTH); + container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + add(container, BorderLayout.CENTER); + } + + public void addFollowThemePane(JPanel content, FollowingThemeActionChangeListener changeListener) { + if (content != null) { + container.add(content, BorderLayout.NORTH); + changeListeners.add(changeListener); + + JPanel nextContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.add(nextContainer, BorderLayout.CENTER); + container = nextContainer; + } + } + + @Override + protected String title4PopupWindow() { + return null; + } + + @Override + public void registerChangeListener(UIObserverListener uiObserverListener) { + this.uiObserverListener = uiObserverListener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + public interface FollowingThemeActionChangeListener { + void onFollowingTheme(boolean following); + } + + public TemplateTheme getUsingTheme() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + TemplateTheme theme = template.getTemplateTheme(); + if (theme instanceof FormTheme) { + return theme; + } + } + return null; + } + + public void supportFollowingTheme(boolean supporting) { + getComponent(0).setVisible(supporting); + if (!supporting) { + setFollowingTheme(false); + } + } + + public void setFollowingTheme(boolean following) { + followingThemeButtonGroup.setSelectedIndex(following ? 0 : 1); + for (FollowingThemeActionChangeListener changeListener : changeListeners) { + changeListener.onFollowingTheme(isFollowingTheme()); + } + } + public boolean isFollowingTheme() { + return followingThemeButtonGroup.getSelectedIndex() == 0; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java new file mode 100644 index 000000000..aeb2938a2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java @@ -0,0 +1,102 @@ +package com.fr.design.gui.style; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.event.UIObserverListener; +import com.fr.design.fun.BackgroundQuickUIProvider; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.PatternBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.TextureBackgroundQuickPane; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/19 + */ +public class ReportBackgroundSpecialPane extends BackgroundPane { + public ReportBackgroundSpecialPane(){ + super(); + } + + @Override + protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { + NullBackgroundQuickPane nullBackgroundPane = new NullBackgroundQuickPane(); + + ColorBackgroundQuickPane colorBackgroundPane = new ColorBackgroundQuickPane(); + colorBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + ImageBackgroundQuickPane imageBackgroundPane = new ImageBackgroundQuickPane(); + imageBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + GradientBackgroundQuickPane gradientBackgroundPane = createGradientBackgroundQuickPane(); + gradientBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + TextureBackgroundQuickPane textureBackgroundPane = new TextureBackgroundQuickPane(); + textureBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + PatternBackgroundQuickPane patternBackgroundPane = new PatternBackgroundQuickPane(); + patternBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + + + List kinds = new ArrayList(); + + kinds.add(nullBackgroundPane); + kinds.add(colorBackgroundPane); + kinds.add(imageBackgroundPane); + kinds.add(gradientBackgroundPane); + kinds.add(textureBackgroundPane); + kinds.add(patternBackgroundPane); + + Set providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); + for (BackgroundQuickUIProvider provider : providers) { + BackgroundQuickPane newTypePane = provider.appearanceForBackground(); + newTypePane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + kinds.add(newTypePane); + } + + return kinds.toArray(new BackgroundQuickPane[kinds.size()]); + } + + protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() { + // 使用默认的150宽度构建渐变条 + return new GradientBackgroundQuickPane(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 4255f9909..f0809091c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -65,6 +65,7 @@ import com.fr.file.MemFILE; import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; @@ -1412,8 +1413,8 @@ public abstract class JTemplate> } protected UIButton createTemplateThemeButton() { - UIButton button = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); - button.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Style")); + UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); + button.setToolTipText(Toolkit.i18nText("Fine-Design_Template_Theme_Using_Dialog_Title")); button.setText(getTemplateTheme().getName()); button.setAlignmentX(SwingConstants.LEFT); button.set4ToolbarButton(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java index ba16de00a..4efcf5834 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java @@ -6,7 +6,6 @@ import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.settings.ThemeThumbnail; import com.fr.design.designer.IntervalConstants; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.JTemplate; @@ -26,8 +25,6 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Window; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; @@ -51,6 +48,8 @@ public class TemplateThemeBlock extends JPanel { private final Icon profileIcon = IOUtils.readIcon("/com/fr/design/icon/icon_edit.png"); private UILabel thumbnailLabel; + // UIButton会影响Block的手势监听,这里使用UILabel代替,点击事件也有Block代为处理 + private UILabel profileButton; private boolean selected = false; private boolean hovering = false; @@ -69,6 +68,8 @@ public class TemplateThemeBlock extends JPanel { if (clickListener != null) { clickListener.mouseClicked(e); } + + delegateProfileButtonClick(e); } @Override @@ -104,7 +105,7 @@ public class TemplateThemeBlock extends JPanel { infoPane.add(titleLabel, BorderLayout.WEST); if (profilePane != null) { - addProfileButton(infoPane, profilePane); + addProfileButton(infoPane); } add(thumbnailLabel, BorderLayout.CENTER); @@ -124,23 +125,35 @@ public class TemplateThemeBlock extends JPanel { this.clickListener = clickListener; } - private void addProfileButton(JPanel panel, TemplateThemeProfilePane profilePane) { - UIButton profileLabel = new UIButton(profileIcon); -// profileLabel.setUI(new BasicLabelUI()); - profileLabel.setBackground(null); - profileLabel.setOpaque(false); - profileLabel.setPreferredSize(new Dimension(24, 24)); - profileLabel.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Window parent = SwingUtilities.getWindowAncestor(TemplateThemeBlock.this); - TemplateThemeProfileDialog profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); - profilePane.populateBean(theme); - profileDialog.setVisible(true); - } - }); - panel.add(profileLabel, BorderLayout.EAST); + private void addProfileButton(JPanel panel) { + profileButton = new UILabel(profileIcon); + profileButton.setPreferredSize(new Dimension(24, 24)); + panel.add(profileButton, BorderLayout.EAST); + } + + private void delegateProfileButtonClick(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + int profileButtonX = profileButton.getX(); + int profileButtonY = thumbnailLabel.getHeight() + profileButton.getY(); + + boolean inX = profileButtonX <= x && x <= profileButtonX + profileButton.getWidth(); + boolean inY = profileButtonY <= y && y <= profileButtonY + profileButton.getHeight(); + if (inX && inY) { + openProfileDialog(); + } + } + + private void openProfileDialog() { + Window parent = SwingUtilities.getWindowAncestor(TemplateThemeBlock.this); + TemplateThemeProfileDialog profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); + try { + profilePane.populateBean((T) theme.clone()); + } catch (CloneNotSupportedException ex) { + ex.printStackTrace(); + } + profileDialog.setVisible(true); } public void refresh() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java index ee1795318..7cea43260 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java @@ -97,30 +97,36 @@ public class TemplateThemeListPane extends BasicPane { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); - if (selectedBlock != null) { - selectedBlock.setSelected(false); - } - selectedBlock = block; - selectedBlock.setSelected(true); - if (changeListener != null) { - changeListener.fireChanged(new ChangeEvent(selectedBlock)); - } + setSelectedBlock(block); } }); return block; } - public void setChangeListener(ChangeListener changeListener) { + public void setSelectedChangeListener(ChangeListener changeListener) { this.changeListener = changeListener; } + private void setSelectedBlock(TemplateThemeBlock block) { + if (selectedBlock != null) { + selectedBlock.setSelected(false); + } + selectedBlock = block; + if (selectedBlock != null) { + selectedBlock.setSelected(true); + } + if (changeListener != null) { + changeListener.fireChanged(new ChangeEvent(this)); + } + } + @Override protected String title4PopupWindow() { return null; } public T getSelectedTheme() { - return selectedBlock.getTheme(); + return selectedBlock != null ? selectedBlock.getTheme() : null; } public void startListenThemeConfig() { @@ -149,6 +155,9 @@ public class TemplateThemeListPane extends BasicPane { case REMOVE: { if (existingBlock != null) { contentListPane.remove(existingBlock); + if (existingBlock == selectedBlock) { + setSelectedBlock(null); + } validate(); repaint(); blockCache.remove(event.themName); 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 f62612c57..6b08b8904 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 @@ -49,7 +49,8 @@ import java.awt.event.ActionListener; * Created by Starryi on 2021/8/13 */ public class TemplateThemeManagePane extends BasicPane { - private RemoveThemeAction removeAction; + private final RemoveThemeAction removeAction; + private final UIButton setTheme4NewTemplate; private final TemplateThemeConfig config; private final TemplateThemeListPane themeListPane; @@ -71,6 +72,9 @@ public class TemplateThemeManagePane extends BasicPane this.config = config; this.profilePane = profilePane; this.themeListPane = new TemplateThemeListPane<>(config, profilePane); + this.removeAction = new RemoveThemeAction(false); + this.setTheme4NewTemplate = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting")); + profilePane.setThemeListPane(themeListPane); initializePane(); @@ -92,18 +96,60 @@ public class TemplateThemeManagePane extends BasicPane nextContainer.add(new JSeparator(), BorderLayout.NORTH); themeListPane.setPreferredSize(new Dimension(themeListPane.getPreferredSize().width, 490)); - themeListPane.setChangeListener(new ChangeListener() { + themeListPane.setSelectedChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { - T theme = themeListPane.getSelectedTheme(); - removeAction.setEnabled(theme.isRemovable()); + resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction); + resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplate); } }); nextContainer.add(themeListPane, BorderLayout.CENTER); + resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction); + resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplate); + repaint(); } + private void resetEnableRemoveAction(T selectedTheme, RemoveThemeAction removeAction) { + if (selectedTheme == null) { + removeAction.setEnabled(false); + return; + } + String selectedThemeName = selectedTheme.getName(); + if (StringUtils.isEmpty(selectedThemeName)) { + removeAction.setEnabled(false); + return; + } + + removeAction.setEnabled(selectedTheme.isRemovable()); + } + + private void resetEnableSetTheme4NewTemplateButton(T selectedTheme, UIButton setTheme4NewTemplateButton) { + if (selectedTheme == null) { + setTheme4NewTemplateButton.setEnabled(false); + return; + } + String selectedThemeName = selectedTheme.getName(); + if (StringUtils.isEmpty(selectedThemeName)) { + setTheme4NewTemplateButton.setEnabled(false); + return; + } + + T currentTheme4NewTemplate = config.getTheme4NewTemplate(); + if (currentTheme4NewTemplate == null) { + setTheme4NewTemplateButton.setEnabled(true); + return; + } + String currentThemeName4NewTemplate = currentTheme4NewTemplate.getName(); + if (StringUtils.isEmpty(currentThemeName4NewTemplate)) { + setTheme4NewTemplateButton.setEnabled(true); + return; + } + + setTheme4NewTemplateButton.setEnabled(!StringUtils.equals(currentThemeName4NewTemplate, selectedTheme.getName())); + } + private JPanel createActionsContainer() { JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); content.setPreferredSize(new Dimension(content.getPreferredSize().width, 20)); @@ -113,14 +159,12 @@ public class TemplateThemeManagePane extends BasicPane content.add(toolBar, BorderLayout.CENTER); MenuDef addMenuDef = createAddMenuDef(); - removeAction = new RemoveThemeAction(false); ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(addMenuDef, removeAction); toolbarDef.updateToolBar(toolBar); - UIButton defaultSettingBtn = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting")); - defaultSettingBtn.addActionListener(new ActionListener() { + setTheme4NewTemplate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { T style = themeListPane.getSelectedTheme(); @@ -129,7 +173,7 @@ public class TemplateThemeManagePane extends BasicPane } } }); - content.add(defaultSettingBtn, BorderLayout.EAST); + content.add(setTheme4NewTemplate, BorderLayout.EAST); JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); container.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); @@ -152,7 +196,7 @@ public class TemplateThemeManagePane extends BasicPane @Override protected String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Predefined_Server_Style"); + return Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title"); } private class RemoveThemeAction extends UpdateAction { @@ -168,7 +212,7 @@ public class TemplateThemeManagePane extends BasicPane public void actionPerformed(ActionEvent e) { T theme = TemplateThemeManagePane.this.themeListPane.getSelectedTheme(); int result = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this), - Toolkit.i18nText("Fine-Design_Predefined_Remove_Style_Confirm", theme.getName()), + Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Delete_Tip", theme.getName()), Toolkit.i18nText("Fine-Design_Basic_Delete"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { removeTheme(theme.getName()); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java index f9e427887..af62482d7 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java @@ -2,7 +2,9 @@ package com.fr.design.mainframe.theme; import com.fr.base.Style; import com.fr.base.background.ColorBackground; +import com.fr.base.theme.FineColorManager; import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.settings.ThemeThumbnail; import com.fr.base.theme.settings.ThemedCellStyle; @@ -423,7 +425,11 @@ public abstract class TemplateThemeProfilePane extends if (canBeSaved) { theme.setName(nameTextField.getText()); saveTheme(theme); - populateBean(theme); + try { + populateBean((T) theme.clone()); + } catch (CloneNotSupportedException ex) { + ex.printStackTrace(); + } } } }); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java index 54628a6c4..69a057d65 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java @@ -75,8 +75,10 @@ public abstract class TemplateThemeDialog extends JDialog { } for (UIButton button: buttons) { - button.setPreferredSize(new Dimension(button.getPreferredSize().width, DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT)); - container.add(button); + if (button != null) { + button.setPreferredSize(new Dimension(button.getPreferredSize().width, DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT)); + container.add(button); + } } return container; 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 3af94a48a..03b74460e 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 @@ -2,10 +2,14 @@ package com.fr.design.mainframe.theme.dialog; import com.fr.base.theme.FormTheme; import com.fr.base.theme.ReportTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +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.TemplateThemeManagePane; import javax.swing.BorderFactory; @@ -49,6 +53,15 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog { tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_FORM_TAB"), formThemesManagerPane); tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_REPORT_TAB"), reportThemesManagerPane); + tabbedPane.setSelectedIndex(0); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + TemplateThemeConfig config = template.getUsingTemplateThemeConfig(); + if (config == reportThemesManagerPane.getConfig()) { + tabbedPane.setSelectedIndex(1); + } + } + return content; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java index cde30ca4e..e853f68e5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java @@ -3,12 +3,15 @@ package com.fr.design.mainframe.theme.dialog; import com.fr.base.theme.ThemedTemplate; import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateThemeConfig; +import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; 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.TemplateThemeListPane; import com.fr.design.mainframe.theme.ui.BorderUtils; -import com.fr.workspace.WorkContext; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -41,18 +44,51 @@ public class TemplateThemeUsingDialog extends TemplateT UIButton usingCurrentThemeButton = createUsingCurrentThemeButton(); UIButton completeButton = createCompleteButton(); - if (WorkContext.getCurrent().isRoot()) { - setContentPane(createDialogContentPane(content, - new UIButton[]{ openThemeManagerButton }, - new UIButton[]{ usingCurrentThemeButton, completeButton } - )); - } else { - setContentPane(createDialogContentPane(content, - new UIButton[]{ usingCurrentThemeButton, completeButton } - )); - } + setContentPane(createDialogContentPane(content, + new UIButton[]{ openThemeManagerButton }, + new UIButton[]{ usingCurrentThemeButton, completeButton } + )); themeListPane.startListenThemeConfig(); + + resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton); + themeListPane.setSelectedChangeListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton); + } + }); + } + + private void resetEnableCurrentThemeButton(T selectedTheme, UIButton usingCurrentThemeButton) { + if (selectedTheme == null) { + usingCurrentThemeButton.setEnabled(false); + return; + } + String selectedThemeName = selectedTheme.getName(); + if (StringUtils.isEmpty(selectedThemeName)) { + usingCurrentThemeButton.setEnabled(false); + return; + } + + if (currentTemplate == null) { + usingCurrentThemeButton.setEnabled(false); + return; + } + + TemplateTheme templateUsingTheme = currentTemplate.getTemplateTheme(); + if (templateUsingTheme == null) { + usingCurrentThemeButton.setEnabled(true); + return; + } + + String templateUsingThemeName = templateUsingTheme.getName(); + if (StringUtils.isEmpty(templateUsingThemeName)) { + usingCurrentThemeButton.setEnabled(true); + return; + } + + usingCurrentThemeButton.setEnabled(!StringUtils.equals(templateUsingThemeName, selectedTheme.getName())); } private JPanel createContent() { @@ -71,6 +107,10 @@ public class TemplateThemeUsingDialog extends TemplateT } private UIButton createOpenThemeManagerButton() { + if (DesignModeContext.isAuthorityEditing()) { + // 权限编辑模式下,不显示打开主题管理对话框的按钮 + return null; + } UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title")); button.addActionListener(new ActionListener() { @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java index 5bf93ea51..9a211ccb6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java @@ -11,6 +11,8 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.theme.edit.component.ComponentMarginStylePane; import com.fr.design.mainframe.theme.edit.ui.LabelUtils; import com.fr.design.mainframe.theme.edit.ui.TabbedPane; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.general.act.BorderPacker; import javax.swing.BorderFactory; import javax.swing.JComponent; @@ -27,7 +29,7 @@ import java.awt.Dimension; */ public class ComponentStyleEditPane extends JPanel { public static final int LABEL_WIDTH = 60; - public static final int SETTING_WIDTH = 150; + public static final int SETTING_WIDTH = 193; private final ComponentTitleStylePane componentTitleStylePane; private final ComponentBodyStylePane componentBodyStylePane; @@ -35,7 +37,7 @@ public class ComponentStyleEditPane extends JPanel { public ComponentStyleEditPane() { setLayout(FRGUIPaneFactory.createBorderLayout()); - componentTitleStylePane = new ComponentTitleStylePane(LABEL_WIDTH, SETTING_WIDTH, false, false); + componentTitleStylePane = new ThemedComponentTitleStylePane(LABEL_WIDTH, SETTING_WIDTH); componentBodyStylePane = new ComponentBodyStylePane(LABEL_WIDTH, SETTING_WIDTH); componentIntegralStylePane = new ExtendedComponentIntegralStylePane(); @@ -89,6 +91,28 @@ public class ComponentStyleEditPane extends JPanel { } } + private static class ThemedComponentTitleStylePane extends ComponentTitleStylePane { + + public ThemedComponentTitleStylePane(int uiLabelWidth, int uiSettingWidth) { + super(uiLabelWidth, uiSettingWidth); + setSupportTitleVisible(false); + setSupportTitleContent(false); + setSupportOtherSetting(true); + } + + @Override + public void populateBean(BorderPacker style) { + style.setType(LayoutBorderStyle.TITLE); + super.populateBean(style); + } + + @Override + public void updateBean(BorderPacker style) { + super.updateBean(style); + style.setType(LayoutBorderStyle.TITLE); + } + } + private JComponent createTabContainer(final JComponent component) { JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); container.setPreferredSize(new Dimension(container.getPreferredSize().width, 220)); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/FormBodyStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/FormBodyStyleEditPane.java index 35a1ebe9e..1f2089e69 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/FormBodyStyleEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/FormBodyStyleEditPane.java @@ -15,7 +15,7 @@ import javax.swing.ScrollPaneConstants; */ public class FormBodyStyleEditPane extends JScrollPane { public static final int LABEL_WIDTH = 60; - public static final int SETTING_WIDTH = 150; + public static final int SETTING_WIDTH = 193; private final ComponentBodyStylePane bodyStylePane; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java index 9de8cc605..ec36c2970 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java @@ -1,11 +1,22 @@ package com.fr.design.mainframe.theme.edit; import com.fr.base.theme.settings.ThemedReportBodyStyle; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.ReportBackgroundSpecialPane; +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.predefined.ui.detail.background.BackgroundSettingPane; import javax.swing.BorderFactory; +import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; /** * @author Starryi @@ -13,11 +24,31 @@ import javax.swing.ScrollPaneConstants; * Created by Starryi on 2021/8/12 */ public class ReportBodyStyleEditPane extends JScrollPane { - private final BackgroundSettingPane backgroundPane; + public static final int LABEL_WIDTH = 60; + public static final int SETTING_WIDTH = 193; + + private final ReportBackgroundSpecialPane backgroundPane; + public ReportBodyStyleEditPane() { - backgroundPane = new BackgroundSettingPane(); - setViewportView(backgroundPane); + backgroundPane = new ReportBackgroundSpecialPane(); + + double p = TableLayout.PREFERRED; + + JPanel uiLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + uiLabelPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Background_Fill")), BorderLayout.NORTH); + uiLabelPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + JPanel backgroundLabeledPane = TableLayoutHelper.createCommonTableLayoutPane( + new Component[][]{ new Component[] { uiLabelPane, backgroundPane } }, + new double[] { p }, new double[] { LABEL_WIDTH, SETTING_WIDTH}, IntervalConstants.INTERVAL_L1 + ); + backgroundLabeledPane.setBorder(BorderFactory.createEmptyBorder( + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1 + )); + setViewportView(backgroundLabeledPane); setBorder(BorderFactory.createEmptyBorder()); setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); } @@ -28,7 +59,7 @@ public class ReportBodyStyleEditPane extends JScrollPane { public ThemedReportBodyStyle updateBean() { ThemedReportBodyStyle style = new ThemedReportBodyStyle(); - style.setBackground(backgroundPane.updateBean()); + style.setBackground(backgroundPane.update()); return style; } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListExtendedPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListExtendedPane.java index ddab72c80..4aac8562d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListExtendedPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListExtendedPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.theme.edit.ui; +import com.fr.base.theme.FineColorManager; import com.fr.design.layout.FRGUIPaneFactory; import javax.swing.JPanel; @@ -25,9 +26,7 @@ public class ColorListExtendedPane extends JPanel implements MouseListener { public static final ExtendedColorComputer DEFAULT_EXTENDED_COMPUTER = new ExtendedColorComputer() { @Override public Color computeExtendedColor(Color color, int index, int count) { - float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]); - hsb[2] *= 1.0F * (index + 1) / count; - return Color.getHSBColor(hsb[0], hsb[1], hsb[2]); + return FineColorManager.computeExtendedColor(color, index, count); } }; diff --git a/designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java b/designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java index 3d25590f4..20351165e 100644 --- a/designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java @@ -1,17 +1,23 @@ package com.fr.design.fit.attrpane; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.PropertyGroupPane; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XElementCase; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.design.widget.ui.designer.layout.WTitleLayoutDefinePane; +import com.fr.form.main.Form; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.PaddingMargin; import com.fr.form.web.FormToolBarManager; import com.fr.general.ComparatorUtils; import com.fr.report.fit.ReportFitAttr; @@ -27,7 +33,7 @@ import java.util.List; * Created by kerry on 2020-04-09 */ public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane { - private PaddingBoundPane paddingBoundPane; + private final PaddingBoundPane paddingBoundPane; private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; private PropertyGroupPane extraPropertyGroupPane; private PcFitExpandablePane pcFitExpandablePane; @@ -36,14 +42,31 @@ public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane { protected LayoutBorderStyle style = new LayoutBorderStyle(); + public JPanel namedTitleStylePane; + public JPanel namedBodyStylePane; + public JPanel namedIntegralStylePane; + protected ComponentTitleStylePane titleStylePane; protected ComponentBodyStylePane bodyStylePane; protected ComponentIntegralStylePane integralStylePane; @@ -65,11 +69,11 @@ public class LayoutStylePane extends BasicBeanPane { JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); boolean isRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); - JPanel titleStylePane = createNamedTitleStylePane(isRootLayout); - JPanel bodyStylePane = createNamedBodyStylePane(isRootLayout); - JPanel integralStylePane = createNamedIntegralStylePane(isRootLayout, true); + namedTitleStylePane = createNamedTitleStylePane(isRootLayout); + namedBodyStylePane = createNamedBodyStylePane(isRootLayout); + namedIntegralStylePane = createNamedIntegralStylePane(isRootLayout, true); - addComponents(new JComponent[] { titleStylePane, bodyStylePane, integralStylePane }); + addComponents(new JComponent[] { namedTitleStylePane, namedBodyStylePane, namedIntegralStylePane }); } protected JPanel createNamedTitleStylePane(boolean isRootLayout) { @@ -197,4 +201,23 @@ public class LayoutStylePane extends BasicBeanPane { return new GradientBackgroundQuickPane(140); } } + + public void supportTitleStyle(boolean supportTitleVisible, boolean supportTitleContent, boolean supportOtherSetting) { + if (titleStylePane != null) { + titleStylePane.setSupportTitleVisible(supportTitleVisible); + titleStylePane.setSupportTitleContent(supportTitleContent); + titleStylePane.setSupportOtherSetting(supportOtherSetting); + } + } + + public void supportBodyStyle(boolean supporting) { + if (namedBodyStylePane != null) { + namedBodyStylePane.setVisible(supporting); + } + } + public void supportIntegralStyle(boolean supporting) { + if (namedIntegralStylePane != null) { + namedIntegralStylePane.setVisible(supporting); + } + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 820183eab..ca09f012f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.chart.BaseChartCollection; +import com.fr.base.theme.TemplateThemeAware; import com.fr.base.theme.TemplateThemeCompatible; import com.fr.chart.chartattr.ChartCollection; import com.fr.chartx.attr.ChartProvider; @@ -31,6 +32,8 @@ import com.fr.design.mod.bean.ContentChangeItem; import com.fr.design.mod.event.TableDataModifyEvent; import com.fr.design.utils.ComponentUtils; import com.fr.event.EventDispatcher; +import com.fr.form.main.Form; +import com.fr.form.main.WidgetGather; import com.fr.form.share.editor.SharableEditorProvider; import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; @@ -148,7 +151,7 @@ public class FormCreatorDropTarget extends DropTarget { // 新疆的图表块和报表块默认主题化 - addThemeToNewWidget(widget, addingXCreator); + addThemeToNewWidget(addingXCreator); designer.getSelectionModel().setSelectedCreators( FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget})); @@ -361,20 +364,25 @@ public class FormCreatorDropTarget extends DropTarget { return this.tabDragInner; } - private void addThemeToNewWidget(Widget widget, XCreator addingXCreator) { + private void addThemeToNewWidget(XCreator addingXCreator) { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); TemplateTheme theme = template.getTemplateTheme(); if (theme instanceof FormTheme) { FormTheme formTheme = (FormTheme) theme; - if (widget instanceof ChartEditor) { - ((ChartEditor) widget).setBorderStyleFollowingTheme(true); - ((ChartEditor) widget).onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE); - addingXCreator.firePropertyChange(); - } else if (widget instanceof ElementCaseEditor) { - ((ElementCaseEditor) widget).setBorderStyleFollowingTheme(true); - ((ElementCaseEditor) widget).onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE); - addingXCreator.firePropertyChange(); - } + Form.traversalWidget(addingXCreator.toData(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + if (widget instanceof TemplateThemeAware) { + ((TemplateThemeAware) widget).onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE); + } + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, TemplateThemeAware.class); + addingXCreator.firePropertyChange(); } } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java index fdb3efc9d..a4daf4acf 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java @@ -1,49 +1,56 @@ package com.fr.design.widget.ui.designer.layout; -import com.fr.design.designer.IntervalConstants; -import com.fr.design.designer.creator.CRPropertyDescriptor; -import com.fr.design.designer.creator.PropertyGroupPane; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XElementCase; -import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.form.ui.ChartEditor; -import com.fr.form.ui.ElementCaseEditor; -import com.fr.form.web.FormToolBarManager; +import com.fr.form.ui.PaddingMargin; import com.fr.general.ComparatorUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; /** * Created by ibm on 2017/8/7. */ public class ChartEditorDefinePane extends WTitleLayoutDefinePane { - private PaddingBoundPane paddingBoundPane; + private final PaddingBoundPane paddingBoundPane; public ChartEditorDefinePane(XCreator xCreator) { super(xCreator); + paddingBoundPane = new PaddingBoundPane(); + themePane.addFollowThemePane(paddingBoundPane, new FollowingThemePane.FollowingThemeActionChangeListener() { + @Override + public void onFollowingTheme(boolean following) { + paddingBoundPane.setVisible(!following); + + if (following) { + TemplateTheme theme = themePane.getUsingTheme(); + if (theme instanceof FormTheme) { + ThemedComponentStyle style = ((FormTheme) theme).getComponentStyle(); + int top = style.getPaddingTop(); + int bottom = style.getPaddingBottom(); + int left = style.getPaddingLeft(); + int right = style.getPaddingRight(); + paddingBoundPane.populateBean(new PaddingMargin(top, left, bottom, right)); + } + } + + } + }); } protected JPanel createCenterPane() { - JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - paddingBoundPane = new PaddingBoundPane(); - Component[][] components = new Component[][]{ - new Component[]{paddingBoundPane, null}, - }; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); - panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); - centerPane.add(panel, BorderLayout.NORTH); - return centerPane; + return FRGUIPaneFactory.createBorderLayout_S_Pane(); } protected ChartEditor updateSubBean() { ChartEditor chartEditor = (ChartEditor) creator.toData(); - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { + if (themePane.isFollowingTheme() || ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { paddingBoundPane.update(chartEditor); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java index d8b0060e7..87c89f3cb 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java @@ -1,13 +1,18 @@ package com.fr.design.widget.ui.designer.layout; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.*; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.PaddingMargin; import com.fr.form.web.FormToolBarManager; import com.fr.general.ComparatorUtils; @@ -21,21 +26,37 @@ import java.awt.Component; * Created by ibm on 2017/8/7. */ public class ElementEditorDefinePane extends WTitleLayoutDefinePane { - private PaddingBoundPane paddingBoundPane; + private final PaddingBoundPane paddingBoundPane; private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; private PropertyGroupPane extraPropertyGroupPane; public ElementEditorDefinePane(XCreator xCreator) { super(xCreator); + paddingBoundPane = new PaddingBoundPane(); + themePane.addFollowThemePane(paddingBoundPane, new FollowingThemePane.FollowingThemeActionChangeListener() { + @Override + public void onFollowingTheme(boolean following) { + paddingBoundPane.setVisible(!following); + if (following) { + TemplateTheme theme = themePane.getUsingTheme(); + if (theme instanceof FormTheme) { + ThemedComponentStyle style = ((FormTheme) theme).getComponentStyle(); + int top = style.getPaddingTop(); + int bottom = style.getPaddingBottom(); + int left = style.getPaddingLeft(); + int right = style.getPaddingRight(); + paddingBoundPane.populateBean(new PaddingMargin(top, left, bottom, right)); + } + } + } + }); } protected JPanel createCenterPane() { JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - paddingBoundPane = new PaddingBoundPane(); elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor(); Component[][] components = new Component[][]{ - new Component[]{paddingBoundPane, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor}, }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); @@ -49,7 +70,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane extends AbstractDataModify { + protected FollowingThemePane themePane; private LayoutStylePane stylePane; public WTitleLayoutDefinePane(XCreator xCreator) { @@ -27,8 +33,29 @@ public abstract class WTitleLayoutDefinePane