|
|
@ -15,6 +15,7 @@ import com.fr.design.gui.frpane.UITabbedPane; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
|
|
|
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Theme; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
@ -82,12 +83,10 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
protected boolean isPopulating = false; |
|
|
|
protected boolean isPopulating = false; |
|
|
|
protected UITabbedPane uiTabbedPane; |
|
|
|
protected UITabbedPane uiTabbedPane; |
|
|
|
|
|
|
|
|
|
|
|
protected TemplateThemeListPane<T> themeListPane; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final TemplateThemeConfig<T> config; |
|
|
|
private final TemplateThemeConfig<T> config; |
|
|
|
|
|
|
|
|
|
|
|
private final UIButton saveButton = new UIButton(); |
|
|
|
private UIButton saveButton = new UIButton(); |
|
|
|
private final UIButton saveAsButton = new UIButton(); |
|
|
|
private UIButton saveAsButton = new UIButton(); |
|
|
|
|
|
|
|
|
|
|
|
private boolean currentIsNewTheme; |
|
|
|
private boolean currentIsNewTheme; |
|
|
|
private T theme; |
|
|
|
private T theme; |
|
|
@ -96,11 +95,6 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
this.config = config; |
|
|
|
this.config = config; |
|
|
|
theme = config.createNewTheme(); |
|
|
|
theme = config.createNewTheme(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setThemeListPane(TemplateThemeListPane<T> themeListPane) { |
|
|
|
|
|
|
|
this.themeListPane = themeListPane; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected JPanel createContentPane() { |
|
|
|
protected JPanel createContentPane() { |
|
|
|
JPanel container = new JPanel(new BorderLayout(5, 0)); |
|
|
|
JPanel container = new JPanel(new BorderLayout(5, 0)); |
|
|
@ -326,8 +320,12 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
|
|
|
|
|
|
|
|
nameTextField.setText(name); |
|
|
|
nameTextField.setText(name); |
|
|
|
nameTextField.setEnabled(StringUtils.isEmpty(name)); |
|
|
|
nameTextField.setEnabled(StringUtils.isEmpty(name)); |
|
|
|
|
|
|
|
if (saveButton != null) { |
|
|
|
saveButton.setEnabled(theme.isMutable() && !currentIsNewTheme); |
|
|
|
saveButton.setEnabled(theme.isMutable() && !currentIsNewTheme); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (saveAsButton != null) { |
|
|
|
saveAsButton.setEnabled(!currentIsNewTheme); |
|
|
|
saveAsButton.setEnabled(!currentIsNewTheme); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cellStyleSettingPane.populateBean(theme.getCellStyleList()); |
|
|
|
cellStyleSettingPane.populateBean(theme.getCellStyleList()); |
|
|
|
colorListPane.populate(theme.getColorScheme().getColors()); |
|
|
|
colorListPane.populate(theme.getColorScheme().getColors()); |
|
|
@ -351,7 +349,6 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
|
|
|
|
|
|
|
|
ThemedColorScheme colorScheme = theme.getColorScheme(); |
|
|
|
ThemedColorScheme colorScheme = theme.getColorScheme(); |
|
|
|
colorScheme.setColors(this.colorListPane.update()); |
|
|
|
colorScheme.setColors(this.colorListPane.update()); |
|
|
|
updateCellStyleByColorStyle(colorScheme, cellStyleConfig); |
|
|
|
|
|
|
|
theme.setColorScheme(colorScheme); |
|
|
|
theme.setColorScheme(colorScheme); |
|
|
|
|
|
|
|
|
|
|
|
theme.setChartStyle(this.chartStyleSettingPane.updateBean()); |
|
|
|
theme.setChartStyle(this.chartStyleSettingPane.updateBean()); |
|
|
@ -360,42 +357,27 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
return theme; |
|
|
|
return theme; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<Color> updateColorScheme() { |
|
|
|
public List<Color> getCurrentColorScheme() { |
|
|
|
return colorListPane.update(); |
|
|
|
return colorListPane.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected abstract void updateBean(T theme); |
|
|
|
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<Color> 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() { |
|
|
|
protected ThemeThumbnail updateThumbnail() { |
|
|
|
BufferedImage image = null; |
|
|
|
BufferedImage image = null; |
|
|
|
int width = themePreviewPane.getWidth(); |
|
|
|
int imgWidth = ThemeThumbnail.WIDTH; |
|
|
|
int height = themePreviewPane.getHeight(); |
|
|
|
int imgHeight = ThemeThumbnail.HEIGHT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int canvasWidth = themePreviewPane.getWidth(); |
|
|
|
|
|
|
|
int canvasHeight = themePreviewPane.getHeight(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
|
|
|
|
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
|
|
|
|
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
|
|
|
|
// 使得创建出来的透明像素是(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(); |
|
|
|
Graphics2D g2d = image.createGraphics(); |
|
|
|
// 创建一个支持透明背景的buffer image
|
|
|
|
// 创建一个支持透明背景的buffer image
|
|
|
|
image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); |
|
|
|
image = g2d.getDeviceConfiguration().createCompatibleImage(imgWidth, imgHeight, Transparency.TRANSLUCENT); |
|
|
|
g2d.dispose(); |
|
|
|
g2d.dispose(); |
|
|
|
g2d = image.createGraphics(); |
|
|
|
g2d = image.createGraphics(); |
|
|
|
|
|
|
|
|
|
|
@ -403,8 +385,10 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
|
|
|
|
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
|
|
|
|
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
|
|
|
|
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
|
|
|
|
g2d.setColor(new Color(255, 255, 255, 1)); |
|
|
|
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); |
|
|
|
themePreviewPane.paint(g2d); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -416,6 +400,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public UIButton createSaveButton() { |
|
|
|
public UIButton createSaveButton() { |
|
|
|
|
|
|
|
saveButton = new UIButton(); |
|
|
|
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save")); |
|
|
|
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save")); |
|
|
|
saveButton.setEnabled(false); |
|
|
|
saveButton.setEnabled(false); |
|
|
|
saveButton.addActionListener(new ActionListener() { |
|
|
|
saveButton.addActionListener(new ActionListener() { |
|
|
@ -423,7 +408,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
T theme = updateBean(); |
|
|
|
T theme = updateBean(); |
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
if (canBeSaved) { |
|
|
|
if (canBeSaved && theme != null) { |
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
config.addTheme(theme, true); |
|
|
|
config.addTheme(theme, true); |
|
|
|
currentIsNewTheme = false; |
|
|
|
currentIsNewTheme = false; |
|
|
@ -435,6 +420,8 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
return saveButton; |
|
|
|
return saveButton; |
|
|
|
} |
|
|
|
} |
|
|
|
public UIButton createSaveAsButton(final TemplateThemeProfileDialog<T> profileDialog) { |
|
|
|
public UIButton createSaveAsButton(final TemplateThemeProfileDialog<T> profileDialog) { |
|
|
|
|
|
|
|
saveAsButton = new UIButton(); |
|
|
|
|
|
|
|
saveAsButton.removeAll(); |
|
|
|
saveAsButton.setText(Toolkit.i18nText("Fine-Design_Basic_Predefined_Save_As_New")); |
|
|
|
saveAsButton.setText(Toolkit.i18nText("Fine-Design_Basic_Predefined_Save_As_New")); |
|
|
|
saveAsButton.setEnabled(false); |
|
|
|
saveAsButton.setEnabled(false); |
|
|
|
saveAsButton.addActionListener(new ActionListener() { |
|
|
|
saveAsButton.addActionListener(new ActionListener() { |
|
|
@ -482,10 +469,12 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
confirmButton.addActionListener(new ActionListener() { |
|
|
|
confirmButton.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
|
|
|
if (canBeSaved) { |
|
|
|
|
|
|
|
T theme = updateBean(); |
|
|
|
T theme = updateBean(); |
|
|
|
|
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
|
|
|
if (canBeSaved && theme != null) { |
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
|
|
|
|
theme.setRemovable(true); |
|
|
|
|
|
|
|
theme.setMutable(true); |
|
|
|
config.addTheme(theme, true); |
|
|
|
config.addTheme(theme, true); |
|
|
|
exit(); |
|
|
|
exit(); |
|
|
|
parent.exit(); |
|
|
|
parent.exit(); |
|
|
@ -589,9 +578,13 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
textField.requestFocus(); |
|
|
|
textField.requestFocus(); |
|
|
|
} |
|
|
|
} |
|
|
|
errorLabel.setVisible(!valid); |
|
|
|
errorLabel.setVisible(!valid); |
|
|
|
for (UIButton button: actionButtons) { |
|
|
|
if (actionButtons != null && actionButtons.length > 0) { |
|
|
|
|
|
|
|
for (UIButton button : actionButtons) { |
|
|
|
|
|
|
|
if (button != null) { |
|
|
|
button.setEnabled(valid); |
|
|
|
button.setEnabled(valid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return valid; |
|
|
|
return valid; |
|
|
|
} |
|
|
|
} |
|
|
|