Browse Source

Merge branch 'feature/x' of ssh://code.fineres.com:7999/~fanglei/design10.0 into feature/x

* 'feature/x' of ssh://code.fineres.com:7999/~fanglei/design10.0:
  REPORT-59908 && REPORT-59906 && REPORT-59907
  REPORT-59844 视觉微调
  REPORT-59351 【主题切换】国际化显示问题
  REPORT-59674 FR11新主题,单元格样式跟随主题时,样式选择中的字体看不清
  REPORT-59423 【主题切换】高分辨率下主题管理页面显示不全
  REPORT-59756 【主题切换】新建主题时,输入主题名称的时候会卡顿 & REPORT-59078 【主题切换】主题编辑界面 保存按钮交互优化
  REPORT-57298【回归测试】控件事件名显示完全,但出现横向滚动条
  代码修改
  REPORT-57810 固定布局-原布局推荐4.1
  REPORT-59719 fix加个判断
  REPORT-59719 下拉框效果还有点问题 fix
  REPORT-59770 【主题切换】编辑主题时,主题配色修改以后,细节配置和整体预览里的颜色没有相应联动
  REPORT-59719 下拉框效果还有点问题
  REPORT-59719 【10.0】点击数据源的刷新按钮,数据列表会变空白
research/11.0
方磊 3 years ago
parent
commit
dce5874859
  1. 31
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  2. 5
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  3. 14
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java
  4. 8
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java
  5. 28
      designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java
  6. 25
      designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java
  7. 315
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeEditorPane.java
  8. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java
  9. 496
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java
  10. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java
  11. 28
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java
  12. 7
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java
  13. 19
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java
  14. 1
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/TabbedPane.java
  15. 6
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java
  16. 100
      designer-base/src/main/java/com/fr/design/mainframe/theme/ui/AutoCheckTextField.java
  17. 26
      designer-base/src/main/java/com/fr/design/mainframe/theme/ui/AutoCheckThemeNameTextField.java
  18. BIN
      designer-base/src/main/resources/com/fr/design/images/transparent_background.png
  19. 14
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java
  20. 9
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java
  21. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java
  22. 19
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  23. 7
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  24. 3
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  25. 2
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

31
designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

@ -6,6 +6,9 @@ import com.fr.base.Style;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@ -40,10 +43,21 @@ public class CellStylePreviewPane extends JPanel {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
int width = getWidth(); paintTransparentBackground(g2d, style);
int height = getHeight();
paintCellStyle(g2d, style);
}
private void paintTransparentBackground(Graphics2D g2d, Style style) {
Color fontColor = style.getFRFont().getForeground();
float g = fontColor.getRed() * 0.299F + fontColor.getGreen() * 0.587F * fontColor.getBlue() * 0.114F;
float alpha = 1.0F;
if (g < 50) {
alpha = 0.2F;
} else if (g < 160){
alpha = 0.5F;
}
float scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth; float scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth;
float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight; float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight;
@ -54,7 +68,18 @@ public class CellStylePreviewPane extends JPanel {
} else { } else {
scaleHeight = scaleWidth = maxScale; scaleHeight = scaleWidth = maxScale;
} }
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
g2d.drawImage(transparentBackgroundImage, 0, 0, (int) (transparentBackgroundWidth * scaleWidth), (int) (transparentBackgroundHeight * scaleHeight), null); g2d.drawImage(transparentBackgroundImage, 0, 0, (int) (transparentBackgroundWidth * scaleWidth), (int) (transparentBackgroundHeight * scaleHeight), null);
g2d.setComposite(oldComposite);
}
private void paintCellStyle(Graphics2D g2d, Style style) {
int resolution = ScreenResolution.getScreenResolution();
int width = getWidth();
int height = getHeight();
if (style == Style.DEFAULT_STYLE) { if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去 // 如果是默认的style,就只写"Report"上去

5
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java

@ -80,12 +80,13 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
* 刷新ComboBox.items * 刷新ComboBox.items
*/ */
protected Iterator<String> items() { protected Iterator<String> items() {
nameList = new ArrayList<String>();
ConnectionConfig mgr = ConnectionConfig.getInstance(); ConnectionConfig mgr = ConnectionConfig.getInstance();
Iterator<String> nameIt = mgr.getConnections().keySet().iterator(); Iterator<String> nameIt = mgr.getConnections().keySet().iterator();
Collection<String> noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections(); Collection<String> noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections();
nameList = new ArrayList<>();
if (noAuthConnections == null) { if (noAuthConnections == null) {
return nameList.iterator(); return nameList.iterator();
} }

14
designer-base/src/main/java/com/fr/design/data/datapane/connect/ItemEditableComboBoxPanel.java

@ -91,6 +91,9 @@ public abstract class ItemEditableComboBoxPanel extends JPanel {
refreshWorker.cancel(true); refreshWorker.cancel(true);
} }
// 记录原来选中的Item,重新加载后需要再次选中
Object lastSelectedItem = itemComboBox.getSelectedItem();
DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel()); DefaultComboBoxModel model = ((DefaultComboBoxModel) itemComboBox.getModel());
model.removeAllElements(); model.removeAllElements();
@ -98,6 +101,12 @@ public abstract class ItemEditableComboBoxPanel extends JPanel {
model.addElement(EMPTY); model.addElement(EMPTY);
model.addElement(PENDING); model.addElement(PENDING);
// 存在两种场景之前只考虑了填充场景 有populate会填充下 把这边的填充逻辑删了 所以没有问题
// 如果是纯通过刷新按钮 没有populate 需要手动设置下上次选中的内容
if (lastSelectedItem != null) {
model.setSelectedItem(lastSelectedItem);
}
refreshWorker = new SwingWorker<Iterator<String>, Void>() { refreshWorker = new SwingWorker<Iterator<String>, Void>() {
@Override @Override
protected Iterator<String> doInBackground() throws Exception { protected Iterator<String> doInBackground() throws Exception {
@ -112,7 +121,12 @@ public abstract class ItemEditableComboBoxPanel extends JPanel {
while(itemIt.hasNext()) { while(itemIt.hasNext()) {
model.addElement(itemIt.next()); model.addElement(itemIt.next());
} }
// 如果加载成功 但是下拉框是可见的 下拉框高度是会固定为原始高度 不会因为填充了更多下拉项而变化
// 需要重新设置下拉框高度 但值一样时相关事件不会生效 所以先加再减下
if (itemComboBox.isPopupVisible()) {
itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1); itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() + 1);
itemComboBox.setMaximumRowCount(itemComboBox.getMaximumRowCount() - 1);
}
} catch (Exception e) { } catch (Exception e) {
if (!(e instanceof CancellationException)) { if (!(e instanceof CancellationException)) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

8
designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java

@ -329,7 +329,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
width = Math.max(width, calculateUIListMaxCellWidth(uiList.getModel(), uiList.getFontMetrics(uiList.getFont()))); width = Math.max(width, calculateUIListMaxCellWidth(uiList.getModel(), uiList.getFontMetrics(uiList.getFont())));
} }
iterator = nameEdListMap.entrySet().iterator(); iterator = nameEdListMap.entrySet().iterator();
width += 40; width += 30;
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<String, ListWrapperPane> entry = iterator.next(); Map.Entry<String, ListWrapperPane> entry = iterator.next();
ListWrapperPane wrapperPane = entry.getValue(); ListWrapperPane wrapperPane = entry.getValue();
@ -349,7 +349,8 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
} else { } else {
text = element.toString(); text = element.toString();
} }
width = Math.max(width, fontMetrics.stringWidth(text)); //增加 10px 的左右间隔
width = Math.max(width, fontMetrics.stringWidth(text) + 10);
} }
} }
return width; return width;
@ -539,7 +540,8 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
label.setBackground(Color.WHITE); label.setBackground(Color.WHITE);
label.setForeground(Color.decode("#333334")); label.setForeground(Color.decode("#333334"));
label.setFont(label.getFont().deriveFont(11F)); label.setFont(label.getFont().deriveFont(11F));
label.setPreferredSize(new Dimension(224, 26)); //预留 10px 的纵向滚动条的宽度
label.setPreferredSize(new Dimension(214, 26));
this.nameEdList = nameEdList; this.nameEdList = nameEdList;
this.add(label, BorderLayout.NORTH); this.add(label, BorderLayout.NORTH);
this.add(this.nameEdList, BorderLayout.CENTER); this.add(this.nameEdList, BorderLayout.CENTER);

28
designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java

@ -36,8 +36,22 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane<FormTheme> {
} }
@Override @Override
protected JPanel createCustomEditorsPane() { public TemplateThemeEditorPane<FormTheme> createThemeEditorPane() {
JPanel container = super.createCustomEditorsPane(); return new FormThemeEditorPane(config);
}
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Form_Theme_Profile_Dialog_Title");
}
private static class FormThemeEditorPane extends TemplateThemeEditorPane<FormTheme> {
private final FormBodyStyleEditPane formBodyStyleSettingPane;
private final ComponentStyleEditPane componentStyleSettingPane;
public FormThemeEditorPane(TemplateThemeConfig<FormTheme> config) {
super(config);
formBodyStyleSettingPane = new FormBodyStyleEditPane(); formBodyStyleSettingPane = new FormBodyStyleEditPane();
addCustomEditorPane(i18nText("Fine-Design_Predefined_Template_Background"), formBodyStyleSettingPane); addCustomEditorPane(i18nText("Fine-Design_Predefined_Template_Background"), formBodyStyleSettingPane);
@ -47,7 +61,6 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane<FormTheme> {
componentStyleSettingPane = new ComponentStyleEditPane(); componentStyleSettingPane = new ComponentStyleEditPane();
addCustomEditorPane(i18nText("Fine-Design_Predefined_Component_Style"), componentStyleSettingPane); addCustomEditorPane(i18nText("Fine-Design_Predefined_Component_Style"), componentStyleSettingPane);
return container;
} }
@Override @Override
@ -59,23 +72,20 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane<FormTheme> {
} }
@Override @Override
public void populateBean4CustomEditors(FormTheme theme) { protected void populateBean4CustomEditors(FormTheme theme) {
super.populateBean4CustomEditors(theme); super.populateBean4CustomEditors(theme);
formBodyStyleSettingPane.populateBean(theme.getBodyStyle()); formBodyStyleSettingPane.populateBean(theme.getBodyStyle());
componentStyleSettingPane.populateBean(theme.getComponentStyle()); componentStyleSettingPane.populateBean(theme.getComponentStyle());
} }
@Override @Override
public void updateBean(FormTheme theme) { protected void updateBean4CustomEditors(FormTheme theme) {
super.updateBean4CustomEditors(theme);
ThemedFormBodyStyle formBodyStyle = formBodyStyleSettingPane.updateBean(); ThemedFormBodyStyle formBodyStyle = formBodyStyleSettingPane.updateBean();
theme.setBodyStyle(formBodyStyle); theme.setBodyStyle(formBodyStyle);
ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean(); ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean();
theme.setComponentStyle(componentStyle); theme.setComponentStyle(componentStyle);
} }
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Form_Theme_Profile_Dialog_Title");
} }
} }

25
designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java

@ -25,13 +25,25 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane<ReportTheme
} }
@Override @Override
protected JPanel createCustomEditorsPane() { public TemplateThemeEditorPane<ReportTheme> createThemeEditorPane() {
JPanel container = super.createCustomEditorsPane(); return new ReportThemeEditorPane(config);
}
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Report_Theme_Profile_Dialog_Title");
}
private static class ReportThemeEditorPane extends TemplateThemeEditorPane<ReportTheme> {
private final ReportBodyStyleEditPane reportBodyStyleSettingPane;
public ReportThemeEditorPane(TemplateThemeConfig<ReportTheme> config) {
super(config);
this.reportBodyStyleSettingPane = new ReportBodyStyleEditPane(); this.reportBodyStyleSettingPane = new ReportBodyStyleEditPane();
addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Template_Background"), reportBodyStyleSettingPane); addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Template_Background"), reportBodyStyleSettingPane);
addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane()); addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane());
addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane()); addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane());
return container;
} }
@Override @Override
@ -41,12 +53,9 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane<ReportTheme
} }
@Override @Override
public void updateBean(ReportTheme theme) { public void updateBean4CustomEditors(ReportTheme theme) {
super.updateBean4CustomEditors(theme);
theme.setBodyStyle(this.reportBodyStyleSettingPane.updateBean()); theme.setBodyStyle(this.reportBodyStyleSettingPane.updateBean());
} }
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Report_Theme_Profile_Dialog_Title");
} }
} }

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

@ -0,0 +1,315 @@
package com.fr.design.mainframe.theme;
import com.fr.base.theme.FineColorFlushUtils;
import com.fr.base.theme.FineColorManager;
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.design.designer.IntervalConstants;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.frpane.UITabbedPane;
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.theme.edit.CellStyleListEditPane;
import com.fr.design.mainframe.theme.edit.ChartStyleEditPane;
import com.fr.design.mainframe.theme.edit.ui.ColorListExtendedPane;
import com.fr.design.mainframe.theme.edit.ui.ColorListPane;
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.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.util.List;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/13
*/
public abstract class TemplateThemeEditorPane<T extends TemplateTheme> extends JPanel {
public static final int LEFT_TITLE_PANE_HEIGHT = 539;
public static final int RIGHT_PANE_WIDTH = 362;
public static final int RIGHT_PANE_HEIGHT = LEFT_TITLE_PANE_HEIGHT;
protected AutoCheckThemeNameTextField<T> nameTextField;
private UILabel nameErrorLabel;
protected ColorListPane colorListPane;
private ColorListExtendedPane colorListExtendedPane;
protected CellStyleListEditPane cellStyleSettingPane;
protected ChartStyleEditPane chartStyleSettingPane;
protected boolean isPopulating = false;
protected UITabbedPane uiTabbedPane;
private final TemplateThemeConfig<T> config;
private boolean refreshingThemedColor = false;
private T theme;
private AttributeChangeListener changeListener;
private AutoCheckTextField.CheckListener themeNameCheckListener;
public TemplateThemeEditorPane(TemplateThemeConfig<T> config) {
super();
this.config = config;
theme = config.createNewTheme();
initializePane();
}
private void initializePane() {
setLayout(new BorderLayout(0, 0));
setPreferredSize(new Dimension(RIGHT_PANE_WIDTH, RIGHT_PANE_HEIGHT));
JPanel nameEditPane = createNameEditPane();
add(nameEditPane, BorderLayout.NORTH);
JPanel settingPane = new JPanel(new BorderLayout(0, IntervalConstants.INTERVAL_L1));
settingPane.add(createColorSchemeEditPane(), BorderLayout.NORTH);
settingPane.add(createCustomEditorsPane(), BorderLayout.CENTER);
add(settingPane, BorderLayout.CENTER);
}
private JPanel createNameEditPane() {
nameErrorLabel = LabelUtils.createLabel(StringUtils.EMPTY, Color.RED);
nameErrorLabel.setVisible(false);
nameTextField = new AutoCheckThemeNameTextField<>();
nameTextField.setThemeConfig(config);
nameTextField.setEditable(false);
nameTextField.setEnabled(false);
nameTextField.setPreferredSize(new Dimension(165, 20));
nameTextField.setNameCheckListener(new AutoCheckTextField.CheckListener() {
@Override
public void onChecked(String error, boolean valid) {
nameErrorLabel.setVisible(StringUtils.isNotEmpty(error));
nameErrorLabel.setText(error);
themeNameCheckListener.onChecked(error, valid);
}
});
double p = TableLayout.PREFERRED;
JPanel container = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[] { LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Name")), nameTextField },
new Component[] { null, nameErrorLabel },
}, new double[] { 20, 20}, new double[] { p, 165}, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_W0);
container.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
return container;
}
private JPanel createColorSchemeEditPane() {
colorListPane = new ColorListPane();
colorListExtendedPane = new ColorListExtendedPane();
colorListExtendedPane.setBackground(null);
colorListExtendedPane.setOpaque(false);
JPanel extendedBackgroundContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
extendedBackgroundContainer.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
extendedBackgroundContainer.setBackground(Color.WHITE);
extendedBackgroundContainer.add(colorListExtendedPane, BorderLayout.WEST);
JPanel extendedContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
extendedContainer.add(extendedBackgroundContainer, BorderLayout.WEST);
double p = TableLayout.PREFERRED;
double[] rowSize = new double[]{p, p, p};
double[] columnSize = {p, p};
JPanel colorListContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
colorListContainerPane.add(colorListPane, BorderLayout.WEST);
JPanel previewLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewLabelPane.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Preview_Label")), BorderLayout.NORTH);
UILabel tipLabel = LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Tip"), new Color(153, 153, 153));
tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Label")), colorListContainerPane},
{null, tipLabel},
{previewLabelPane, extendedContainer},
},
rowSize, columnSize, 18, 7);
content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JPanel borderContainer = new JPanel(new BorderLayout());
borderContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Title")));
borderContainer.add(content);
JPanel container = new JPanel(new BorderLayout());
container.add(borderContainer, BorderLayout.CENTER);
colorListPane.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (refreshingThemedColor) {
return;
}
List<Color> colors = colorListPane.update();
refreshingThemedColor = true;
onColorSchemeChanged(colors);
refreshingThemedColor = false;
fireAttributeChange();
}
});
return container;
}
private void onColorSchemeChanged(List<Color> colors) {
colorListExtendedPane.populate(colors);
FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors);
T theme = updateBean();
FineColorFlushUtils.replaceCacheObject(theme, replaceByColorScheme);
FineColorManager.traverse(theme, replaceByColorScheme);
populateBean4CustomEditors(theme);
//图表渐变色
chartStyleSettingPane.populateGradientBar(colors);
this.repaint();
}
protected JPanel createCustomEditorsPane() {
JPanel container = new JPanel(new BorderLayout());
container.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Custom_Settings_Title")));
uiTabbedPane = new UITabbedPane();
uiTabbedPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 1));
container.add(uiTabbedPane, BorderLayout.CENTER);
return container;
}
public void addCustomEditorPane(String title, final Component component) {
AbstractAttrNoScrollPane settingPane = new NoBorderAbstractAttrNoScrollPane() {
@Override
protected JPanel createContentPane() {
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentPane.add(component, BorderLayout.CENTER);
return contentPane;
}
};
settingPane.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
fireAttributeChange();
}
});
uiTabbedPane.addTab(title, settingPane);
}
protected JPanel createCellStyleSettingPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
cellStyleSettingPane = new CellStyleListEditPane();
cellStyleSettingPane.registerAttrChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
fireAttributeChange();
}
});
container.add(cellStyleSettingPane);
return container;
}
protected JPanel createChartStyleSettingPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
chartStyleSettingPane = new ChartStyleEditPane();
container.add(chartStyleSettingPane);
return container;
}
public void populateBean(T theme) {
this.theme = theme;
isPopulating = true;
String name = theme.getName();
setThemeNameEditable(StringUtils.isEmpty(name));
nameTextField.setText(name);
colorListPane.populate(theme.getColorScheme().getColors());
colorListExtendedPane.populate(colorListPane.update());
populateBean4CustomEditors(theme);
isPopulating = false;
}
protected void populateBean4CustomEditors(T theme) {
cellStyleSettingPane.populateBean(theme.getCellStyleList());
chartStyleSettingPane.populateBean(theme.getChartStyle());
}
public T updateBean() {
if (theme == null) {
theme = config.createNewTheme();
}
theme.setName(this.nameTextField.getText());
ThemedColorScheme colorScheme = theme.getColorScheme();
colorScheme.setColors(this.colorListPane.update());
theme.setColorScheme(colorScheme);
updateBean4CustomEditors(theme);
return theme;
}
protected void updateBean4CustomEditors(T theme) {
ThemedCellStyleList cellStyleConfig = this.cellStyleSettingPane.updateBean();
theme.setCellStyleList(cellStyleConfig);
theme.setChartStyle(this.chartStyleSettingPane.updateBean());
}
public void setThemeNameEditable(boolean editable) {
nameTextField.setEditable(editable);
nameTextField.setEnabled(editable);
}
public boolean checkNameValid() {
return nameTextField.checkValid();
}
public List<Color> getCurrentColorScheme() {
return colorListPane.update();
}
private void fireAttributeChange() {
if (!isPopulating && !refreshingThemedColor && changeListener != null) {
changeListener.attributeChange();
}
}
public void addAttributeChangeListener(AttributeChangeListener changeListener) {
this.changeListener = changeListener;
}
public void addThemeNameCheckListener(AutoCheckTextField.CheckListener checkListener) {
this.themeNameCheckListener = checkListener;
}
private static abstract class NoBorderAbstractAttrNoScrollPane extends AbstractAttrNoScrollPane {
@Override
protected void initContentPane() {
super.initContentPane();
if (leftContentPane != null) {
// 修正 AbstractAttrNoScrollPane 的默认行为
leftContentPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
}
}
}

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

@ -32,7 +32,7 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
public static final int BLOCK_GAP = IntervalConstants.INTERVAL_L1; public static final int BLOCK_GAP = IntervalConstants.INTERVAL_L1;
public static final int CONTENT_WIDTH = TemplateThemeBlock.CONTENT_WIDTH * BLOCK_COUNT_ROW_LINE + BLOCK_GAP * (BLOCK_COUNT_ROW_LINE - 1) + 10; public static final int CONTENT_WIDTH = TemplateThemeBlock.CONTENT_WIDTH * BLOCK_COUNT_ROW_LINE + BLOCK_GAP * (BLOCK_COUNT_ROW_LINE - 1) + 10;
public static final int BLOCK_ROWS_PER_PAGE = 3; public static final int BLOCK_ROWS_PER_PAGE = 3;
public static final int CONTENT_HEIGHT = TemplateThemeBlock.CONTENT_HEIGHT * BLOCK_ROWS_PER_PAGE + BLOCK_GAP * (BLOCK_ROWS_PER_PAGE + 1); public static final int CONTENT_HEIGHT = Math.min(527, TemplateThemeBlock.CONTENT_HEIGHT * BLOCK_ROWS_PER_PAGE + BLOCK_GAP * (BLOCK_ROWS_PER_PAGE + 1));
public static final int ASYNC_FETCH_THEME_THREAD_COUNT = 10; public static final int ASYNC_FETCH_THEME_THREAD_COUNT = 10;
private final AsyncThemeFetcher<T> asyncThemeFetcher; private final AsyncThemeFetcher<T> asyncThemeFetcher;

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

@ -1,58 +1,39 @@
package com.fr.design.mainframe.theme; package com.fr.design.mainframe.theme;
import com.fr.base.theme.FineColorFlushUtils;
import com.fr.base.theme.FineColorManager;
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.base.theme.settings.ThemeThumbnail; import com.fr.base.theme.settings.ThemeThumbnail;
import com.fr.base.theme.settings.ThemedCellStyleList; import com.fr.design.dialog.BasicPane;
import com.fr.base.theme.settings.ThemedColorScheme;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
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.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
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.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog;
import com.fr.design.mainframe.theme.edit.CellStyleListEditPane;
import com.fr.design.mainframe.theme.edit.ChartStyleEditPane;
import com.fr.design.mainframe.theme.edit.ui.ColorListExtendedPane;
import com.fr.design.mainframe.theme.edit.ui.ColorListPane;
import com.fr.design.mainframe.theme.edit.ui.LabelUtils; 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.theme.ui.BorderUtils;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.CallBackAdaptor;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Image; import java.awt.Image;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.List;
import static com.fr.design.i18n.Toolkit.i18nText; import static com.fr.design.i18n.Toolkit.i18nText;
@ -61,71 +42,35 @@ import static com.fr.design.i18n.Toolkit.i18nText;
* @version 1.0 * @version 1.0
* Created by Starryi on 2021/8/13 * Created by Starryi on 2021/8/13
*/ */
public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends AbstractAttrNoScrollPane { public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends BasicPane {
public static final int TITLE_BORDER_FONT = 12; public static final int TITLE_BORDER_FONT = 12;
public static final int LEFT_TITLE_PANE_WIDTH = 627; public static final int LEFT_TITLE_PANE_WIDTH = 627;
public static final int LEFT_TITLE_PANE_HEIGHT = 539; public static final int LEFT_TITLE_PANE_HEIGHT = 539;
public static final int PREVIEW_PANE_WIDTH = LEFT_TITLE_PANE_WIDTH - 10; public static final int PREVIEW_PANE_WIDTH = LEFT_TITLE_PANE_WIDTH - 10;
public static final int PREVIEW_PANE_HEIGHT = LEFT_TITLE_PANE_HEIGHT - TITLE_BORDER_FONT - 16; public static final int PREVIEW_PANE_HEIGHT = LEFT_TITLE_PANE_HEIGHT - TITLE_BORDER_FONT - 16;
public static final int RIGHT_PANE_WIDTH = 362;
public static final int RIGHT_PANE_HEIGHT = LEFT_TITLE_PANE_HEIGHT;
public static final int COLOR_SCHEME_TITLE_PANE_WIDTH = 298;
public static final int COLOR_SCHEME_TITLE_PANE_HEIGHT = 174 + TITLE_BORDER_FONT / 2;
protected TemplateThemePreviewPane<T> themePreviewPane; protected TemplateThemePreviewPane<T> themePreviewPane;
protected TemplateThemeEditorPane<T> themeEditorPane;
protected UITextField nameTextField;
private UILabel nameErrorLabel;
protected ColorListPane colorListPane;
private ColorListExtendedPane colorListExtendedPane;
protected CellStyleListEditPane cellStyleSettingPane;
protected ChartStyleEditPane chartStyleSettingPane;
protected boolean isPopulating = false; protected boolean isPopulating = false;
protected UITabbedPane uiTabbedPane; protected boolean isMutable = false;
private final TemplateThemeConfig<T> config; protected final TemplateThemeConfig<T> config;
private UIButton saveButton = new UIButton(); private UIButton saveButton = new UIButton();
private UIButton saveAsButton = new UIButton(); private UIButton saveAsButton = new UIButton();
private boolean refreshingThemedColor = false;
private boolean currentIsNewTheme;
private T theme;
public TemplateThemeProfilePane(TemplateThemeConfig<T> config) { public TemplateThemeProfilePane(TemplateThemeConfig<T> config) {
super();
this.config = config; this.config = config;
theme = config.createNewTheme(); initializePane();
}
@Override
protected JPanel createContentPane() {
JPanel container = new JPanel(new BorderLayout(5, 0));
container.add(createLeftPane(), BorderLayout.CENTER);
container.add(createRightPane(), BorderLayout.EAST);
addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
if (!isPopulating) {
valueChangeAction();
}
}
});
return container;
}
@Override
protected void initContentPane() {
super.initContentPane();
if (leftContentPane != null) {
// 修正 AbstractAttrNoScrollPane 的默认行为
leftContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 6));
}
} }
public void valueChangeAction() { private void initializePane() {
themePreviewPane.refresh(updateBean()); setLayout(new BorderLayout(5, 0));
setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 6));
add(createLeftPane(), BorderLayout.CENTER);
add(createRightPane(), BorderLayout.EAST);
} }
@Override @Override
@ -149,220 +94,55 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
return titleContainer; return titleContainer;
} }
private JPanel createRightPane() { private JPanel createRightPane() {
JPanel container = new JPanel(new BorderLayout(0, 0)); themeEditorPane = createThemeEditorPane();
container.setPreferredSize(new Dimension(RIGHT_PANE_WIDTH, RIGHT_PANE_HEIGHT)); themeEditorPane.addAttributeChangeListener(new AttributeChangeListener() {
JPanel nameEditPane = createNameEditPane();
container.add(nameEditPane, BorderLayout.NORTH);
JPanel settingPane = new JPanel(new BorderLayout(0, IntervalConstants.INTERVAL_L1));
container.add(settingPane, BorderLayout.CENTER);
settingPane.add(createColorSchemeEditPane(), BorderLayout.NORTH);
settingPane.add(createCustomEditorsPane(), BorderLayout.CENTER);
uiTabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueChangeAction();
}
});
return container;
}
private JPanel createNameEditPane() {
nameErrorLabel = LabelUtils.createLabel(StringUtils.EMPTY, Color.RED);
nameErrorLabel.setVisible(false);
nameTextField = new UITextField();
nameTextField.setEnabled(false);
nameTextField.setPreferredSize(new Dimension(165, 20));
nameTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override @Override
public void insertUpdate(DocumentEvent e) { public void attributeChange() {
if (isEnabled()) { if (isPopulating) {
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, false, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton); return;
}
}
@Override
public void removeUpdate(DocumentEvent e) {
if (isEnabled()) {
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, false, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton);
}
} }
themePreviewPane.refresh(updateBean());
@Override saveButton.setEnabled(themeEditorPane.checkNameValid() && isMutable);
public void changedUpdate(DocumentEvent e) {
} }
}); });
nameTextField.addFocusListener(new FocusAdapter() { themeEditorPane.addThemeNameCheckListener(new AutoCheckTextField.CheckListener() {
@Override
public void focusGained(FocusEvent e) {
if (isEnabled()) {
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, false, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton);
}
}
@Override @Override
public void focusLost(FocusEvent e) { public void onChecked(String error, boolean valid) {
if (isEnabled()) { if (isPopulating) {
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, true, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton);
}
}
});
double p = TableLayout.PREFERRED;
JPanel container = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[] { LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Name")), nameTextField },
new Component[] { null, nameErrorLabel },
}, new double[] { 20, 20}, new double[] { p, 165}, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_W0);
container.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
return container;
}
private JPanel createColorSchemeEditPane() {
colorListPane = new ColorListPane();
colorListExtendedPane = new ColorListExtendedPane();
JPanel extendedContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
colorListExtendedPane.setBackground(null);
colorListExtendedPane.setOpaque(false);
extendedContainer.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
extendedContainer.setBackground(Color.WHITE);
extendedContainer.add(colorListExtendedPane);
double p = TableLayout.PREFERRED;
double[] rowSize = new double[]{p, p, p};
double[] columnSize = {p, p};
JPanel colorListContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
colorListContainerPane.add(colorListPane, BorderLayout.WEST);
JPanel previewLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewLabelPane.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Preview_Label")), BorderLayout.NORTH);
UILabel tipLabel = LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Tip"), new Color(153, 153, 153));
tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Label")), colorListContainerPane},
{null, tipLabel},
{previewLabelPane, extendedContainer},
},
rowSize, columnSize, 18, 7);
content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JPanel borderContainer = new JPanel(new BorderLayout());
borderContainer.setPreferredSize(new Dimension(COLOR_SCHEME_TITLE_PANE_WIDTH, COLOR_SCHEME_TITLE_PANE_HEIGHT));
borderContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Title")));
borderContainer.add(content);
JPanel container = new JPanel(new BorderLayout());
container.add(borderContainer, BorderLayout.WEST);
colorListPane.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (refreshingThemedColor) {
return; return;
} }
List<Color> colors = colorListPane.update(); saveButton.setEnabled(valid && isMutable);
refreshingThemedColor = true;
onColorSchemeChanged(colors);
refreshingThemedColor = false;
} }
}); });
return container; return themeEditorPane;
} }
protected JPanel createCustomEditorsPane() {
JPanel container = new JPanel(new BorderLayout());
container.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Custom_Settings_Title")));
uiTabbedPane = new UITabbedPane(); public abstract TemplateThemePreviewPane<T> createThemePreviewPane();
uiTabbedPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 1)); public abstract TemplateThemeEditorPane<T> createThemeEditorPane();
container.add(uiTabbedPane, BorderLayout.NORTH);
return container; public void populateBean(T theme) {
} isPopulating = true;
public void addCustomEditorPane(String title, JComponent component) {
component.setPreferredSize(new Dimension(317, 239));
uiTabbedPane.addTab(title, component);
}
protected JPanel createCellStyleSettingPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
cellStyleSettingPane = new CellStyleListEditPane();
cellStyleSettingPane.registerAttrChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
valueChangeAction();
}
});
container.add(cellStyleSettingPane);
return container;
}
protected JPanel createChartStyleSettingPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
chartStyleSettingPane = new ChartStyleEditPane();
container.add(chartStyleSettingPane);
return container;
}
public abstract TemplateThemePreviewPane<T> createThemePreviewPane(); isMutable = theme.isMutable();
public void onColorSchemeChanged(List<Color> colors) { themeEditorPane.populateBean(theme);
colorListExtendedPane.populate(colors);
FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors);
T theme = updateBean();
FineColorFlushUtils.replaceCacheObject(theme, replaceByColorScheme);
FineColorManager.traverse(theme, replaceByColorScheme);
populateBean4CustomEditors(theme);
//图表渐变色
chartStyleSettingPane.populateGradientBar(colors);
themePreviewPane.refresh(theme); themePreviewPane.refresh(theme);
this.repaint();
}
public void populateBean(T theme) {
this.theme = theme;
isPopulating = true;
String name = theme.getName(); String name = theme.getName();
currentIsNewTheme = config.cachedFetch(name) == null;
nameTextField.setText(name);
nameTextField.setEnabled(StringUtils.isEmpty(name));
if (saveButton != null) { if (saveButton != null) {
saveButton.setEnabled(theme.isMutable() && !currentIsNewTheme); saveButton.setEnabled(isMutable);
} }
if (saveAsButton != null) { if (saveAsButton != null) {
saveAsButton.setEnabled(!currentIsNewTheme); saveAsButton.setEnabled(StringUtils.isNotEmpty(name));
} }
colorListPane.populate(theme.getColorScheme().getColors());
colorListExtendedPane.populate(colorListPane.update());
populateBean4CustomEditors(theme);
themePreviewPane.refresh(theme);
isPopulating = false; isPopulating = false;
} }
protected void populateBean4CustomEditors(T theme) {
cellStyleSettingPane.populateBean(theme.getCellStyleList());
chartStyleSettingPane.populateBean(theme.getChartStyle());
}
public T updateBean() { public T updateBean() {
if (theme == null) { T theme = themeEditorPane.updateBean();
theme = config.createNewTheme();
}
theme.setName(this.nameTextField.getText());
Image thumbnailImage = themePreviewPane.createThumbnailImage(); Image thumbnailImage = themePreviewPane.createThumbnailImage();
if (thumbnailImage != null) { if (thumbnailImage != null) {
@ -371,43 +151,43 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
theme.setThumbnail(thumbnail); theme.setThumbnail(thumbnail);
} }
ThemedCellStyleList cellStyleConfig = this.cellStyleSettingPane.updateBean();
theme.setCellStyleList(cellStyleConfig);
ThemedColorScheme colorScheme = theme.getColorScheme();
colorScheme.setColors(this.colorListPane.update());
theme.setColorScheme(colorScheme);
theme.setChartStyle(this.chartStyleSettingPane.updateBean());
updateBean(theme);
return theme; return theme;
} }
public List<Color> getCurrentColorScheme() { public TemplateThemeEditorPane<T> getThemeEditorPane() {
return colorListPane.update(); return themeEditorPane;
} }
protected abstract void updateBean(T theme); public void save(CallBackAdaptor callBack) {
T theme;
public UIButton createSaveButton() { try {
saveButton = new UIButton(); theme = (T) updateBean().clone();
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save")); } catch (CloneNotSupportedException ex) {
saveButton.setEnabled(false); FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
saveButton.addActionListener(new ActionListener() { return;
@Override }
public void actionPerformed(ActionEvent e) { save(theme, callBack);
T theme = updateBean(); }
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, true, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton); public void save(String name, CallBackAdaptor callBack) {
if (canBeSaved && theme != null) { T theme = null;
theme.setName(nameTextField.getText()); try {
theme = (T) updateBean().clone();
} catch (CloneNotSupportedException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
return;
}
theme.setName(name);
save(theme, callBack);
}
private void save(T theme, CallBackAdaptor callBack) {
theme.setRemovable(true);
theme.setMutable(true);
config.addTheme(theme, true, new CallBackAdaptor() { config.addTheme(theme, true, new CallBackAdaptor() {
@Override @Override
public void afterCommit() { public void afterCommit() {
super.afterCommit(); super.afterCommit();
currentIsNewTheme = false; themeEditorPane.setThemeNameEditable(false);
nameTextField.setEnabled(false); callBack.afterCommit();
saveAsButton.setEnabled(true);
} }
@Override @Override
@ -420,6 +200,23 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
} }
}); });
} }
public UIButton createSaveButton() {
saveButton = new UIButton();
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save"));
saveButton.setEnabled(false);
saveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
save(new CallBackAdaptor() {
@Override
public void afterCommit() {
super.afterCommit();
saveButton.setEnabled(false);
saveAsButton.setEnabled(true);
DesignerToastMsgUtil.toastPrompt(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save_Successfully"));
}
});
} }
}); });
return saveButton; return saveButton;
@ -440,7 +237,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
private class SaveAsDialog extends JDialog { private class SaveAsDialog extends JDialog {
private final TemplateThemeProfileDialog<T> parent; private final TemplateThemeProfileDialog<T> parent;
private UITextField nameTextField; private AutoCheckThemeNameTextField<T> nameTextField;
private UILabel nameErrorLabel; private UILabel nameErrorLabel;
private UIButton confirmButton; private UIButton confirmButton;
@ -466,6 +263,18 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
} }
private void initializeComponents() { private void initializeComponents() {
nameTextField = new AutoCheckThemeNameTextField<>();
nameTextField.setThemeConfig(config);
nameTextField.setPreferredSize(new Dimension(180, 20));
nameTextField.setNameCheckListener(new AutoCheckTextField.CheckListener() {
@Override
public void onChecked(String error, boolean valid) {
nameErrorLabel.setVisible(StringUtils.isNotEmpty(error));
nameErrorLabel.setText(error);
confirmButton.setEnabled(valid);
}
});
nameErrorLabel = LabelUtils.createLabel(StringUtils.EMPTY, Color.RED); nameErrorLabel = LabelUtils.createLabel(StringUtils.EMPTY, Color.RED);
nameErrorLabel.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 0)); nameErrorLabel.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 0));
@ -474,47 +283,16 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
confirmButton.addActionListener(new ActionListener() { confirmButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
saveAsNew(nameTextField.getText()); save(nameTextField.getText(), new CallBackAdaptor() {
}
});
nameTextField = new UITextField();
nameTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
if (isEnabled()) {
checkThemeCanBeSavedAndUpdateUI(true, false, true, true, nameTextField, nameErrorLabel, confirmButton);
}
}
@Override
public void removeUpdate(DocumentEvent e) {
if (isEnabled()) {
checkThemeCanBeSavedAndUpdateUI(true, false, true, true, nameTextField, nameErrorLabel, confirmButton);
}
}
@Override @Override
public void changedUpdate(DocumentEvent e) { public void afterCommit() {
super.afterCommit();
exit();
parent.exit();
} }
}); });
nameTextField.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
if (isEnabled()) {
checkThemeCanBeSavedAndUpdateUI(true, false, true, true, nameTextField, nameErrorLabel, confirmButton);
}
}
@Override
public void focusLost(FocusEvent e) {
if (isEnabled()) {
checkThemeCanBeSavedAndUpdateUI(true, true, true, true, nameTextField, nameErrorLabel, confirmButton);
}
} }
}); });
nameTextField.setPreferredSize(new Dimension(180, 20));
} }
private JPanel createActionsContainer() { private JPanel createActionsContainer() {
@ -548,82 +326,8 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
return container; return container;
} }
private void saveAsNew(String name) {
T newThemeObject = null;
try {
newThemeObject = (T) updateBean().clone();
} catch (CloneNotSupportedException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
return;
}
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, true, true, true, nameTextField, nameErrorLabel, confirmButton);
if (canBeSaved && newThemeObject != null) {
newThemeObject.setName(name);
newThemeObject.setRemovable(true);
newThemeObject.setMutable(true);
config.addTheme(newThemeObject, true, new CallBackAdaptor() {
@Override
public void afterCommit() {
super.afterCommit();
exit();
parent.exit();
}
@Override
public void afterRollback() {
super.afterRollback();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TemplateThemeProfilePane.this),
i18nText("Fine-Design_Basic_Template_Theme_Operation_Failed_Tip"),
i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
}
});
}
}
public void exit() { public void exit() {
this.dispose(); this.dispose();
} }
} }
private boolean isThemeNameEmpty(String name) {
return StringUtils.isEmpty(name);
}
private boolean isThemeNameDuplicated(String name) {
return config.cachedFetch(name) != null;
}
private boolean checkThemeCanBeSavedAndUpdateUI(
boolean checkEmpty,
boolean displayEmptyTip,
boolean checkDuplicated,
boolean displayDuplicatedTip,
UITextField textField,
UILabel errorLabel, UIButton... actionButtons) {
String name = textField.getText();
boolean valid = true;
errorLabel.setText(StringUtils.EMPTY);
if (checkEmpty && isThemeNameEmpty(name)) {
valid = false;
if (displayEmptyTip) {
errorLabel.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Empty_Name_Error_Tip"));
}
} else if (checkDuplicated && isThemeNameDuplicated(name)) {
valid = false;
if (displayDuplicatedTip) {
errorLabel.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Duplicated_Name_Error_Tip"));
}
}
errorLabel.setVisible(!valid);
if (actionButtons != null && actionButtons.length > 0) {
for (UIButton button : actionButtons) {
if (button != null) {
button.setEnabled(valid);
}
}
}
return valid;
}
} }

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

@ -51,7 +51,7 @@ public class TemplateThemeProfileDialog<T extends TemplateTheme> extends Templat
public static List<Color> getEditingColorScheme() { public static List<Color> getEditingColorScheme() {
if (currentVisibleProfilePane != null) { if (currentVisibleProfilePane != null) {
return currentVisibleProfilePane.getCurrentColorScheme(); return currentVisibleProfilePane.getThemeEditorPane().getCurrentColorScheme();
} }
return null; return null;
} }

28
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java

@ -2,8 +2,7 @@ package com.fr.design.mainframe.theme.edit;
import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.AttrScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.style.ComponentBodyStylePane; import com.fr.design.gui.style.ComponentBodyStylePane;
import com.fr.design.gui.style.ComponentIntegralStylePane; import com.fr.design.gui.style.ComponentIntegralStylePane;
import com.fr.design.gui.style.ComponentTitleStylePane; import com.fr.design.gui.style.ComponentTitleStylePane;
@ -18,10 +17,9 @@ import com.fr.general.act.BorderPacker;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JTextArea;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
/** /**
* @author Starryi * @author Starryi
@ -50,7 +48,8 @@ public class ComponentStyleEditPane extends JPanel {
}, },
new JComponent[] { createTabContainer(componentTitleStylePane), createTabContainer(componentBodyStylePane), createTabContainer(componentIntegralStylePane) } new JComponent[] { createTabContainer(componentTitleStylePane), createTabContainer(componentBodyStylePane), createTabContainer(componentIntegralStylePane) }
); );
add(content, BorderLayout.NORTH); content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
add(content, BorderLayout.CENTER);
} }
public void populateBean(ThemedComponentStyle style) { public void populateBean(ThemedComponentStyle style) {
@ -115,21 +114,20 @@ public class ComponentStyleEditPane extends JPanel {
} }
private JComponent createTabContainer(final JPanel component) { private JComponent createTabContainer(final JPanel component) {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setPreferredSize(new Dimension(container.getPreferredSize().width, 220));
JPanel tipLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel tipLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
tipLabelPane.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); tipLabelPane.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
UILabel tipLabel = LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Style_Tip"), new Color(153, 153, 153)); JTextArea tipLabel = LabelUtils.createAutoWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Style_Tip"), new Color(153, 153, 153));
tipLabelPane.add(tipLabel); tipLabelPane.add(tipLabel);
container.add(tipLabelPane, BorderLayout.NORTH); content.add(tipLabelPane, BorderLayout.NORTH);
content.add(component, BorderLayout.CENTER);
container.add(new AttrScrollPane() { UIScrollPane scrollPane = new UIScrollPane(content);
@Override scrollPane.setBorder(BorderFactory.createEmptyBorder());
protected JPanel createContentPane() {
return component; JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
} container.add(scrollPane, BorderLayout.CENTER);
}, BorderLayout.CENTER);
return container; return container;

7
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java

@ -40,6 +40,8 @@ public class ColorListPane extends JPanel implements UIObserver {
private final EventListenerList colorChangeListenerList = new EventListenerList(); private final EventListenerList colorChangeListenerList = new EventListenerList();
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
private boolean isPopulating = false;
public ColorListPane() { public ColorListPane() {
this(DEFAULT_COLOR_COUNT, DEFAULT_COLOR_SIZE, DEFAULT_COLOR_GAP); this(DEFAULT_COLOR_COUNT, DEFAULT_COLOR_SIZE, DEFAULT_COLOR_GAP);
} }
@ -61,6 +63,9 @@ public class ColorListPane extends JPanel implements UIObserver {
colorButton.addChangeListener(new ChangeListener() { colorButton.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (isPopulating) {
return;
}
colorList.set(index, colorButton.getSelectObject()); colorList.set(index, colorButton.getSelectObject());
fireColorStateChanged(); fireColorStateChanged();
} }
@ -88,6 +93,7 @@ public class ColorListPane extends JPanel implements UIObserver {
} }
public void populate(List<Color> colors) { public void populate(List<Color> colors) {
isPopulating = true;
colorList.clear(); colorList.clear();
for (int i = 0; i < colors.size(); i++) { for (int i = 0; i < colors.size(); i++) {
Color color = colors.get(i); Color color = colors.get(i);
@ -96,6 +102,7 @@ public class ColorListPane extends JPanel implements UIObserver {
colorButtons.get(i).setSelectObject(color); colorButtons.get(i).setSelectObject(color);
} }
} }
isPopulating = false;
} }
public List<Color> update() { public List<Color> update() {

19
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java

@ -3,6 +3,9 @@ package com.fr.design.mainframe.theme.edit.ui;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import javax.swing.BorderFactory;
import javax.swing.JTextArea;
import javax.swing.plaf.basic.BasicTextAreaUI;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
@ -26,4 +29,20 @@ public class LabelUtils {
uiLabel.setFont(newFont); uiLabel.setFont(newFont);
return uiLabel; return uiLabel;
} }
public static JTextArea createAutoWrapLabel(String title, Color color) {
JTextArea tipLabel = new JTextArea();
tipLabel.setUI(new BasicTextAreaUI());
tipLabel.setForeground(color);
Font newFont = FRFont.getInstance(tipLabel.getFont().getFontName(), Font.PLAIN, 12);
tipLabel.setFont(newFont);
tipLabel.setBorder(BorderFactory.createEmptyBorder());
tipLabel.setEnabled(false);
tipLabel.setText(title);
tipLabel.setLineWrap(true);
tipLabel.setWrapStyleWord(true);
tipLabel.setOpaque(false);
tipLabel.setBackground(null);
return tipLabel;
}
} }

1
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/TabbedPane.java

@ -25,7 +25,6 @@ public class TabbedPane extends JPanel {
public TabbedPane(String[] names, JComponent[] panes) { public TabbedPane(String[] names, JComponent[] panes) {
setLayout(FRGUIPaneFactory.createBorderLayout()); setLayout(FRGUIPaneFactory.createBorderLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
for (JComponent pane :panes) { for (JComponent pane :panes) {
pane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); pane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

6
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java

@ -64,8 +64,8 @@ public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreview
northPane.add(bigTitleCell, BorderLayout.NORTH); northPane.add(bigTitleCell, BorderLayout.NORTH);
CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Product"), CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Product"),
Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Data"), Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Statistical_Dimension")}, Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Data"), Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Statistical_Dimension")},
new Point2D[]{new Point(159, 71), new Point(226, 49)}); new Point2D[]{new Point(159, 71), new Point(225, 49)});
cornerCell.setPreferredSize(new Dimension(226, 71)); cornerCell.setPreferredSize(new Dimension(225, 71));
headerCellList.add(cornerCell); headerCellList.add(cornerCell);
northPane.add(cornerCell, BorderLayout.WEST); northPane.add(cornerCell, BorderLayout.WEST);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
@ -99,7 +99,7 @@ public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreview
JPanel gridPane = new UINoOpaquePanel(new GridLayout(5, 1)); JPanel gridPane = new UINoOpaquePanel(new GridLayout(5, 1));
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Apple_Juice")); PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Apple_Juice"));
cell.setPreferredSize(new Dimension(114, 31)); cell.setPreferredSize(new Dimension(113, 31));
headerCellList.add(cell); headerCellList.add(cell);
gridPane.add(cell); gridPane.add(cell);
} }

100
designer-base/src/main/java/com/fr/design/mainframe/theme/ui/AutoCheckTextField.java

@ -0,0 +1,100 @@
package com.fr.design.mainframe.theme.ui;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StringUtils;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/18
*/
public class AutoCheckTextField extends UITextField implements DocumentListener, FocusListener {
private DuplicateChecker duplicatedChecker;
private CheckListener checkListener;
public AutoCheckTextField() {
getDocument().addDocumentListener(this);
addFocusListener(this);
}
public void setDuplicatedChecker(DuplicateChecker checker) {
this.duplicatedChecker = checker;
}
public void setNameCheckListener(CheckListener checkListener) {
this.checkListener = checkListener;
}
private boolean isEmpty(String name) {
return StringUtils.isEmpty(name);
}
private boolean isDuplicated(String name) {
if (duplicatedChecker != null) {
return duplicatedChecker.isDuplicated(name);
}
return false;
}
private boolean checkValid(boolean notifyEmptyTip) {
String name = getText();
String error = StringUtils.EMPTY;
boolean valid = true;
if (isEditable()) {
if (isEmpty(name)) {
valid = false;
if (notifyEmptyTip) {
error = Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Empty_Name_Error_Tip");
}
} else if (isDuplicated(name)) {
valid = false;
error = Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Duplicated_Name_Error_Tip");
}
}
if (checkListener != null) {
checkListener.onChecked(error, valid);
}
return valid;
}
public boolean checkValid() {
return checkValid(true);
}
@Override
public void insertUpdate(DocumentEvent e) {
checkValid(false);
}
@Override
public void removeUpdate(DocumentEvent e) {
checkValid(false);
}
@Override
public void changedUpdate(DocumentEvent e) {
}
@Override
public void focusGained(FocusEvent e) {
checkValid(false);
}
@Override
public void focusLost(FocusEvent e) {
checkValid(true);
}
public interface CheckListener {
void onChecked(String error, boolean valid);
}
public interface DuplicateChecker {
boolean isDuplicated(String name);
}
}

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

@ -0,0 +1,26 @@
package com.fr.design.mainframe.theme.ui;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/18
*/
public class AutoCheckThemeNameTextField<T extends TemplateTheme> extends AutoCheckTextField {
private TemplateThemeConfig<T> config;
public AutoCheckThemeNameTextField() {
setDuplicatedChecker(new DuplicateChecker() {
@Override
public boolean isDuplicated(String name) {
return config != null && config.contains(name);
}
});
}
public void setThemeConfig(TemplateThemeConfig<T> config) {
this.config = config;
}
}

BIN
designer-base/src/main/resources/com/fr/design/images/transparent_background.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 17 KiB

14
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java

@ -21,7 +21,7 @@ import java.awt.Graphics;
public class FRFixLayoutAdapter extends AbstractLayoutAdapter { public class FRFixLayoutAdapter extends AbstractLayoutAdapter {
private static final Icon OCCUPIED_ICON = IconUtils.readIcon("/com/fr/design/form/images/occupied_layout.png"); private static final Icon OCCUPIED_ICON = IconUtils.readIcon("/com/fr/design/form/images/occupied_layout.png");
public FRFixLayoutAdapter(XLayoutContainer container) { public FRFixLayoutAdapter( XLayoutContainer container) {
super(container); super(container);
} }
@ -32,12 +32,11 @@ public class FRFixLayoutAdapter extends AbstractLayoutAdapter {
} }
child.setLocation(component.getX(), component.getY()); child.setLocation(component.getX(), component.getY());
child.setSize(component.getWidth(), component.getHeight()); child.setSize(component.getWidth(), component.getHeight());
container.remove(component);
if (child.shouldScaleCreator() || child.hasTitleStyle()) { if (child.shouldScaleCreator() || child.hasTitleStyle()) {
XLayoutContainer parentPanel = child.initCreatorWrapper(21); XLayoutContainer parentPanel = child.initCreatorWrapper(21);
container.add(parentPanel, child.toData().getWidgetName()); container.replaceXcreator(parentPanel, (XCreator) component);
} else { } else {
container.add(child, child.toData().getWidgetName()); container.replaceXcreator(child, (XCreator) component);
} }
if (child.getBackupRectangle() != null && child.getParent() == container) { if (child.getBackupRectangle() != null && child.getParent() == container) {
Component origin = container.getComponentAt(child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5); Component origin = container.getComponentAt(child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5);
@ -52,15 +51,20 @@ public class FRFixLayoutAdapter extends AbstractLayoutAdapter {
@Override @Override
public void delete(XCreator creator, int creatorWidth, int creatorHeight) { public void delete(XCreator creator, int creatorWidth, int creatorHeight) {
//固定布局下不支持移除占位块组件
if (creator.acceptType(XOccupiedLayout.class)){
return;
}
OccupiedLayout occupiedLayout = new OccupiedLayout(); OccupiedLayout occupiedLayout = new OccupiedLayout();
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XOccupiedLayout xoccupiedLayout = new XOccupiedLayout(occupiedLayout, new Dimension()); XOccupiedLayout xoccupiedLayout = new XOccupiedLayout(occupiedLayout, new Dimension());
ModelUtil.renameWidgetName(formDesigner.getTarget(), xoccupiedLayout); ModelUtil.renameWidgetName(formDesigner.getTarget(), xoccupiedLayout);
xoccupiedLayout.setLocation(creator.getX(), creator.getY()); xoccupiedLayout.setLocation(creator.getX(), creator.getY());
xoccupiedLayout.setSize(creatorWidth, creatorHeight); xoccupiedLayout.setSize(creatorWidth, creatorHeight);
container.add(xoccupiedLayout); container.replaceXcreator(xoccupiedLayout,creator);
} }
@Override @Override
public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) { public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) {
return new DefaultXCreatorTreeCellRender(creator) { return new DefaultXCreatorTreeCellRender(creator) {

9
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java

@ -9,18 +9,15 @@ import com.fr.design.designer.treeview.XCreatorTreeCellRender;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics; import java.awt.Graphics;
public class FROccupiedLayoutAdapter extends AbstractLayoutAdapter { public class FROccupiedLayoutAdapter extends AbstractLayoutAdapter {
public FROccupiedLayoutAdapter(XLayoutContainer container) { public FROccupiedLayoutAdapter(XLayoutContainer container) {
super(container); super(container);
painter = new FROccupiedLayoutPainter(container); painter = new FROccupiedLayoutPainter(container);
} }
private HoverPainter painter; private HoverPainter painter;
@ -29,14 +26,12 @@ public class FROccupiedLayoutAdapter extends AbstractLayoutAdapter {
if (container.getComponentCount() == 0) { if (container.getComponentCount() == 0) {
creator.setLocation(container.getLocation().x, container.getLocation().y); creator.setLocation(container.getLocation().x, container.getLocation().y);
creator.setSize(container.getWidth(), container.getHeight()); creator.setSize(container.getWidth(), container.getHeight());
//将 xcreator 添加到其父容器中,并删除此
XLayoutContainer parent = (XLayoutContainer) container.getParent(); XLayoutContainer parent = (XLayoutContainer) container.getParent();
parent.getLayoutAdapter().removeBean(container, container.getWidth(), container.getHeight());
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { if (creator.shouldScaleCreator() || creator.hasTitleStyle()) {
XLayoutContainer parentPanel = creator.initCreatorWrapper(21); XLayoutContainer parentPanel = creator.initCreatorWrapper(21);
parent.add(parentPanel, creator.toData().getWidgetName()); parent.replaceXcreator(parentPanel, container);
} else { } else {
parent.add(creator, creator.toData().getWidgetName()); parent.replaceXcreator(creator, container);
} }
LayoutUtils.layoutContainer(parent); LayoutUtils.layoutContainer(parent);
} }

4
designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java

@ -608,4 +608,8 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
public boolean supportFixLayout(){ public boolean supportFixLayout(){
return false; return false;
} }
public void replaceXcreator(XCreator newCreator, XCreator oldCreator){
}
} }

19
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -3,6 +3,7 @@ package com.fr.design.designer.creator;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFixLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFixLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRNoFixLayoutAdapter;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
@ -82,6 +83,7 @@ public class XWFitLayout extends XLayoutContainer {
@Override @Override
public LayoutAdapter getLayoutAdapter() { public LayoutAdapter getLayoutAdapter() {
FRFitLayoutAdapter layoutAdapter = new FRFitLayoutAdapter(this); FRFitLayoutAdapter layoutAdapter = new FRFitLayoutAdapter(this);
if (isFixLayout) { if (isFixLayout) {
layoutAdapter.setFrLayoutState(new FRFixLayoutAdapter(this)); layoutAdapter.setFrLayoutState(new FRFixLayoutAdapter(this));
} }
@ -871,10 +873,23 @@ public class XWFitLayout extends XLayoutContainer {
Widget wgt = xwc.toData(); Widget wgt = xwc.toData();
BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt); BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt);
wlayout.removeWidget(bw); wlayout.removeWidget(bw);
if(!isFixLayout){
updateBoundsWidget(); updateBoundsWidget();
((FRFitLayoutAdapter)getLayoutAdapter()).updateCreatorBackBound(); ((FRFitLayoutAdapter) getLayoutAdapter()).updateCreatorBackBound();
} }
public void replaceXcreator(XCreator newCreator, XCreator oldCreator) {
WFitLayout wlayout = this.toData();
Widget wgt = oldCreator.toData();
BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt);
wlayout.removeWidget(bw);
wlayout.addWidget(new BoundsWidget(newCreator.toData(), bw.getBounds()));
newCreator.setBackupParent(this);
isRefreshing = true;
this.remove(oldCreator);
this.add(newCreator);
this.updateBoundsWidget();
isRefreshing = false;
LayoutUtils.layoutContainer(this);
} }
/** /**

7
designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

@ -362,7 +362,6 @@ public class ComponentTree extends JTree {
@Override @Override
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
Point p = e.getPoint(); Point p = e.getPoint();
int selRow = tree.getRowForLocation(p.x, p.y); int selRow = tree.getRowForLocation(p.x, p.y);
TreeCellRenderer r = tree.getCellRenderer(); TreeCellRenderer r = tree.getCellRenderer();
@ -371,12 +370,12 @@ public class ComponentTree extends JTree {
Point point = tree.getPathBounds(path).getLocation(); Point point = tree.getPathBounds(path).getLocation();
SwingUtilities.convertPointToScreen(point, tree); SwingUtilities.convertPointToScreen(point, tree);
XCreator comp = (XCreator) path.getLastPathComponent(); XCreator comp = (XCreator) path.getLastPathComponent();
if (comp.getXCreatorBaseOperate().supportSelected()){ if (comp.getXCreatorBaseOperate().supportSelected()) {
popupPreviewPane(point.y, comp); popupPreviewPane(point.y, comp);
return;
} }
} else {
hidePreviewPane();
} }
hidePreviewPane();
} }
@Override @Override

3
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1317,9 +1317,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
protected void setToolbarButtons() { protected void setToolbarButtons() {
//自适应布局和底层都不能删除
DesignerContext.getDesignerFrame().checkCombineUp(!isRootSelected(), NAME_ARRAY_LIST);
if (isParameterSelected()) { if (isParameterSelected()) {
DesignerContext.getDesignerFrame().checkCombineUp(false, PARAMETER_TOOLAR_BAN_LIST); DesignerContext.getDesignerFrame().checkCombineUp(false, PARAMETER_TOOLAR_BAN_LIST);
} }

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

@ -8,6 +8,7 @@ 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;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.items.FRLayoutTypeItems; import com.fr.design.designer.properties.items.FRLayoutTypeItems;
import com.fr.design.designer.properties.items.Item; import com.fr.design.designer.properties.items.Item;
@ -169,6 +170,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
boundPane.populate(); boundPane.populate();
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
WidgetPropertyPane.getInstance().getEditingFormDesigner().switchBodyLayout((XLayoutContainer) creator);
} }
public WAbsoluteBodyLayout updateSubPane() { public WAbsoluteBodyLayout updateSubPane() {

Loading…
Cancel
Save