Browse Source

Merge remote-tracking branch 'origin/release/11.0' into release/11.0

release/11.0
lixing 10 months ago
parent
commit
02d947b391
  1. 17
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeEditorPane.java
  2. 30
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java
  3. 12
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ThemePreviewed.java
  4. 62
      designer-base/src/main/java/com/fr/widgettheme/ThemePreviewTerminal.java
  5. 5
      designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/WidgetStyleEditContainerPane.java
  6. 26
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/ControlPreviewCell.java
  7. 8
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/ControlPreviewPane.java
  8. 15
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/NormalButtonPreviewCell.java
  9. 17
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/TextPreviewCell.java
  10. 8
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetDisplayFormThemePreviewPane.java
  11. 8
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetDisplayReportThemePreviewPane.java
  12. 4
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java

17
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeEditorPane.java

@ -5,6 +5,7 @@ import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.settings.ThemedCellStyleList;
import com.fr.base.theme.settings.ThemedColorScheme;
import com.fr.widgettheme.ThemePreviewTerminal;
import com.fr.widgettheme.util.WidgetThemeDesignerUtils;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
@ -340,4 +341,20 @@ public abstract class TemplateThemeEditorPane<T extends TemplateTheme> extends J
}
}
}
/**
* 开启控件显示增强时从配置面板处获取主题样式预览的终端类型
* 默认为PC端兼容原有场景
*/
public ThemePreviewTerminal getWidgetStyleEditorTerminal() {
if (!WidgetThemeDesignerUtils.enableWidgetEnhance()) {
return ThemePreviewTerminal.PC;
}
for (BasicBeanPane<T> pane : extraPaneList) {
if (pane instanceof WidgetStyleEditContainerPane) {
return ((WidgetStyleEditContainerPane<T>) pane).getTerminalStyle();
}
}
return ThemePreviewTerminal.PC;
}
}

30
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java

@ -14,12 +14,13 @@ import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog;
import com.fr.design.mainframe.theme.edit.ui.LabelUtils;
import com.fr.design.mainframe.theme.ui.AutoCheckTextField;
import com.fr.design.mainframe.theme.ui.AutoCheckThemeNameTextField;
import com.fr.design.mainframe.theme.ui.BorderUtils;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.transaction.CallBackAdaptor;
import com.fr.widgettheme.ThemePreviewTerminal;
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
@ -51,7 +52,8 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
protected TemplateThemePreviewPane<T> themePreviewPane;
protected TemplateThemeEditorPane<T> themeEditorPane;
protected UILabel leftTitleLabel;
protected UILabel leftTitlePromptLabel;
protected boolean isPopulating = false;
protected boolean isMutable = false;
@ -83,10 +85,9 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
private JPanel createLeftPane() {
JPanel titleContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
titleContainer.setPreferredSize(new Dimension(LEFT_TITLE_PANE_WIDTH, LEFT_TITLE_PANE_HEIGHT));
titleContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Preview_Pane_Title"), TITLE_BORDER_FONT));
JPanel previewContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewContainer.setBorder(BorderFactory.createEmptyBorder(5, 4, 10, 4));
titleContainer.add(createTitlePane(), BorderLayout.NORTH);
titleContainer.add(previewContainer, BorderLayout.CENTER);
themePreviewPane = createThemePreviewPane();
@ -103,7 +104,10 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
if (isPopulating) {
return;
}
themePreviewPane.refresh(updateBean());
ThemePreviewTerminal terminal = themeEditorPane.getWidgetStyleEditorTerminal();
themePreviewPane.refresh(updateBean(), terminal);
String prompt = terminal == ThemePreviewTerminal.PC ? Toolkit.i18nText("Fine-Design_Theme_Control_PC_Prompt") : Toolkit.i18nText("Fine-Design_Theme_Control_Mobile_Prompt");
leftTitlePromptLabel.setText(prompt);
saveButton.setEnabled(themeEditorPane.checkNameValid() && isMutable);
}
});
@ -367,4 +371,20 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
@Override
public void onSaved(TemplateTheme theme) {}
}
/**
* 创建预览界面标题面板
*/
protected JPanel createTitlePane() {
JPanel titlePane = new JPanel();
titlePane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
titlePane.setLayout(new BorderLayout());
leftTitleLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Preview_Pane_Title"));
leftTitlePromptLabel = new UILabel(Toolkit.i18nText("Fine-Design_Theme_Control_PC_Prompt"));
leftTitleLabel.setForeground(WidgetThemeDisplayConstants.THEME_PREVIEW_TITLE_COLOR);
leftTitlePromptLabel.setForeground(WidgetThemeDisplayConstants.COMPATIBLE_STYLE_FONT_COLOR);
titlePane.add(leftTitleLabel, BorderLayout.WEST);
titlePane.add(leftTitlePromptLabel, BorderLayout.EAST);
return titlePane;
}
}

12
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ThemePreviewed.java

@ -1,5 +1,7 @@
package com.fr.design.mainframe.theme.preview;
import com.fr.widgettheme.ThemePreviewTerminal;
/**
* @author Starryi
* @version 1.0
@ -7,4 +9,14 @@ package com.fr.design.mainframe.theme.preview;
*/
public interface ThemePreviewed<T> {
void refresh(T style);
/**
* 根据主题预览样式类型进行刷新
*
* @param style 样式可以包含多个终端展现效果
* @param terminal 终端类型
*/
default void refresh(T style, ThemePreviewTerminal terminal) {
refresh(style);
}
}

62
designer-base/src/main/java/com/fr/widgettheme/ThemePreviewTerminal.java

@ -0,0 +1,62 @@
package com.fr.widgettheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.widgettheme.theme.widget.style.MobileThemedWidgetStyle;
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle;
/**
* 主题样式预览终端类型
*
* @author obo
* @since 11.0
* Created on 2024/2/2
*/
public enum ThemePreviewTerminal {
/**
* 桌面端,为默认类型
*/
PC(0) {
@Override
public ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme) {
return (ThemedWidgetStyle) theme.getWidgetStyle();
}
},
/**
* 移动端
*/
MOBILE(1) {
@Override
public ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme) {
return (MobileThemedWidgetStyle) theme.getMobileWidgetStyle();
}
};
/**
* 类型码
*/
final int code;
ThemePreviewTerminal(int code) {
this.code = code;
}
public int getCode() {
return code;
}
public abstract ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme);
/**
* 根据code获取对应的枚举
*/
public static ThemePreviewTerminal getTypeByCode(int code) {
for (ThemePreviewTerminal type : ThemePreviewTerminal.values()) {
if (type.code == code) {
return type;
}
}
throw new IllegalArgumentException("Invalid ThemePreviewTerminalType code :" + code);
}
}

5
designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/WidgetStyleEditContainerPane.java

@ -8,6 +8,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.widgettheme.ThemePreviewTerminal;
import org.jetbrains.annotations.Nullable;
import javax.swing.JPanel;
@ -133,4 +134,8 @@ public class WidgetStyleEditContainerPane<T extends TemplateTheme> extends Basic
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Theme_Widget_Style");
}
public ThemePreviewTerminal getTerminalStyle() {
return ThemePreviewTerminal.getTypeByCode(terminalStyleGroup.getSelectedIndex());
}
}

26
designer-base/src/main/java/com/fr/widgettheme/theme/panel/ControlPreviewCell.java

@ -3,6 +3,8 @@ package com.fr.widgettheme.theme.panel;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.base.theme.TemplateTheme;
import com.fr.widgettheme.ThemePreviewTerminal;
import com.fr.widgettheme.theme.widget.style.ThemeTextStyle;
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.FRFont;
@ -14,7 +16,6 @@ import javax.swing.ImageIcon;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
@ -39,6 +40,11 @@ public class ControlPreviewCell extends JPanel {
*/
protected String value;
protected TemplateTheme reportTheme;
/**
* 主题预览类型默认为PC端
*/
protected ThemePreviewTerminal themePreviewTerminal = ThemePreviewTerminal.PC;
/**
* 字体的颜色
*/
@ -70,9 +76,10 @@ public class ControlPreviewCell extends JPanel {
/**
* 主题样式变化后监听改变
*/
public void refresh(TemplateTheme reportTheme) {
public void refresh(TemplateTheme reportTheme, ThemePreviewTerminal type) {
this.reportTheme = reportTheme;
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) this.reportTheme.getWidgetStyle();
this.themePreviewTerminal = type;
ThemedWidgetStyle widgetStyle = this.themePreviewTerminal.getThemeWidgetStyle(reportTheme);
//主题色设置为透明或者插件启动前已有的主题启动插件后主题色为null
if (widgetStyle.getThemeColor() == null) {
widgetStyle.setThemeColor(DEFAULT_THEME_COLOR);
@ -87,8 +94,7 @@ public class ControlPreviewCell extends JPanel {
}
public Color getIconColor() {
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle();
return widgetStyle.getIconColor();
return this.themePreviewTerminal.getThemeWidgetStyle(reportTheme).getIconColor();
}
protected Icon setStyleTwoIcon(Icon icon, Icon defaultIcon) {
@ -106,13 +112,15 @@ public class ControlPreviewCell extends JPanel {
* 填充圆角矩形背景色
*/
public void paintBgColor(Graphics g, ThemedWidgetStyle widgetStyle, int alpha) {
Color themeColor = widgetStyle.getWidgetBackground().getColor();
ThemedWidgetStyle themeWidgetStyle = this.themePreviewTerminal.getThemeWidgetStyle(this.reportTheme);
Color themeColor = themeWidgetStyle.getThemeColor();
themeColor = themeColor == null ? WidgetThemeDisplayConstants.DEFAULT_TRANSPARENT_COLOR : themeColor;
g.setColor(new Color(themeColor.getRed(), themeColor.getGreen(), themeColor.getBlue(), alpha));
g.fillRoundRect(0, 0, getSize().width - 1, getSize().height - 1, (int) widgetStyle.getBorderStyle().getRadius(), (int) widgetStyle.getBorderStyle().getRadius());
//需要重新绘制一遍字体,否则会被颜色填充给遮住
Graphics2D g2d = (Graphics2D) g.create();
FRFont font = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, widgetStyle.getTextStyle().getFontSize(), textColor);
ThemeTextStyle textStyle = themeWidgetStyle.getTextStyle();
FRFont font = FRFont.getInstance(textStyle.getName(), textStyle.getCompositeFontStyle(), textStyle.getFontSize(), textStyle.getFontColor());
BaseUtils.drawStringStyleInRotation(g2d, getWidth(), getHeight(), this.value,
Style.getInstance(font).deriveHorizontalAlignment(Constants.LEFT)
.deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), NO_SCALE_RESOLUTION);
@ -125,8 +133,8 @@ public class ControlPreviewCell extends JPanel {
return;
}
Graphics2D g2d = (Graphics2D) g.create();
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle();
FRFont font = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, widgetStyle.getTextStyle().getFontSize(), textColor);
ThemeTextStyle textStyle = this.themePreviewTerminal.getThemeWidgetStyle(reportTheme).getTextStyle();
FRFont font = FRFont.getInstance(textStyle.getName(), textStyle.getCompositeFontStyle(), textStyle.getFontSize(), textStyle.getFontColor());
//每个预览格子通用的字体绘制
BaseUtils.drawStringStyleInRotation(g2d, getWidth(), getHeight(), this.value,
Style.getInstance(font).deriveHorizontalAlignment(Constants.LEFT)

8
designer-base/src/main/java/com/fr/widgettheme/theme/panel/ControlPreviewPane.java

@ -6,6 +6,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.preview.ThemePreviewed;
import com.fr.general.Background;
import com.fr.widgettheme.ThemePreviewTerminal;
import javax.swing.JPanel;
import java.awt.Color;
@ -42,9 +43,14 @@ public class ControlPreviewPane extends JPanel implements ThemePreviewed<Templat
@Override
public void refresh(TemplateTheme style) {
refresh(style, ThemePreviewTerminal.PC);
}
@Override
public void refresh(TemplateTheme style, ThemePreviewTerminal type) {
this.background = style.getParamContainerStyle().getBackground();
for (ControlPreviewCell controlPreviewCell : list) {
controlPreviewCell.refresh(style);
controlPreviewCell.refresh(style, type);
}
}

15
designer-base/src/main/java/com/fr/widgettheme/theme/panel/NormalButtonPreviewCell.java

@ -1,12 +1,15 @@
package com.fr.widgettheme.theme.panel;
import com.fr.widgettheme.theme.widget.style.ThemeTextStyle;
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.general.FRFont;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.LayoutManager;
/**
* 主题参数面板按钮预览格子
@ -40,10 +43,12 @@ public class NormalButtonPreviewCell extends ControlPreviewCell {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle();
ThemedWidgetStyle widgetStyle = this.themePreviewTerminal.getThemeWidgetStyle(this.reportTheme);
paintBgColor(g, widgetStyle);
uiLabel.setForeground(Color.WHITE);
FRFont font = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, widgetStyle.getTextStyle().getFontSize(), Color.WHITE);
uiLabel.setBackground(widgetStyle.getThemeColor());
ThemeTextStyle textStyle = widgetStyle.getTextStyle();
uiLabel.setForeground(textStyle.getFontColor());
FRFont font = FRFont.getInstance(textStyle.getName(), textStyle.getCompositeFontStyle(), textStyle.getFontSize(), textStyle.getFontColor());
uiLabel.setFont(font);
this.add(uiLabel, BorderLayout.CENTER);
}

17
designer-base/src/main/java/com/fr/widgettheme/theme/panel/TextPreviewCell.java

@ -1,9 +1,10 @@
package com.fr.widgettheme.theme.panel;
import com.fr.base.theme.TemplateTheme;
import com.fr.widgettheme.ThemePreviewTerminal;
import com.fr.widgettheme.theme.widget.style.ThemeTextStyle;
import java.awt.*;
import java.awt.LayoutManager;
/**
* 文字预览格子
@ -24,13 +25,9 @@ public class TextPreviewCell extends ControlPreviewCell {
}
@Override
public void refresh(TemplateTheme reportTheme) {
super.refresh(reportTheme);
// 文字根据是否深色主题自适应改变
if (reportTheme.isDark()) {
textColor = Color.WHITE;
} else {
textColor = Color.BLACK;
}
public void refresh(TemplateTheme reportTheme, ThemePreviewTerminal type) {
super.refresh(reportTheme, type);
ThemeTextStyle textStyle = type.getThemeWidgetStyle(reportTheme).getTextStyle();
textColor = textStyle.getFontColor();
}
}

8
designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetDisplayFormThemePreviewPane.java

@ -21,6 +21,7 @@ import com.fr.plugin.chart.type.RadiusType;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import com.fr.widgettheme.ThemePreviewTerminal;
import javax.swing.JPanel;
import java.awt.AlphaComposite;
@ -100,12 +101,17 @@ public class WidgetDisplayFormThemePreviewPane extends TemplateThemePreviewPane<
@Override
public void refresh(FormTheme theme) {
refresh(theme, ThemePreviewTerminal.PC);
}
@Override
public void refresh(FormTheme theme, ThemePreviewTerminal themeStyleType) {
background = theme.getBodyStyle().getStyle().getBackground();
alpha = theme.getBodyStyle().getStyle().getAlpha();
elementCasePane.refresh(theme);
columnChartPreviewPane.refresh(theme);
pieChartPreviewPane.refresh(theme);
controlPreviewPane.refresh(theme);
controlPreviewPane.refresh(theme, themeStyleType);
repaint();
}

8
designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetDisplayReportThemePreviewPane.java

@ -13,6 +13,7 @@ import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.widgettheme.ThemePreviewTerminal;
import java.awt.BorderLayout;
import java.awt.Color;
@ -59,10 +60,15 @@ public class WidgetDisplayReportThemePreviewPane extends TemplateThemePreviewPan
@Override
public void refresh(ReportTheme theme) {
refresh(theme, ThemePreviewTerminal.PC);
}
@Override
public void refresh(ReportTheme theme, ThemePreviewTerminal terminal) {
background = theme.getBodyStyle().getBackground();
reportPreviewPane.refresh(theme);
chartPreviewPane.refresh(theme);
controlPreviewPane.refresh(theme);
controlPreviewPane.refresh(theme, terminal);
repaint();
}

4
designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java

@ -6,6 +6,7 @@ import com.fr.chart.web.ChartHyperPoplink;
import com.fr.chart.web.ChartHyperRelateCellLink;
import com.fr.chart.web.ChartHyperRelateFloatLink;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.javascript.ChartEmailPane;
import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane;
@ -24,7 +25,6 @@ import com.fr.design.javascript.JavaScriptImplPane;
import com.fr.design.javascript.ParameterJavaScriptPane;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
@ -149,7 +149,7 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane {
}
private void refreshNameableCreator() {
if (ChartEditContext.duchampMode()) {
if (DesignModeContext.isDuchampMode()) {
return;
}
HashMap paneMap = getHyperlinkMap();

Loading…
Cancel
Save