Browse Source

代码修改

research/11.0
kerry 4 years ago
parent
commit
916deab7f9
  1. 36
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java
  2. 7
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java
  3. 5
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java

36
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;
}
}

7
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java

@ -240,6 +240,7 @@ public class CellStyleSettingPane extends BasicBeanPane<PredefinedCellStyleConfi
}
reset();
}
private void reset() {
@ -248,6 +249,12 @@ public class CellStyleSettingPane extends BasicBeanPane<PredefinedCellStyleConfi
removeBtn.setEnabled(false);
cardLayout.show(centerPane, styleList.getNameAt(0));
centerPane.validate();
Object nameable = styleList.getType(0);
if (nameable == null) {
return;
}
PredefinedCellStyle cellStyle = ((PredefinedCellStyle) nameable);
previewPane.refresh(cellStyle.getStyle());
}
}

5
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java

@ -48,8 +48,9 @@ public class PredefinedStyleEditDialog extends JDialog {
saveBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
contentPane.saveStyle();
dialogExit();
if(contentPane.saveStyle()){
dialogExit();
}
}
});
UIButton saveAsBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Save_As_New"));

Loading…
Cancel
Save