|
|
|
@ -7,6 +7,7 @@ import com.fr.base.theme.settings.ThemeThumbnail;
|
|
|
|
|
import com.fr.base.theme.settings.ThemedCellStyleList; |
|
|
|
|
import com.fr.base.theme.settings.ThemedChartStyle; |
|
|
|
|
import com.fr.base.theme.settings.ThemedColorScheme; |
|
|
|
|
import com.fr.design.designer.IntervalConstants; |
|
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
|
|
|
|
import com.fr.design.gui.frpane.AttributeChangeListener; |
|
|
|
@ -26,6 +27,7 @@ import com.fr.design.mainframe.theme.edit.ui.ColorListPane;
|
|
|
|
|
import com.fr.design.mainframe.theme.edit.ui.LabelUtils; |
|
|
|
|
import com.fr.design.mainframe.theme.ui.BorderUtils; |
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.transaction.CallBackAdaptor; |
|
|
|
@ -44,6 +46,7 @@ import javax.swing.event.DocumentEvent;
|
|
|
|
|
import javax.swing.event.DocumentListener; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.Image; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
@ -63,12 +66,12 @@ import static com.fr.design.i18n.Toolkit.i18nText;
|
|
|
|
|
*/ |
|
|
|
|
public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends AbstractAttrNoScrollPane { |
|
|
|
|
public static final int TITLE_BORDER_FONT = 12; |
|
|
|
|
public static final int LEFT_TITLE_PANE_WIDTH = 397; |
|
|
|
|
public static final int LEFT_TITLE_PANE_HEIGHT = 532 + TITLE_BORDER_FONT / 2 + 10; |
|
|
|
|
public static final int LEFT_TITLE_PANE_WIDTH = 627; |
|
|
|
|
public static final int LEFT_TITLE_PANE_HEIGHT = 539; |
|
|
|
|
public static final int PREVIEW_PANE_WIDTH = LEFT_TITLE_PANE_WIDTH - 10; |
|
|
|
|
public static final int PREVIEW_PANE_HEIGHT = LEFT_TITLE_PANE_HEIGHT - TITLE_BORDER_FONT - 16; |
|
|
|
|
|
|
|
|
|
public static final int RIGHT_PANE_WIDTH = 362; |
|
|
|
|
public static final int RIGHT_PANE_WIDTH = 352; |
|
|
|
|
public static final int RIGHT_PANE_HEIGHT = LEFT_TITLE_PANE_HEIGHT; |
|
|
|
|
public static final int COLOR_SCHEME_TITLE_PANE_WIDTH = 298; |
|
|
|
|
public static final int COLOR_SCHEME_TITLE_PANE_HEIGHT = 174 + TITLE_BORDER_FONT / 2; |
|
|
|
@ -90,6 +93,8 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
private UIButton saveButton = new UIButton(); |
|
|
|
|
private UIButton saveAsButton = new UIButton(); |
|
|
|
|
|
|
|
|
|
private boolean refreshingThemedColor = false; |
|
|
|
|
|
|
|
|
|
private boolean currentIsNewTheme; |
|
|
|
|
private T theme; |
|
|
|
|
|
|
|
|
@ -142,19 +147,17 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
|
|
|
|
|
themePreviewPane = createThemePreviewPane(); |
|
|
|
|
themePreviewPane.setPreferredSize(new Dimension(PREVIEW_PANE_WIDTH, PREVIEW_PANE_HEIGHT)); |
|
|
|
|
themePreviewPane.setPreferredSize(new Dimension(PREVIEW_PANE_WIDTH, PREVIEW_PANE_HEIGHT)); |
|
|
|
|
|
|
|
|
|
previewContainer.add(themePreviewPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
return titleContainer; |
|
|
|
|
} |
|
|
|
|
private JPanel createRightPane() { |
|
|
|
|
JPanel container = new JPanel(new BorderLayout(0, 12)); |
|
|
|
|
JPanel container = new JPanel(new BorderLayout(0, 0)); |
|
|
|
|
container.setPreferredSize(new Dimension(RIGHT_PANE_WIDTH, RIGHT_PANE_HEIGHT)); |
|
|
|
|
JPanel nameEditPane = createNameEditPane(); |
|
|
|
|
container.add(nameEditPane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
JPanel settingPane = new JPanel(new BorderLayout(0, 10)); |
|
|
|
|
JPanel settingPane = new JPanel(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); |
|
|
|
|
container.add(settingPane, BorderLayout.CENTER); |
|
|
|
|
settingPane.add(createColorSchemeEditPane(), BorderLayout.NORTH); |
|
|
|
|
settingPane.add(createCustomEditorsPane(), BorderLayout.CENTER); |
|
|
|
@ -170,13 +173,6 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel createNameEditPane() { |
|
|
|
|
JPanel container = new JPanel(new BorderLayout(30, 0)); |
|
|
|
|
container.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
|
|
|
|
container.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Name")), BorderLayout.WEST); |
|
|
|
|
|
|
|
|
|
JPanel settingContainer = new JPanel(new BorderLayout(10, 0)); |
|
|
|
|
container.add(settingContainer, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
nameErrorLabel = LabelUtils.createLabel(StringUtils.EMPTY, Color.RED); |
|
|
|
|
nameErrorLabel.setVisible(false); |
|
|
|
|
|
|
|
|
@ -187,14 +183,14 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
@Override |
|
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
|
|
if (isEnabled()) { |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, false, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void removeUpdate(DocumentEvent e) { |
|
|
|
|
if (isEnabled()) { |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, false, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -207,22 +203,26 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
@Override |
|
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
|
if (isEnabled()) { |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, false, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
|
if (isEnabled()) { |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, true, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
settingContainer.add(nameTextField, BorderLayout.WEST); |
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
|
|
|
|
|
settingContainer.add(nameErrorLabel, BorderLayout.CENTER); |
|
|
|
|
JPanel container = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
|
|
|
|
new Component[] { LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Name")), nameTextField }, |
|
|
|
|
new Component[] { null, nameErrorLabel }, |
|
|
|
|
}, new double[] { 20, 20}, new double[] { p, 165}, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_W0); |
|
|
|
|
|
|
|
|
|
container.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
|
|
|
|
return container; |
|
|
|
|
} |
|
|
|
|
private JPanel createColorSchemeEditPane() { |
|
|
|
@ -265,8 +265,13 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
colorListPane.addColorChangeListener(new ChangeListener() { |
|
|
|
|
@Override |
|
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
|
if (refreshingThemedColor) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
List<Color> colors = colorListPane.update(); |
|
|
|
|
refreshingThemedColor = true; |
|
|
|
|
onColorSchemeChanged(colors); |
|
|
|
|
refreshingThemedColor = false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -283,7 +288,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
return container; |
|
|
|
|
} |
|
|
|
|
public void addCustomEditorPane(String title, JComponent component) { |
|
|
|
|
component.setPreferredSize(new Dimension(360, 260)); |
|
|
|
|
component.setPreferredSize(new Dimension(317, 239)); |
|
|
|
|
uiTabbedPane.addTab(title, component); |
|
|
|
|
} |
|
|
|
|
protected JPanel createCellStyleSettingPane() { |
|
|
|
@ -310,12 +315,12 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
public void onColorSchemeChanged(List<Color> colors) { |
|
|
|
|
colorListExtendedPane.populate(colors); |
|
|
|
|
FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors); |
|
|
|
|
ThemedCellStyleList cellStyle = cellStyleSettingPane.updateBean(); |
|
|
|
|
FineColorManager.traverse(cellStyle, replaceByColorScheme); |
|
|
|
|
T theme = updateBean(); |
|
|
|
|
|
|
|
|
|
ThemedChartStyle themedChartStyle = chartStyleSettingPane.updateBean(); |
|
|
|
|
FineColorManager.traverse(themedChartStyle, replaceByColorScheme); |
|
|
|
|
chartStyleSettingPane.populateBean(themedChartStyle); |
|
|
|
|
FineColorManager.traverse(theme, replaceByColorScheme); |
|
|
|
|
populateBean(theme); |
|
|
|
|
|
|
|
|
|
//图表渐变色
|
|
|
|
|
chartStyleSettingPane.populateGradientBar(colors); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -389,7 +394,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
T theme = updateBean(); |
|
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, true, currentIsNewTheme, true, nameTextField, nameErrorLabel, saveButton); |
|
|
|
|
if (canBeSaved && theme != null) { |
|
|
|
|
theme.setName(nameTextField.getText()); |
|
|
|
|
config.addTheme(theme, true, new CallBackAdaptor() { |
|
|
|
@ -474,14 +479,14 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
@Override |
|
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
|
|
if (isEnabled()) { |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(true, false, true, true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void removeUpdate(DocumentEvent e) { |
|
|
|
|
if (isEnabled()) { |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(true, false, true, true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -494,14 +499,14 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
@Override |
|
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
|
if (isEnabled()) { |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(true, false, true, true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
|
if (isEnabled()) { |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
checkThemeCanBeSavedAndUpdateUI(true, true, true, true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -547,7 +552,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, true, true, true, nameTextField, nameErrorLabel, confirmButton); |
|
|
|
|
if (canBeSaved && newThemeObject != null) { |
|
|
|
|
newThemeObject.setName(name); |
|
|
|
|
newThemeObject.setRemovable(true); |
|
|
|
@ -583,17 +588,28 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
private boolean isThemeNameDuplicated(String name) { |
|
|
|
|
return config.cachedFetch(name) != null; |
|
|
|
|
} |
|
|
|
|
private boolean checkThemeCanBeSavedAndUpdateUI(boolean checkDuplicated, UITextField textField, UILabel errorLabel, UIButton... actionButtons) { |
|
|
|
|
String error = StringUtils.EMPTY; |
|
|
|
|
private boolean checkThemeCanBeSavedAndUpdateUI( |
|
|
|
|
boolean checkEmpty, |
|
|
|
|
boolean displayEmptyTip, |
|
|
|
|
boolean checkDuplicated, |
|
|
|
|
boolean displayDuplicatedTip, |
|
|
|
|
UITextField textField, |
|
|
|
|
UILabel errorLabel, UIButton... actionButtons) { |
|
|
|
|
String name = textField.getText(); |
|
|
|
|
if (isThemeNameEmpty(name)) { |
|
|
|
|
error = Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Empty_Name_Error_Tip"); |
|
|
|
|
|
|
|
|
|
boolean valid = true; |
|
|
|
|
errorLabel.setText(StringUtils.EMPTY); |
|
|
|
|
if (checkEmpty && isThemeNameEmpty(name)) { |
|
|
|
|
valid = false; |
|
|
|
|
if (displayEmptyTip) { |
|
|
|
|
errorLabel.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Empty_Name_Error_Tip")); |
|
|
|
|
} |
|
|
|
|
} else if (checkDuplicated && isThemeNameDuplicated(name)) { |
|
|
|
|
error = Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Duplicated_Name_Error_Tip"); |
|
|
|
|
valid = false; |
|
|
|
|
if (displayDuplicatedTip) { |
|
|
|
|
errorLabel.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Duplicated_Name_Error_Tip")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
errorLabel.setText(error); |
|
|
|
|
|
|
|
|
|
boolean valid = StringUtils.isEmpty(error); |
|
|
|
|
|
|
|
|
|
errorLabel.setVisible(!valid); |
|
|
|
|
if (actionButtons != null && actionButtons.length > 0) { |
|
|
|
|