diff --git a/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java b/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java index 52ce8dd50b..8f8d4ae139 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java @@ -68,9 +68,21 @@ public final class WebPreviewUtils { * * 如果保存失败,不执行下面的WebPreview */ - if (!jt.isSaved() && !jt.saveTemplate2Env()) { + if (!jt.isSaved()) { + CallbackSaveWorker worker = jt.save2Env(); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + browserTemplate(jt, baseRoute, map, actionType); + } + }); + worker.start(jt.getTarget().getTemplateID()); return; } + browserTemplate(jt, baseRoute, map, actionType); + } + + private static void browserTemplate(JTemplate jt, String baseRoute, Map map, String actionType) { FILE currentTemplate = jt.getEditingFILE(); // carl:是否是保存在运行环境下的模板,不是就不能被预览 if (currentTemplate instanceof FileNodeFILE) { @@ -106,11 +118,14 @@ public final class WebPreviewUtils { WARNING_MESSAGE); if (OK_OPTION == selVal) { - if (!jt.saveAsTemplate2Env()) { - return; - } - currentTemplate = jt.getEditingFILE(); - browseUrl(currentTemplate, baseRoute, map, actionType, jt); + CallbackSaveWorker worker = jt.saveAs2Env(); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + browseUrl(jt.getEditingFILE(), baseRoute, map, actionType, jt); + } + }); + worker.start(jt.getTarget().getTemplateID()); } } } diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java index f447749113..d7173d5f47 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java @@ -1,6 +1,8 @@ package com.fr.design.gui.ibutton; import com.fr.base.CellBorderStyle; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; import javax.swing.Action; import javax.swing.Icon; import javax.swing.plaf.ButtonUI; @@ -45,6 +47,16 @@ public class UIForbiddenButton extends UIButton { return super.getBorderStyle(); } + @Override + public boolean isEnabled() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + boolean enabled = true; + if (template != null) { + enabled = super.isEnabled() && template.checkEnable(); + } + return enabled; + } + @Override public ButtonUI getUI() { return new UIForbiddenButtonUI(); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java index df3b6a86e0..d8f51f62bc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java @@ -1,7 +1,5 @@ package com.fr.design.gui.ibutton; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.mainframe.JTemplate; import java.awt.Graphics; import javax.swing.JComponent; @@ -15,11 +13,6 @@ public class UIForbiddenButtonUI extends UIButtonUI { @Override public void paint(Graphics g, JComponent c) { super.paint(g, c); - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - boolean flag = true; - if (template != null) { - flag = c.isEnabled() && template.checkEnable(); - } - c.setEnabled(flag); + c.setEnabled(c.isEnabled()); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index d32d14cf23..f940f89045 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -76,6 +76,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener private void showOpenStatus() { DesignerContext.getDesignerFrame().refreshUIToolBar(); + DesignerFrameFileDealerPane.getInstance().stateChange(); EastRegionContainerPane.getInstance().updateAllPropertyPane(); layeredPane.moveToFront(loadingPane); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index dd2a05a2a4..b374dbbf97 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1559,6 +1559,16 @@ public abstract class JTemplate> worker.start(this.template.getTemplateID()); } + @Override + public CallbackSaveWorker save2Env() { + return save(false); + } + + @Override + public CallbackSaveWorker saveAs2Env() { + return saveAs(false); + } + public boolean isSaving() { return saving; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java index 2b96a471b5..005dadac2a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java @@ -12,7 +12,7 @@ import com.fr.design.worker.save.CallbackSaveWorker; public interface JTemplateSave { /** - * 直接保存后需要根据是否成功做外部回调 + * 保存后需要根据是否成功做外部回调,可选保存位置 * * @return */ @@ -20,12 +20,29 @@ public interface JTemplateSave { /** - * 另存为后需要根据是否成功做外部回调 + * 另存为后需要根据是否成功做外部回调,可选保存位置 * * @return */ CallbackSaveWorker saveAs(); + + /** + * 保存到当前工作目录(reportlets)后需要根据是否成功做外部回调 + * + * + * @return + */ + CallbackSaveWorker save2Env(); + + + /** + * 另存为到当前工作目录(reportlets)后需要根据是否成功做外部回调 + * + * @return + */ + CallbackSaveWorker saveAs2Env(); + /**D * 直接保存 */ diff --git a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java index 97f13a0e30..f166020513 100644 --- a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java @@ -2,6 +2,7 @@ package com.fr.design.worker.open; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.worker.WorkerManager; @@ -69,21 +70,22 @@ public class OpenWorker extends SwingWorker { DesignerContext.getDesignerFrame().addAndActivateJTemplate(book); HistoryTemplateListCache.getInstance().replaceCurrentEditingTemplate(book); EastRegionContainerPane.getInstance().updateAllPropertyPane(); - return; - } - // 当前tab页是其他模板 - for (int i = 0, len = HistoryTemplateListCache.getInstance().getHistoryCount(); i < len; i++) { - JTemplate template = HistoryTemplateListCache.getInstance().get(i); - if (ComparatorUtils.equals(template.getEditingFILE(), book.getEditingFILE())) { - template.whenClose(); - HistoryTemplateListCache.getInstance().getHistoryList().set(i, book); - return; + } else { + // 当前tab页是其他模板 + for (int i = 0, len = HistoryTemplateListCache.getInstance().getHistoryCount(); i < len; i++) { + JTemplate template = HistoryTemplateListCache.getInstance().get(i); + if (ComparatorUtils.equals(template.getEditingFILE(), book.getEditingFILE())) { + template.whenClose(); + HistoryTemplateListCache.getInstance().getHistoryList().set(i, book); + break; + } } } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + DesignerFrameFileDealerPane.getInstance().stateChange(); WorkerManager.getInstance().removeWorker(taskName); } diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java index d9f511cc70..2ce5089705 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java @@ -35,6 +35,8 @@ public class SaveWorker extends SwingWorker { protected boolean success; + private boolean slowly; + public SaveWorker(Callable callable, JTemplate template) { this.callable = callable; this.template = template; @@ -59,7 +61,7 @@ public class SaveWorker extends SwingWorker { } this.template.setSaving(false); // 恢复界面 - if (ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) { + if (slowly && ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) { EastRegionContainerPane.getInstance().updateAllPropertyPane(); DesignerContext.getDesignerFrame().refreshUIToolBar(); DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover(); @@ -77,6 +79,7 @@ public class SaveWorker extends SwingWorker { try { this.get(TIME_OUT, TimeUnit.MILLISECONDS); } catch (TimeoutException timeoutException) { + slowly = true; // 开始禁用 EastRegionContainerPane.getInstance().updateAllPropertyPane(); DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java b/designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java index b336a3ac02..4c18ba4750 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.vcs.DesignerMode; import com.fr.design.designer.creator.XCreator; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.core.WidgetOption; @@ -174,4 +175,14 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio public ButtonUI getUI() { return new UIForbiddenButtonUI(); } + + @Override + public boolean isEnabled() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + boolean enable = true; + if (template != null) { + enable = super.isEnabled() && template.checkEnable(); + } + return enable; + } } 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 f9e19dd64b..6f83a35ddf 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 @@ -83,7 +83,7 @@ class FormApp extends AbstractAppProvider { // peter:打开新报表. Form tpl = new Form(); // richer:打开报表通知 - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("file.getName()", file.getName()) + "..."); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", file.getName()) + "..."); try { tpl.readStream(file.asInputStream()); } catch (DecryptTemplateException e) {