From 15c3770f546e4d302afa2a8fceffce23ee5244cd Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Apr 2021 09:33:39 +0800 Subject: [PATCH 1/8] =?UTF-8?q?REPORT-49986=20=E3=80=9010.0.16=E3=80=91?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96=E4=B9=8B=E9=98=BB=E5=A1=9E?= =?UTF-8?q?EDT=E7=BA=BF=E7=A8=8B=E6=97=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignModelAdapter.java | 16 ++ .../design/actions/ForbiddenUpdateAction.java | 26 ++ .../fr/design/actions/edit/RedoAction.java | 3 +- .../fr/design/actions/edit/UndoAction.java | 5 +- .../actions/file/SaveAsTemplateAction.java | 8 +- .../actions/file/SaveTemplateAction.java | 5 +- .../design/actions/file/WebPreviewUtils.java | 20 +- .../design/data/BasicTableDataTreePane.java | 3 +- .../data/datapane/TableDataTreePane.java | 5 +- .../design/env/DesignerWorkspaceLoader.java | 21 ++ .../com/fr/design/env/RemoteWorkspace.java | 44 +++- .../env/WorkspaceChangeLoadingDialog.java | 47 ++++ .../design/file/HistoryTemplateListCache.java | 31 +++ .../fr/design/file/MutilTempalteTabPane.java | 29 ++- .../fr/design/file/SaveSomeTemplatePane.java | 2 +- .../design/gui/ibutton/UIForbiddenButton.java | 52 ++++ .../gui/ibutton/UIForbiddenButtonUI.java | 25 ++ .../gui/ibutton/UISaveForbiddenButton.java | 44 ++++ .../gui/ibutton/UISaveForbiddenButtonUI.java | 25 ++ .../design/gui/imenu/UIForBiddenHeadMenu.java | 18 ++ .../design/gui/imenu/UIForbiddenMenuUI.java | 25 ++ .../com/fr/design/gui/itoolbar/UIToolbar.java | 17 +- .../fr/design/mainframe/DesignerFrame.java | 45 +--- .../DesignerFrameFileDealerPane.java | 27 +- .../fr/design/mainframe/DesktopCardPane.java | 46 +++- .../mainframe/EastRegionContainerPane.java | 10 +- .../com/fr/design/mainframe/JTemplate.java | 245 +++++++++++++++--- .../fr/design/mainframe/JTemplateSave.java | 40 +++ .../fr/design/mainframe/OpenLoadingPane.java | 60 +++++ .../fr/design/mainframe/TransparentPane.java | 102 ++++++++ .../main/java/com/fr/design/menu/MenuDef.java | 37 ++- .../com/fr/design/worker/WorkerManager.java | 49 ++++ .../com/fr/design/worker/open/OpenResult.java | 28 ++ .../com/fr/design/worker/open/OpenWorker.java | 115 ++++++++ .../worker/save/CallbackSaveWorker.java | 75 ++++++ .../worker/save/EmptyCallBackSaveWorker.java | 37 +++ .../com/fr/design/worker/save/SaveWorker.java | 82 ++++++ .../java/com/fr/file/FILEChooserPane.java | 5 +- .../fr/design/mainframe/FormModelAdapter.java | 4 + .../java/com/fr/design/mainframe/JForm.java | 8 + .../fr/design/mainframe/ToolBarButton.java | 12 +- .../fr/design/mainframe/ElementCasePane.java | 3 + .../com/fr/design/mainframe/JWorkBook.java | 9 + .../mainframe/WorkBookModelAdapter.java | 3 + .../mainframe/app/AbstractWorkBookApp.java | 29 ++- .../com/fr/design/mainframe/app/CptApp.java | 8 +- .../com/fr/design/mainframe/app/FormApp.java | 34 ++- .../main/java/com/fr/start/MainDesigner.java | 7 +- .../fr/start/module/DesignerActivator.java | 2 + .../module/DesignerWorkspaceActivator.java | 3 + 50 files changed, 1462 insertions(+), 134 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/actions/ForbiddenUpdateAction.java create mode 100644 designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceLoader.java create mode 100644 designer-base/src/main/java/com/fr/design/env/WorkspaceChangeLoadingDialog.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/TransparentPane.java create mode 100644 designer-base/src/main/java/com/fr/design/worker/WorkerManager.java create mode 100644 designer-base/src/main/java/com/fr/design/worker/open/OpenResult.java create mode 100644 designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java create mode 100644 designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java create mode 100644 designer-base/src/main/java/com/fr/design/worker/save/EmptyCallBackSaveWorker.java create mode 100644 designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java diff --git a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java index 7a237ffb59..f48efa15ba 100644 --- a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java @@ -75,6 +75,12 @@ public abstract class DesignModelAdapter model) { currentModelAdapter = model; } @@ -244,6 +250,16 @@ public abstract class DesignModelAdapter undoComponent = getEditingComponent(); if (DesignerEnvManager.getEnvManager().isSupportUndo()) { - this.setEnabled(undoComponent != null && undoComponent.canRedo()); + boolean enable = undoComponent != null && undoComponent.canRedo() && !undoComponent.isOpening() && !undoComponent.isSaving(); + this.setEnabled(enable); } else { this.setEnabled(false); } diff --git a/designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java b/designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java index ff337620c9..53e5ed7c5a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java @@ -28,7 +28,7 @@ public class UndoAction extends UpdateAction implements TemplateComponentActionI @Override public JTemplate getEditingComponent() { - return t; + return t; } /** @@ -49,7 +49,8 @@ public class UndoAction extends UpdateAction implements TemplateComponentActionI public void update() { JTemplate undoComponent = getEditingComponent(); if (DesignerEnvManager.getEnvManager().isSupportUndo()) { - this.setEnabled(undoComponent != null && undoComponent.canUndo()); + boolean enable = undoComponent != null && undoComponent.canUndo() && !undoComponent.isOpening() && !undoComponent.isSaving(); + this.setEnabled(enable); } else { this.setEnabled(false); } diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java index a60b397628..07b8a8024b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java @@ -31,7 +31,7 @@ public class SaveAsTemplateAction extends JTemplateAction> { JTemplate jt = this.getEditingComponent(); // kunsnat: 保存前停止编辑状态,保存属性. jt.stopEditing(); - jt.saveAsTemplate(); + jt.saveAsDirectly(); this.setEnabled(true); jt.requestFocus(); @@ -40,9 +40,7 @@ public class SaveAsTemplateAction extends JTemplateAction> { @Override public void update() { super.update(); - -// this.setEnabled(!this.getEditingComponent().isSaved()); -// 另存为按钮应该一直可用使用 - this.setEnabled(true); + boolean enable = !this.getEditingComponent().isSaving() && !this.getEditingComponent().isOpening(); + this.setEnabled(enable); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java index 920f5b41ae..dfc2071b11 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java @@ -31,14 +31,15 @@ public class SaveTemplateAction extends JTemplateAction> { public void actionPerformed(ActionEvent e) { JTemplate jt = this.getEditingComponent(); jt.stopEditing(); - jt.saveTemplate(); + jt.saveDirectly(); jt.requestFocus(); } @Override public void update() { super.update(); - this.setEnabled(!this.getEditingComponent().isSaved()); + boolean enable = !this.getEditingComponent().isSaved() && !this.getEditingComponent().isSaving() && !this.getEditingComponent().isOpening(); + this.setEnabled(enable); } } 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 9f87943e10..52ce8dd50b 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 @@ -6,6 +6,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.DesignUtils; +import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.general.GeneralUtils; @@ -83,15 +84,18 @@ public final class WebPreviewUtils { WARNING_MESSAGE ); if (OK_OPTION == selVal) { - if (!jt.saveAsTemplate()) { - return; - } - } else { - return; + CallbackSaveWorker worker = jt.saveAs(); + worker.start(jt.getTarget().getTemplateID()); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + browseUrl(jt.getEditingFILE(), baseRoute, map, actionType, jt); + } + }); } - currentTemplate = jt.getEditingFILE(); + return; } - browseUrl(currentTemplate, baseRoute, map, actionType, jt); + browseUrl(jt.getEditingFILE(), baseRoute, map, actionType, jt); } else { // 说明模板没有保存在报表运行环境下面,提示用户 int selVal = showConfirmDialog( @@ -150,7 +154,7 @@ public final class WebPreviewUtils { WARNING_MESSAGE ); if (OK_OPTION == selVal) { - jt.saveAsTemplate(); + jt.saveAsDirectly(); } } } diff --git a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java index 34482d0d20..bfdd11bd46 100644 --- a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java @@ -6,6 +6,7 @@ import com.fr.data.TableDataSource; import com.fr.data.api.StoreProcedureAssist; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.DesignModelAdapter; +import com.fr.design.actions.ForbiddenUpdateAction; import com.fr.design.actions.UpdateAction; import com.fr.design.data.datapane.TableDataCreatorProducer; import com.fr.design.data.datapane.TableDataNameObjectCreator; @@ -398,7 +399,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp return prefix + count; } - protected class PreviewTableDataAction extends UpdateAction { + protected class PreviewTableDataAction extends ForbiddenUpdateAction { private TableDataTree dataTree; public PreviewTableDataAction(TableDataTree dataTree) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index 230bf8a47c..36cd0a4fe6 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -6,6 +6,7 @@ import com.fr.data.TableDataSource; import com.fr.data.impl.TableDataSourceDependent; import com.fr.design.DesignModelAdapter; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.actions.ForbiddenUpdateAction; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.BasicTableDataTreePane; @@ -243,7 +244,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { dg.setVisible(true); } - private class EditAction extends UpdateAction { + private class EditAction extends ForbiddenUpdateAction { public EditAction() { this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); this.setMnemonic('E'); @@ -260,7 +261,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { } } - private class RemoveAction extends UpdateAction { + private class RemoveAction extends ForbiddenUpdateAction { public RemoveAction() { this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove")); diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceLoader.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceLoader.java new file mode 100644 index 0000000000..c910c7db42 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceLoader.java @@ -0,0 +1,21 @@ +package com.fr.design.env; + +import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/11 + */ +public class DesignerWorkspaceLoader { + + public static void init() { + Workspace workspace = WorkContext.getCurrent(); + if (workspace.isLocal()) { + return; + } + workspace.isWarDeploy(); + workspace.isCluster(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index 6d1685e74f..c3c5a34a3e 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -14,6 +14,7 @@ import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.server.authority.decision.DecisionOperator; import com.fr.workspace.engine.rpc.WorkspaceProxyPool; import com.fr.workspace.pool.WorkObjectPool; +import javax.swing.SwingWorker; /** * Created by juhaoyu on 2018/6/14. @@ -29,6 +30,10 @@ public class RemoteWorkspace implements Workspace { private volatile Boolean isRoot = null; + private volatile Boolean cluster; + + private volatile Boolean warDeploy; + RemoteWorkspace(WorkspaceClient client, WorkspaceConnectionInfo connection) { this.client = client; @@ -50,12 +55,15 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isWarDeploy() { - return WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler() { - @Override - public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { - return false; - } - }).isWarDeploy(); + if (warDeploy == null) { + warDeploy = WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler() { + @Override + public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { + return false; + } + }).isWarDeploy(); + } + return warDeploy; } @Override @@ -79,12 +87,15 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isCluster() { - return WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler() { - @Override - public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { - return false; - } - }).isCluster(); + if (cluster == null) { + cluster = WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler() { + @Override + public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { + return false; + } + }).isCluster(); + } + return cluster; } @Override @@ -114,8 +125,13 @@ public class RemoteWorkspace implements Workspace { @Override public void close() { - - client.close(); + new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + client.close(); + return null; + } + }.execute(); } @Override diff --git a/designer-base/src/main/java/com/fr/design/env/WorkspaceChangeLoadingDialog.java b/designer-base/src/main/java/com/fr/design/env/WorkspaceChangeLoadingDialog.java new file mode 100644 index 0000000000..91dc3fcd7b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/env/WorkspaceChangeLoadingDialog.java @@ -0,0 +1,47 @@ +package com.fr.design.env; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.utils.gui.GUICoreUtils; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import javax.swing.ImageIcon; +import javax.swing.JDialog; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/10 + */ +public class WorkspaceChangeLoadingDialog extends JDialog { + + private static final ImageIcon LOADING_ICON = new ImageIcon(WorkspaceChangeLoadingDialog.class.getResource("/com/fr/web/images/loading-local.gif")); + + private static WorkspaceChangeLoadingDialog dialog; + + public WorkspaceChangeLoadingDialog() { + super(DesignerContext.getDesignerFrame()); + setLayout(new BorderLayout()); + this.getContentPane().setBackground(Color.WHITE); + this.setResizable(false); + this.setUndecorated(true); + this.setAlwaysOnTop(true); + this.setModal(false); + this.setSize(new Dimension(400, 100)); + this.add(new UILabel(LOADING_ICON, UILabel.CENTER), BorderLayout.NORTH); + this.add(new UILabel(Toolkit.i18nText("Fine-Design_Change_Workspace_Tip"), UILabel.CENTER), BorderLayout.CENTER); + GUICoreUtils.centerWindow(this); + } + + + public static void showDialog() { + dialog = new WorkspaceChangeLoadingDialog(); + dialog.setVisible(true); + } + + public static void hideDialog() { + dialog.dispose(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 8742a894f2..4487a2bbfc 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Set; +import javax.swing.SwingWorker; /** * 历史模板缓存 @@ -45,6 +46,7 @@ public class HistoryTemplateListCache implements CallbackEvent { private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit(); private List> historyList; private JTemplate editingTemplate; + private SwingWorker stashWorker; public static HistoryTemplateListCache getInstance() { return Holder.INSTANCE; @@ -338,6 +340,17 @@ public class HistoryTemplateListCache implements CallbackEvent { * @see HistoryTemplateListCache#load() */ public void stash() { + stashWorker = new SwingWorker() { + @Override + protected Boolean doInBackground() throws Exception { + _stash(); + return true; + } + }; + stashWorker.execute(); + + } + private void _stash() { FineLoggerFactory.getLogger().info("Env Change Template Stashing..."); if (stashFILEMap == null) { stashFILEMap = new HashMap(); @@ -363,6 +376,14 @@ public class HistoryTemplateListCache implements CallbackEvent { FineLoggerFactory.getLogger().info("Env Change Template Stashed."); } + private boolean checkStash() { + try { + return stashWorker.get(); + } catch (Exception e) { + return false; + } + } + /** * 切换环境前将正在编辑的模板暂存起来后,在新环境重新读取一遍 *

@@ -371,6 +392,9 @@ public class HistoryTemplateListCache implements CallbackEvent { * @see HistoryTemplateListCache#stash() */ public void load() { + if (!checkStash()) { + return; + } FineLoggerFactory.getLogger().info("Env Change Template Loading..."); if (stashFILEMap != null && stashFILEMap.size() != 0) { int size = historyList.size(); @@ -488,4 +512,11 @@ public class HistoryTemplateListCache implements CallbackEvent { return false; } + public void replaceCurrentEditingTemplate(JTemplate jt) { + int index = contains(this.editingTemplate); + this.editingTemplate = jt; + historyList.set(index, jt); + MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); + MutilTempalteTabPane.getInstance().setSelectedIndex(contains(jt)); + } } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 99cd179169..b5f6b2ffda 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -14,6 +14,8 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; +import com.fr.design.worker.WorkerManager; +import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.file.FILE; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -682,9 +684,15 @@ public class MutilTempalteTabPane extends JComponent { int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION) { - specifiedTemplate.saveTemplate(); - FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); - closeTpl(specifiedTemplate); + CallbackSaveWorker worker = specifiedTemplate.save(); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + closeTpl(specifiedTemplate); + } + }); + worker.start(specifiedTemplate.getTarget().getTemplateID()); } else if (returnVal == JOptionPane.NO_OPTION) { closeTpl(specifiedTemplate); } @@ -919,8 +927,19 @@ public class MutilTempalteTabPane extends JComponent { closeIconIndex = getTemplateIndex(evtX); clodeMode = MOUSE_PRESS_CLOSE; //关闭close图标所在的模板{ - closeFormat(openedTemplate.get(closeIconIndex)); - closeSpecifiedTemplate(openedTemplate.get(closeIconIndex)); + JTemplate template = openedTemplate.get(closeIconIndex); + if (template.isOpening()) { + WorkerManager.getInstance().cancelWorker(template.getPath()); + } else if (template.isSaving()) { + boolean completed = WorkerManager.getInstance().isCompleted(template.getTarget().getTemplateID()); + if (!completed) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Close_Template_Tip", template.getEditingFILE().getName())); + return; + } + } + closeFormat(template); + closeSpecifiedTemplate(template); DesignerContext.getDesignerFrame().getContentFrame().repaint(); isShowList = false; } else { diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index e331d296ef..7fef2e379b 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -195,7 +195,7 @@ public class SaveSomeTemplatePane extends BasicPane { specifiedTemplate.stopEditing(); int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { + if (returnVal == JOptionPane.YES_OPTION) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } 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 new file mode 100644 index 0000000000..f447749113 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java @@ -0,0 +1,52 @@ +package com.fr.design.gui.ibutton; + +import com.fr.base.CellBorderStyle; +import javax.swing.Action; +import javax.swing.Icon; +import javax.swing.plaf.ButtonUI; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/9 + */ +public class UIForbiddenButton extends UIButton { + + public UIForbiddenButton() { + super(); + } + + public UIForbiddenButton(String string) { + super(string); + } + + public UIForbiddenButton(Icon icon) { + super(icon); + } + + public UIForbiddenButton(Action action) { + super(action); + } + + public UIForbiddenButton(String text, Icon icon) { + super(text, icon); + } + + public UIForbiddenButton(Icon normal, Icon rollOver, Icon pressed) { + super(normal, rollOver, pressed); + } + + public UIForbiddenButton(String resource, boolean needSetDisabledIcon) { + super(resource, needSetDisabledIcon); + } + + @Override + public CellBorderStyle getBorderStyle() { + return super.getBorderStyle(); + } + + @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 new file mode 100644 index 0000000000..94353deea7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java @@ -0,0 +1,25 @@ +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; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/11 + */ +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.isSaving() && !template.isOpening(); + } + c.setEnabled(flag); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java new file mode 100644 index 0000000000..7e55c1b35e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java @@ -0,0 +1,44 @@ +package com.fr.design.gui.ibutton; + +import javax.swing.Action; +import javax.swing.Icon; +import javax.swing.plaf.ButtonUI; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/10 + */ +public class UISaveForbiddenButton extends UIButton { + public UISaveForbiddenButton() { + } + + public UISaveForbiddenButton(String string) { + super(string); + } + + public UISaveForbiddenButton(Icon icon) { + super(icon); + } + + public UISaveForbiddenButton(Action action) { + super(action); + } + + public UISaveForbiddenButton(String text, Icon icon) { + super(text, icon); + } + + public UISaveForbiddenButton(Icon normal, Icon rollOver, Icon pressed) { + super(normal, rollOver, pressed); + } + + public UISaveForbiddenButton(String resource, boolean needSetDisabledIcon) { + super(resource, needSetDisabledIcon); + } + + @Override + public ButtonUI getUI() { + return new UISaveForbiddenButtonUI(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java new file mode 100644 index 0000000000..7a830c39fd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java @@ -0,0 +1,25 @@ +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; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/14 + */ +public class UISaveForbiddenButtonUI 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 = !template.isSaving(); + } + c.setEnabled(flag); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java new file mode 100644 index 0000000000..14a12b58c5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java @@ -0,0 +1,18 @@ +package com.fr.design.gui.imenu; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/11 + */ +public class UIForBiddenHeadMenu extends UIHeadMenu { + + public UIForBiddenHeadMenu(String name) { + super(name); + } + + @Override + public void updateUI() { + setUI(new UIForbiddenMenuUI()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java new file mode 100644 index 0000000000..7a28513400 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java @@ -0,0 +1,25 @@ +package com.fr.design.gui.imenu; + +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; +import java.awt.Graphics; +import javax.swing.JComponent; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/11 + */ +public class UIForbiddenMenuUI extends UIMenuUI { + + @Override + public void paint(Graphics g, JComponent c) { +// JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); +// boolean flag = true; +// if (template != null) { +// flag = !template.isSaving() && !template.isOpening(); +// } +// c.setEnabled(flag); + super.paint(g, c); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java index d2cca4b482..1740c6d3b4 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java +++ b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java @@ -1,8 +1,11 @@ package com.fr.design.gui.itoolbar; -import javax.swing.*; -import java.awt.*; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; +import java.awt.Component; +import java.awt.FlowLayout; import java.util.ArrayList; +import javax.swing.JToolBar; public class UIToolbar extends JToolBar { @@ -31,4 +34,14 @@ public class UIToolbar extends JToolBar { } } } + + public void refreshUIToolBar() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + for (int i = 0; i < getComponentCount(); i++) { + Component component = getComponents()[i]; + component.setEnabled(!template.isSaving() && !template.isOpening()); + } + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index eec902c4c1..7ebf3ebe05 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -404,7 +404,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta designerOpenedListenerList.clear(); } - protected DesktopCardPane getCenterTemplateCardPane() { + public DesktopCardPane getCenterTemplateCardPane() { return centerTemplateCardPane; } @@ -811,6 +811,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta layeredPane.repaint(); } + public void refreshUIToolBar() { + if (toolbarComponent instanceof UIToolbar) { + ((UIToolbar ) toolbarComponent).refreshUIToolBar(); + } + combineUp.refreshUIToolBar(); + } + public JComponent getToolbarComponent() { return this.toolbarComponent; @@ -940,42 +947,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta return this.centerTemplateCardPane.getSelectedJTemplate(); } - /** - * 保存当前编辑的模板 - */ - - public void saveCurrentEditingTemplate() { - - JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (editingTemplate == null) { - return; - } - if (editingTemplate.isSaved()) {// isSaved == true表示已经保存过,或者新建的一张模板 - if (editingTemplate.getEditingFILE().exists()) {// 表示磁盘上的某一张已经保存过的模板,要添加到历史中 - // HistoryTemplateListPane.getInstance().addHistory(); - } - } else { - editingTemplate.stopEditing(); - if (!editingTemplate.getEditingFILE().exists()) { - int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE() - + "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) { - editingTemplate.saveTemplate(); - FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", - editingTemplate.getEditingFILE().getName())); - } - } else { - if (editingTemplate.saveTemplate()) { - editingTemplate.saveTemplate(); - FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", - editingTemplate.getEditingFILE().getName())); - } - } - } - } - /** * 添加新建模板, 并激活. */ diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index fb8f9a2da2..ad4726d664 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -289,16 +289,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt // 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用 boolean singleSelected = selectedPathNum == 1; + // 打开和保存中 需要禁用相关操作 + boolean enable = isEnable(); newFolderAction.setEnabled(singleSelected); - renameAction.setEnabled(singleSelected); + renameAction.setEnabled(singleSelected && enable); showInExplorerAction.setEnabled(singleSelected); // 删除操作在至少选中一个时可用 boolean selected = selectedPathNum > 0; - delFileAction.setEnabled(selected); + delFileAction.setEnabled(selected && enable); // 刷新操作始终可用 refreshTreeAction.setEnabled(true); //触发vcsAction变化 - vcsAction.fireVcsActionChange(); + vcsAction.fireVcsActionChange(enable); // 其他状态 otherStateChange(); @@ -363,7 +365,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt /** * 版本管理可用状态的监控 */ - private void fireVcsActionChange() { + private void fireVcsActionChange(boolean enable) { if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() || WorkContext.getCurrent().isCluster()) { @@ -381,14 +383,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) { setEnabled(false); } else { - setEnabled(true); + setEnabled(enable); } } else { setEnabled(false); } } else { //当前环境为本地环境时 - setEnabled(pathSupportVcsAction); + setEnabled(pathSupportVcsAction && enable); } } } @@ -915,5 +917,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } + private boolean isEnable() { + List> templates = HistoryTemplateListCache.getInstance().getHistoryList(); + for (JTemplate template : templates) { + if (template.isSaving() || template.isOpening()) { + FileNode node = TemplateTreePane.getInstance().getFileNode(); + if (node != null && ComparatorUtils.equals(template.getEditingFILE().getPath(), node.getEnvPath())) { + return false; + } + } + } + return true; + } + } 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 8b32d14273..d32d14cf23 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 @@ -11,6 +11,8 @@ import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import java.awt.BorderLayout; +import java.awt.Component; +import javax.swing.JLayeredPane; /** @@ -21,9 +23,21 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener private static final long serialVersionUID = 1L; private JTemplate component; + private TransparentPane transparentPane = new TransparentPane(); + private OpenLoadingPane loadingPane = new OpenLoadingPane(); + private JLayeredPane layeredPane = new JLayeredPane() { + @Override + public void doLayout() { + for (Component comp : getComponents()) { + comp.setBounds(0, 0, getWidth(), getHeight()); + } + } + }; protected DesktopCardPane() { setLayout(new BorderLayout()); + layeredPane.add(transparentPane, 1); + layeredPane.add(loadingPane, 2); } protected void showJTemplate(final JTemplate jt) { @@ -36,10 +50,12 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt); if (component != null) { component.onLostFocus(); - remove(component); + layeredPane.remove(component); } component = jt; - add(component, BorderLayout.CENTER); + layeredPane.add(component, 0); + checkSavingAndOpening(jt); + add(layeredPane, BorderLayout.CENTER); validate(); repaint(); revalidate(); @@ -47,6 +63,32 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener component.onGetFocus(); } + + private void checkSavingAndOpening(JTemplate jt) { + if (jt.isSaving()) { + showCover(); + } else if (jt.isOpening()) { + showOpenStatus(); + } else { + hideCover(); + } + } + + private void showOpenStatus() { + DesignerContext.getDesignerFrame().refreshUIToolBar(); + EastRegionContainerPane.getInstance().updateAllPropertyPane(); + layeredPane.moveToFront(loadingPane); + } + + public void showCover() { + layeredPane.moveToFront(transparentPane); + DesignerContext.getDesignerFrame().refreshUIToolBar(); + } + + public void hideCover() { + layeredPane.moveToFront(component); + } + protected JTemplate getSelectedJTemplate() { return component; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 8827d6a857..8097d02f40 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -6,6 +6,7 @@ import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.constants.UIConstants; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; @@ -791,8 +792,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 选项不可用 public void setEnabled(boolean isEnabled) { - this.isEnabled = isEnabled; - button.setEnabled(isEnabled); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + this.isEnabled = isEnabled && !template.isOpening() && !template.isSaving(); + } else { + this.isEnabled = isEnabled; + } + button.setEnabled(this.isEnabled); } public void setIconBaseDir(String iconBaseDir) { 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 0ff728580a..dd2a05a2a4 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 @@ -1,7 +1,6 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.base.FRContext; import com.fr.base.Parameter; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; @@ -22,6 +21,7 @@ import com.fr.design.designer.DesignerProxy; import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateResourceManager; import com.fr.design.file.TemplateTreePane; @@ -49,6 +49,8 @@ import com.fr.design.menu.NameSeparator; import com.fr.design.menu.ShortCut; import com.fr.design.preview.PagePreview; import com.fr.design.ui.util.UIUtil; +import com.fr.design.worker.save.CallbackSaveWorker; +import com.fr.design.worker.save.EmptyCallBackSaveWorker; import com.fr.design.write.submit.DBManipulationInWidgetEventPane; import com.fr.design.write.submit.DBManipulationPane; import com.fr.event.EventDispatcher; @@ -77,6 +79,7 @@ import com.fr.stable.core.UUID; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; +import java.util.concurrent.Callable; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; @@ -92,10 +95,10 @@ import java.util.Set; /** * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) */ -public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy { +public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave { // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null private static final int PREFIX_NUM = 3000; - private FILE editingFILE = null; + protected FILE editingFILE = null; // alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存 private boolean saved = true; private boolean authoritySaved = true; @@ -110,6 +113,8 @@ public abstract class JTemplate> private DesignModelAdapter designModel; private PreviewProvider previewType; protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); + private volatile boolean saving = false; + private volatile boolean opening = false; private PluginEventListener pluginListener; @@ -125,7 +130,15 @@ public abstract class JTemplate> this(t, file, false); } + public JTemplate(T t, FILE file, Parameter[] parameters) { + this(t, file, false, parameters); + } + public JTemplate(T t, FILE file, boolean isNewFile) { + this(t, file, isNewFile, null); + } + + public JTemplate(T t, FILE file, boolean isNewFile, Parameter[] parameters) { super(t); beforeInit(); // 判断是否切换设计器状态到禁止拷贝剪切 @@ -139,7 +152,11 @@ public abstract class JTemplate> this.editingFILE = file; this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); - designModel = createDesignModel(); + if (parameters == null) { + designModel = createDesignModel(); + } else { + designModel = createDesignModel(parameters); + } addCenterPane(); this.undoState = createUndoState(); @@ -397,6 +414,12 @@ public abstract class JTemplate> protected abstract DesignModelAdapter createDesignModel(); + protected DesignModelAdapter createDesignModel(Parameter[] parameters) { + // 空实现 兼容下 + return null; + } + + /** * 创建菜单项Preview * @@ -614,6 +637,7 @@ public abstract class JTemplate> * * @return 保存模板 */ + @Deprecated public boolean saveTemplate() { return this.saveTemplate(true); } @@ -623,6 +647,7 @@ public abstract class JTemplate> * * @return 保存成功返回true */ + @Deprecated public boolean saveTemplate2Env() { return this.saveTemplate(false); } @@ -632,6 +657,7 @@ public abstract class JTemplate> * * @return 保存成功返回true */ + @Deprecated public boolean saveAsTemplate() { return this.saveAsTemplate(true); } @@ -641,6 +667,7 @@ public abstract class JTemplate> * * @return 保存成功返回true */ + @Deprecated public boolean saveAsTemplate2Env() { return this.saveAsTemplate(false); } @@ -651,6 +678,7 @@ public abstract class JTemplate> * @param isShowLoc 是否本地 * @return 保存成功返回true */ + @Deprecated public boolean saveTemplate(boolean isShowLoc) { FILE editingFILE = this.getEditingFILE(); // carl:editingFILE没有,当然不存了,虽然不会有这种情况 @@ -662,17 +690,6 @@ public abstract class JTemplate> if (!editingFILE.exists()) { return saveAsTemplate(isShowLoc); } - boolean access = false; - - try { - access = FRContext.getOrganizationOperator().canAccess(this.getEditingFILE().getPath()); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - if (!access) { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); - return false; - } collectInfo(); return this.saveFile(); } @@ -702,6 +719,7 @@ public abstract class JTemplate> * @param fileName 保存文件名 * @return */ + @Deprecated public boolean saveAsTemplate(boolean isShowLoc, String fileName) { String oldName = this.getPath(); // alex:如果是SaveAs的话需要让用户来选择路径了 @@ -717,20 +735,6 @@ public abstract class JTemplate> FILE sourceFile = editingFILE; if (isOkOperation(chooseResult)) { - boolean access = false; - try { - access = FRContext.getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath()); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - if (!access) { - FineJOptionPane.showMessageDialog( - DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), - JOptionPane.WARNING_MESSAGE); - return false; - } // 目标文件 editingFILE = fileChooser.getSelectedFILE(); } @@ -1392,4 +1396,187 @@ public abstract class JTemplate> return StringUtils.EMPTY; } + private CallbackSaveWorker save(boolean showLoc) { + FILE editingFILE = this.getEditingFILE(); + // carl:editingFILE没有,当然不存了,虽然不会有这种情况 + if (editingFILE == null) { + return new EmptyCallBackSaveWorker(); + } + // 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs + if (!editingFILE.exists()) { + return saveAs(showLoc); + } + + CallbackSaveWorker worker = new CallbackSaveWorker(new Callable() { + @Override + public Boolean call() throws Exception { + collectInfo(); + return JTemplate.this.saveRealFile(); + } + }, this); + + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + callBackForSave(); + } + }); + + return worker; + } + + private void callBackForSave() { + JTemplate.this.saved = true; + JTemplate.this.authoritySaved = true; + DesignerContext.getDesignerFrame().setTitle(); + JTemplate.this.fireJTemplateSaved(); + } + + private boolean saveRealFile() throws Exception { + FILE editingFILE = this.getEditingFILE(); + if (editingFILE == null || editingFILE instanceof MemFILE) { + return false; + } + this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); + this.editingFILE = editingFILE; + return true; + } + + private CallbackSaveWorker saveAs(boolean showLoc) { + FILE editingFILE = this.getEditingFILE(); + if (editingFILE == null) { + return new EmptyCallBackSaveWorker(); + } + String oldName = this.getPath(); + // alex:如果是SaveAs的话需要让用户来选择路径了 + FILEChooserPane fileChooser = getFILEChooserPane(showLoc); + addChooseFILEFilter(fileChooser); + fileChooser.setFileNameTextField(editingFILE.getName(), this.suffix()); + int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix()); + if (isCancelOperation(chooseResult)) { + return new EmptyCallBackSaveWorker(); + } + // 源文件 + FILE sourceFile = editingFILE; + + if (isOkOperation(chooseResult)) { + // 目标文件 + editingFILE = fileChooser.getSelectedFILE(); + } + + // 在保存之前,初始化 templateID + if (StringUtils.isEmpty(this.template.getTemplateID())) { + generateTemplateId(); + } + + FILE finalEditingFILE = editingFILE; + CallbackSaveWorker worker = new CallbackSaveWorker(new Callable() { + @Override + public Boolean call() throws Exception { + return saveAs(finalEditingFILE, sourceFile, oldName); + } + }, this); + + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + callBackForSave(); + // 当前打开的是正在保存的模板才刷新 + if (ComparatorUtils.equals(JTemplate.this.template.getTemplateID(), + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) { + refreshToolArea(); + } + DesignerFrameFileDealerPane.getInstance().refresh(); + } + }); + + return worker; + + } + + private boolean saveAs(FILE editingFILE, FILE sourceFile, String oldName) throws Exception { + boolean lockedTarget = + // 目标本地文件 + !editingFILE.isEnvFile() || + // 目标远程文件 + WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath()); + if (lockedTarget) { + boolean saved = saveNewRealFile(editingFILE, oldName); + // 目标文件保存成功并且源文件不一致的情况下,把源文件锁释放掉 + if (saved && !ComparatorUtils.equals(editingFILE.getPath(), sourceFile.getPath())) { + WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(sourceFile.getPath()); + } + return saved; + } else { + return false; + } + } + + private boolean saveNewRealFile(FILE editingFILE, String oldName) throws Exception { + consumeTimer.setEnabled(true); + consumeTimer.start(); + this.editingFILE = editingFILE; + boolean result = this.saveToNewRealFile(oldName); + if (result) { + collectInfo(this.template.getTemplateID()); + } + return result; + } + + private boolean saveToNewRealFile(String oldName) throws Exception { + boolean result = false; + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { + result = result || provider.saveToNewFile(this.editingFILE.getPath(), this); + } + if (!result) { + result = this.saveRealFile(); + // 更换最近打开 + DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); + } + return result; + } + + @Override + public CallbackSaveWorker save() { + return save(true); + } + + @Override + public CallbackSaveWorker saveAs() { + return saveAs(true); + } + + @Override + public void saveDirectly() { + CallbackSaveWorker worker = save(); + worker.start(this.template.getTemplateID()); + } + + @Override + public void saveAsDirectly() { + CallbackSaveWorker worker = saveAs(); + worker.start(this.template.getTemplateID()); + } + + public boolean isSaving() { + return saving; + } + + public void setSaving(boolean saving) { + this.saving = saving; + } + + public boolean isOpening() { + return opening; + } + + public void setOpening(boolean opening) { + this.opening = opening; + } + + public boolean checkEnable() { + return !isSaving() && !isOpening(); + } + } 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 new file mode 100644 index 0000000000..2b96a471b5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java @@ -0,0 +1,40 @@ +package com.fr.design.mainframe; + +import com.fr.design.worker.save.CallbackSaveWorker; + +/** + * 模板保存接口 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/4/9 + */ +public interface JTemplateSave { + + /** + * 直接保存后需要根据是否成功做外部回调 + * + * @return + */ + CallbackSaveWorker save(); + + + /** + * 另存为后需要根据是否成功做外部回调 + * + * @return + */ + CallbackSaveWorker saveAs(); + + /**D + * 直接保存 + */ + void saveDirectly(); + + + /** + * 直接另存为 + */ + void saveAsDirectly(); + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java new file mode 100644 index 0000000000..5a81319739 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java @@ -0,0 +1,60 @@ +package com.fr.design.mainframe; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.general.IOUtils; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.LayoutManager; +import javax.swing.ImageIcon; +import javax.swing.JPanel; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/9 + */ +public class OpenLoadingPane extends JPanel { + + private UILabel loadingLabel; + + public OpenLoadingPane() { + + setLayout(new LayoutManager() { + + @Override + public void removeLayoutComponent(Component comp) { + } + + @Override + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + @Override + public Dimension minimumLayoutSize(Container parent) { + return null; + } + + @Override + public void layoutContainer(Container parent) { + int width = parent.getParent().getWidth(); + int height = parent.getParent().getHeight(); + int loadingLabelWidth = loadingLabel.getPreferredSize().width; + int loadingLabelHeight = loadingLabel.getPreferredSize().height; + int loadingLabelX = (width - loadingLabelWidth) / 2; + int loadingLabelY = (height - loadingLabelHeight) / 2; + loadingLabel.setBounds(loadingLabelX, loadingLabelY, loadingLabelWidth, loadingLabelHeight); + } + + @Override + public void addLayoutComponent(String name, Component comp) { + } + }); + setBackground(Color.WHITE); + loadingLabel = new UILabel(new ImageIcon(IOUtils.readImage("com/fr/plugin/chart/vanchart/export/loading.png"))); + add(loadingLabel); + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/TransparentPane.java b/designer-base/src/main/java/com/fr/design/mainframe/TransparentPane.java new file mode 100644 index 0000000000..100ab04f63 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/TransparentPane.java @@ -0,0 +1,102 @@ +package com.fr.design.mainframe; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Composite; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.LayoutManager; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.ImageIcon; +import javax.swing.JComponent; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/12 + */ +public class TransparentPane extends JComponent { + + private static final ImageIcon LOADING_ICON = new ImageIcon(TransparentPane.class.getResource("/com/fr/web/images/loading-local.gif")); + + private UILabel loadingLabel; + private UILabel label; + private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f); + + public TransparentPane() { + + addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + // do nothing + } + }); + + setLayout(getCoverLayout()); + setBackground(null); + setOpaque(false); + + loadingLabel = new UILabel(LOADING_ICON); + label = new UILabel(Toolkit.i18nText("Fine-Design_Saving_Template_Tip")); + add(loadingLabel); + add(label); + } + + protected LayoutManager getCoverLayout() { + return new LayoutManager() { + + @Override + public void removeLayoutComponent(Component comp) { + } + + @Override + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + @Override + public Dimension minimumLayoutSize(Container parent) { + return null; + } + + @Override + public void layoutContainer(Container parent) { + int width = parent.getParent().getWidth(); + int height = parent.getParent().getHeight(); + int loadingLabelWidth = loadingLabel.getPreferredSize().width; + int loadingLabelHeight = loadingLabel.getPreferredSize().height; + int buttonX = (width - loadingLabelWidth) / 2; + int buttonY = (height - loadingLabelHeight) / 2; + int labelWidth = label.getPreferredSize().width; + int labelHeight = label.getPreferredSize().height; + int labelX = (width - labelWidth) / 2; + int labelY = (height - labelHeight) / 2 + loadingLabelHeight; + label.setBounds(labelX, labelY, labelWidth, labelHeight); + loadingLabel.setBounds(buttonX, buttonY, loadingLabelWidth, loadingLabelHeight); + } + + @Override + public void addLayoutComponent(String name, Component comp) { + } + }; + } + + + @Override + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(composite); + g2d.setColor(Color.BLACK); + g2d.fillRect(0, 0, getWidth(), getHeight()); + g2d.setComposite(oldComposite); + super.paint(g); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java index f2ed81394b..55b80c0ec8 100644 --- a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java @@ -1,12 +1,17 @@ package com.fr.design.menu; import com.fr.base.svg.IconUtils; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.*; import com.fr.design.gui.iscrollbar.UIScrollBar; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StringUtils; +import java.util.HashSet; +import java.util.Set; import javax.swing.*; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; @@ -25,6 +30,17 @@ public class MenuDef extends ShortCut { private static final int MENU_DEFAULTWDITH = 156; private static final int BLANK_WIDTH = 30; + + private static final Set FORBIDDEN_SET = new HashSet<>(); + + { + FORBIDDEN_SET.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Template")); + FORBIDDEN_SET.add(Toolkit.i18nText("Fine-Design_Report_M_Insert")); + FORBIDDEN_SET.add(Toolkit.i18nText("Fine-Design_Basic_Action_Add")); + FORBIDDEN_SET.add(KeySetUtils.CELL.getMenuKeySetName()); + FORBIDDEN_SET.add(KeySetUtils.INSERT_FLOAT.getMenuKeySetName()); + } + protected String name; //右侧属性表弹出框重绘 protected Boolean isEastAttr = false; @@ -390,6 +406,21 @@ public class MenuDef extends ShortCut { toolBar.add(this.createUIButton()); } + private boolean checkEnable(JComponent component) { + if (FORBIDDEN_SET.contains(component.getName())) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + boolean flag = true; + if (template != null) { + flag = !template.isSaving() && !template.isOpening(); + } + component.setEnabled(flag); + if (!flag) { + return false; + } + } + return true; + } + protected MenuListener createMenuListener() { return menuDefListener; @@ -411,7 +442,9 @@ public class MenuDef extends ShortCut { if (!(source instanceof JMenu)) { return; } - + if (!checkEnable(createJMenu())) { + return; + } MenuDef.this.updateMenu(); } }; @@ -421,7 +454,7 @@ public class MenuDef extends ShortCut { public void mouseReleased(MouseEvent evt) { Object source = evt.getSource(); UIButton button = (UIButton) source; - if (!button.isEnabled()) { + if (!checkEnable(button)) { return; } if (isEastAttr) { diff --git a/designer-base/src/main/java/com/fr/design/worker/WorkerManager.java b/designer-base/src/main/java/com/fr/design/worker/WorkerManager.java new file mode 100644 index 0000000000..1346da453f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/worker/WorkerManager.java @@ -0,0 +1,49 @@ +package com.fr.design.worker; + +import java.util.HashMap; +import java.util.Map; +import javax.swing.SwingWorker; +import org.jetbrains.annotations.Nullable; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/2 + */ +public class WorkerManager { + + private static final WorkerManager INSTANCE = new WorkerManager(); + + private Map workerMap = new HashMap<>(); + + public static WorkerManager getInstance() { + return INSTANCE; + } + + @Nullable + public SwingWorker getWorker(String taskName) { + return workerMap.get(taskName); + } + + public boolean isCompleted(String taskName) { + SwingWorker worker = getWorker(taskName); + return worker == null || worker.isDone(); + } + + public void registerWorker(String taskName, SwingWorker worker) { + workerMap.put(taskName, worker); + } + + public void removeWorker(String taskName) { + workerMap.remove(taskName); + } + + public void cancelWorker(String taskName) { + SwingWorker worker = getWorker(taskName); + if (worker != null && !worker.isDone()) { + worker.cancel(true); + removeWorker(taskName); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/worker/open/OpenResult.java b/designer-base/src/main/java/com/fr/design/worker/open/OpenResult.java new file mode 100644 index 0000000000..a8b6f0c579 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/worker/open/OpenResult.java @@ -0,0 +1,28 @@ +package com.fr.design.worker.open; + +import com.fr.base.io.BaseBook; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/13 + */ +public class OpenResult { + + private final T baseBook; + + private final R ref; + + public OpenResult(T baseBook, R r) { + this.baseBook = baseBook; + this.ref = r; + } + + public T getBaseBook() { + return baseBook; + } + + public R getRef() { + return ref; + } +} 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 new file mode 100644 index 0000000000..97f13a0e30 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java @@ -0,0 +1,115 @@ +package com.fr.design.worker.open; + +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.worker.WorkerManager; +import com.fr.file.FILE; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import javax.swing.SwingWorker; + +/** + * 模板打开的worker + * + * @author hades + * @version 10.0 + * Created by hades on 2021/4/9 + */ +public class OpenWorker extends SwingWorker { + + private static final int TIME_OUT = 400; + + private final Callable callable; + + private final JTemplate template; + + private Callable> templateCallable; + + private boolean slowly = false; + + private String taskName; + + private T result; + + public OpenWorker(Callable callable, JTemplate template) { + this.callable = callable; + this.template = template; + } + + @Override + protected T doInBackground() throws Exception { + return this.callable.call(); + } + + @Override + protected void done() { + try { + result = get(); + } catch (CancellationException ignored) { + return; + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + this.template.setOpening(false); + // 后续动作 + if (slowly && templateCallable != null) { + try { + JTemplate book = templateCallable.call(); + FILE tplFile = book.getEditingFILE(); + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + // 当前tab页是正在打开的模板 + if (ComparatorUtils.equals(currentTemplate.getEditingFILE(), tplFile)) { + currentTemplate.whenClose(); + 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; + } + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + WorkerManager.getInstance().removeWorker(taskName); + } + + public void addCallBack(Callable> templateCallable) { + this.templateCallable = templateCallable; + } + + public void start(String taskName) { + this.taskName = taskName; + this.template.setOpening(true); + this.execute(); + WorkerManager.getInstance().registerWorker(taskName, this); + } + + public T getResult() { + if (result != null) { + return result; + } + try { + return this.get(TIME_OUT, TimeUnit.MILLISECONDS); + } catch (TimeoutException e) { + slowly = true; + } catch (Exception exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + WorkerManager.getInstance().removeWorker(taskName); + } + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java new file mode 100644 index 0000000000..f8a0f5d4fa --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java @@ -0,0 +1,75 @@ +package com.fr.design.worker.save; + +import com.fr.common.util.Collections; +import com.fr.design.mainframe.JTemplate; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.Callable; + +/** + * 保存之后需要做些外部回调 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/4/8 + */ +public class CallbackSaveWorker extends SaveWorker { + + private List successRunnableList; + + private List failRunnableList; + + public CallbackSaveWorker(Callable callable, JTemplate template) { + super(callable, template); + } + + @Override + protected void done() { + super.done(); + + if (success) { + fireRunnable(successRunnableList); + } else { + fireRunnable(failRunnableList); + } + successRunnableList = null; + failRunnableList = null; + } + + private void fireRunnable(List list) { + if (Collections.isEmpty(list)) { + return; + } + for (Runnable runnable : list) { + runnable.run(); + } + } + + private void addCallback(List runnableList, Runnable runnable) { + if (runnableList == null) { + runnableList = new LinkedList<>(); + } + if (runnable != null) { + runnableList.add(runnable); + } + } + + public void addSuccessCallback(Runnable successRunnable) { + if (successRunnableList == null) { + successRunnableList = new LinkedList<>(); + } + if (successRunnable != null) { + successRunnableList.add(successRunnable); + } + } + + public void addFailCallback(Runnable failRunnable) { + if (failRunnableList == null) { + failRunnableList = new LinkedList<>(); + } + if (failRunnable != null) { + failRunnableList.add(failRunnable); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/worker/save/EmptyCallBackSaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/EmptyCallBackSaveWorker.java new file mode 100644 index 0000000000..27e85f5ec6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/worker/save/EmptyCallBackSaveWorker.java @@ -0,0 +1,37 @@ +package com.fr.design.worker.save; + +import com.fr.design.mainframe.JTemplate; +import java.util.concurrent.Callable; + +/** + * 空实现 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/4/9 + */ +public class EmptyCallBackSaveWorker extends CallbackSaveWorker { + + public EmptyCallBackSaveWorker(Callable callable, JTemplate template) { + super(callable, template); + } + + public EmptyCallBackSaveWorker() { + this(null, null); + } + + @Override + protected Boolean doInBackground() throws Exception { + return false; + } + + @Override + protected void done() { + // do nothing + } + + @Override + public void start(String taskName) { + // do nothing + } +} 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 new file mode 100644 index 0000000000..f3baa98f7a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java @@ -0,0 +1,82 @@ +package com.fr.design.worker.save; + +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.mainframe.DesignerFrameFileDealerPane; +import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.worker.WorkerManager; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import javax.swing.SwingWorker; + +/** + * 模板保存的worker + * + * @author hades + * @version 10.0 + * Created by hades on 2021/4/1 + */ +public class SaveWorker extends SwingWorker { + + private static final int TIME_OUT = 400; + + private final Callable callable; + + private String taskName; + + private final JTemplate template; + + protected boolean success; + + public SaveWorker(Callable callable, JTemplate template) { + this.callable = callable; + this.template = template; + } + + @Override + protected Boolean doInBackground() throws Exception { + return callable.call(); + } + + @Override + protected void done() { + try { + success = get(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + this.template.setSaving(false); + // 恢复界面 + if (ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) { + EastRegionContainerPane.getInstance().updateAllPropertyPane(); + DesignerContext.getDesignerFrame().refreshUIToolBar(); + DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover(); + } + DesignerFrameFileDealerPane.getInstance().stateChange(); + WorkerManager.getInstance().removeWorker(taskName); + } + + public void start(String taskName) { + this.taskName = taskName; + this.template.setSaving(true); + this.execute(); + // worker纳入管理 + WorkerManager.getInstance().registerWorker(taskName, this); + try { + this.get(TIME_OUT, TimeUnit.MILLISECONDS); + } catch (TimeoutException timeoutException) { + // 开始禁用 + EastRegionContainerPane.getInstance().updateAllPropertyPane(); + DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); + DesignerFrameFileDealerPane.getInstance().stateChange(); + } catch (Exception exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + WorkerManager.getInstance().removeWorker(taskName); + } + } +} diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 1f4f331d83..4bacf9a85b 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -892,7 +892,7 @@ public class FILEChooserPane extends BasicPane { if (access(selectedFile) && access(currentDirectory)) { if (selectedFile.exists()) { int selVal = FineJOptionPane.showConfirmDialog(dialog, Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Cover_The_Current_File") + " ?", - Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (selVal == JOptionPane.YES_OPTION) { option = JOPTIONPANE_OK_OPTION; saveDictionary(); @@ -913,9 +913,8 @@ public class FILEChooserPane extends BasicPane { private boolean access(FILE selectedFile) { - boolean access = false; + boolean access = true; try { - access = FRContext.getOrganizationOperator().canAccess(selectedFile.getPath()); if (selectedFile.isEnvFile() && selectedFile instanceof FileNodeFILE) { FileNodeFILE fileNodeFILE = ((FileNodeFILE) selectedFile); access = access && fileNodeFILE.hasFullAuth() && NodeAuthProcessor.getInstance().checkFileNodeAuth(new FileNode(fileNodeFILE.getPath(), fileNodeFILE.isDirectory())); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java b/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java index e5617c9462..bf047a3bee 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java @@ -27,6 +27,10 @@ public class FormModelAdapter extends DesignModelAdapter> super(jForm); } + public FormModelAdapter(BaseJForm

jTemplate, Parameter[] parameters) { + super(jTemplate, parameters); + } + /** * 环境改变. */ diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index d39de1d447..a851074be1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -127,6 +127,9 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm extends Tar @Override public void mouseClicked(MouseEvent e) { //如果没有格式刷,点击时就是想使用格式刷 + if (!formatBrush.isEnabled()) { + return; + } if (e.getClickCount() == 1) { if (!formatBrush.isSelected()) { DesignerContext.setFormatState(DesignerContext.FORMAT_STATE_ONCE); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index ff14d54f40..0f1ced3797 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -145,6 +145,10 @@ public class JWorkBook extends JTemplate { super(workBook, fileName); populateReportParameterAttr(); } + public JWorkBook(WorkBook workBook, FILE file, Parameter[] parameters) { + super(workBook, file, parameters); + populateReportParameterAttr(); + } public JWorkBook(WorkBook workBook, FILE file) { super(workBook, file); @@ -871,6 +875,11 @@ public class JWorkBook extends JTemplate { return new WorkBookModelAdapter(this); } + @Override + protected WorkBookModelAdapter createDesignModel(Parameter[] parameters) { + return new WorkBookModelAdapter(this, parameters); + } + /** * 表单的工具栏 * diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java b/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java index 87391a5a05..53f193be74 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java @@ -36,6 +36,9 @@ public class WorkBookModelAdapter extends DesignModelAdapter { @Override public JTemplate openTemplate(FILE tplFile) { - - return new JWorkBook(asIOFile(tplFile), tplFile); + JWorkBook emptyTemplate = new JWorkBook(new WorkBook(new WorkSheet()), tplFile); + OpenWorker> worker = new OpenWorker<>( + new Callable>() { + @Override + public OpenResult call() { + WorkBook workBook = asIOFile(tplFile); + return new OpenResult<>(workBook, workBook.getParameters()); + } + }, emptyTemplate); + worker.addCallBack(new Callable>() { + @Override + public JTemplate call() throws Exception { + OpenResult result = worker.getResult(); + return new JWorkBook(result.getBaseBook(), tplFile, result.getRef()); + } + }); + worker.start(tplFile.getPath()); + OpenResult result = worker.getResult(); + if (result != null) { + return new JWorkBook(result.getBaseBook(), tplFile); + } + return emptyTemplate; } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java index adadab36d4..3e9b43e8ed 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java @@ -12,6 +12,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DecodeDialog; +import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.exception.DecryptTemplateException; import com.fr.exception.RemoteDesignPermissionDeniedException; @@ -85,7 +86,12 @@ class CptApp extends AbstractWorkBookApp { al.add((String) it.next()); } if (!al.isEmpty()) { - showConfirmDialog(al); + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + showConfirmDialog(al); + } + }); } } 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 046451337e..f9e19dd64b 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 @@ -1,22 +1,28 @@ package com.fr.design.mainframe.app; +import com.fr.base.Parameter; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.DesignerEnvManager; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.AbstractAppProvider; import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.DecodeDialog; +import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; +import com.fr.design.worker.open.OpenResult; +import com.fr.design.worker.open.OpenWorker; import com.fr.exception.DecryptTemplateException; import com.fr.exception.RemoteDesignPermissionDeniedException; import com.fr.exception.TplLockedException; import com.fr.file.FILE; import com.fr.form.main.Form; +import com.fr.form.ui.container.WBorderLayout; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import com.fr.stable.bridge.StableFactory; import java.util.HashMap; +import java.util.concurrent.Callable; /** * Created by juhaoyu on 2018/6/27. @@ -36,9 +42,31 @@ class FormApp extends AbstractAppProvider { HashMap classType = new HashMap(); classType.put(Constants.ARG_0, Form.class); classType.put(Constants.ARG_1, FILE.class); - - return (JTemplate) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, - new Object[]{asIOFile(tplFile), tplFile}, classType, BaseJForm.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 = asIOFile(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) { + return (JTemplate) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, + new Object[]{result.getBaseBook(), tplFile, new Parameter[0]}, classType, BaseJForm.class); + } + return emptyForm; } @Override diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index 162a2044f4..5d39647714 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -17,6 +17,7 @@ import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.fun.MenuHandler; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIPreviewButton; +import com.fr.design.gui.ibutton.UISaveForbiddenButton; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.itoolbar.UILargeToolbar; @@ -232,7 +233,7 @@ public class MainDesigner extends BaseDesigner { public void actionPerformed(ActionEvent e) { JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); jt.stopEditing(); - jt.saveTemplate(); + jt.saveDirectly(); jt.requestFocus(); } }); @@ -270,12 +271,12 @@ public class MainDesigner extends BaseDesigner { } private void createRunButton(UILargeToolbar largeToolbar) { - run = new UIPreviewButton(new UIButton(UIConstants.PAGE_BIG_ICON) { + run = new UIPreviewButton(new UISaveForbiddenButton(UIConstants.PAGE_BIG_ICON) { @Override public Dimension getPreferredSize() { return new Dimension(34, 34); } - }, new UIButton(UIConstants.PREVIEW_DOWN) { + }, new UISaveForbiddenButton(UIConstants.PREVIEW_DOWN) { @Override public Dimension getPreferredSize() { return new Dimension(34, 10); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 8c607f9ed5..eb3f577cc9 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -27,6 +27,7 @@ import com.fr.design.actions.insert.flot.ImageFloatAction; import com.fr.design.actions.insert.flot.TextBoxFloatAction; import com.fr.design.bridge.DesignToolbarProvider; import com.fr.design.constants.DesignerLaunchStatus; +import com.fr.design.env.DesignerWorkspaceLoader; import com.fr.design.form.parameter.FormParaDesigner; import com.fr.design.fun.ElementUIProvider; import com.fr.design.gui.controlpane.NameObjectCreator; @@ -145,6 +146,7 @@ public class DesignerActivator extends Activator { designerModuleStart(); loadLogAppender(); DesignerSocketIO.update(); + DesignerWorkspaceLoader.init(); OSSupportCenter.buildAction(new OSBasedAction() { @Override public void execute(Object... objects) { diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java index 7154de982f..e43cd6cbb3 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java @@ -2,6 +2,7 @@ package com.fr.start.module; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.PluginClassRefreshManager; +import com.fr.design.env.WorkspaceChangeLoadingDialog; import com.fr.design.file.HistoryTemplateListCache; import com.fr.event.Event; import com.fr.event.Listener; @@ -51,6 +52,7 @@ public class DesignerWorkspaceActivator extends Activator { @Override public void on(Event event, Workspace workspace) { + WorkspaceChangeLoadingDialog.showDialog(); PluginClassRefreshManager.getInstance().removePluginListener(); HistoryTemplateListCache.getInstance().stash(); } @@ -64,6 +66,7 @@ public class DesignerWorkspaceActivator extends Activator { HistoryTemplateListCache.getInstance().load(); PluginClassRefreshManager.getInstance().addPluginListener(); + WorkspaceChangeLoadingDialog.hideDialog(); } }); } From 46bfdaf2b3aa1afba84aa6e4d36c71c819789dc9 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Apr 2021 11:05:25 +0800 Subject: [PATCH 2/8] =?UTF-8?q?REPORT-49986=20=E3=80=9010.0.16=E3=80=91?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96=E4=B9=8B=E9=98=BB=E5=A1=9E?= =?UTF-8?q?EDT=E7=BA=BF=E7=A8=8B=E6=97=B6=E4=BC=98=E5=8C=96=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/edit/RedoAction.java | 2 +- .../fr/design/actions/edit/UndoAction.java | 2 +- .../file/CloseCurrentTemplateAction.java | 2 +- .../actions/file/ExitDesignerAction.java | 4 +++ .../actions/file/SaveAsTemplateAction.java | 3 +-- .../actions/file/SaveTemplateAction.java | 2 +- .../file/export/AbstractExportAction.java | 6 +++++ .../design/file/HistoryTemplateListCache.java | 1 + .../fr/design/file/MutilTempalteTabPane.java | 4 +++ .../gui/ibutton/UIForbiddenButtonUI.java | 2 +- .../design/gui/imenu/UIForBiddenHeadMenu.java | 18 ------------- .../design/gui/imenu/UIForbiddenMenuUI.java | 25 ------------------- .../com/fr/design/gui/itoolbar/UIToolbar.java | 2 +- .../fr/design/mainframe/DesignerFrame.java | 4 +++ .../com/fr/design/worker/save/SaveWorker.java | 9 ++++++- 15 files changed, 34 insertions(+), 52 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java delete mode 100644 designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java diff --git a/designer-base/src/main/java/com/fr/design/actions/edit/RedoAction.java b/designer-base/src/main/java/com/fr/design/actions/edit/RedoAction.java index 8b8ffde4a0..b00aff1a61 100644 --- a/designer-base/src/main/java/com/fr/design/actions/edit/RedoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/edit/RedoAction.java @@ -49,7 +49,7 @@ public class RedoAction extends UpdateAction implements TemplateComponentActionI public void update() { JTemplate undoComponent = getEditingComponent(); if (DesignerEnvManager.getEnvManager().isSupportUndo()) { - boolean enable = undoComponent != null && undoComponent.canRedo() && !undoComponent.isOpening() && !undoComponent.isSaving(); + boolean enable = undoComponent != null && undoComponent.canRedo() && undoComponent.checkEnable(); this.setEnabled(enable); } else { this.setEnabled(false); diff --git a/designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java b/designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java index 53e5ed7c5a..d8ed5b9da1 100644 --- a/designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java @@ -49,7 +49,7 @@ public class UndoAction extends UpdateAction implements TemplateComponentActionI public void update() { JTemplate undoComponent = getEditingComponent(); if (DesignerEnvManager.getEnvManager().isSupportUndo()) { - boolean enable = undoComponent != null && undoComponent.canUndo() && !undoComponent.isOpening() && !undoComponent.isSaving(); + boolean enable = undoComponent != null && undoComponent.canUndo() && undoComponent.checkEnable(); this.setEnabled(enable); } else { this.setEnabled(false); diff --git a/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java index 9e8be9f51b..e7c83ce47b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java @@ -1 +1 @@ -package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.menu.KeySetUtils; import java.awt.event.ActionEvent; /** * Author : daisy * Date: 13-8-16 * Time: 下午3:23 */ public class CloseCurrentTemplateAction extends UpdateAction { public CloseCurrentTemplateAction() { this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setAccelerator(getMenuKeySet().getKeyStroke()); } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } } \ No newline at end of file +package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; import java.awt.event.ActionEvent; /** * Author : daisy * Date: 13-8-16 * Time: 下午3:23 */ public class CloseCurrentTemplateAction extends UpdateAction { public CloseCurrentTemplateAction() { this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setAccelerator(getMenuKeySet().getKeyStroke()); } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } @Override public void update() { super.update(); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { this.setEnabled(!template.isSaving()); } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/file/ExitDesignerAction.java b/designer-base/src/main/java/com/fr/design/actions/file/ExitDesignerAction.java index 070b9df221..1ca29a0425 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/ExitDesignerAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/ExitDesignerAction.java @@ -3,6 +3,7 @@ */ package com.fr.design.actions.file; +import com.fr.design.mainframe.TemplateSavingChecker; import java.awt.event.ActionEvent; import com.fr.design.actions.UpdateAction; @@ -27,6 +28,9 @@ public class ExitDesignerAction extends UpdateAction { * @param e 事件 */ public void actionPerformed(ActionEvent e) { + if (!TemplateSavingChecker.check()) { + return; + } DesignerContext.getDesignerFrame().exit(); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java index 07b8a8024b..b957e15630 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java @@ -40,7 +40,6 @@ public class SaveAsTemplateAction extends JTemplateAction> { @Override public void update() { super.update(); - boolean enable = !this.getEditingComponent().isSaving() && !this.getEditingComponent().isOpening(); - this.setEnabled(enable); + this.setEnabled(this.getEditingComponent().checkEnable()); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java index dfc2071b11..072a127aa9 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java @@ -38,7 +38,7 @@ public class SaveTemplateAction extends JTemplateAction> { @Override public void update() { super.update(); - boolean enable = !this.getEditingComponent().isSaved() && !this.getEditingComponent().isSaving() && !this.getEditingComponent().isOpening(); + boolean enable = !this.getEditingComponent().isSaved() && this.getEditingComponent().checkEnable(); this.setEnabled(enable); } diff --git a/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java b/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java index 5277d2ebf1..094915a858 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java @@ -226,4 +226,10 @@ public abstract class AbstractExportAction> extends JT } } + @Override + public void update() { + super.update(); + this.setEnabled(this.getEditingComponent().checkEnable()); + } + } diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 4487a2bbfc..f7d4d1f571 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -380,6 +380,7 @@ public class HistoryTemplateListCache implements CallbackEvent { try { return stashWorker.get(); } catch (Exception e) { + FineLoggerFactory.getLogger().debug(e.getMessage(), e); return false; } } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index b5f6b2ffda..0e81485849 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -11,6 +11,7 @@ import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.TemplateSavingChecker; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; @@ -197,6 +198,9 @@ public class MutilTempalteTabPane extends JComponent { if (openedTemplate.size() == 1) { return; } + if (!TemplateSavingChecker.check()) { + return; + } SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); //点击关闭其他模板,并且点击确定保存 if (saveSomeTempaltePane.showSavePane()) { 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 94353deea7..df3b6a86e0 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 @@ -18,7 +18,7 @@ public class UIForbiddenButtonUI extends UIButtonUI { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); boolean flag = true; if (template != null) { - flag = c.isEnabled() && !template.isSaving() && !template.isOpening(); + flag = c.isEnabled() && template.checkEnable(); } c.setEnabled(flag); } diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java deleted file mode 100644 index 14a12b58c5..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fr.design.gui.imenu; - -/** - * @author hades - * @version 10.0 - * Created by hades on 2021/4/11 - */ -public class UIForBiddenHeadMenu extends UIHeadMenu { - - public UIForBiddenHeadMenu(String name) { - super(name); - } - - @Override - public void updateUI() { - setUI(new UIForbiddenMenuUI()); - } -} diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java deleted file mode 100644 index 7a28513400..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fr.design.gui.imenu; - -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.mainframe.JTemplate; -import java.awt.Graphics; -import javax.swing.JComponent; - -/** - * @author hades - * @version 10.0 - * Created by hades on 2021/4/11 - */ -public class UIForbiddenMenuUI extends UIMenuUI { - - @Override - public void paint(Graphics g, JComponent c) { -// JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); -// boolean flag = true; -// if (template != null) { -// flag = !template.isSaving() && !template.isOpening(); -// } -// c.setEnabled(flag); - super.paint(g, c); - } -} diff --git a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java index 1740c6d3b4..347dd768f5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java +++ b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java @@ -40,7 +40,7 @@ public class UIToolbar extends JToolBar { if (template != null) { for (int i = 0; i < getComponentCount(); i++) { Component component = getComponents()[i]; - component.setEnabled(!template.isSaving() && !template.isOpening()); + component.setEnabled(template.checkEnable()); } } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 7ebf3ebe05..4434131813 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -185,6 +185,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta @Override public void windowClosing(WindowEvent e) { + // 关闭前check + if (!TemplateSavingChecker.check()) { + return; + } //关闭前当前模板 停止编辑 HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().stopEditing(); SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); 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 f3baa98f7a..d9f511cc70 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 @@ -1,8 +1,9 @@ package com.fr.design.worker.save; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; @@ -12,6 +13,7 @@ import com.fr.log.FineLoggerFactory; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import javax.swing.JOptionPane; import javax.swing.SwingWorker; /** @@ -49,6 +51,11 @@ public class SaveWorker extends SwingWorker { success = get(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineJOptionPane.showMessageDialog( + DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design-Basic_Save_Failure"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.ERROR_MESSAGE); } this.template.setSaving(false); // 恢复界面 From d2e5f1f454d1febb136dd23405cad49d426fcc5f Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Apr 2021 11:06:26 +0800 Subject: [PATCH 3/8] =?UTF-8?q?REPORT-49986=20=E3=80=9010.0.16=E3=80=91?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96=E4=B9=8B=E9=98=BB=E5=A1=9E?= =?UTF-8?q?EDT=E7=BA=BF=E7=A8=8B=E6=97=B6=E4=BC=98=E5=8C=96=20add?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/TemplateSavingChecker.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/TemplateSavingChecker.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/TemplateSavingChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/TemplateSavingChecker.java new file mode 100644 index 0000000000..11ffc6e917 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/TemplateSavingChecker.java @@ -0,0 +1,41 @@ +package com.fr.design.mainframe; + +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.StableUtils; +import java.util.ArrayList; +import java.util.List; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/12 + */ +public class TemplateSavingChecker { + + + public static boolean check() { + List list = getSavingTemplate(); + if (!list.isEmpty()) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Close_Template_Tip", StableUtils.join(list, "、")), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + FineJOptionPane.INFORMATION_MESSAGE); + return false; + } + return true; + } + + + private static List getSavingTemplate() { + List result = new ArrayList<>(); + for (JTemplate template : HistoryTemplateListCache.getInstance().getHistoryList()) { + if (template.isSaving()) { + result.add(template.getEditingFILE().getName()); + } + } + return result; + } + +} From 39a68171c3dd260c9b5dc83cc012e0c1798afa6e Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Apr 2021 11:08:29 +0800 Subject: [PATCH 4/8] =?UTF-8?q?REPORT-49986=20CloseCurrentTemplateAction?= =?UTF-8?q?=20=E6=8D=A2=E8=A1=8C=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../file/CloseCurrentTemplateAction.java | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java index e7c83ce47b..58fe5666a4 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java @@ -1 +1,44 @@ -package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; import java.awt.event.ActionEvent; /** * Author : daisy * Date: 13-8-16 * Time: 下午3:23 */ public class CloseCurrentTemplateAction extends UpdateAction { public CloseCurrentTemplateAction() { this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setAccelerator(getMenuKeySet().getKeyStroke()); } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } @Override public void update() { super.update(); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { this.setEnabled(!template.isSaving()); } } } \ No newline at end of file +package com.fr.design.actions.file; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.menu.KeySetUtils; + +import java.awt.event.ActionEvent; + +/** + * Author : daisy + * Date: 13-8-16 + * Time: 下午3:23 + */ +public class CloseCurrentTemplateAction extends UpdateAction { + + public CloseCurrentTemplateAction() { + this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); + this.setName(getMenuKeySet().getMenuKeySetName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setAccelerator(getMenuKeySet().getKeyStroke()); + } + + /** + * 动作 + * @param e 事件 + */ + public void actionPerformed(ActionEvent e) { + MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); + MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + } + + @Override + public void update() { + super.update(); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + this.setEnabled(!template.isSaving()); + } + } +} \ No newline at end of file From bb5e2d53849cd07c642b9e9ec48bb8b057507e1a Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Apr 2021 19:23:18 +0800 Subject: [PATCH 5/8] =?UTF-8?q?REPORT-49986=20=E3=80=9010.0.16=E3=80=91?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96=E4=B9=8B=E9=98=BB=E5=A1=9E?= =?UTF-8?q?EDT=E7=BA=BF=E7=A8=8B=E6=97=B6=E4=BC=98=E5=8C=96=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/WebPreviewUtils.java | 27 ++++++++++++++----- .../design/gui/ibutton/UIForbiddenButton.java | 12 +++++++++ .../gui/ibutton/UIForbiddenButtonUI.java | 9 +------ .../fr/design/mainframe/DesktopCardPane.java | 1 + .../com/fr/design/mainframe/JTemplate.java | 10 +++++++ .../fr/design/mainframe/JTemplateSave.java | 21 +++++++++++++-- .../com/fr/design/worker/open/OpenWorker.java | 20 +++++++------- .../com/fr/design/worker/save/SaveWorker.java | 5 +++- .../fr/design/mainframe/ToolBarButton.java | 11 ++++++++ .../com/fr/design/mainframe/app/FormApp.java | 2 +- 10 files changed, 91 insertions(+), 27 deletions(-) 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) { From 7026cd45683e9f84e6ec4da025c3d2baff6acbde Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Apr 2021 19:28:03 +0800 Subject: [PATCH 6/8] =?UTF-8?q?REPORT-49986=20=E3=80=9010.0.16=E3=80=91?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96=E4=B9=8B=E9=98=BB=E5=A1=9E?= =?UTF-8?q?EDT=E7=BA=BF=E7=A8=8B=E6=97=B6=E4=BC=98=E5=8C=96=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/ibutton/UISaveForbiddenButton.java | 12 ++++++++++++ .../design/gui/ibutton/UISaveForbiddenButtonUI.java | 9 +-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java index 7e55c1b35e..7d65df421d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java @@ -1,5 +1,7 @@ package com.fr.design.gui.ibutton; +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; @@ -37,6 +39,16 @@ public class UISaveForbiddenButton extends UIButton { super(resource, needSetDisabledIcon); } + @Override + public boolean isEnabled() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + boolean enabled = true; + if (template != null) { + enabled = !template.isSaving(); + } + return enabled; + } + @Override public ButtonUI getUI() { return new UISaveForbiddenButtonUI(); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java index 7a830c39fd..47be051248 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.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 UISaveForbiddenButtonUI 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 = !template.isSaving(); - } - c.setEnabled(flag); + c.setEnabled(c.isEnabled()); } } From e3385b7167b567482dd7ced5edd28a7f6433e03e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Fri, 16 Apr 2021 10:44:26 +0800 Subject: [PATCH 7/8] =?UTF-8?q?REPORT-50802=20=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E7=BB=84=E5=BB=BA=E8=AE=BE=E7=BD=AE=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE=E7=9A=84?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E6=8F=90=E7=A4=BA=E6=B5=AE=E7=AA=97?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/actions/core/ActionFactory.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java index f19c962f83..2d4554afdd 100644 --- a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java +++ b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java @@ -7,6 +7,7 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuKeySet; import com.fr.design.selection.QuickEditor; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import javax.swing.Action; import javax.swing.KeyStroke; @@ -14,7 +15,6 @@ import java.awt.event.KeyEvent; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -242,8 +242,11 @@ public class ActionFactory { KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY); if (keyStroke != null) { buttonToolTipTextBuf.append(" ("); - buttonToolTipTextBuf.append(KeyEvent.getKeyModifiersText(keyStroke.getModifiers())); - buttonToolTipTextBuf.append('+'); + String modifiersText = KeyEvent.getKeyModifiersText(keyStroke.getModifiers()); + if (!StringUtils.isEmpty(modifiersText)) { + buttonToolTipTextBuf.append(modifiersText); + buttonToolTipTextBuf.append('+'); + } buttonToolTipTextBuf.append(KeyEvent.getKeyText(keyStroke.getKeyCode())); buttonToolTipTextBuf.append(')'); } From c763dc04a6c4a9b796caf18ad0830e48963ee520 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 31 Mar 2021 18:27:19 +0800 Subject: [PATCH 8/8] =?UTF-8?q?REPORT-49034=20=E5=BC=95=E7=94=A8JS?= =?UTF-8?q?=E9=9D=99=E6=80=81=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-base/src/main/java/com/fr/file/FILEChooserPane.java | 4 ++-- designer-base/src/main/java/com/fr/file/FILEFactory.java | 4 ++-- designer-base/src/main/java/com/fr/file/FileNodeFILE.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 43c3f43ad8..1f4f331d83 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -1158,7 +1158,7 @@ public class FILEChooserPane extends BasicPane { }; } if (FILEChooserPane.this.showWebReport) { - webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebRootPath()); + webReportFILE = new FileNodeFILE(FileNodeFILE.webRootPath); } if (FILEChooserPane.this.showLoc) { processSystemFile(); @@ -1219,7 +1219,7 @@ public class FILEChooserPane extends BasicPane { } if (FILEChooserPane.this.showWebReport) { - webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebRootPath()); + webReportFILE = new FileNodeFILE(FileNodeFILE.webRootPath); } if (FILEChooserPane.this.showLoc) { processSystemFile(); diff --git a/designer-base/src/main/java/com/fr/file/FILEFactory.java b/designer-base/src/main/java/com/fr/file/FILEFactory.java index 5a19108ee3..3d48bab341 100644 --- a/designer-base/src/main/java/com/fr/file/FILEFactory.java +++ b/designer-base/src/main/java/com/fr/file/FILEFactory.java @@ -32,7 +32,7 @@ public class FILEFactory { return new FileNodeFILE(new FileNode(path.substring(envPath.length() + 1), false)); } else if (path.startsWith(WEBREPORT_PREFIX)) { return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), false), - FRContext.getCommonOperator().getWebRootPath()); + FileNodeFILE.webRootPath); } else if (path.startsWith(FILE_PREFIX)) { return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); } else { @@ -50,7 +50,7 @@ public class FILEFactory { fixFILENodeAuth(new FileNode(path.substring(ENV_PREFIX.length()), true)); } else if (path.startsWith(WEBREPORT_PREFIX)) { return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true), - FRContext.getCommonOperator().getWebRootPath()); + FileNodeFILE.webRootPath); } else if (path.startsWith(FILE_PREFIX)) { return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); } else { diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index d096faf8a7..bcf1ff7686 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -32,7 +32,7 @@ import java.util.Arrays; public class FileNodeFILE implements FILE { - private static String webRootPath = FRContext.getCommonOperator().getWebRootPath(); + public static String webRootPath = FRContext.getCommonOperator().getWebRootPath(); private static String[] supportTypes = FRContext.getFileNodes().getSupportedTypes(); static {