Browse Source

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

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

* commit '9e499477c6a3b84936241f90db5eb27788cab3fd':
  REPORT-51919 主题切换
research/11.0
starryi 3 years ago
parent
commit
c3e0200cd6
  1. 8
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 18
      designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java
  3. 15
      designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java
  4. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java
  5. 12
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java
  6. 39
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java
  7. 54
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java
  8. 96
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java
  9. 102
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java
  10. 10
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  11. 19
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/NoBorderPaneCellStyleEditPane.java
  12. 105
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java
  13. 31
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  14. 14
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  15. 2
      designer-realize/src/main/java/com/fr/design/actions/server/TemplateThemeManagerAction.java
  16. 15
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  17. 1
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java

8
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -675,6 +675,14 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
super.fireTargetModified(); super.fireTargetModified();
} }
public void fireTargetModified(boolean shouldCreateNewUndoState) {
if (shouldCreateNewUndoState) {
fireTargetModified();
} else {
super.fireTargetModified();
}
}
protected abstract U createUndoState(); protected abstract U createUndoState();
protected abstract void applyUndoState(U u); protected abstract void applyUndoState(U u);

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

@ -1,5 +1,6 @@
package com.fr.design.mainframe.theme; package com.fr.design.mainframe.theme;
import com.fr.base.theme.FineColorManager;
import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormTheme;
import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedComponentStyle;
@ -10,6 +11,9 @@ import com.fr.design.mainframe.theme.preview.FormThemePreviewPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Color;
import java.util.List;
import static com.fr.design.i18n.Toolkit.i18nText; import static com.fr.design.i18n.Toolkit.i18nText;
/** /**
@ -47,6 +51,20 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane<FormTheme> {
return container; return container;
} }
@Override
public void onColorSchemeChanged(List<Color> colors) {
super.onColorSchemeChanged(colors);
FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors);
ThemedFormBodyStyle formBodyStyle = formBodyStyleSettingPane.updateBean();
FineColorManager.traverse(formBodyStyle, replaceByColorScheme);
formBodyStyleSettingPane.populateBean(formBodyStyle);
ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean();
FineColorManager.traverse(componentStyle, replaceByColorScheme);
componentStyleSettingPane.populateBean(componentStyle);
}
@Override @Override
public void populateBean(FormTheme theme) { public void populateBean(FormTheme theme) {
super.populateBean(theme); super.populateBean(theme);

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

@ -1,12 +1,16 @@
package com.fr.design.mainframe.theme; package com.fr.design.mainframe.theme;
import com.fr.base.theme.FineColorManager;
import com.fr.base.theme.ReportTheme; import com.fr.base.theme.ReportTheme;
import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.settings.ThemedReportBodyStyle;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.theme.edit.ReportBodyStyleEditPane; import com.fr.design.mainframe.theme.edit.ReportBodyStyleEditPane;
import com.fr.design.mainframe.theme.preview.ReportThemePreviewPane; import com.fr.design.mainframe.theme.preview.ReportThemePreviewPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Color;
import java.util.List;
/** /**
* @author Starryi * @author Starryi
@ -35,6 +39,17 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane<ReportTheme
return container; return container;
} }
@Override
public void onColorSchemeChanged(List<Color> colors) {
super.onColorSchemeChanged(colors);
FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors);
ThemedReportBodyStyle bodyStyle = reportBodyStyleSettingPane.updateBean();
FineColorManager.traverse(bodyStyle, replaceByColorScheme);
reportBodyStyleSettingPane.populateBean(bodyStyle);
}
@Override @Override
public void populateBean(ReportTheme theme) { public void populateBean(ReportTheme theme) {
super.populateBean(theme); super.populateBean(theme);

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

@ -69,8 +69,10 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
clickListener.mouseClicked(e); clickListener.mouseClicked(e);
} }
if (profileButton != null && profilePane != null) {
delegateProfileButtonClick(e); delegateProfileButtonClick(e);
} }
}
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {

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

@ -50,7 +50,7 @@ import java.awt.event.ActionListener;
*/ */
public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane { public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane {
private final RemoveThemeAction removeAction; private final RemoveThemeAction removeAction;
private final UIButton setTheme4NewTemplate; private final UIButton setTheme4NewTemplateButton;
private final TemplateThemeConfig<T> config; private final TemplateThemeConfig<T> config;
private final TemplateThemeListPane<T> themeListPane; private final TemplateThemeListPane<T> themeListPane;
@ -73,7 +73,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
this.profilePane = profilePane; this.profilePane = profilePane;
this.themeListPane = new TemplateThemeListPane<>(config, profilePane); this.themeListPane = new TemplateThemeListPane<>(config, profilePane);
this.removeAction = new RemoveThemeAction(false); this.removeAction = new RemoveThemeAction(false);
this.setTheme4NewTemplate = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting")); this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting"));
profilePane.setThemeListPane(themeListPane); profilePane.setThemeListPane(themeListPane);
@ -100,13 +100,13 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
@Override @Override
public void fireChanged(ChangeEvent event) { public void fireChanged(ChangeEvent event) {
resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction); resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction);
resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplate); resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplateButton);
} }
}); });
nextContainer.add(themeListPane, BorderLayout.CENTER); nextContainer.add(themeListPane, BorderLayout.CENTER);
resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction); resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction);
resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplate); resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplateButton);
repaint(); repaint();
} }
@ -164,7 +164,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
toolbarDef.addShortCut(addMenuDef, removeAction); toolbarDef.addShortCut(addMenuDef, removeAction);
toolbarDef.updateToolBar(toolBar); toolbarDef.updateToolBar(toolBar);
setTheme4NewTemplate.addActionListener(new ActionListener() { setTheme4NewTemplateButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
T style = themeListPane.getSelectedTheme(); T style = themeListPane.getSelectedTheme();
@ -173,7 +173,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
} }
} }
}); });
content.add(setTheme4NewTemplate, BorderLayout.EAST); content.add(setTheme4NewTemplateButton, BorderLayout.EAST);
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); container.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));

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

@ -4,13 +4,11 @@ import com.fr.base.Style;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.base.theme.FineColorManager; import com.fr.base.theme.FineColorManager;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.settings.ThemeThumbnail; import com.fr.base.theme.settings.ThemeThumbnail;
import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.base.theme.settings.ThemedCellStyleList; import com.fr.base.theme.settings.ThemedCellStyleList;
import com.fr.base.theme.settings.ThemedColorScheme; import com.fr.base.theme.settings.ThemedColorScheme;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; 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.frpane.UITabbedPane;
@ -41,7 +39,6 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -54,6 +51,7 @@ 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.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.List;
/** /**
* @author Starryi * @author Starryi
@ -269,8 +267,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
List<Color> colors = colorListPane.update(); List<Color> colors = colorListPane.update();
colorListExtendedPane.populate(colors); onColorSchemeChanged(colors);
chartStyleSettingPane.populateGradientBar(colors);
} }
}); });
@ -311,6 +308,14 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
public abstract TemplateThemePreviewPane<T> createThemePreviewPane(); public abstract TemplateThemePreviewPane<T> createThemePreviewPane();
public void onColorSchemeChanged(List<Color> colors) {
colorListExtendedPane.populate(colors);
ThemedCellStyleList cellStyle = cellStyleSettingPane.updateBean();
FineColorManager.traverse(cellStyle, new FineColorManager.FineColorReplaceByColorScheme(colors));
chartStyleSettingPane.populateGradientBar(colors);
}
public void populateBean(T theme) { public void populateBean(T theme) {
this.theme = theme; this.theme = theme;
isPopulating = true; isPopulating = true;
@ -355,6 +360,10 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
return theme; return theme;
} }
public List<Color> updateColorScheme() {
return colorListPane.update();
}
protected abstract void updateBean(T theme); protected abstract void updateBean(T theme);
protected void updateCellStyleByColorStyle(ThemedColorScheme colorStyle, ThemedCellStyleList cellStyleConfig) { protected void updateCellStyleByColorStyle(ThemedColorScheme colorStyle, ThemedCellStyleList cellStyleConfig) {
ThemedCellStyle headerStyle = cellStyleConfig.find(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); ThemedCellStyle headerStyle = cellStyleConfig.find(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
@ -406,13 +415,6 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
return thumbnail; return thumbnail;
} }
public void saveTheme(T theme) {
if (StringUtils.isEmpty(theme.getName())) {
FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Name_Cannot_Empty"));
} else {
config.addTheme(theme, true);
}
}
public UIButton createSaveButton() { public UIButton createSaveButton() {
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save")); saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save"));
saveButton.setEnabled(false); saveButton.setEnabled(false);
@ -423,12 +425,10 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton);
if (canBeSaved) { if (canBeSaved) {
theme.setName(nameTextField.getText()); theme.setName(nameTextField.getText());
saveTheme(theme); config.addTheme(theme, true);
try { currentIsNewTheme = false;
populateBean((T) theme.clone()); nameTextField.setEnabled(false);
} catch (CloneNotSupportedException ex) { saveAsButton.setEnabled(true);
ex.printStackTrace();
}
} }
} }
}); });
@ -486,8 +486,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
if (canBeSaved) { if (canBeSaved) {
T theme = updateBean(); T theme = updateBean();
theme.setName(nameTextField.getText()); theme.setName(nameTextField.getText());
saveTheme(theme); config.addTheme(theme, true);
exit(); exit();
parent.exit(); parent.exit();
} }

54
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java

@ -28,22 +28,42 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog {
public static final int CONTENT_WIDTH = 660; public static final int CONTENT_WIDTH = 660;
public static final int CONTENT_HEIGHT = 570; public static final int CONTENT_HEIGHT = 570;
private TemplateThemeManagePane<FormTheme> formThemesManagerPane; private final TemplateThemeManageDialogContentPane contentPane;
private TemplateThemeManagePane<ReportTheme> reportThemesManagerPane;
public TemplateThemeManageDialog(Window parent) { public TemplateThemeManageDialog(Window parent) {
super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT);
setContentPane(createDialogContentPane(createContent(), new UIButton[]{ contentPane = new TemplateThemeManageDialogContentPane();
createCompleteButton()
})); setContentPane(createDialogContentPane(contentPane, new UIButton[]{ createCompleteButton() }));
}
private UIButton createCompleteButton() {
UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Complete"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
exit();
}
});
return button;
}
@Override
public void exit(){
contentPane.exit();
super.exit();
} }
private JPanel createContent() { public static class TemplateThemeManageDialogContentPane extends JPanel {
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); private final TemplateThemeManagePane<FormTheme> formThemesManagerPane;
content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); private final TemplateThemeManagePane<ReportTheme> reportThemesManagerPane;
public TemplateThemeManageDialogContentPane() {
setLayout(FRGUIPaneFactory.createBorderLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
UITabbedPane tabbedPane = new UITabbedPane(); UITabbedPane tabbedPane = new UITabbedPane();
content.add(tabbedPane, BorderLayout.NORTH); add(tabbedPane, BorderLayout.NORTH);
formThemesManagerPane = TemplateThemeManagePane.createFormThemesManagerPane(); formThemesManagerPane = TemplateThemeManagePane.createFormThemesManagerPane();
formThemesManagerPane.startListenThemeConfig(); formThemesManagerPane.startListenThemeConfig();
@ -61,25 +81,11 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog {
tabbedPane.setSelectedIndex(1); tabbedPane.setSelectedIndex(1);
} }
} }
return content;
}
private UIButton createCompleteButton() {
UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Complete"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
exit();
}
});
return button;
} }
@Override
public void exit() { public void exit() {
formThemesManagerPane.stopListenThemeConfig(); formThemesManagerPane.stopListenThemeConfig();
reportThemesManagerPane.stopListenThemeConfig(); reportThemesManagerPane.stopListenThemeConfig();
super.exit(); }
} }
} }

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

@ -4,14 +4,29 @@ import com.fr.base.theme.TemplateTheme;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.theme.TemplateThemeProfilePane; import com.fr.design.mainframe.theme.TemplateThemeProfilePane;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.FileFILE;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.file.filter.FILEFilter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
/** /**
* @author Starryi * @author Starryi
@ -19,21 +34,85 @@ import java.awt.event.ActionListener;
* Created by Starryi on 2021/8/13 * Created by Starryi on 2021/8/13
*/ */
public class TemplateThemeProfileDialog<T extends TemplateTheme> extends TemplateThemeDialog { public class TemplateThemeProfileDialog<T extends TemplateTheme> extends TemplateThemeDialog {
public static TemplateThemeProfilePane<? extends TemplateTheme> currentVisibleProfilePane;
public static final int CONTENT_WIDTH = 900; public static final int CONTENT_WIDTH = 900;
public static final int CONTENT_HEIGHT = 570; public static final int CONTENT_HEIGHT = 570;
public TemplateThemeProfileDialog(Window parent, TemplateThemeProfilePane<T> profilePane) { public TemplateThemeProfileDialog(Window parent, TemplateThemeProfilePane<T> profilePane) {
super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Profile_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Profile_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT);
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT));
content.add(profilePane, BorderLayout.CENTER); content.add(profilePane, BorderLayout.CENTER);
setContentPane(createDialogContentPane(content, new UIButton[]{ setContentPane(createDialogContentPane(content, new UIButton[]{
// 用于视觉设计师导出内置主题文件,发布前关闭
// 后续由产品经理决定是否开启此功能
createExportButton(profilePane),
profilePane.createSaveButton(), profilePane.createSaveButton(),
profilePane.createSaveAsButton(this), profilePane.createSaveAsButton(this),
createCancelButton() createCancelButton()
})); }));
currentVisibleProfilePane = profilePane;
}
private void exportTheme(T theme) {
FILEChooserPane fileChooser = FILEChooserPane.getInstance(true, true, new ChooseFileFilter() {
@Override
public boolean accept(FILE f) {
return f.isDirectory();
}
@Override
public String getDescription() {
return "export theme to xml";
}
@Override
public boolean containsExtension(String extension) {
return true;
}
@Override
public String toString() {
return getDescription();
}
});
fileChooser.setCurrentDirectory(new FileFILE(new File("~/")));
fileChooser.setFileNameTextField(theme.getName(), ".xml");
FILE exportedFile = null;
int result = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), ".xml");
if (result == FILEChooserPane.JOPTIONPANE_OK_OPTION || result == FILEChooserPane.OK_OPTION) {
exportedFile = fileChooser.getSelectedFILE();
}
if (exportedFile == null) {
return;
}
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(exportedFile.getPath()))) {
XMLPrintWriter writer = XMLPrintWriter.create(bos);
theme.writeXML(writer);
writer.flush();
writer.close();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public UIButton createExportButton(TemplateThemeProfilePane<T> profilePane) {
UIButton exportButton = new UIButton();
exportButton.setText(Toolkit.i18nText("Fine-Design_Basic_Export"));
exportButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
T theme = profilePane.updateBean();
exportTheme(theme);
}
});
return exportButton;
} }
private UIButton createCancelButton() { private UIButton createCancelButton() {
@ -46,4 +125,21 @@ public class TemplateThemeProfileDialog<T extends TemplateTheme> extends Templat
}); });
return button; return button;
} }
@Override
public void exit() {
currentVisibleProfilePane = null;
super.exit();
}
public static List<Color> getEditingColorScheme() {
if (currentVisibleProfilePane != null) {
return currentVisibleProfilePane.updateColorScheme();
}
return null;
}
public static boolean isEditingTheme() {
return currentVisibleProfilePane != null;
}
} }

102
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.theme.edit;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.base.theme.settings.ThemedCellStyleList; import com.fr.base.theme.settings.ThemedCellStyleList;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
@ -13,12 +14,16 @@ import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper; import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ilist.DefaultListCellEditor;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener; import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.edit.cell.CellStyleEditPane; import com.fr.design.mainframe.theme.edit.cell.CellStyleEditPane;
import com.fr.design.mainframe.theme.edit.cell.NoBorderPaneCellStyleEditPane;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
@ -27,10 +32,12 @@ import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JList;
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 java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -89,7 +96,27 @@ public class CellStyleListEditPane extends JListControlPane {
@Override @Override
public NameableCreator[] createNameableCreators() { public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{ new CellStyleNameObjectCreator()}; return new NameableCreator[]{ new DefaultCellStyleNameObjectCreator(), new CellStyleNameObjectCreator() };
}
@Override
protected JNameEdList createJNameList() {
JNameEdList nameEdList = super.createJNameList();
nameEdList.setCellEditor(new DefaultListCellEditor(new UITextField()) {
@Override
public Component getListCellEditorComponent(JList list, Object value, boolean isSelected, int index) {
ListModelElement element = (ListModelElement) getModel().getElementAt(index);
if (element != null) {
NameObject selectNameObject = (NameObject) element.wrapper;
ThemedCellStyle cellStyle = (ThemedCellStyle) (selectNameObject.getObject());
if (!cellStyle.isRemovable()) {
return null;
}
}
return super.getListCellEditorComponent(list, value, isSelected, index);
}
});
return nameEdList;
} }
@Override @Override
@ -139,6 +166,36 @@ public class CellStyleListEditPane extends JListControlPane {
return new AddItemShortCut4JControlPane(shortCut); return new AddItemShortCut4JControlPane(shortCut);
} }
public void populateBean(ThemedCellStyleList ob) {
if (ob == null) {
return;
}
List<NameObject> nameObjectList = new ArrayList<>();
List<ThemedCellStyle> cellStyleList = ob.getCellStyleList();
for (ThemedCellStyle cellStyle: cellStyleList) {
nameObjectList.add(new NameObject(cellStyle.getName(), cellStyle));
}
NameObject[] nameObjectArray = new NameObject[nameObjectList.size()];
nameObjectList.toArray(nameObjectArray);
populate(nameObjectArray);
}
public ThemedCellStyleList updateBean() {
Nameable[] nameables = this.update();
ThemedCellStyleList styleConfig = new ThemedCellStyleList();
for (Nameable nameable : nameables) {
ThemedCellStyle tmpStyle = (ThemedCellStyle) ((NameObject) nameable).getObject();
tmpStyle.setName(nameable.getName());
styleConfig.addThemedCellStyle(tmpStyle);
}
return styleConfig;
}
private static class AddItemShortCut4JControlPane extends ShortCut4JControlPane{ private static class AddItemShortCut4JControlPane extends ShortCut4JControlPane{
AddItemShortCut4JControlPane(ShortCut shortCut) { AddItemShortCut4JControlPane(ShortCut shortCut) {
this.shortCut = shortCut; this.shortCut = shortCut;
@ -185,13 +242,21 @@ public class CellStyleListEditPane extends JListControlPane {
private static class CellStyleNameObjectCreator extends NameObjectCreator { private static class CellStyleNameObjectCreator extends NameObjectCreator {
public CellStyleNameObjectCreator() { public CellStyleNameObjectCreator() {
super(i18nText("Fine-Design_Predefined_Cell_New_Style"), ThemedCellStyle.class, CellStyleEditPane.class); this(CellStyleEditPane.class);
}
public CellStyleNameObjectCreator(Class<? extends BasicBeanPane> updatePane) {
super(i18nText("Fine-Design_Predefined_Cell_New_Style"), ThemedCellStyle.class, updatePane);
} }
public Nameable createNameable(UnrepeatedNameHelper helper) { public Nameable createNameable(UnrepeatedNameHelper helper) {
ThemedCellStyle cellStyle = new ThemedCellStyle(); ThemedCellStyle cellStyle = new ThemedCellStyle();
cellStyle.setName(menuName); cellStyle.setName(menuName);
cellStyle.setStyle(Style.getInstance()); cellStyle.setStyle(Style.getInstance());
cellStyle.setRemovable(true);
cellStyle.setImmutable(true);
cellStyle.setDefault4Absent(false);
cellStyle.setDefault4New(false);
return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle); return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle);
} }
@ -199,44 +264,27 @@ public class CellStyleListEditPane extends JListControlPane {
if (ob instanceof NameObject) { if (ob instanceof NameObject) {
ob = ((NameObject) ob).getObject(); ob = ((NameObject) ob).getObject();
} }
if (clazzOfObject != null && clazzOfObject.isInstance(ob) && acceptDefaultNameObject(ob)) { if (clazzOfObject != null && clazzOfObject.isInstance(ob) && acceptNameObject(ob)) {
doSthChanged4Icon(ob); doSthChanged4Icon(ob);
return ob; return ob;
} }
return null; return null;
} }
public boolean acceptDefaultNameObject(Object ob) { public boolean acceptNameObject(Object ob) {
return !((ThemedCellStyle) ob).isDefault4New(); return !((ThemedCellStyle) ob).isDefault4New();
} }
} }
public void populateBean(ThemedCellStyleList ob) { private static class DefaultCellStyleNameObjectCreator extends CellStyleNameObjectCreator {
if (ob == null) {
return;
}
List<NameObject> nameObjectList = new ArrayList<>(); public DefaultCellStyleNameObjectCreator() {
super(NoBorderPaneCellStyleEditPane.class);
List<ThemedCellStyle> cellStyleList = ob.getCellStyleList();
for (ThemedCellStyle cellStyle: cellStyleList) {
nameObjectList.add(new NameObject(cellStyle.getName(), cellStyle));
}
NameObject[] nameObjectArray = new NameObject[nameObjectList.size()];
nameObjectList.toArray(nameObjectArray);
populate(nameObjectArray);
} }
public ThemedCellStyleList updateBean() { @Override
Nameable[] nameables = this.update(); public boolean acceptNameObject(Object ob) {
ThemedCellStyleList styleConfig = new ThemedCellStyleList(); return ((ThemedCellStyle) ob).isDefault4New();
for (Nameable nameable : nameables) {
ThemedCellStyle tmpStyle = (ThemedCellStyle) ((NameObject) nameable).getObject();
tmpStyle.setName(nameable.getName());
styleConfig.addThemedCellStyle(tmpStyle);
} }
return styleConfig;
} }
} }

10
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java

@ -76,19 +76,9 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
this.populating = true; this.populating = true;
this.cellStyle = ob; this.cellStyle = ob;
BasicPane borderPane = null;
for (BasicPane basicPane : paneList) { for (BasicPane basicPane : paneList) {
((AbstractBasicStylePane) basicPane).populateBean(ob.getStyle()); ((AbstractBasicStylePane) basicPane).populateBean(ob.getStyle());
previewArea.preview(ob.getStyle()); previewArea.preview(ob.getStyle());
if (basicPane instanceof BorderPane) {
borderPane = basicPane;
}
}
if (borderPane != null && ob.isDefault4New()) {
// 默认单元格样式不显示边框面板,禁止用户编辑边框
paneList.remove(borderPane);
relayoutWhenListChange();
} }
this.populating = false; this.populating = false;
} }

19
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/NoBorderPaneCellStyleEditPane.java

@ -0,0 +1,19 @@
package com.fr.design.mainframe.theme.edit.cell;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.style.AlignmentPane;
import com.fr.design.gui.style.FormatPane;
import java.util.ArrayList;
import java.util.List;
public class NoBorderPaneCellStyleEditPane extends CellStyleEditPane {
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<>();
paneList.add(new FormatPane());
paneList.add(new AlignmentPane());
return paneList;
}
}

105
designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

@ -1,15 +1,19 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import com.fr.base.FineColor; import com.fr.base.FineColor;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.file.HistoryTemplateListCache;
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.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JButton; import javax.swing.JButton;
@ -24,6 +28,7 @@ import java.awt.GridLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
/** /**
@ -49,6 +54,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
// 最近使用颜色 // 最近使用颜色
private final NewUsedColorPane usedColorPane; private final NewUsedColorPane usedColorPane;
private final JPanel menuColorPane;
private ColorCell[][] themeColorCellGrid;
public static NewColorSelectPane createColorSelectPaneWithTheme(boolean supportTheme){ public static NewColorSelectPane createColorSelectPaneWithTheme(boolean supportTheme){
return new NewColorSelectPane(true, supportTheme); return new NewColorSelectPane(true, supportTheme);
@ -76,12 +83,12 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0 ,4)); centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0 ,4));
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
JPanel menuColorPane1 = getMenuColorPane(); menuColorPane = getMenuColorPane();
centerPane.add(menuColorPane1); centerPane.add(menuColorPane);
if(isSupportThemeColor){ if(isSupportThemeColor){
initThemeColorPane(menuColorPane1); initThemeColorPane();
}else { }else {
initMenuColorPane(menuColorPane1); initMenuColorPane();
} }
JPanel standardColorPane = new JPanel(new BorderLayout(0, 5)); JPanel standardColorPane = new JPanel(new BorderLayout(0, 5));
@ -132,34 +139,89 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
return jPanel; return jPanel;
} }
private void initThemeColorPane(JPanel menuColorPane){ private void initThemeColorPane(){
menuColorPane.removeAll();
menuColorPane.setLayout(new BorderLayout(0, 10)); menuColorPane.setLayout(new BorderLayout(0, 10));
JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0)); JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0));
JPanel centerPane = new JPanel(new GridLayout(1, 8, 3, 0)); JPanel centerPane = new JPanel(new GridLayout(1, 8, 3, 0));
menuColorPane.add(northPane, BorderLayout.NORTH); menuColorPane.add(northPane, BorderLayout.NORTH);
menuColorPane.add(centerPane, BorderLayout.CENTER); menuColorPane.add(centerPane, BorderLayout.CENTER);
//todo 暂时先写死,后续对接的时候从主体里面拿主题配色
Color[] colorArray = new Color[]{Color.decode("#FFFFFF"), Color.decode("#CCCCCC"),
Color.decode("#E6A48A"), Color.decode("#E68A8A"), Color.gray, Color.green, Color.DARK_GRAY, Color.CYAN, Color.YELLOW, Color.lightGray};
Color[] colorArray = new Color[] {
// 2列灰度色
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
// 8列主题色
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
};
if (themeColorCellGrid == null) {
themeColorCellGrid = new ColorCell[colorArray.length][5];
for (int i = 0; i < colorArray.length; i++) { for (int i = 0; i < colorArray.length; i++) {
Color color = colorArray[i]; ColorCell[] colorCellColumn = new ColorCell[5];
boolean isDefaultColor = (i == 0 || i == 1); boolean isDefaultColor = (i == 0 || i == 1);
northPane.add(createFineColorCell(color, isDefaultColor, i, 0)); Color color = colorArray[i];
colorCellColumn[0] = createFineColorCell(color, isDefaultColor, i, 2);
colorCellColumn[2] = createFineColorCell(color = saturationDown(color, false, true), isDefaultColor, i, 1);
colorCellColumn[1] = createFineColorCell(saturationDown(color, false, true), isDefaultColor, i, 0);
color = colorArray[i];
colorCellColumn[3] = createFineColorCell(color = saturationDown(color, false, false), isDefaultColor, i, 3);
colorCellColumn[4] = createFineColorCell(saturationDown(color, false, false), isDefaultColor, i, 4);
themeColorCellGrid[i] = colorCellColumn;
}
} }
for (int i = 0; i < colorArray.length; i++) { for (int i = 0; i < colorArray.length; i++) {
Color color = colorArray[i]; northPane.add(themeColorCellGrid[i][0]);
boolean isDefaultColor = (i == 0 || i == 1); }
JPanel jPanel = new JPanel(new GridLayout(4, 1, 0, 3)); for (int i = 0; i < colorArray.length; i++) {
jPanel.add(createFineColorCell(color = saturationDown(color, isDefaultColor, true), isDefaultColor, i, 1)); JPanel columnPane = new JPanel(new GridLayout(4, 1, 0, 3));
jPanel.add(createFineColorCell(saturationDown(color, isDefaultColor, true), isDefaultColor, i, 2)); columnPane.add(themeColorCellGrid[i][1]);
color = colorArray[i]; columnPane.add(themeColorCellGrid[i][2]);
jPanel.add(createFineColorCell(color = saturationDown(color, isDefaultColor, false), isDefaultColor, i, 3)); columnPane.add(themeColorCellGrid[i][3]);
jPanel.add(createFineColorCell(saturationDown(color, isDefaultColor, false), isDefaultColor, i, 4)); columnPane.add(themeColorCellGrid[i][4]);
centerPane.add(jPanel); centerPane.add(columnPane);
} }
refreshThemeMenuColorPane();
}
private void refreshThemeMenuColorPane() {
List<Color> standardColors = null;
if (TemplateThemeProfileDialog.isEditingTheme()) {
standardColors = TemplateThemeProfileDialog.getEditingColorScheme();
} else {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
TemplateTheme theme = template.getTemplateTheme();
if (theme != null) {
standardColors = theme.getColorScheme().getColors();
}
}
}
if (standardColors == null || standardColors.size() != 8) {
return;
}
for (int i = 2; i < themeColorCellGrid.length; i++) {
Color color = standardColors.get(i - 2);
themeColorCellGrid[i][0].setColor(color);
themeColorCellGrid[i][2].setColor(color = saturationDown(color, false, true));
themeColorCellGrid[i][1].setColor(saturationDown(color, false, true));
color = standardColors.get(i - 2);
themeColorCellGrid[i][3].setColor(color = saturationDown(color, false, false));
themeColorCellGrid[i][4].setColor(saturationDown(color, false, false));
}
} }
@ -183,7 +245,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
return color1; return color1;
} }
private void initMenuColorPane(JPanel menuColorPane) { private void initMenuColorPane() {
menuColorPane.setLayout(new GridLayout(5, 8, 3, 3)); menuColorPane.setLayout(new GridLayout(5, 8, 3, 3));
Color[] colorArray = this.getColorArray(); Color[] colorArray = this.getColorArray();
for (int i = 0; i < colorArray.length; i++) { for (int i = 0; i < colorArray.length; i++) {
@ -259,6 +321,9 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
*/ */
@Override @Override
public void setColor(Color color) { public void setColor(Color color) {
if (isSupportThemeColor) {
refreshThemeMenuColorPane();
}
FineColor fineColor; FineColor fineColor;
if (color == null) { if (color == null) {
fineColor = null; fineColor = null;

31
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -37,6 +37,7 @@ import com.fr.form.main.WidgetGather;
import com.fr.form.share.editor.SharableEditorProvider; import com.fr.form.share.editor.SharableEditorProvider;
import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.ShareLoader; import com.fr.form.share.ShareLoader;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
@ -149,7 +150,6 @@ public class FormCreatorDropTarget extends DropTarget {
EventDispatcher.fire(TableDataModifyEvent.INSTANCE, new ContentChangeItem(tdNameMap, widget, ChangeItem.TABLE_DATA_NAME)); EventDispatcher.fire(TableDataModifyEvent.INSTANCE, new ContentChangeItem(tdNameMap, widget, ChangeItem.TABLE_DATA_NAME));
} }
// 新疆的图表块和报表块默认主题化 // 新疆的图表块和报表块默认主题化
addThemeToNewWidget(addingXCreator); addThemeToNewWidget(addingXCreator);
@ -366,23 +366,34 @@ public class FormCreatorDropTarget extends DropTarget {
private void addThemeToNewWidget(XCreator addingXCreator) { private void addThemeToNewWidget(XCreator addingXCreator) {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template == null) {
return;
}
TemplateTheme theme = template.getTemplateTheme(); TemplateTheme theme = template.getTemplateTheme();
if (theme instanceof FormTheme) { if (!(theme instanceof FormTheme)) {
return;
}
FormTheme formTheme = (FormTheme) theme; FormTheme formTheme = (FormTheme) theme;
Form.traversalWidget(addingXCreator.toData(), new WidgetGather() { Form.traversalWidget(addingXCreator.toData(), new WidgetGather() {
@Override @Override
public void dealWith(Widget widget) { public void dealWith(Widget widget) {
if (widget instanceof TemplateThemeAware) { if (widget instanceof AbstractBorderStyleWidget) {
((TemplateThemeAware) widget).onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE); AbstractBorderStyleWidget styleWidget = (AbstractBorderStyleWidget) widget;
} if (!styleWidget.supportThemed()) {
return;
} }
@Override boolean followingTheme = (!addingXCreator.isShared()) || styleWidget.isBorderStyleFollowingTheme();
public boolean dealWithAllCards() { styleWidget.setBorderStyleFollowingTheme(followingTheme);
return true; if (followingTheme) {
styleWidget.onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE);
} }
}, TemplateThemeAware.class);
addingXCreator.firePropertyChange();
} }
} }
@Override
public boolean dealWithAllCards() { return true; }
}, AbstractBorderStyleWidget.class);
addingXCreator.rebuid();
}
} }

14
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -1170,7 +1170,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
@Override @Override
public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() { public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() {
return FormThemeConfig.getInstance(); return getTarget().getUsingTemplateThemeConfig();
} }
@Override @Override
@ -1181,13 +1181,15 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
@Override @Override
public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) {
FormTheme oldTheme = getTarget().getTemplateTheme(); FormTheme oldTheme = getTarget().getTemplateTheme();
boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName());
getTarget().setTemplateTheme(newTheme, compatible); getTarget().setTemplateTheme(newTheme, compatible);
if (compatible == TemplateThemeCompatible.NONE && StringUtils.equals(oldTheme.getName(), newTheme.getName()) ) {
// 模版主题切换会产生一个回退 fireTargetModified(shouldCreateUndoState);
fireTargetModified(); JForm.this.refreshRoot();
} refreshToolArea();
refreshRoot();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
super.setTemplateTheme(newTheme, compatible); super.setTemplateTheme(newTheme, compatible);
} }
} }

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

@ -25,7 +25,7 @@ public class TemplateThemeManagerAction extends SnapChatUpdateAction {
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png"));
this.generateAndSetSearchText(TemplateThemeManageDialog.class.getName()); this.generateAndSetSearchText(TemplateThemeManageDialog.TemplateThemeManageDialogContentPane.class.getName());
} }
@Override @Override

15
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -1271,7 +1271,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
@Override @Override
public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() { public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() {
return ReportThemeConfig.getInstance(); return getTarget().getUsingTemplateThemeConfig();
} }
@Override @Override
@ -1282,12 +1282,15 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
@Override @Override
public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) {
ReportTheme oldTheme = getTarget().getTemplateTheme(); ReportTheme oldTheme = getTarget().getTemplateTheme();
boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName());
getTarget().setTemplateTheme(newTheme, compatible); getTarget().setTemplateTheme(newTheme, compatible);
if (compatible == TemplateThemeCompatible.NONE && StringUtils.equals(oldTheme.getName(), newTheme.getName()) ) {
// 模版主题切换会产生一个回退 fireTargetModified(shouldCreateUndoState);
fireTargetModified(); reportComposite.setSelectedIndex(reportComposite.getSelectedIndex());
} TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
DesignModuleFactory.getFormHierarchyPane().refreshRoot(); DesignerContext.getDesignerFrame().resetToolkitByPlus(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
super.setTemplateTheme(newTheme, compatible); super.setTemplateTheme(newTheme, compatible);
} }
} }

1
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java

@ -160,7 +160,6 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
} }
} }
styleList.setModel(defaultListModel); styleList.setModel(defaultListModel);
GUICoreUtils.repaint(this);
} }
} }
Loading…
Cancel
Save