diff --git a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java index b559c22e6e..48c18eb699 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java @@ -218,6 +218,10 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane { + if (e.getStateChange() == ItemEvent.SELECTED) { + final int row = table.getSelectedRow(); + if (row == -1) { + return; + } + SingleJavaScript js = getList().get(row); + Object ob = fileNameComboBox.getSelectedItem(); + if (ob != null) { + String value = ob.toString(); + js.setDefaultFileName(StringUtils.equals(value, DEFAULT)); + if (js.isDefaultFileName()) { + js.setFileName(StringUtils.EMPTY); + } + } + table.repaint(); + } + }); this.addCellEditorListener(new CellEditorListener() { @Override @@ -458,15 +482,6 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane(Arrays.asList(providers))); } return paraButton; } @@ -758,6 +777,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane extends if (saveAsButton != null) { saveAsButton.setEnabled(StringUtils.isNotEmpty(name)); } + actionListener.onInitialize(theme); isPopulating = false; } @@ -218,6 +219,7 @@ public abstract class TemplateThemeProfilePane extends super.afterCommit(); saveButton.setEnabled(false); saveAsButton.setEnabled(true); + actionListener.onSaved(config.cachedFetch(getName())); DesignerToastMsgUtil.toastPrompt(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save_Successfully")); } }); @@ -342,11 +344,21 @@ public abstract class TemplateThemeProfilePane extends } public interface TemplateThemeProfileActionListener { + void onInitialize(TemplateTheme theme); + void onThemeNameChecked(String name, boolean valid); + + void onSaved(TemplateTheme theme); } public static class TemplateThemeProfileActionAdapter implements TemplateThemeProfileActionListener { + @Override + public void onInitialize(TemplateTheme theme) {} + @Override public void onThemeNameChecked(String name, boolean valid) { } + + @Override + public void onSaved(TemplateTheme theme) {} } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java index 6262c34a33..883a306446 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java @@ -23,7 +23,7 @@ public class LoadingMenuItem extends UIMenuItem { super(action); setOpaque(true); setBackground(ColorConstants.BACKGROUND); - setUI(new SharedComponentActionMenuItemUI(false)); + setUI(new SharedComponentActionMenuItemUI()); } public void startLoading() { @@ -40,6 +40,10 @@ public class LoadingMenuItem extends UIMenuItem { repaint(); } + public boolean isLoading() { + return loading; + } + @Override protected void paintBorder(Graphics g) { super.paintBorder(g); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java index 8a3fe5e1c9..a400ccf37b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java @@ -2,6 +2,8 @@ package com.fr.design.mainframe.share.ui.actions; import com.fr.design.constants.UIConstants; import com.fr.design.gui.imenu.UIMenuItemUI; +import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.mainframe.share.ui.constants.ColorConstants; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; @@ -10,6 +12,8 @@ import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.MenuSelectionManager; import java.awt.Color; +import java.awt.Component; +import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; @@ -20,16 +24,6 @@ import java.awt.Graphics2D; */ public class SharedComponentActionMenuItemUI extends UIMenuItemUI { - private final boolean autoClosePopup; - - public SharedComponentActionMenuItemUI(boolean autoClosePopup) { - this.autoClosePopup = autoClosePopup; - } - - public SharedComponentActionMenuItemUI() { - this(true); - } - @Override protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { ButtonModel model = menuItem.getModel(); @@ -37,19 +31,45 @@ public class SharedComponentActionMenuItemUI extends UIMenuItemUI { int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); - if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { - GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 0); + g.setColor(ColorConstants.BACKGROUND); + g.fillRect(0, 0, menuWidth, menuHeight); + if (menuItem.isOpaque()) { + if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + } else { + GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); + } + g.setColor(oldColor); + } else if (model.isArmed() || (menuItem instanceof JMenu && + model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + g.setColor(oldColor); } - - g.setColor(oldColor); } @Override protected void doClick(MenuSelectionManager msm) { - if (autoClosePopup) { - super.doClick(msm); - } else { + if (hasLoadingMenuItem()) { + return; + } + + if (menuItem instanceof LoadingMenuItem) { menuItem.doClick(0); + } else { + super.doClick(msm); + } + } + + private boolean hasLoadingMenuItem() { + Container parent = menuItem.getParent(); + if (parent instanceof UIPopupMenu) { + Component[] components = parent.getComponents(); + for (Component component: components) { + if (component instanceof LoadingMenuItem && ((LoadingMenuItem) component).isLoading()) { + return true; + } + } } + return false; } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java index 286890303e..c048edbd0a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java @@ -58,36 +58,31 @@ class FormApp extends AbstractAppProvider { * @return */ private JTemplate compatibleForm(FILE tplFile, HashMap classType) { - if (ComparatorUtils.equals(StableFactory.getRegisteredClass(BaseJForm.XML_TAG), JForm.class)) { - classType.put(Constants.ARG_2, Parameter[].class); - JForm emptyForm = new JForm(new Form(new WBorderLayout("form")), tplFile); - OpenWorker> worker = new OpenWorker<>( - new Callable>() { - @Override - public OpenResult call() throws Exception { - Form form = getForm(tplFile); - return new OpenResult<>(form, form.getParameters()); - } - }, emptyForm); - worker.addCallBack(new Callable>() { - @Override - public JTemplate call() throws Exception { - OpenResult result = worker.getResult(); - return (JTemplate) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, - new Object[]{result.getBaseBook(), tplFile, result.getRef()}, classType, BaseJForm.class); - } - }); - worker.start(tplFile.getPath()); - OpenResult result = worker.getResult(); - if (result != null) { + classType.put(Constants.ARG_2, Parameter[].class); + JForm emptyForm = new JForm(new Form(new WBorderLayout("form")), tplFile); + OpenWorker> worker = new OpenWorker<>( + new Callable>() { + @Override + public OpenResult call() throws Exception { + Form form = getForm(tplFile); + return new OpenResult<>(form, form.getParameters()); + } + }, emptyForm); + worker.addCallBack(new Callable>() { + @Override + public JTemplate call() throws Exception { + OpenResult result = worker.getResult(); return (JTemplate) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, - new Object[]{result.getBaseBook(), tplFile, new Parameter[0]}, classType, BaseJForm.class); + new Object[]{result.getBaseBook(), tplFile, result.getRef()}, classType, BaseJForm.class); } - return emptyForm; - } else { + }); + worker.start(tplFile.getPath()); + OpenResult result = worker.getResult(); + if (result != null) { return (JTemplate) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, - new Object[]{getForm(tplFile), tplFile}, classType, BaseJForm.class); + new Object[]{result.getBaseBook(), tplFile, new Parameter[0]}, classType, BaseJForm.class); } + return emptyForm; } @Nullable