|
|
|
@ -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; |
|
|
|
@ -151,12 +154,12 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
|
|
|
|
|
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); |
|
|
|
@ -172,13 +175,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); |
|
|
|
|
|
|
|
|
@ -189,14 +185,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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -209,22 +205,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() { |
|
|
|
@ -393,7 +393,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() { |
|
|
|
@ -478,14 +478,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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -498,14 +498,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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -551,7 +551,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); |
|
|
|
@ -587,17 +587,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) { |
|
|
|
|