diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java index cc3811f9f6..d9e7e0839d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.predefined.ui; import com.fr.config.predefined.PredefinedStyle; import com.fr.config.predefined.PredefinedStyleConfig; import com.fr.config.ServerPreferenceConfig; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.UITabbedPane; @@ -16,9 +17,11 @@ import com.fr.design.mainframe.predefined.ui.detail.ComponentStyleSettingPane; import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane; import com.fr.design.utils.DesignUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; @@ -200,22 +203,35 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane { return predefinedStyle; } - public void saveStyle() { + public boolean saveStyle() { PredefinedStyle previewObject = null; try { previewObject = update(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - saveStyle(previewObject); + if (this.styleNameField.isEnabled() && !validateRepeat(previewObject.getStyleName())) { + return false; + } + if (!saveStyle(previewObject)) { + return false; + } DesignUtils.refreshDesignerFrame(); + return true; } - public void saveStyle(PredefinedStyle previewObject) { + public boolean saveStyle(PredefinedStyle previewObject) { PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + if (StringUtils.isEmpty(previewObject.getStyleName())) { + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(PredefinedStyleEditPane.this), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Name_Cannot_Empty")); + + return false; + } config.put(previewObject.getStyleName(), previewObject); ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); selectPane.refreshPane(); + return true; } public void saveAsNewStyle(String styleName) { @@ -226,8 +242,20 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane { FineLoggerFactory.getLogger().error(e.getMessage(), e); } previewObject.setStyleName(styleName); - saveStyle(previewObject); + if (validateRepeat(styleName)){ + saveStyle(previewObject); + } } + private boolean validateRepeat(String styleName){ + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + if (config.getStyle(styleName) != null) { + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(PredefinedStyleEditPane.this), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Name_Repeat")); + + return false; + } + return true; + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java index 9cff0482f6..5b405b814d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java @@ -240,6 +240,7 @@ public class CellStyleSettingPane extends BasicBeanPane