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. 4
      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. 72
      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. 109
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java
  13. 41
      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();
}
public void fireTargetModified(boolean shouldCreateNewUndoState) {
if (shouldCreateNewUndoState) {
fireTargetModified();
} else {
super.fireTargetModified();
}
}
protected abstract U createUndoState();
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;
import com.fr.base.theme.FineColorManager;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.settings.ThemedComponentStyle;
@ -10,6 +11,9 @@ import com.fr.design.mainframe.theme.preview.FormThemePreviewPane;
import javax.swing.JPanel;
import java.awt.Color;
import java.util.List;
import static com.fr.design.i18n.Toolkit.i18nText;
/**
@ -47,6 +51,20 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane<FormTheme> {
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
public void populateBean(FormTheme 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;
import com.fr.base.theme.FineColorManager;
import com.fr.base.theme.ReportTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.settings.ThemedReportBodyStyle;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.theme.edit.ReportBodyStyleEditPane;
import com.fr.design.mainframe.theme.preview.ReportThemePreviewPane;
import javax.swing.JPanel;
import java.awt.Color;
import java.util.List;
/**
* @author Starryi
@ -35,6 +39,17 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane<ReportTheme
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
public void populateBean(ReportTheme theme) {
super.populateBean(theme);

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

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

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 {
private final RemoveThemeAction removeAction;
private final UIButton setTheme4NewTemplate;
private final UIButton setTheme4NewTemplateButton;
private final TemplateThemeConfig<T> config;
private final TemplateThemeListPane<T> themeListPane;
@ -73,7 +73,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
this.profilePane = profilePane;
this.themeListPane = new TemplateThemeListPane<>(config, profilePane);
this.removeAction = new RemoveThemeAction(false);
this.setTheme4NewTemplate = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting"));
this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting"));
profilePane.setThemeListPane(themeListPane);
@ -100,13 +100,13 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
@Override
public void fireChanged(ChangeEvent event) {
resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction);
resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplate);
resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplateButton);
}
});
nextContainer.add(themeListPane, BorderLayout.CENTER);
resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction);
resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplate);
resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplateButton);
repaint();
}
@ -164,7 +164,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
toolbarDef.addShortCut(addMenuDef, removeAction);
toolbarDef.updateToolBar(toolBar);
setTheme4NewTemplate.addActionListener(new ActionListener() {
setTheme4NewTemplateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
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();
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.theme.FineColorManager;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.settings.ThemeThumbnail;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.base.theme.settings.ThemedCellStyleList;
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.AttributeChangeListener;
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.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@ -54,6 +51,7 @@ import java.awt.event.FocusEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.List;
/**
* @author Starryi
@ -269,8 +267,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
@Override
public void stateChanged(ChangeEvent e) {
List<Color> colors = colorListPane.update();
colorListExtendedPane.populate(colors);
chartStyleSettingPane.populateGradientBar(colors);
onColorSchemeChanged(colors);
}
});
@ -311,6 +308,14 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
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) {
this.theme = theme;
isPopulating = true;
@ -355,6 +360,10 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
return theme;
}
public List<Color> updateColorScheme() {
return colorListPane.update();
}
protected abstract void updateBean(T theme);
protected void updateCellStyleByColorStyle(ThemedColorScheme colorStyle, ThemedCellStyleList cellStyleConfig) {
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;
}
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() {
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save"));
saveButton.setEnabled(false);
@ -423,12 +425,10 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton);
if (canBeSaved) {
theme.setName(nameTextField.getText());
saveTheme(theme);
try {
populateBean((T) theme.clone());
} catch (CloneNotSupportedException ex) {
ex.printStackTrace();
}
config.addTheme(theme, true);
currentIsNewTheme = false;
nameTextField.setEnabled(false);
saveAsButton.setEnabled(true);
}
}
});
@ -486,8 +486,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
if (canBeSaved) {
T theme = updateBean();
theme.setName(nameTextField.getText());
saveTheme(theme);
config.addTheme(theme, true);
exit();
parent.exit();
}

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

@ -28,41 +28,13 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog {
public static final int CONTENT_WIDTH = 660;
public static final int CONTENT_HEIGHT = 570;
private TemplateThemeManagePane<FormTheme> formThemesManagerPane;
private TemplateThemeManagePane<ReportTheme> reportThemesManagerPane;
private final TemplateThemeManageDialogContentPane contentPane;
public TemplateThemeManageDialog(Window parent) {
super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT);
setContentPane(createDialogContentPane(createContent(), new UIButton[]{
createCompleteButton()
}));
}
private JPanel createContent() {
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
UITabbedPane tabbedPane = new UITabbedPane();
content.add(tabbedPane, BorderLayout.NORTH);
formThemesManagerPane = TemplateThemeManagePane.createFormThemesManagerPane();
formThemesManagerPane.startListenThemeConfig();
reportThemesManagerPane = TemplateThemeManagePane.createReportThemesManagerPane();
reportThemesManagerPane.startListenThemeConfig();
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_FORM_TAB"), formThemesManagerPane);
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_REPORT_TAB"), reportThemesManagerPane);
contentPane = new TemplateThemeManageDialogContentPane();
tabbedPane.setSelectedIndex(0);
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
TemplateThemeConfig<? extends TemplateTheme> config = template.getUsingTemplateThemeConfig();
if (config == reportThemesManagerPane.getConfig()) {
tabbedPane.setSelectedIndex(1);
}
}
return content;
setContentPane(createDialogContentPane(contentPane, new UIButton[]{ createCompleteButton() }));
}
private UIButton createCompleteButton() {
@ -78,8 +50,42 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog {
@Override
public void exit(){
formThemesManagerPane.stopListenThemeConfig();
reportThemesManagerPane.stopListenThemeConfig();
contentPane.exit();
super.exit();
}
public static class TemplateThemeManageDialogContentPane extends JPanel {
private final TemplateThemeManagePane<FormTheme> formThemesManagerPane;
private final TemplateThemeManagePane<ReportTheme> reportThemesManagerPane;
public TemplateThemeManageDialogContentPane() {
setLayout(FRGUIPaneFactory.createBorderLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
UITabbedPane tabbedPane = new UITabbedPane();
add(tabbedPane, BorderLayout.NORTH);
formThemesManagerPane = TemplateThemeManagePane.createFormThemesManagerPane();
formThemesManagerPane.startListenThemeConfig();
reportThemesManagerPane = TemplateThemeManagePane.createReportThemesManagerPane();
reportThemesManagerPane.startListenThemeConfig();
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_FORM_TAB"), formThemesManagerPane);
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_REPORT_TAB"), reportThemesManagerPane);
tabbedPane.setSelectedIndex(0);
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
TemplateThemeConfig<? extends TemplateTheme> config = template.getUsingTemplateThemeConfig();
if (config == reportThemesManagerPane.getConfig()) {
tabbedPane.setSelectedIndex(1);
}
}
}
public void exit() {
formThemesManagerPane.stopListenThemeConfig();
reportThemesManagerPane.stopListenThemeConfig();
}
}
}

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.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
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 java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
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
@ -19,21 +34,85 @@ import java.awt.event.ActionListener;
* Created by Starryi on 2021/8/13
*/
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_HEIGHT = 570;
public TemplateThemeProfileDialog(Window parent, TemplateThemeProfilePane<T> profilePane) {
super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Profile_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT);
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT));
content.add(profilePane, BorderLayout.CENTER);
setContentPane(createDialogContentPane(content, new UIButton[]{
// 用于视觉设计师导出内置主题文件,发布前关闭
// 后续由产品经理决定是否开启此功能
createExportButton(profilePane),
profilePane.createSaveButton(),
profilePane.createSaveAsButton(this),
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() {
@ -46,4 +125,21 @@ public class TemplateThemeProfileDialog<T extends TemplateTheme> extends Templat
});
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.theme.settings.ThemedCellStyle;
import com.fr.base.theme.settings.ThemedCellStyleList;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
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.UnrepeatedNameHelper;
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.ModNameActionListener;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
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.general.ComparatorUtils;
import com.fr.general.IOUtils;
@ -27,10 +32,12 @@ import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
@ -89,7 +96,27 @@ public class CellStyleListEditPane extends JListControlPane {
@Override
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
@ -139,6 +166,36 @@ public class CellStyleListEditPane extends JListControlPane {
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{
AddItemShortCut4JControlPane(ShortCut shortCut) {
this.shortCut = shortCut;
@ -185,13 +242,21 @@ public class CellStyleListEditPane extends JListControlPane {
private static class CellStyleNameObjectCreator extends NameObjectCreator {
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) {
ThemedCellStyle cellStyle = new ThemedCellStyle();
cellStyle.setName(menuName);
cellStyle.setStyle(Style.getInstance());
cellStyle.setRemovable(true);
cellStyle.setImmutable(true);
cellStyle.setDefault4Absent(false);
cellStyle.setDefault4New(false);
return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle);
}
@ -199,44 +264,27 @@ public class CellStyleListEditPane extends JListControlPane {
if (ob instanceof NameObject) {
ob = ((NameObject) ob).getObject();
}
if (clazzOfObject != null && clazzOfObject.isInstance(ob) && acceptDefaultNameObject(ob)) {
if (clazzOfObject != null && clazzOfObject.isInstance(ob) && acceptNameObject(ob)) {
doSthChanged4Icon(ob);
return ob;
}
return null;
}
public boolean acceptDefaultNameObject(Object ob) {
public boolean acceptNameObject(Object ob) {
return !((ThemedCellStyle) ob).isDefault4New();
}
}
public void populateBean(ThemedCellStyleList ob) {
if (ob == null) {
return;
}
List<NameObject> nameObjectList = new ArrayList<>();
private static class DefaultCellStyleNameObjectCreator extends CellStyleNameObjectCreator {
List<ThemedCellStyle> cellStyleList = ob.getCellStyleList();
for (ThemedCellStyle cellStyle: cellStyleList) {
nameObjectList.add(new NameObject(cellStyle.getName(), cellStyle));
public DefaultCellStyleNameObjectCreator() {
super(NoBorderPaneCellStyleEditPane.class);
}
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);
@Override
public boolean acceptNameObject(Object ob) {
return ((ThemedCellStyle) ob).isDefault4New();
}
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.cellStyle = ob;
BasicPane borderPane = null;
for (BasicPane basicPane : paneList) {
((AbstractBasicStylePane) basicPane).populateBean(ob.getStyle());
previewArea.preview(ob.getStyle());
if (basicPane instanceof BorderPane) {
borderPane = basicPane;
}
}
if (borderPane != null && ob.isDefault4New()) {
// 默认单元格样式不显示边框面板,禁止用户编辑边框
paneList.remove(borderPane);
relayoutWhenListChange();
}
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;
}
}

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

@ -1,15 +1,19 @@
package com.fr.design.style.color;
import com.fr.base.FineColor;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.DesignerEnvManager;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
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.JButton;
@ -24,6 +28,7 @@ import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
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 JPanel menuColorPane;
private ColorCell[][] themeColorCellGrid;
public static NewColorSelectPane createColorSelectPaneWithTheme(boolean 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));
this.add(centerPane, BorderLayout.CENTER);
JPanel menuColorPane1 = getMenuColorPane();
centerPane.add(menuColorPane1);
menuColorPane = getMenuColorPane();
centerPane.add(menuColorPane);
if(isSupportThemeColor){
initThemeColorPane(menuColorPane1);
initThemeColorPane();
}else {
initMenuColorPane(menuColorPane1);
initMenuColorPane();
}
JPanel standardColorPane = new JPanel(new BorderLayout(0, 5));
@ -132,34 +139,89 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
return jPanel;
}
private void initThemeColorPane(JPanel menuColorPane){
private void initThemeColorPane(){
menuColorPane.removeAll();
menuColorPane.setLayout(new BorderLayout(0, 10));
JPanel northPane = 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(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};
for (int i = 0; i < colorArray.length; i++) {
Color color = colorArray[i];
boolean isDefaultColor = (i == 0 || i == 1);
northPane.add(createFineColorCell(color, isDefaultColor, i, 0));
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++) {
ColorCell[] colorCellColumn = new ColorCell[5];
boolean isDefaultColor = (i == 0 || i == 1);
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++) {
Color color = colorArray[i];
boolean isDefaultColor = (i == 0 || i == 1);
JPanel jPanel = new JPanel(new GridLayout(4, 1, 0, 3));
jPanel.add(createFineColorCell(color = saturationDown(color, isDefaultColor, true), isDefaultColor, i, 1));
jPanel.add(createFineColorCell(saturationDown(color, isDefaultColor, true), isDefaultColor, i, 2));
color = colorArray[i];
jPanel.add(createFineColorCell(color = saturationDown(color, isDefaultColor, false), isDefaultColor, i, 3));
jPanel.add(createFineColorCell(saturationDown(color, isDefaultColor, false), isDefaultColor, i, 4));
centerPane.add(jPanel);
northPane.add(themeColorCellGrid[i][0]);
}
for (int i = 0; i < colorArray.length; i++) {
JPanel columnPane = new JPanel(new GridLayout(4, 1, 0, 3));
columnPane.add(themeColorCellGrid[i][1]);
columnPane.add(themeColorCellGrid[i][2]);
columnPane.add(themeColorCellGrid[i][3]);
columnPane.add(themeColorCellGrid[i][4]);
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;
}
private void initMenuColorPane(JPanel menuColorPane) {
private void initMenuColorPane() {
menuColorPane.setLayout(new GridLayout(5, 8, 3, 3));
Color[] colorArray = this.getColorArray();
for (int i = 0; i < colorArray.length; i++) {
@ -259,6 +321,9 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
*/
@Override
public void setColor(Color color) {
if (isSupportThemeColor) {
refreshThemeMenuColorPane();
}
FineColor fineColor;
if (color == null) {
fineColor = null;

41
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.SharableWidgetProvider;
import com.fr.form.share.ShareLoader;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.ElementCaseEditor;
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));
}
// 新疆的图表块和报表块默认主题化
addThemeToNewWidget(addingXCreator);
@ -366,23 +366,34 @@ public class FormCreatorDropTarget extends DropTarget {
private void addThemeToNewWidget(XCreator addingXCreator) {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template == null) {
return;
}
TemplateTheme theme = template.getTemplateTheme();
if (theme instanceof FormTheme) {
FormTheme formTheme = (FormTheme) theme;
Form.traversalWidget(addingXCreator.toData(), new WidgetGather() {
@Override
public void dealWith(Widget widget) {
if (widget instanceof TemplateThemeAware) {
((TemplateThemeAware) widget).onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE);
if (!(theme instanceof FormTheme)) {
return;
}
FormTheme formTheme = (FormTheme) theme;
Form.traversalWidget(addingXCreator.toData(), new WidgetGather() {
@Override
public void dealWith(Widget widget) {
if (widget instanceof AbstractBorderStyleWidget) {
AbstractBorderStyleWidget styleWidget = (AbstractBorderStyleWidget) widget;
if (!styleWidget.supportThemed()) {
return;
}
}
@Override
public boolean dealWithAllCards() {
return true;
boolean followingTheme = (!addingXCreator.isShared()) || styleWidget.isBorderStyleFollowingTheme();
styleWidget.setBorderStyleFollowingTheme(followingTheme);
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
public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() {
return FormThemeConfig.getInstance();
return getTarget().getUsingTemplateThemeConfig();
}
@Override
@ -1181,13 +1181,15 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
@Override
public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) {
FormTheme oldTheme = getTarget().getTemplateTheme();
boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName());
getTarget().setTemplateTheme(newTheme, compatible);
if (compatible == TemplateThemeCompatible.NONE && StringUtils.equals(oldTheme.getName(), newTheme.getName()) ) {
// 模版主题切换会产生一个回退
fireTargetModified();
}
refreshRoot();
fireTargetModified(shouldCreateUndoState);
JForm.this.refreshRoot();
refreshToolArea();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
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.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png"));
this.generateAndSetSearchText(TemplateThemeManageDialog.class.getName());
this.generateAndSetSearchText(TemplateThemeManageDialog.TemplateThemeManageDialogContentPane.class.getName());
}
@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
public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() {
return ReportThemeConfig.getInstance();
return getTarget().getUsingTemplateThemeConfig();
}
@Override
@ -1282,12 +1282,15 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
@Override
public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) {
ReportTheme oldTheme = getTarget().getTemplateTheme();
boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName());
getTarget().setTemplateTheme(newTheme, compatible);
if (compatible == TemplateThemeCompatible.NONE && StringUtils.equals(oldTheme.getName(), newTheme.getName()) ) {
// 模版主题切换会产生一个回退
fireTargetModified();
}
DesignModuleFactory.getFormHierarchyPane().refreshRoot();
fireTargetModified(shouldCreateUndoState);
reportComposite.setSelectedIndex(reportComposite.getSelectedIndex());
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
DesignerContext.getDesignerFrame().resetToolkitByPlus(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
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);
GUICoreUtils.repaint(this);
}
}
Loading…
Cancel
Save