Browse Source

Merge pull request #5602 in DESIGN/design from feature/x to release/11.0

* commit 'fbe446717b14d8dda010b4458cf486149cef9130':
  REPORT-58212 【主题切换】远程10.0升上来的工程,特定操作下新建的模板预览500
  REPORT-58064 【主题切换】悬浮元素-样式的显示同交互稿不符
  REPORT-58276 【主题切换】细节定制-FRM组件样式-主体填充修改后,联动显示异常
  REPORT-58301 【决策报表】布局切换以后,body背景样式不保留
  代码修改
  REPORT-58225【主题切换】除图表外所有渐变色设置,打开颜色控件显示不正确
  REPORT-58289【主题切换】缩略图没有背景
fix-lag
superman 3 years ago
parent
commit
979c21fe6b
  1. 8
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java
  2. 26
      designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java
  3. 26
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java
  4. 4
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java
  5. 6
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java
  6. 39
      designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java
  7. 53
      designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarWithPopMenu.java
  8. 45
      designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java
  9. 5
      designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java
  10. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java
  11. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java
  12. 7
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  13. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  14. 605
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

8
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java

@ -15,7 +15,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.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.style.background.gradient.FixedGradientBar; import com.fr.design.style.background.gradient.FixedGradientBarNoTheme;
import com.fr.design.style.color.ColorAdjustPane; import com.fr.design.style.color.ColorAdjustPane;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -40,7 +40,7 @@ public class ColorFillStylePane extends BasicBeanPane<ColorFillStyle> {
private ColorSchemeComboBox styleSelectBox; private ColorSchemeComboBox styleSelectBox;
private JPanel customPane; private JPanel customPane;
private JPanel changeColorSetPane; private JPanel changeColorSetPane;
private FixedGradientBar colorGradient; private FixedGradientBarNoTheme colorGradient;
private CardLayout cardLayout; private CardLayout cardLayout;
@ -69,8 +69,8 @@ public class ColorFillStylePane extends BasicBeanPane<ColorFillStyle> {
}; };
changeColorSetPane = new JPanel(cardLayout = new CardLayout()); changeColorSetPane = new JPanel(cardLayout = new CardLayout());
changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); changeColorSetPane.add(colorGradient = new FixedGradientBarNoTheme(4, 130), "gradient");
gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER}; gradientColors = new Color[]{Color.WHITE, FixedGradientBarNoTheme.NEW_CHARACTER};
changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc"); changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc");
accColors = ColorAdjustPane.DEFAULT_COLORS; accColors = ColorAdjustPane.DEFAULT_COLORS;
cardLayout.show(changeColorSetPane, "acc"); cardLayout.show(changeColorSetPane, "acc");

26
designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java

@ -34,30 +34,28 @@ public class AsyncThemeFetcher<T extends TemplateTheme> {
} }
public void submit(String themeName, AsyncThemeFetchCallback<T> callback) { public void submit(String themeName, AsyncThemeFetchCallback<T> callback) {
callback.beforeCachedFetch(); if (callback != null) {
callback.beforeCachedFetch();
}
executorService.submit(new Runnable() { executorService.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
if (executorService.isShutdown()) { if (executorService.isShutdown()) {
return; return;
} }
T theme = config.cachedFetch(themeName, new TemplateThemeConfig.CacheCondition<T>() { T theme = config.cachedFetch(themeName);
@Override
public boolean shouldCacheTheme(T theme) {
return callback.shouldCache(AsyncThemeFetcher.this, theme);
}
});
if (executorService.isShutdown()) { if (executorService.isShutdown()) {
return; return;
} }
callback.afterCachedFetch(theme); if (callback != null) {
callback.afterCachedFetch(theme);
}
} }
}); });
} }
public interface AsyncThemeFetchCallback<T extends TemplateTheme> { public interface AsyncThemeFetchCallback<T extends TemplateTheme> {
void beforeCachedFetch(); void beforeCachedFetch();
boolean shouldCache(AsyncThemeFetcher<T> fetcher, T theme);
void afterCachedFetch(T theme); void afterCachedFetch(T theme);
} }
@ -68,16 +66,6 @@ public class AsyncThemeFetcher<T extends TemplateTheme> {
} }
@Override
public boolean shouldCache(AsyncThemeFetcher<T> fetcher, T theme) {
// 如果Fetcher已经关闭就不放进缓存里了
// 因为可切换工作目录,所以submit时的工作目录环境与最终获取到主题数据时的工作目录环境可能不是同一个,
// 如果仍然放进缓存中,会污染当前工作目录环境的主题缓存.
// TODO: 除了根据asyncThemeFetch的关闭情况来判断是否缓存主题,也可以更加精细的判断前后的工作目录环境是否时同一个
// TODO: 后续看情况再优化吧.
return !fetcher.isShutdown();
}
@Override @Override
public void afterCachedFetch(T theme) { public void afterCachedFetch(T theme) {

26
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java

@ -191,8 +191,8 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add")); MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
menuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); menuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH);
menuDef.setRePaint(true); menuDef.setRePaint(true);
menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getLightThemeName4New())); menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getDefaultLightThemeName()));
menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDarkThemeName4New())); menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDefaultDarkThemeName()));
return menuDef; return menuDef;
} }
@ -232,31 +232,27 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
} }
private class AddThemeAction extends UpdateAction { private class AddThemeAction extends UpdateAction {
private T prototypeTheme; private final String prototypeThemeName;
public AddThemeAction(String name, String prototypeThemeName) { public AddThemeAction(String name, String prototypeThemeName) {
setName(name); setName(name);
setMnemonic('R'); setMnemonic('R');
asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter<T>() { this.prototypeThemeName = prototypeThemeName;
@Override asyncThemeFetcher.submit(prototypeThemeName, null);
public void beforeCachedFetch() { }
super.beforeCachedFetch();
prototypeTheme = null;
}
@Override
public void actionPerformed(ActionEvent e) {
asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter<T>() {
@Override @Override
public void afterCachedFetch(T theme) { public void afterCachedFetch(T theme) {
super.afterCachedFetch(theme); super.afterCachedFetch(theme);
prototypeTheme = theme; createNewTheme(theme);
} }
}); });
} }
@Override private void createNewTheme(T prototypeTheme) {
public void actionPerformed(ActionEvent e) {
if (prototypeTheme == null) {
return;
}
Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this); Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this);
TemplateThemeProfileDialog<T> profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); TemplateThemeProfileDialog<T> profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane);
try { try {

4
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java

@ -63,10 +63,6 @@ public abstract class TemplateThemePreviewPane<T extends TemplateTheme> extends
g2d.dispose(); g2d.dispose();
g2d = image.createGraphics(); g2d = image.createGraphics();
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
g2d.setColor(new Color(255, 255, 255, 1));
g2d.fillRect(0, 0, width, height); g2d.fillRect(0, 0, width, height);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

6
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java

@ -5,7 +5,7 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog;
import com.fr.design.style.background.gradient.FixedGradientBarWithPopMenu; import com.fr.design.style.background.gradient.FixedGradientBar;
import java.util.List; import java.util.List;
import java.awt.Color; import java.awt.Color;
@ -22,12 +22,12 @@ import java.awt.event.ActionListener;
public class ChartSeriesStylePane extends AbstractChartStylePane { public class ChartSeriesStylePane extends AbstractChartStylePane {
private UIButtonGroup<Integer> colorTypeButton; private UIButtonGroup<Integer> colorTypeButton;
private FixedGradientBarWithPopMenu gradientBar; private FixedGradientBar gradientBar;
protected void initComponents() { protected void initComponents() {
colorTypeButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Custom_Color"), colorTypeButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Custom_Color"),
Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual")}); Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual")});
gradientBar = new FixedGradientBarWithPopMenu(4, 130); gradientBar = new FixedGradientBar(4, 130);
initListener(); initListener();
} }

39
designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java

@ -0,0 +1,39 @@
package com.fr.design.style.background.gradient;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.style.color.ColorSelectDetailPane;
import com.fr.design.style.color.ColorSelectDialog;
import javax.swing.JPanel;
import java.awt.Color;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2021-08-19
*/
public class FixedGradientBarNoTheme extends FixedGradientBar {
public FixedGradientBarNoTheme(int minvalue, int maxvalue) {
super(minvalue, maxvalue);
}
protected void clickButton(int select) {
ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE);
Color selectColor = getList().get(select).getColorInner() == null ? Color.WHITE : getList().get(select).getColorInner();
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, FixedGradientBarNoTheme.this);
Color color = FixedGradientBarNoTheme.this.getColor();
if (color != null) {
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color);
getList().get(select).setColorInner(color);
stateChanged();
FixedGradientBarNoTheme.this.repaint();
}
}
public JPanel initWindowPane(double preWidth) {
return null;
}
}

53
designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarWithPopMenu.java

@ -1,53 +0,0 @@
package com.fr.design.style.background.gradient;
import com.fr.base.background.ColorBackground;
import com.fr.design.style.color.NewColorSelectPane;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2021-08-19
*/
public class FixedGradientBarWithPopMenu extends FixedGradientBar {
private NewColorSelectPane colorPane;
public FixedGradientBarWithPopMenu(int minvalue, int maxvalue) {
super(minvalue, maxvalue);
}
protected void clickButton(int select) {
setIndex(select);
showPopupMenu();
}
public JPanel initWindowPane(double preferredWidth) {
// 下拉的时候重新生成面板,刷新最近使用颜色
colorPane = new NewColorSelectPane(false) {
@Override
public void setVisible(boolean b) {
super.setVisible(b);
}
@Override
protected boolean selectRealTime() {
return false;
}
};
colorPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
hidePopupMenu();
setColor(((NewColorSelectPane) e.getSource()).getColor());
getList().get(getIndex()).setColorInner(getColor());
fireDisplayComponent(ColorBackground.getInstance(getColor()));
FixedGradientBarWithPopMenu.this.stateChanged();
}
});
return colorPane;
}
}

45
designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java

@ -1,14 +1,12 @@
package com.fr.design.style.background.gradient; package com.fr.design.style.background.gradient;
import com.fr.design.DesignerEnvManager; import com.fr.base.background.ColorBackground;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorCell;
import com.fr.design.style.color.ColorSelectDetailPane;
import com.fr.design.style.color.ColorSelectDialog;
import com.fr.design.style.color.ColorSelectable; import com.fr.design.style.color.ColorSelectable;
import com.fr.design.style.color.NewColorSelectPane;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
@ -34,7 +32,7 @@ import java.awt.geom.Point2D;
* TODO:面板缩放的功能没有考虑就是尾值过大导致超过界面显示的情况原来的那个实现完全是个BUG要缩放的情况也比较少就干脆以后弄吧 * TODO:面板缩放的功能没有考虑就是尾值过大导致超过界面显示的情况原来的那个实现完全是个BUG要缩放的情况也比较少就干脆以后弄吧
*/ */
public class GradientBar extends AbstractComponentPopBox implements UIObserver, ColorSelectable { public class GradientBar extends AbstractComponentPopBox implements UIObserver, ColorSelectable {
private NewColorSelectPane colorPane;
/** /**
* *
*/ */
@ -131,20 +129,33 @@ public class GradientBar extends AbstractComponentPopBox implements UIObserver,
} }
protected void clickButton(int select) { protected void clickButton(int select) {
ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); setIndex(select);
Color selectColor = list.get(select).getColorInner() == null ? Color.WHITE : list.get(select).getColorInner(); showPopupMenu();
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, GradientBar.this);
Color color = GradientBar.this.getColor();
if (color != null) {
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color);
list.get(select).setColorInner(color);
stateChanged();
GradientBar.this.repaint();
}
} }
public JPanel initWindowPane(double preWidth) { public JPanel initWindowPane(double preferredWidth) {
return null; // 下拉的时候重新生成面板,刷新最近使用颜色
colorPane = new NewColorSelectPane(false) {
@Override
public void setVisible(boolean b) {
super.setVisible(b);
}
@Override
protected boolean selectRealTime() {
return false;
}
};
colorPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
hidePopupMenu();
setColor(((NewColorSelectPane) e.getSource()).getColor());
getList().get(getIndex()).setColorInner(getColor());
fireDisplayComponent(ColorBackground.getInstance(getColor()));
GradientBar.this.stateChanged();
}
});
return colorPane;
} }
protected void addMouseDragListener() { protected void addMouseDragListener() {

5
designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java

@ -115,10 +115,7 @@ public abstract class ColorControlWindowWithAuto extends ColorControlWindow {
} }
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
if (isSupportTransparent()) { return super.getPreferredSize();
return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT + BUTTON_HEIGHT);
}
return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT + BUTTON_HEIGHT);
} }
} }

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java

@ -24,8 +24,6 @@ public class ColorSelectPaneWithOutTransparent extends NewColorSelectPane {
menuColorPane.setLayout(new GridLayout(0, 8, 1, 1)); menuColorPane.setLayout(new GridLayout(0, 8, 1, 1));
menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
menuColorPane.setPreferredSize(new Dimension(205, 62));
return menuColorPane; return menuColorPane;
} }
} }

2
designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java

@ -76,7 +76,7 @@ public class XWTitleLayout extends DedicateLayoutContainer {
// 初始化后(如打开旧模版),需要重新调整组件/标题/边框的显示效果 // 初始化后(如打开旧模版),需要重新调整组件/标题/边框的显示效果
XCreator xCreator = getBodyCreator(); XCreator xCreator = getBodyCreator();
if (xCreator instanceof XBorderStyleWidgetCreator) { if (xCreator instanceof XBorderStyleWidgetCreator) {
((XBorderStyleWidgetCreator) xCreator).reshuffleBorderAndBackgroundPaintingEffectIfTitleExists(); ((XBorderStyleWidgetCreator) xCreator).initStyle();
} }
} }

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

@ -27,6 +27,7 @@ import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.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.form.ui.container.WFitLayout;
import com.fr.general.act.BorderPacker; import com.fr.general.act.BorderPacker;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
@ -173,6 +174,12 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
if (state == WBodyLayoutType.FIT.getTypeValue()) { if (state == WBodyLayoutType.FIT.getTypeValue()) {
XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent()); XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent());
xwFitLayout.switch2FitBodyLayout(creator); xwFitLayout.switch2FitBodyLayout(creator);
WFitLayout wFitLayout = xwFitLayout.toData();
// 切换布局类型时,保留body背景样式
if (wFitLayout != null) {
wFitLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme());
wFitLayout.setBorderStyle(layout.getBorderStyle());
}
copyLayoutAttr(layout, xwFitLayout.toData()); copyLayoutAttr(layout, xwFitLayout.toData());
} }
} }

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

@ -215,9 +215,13 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
layout.setLayoutType(WBodyLayoutType.parse(state)); layout.setLayoutType(WBodyLayoutType.parse(state));
layout.setCompState(adaptComboBox.getSelectedIndex()); layout.setCompState(adaptComboBox.getSelectedIndex());
try { try {
// 自适应布局切换到绝对布局
if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) { if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) {
WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body"); WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body");
wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED); wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED);
// 切换布局类型时,保留body背景样式
wAbsoluteBodyLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme());
wAbsoluteBodyLayout.setBorderStyle((BorderPacker) (layout.getBorderStyle().clone()));
Component[] components = xWFitLayout.getComponents(); Component[] components = xWFitLayout.getComponents();
xWFitLayout.removeAll(); xWFitLayout.removeAll();
layout.resetStyle(); layout.resetStyle();

605
designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

@ -1,52 +1,591 @@
package com.fr.design.report; package com.fr.design.report;
import com.fr.config.ServerPreferenceConfig; import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.fun.StyleUIConfigProvider;
import com.fr.design.style.StylePane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.general.ComparatorUtils; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.cell.settingpane.style.ThemedCellStyleListPane;
import com.fr.design.mainframe.theme.ui.NoEdgeTitleBorder;
import com.fr.design.style.AlignmentPane;
import com.fr.design.style.BorderPane;
import com.fr.design.style.BorderUtils;
import com.fr.design.style.FRFontPane;
import com.fr.design.style.FormatPane;
import com.fr.design.style.background.BackgroundPane;
import com.fr.general.FRFont;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.FloatElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.ElementCase;
import com.fr.report.elementcase.TemplateElementCase;
import javax.swing.BorderFactory;
import javax.swing.*; import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.util.ArrayList;
import java.awt.event.MouseEvent; import java.util.List;
public class ReportStylePane extends StylePane { public class ReportStylePane extends BasicPane {
public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{
Toolkit.i18nText("Fine-Design_Style_Follow_Theme"),
Toolkit.i18nText("Fine-Design_Style_Not_Follow_Theme"),
};
public static final int DEFAULT_SELECTED_INDEX = 0;
private static final int Y_OFFSET = 8; private final PreviewArea previewArea;
private final UIButtonGroup<String> followingThemeButtonGroup;
private final CustomFloatStyleSettingPane customStylePane;
private final ThemedCellStyleListPane themedCellStyleListPane;
private final CardLayout cardLayout;
private final JComponent[] panes = new JComponent[2];
private final JPanel contentPane;
public ReportStylePane() { public ReportStylePane() {
super(); setLayout(FRGUIPaneFactory.createBorderLayout());
getPreviewArea().addMouseListener(new MouseAdapter() { setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
previewArea = new PreviewArea();
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
customStylePane = new CustomFloatStyleSettingPane();
themedCellStyleListPane = new ThemedCellStyleListPane();
panes[0] = createThemedStylePane();
panes[1] = createCustomStylePane();
cardLayout = new CardLayout();
contentPane = createTabbedContentPane();
initializePane();
themedCellStyleListPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewArea();
}
});
customStylePane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewArea();
}
});
}
private void initializePane() {
add(createPreviewPane(), BorderLayout.NORTH);
JPanel settingContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel followingThemePane = createFollowingThemePane();
followingThemePane.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0));
settingContainer.add(followingThemePane, BorderLayout.NORTH);
settingContainer.add(contentPane, BorderLayout.CENTER);
add(settingContainer, BorderLayout.CENTER);
}
private JPanel createPreviewPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Preview")));
container.setPreferredSize(new Dimension(container.getPreferredSize().width, 60));
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
content.setBorder(BorderFactory.createEmptyBorder(4, 4, 2, 2));
previewArea.setPreferredSize(new Dimension(container.getPreferredSize().width, 42));
content.add(previewArea, BorderLayout.NORTH);
container.add(content, BorderLayout.NORTH);
return container;
}
private JPanel createFollowingThemePane() {
followingThemeButtonGroup.setSelectedIndex(DEFAULT_SELECTED_INDEX);
followingThemeButtonGroup.addActionListener(new ActionListener() {
@Override @Override
public void mousePressed(MouseEvent evt) { public void actionPerformed(ActionEvent e) {
if (!SwingUtilities.isRightMouseButton(evt)) { int selectedIndex = followingThemeButtonGroup.getSelectedIndex();
return; cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]);
} if (selectedIndex == 1) {
// 对于同一个单元格,跟随主题切换到自定义,若跟随主题面板有选中项,则自定义中的配置与其保持一致,否则自定义中配置保持不变
JPopupMenu popupMenu = new JPopupMenu(); NameStyle lastSelectedNameStyle = themedCellStyleListPane.updateBean();
UIMenuItem menuItem = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Save_As_Global_Style")); if (lastSelectedNameStyle != null) {
popupMenu.add(menuItem); Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle();
menuItem.addActionListener(new ActionListener() { try {
public void actionPerformed(ActionEvent e) { lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone();
String name = FineJOptionPane.showInputDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Input_The_Name_Of_Gloabel_Style")); if (lastSelectedRealStyle != null) {
if (ComparatorUtils.equals(name, "")) { customStylePane.populateBean(lastSelectedRealStyle);
return; }
} catch (CloneNotSupportedException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
} }
if (ServerPreferenceConfig.getInstance().getStyle(name) == null) { }
ServerPreferenceConfig.getInstance().putStyle(name, ReportStylePane.this.updateBean()); } else {
} else { // 对于同一个单元格,自定义切换到跟随主题,跟随主题应当清除选中项,即没有选中任何主题中的单元格样式,
FineJOptionPane.showMessageDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_This_Name_Has_Exsit") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Warning"), JOptionPane.WARNING_MESSAGE); // 因为还未选中,所以自定义中的配置保持不变,此时若用户切换会自定义,配置应当与之前一样
themedCellStyleListPane.populateBean(null);
}
}
});
UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Setting"));
double p = TableLayout.PREFERRED;
return TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{ new Component[] { uiLabel, followingThemeButtonGroup} },
new double[] { p }, new double[] { p, 160},
IntervalConstants.INTERVAL_L1, 0);
}
protected JPanel createTabbedContentPane() {
JPanel contentPane = new JPanel(cardLayout) {
@Override
public Dimension getPreferredSize() {
int selectedIndex = followingThemeButtonGroup.getSelectedIndex();
if (selectedIndex < 0) {
return super.getPreferredSize();
} else {
return panes[selectedIndex].getPreferredSize();
}
}
};
for (int i = 0; i < FOLLOWING_THEME_STRING_ARRAYS.length; i++) {
contentPane.add(panes[i], FOLLOWING_THEME_STRING_ARRAYS[i]);
}
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[DEFAULT_SELECTED_INDEX]);
return contentPane;
}
private JPanel createThemedStylePane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(createTitleBorder(Toolkit.i18nText("Fine-Design_Style_Selecting")));
themedCellStyleListPane.setBorder(BorderFactory.createEmptyBorder());
UIScrollPane scrollPane = new UIScrollPane(themedCellStyleListPane);
scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 0));
scrollPane.setPreferredSize(new Dimension(620, scrollPane.getPreferredSize().height));
container.add(scrollPane, BorderLayout.CENTER);
return container;
}
private JPanel createCustomStylePane() {
return customStylePane;
}
public void setSelectedIndex(int index) {
if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) {
followingThemeButtonGroup.setSelectedIndex(index);
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]);
}
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style");
}
public int getSelectedIndex() {
return followingThemeButtonGroup.getSelectedIndex();
}
public void populate(ElementCasePane reportPane) {
populateBean(this.analyzeCurrentStyle(reportPane));
updatePreviewArea();
}
private Style analyzeCurrentStyle(ElementCasePane reportPane) {
Style style = null;
// p:从选中的CellElement那里先获得原始的Style.
Selection sel = reportPane.getSelection();
if (sel instanceof FloatSelection) {
// got simple cell element from column and row.
ElementCase report = reportPane.getEditingElementCase();
FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection) sel).getSelectedFloatName());
style = selectedFloatElement.getStyle();
} else {
CellSelection cs = (CellSelection) sel;
// got simple cell element from column and row.
ElementCase report = reportPane.getEditingElementCase();
CellElement editCellElement = report.getCellElement(cs.getColumn(), cs.getRow());
if (editCellElement != null && editCellElement.getStyle() != null) {// editCellElement
// cellstyle.
try {
style = (Style) editCellElement.getStyle().clone();
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
if (style == null) {
// peter:获取默认的Style.
style = Style.DEFAULT_STYLE;
}
return style;
}
public boolean update(ElementCasePane reportPane) {
return applyStyle(reportPane, updateBean());
}
private boolean applyStyle(ElementCasePane reportPane, Style style) {
TemplateElementCase report = reportPane.getEditingElementCase();
Selection sel = reportPane.getSelection();
if (sel instanceof FloatSelection) {
FloatElement floatElement = report.getFloatElement(((FloatSelection) sel).getSelectedFloatName());
// Apply style.
floatElement.setStyle(style);
} else {
CellSelection cs = (CellSelection) sel;
// Got editCellElement.
TemplateCellElement editCellElement;
// 需要先行后列地增加新元素。
for (int j = 0; j < cs.getRowSpan(); j++) {
for (int i = 0; i < cs.getColumnSpan(); i++) {
int column = i + cs.getColumn();
int row = j + cs.getRow();
editCellElement = report.getTemplateCellElement(column, row);
if (editCellElement == null) {
editCellElement = new DefaultTemplateCellElement(column, row);
report.addCellElement(editCellElement);
}
// Apply cellstyle.
editCellElement.setStyle(style);
}
}
}
if (getSelectedIndex() == 1) {
// p:因为borderpane特殊,update borderpane
customStylePane.dealBorder(reportPane);
}
reportPane.repaint();
return true;
}
public Style updateBean() {
if (getSelectedIndex() == 0) {
NameStyle nameStyle = themedCellStyleListPane.updateBean();
if (nameStyle != null) {
// 只有当前样式面板是跟随主题面板,且跟随主题面板中存在选中项,才使用该样式设置单元格
return nameStyle;
}
}
return customStylePane.updateBean();
}
public void populateBean(Style style) {
if (style instanceof NameStyle) {
NameStyle nameStyle = (NameStyle) style;
setSelectedIndex(0);
themedCellStyleListPane.populateBean(nameStyle);
Style realStyle = nameStyle.getRealStyle();
try {
realStyle = (Style) realStyle.clone();
customStylePane.populateBean(realStyle);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
} else {
setSelectedIndex(1);
customStylePane.populateBean(style);
}
}
public void updatePreviewArea() {
previewArea.setStyle(updateBean());
}
private static class PreviewArea extends JComponent {
private static final String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public void setStyle(Style style) {
this.style = style;
repaint();
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
return;
}
Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3);
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}
private static class CustomFloatStyleSettingPane extends BasicPane implements ChangeListener {
private static final int ALIGNMENT_INDEX = 1;
private static final int FONT_INDEX = 2;
private static final int BORDER_INDEX = 3;
private static final int BACKGROUND_INDEX = 4;
private static final int NEXT_TAB_INDEX = 5;
protected Style editing;
private FormatPane formatPane = null;
private AlignmentPane alignmentPane = null;
private FRFontPane frFontPane = null;
private BorderPane borderPane = null;
private BackgroundPane backgroundPane = null;
private static final List<StyleUIConfigProvider> configList = PluginSandboxCollections.newSandboxList();
private final List<ChangeListener> changeListeners = new ArrayList<>();
public CustomFloatStyleSettingPane() {
setLayout(FRGUIPaneFactory.createBorderLayout());
UITabbedPane mainTabbedPane = new UITabbedPane();
mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Format"), this.getFormatPane());
mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alignment"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sytle_FRFont"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
for (StyleUIConfigProvider config : configList) {
mainTabbedPane.addTab(config.configName(), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
}
mainTabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent evt) {
Object tabObj = evt.getSource();
if (!(tabObj instanceof JTabbedPane)) {
return;
}
JTabbedPane tabbedPane = (JTabbedPane) tabObj;
int selectedIndex = tabbedPane.getSelectedIndex();
if (tabbedPane.getComponentAt(selectedIndex).getClass() == JPanel.class) {// 是JPanel,需要替换
if (selectedIndex == ALIGNMENT_INDEX) {
tabbedPane.setComponentAt(selectedIndex, getAlignmentPane());
} else if (selectedIndex == FONT_INDEX) {
tabbedPane.setComponentAt(selectedIndex, getFRFontPane());
} else if (selectedIndex == BORDER_INDEX) {
tabbedPane.setComponentAt(selectedIndex, getBorderPane());
} else if (selectedIndex == BACKGROUND_INDEX) {
tabbedPane.setComponentAt(selectedIndex, getBackgroundPane());
} else if (configList.size() + NEXT_TAB_INDEX > selectedIndex && configList.get(selectedIndex - NEXT_TAB_INDEX) != null) {
tabbedPane.setComponentAt(selectedIndex, configList.get(selectedIndex - NEXT_TAB_INDEX).uiComponent(this));
configList.get(selectedIndex - NEXT_TAB_INDEX).populateConfig(editing);
} }
} }
});
GUICoreUtils.showPopupMenu(popupMenu, ReportStylePane.this, evt.getX() - 1, evt.getY() + Y_OFFSET); stateChanged(evt);
}
});
add(mainTabbedPane, BorderLayout.CENTER);
}
public void addChangeListener(ChangeListener changeListener) {
this.changeListeners.add(changeListener);
}
protected FormatPane getFormatPane() {
if (this.formatPane == null) {
this.formatPane = new FormatPane();
if (this.editing != null) {
this.formatPane.populate(this.editing.getFormat());
}
}
return this.formatPane;
}
private AlignmentPane getAlignmentPane() {
if (this.alignmentPane == null) {
this.alignmentPane = new AlignmentPane();
this.alignmentPane.addChangeListener(this);
if (this.editing != null) {
this.alignmentPane.populate(this.editing);
}
} }
});
return this.alignmentPane;
}
private FRFontPane getFRFontPane() {
if (this.frFontPane == null) {
this.frFontPane = new FRFontPane();
this.frFontPane.addChangeListener(this);
if (this.editing != null) {
this.frFontPane.populate(this.editing.getFRFont());
}
}
return this.frFontPane;
}
private BorderPane getBorderPane() {
if (this.borderPane == null) {
this.borderPane = new BorderPane();
this.borderPane.addChangeListener(this);
if (this.editing != null) {
this.borderPane.populate(this.editing);
}
}
return this.borderPane;
}
private BackgroundPane getBackgroundPane() {
if (this.backgroundPane == null) {
this.backgroundPane = new BackgroundPane();
this.backgroundPane.addChangeListener(this);
if (this.editing != null) {
this.backgroundPane.populate(this.editing.getBackground());
}
}
return this.backgroundPane;
}
public void populateBean(Style ob) {
this.editing = ob == null ? Style.getInstance() : ob;
if (this.formatPane != null) {
this.formatPane.populate(editing.getFormat());
}
if (this.alignmentPane != null) {
this.alignmentPane.populate(editing);
}
if (this.frFontPane != null) {
this.frFontPane.populate(editing.getFRFont());
}
if (this.borderPane != null) {
this.borderPane.populate(editing);
}
if (this.backgroundPane != null) {
this.backgroundPane.populate(editing.getBackground());
}
for(StyleUIConfigProvider tabConfig : configList){
tabConfig.populateConfig(this.editing);
}
}
public Style updateBean() {
// need the check the valid of CellAlignment pane.
try {
if (this.alignmentPane != null) {
this.alignmentPane.checkValid();
}
} catch (Exception exp) {
FineJOptionPane.showMessageDialog(this, exp.getMessage());
return editing;
}
Style style = editing;
if (this.formatPane != null) {
style = style.deriveFormat(this.formatPane.update());
}
if (this.alignmentPane != null) {
style = this.alignmentPane.update(style);
}
if (this.frFontPane != null) {
style = style.deriveFRFont(this.frFontPane.update());
}
if (this.borderPane != null) {
style = this.borderPane.update(style);
}
if (this.backgroundPane != null) {
style = style.deriveBackground(this.backgroundPane.update());
}
for(StyleUIConfigProvider tabConfig : configList){
style = tabConfig.updateConfig();
}
return style;
}
public void dealBorder(ElementCasePane reportPane) {
if (this.borderPane != null) {
BorderUtils.update(reportPane, this.borderPane.update());
}
}
@Override
protected String title4PopupWindow() {
return null;
}
@Override
public void stateChanged(ChangeEvent e) {
for (ChangeListener changeListener: changeListeners) {
changeListener.stateChanged(e);
}
}
}
private Border createTitleBorder(String title) {
return new NoEdgeTitleBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(
0,
0,
0,
0),
new UIRoundedBorder(
UIConstants.TITLED_BORDER_COLOR,
1,
10)
),
title,
TitledBorder.LEADING,
TitledBorder.TOP,
FRFont.getInstance().deriveFont(12F),
new Color(0x2F8EF1)
);
} }
} }

Loading…
Cancel
Save