|
|
@ -25,8 +25,10 @@ import com.fr.design.mainframe.theme.edit.ui.ColorListPane; |
|
|
|
import com.fr.design.mainframe.theme.edit.ui.LabelUtils; |
|
|
|
import com.fr.design.mainframe.theme.edit.ui.LabelUtils; |
|
|
|
import com.fr.design.mainframe.theme.ui.BorderUtils; |
|
|
|
import com.fr.design.mainframe.theme.ui.BorderUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import com.fr.transaction.CallBackAdaptor; |
|
|
|
|
|
|
|
import com.fr.transaction.Configurations; |
|
|
|
|
|
|
|
import com.fr.transaction.WorkerFacade; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JComponent; |
|
|
@ -36,19 +38,17 @@ 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; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.Image; |
|
|
|
import java.awt.Transparency; |
|
|
|
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.FocusAdapter; |
|
|
|
import java.awt.event.FocusAdapter; |
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
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.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author Starryi |
|
|
|
* @author Starryi |
|
|
@ -316,7 +316,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
|
|
|
|
|
|
|
|
String name = theme.getName(); |
|
|
|
String name = theme.getName(); |
|
|
|
|
|
|
|
|
|
|
|
currentIsNewTheme = config.find(name) == null; |
|
|
|
currentIsNewTheme = config.cachedFetch(name) == null; |
|
|
|
|
|
|
|
|
|
|
|
nameTextField.setText(name); |
|
|
|
nameTextField.setText(name); |
|
|
|
nameTextField.setEnabled(StringUtils.isEmpty(name)); |
|
|
|
nameTextField.setEnabled(StringUtils.isEmpty(name)); |
|
|
@ -342,7 +342,12 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
|
|
|
|
|
|
|
|
theme.setName(this.nameTextField.getText()); |
|
|
|
theme.setName(this.nameTextField.getText()); |
|
|
|
|
|
|
|
|
|
|
|
theme.setThumbnail(updateThumbnail()); |
|
|
|
Image thumbnailImage = themePreviewPane.createThumbnailImage(); |
|
|
|
|
|
|
|
if (thumbnailImage != null) { |
|
|
|
|
|
|
|
ThemeThumbnail thumbnail = new ThemeThumbnail(); |
|
|
|
|
|
|
|
thumbnail.setImage(thumbnailImage); |
|
|
|
|
|
|
|
theme.setThumbnail(thumbnail); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ThemedCellStyleList cellStyleConfig = this.cellStyleSettingPane.updateBean(); |
|
|
|
ThemedCellStyleList cellStyleConfig = this.cellStyleSettingPane.updateBean(); |
|
|
|
theme.setCellStyleList(cellStyleConfig); |
|
|
|
theme.setCellStyleList(cellStyleConfig); |
|
|
@ -363,42 +368,6 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
|
|
|
|
|
|
|
|
protected abstract void updateBean(T theme); |
|
|
|
protected abstract void updateBean(T theme); |
|
|
|
|
|
|
|
|
|
|
|
protected ThemeThumbnail updateThumbnail() { |
|
|
|
|
|
|
|
BufferedImage image = null; |
|
|
|
|
|
|
|
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(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); |
|
|
|
|
|
|
|
Graphics2D g2d = image.createGraphics(); |
|
|
|
|
|
|
|
// 创建一个支持透明背景的buffer image
|
|
|
|
|
|
|
|
image = g2d.getDeviceConfiguration().createCompatibleImage(imgWidth, imgHeight, Transparency.TRANSLUCENT); |
|
|
|
|
|
|
|
g2d.dispose(); |
|
|
|
|
|
|
|
g2d = image.createGraphics(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
|
|
|
|
|
|
|
|
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
|
|
|
|
|
|
|
|
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
|
|
|
|
|
|
|
|
g2d.setColor(new Color(255, 255, 255, 1)); |
|
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ThemeThumbnail thumbnail = new ThemeThumbnail(); |
|
|
|
|
|
|
|
thumbnail.setImage(image); |
|
|
|
|
|
|
|
return thumbnail; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UIButton createSaveButton() { |
|
|
|
public UIButton createSaveButton() { |
|
|
|
saveButton = new UIButton(); |
|
|
|
saveButton = new UIButton(); |
|
|
|
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save")); |
|
|
|
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save")); |
|
|
@ -410,11 +379,21 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
if (canBeSaved && theme != null) { |
|
|
|
if (canBeSaved && theme != null) { |
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
|
|
|
|
Configurations.modify(new WorkerFacade(config.getClass()) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
config.addTheme(theme, true); |
|
|
|
config.addTheme(theme, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.addCallBack(new CallBackAdaptor() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void afterCommit() { |
|
|
|
|
|
|
|
super.afterCommit(); |
|
|
|
currentIsNewTheme = false; |
|
|
|
currentIsNewTheme = false; |
|
|
|
nameTextField.setEnabled(false); |
|
|
|
nameTextField.setEnabled(false); |
|
|
|
saveAsButton.setEnabled(true); |
|
|
|
saveAsButton.setEnabled(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
return saveButton; |
|
|
|
return saveButton; |
|
|
@ -475,10 +454,20 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
theme.setRemovable(true); |
|
|
|
theme.setRemovable(true); |
|
|
|
theme.setMutable(true); |
|
|
|
theme.setMutable(true); |
|
|
|
|
|
|
|
Configurations.modify(new WorkerFacade(config.getClass()) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
config.addTheme(theme, true); |
|
|
|
config.addTheme(theme, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.addCallBack(new CallBackAdaptor() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void afterCommit() { |
|
|
|
|
|
|
|
super.afterCommit(); |
|
|
|
exit(); |
|
|
|
exit(); |
|
|
|
parent.exit(); |
|
|
|
parent.exit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -560,7 +549,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends |
|
|
|
return StringUtils.isEmpty(name); |
|
|
|
return StringUtils.isEmpty(name); |
|
|
|
} |
|
|
|
} |
|
|
|
private boolean isThemeNameDuplicated(String name) { |
|
|
|
private boolean isThemeNameDuplicated(String name) { |
|
|
|
return config.find(name) != null; |
|
|
|
return config.cachedFetch(name) != null; |
|
|
|
} |
|
|
|
} |
|
|
|
private boolean checkThemeCanBeSavedAndUpdateUI(boolean checkDuplicated, UITextField textField, UILabel errorLabel, UIButton... actionButtons) { |
|
|
|
private boolean checkThemeCanBeSavedAndUpdateUI(boolean checkDuplicated, UITextField textField, UILabel errorLabel, UIButton... actionButtons) { |
|
|
|
String error = StringUtils.EMPTY; |
|
|
|
String error = StringUtils.EMPTY; |
|
|
|