Browse Source

Pull request #5448: REPORT-51919 主题切换

Merge in DESIGN/design from ~STARRYI/design:feature/x to feature/x

* commit '7249227b0afea298be29eb4ad901c6752c93e865':
  REPORT-51919 主题切换
research/11.0
starryi 3 years ago
parent
commit
9561fff6c6
  1. 133
      designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java
  2. 140
      designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java
  3. 102
      designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java
  4. 5
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  5. 49
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java
  6. 27
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java
  7. 64
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java
  8. 8
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java
  9. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java
  10. 13
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java
  11. 54
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java
  12. 28
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java
  13. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/FormBodyStyleEditPane.java
  14. 39
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java
  15. 5
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListExtendedPane.java
  16. 31
      designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java
  17. 31
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  18. 28
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  19. 51
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java
  20. 29
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java
  21. 30
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  22. 28
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  23. 32
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java
  24. 13
      designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java
  25. 7
      designer-realize/src/main/java/com/fr/design/actions/server/TemplateThemeManagerAction.java
  26. 211
      designer-realize/src/main/java/com/fr/design/report/NewReportBackgroundPane.java
  27. 2
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

133
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.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.WidgetTitle;
import com.fr.general.FRFont; import com.fr.general.FRFont;
@ -29,7 +28,6 @@ import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
@ -40,6 +38,7 @@ import java.awt.Font;
*/ */
public class ComponentTitleStylePane extends AbstractBorderPackerPane { public class ComponentTitleStylePane extends AbstractBorderPackerPane {
private static final Dimension BUTTON_SIZE = new Dimension(20, 20); private static final Dimension BUTTON_SIZE = new Dimension(20, 20);
public static final TitlePacker DEFAULT_TITLE_PACKER = new WidgetTitle();
// 标题可见 // 标题可见
protected UICheckBox visibleCheckbox; protected UICheckBox visibleCheckbox;
@ -62,22 +61,27 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
//标题整体背景 //标题整体背景
protected TitleTranslucentBackgroundSpecialPane backgroundPane; 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 uiLabelWidth;
private final int uiSettingWidth; private final int uiSettingWidth;
private final boolean supportTitleVisible;
protected final boolean supportTitleContent;
public ComponentTitleStylePane(int uiLabelWidth) { public ComponentTitleStylePane(int uiLabelWidth) {
this(uiLabelWidth, -1, true, true); this(uiLabelWidth, -1);
} }
public ComponentTitleStylePane( public ComponentTitleStylePane(
int uiLabelWidth, int uiSettingWidth, int uiLabelWidth, int uiSettingWidth) {
boolean supportTitleVisible, boolean supportTitleContent) {
this.uiLabelWidth = uiLabelWidth; this.uiLabelWidth = uiLabelWidth;
this.uiSettingWidth = uiSettingWidth; this.uiSettingWidth = uiSettingWidth;
this.supportTitleVisible = supportTitleVisible;
this.supportTitleContent = supportTitleContent;
this.initializePane(); this.initializePane();
} }
@ -87,7 +91,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
textContentPane = new TinyFormulaPane(); textContentPane = new TinyFormulaPane();
fontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); fontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
FRFont frFont = new WidgetTitle().getFrFont(); FRFont frFont = DEFAULT_TITLE_PACKER.getFrFont();
if (frFont != null) { if (frFont != null) {
String fontFamily = frFont.getFamily(); String fontFamily = frFont.getFamily();
// 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性 // 使用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_Center"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right") com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")
}); });
alignPane.setSelectedItem(DEFAULT_TITLE_PACKER.getPosition());
backgroundPane = new TitleTranslucentBackgroundSpecialPane(this.uiLabelWidth, this.uiSettingWidth); backgroundPane = new TitleTranslucentBackgroundSpecialPane(this.uiLabelWidth, this.uiSettingWidth);
} }
@ -140,20 +145,21 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
this.setLayout(new BorderLayout(0, 0)); this.setLayout(new BorderLayout(0, 0));
this.initializeComponents(); this.initializeComponents();
JPanel titleVisiblePane = this.createTitleVisiblePane(); titleVisiblePane = this.createTitleVisiblePane();
JPanel detailedTitleStylePane = this.createDetailedTitleStylePane(); titleContentPane = this.createTitleContentPane();
detailedTitleStylePane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); titleOtherSettingPane = this.createTitleOtherSettingPane();
if (this.supportTitleVisible) { if (isSupportTitleVisible) {
titleVisiblePane.setVisible(true); titleVisiblePane.setVisible(true);
detailedTitleStylePane.setVisible(false); }
} else { if (isSupportTitleVisible) {
titleVisiblePane.setVisible(false); titleContentPane.setVisible(false);
detailedTitleStylePane.setVisible(true); }
if (isSupportTitleVisible) {
titleOtherSettingPane.setVisible(false);
} }
add(titleVisiblePane, BorderLayout.NORTH, 0); addComponents(titleVisiblePane, titleContentPane, titleOtherSettingPane);
add(detailedTitleStylePane, BorderLayout.CENTER, 1);
} }
private JPanel createTitleVisiblePane() { private JPanel createTitleVisiblePane() {
@ -167,16 +173,30 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
visibleCheckbox.addChangeListener(new ChangeListener() { visibleCheckbox.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
Component detailedTitleStylePane = getComponent(1); boolean visible = visibleCheckbox.isSelected();
if (detailedTitleStylePane != null) { if (titleContentPane != null) {
detailedTitleStylePane.setVisible(visibleCheckbox.isSelected()); titleContentPane.setVisible(visible && isSupportTitleContent);
}
if (titleOtherSettingPane != null) {
titleOtherSettingPane.setVisible(visible && isSupportTitleOtherSetting);
} }
} }
}); });
return container; 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 p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p, p}; double[] rowSize = {p, p, p, p, p};
@ -190,18 +210,6 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
{backgroundPane, null} {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); return TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, IntervalConstants.INTERVAL_L1);
} }
@ -225,7 +233,10 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
public void populateBean(BorderPacker style) { public void populateBean(BorderPacker style) {
TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle(); TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle();
widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; 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()); this.textContentPane.populateBean(widgetTitle.getTextObject().toString());
@ -286,4 +297,52 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane {
frFont = frFont.applyStyle(italic_bold); frFont = frFont.applyStyle(italic_bold);
return frFont; 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);
}
}
}
} }

140
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<String> followingThemeButtonGroup;
private final List<FollowingThemeActionChangeListener> 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;
}
}

102
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<BackgroundQuickPane> kinds = new ArrayList<BackgroundQuickPane>();
kinds.add(nullBackgroundPane);
kinds.add(colorBackgroundPane);
kinds.add(imageBackgroundPane);
kinds.add(gradientBackgroundPane);
kinds.add(textureBackgroundPane);
kinds.add(patternBackgroundPane);
Set<BackgroundQuickUIProvider> 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();
}
}

5
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.NoneWidget;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime; import com.fr.plugin.context.PluginRuntime;
@ -1412,8 +1413,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
protected UIButton createTemplateThemeButton() { protected UIButton createTemplateThemeButton() {
UIButton button = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png"));
button.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Style")); button.setToolTipText(Toolkit.i18nText("Fine-Design_Template_Theme_Using_Dialog_Title"));
button.setText(getTemplateTheme().getName()); button.setText(getTemplateTheme().getName());
button.setAlignmentX(SwingConstants.LEFT); button.setAlignmentX(SwingConstants.LEFT);
button.set4ToolbarButton(); button.set4ToolbarButton();

49
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.base.theme.settings.ThemeThumbnail;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -26,8 +25,6 @@ import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -51,6 +48,8 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
private final Icon profileIcon = IOUtils.readIcon("/com/fr/design/icon/icon_edit.png"); private final Icon profileIcon = IOUtils.readIcon("/com/fr/design/icon/icon_edit.png");
private UILabel thumbnailLabel; private UILabel thumbnailLabel;
// UIButton会影响Block的手势监听,这里使用UILabel代替,点击事件也有Block代为处理
private UILabel profileButton;
private boolean selected = false; private boolean selected = false;
private boolean hovering = false; private boolean hovering = false;
@ -69,6 +68,8 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
if (clickListener != null) { if (clickListener != null) {
clickListener.mouseClicked(e); clickListener.mouseClicked(e);
} }
delegateProfileButtonClick(e);
} }
@Override @Override
@ -104,7 +105,7 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
infoPane.add(titleLabel, BorderLayout.WEST); infoPane.add(titleLabel, BorderLayout.WEST);
if (profilePane != null) { if (profilePane != null) {
addProfileButton(infoPane, profilePane); addProfileButton(infoPane);
} }
add(thumbnailLabel, BorderLayout.CENTER); add(thumbnailLabel, BorderLayout.CENTER);
@ -124,23 +125,35 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
this.clickListener = clickListener; this.clickListener = clickListener;
} }
private void addProfileButton(JPanel panel, TemplateThemeProfilePane<T> profilePane) { private void addProfileButton(JPanel panel) {
UIButton profileLabel = new UIButton(profileIcon); profileButton = new UILabel(profileIcon);
// profileLabel.setUI(new BasicLabelUI()); profileButton.setPreferredSize(new Dimension(24, 24));
profileLabel.setBackground(null); panel.add(profileButton, BorderLayout.EAST);
profileLabel.setOpaque(false); }
profileLabel.setPreferredSize(new Dimension(24, 24));
profileLabel.addActionListener(new ActionListener() { private void delegateProfileButtonClick(MouseEvent e) {
@Override int x = e.getX();
public void actionPerformed(ActionEvent e) { 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); Window parent = SwingUtilities.getWindowAncestor(TemplateThemeBlock.this);
TemplateThemeProfileDialog<T> profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); TemplateThemeProfileDialog<T> profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane);
profilePane.populateBean(theme); try {
profileDialog.setVisible(true); profilePane.populateBean((T) theme.clone());
} catch (CloneNotSupportedException ex) {
ex.printStackTrace();
} }
}); profileDialog.setVisible(true);
panel.add(profileLabel, BorderLayout.EAST);
} }
public void refresh() { public void refresh() {

27
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java

@ -97,21 +97,27 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
setSelectedBlock(block);
}
});
return block;
}
public void setSelectedChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
private void setSelectedBlock(TemplateThemeBlock<T> block) {
if (selectedBlock != null) { if (selectedBlock != null) {
selectedBlock.setSelected(false); selectedBlock.setSelected(false);
} }
selectedBlock = block; selectedBlock = block;
if (selectedBlock != null) {
selectedBlock.setSelected(true); selectedBlock.setSelected(true);
if (changeListener != null) {
changeListener.fireChanged(new ChangeEvent(selectedBlock));
}
} }
}); if (changeListener != null) {
return block; changeListener.fireChanged(new ChangeEvent(this));
} }
public void setChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
} }
@Override @Override
@ -120,7 +126,7 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
} }
public T getSelectedTheme() { public T getSelectedTheme() {
return selectedBlock.getTheme(); return selectedBlock != null ? selectedBlock.getTheme() : null;
} }
public void startListenThemeConfig() { public void startListenThemeConfig() {
@ -149,6 +155,9 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
case REMOVE: { case REMOVE: {
if (existingBlock != null) { if (existingBlock != null) {
contentListPane.remove(existingBlock); contentListPane.remove(existingBlock);
if (existingBlock == selectedBlock) {
setSelectedBlock(null);
}
validate(); validate();
repaint(); repaint();
blockCache.remove(event.themName); blockCache.remove(event.themName);

64
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 * Created by Starryi on 2021/8/13
*/ */
public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane { public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane {
private RemoveThemeAction removeAction; private final RemoveThemeAction removeAction;
private final UIButton setTheme4NewTemplate;
private final TemplateThemeConfig<T> config; private final TemplateThemeConfig<T> config;
private final TemplateThemeListPane<T> themeListPane; private final TemplateThemeListPane<T> themeListPane;
@ -71,6 +72,9 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
this.config = config; this.config = config;
this.profilePane = profilePane; this.profilePane = profilePane;
this.themeListPane = new TemplateThemeListPane<>(config, 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); profilePane.setThemeListPane(themeListPane);
initializePane(); initializePane();
@ -92,18 +96,60 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
nextContainer.add(new JSeparator(), BorderLayout.NORTH); nextContainer.add(new JSeparator(), BorderLayout.NORTH);
themeListPane.setPreferredSize(new Dimension(themeListPane.getPreferredSize().width, 490)); themeListPane.setPreferredSize(new Dimension(themeListPane.getPreferredSize().width, 490));
themeListPane.setChangeListener(new ChangeListener() { themeListPane.setSelectedChangeListener(new ChangeListener() {
@Override @Override
public void fireChanged(ChangeEvent event) { public void fireChanged(ChangeEvent event) {
T theme = themeListPane.getSelectedTheme(); resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction);
removeAction.setEnabled(theme.isRemovable()); resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplate);
} }
}); });
nextContainer.add(themeListPane, BorderLayout.CENTER); nextContainer.add(themeListPane, BorderLayout.CENTER);
resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction);
resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplate);
repaint(); 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() { private JPanel createActionsContainer() {
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
content.setPreferredSize(new Dimension(content.getPreferredSize().width, 20)); content.setPreferredSize(new Dimension(content.getPreferredSize().width, 20));
@ -113,14 +159,12 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
content.add(toolBar, BorderLayout.CENTER); content.add(toolBar, BorderLayout.CENTER);
MenuDef addMenuDef = createAddMenuDef(); MenuDef addMenuDef = createAddMenuDef();
removeAction = new RemoveThemeAction(false);
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(addMenuDef, removeAction); toolbarDef.addShortCut(addMenuDef, removeAction);
toolbarDef.updateToolBar(toolBar); toolbarDef.updateToolBar(toolBar);
UIButton defaultSettingBtn = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting")); setTheme4NewTemplate.addActionListener(new ActionListener() {
defaultSettingBtn.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
T style = themeListPane.getSelectedTheme(); T style = themeListPane.getSelectedTheme();
@ -129,7 +173,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
} }
} }
}); });
content.add(defaultSettingBtn, BorderLayout.EAST); content.add(setTheme4NewTemplate, BorderLayout.EAST);
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); container.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
@ -152,7 +196,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
@Override @Override
protected String title4PopupWindow() { 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 { private class RemoveThemeAction extends UpdateAction {
@ -168,7 +212,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
T theme = TemplateThemeManagePane.this.themeListPane.getSelectedTheme(); T theme = TemplateThemeManagePane.this.themeListPane.getSelectedTheme();
int result = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this), 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); Toolkit.i18nText("Fine-Design_Basic_Delete"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.YES_OPTION) { if (result == JOptionPane.YES_OPTION) {
removeTheme(theme.getName()); removeTheme(theme.getName());

8
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.Style;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.base.theme.FineColorManager;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.settings.ThemeThumbnail; import com.fr.base.theme.settings.ThemeThumbnail;
import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.base.theme.settings.ThemedCellStyle;
@ -423,7 +425,11 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
if (canBeSaved) { if (canBeSaved) {
theme.setName(nameTextField.getText()); theme.setName(nameTextField.getText());
saveTheme(theme); saveTheme(theme);
populateBean(theme); try {
populateBean((T) theme.clone());
} catch (CloneNotSupportedException ex) {
ex.printStackTrace();
}
} }
} }
}); });

2
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java

@ -75,9 +75,11 @@ public abstract class TemplateThemeDialog extends JDialog {
} }
for (UIButton button: buttons) { for (UIButton button: buttons) {
if (button != null) {
button.setPreferredSize(new Dimension(button.getPreferredSize().width, DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT)); button.setPreferredSize(new Dimension(button.getPreferredSize().width, DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT));
container.add(button); container.add(button);
} }
}
return container; return container;
} }

13
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.FormTheme;
import com.fr.base.theme.ReportTheme; 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.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.theme.TemplateThemeManagePane; import com.fr.design.mainframe.theme.TemplateThemeManagePane;
import javax.swing.BorderFactory; 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_FORM_TAB"), formThemesManagerPane);
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_REPORT_TAB"), reportThemesManagerPane); 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<? extends TemplateTheme> config = template.getUsingTemplateThemeConfig();
if (config == reportThemesManagerPane.getConfig()) {
tabbedPane.setSelectedIndex(1);
}
}
return content; return content;
} }

54
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.ThemedTemplate;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig; 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.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.TemplateThemeListPane; import com.fr.design.mainframe.theme.TemplateThemeListPane;
import com.fr.design.mainframe.theme.ui.BorderUtils; 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.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -41,18 +44,51 @@ public class TemplateThemeUsingDialog<T extends TemplateTheme> extends TemplateT
UIButton usingCurrentThemeButton = createUsingCurrentThemeButton(); UIButton usingCurrentThemeButton = createUsingCurrentThemeButton();
UIButton completeButton = createCompleteButton(); UIButton completeButton = createCompleteButton();
if (WorkContext.getCurrent().isRoot()) {
setContentPane(createDialogContentPane(content, setContentPane(createDialogContentPane(content,
new UIButton[]{ openThemeManagerButton }, new UIButton[]{ openThemeManagerButton },
new UIButton[]{ usingCurrentThemeButton, completeButton } new UIButton[]{ usingCurrentThemeButton, completeButton }
)); ));
} else {
setContentPane(createDialogContentPane(content,
new UIButton[]{ usingCurrentThemeButton, completeButton }
));
}
themeListPane.startListenThemeConfig(); 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() { private JPanel createContent() {
@ -71,6 +107,10 @@ public class TemplateThemeUsingDialog<T extends TemplateTheme> extends TemplateT
} }
private UIButton createOpenThemeManagerButton() { private UIButton createOpenThemeManagerButton() {
if (DesignModeContext.isAuthorityEditing()) {
// 权限编辑模式下,不显示打开主题管理对话框的按钮
return null;
}
UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title")); UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title"));
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
@Override @Override

28
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.component.ComponentMarginStylePane;
import com.fr.design.mainframe.theme.edit.ui.LabelUtils; import com.fr.design.mainframe.theme.edit.ui.LabelUtils;
import com.fr.design.mainframe.theme.edit.ui.TabbedPane; 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.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -27,7 +29,7 @@ import java.awt.Dimension;
*/ */
public class ComponentStyleEditPane extends JPanel { public class ComponentStyleEditPane extends JPanel {
public static final int LABEL_WIDTH = 60; 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 ComponentTitleStylePane componentTitleStylePane;
private final ComponentBodyStylePane componentBodyStylePane; private final ComponentBodyStylePane componentBodyStylePane;
@ -35,7 +37,7 @@ public class ComponentStyleEditPane extends JPanel {
public ComponentStyleEditPane() { public ComponentStyleEditPane() {
setLayout(FRGUIPaneFactory.createBorderLayout()); 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); componentBodyStylePane = new ComponentBodyStylePane(LABEL_WIDTH, SETTING_WIDTH);
componentIntegralStylePane = new ExtendedComponentIntegralStylePane(); 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) { private JComponent createTabContainer(final JComponent component) {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setPreferredSize(new Dimension(container.getPreferredSize().width, 220)); container.setPreferredSize(new Dimension(container.getPreferredSize().width, 220));

2
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 class FormBodyStyleEditPane extends JScrollPane {
public static final int LABEL_WIDTH = 60; 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; private final ComponentBodyStylePane bodyStylePane;

39
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java

@ -1,11 +1,22 @@
package com.fr.design.mainframe.theme.edit; package com.fr.design.mainframe.theme.edit;
import com.fr.base.theme.settings.ThemedReportBodyStyle; 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 com.fr.design.mainframe.predefined.ui.detail.background.BackgroundSettingPane;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants; import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
/** /**
* @author Starryi * @author Starryi
@ -13,11 +24,31 @@ import javax.swing.ScrollPaneConstants;
* Created by Starryi on 2021/8/12 * Created by Starryi on 2021/8/12
*/ */
public class ReportBodyStyleEditPane extends JScrollPane { 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() { public ReportBodyStyleEditPane() {
backgroundPane = new BackgroundSettingPane(); backgroundPane = new ReportBackgroundSpecialPane();
setViewportView(backgroundPane);
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()); setBorder(BorderFactory.createEmptyBorder());
setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
} }
@ -28,7 +59,7 @@ public class ReportBodyStyleEditPane extends JScrollPane {
public ThemedReportBodyStyle updateBean() { public ThemedReportBodyStyle updateBean() {
ThemedReportBodyStyle style = new ThemedReportBodyStyle(); ThemedReportBodyStyle style = new ThemedReportBodyStyle();
style.setBackground(backgroundPane.updateBean()); style.setBackground(backgroundPane.update());
return style; return style;
} }
} }

5
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; package com.fr.design.mainframe.theme.edit.ui;
import com.fr.base.theme.FineColorManager;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -25,9 +26,7 @@ public class ColorListExtendedPane extends JPanel implements MouseListener {
public static final ExtendedColorComputer DEFAULT_EXTENDED_COMPUTER = new ExtendedColorComputer() { public static final ExtendedColorComputer DEFAULT_EXTENDED_COMPUTER = new ExtendedColorComputer() {
@Override @Override
public Color computeExtendedColor(Color color, int index, int count) { public Color computeExtendedColor(Color color, int index, int count) {
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]); return FineColorManager.computeExtendedColor(color, index, count);
hsb[2] *= 1.0F * (index + 1) / count;
return Color.getHSBColor(hsb[0], hsb[1], hsb[2]);
} }
}; };

31
designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java

@ -1,17 +1,23 @@
package com.fr.design.fit.attrpane; 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.IntervalConstants;
import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.PropertyGroupPane; import com.fr.design.designer.creator.PropertyGroupPane;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XElementCase; import com.fr.design.designer.creator.XElementCase;
import com.fr.design.gui.ilable.UILabel; 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.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.design.widget.ui.designer.layout.WTitleLayoutDefinePane; 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.ElementCaseEditor;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.web.FormToolBarManager; import com.fr.form.web.FormToolBarManager;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.report.fit.ReportFitAttr; import com.fr.report.fit.ReportFitAttr;
@ -27,7 +33,7 @@ import java.util.List;
* Created by kerry on 2020-04-09 * Created by kerry on 2020-04-09
*/ */
public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane<ElementCaseEditor> { public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane<ElementCaseEditor> {
private PaddingBoundPane paddingBoundPane; private final PaddingBoundPane paddingBoundPane;
private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor;
private PropertyGroupPane extraPropertyGroupPane; private PropertyGroupPane extraPropertyGroupPane;
private PcFitExpandablePane pcFitExpandablePane; private PcFitExpandablePane pcFitExpandablePane;
@ -36,14 +42,31 @@ public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane<Elemen
public ElementEditorExtendDefinePane(XCreator xCreator) { public ElementEditorExtendDefinePane(XCreator xCreator) {
super(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() { protected JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paddingBoundPane = new PaddingBoundPane();
elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor(); elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{paddingBoundPane, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor}, 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); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
@ -71,7 +94,7 @@ public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane<Elemen
protected ElementCaseEditor updateSubBean() { protected ElementCaseEditor updateSubBean() {
ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData(); ElementCaseEditor elementCaseEditor = (ElementCaseEditor) 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(elementCaseEditor); paddingBoundPane.update(elementCaseEditor);
} }
elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue()); elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue());

31
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java

@ -43,6 +43,10 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
protected LayoutBorderStyle style = new LayoutBorderStyle(); protected LayoutBorderStyle style = new LayoutBorderStyle();
public JPanel namedTitleStylePane;
public JPanel namedBodyStylePane;
public JPanel namedIntegralStylePane;
protected ComponentTitleStylePane titleStylePane; protected ComponentTitleStylePane titleStylePane;
protected ComponentBodyStylePane bodyStylePane; protected ComponentBodyStylePane bodyStylePane;
protected ComponentIntegralStylePane integralStylePane; protected ComponentIntegralStylePane integralStylePane;
@ -65,11 +69,11 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean isRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); boolean isRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane();
JPanel titleStylePane = createNamedTitleStylePane(isRootLayout); namedTitleStylePane = createNamedTitleStylePane(isRootLayout);
JPanel bodyStylePane = createNamedBodyStylePane(isRootLayout); namedBodyStylePane = createNamedBodyStylePane(isRootLayout);
JPanel integralStylePane = createNamedIntegralStylePane(isRootLayout, true); namedIntegralStylePane = createNamedIntegralStylePane(isRootLayout, true);
addComponents(new JComponent[] { titleStylePane, bodyStylePane, integralStylePane }); addComponents(new JComponent[] { namedTitleStylePane, namedBodyStylePane, namedIntegralStylePane });
} }
protected JPanel createNamedTitleStylePane(boolean isRootLayout) { protected JPanel createNamedTitleStylePane(boolean isRootLayout) {
@ -197,4 +201,23 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return new GradientBackgroundQuickPane(140); 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);
}
}
} }

28
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.BaseUtils;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.base.theme.TemplateThemeAware;
import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider; 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.mod.event.TableDataModifyEvent;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.event.EventDispatcher; 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.editor.SharableEditorProvider;
import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.ShareLoader; import com.fr.form.share.ShareLoader;
@ -148,7 +151,7 @@ public class FormCreatorDropTarget extends DropTarget {
// 新疆的图表块和报表块默认主题化 // 新疆的图表块和报表块默认主题化
addThemeToNewWidget(widget, addingXCreator); addThemeToNewWidget(addingXCreator);
designer.getSelectionModel().setSelectedCreators( designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget})); FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
@ -361,20 +364,25 @@ public class FormCreatorDropTarget extends DropTarget {
return this.tabDragInner; return this.tabDragInner;
} }
private void addThemeToNewWidget(Widget widget, XCreator addingXCreator) { private void addThemeToNewWidget(XCreator addingXCreator) {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateTheme theme = template.getTemplateTheme(); TemplateTheme theme = template.getTemplateTheme();
if (theme instanceof FormTheme) { if (theme instanceof FormTheme) {
FormTheme formTheme = (FormTheme) theme; FormTheme formTheme = (FormTheme) theme;
if (widget instanceof ChartEditor) { Form.traversalWidget(addingXCreator.toData(), new WidgetGather() {
((ChartEditor) widget).setBorderStyleFollowingTheme(true); @Override
((ChartEditor) widget).onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE); public void dealWith(Widget widget) {
addingXCreator.firePropertyChange(); if (widget instanceof TemplateThemeAware) {
} else if (widget instanceof ElementCaseEditor) { ((TemplateThemeAware) widget).onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE);
((ElementCaseEditor) widget).setBorderStyleFollowingTheme(true); }
((ElementCaseEditor) widget).onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE);
addingXCreator.firePropertyChange();
} }
@Override
public boolean dealWithAllCards() {
return true;
}
}, TemplateThemeAware.class);
addingXCreator.firePropertyChange();
} }
} }
} }

51
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; package com.fr.design.widget.ui.designer.layout;
import com.fr.design.designer.IntervalConstants; import com.fr.base.theme.FormTheme;
import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.base.theme.TemplateTheme;
import com.fr.design.designer.creator.PropertyGroupPane; import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XElementCase; import com.fr.design.gui.style.FollowingThemePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; 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.component.PaddingBoundPane;
import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ChartEditor;
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.general.ComparatorUtils;
import javax.swing.*; import javax.swing.JPanel;
import java.awt.*;
/** /**
* Created by ibm on 2017/8/7. * Created by ibm on 2017/8/7.
*/ */
public class ChartEditorDefinePane extends WTitleLayoutDefinePane<ChartEditor> { public class ChartEditorDefinePane extends WTitleLayoutDefinePane<ChartEditor> {
private PaddingBoundPane paddingBoundPane; private final PaddingBoundPane paddingBoundPane;
public ChartEditorDefinePane(XCreator xCreator) { public ChartEditorDefinePane(XCreator xCreator) {
super(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() { protected JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); return 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;
} }
protected ChartEditor updateSubBean() { protected ChartEditor updateSubBean() {
ChartEditor chartEditor = (ChartEditor) creator.toData(); 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); paddingBoundPane.update(chartEditor);
} }

29
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; 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.IntervalConstants;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.gui.ilable.UILabel; 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.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.web.FormToolBarManager; import com.fr.form.web.FormToolBarManager;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -21,21 +26,37 @@ import java.awt.Component;
* Created by ibm on 2017/8/7. * Created by ibm on 2017/8/7.
*/ */
public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseEditor> { public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseEditor> {
private PaddingBoundPane paddingBoundPane; private final PaddingBoundPane paddingBoundPane;
private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor;
private PropertyGroupPane extraPropertyGroupPane; private PropertyGroupPane extraPropertyGroupPane;
public ElementEditorDefinePane(XCreator xCreator) { public ElementEditorDefinePane(XCreator xCreator) {
super(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() { protected JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paddingBoundPane = new PaddingBoundPane();
elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor(); elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{paddingBoundPane, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor}, 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); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
@ -49,7 +70,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
protected ElementCaseEditor updateSubBean() { protected ElementCaseEditor updateSubBean() {
ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData(); ElementCaseEditor elementCaseEditor = (ElementCaseEditor) 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(elementCaseEditor); paddingBoundPane.update(elementCaseEditor);
} }
elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue()); elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue());

30
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

@ -2,6 +2,9 @@ package com.fr.design.widget.ui.designer.layout;
import com.fr.base.io.IOFile; import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
@ -11,19 +14,20 @@ import com.fr.design.designer.properties.items.Item;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.style.FollowingThemePane;
import com.fr.design.gui.xpane.LayoutStylePane; import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.WidgetBoundPane; import com.fr.design.widget.ui.designer.component.WidgetBoundPane;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.act.BorderPacker;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -38,6 +42,7 @@ import java.awt.Component;
public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
private static final int MAX_LABEL_WIDTH = 80; private static final int MAX_LABEL_WIDTH = 80;
protected FollowingThemePane themePane;
private LayoutStylePane stylePane; private LayoutStylePane stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor; private AccessibleBodyWatermarkEditor watermarkEditor;
private WidgetBoundPane boundPane; private WidgetBoundPane boundPane;
@ -77,8 +82,24 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public JPanel createAdvancePane() { public JPanel createAdvancePane() {
JPanel advancedContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel advancedContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Widget_Style_Setting"));
stylePane = new LayoutStylePane(); stylePane = new LayoutStylePane();
advancedContentPane.add(stylePane, BorderLayout.NORTH); themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() {
@Override
public void onFollowingTheme(boolean following) {
stylePane.supportBodyStyle(!following);
BorderPacker style = stylePane.updateBean();
if (following) {
TemplateTheme theme = themePane.getUsingTheme();
if (theme instanceof FormTheme) {
style = ((FormTheme) theme).getBodyStyle().merge(style);
}
}
stylePane.populateBean((LayoutBorderStyle) style);
}
});
advancedContentPane.add(themePane, BorderLayout.NORTH);
watermarkEditor = new AccessibleBodyWatermarkEditor(); watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel watermarkPane = TableLayoutHelper.createGapTableLayoutPane( JPanel watermarkPane = TableLayoutHelper.createGapTableLayoutPane(
@ -130,6 +151,8 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void populateSubPane(WAbsoluteLayout ob) { public void populateSubPane(WAbsoluteLayout ob) {
layoutCombox.setSelectedIndex(1); layoutCombox.setSelectedIndex(1);
themePane.supportFollowingTheme(ob.supportThemed());
themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme());
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
boundPane.populate(); boundPane.populate();
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
@ -153,6 +176,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
copyLayoutAttr(layout, xwFitLayout.toData()); copyLayoutAttr(layout, xwFitLayout.toData());
} }
} }
layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme());
layout.setBorderStyle(stylePane.updateBean()); layout.setBorderStyle(stylePane.updateBean());
updateWatermark(); updateWatermark();
return layout; return layout;

28
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -2,6 +2,8 @@ package com.fr.design.widget.ui.designer.layout;
import com.fr.base.io.IOFile; import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
@ -16,9 +18,10 @@ import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.style.FollowingThemePane;
import com.fr.design.gui.xpane.LayoutStylePane; import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
@ -34,6 +37,7 @@ import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WFitLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
@ -51,6 +55,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
private UIComboBox adaptComboBox; private UIComboBox adaptComboBox;
private UISpinner componentIntervel; private UISpinner componentIntervel;
private PaddingBoundPane paddingBound; private PaddingBoundPane paddingBound;
private FollowingThemePane themePane;
private LayoutStylePane stylePane; private LayoutStylePane stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor; private AccessibleBodyWatermarkEditor watermarkEditor;
@ -83,8 +88,24 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
public JPanel createAdvancePane() { public JPanel createAdvancePane() {
JPanel contentPane0 = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel contentPane0 = FRGUIPaneFactory.createBorderLayout_S_Pane();
themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Widget_Style_Setting"));
stylePane = new LayoutStylePane(); stylePane = new LayoutStylePane();
contentPane0.add(stylePane, BorderLayout.NORTH); themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() {
@Override
public void onFollowingTheme(boolean following) {
stylePane.supportBodyStyle(!following);
BorderPacker style = stylePane.updateBean();
if (following) {
TemplateTheme theme = themePane.getUsingTheme();
if (theme instanceof FormTheme) {
style = ((FormTheme) theme).getBodyStyle().merge(style);
}
}
stylePane.populateBean((LayoutBorderStyle) style);
}
});
contentPane0.add(themePane, BorderLayout.NORTH);
JPanel contentPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel contentPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentPane0.add(contentPane1, BorderLayout.CENTER); contentPane0.add(contentPane1, BorderLayout.CENTER);
@ -157,6 +178,8 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue()); layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue());
adaptComboBox.setSelectedIndex(ob.getCompState()); adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval()); componentIntervel.setValue(ob.getCompInterval());
themePane.supportFollowingTheme(ob.supportThemed());
themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme());
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
} }
@ -176,6 +199,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBound.update(layout); paddingBound.update(layout);
} }
layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme());
LayoutBorderStyle borderStyle = stylePane.updateBean(); LayoutBorderStyle borderStyle = stylePane.updateBean();
if (borderStyle != null) { if (borderStyle != null) {
layout.setBorderStyle(borderStyle); layout.setBorderStyle(borderStyle);

32
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java

@ -1,13 +1,18 @@
package com.fr.design.widget.ui.designer.layout; package com.fr.design.widget.ui.designer.layout;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.style.FollowingThemePane;
import com.fr.design.gui.xpane.LayoutStylePane; import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -17,6 +22,7 @@ import java.awt.*;
* Created by ibm on 2017/8/3. * Created by ibm on 2017/8/3.
*/ */
public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget> extends AbstractDataModify<T> { public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget> extends AbstractDataModify<T> {
protected FollowingThemePane themePane;
private LayoutStylePane stylePane; private LayoutStylePane stylePane;
public WTitleLayoutDefinePane(XCreator xCreator) { public WTitleLayoutDefinePane(XCreator xCreator) {
@ -27,8 +33,29 @@ public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel advancePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel advancePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Widget_Style_Setting"));
themePane.supportFollowingTheme(false);
stylePane = new LayoutStylePane(true); stylePane = new LayoutStylePane(true);
advancePane.add(stylePane, BorderLayout.NORTH); themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() {
@Override
public void onFollowingTheme(boolean following) {
stylePane.supportTitleStyle(true, true, !following);
stylePane.supportBodyStyle(!following);
stylePane.supportIntegralStyle(!following);
BorderPacker style = stylePane.updateBean();
if (following) {
TemplateTheme theme = themePane.getUsingTheme();
if (theme instanceof FormTheme) {
style = ((FormTheme) theme).getComponentStyle().merge(style);
}
}
stylePane.populateBean((LayoutBorderStyle) style);
}
});
advancePane.add(themePane, BorderLayout.NORTH);
JPanel centerPane = createCenterPane(); JPanel centerPane = createCenterPane();
if(centerPane!=null){ if(centerPane!=null){
advancePane.add(centerPane, BorderLayout.CENTER); advancePane.add(centerPane, BorderLayout.CENTER);
@ -52,6 +79,8 @@ public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget
@Override @Override
public void populateBean(T ob) { public void populateBean(T ob) {
populateSubBean(ob); populateSubBean(ob);
themePane.supportFollowingTheme(ob.supportThemed());
themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme());
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
} }
@ -59,6 +88,7 @@ public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget
@Override @Override
public T updateBean() { public T updateBean() {
T e = updateSubBean(); T e = updateSubBean();
e.setBorderStyleFollowingTheme(themePane.isFollowingTheme());
LayoutBorderStyle style = stylePane.updateBean(); LayoutBorderStyle style = stylePane.updateBean();
if(!ComparatorUtils.equals(style, e.getBorderStyle())){ if(!ComparatorUtils.equals(style, e.getBorderStyle())){
e.setBorderStyle(style); e.setBorderStyle(style);

13
designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java

@ -4,14 +4,15 @@
package com.fr.design.actions.report; package com.fr.design.actions.report;
import com.fr.base.svg.IconUtils;
import com.fr.design.actions.ReportComponentAction; import com.fr.design.actions.ReportComponentAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ReportComponent; import com.fr.design.mainframe.ReportComponent;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.report.ReportBackgroundPane; import com.fr.design.report.NewReportBackgroundPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
import com.fr.report.report.Report;
/** /**
* Background action. * Background action.
@ -35,16 +36,16 @@ public class ReportBackgroundAction extends ReportComponentAction<ReportComponen
if (reportPane == null) { if (reportPane == null) {
return false; return false;
} }
final ReportBackgroundPane bPane = new ReportBackgroundPane(); final NewReportBackgroundPane bPane = new NewReportBackgroundPane();
bPane.populate(ReportUtils.getReportSettings(reportPane.getTemplateReport())); bPane.populate(ReportUtils.getReportSettings(reportPane.getTemplateReport()));
bPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { bPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
bPane.update(reportPane.getTemplateReport().getReportSettings()); bPane.update(reportPane.getTemplateReport().getReportSettings());
reportPane.fireTargetModified(); reportPane.fireTargetModified();
} }
}).setVisible(true); }, BasicDialog.DEFAULT).setVisible(true);
return false; return false;
} }
} }

7
designer-realize/src/main/java/com/fr/design/actions/server/TemplateThemeManagerAction.java

@ -1,5 +1,6 @@
package com.fr.design.actions.server; package com.fr.design.actions.server;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane; import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane;
import com.fr.design.mainframe.theme.dialog.TemplateThemeManageDialog; import com.fr.design.mainframe.theme.dialog.TemplateThemeManageDialog;
@ -23,8 +24,8 @@ public class TemplateThemeManagerAction extends SnapChatUpdateAction {
this.setMenuKeySet(TEMPLATE_THEMES_MANAGER); this.setMenuKeySet(TEMPLATE_THEMES_MANAGER);
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/style.png")); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png"));
this.generateAndSetSearchText(ServerPredefinedStylePane.class.getName()); this.generateAndSetSearchText(TemplateThemeManageDialog.class.getName());
} }
@Override @Override
@ -41,7 +42,7 @@ public class TemplateThemeManagerAction extends SnapChatUpdateAction {
@Override @Override
public String getMenuName() { public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Server_Style"); return Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title");
} }
@Override @Override

211
designer-realize/src/main/java/com/fr/design/report/NewReportBackgroundPane.java

@ -0,0 +1,211 @@
package com.fr.design.report;
import com.fr.base.theme.ReportTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.base.theme.settings.ThemedReportBodyStyle;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.style.ReportBackgroundSpecialPane;
import com.fr.design.gui.style.FollowingThemePane;
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.theme.ui.BorderUtils;
import com.fr.form.ui.PaddingMargin;
import com.fr.general.Background;
import com.fr.page.ReportSettingsProvider;
import com.fr.report.stable.ReportSettings;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.CompoundBorder;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
public class NewReportBackgroundPane extends BasicPane {
private final UICheckBox isPrintBackgroundCheckBox;
private final UICheckBox isExportBackgroundCheckBox;
private final BackgroundProfilePane profilePane;
public NewReportBackgroundPane() {
setLayout(FRGUIPaneFactory.createBorderLayout());
setBorder(BorderFactory.createEmptyBorder());
setPreferredSize(new Dimension(600, 570));
profilePane = new BackgroundProfilePane();
isPrintBackgroundCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Background"));
isExportBackgroundCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Background"));
add(profilePane, BorderLayout.CENTER);
add(createBottomPane(), BorderLayout.SOUTH);
}
private JPanel createBottomPane() {
JPanel container = new JPanel();
container.setPreferredSize(new Dimension(container.getPreferredSize().width, 30));
container.add(isExportBackgroundCheckBox);
container.add(isPrintBackgroundCheckBox);
return container;
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Background");
}
public void populate(ReportSettingsProvider reportSettings) {
this.profilePane.populateBean(reportSettings);
this.isPrintBackgroundCheckBox.setSelected(reportSettings.isPrintBackground());
this.isExportBackgroundCheckBox.setSelected(reportSettings.isExportBackground());
}
public void update(ReportSettingsProvider reportSettings) {
this.profilePane.updateBean(reportSettings);
reportSettings.setPrintBackground(this.isPrintBackgroundCheckBox.isSelected());
reportSettings.setExportBackground(this.isExportBackgroundCheckBox.isSelected());
}
private static class BackgroundPreviewPane extends JPanel {
private Background background = null;
void refresh(Background background) {
this.background = background;
repaint();
}
@Override
public void paint(Graphics g) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(), getHeight());
Graphics2D g2d = (Graphics2D) g;
if (background != null) {
Shape shape = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
background.paint(g2d, shape);
}
}
}
private static class BackgroundProfilePane extends AbstractAttrNoScrollPane {
public static final int SETTING_LABEL_WIDTH = 60;
private BackgroundPreviewPane previewPane;
private FollowingThemePane themePane;
private ReportBackgroundSpecialPane backgroundPane;
private JPanel backgroundLabeledPane;
@Override
protected JPanel createContentPane() {
previewPane = new BackgroundPreviewPane();
themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Report_Background_Setting"));
themePane.supportFollowingTheme(true);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
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));
backgroundPane = new ReportBackgroundSpecialPane();
backgroundLabeledPane = TableLayoutHelper.createCommonTableLayoutPane(
new Component[][]{ new Component[] { uiLabelPane, backgroundPane } },
new double[] { p }, new double[] { SETTING_LABEL_WIDTH, f}, IntervalConstants.INTERVAL_L1
);
themePane.addFollowThemePane(backgroundLabeledPane, new FollowingThemePane.FollowingThemeActionChangeListener() {
@Override
public void onFollowingTheme(boolean following) {
backgroundLabeledPane.setVisible(!following);
if (following) {
TemplateTheme theme = themePane.getUsingTheme();
if (theme instanceof ReportTheme) {
ThemedReportBodyStyle style = ((ReportTheme) theme).getBodyStyle();
Background background = style.getBackground();
backgroundPane.populateBean(background);
previewPane.refresh(background);
}
}
}
});
JPanel contentContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentContainer.setBorder(BorderFactory.createEmptyBorder());
contentContainer.setBorder(BorderFactory.createEmptyBorder());
contentContainer.setPreferredSize(new Dimension(600, 540));
contentContainer.add(createLeftPane(), BorderLayout.WEST);
contentContainer.add(createRightPane(), BorderLayout.EAST);
addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
valueChangeAction();
}
});
return contentContainer;
}
@Override
protected void initContentPane() {
super.initContentPane();
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
}
private JPanel createLeftPane() {
JPanel container = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
container.setBorder(BorderFactory.createEmptyBorder());
JPanel titledPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
titledPane.setBorder(new CompoundBorder(
BorderUtils.createTitleBorder("预览", 12),
BorderFactory.createEmptyBorder(5, 5, 4, 5)
));
titledPane.setPreferredSize(new Dimension(397, 502));
container.add(titledPane, BorderLayout.WEST);
titledPane.add(previewPane, BorderLayout.WEST);
previewPane.setPreferredSize(new Dimension(387, 480));
return container;
}
private JPanel createRightPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(BorderFactory.createEmptyBorder());
container.setPreferredSize(new Dimension(253, 502));
container.add(themePane, BorderLayout.NORTH);
return container;
}
private void valueChangeAction() {
previewPane.refresh(backgroundPane.update());
}
public void populateBean(ReportSettingsProvider reportSettings) {
if (reportSettings instanceof ReportSettings) {
boolean followingTheme = ((ReportSettings) reportSettings).isBackgroundFollowingTheme();
themePane.setFollowingTheme(followingTheme);
backgroundLabeledPane.setVisible(!followingTheme);
}
backgroundPane.populateBean(reportSettings.getBackground());
previewPane.refresh(reportSettings.getBackground());
}
public void updateBean(ReportSettingsProvider reportSettings) {
if (reportSettings instanceof ReportSettings) {
((ReportSettings) reportSettings).setBackgroundFollowingTheme(themePane.isFollowingTheme());
}
reportSettings.setBackground(backgroundPane.update());
}
}
}

2
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -173,8 +173,6 @@ public class MainDesigner extends BaseDesigner {
if (WorkContext.getCurrent().isRoot()) { if (WorkContext.getCurrent().isRoot()) {
menuDef.addShortCut( menuDef.addShortCut(
new ServerConfigManagerAction(), new ServerConfigManagerAction(),
new StyleListAction(),
new ServerPredefinedStyleAction(SnapChatAllTypes.UpdateAction.TEMPLATE_THEMES_MANAGER),
new TemplateThemeManagerAction(), new TemplateThemeManagerAction(),
new WidgetManagerAction() new WidgetManagerAction()
); );

Loading…
Cancel
Save