diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java index 980a69172..84aee2d6b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java @@ -75,8 +75,6 @@ public class TemplateThemeManagePane extends BasicPane this.removeAction = new RemoveThemeAction(false); this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting")); - profilePane.setThemeListPane(themeListPane); - initializePane(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java index 0336e89a1..d7fb8e2cb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java @@ -15,6 +15,7 @@ import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Theme; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -82,12 +83,10 @@ public abstract class TemplateThemeProfilePane extends protected boolean isPopulating = false; protected UITabbedPane uiTabbedPane; - protected TemplateThemeListPane themeListPane; - private final TemplateThemeConfig config; - private final UIButton saveButton = new UIButton(); - private final UIButton saveAsButton = new UIButton(); + private UIButton saveButton = new UIButton(); + private UIButton saveAsButton = new UIButton(); private boolean currentIsNewTheme; private T theme; @@ -96,11 +95,6 @@ public abstract class TemplateThemeProfilePane extends this.config = config; theme = config.createNewTheme(); } - - public void setThemeListPane(TemplateThemeListPane themeListPane) { - this.themeListPane = themeListPane; - } - @Override protected JPanel createContentPane() { JPanel container = new JPanel(new BorderLayout(5, 0)); @@ -326,8 +320,12 @@ public abstract class TemplateThemeProfilePane extends nameTextField.setText(name); nameTextField.setEnabled(StringUtils.isEmpty(name)); - saveButton.setEnabled(theme.isMutable() && !currentIsNewTheme); - saveAsButton.setEnabled(!currentIsNewTheme); + if (saveButton != null) { + saveButton.setEnabled(theme.isMutable() && !currentIsNewTheme); + } + if (saveAsButton != null) { + saveAsButton.setEnabled(!currentIsNewTheme); + } cellStyleSettingPane.populateBean(theme.getCellStyleList()); colorListPane.populate(theme.getColorScheme().getColors()); @@ -351,7 +349,6 @@ public abstract class TemplateThemeProfilePane extends ThemedColorScheme colorScheme = theme.getColorScheme(); colorScheme.setColors(this.colorListPane.update()); - updateCellStyleByColorStyle(colorScheme, cellStyleConfig); theme.setColorScheme(colorScheme); theme.setChartStyle(this.chartStyleSettingPane.updateBean()); @@ -360,42 +357,27 @@ public abstract class TemplateThemeProfilePane extends return theme; } - public List updateColorScheme() { + public List getCurrentColorScheme() { 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")); - ThemedCellStyle highlightStyle = cellStyleConfig.find(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); - List colorList = colorStyle.getColors(); - - if (headerStyle != null) { - Style style = headerStyle.getStyle(); - Color color = colorList.get(0); - headerStyle.setStyle(style.deriveBackground(ColorBackground.getInstance(color))); - } - if (highlightStyle != null) { - Style style = highlightStyle.getStyle(); - Color color = colorList.get(1); - FRFont font = style.getFRFont(); - font.setForeground(color); - highlightStyle.setStyle(style.deriveFRFont(font)); - } - } protected ThemeThumbnail updateThumbnail() { BufferedImage image = null; - int width = themePreviewPane.getWidth(); - int height = themePreviewPane.getHeight(); + int imgWidth = ThemeThumbnail.WIDTH; + int imgHeight = ThemeThumbnail.HEIGHT; + + int canvasWidth = themePreviewPane.getWidth(); + int canvasHeight = themePreviewPane.getHeight(); try { // 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image, // 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0) // 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图 - image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + image = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = image.createGraphics(); // 创建一个支持透明背景的buffer image - image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); + image = g2d.getDeviceConfiguration().createCompatibleImage(imgWidth, imgHeight, Transparency.TRANSLUCENT); g2d.dispose(); g2d = image.createGraphics(); @@ -403,8 +385,10 @@ public abstract class TemplateThemeProfilePane extends // 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0) // 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图 g2d.setColor(new Color(255, 255, 255, 1)); - g2d.fillRect(0, 0, width, height); + g2d.fillRect(0, 0, imgWidth, imgHeight); + float scale = Math.max(1.0F * imgWidth / canvasWidth, 1.0F * imgHeight / canvasHeight); + g2d.scale(scale, scale); themePreviewPane.paint(g2d); } catch (Exception e) { @@ -416,6 +400,7 @@ public abstract class TemplateThemeProfilePane extends } public UIButton createSaveButton() { + saveButton = new UIButton(); saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save")); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @@ -423,7 +408,7 @@ public abstract class TemplateThemeProfilePane extends public void actionPerformed(ActionEvent e) { T theme = updateBean(); boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); - if (canBeSaved) { + if (canBeSaved && theme != null) { theme.setName(nameTextField.getText()); config.addTheme(theme, true); currentIsNewTheme = false; @@ -435,6 +420,8 @@ public abstract class TemplateThemeProfilePane extends return saveButton; } public UIButton createSaveAsButton(final TemplateThemeProfileDialog profileDialog) { + saveAsButton = new UIButton(); + saveAsButton.removeAll(); saveAsButton.setText(Toolkit.i18nText("Fine-Design_Basic_Predefined_Save_As_New")); saveAsButton.setEnabled(false); saveAsButton.addActionListener(new ActionListener() { @@ -482,10 +469,12 @@ public abstract class TemplateThemeProfilePane extends confirmButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + T theme = updateBean(); boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); - if (canBeSaved) { - T theme = updateBean(); + if (canBeSaved && theme != null) { theme.setName(nameTextField.getText()); + theme.setRemovable(true); + theme.setMutable(true); config.addTheme(theme, true); exit(); parent.exit(); @@ -589,8 +578,12 @@ public abstract class TemplateThemeProfilePane extends textField.requestFocus(); } errorLabel.setVisible(!valid); - for (UIButton button: actionButtons) { - button.setEnabled(valid); + if (actionButtons != null && actionButtons.length > 0) { + for (UIButton button : actionButtons) { + if (button != null) { + button.setEnabled(valid); + } + } } return valid; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java index 682f3f6d5..31d00043d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java @@ -10,9 +10,8 @@ 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.ListSet; import com.fr.stable.xml.XMLPrintWriter; import javax.swing.JPanel; @@ -109,6 +108,7 @@ public class TemplateThemeProfileDialog extends Templat @Override public void actionPerformed(ActionEvent e) { T theme = profilePane.updateBean(); + theme.getImageIdList().setIdList(new ListSet<>()); exportTheme(theme); } }); @@ -134,7 +134,7 @@ public class TemplateThemeProfileDialog extends Templat public static List getEditingColorScheme() { if (currentVisibleProfilePane != null) { - return currentVisibleProfilePane.updateColorScheme(); + return currentVisibleProfilePane.getCurrentColorScheme(); } return null; }