From 5f6e4f48edc6ffccc596b2b77b0572f0159ba82e Mon Sep 17 00:00:00 2001 From: Hades Date: Thu, 13 Feb 2020 16:23:47 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 8 ++--- .../java/com/fr/design/RestartHelper.java | 5 ++-- .../fr/design/mainframe/DesignerFrame.java | 5 ++-- .../java/com/fr/design/utils/DesignUtils.java | 6 ++-- .../main/java/com/fr/exit/DesignerExiter.java | 30 +++++++++++++++++++ .../main/java/com/fr/start/BaseDesigner.java | 6 ++-- .../start/CollectUserInformationDialog.java | 8 ++--- .../main/java/com/fr/start/MainDesigner.java | 3 +- .../com/fr/start/module/DesignerStartup.java | 5 ++-- 9 files changed, 47 insertions(+), 29 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/exit/DesignerExiter.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index ecdef3ed7..cfb488694 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -13,11 +13,10 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.DesignUtils; import com.fr.env.EnvListPane; +import com.fr.exit.DesignerExiter; import com.fr.general.GeneralContext; import com.fr.license.exception.RegistEditionException; import com.fr.log.FineLoggerFactory; -import com.fr.process.engine.core.FineProcessContext; -import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.AssistUtils; import com.fr.stable.EnvChangedListener; import com.fr.start.server.ServerTray; @@ -245,14 +244,13 @@ public class EnvChangeEntrance { @Override public void doOk() { if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); + DesignerExiter.getInstance().execute(); } } @Override public void doCancel() { - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); - } + DesignerExiter.getInstance().execute(); } }); envListDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index 10bee060e..596257d70 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -2,11 +2,10 @@ package com.fr.design; import com.fr.design.mainframe.DesignerContext; import com.fr.design.os.impl.RestartAction; +import com.fr.exit.DesignerExiter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; -import com.fr.process.engine.core.FineProcessContext; -import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.ArrayUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -154,7 +153,7 @@ public class RestartHelper { } finally { WorkContext.getCurrent().close(); frame.dispose(); - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); + DesignerExiter.getInstance().execute(); } } 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 14a566c73..718a9f50c 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 @@ -43,6 +43,7 @@ import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.event.EventDispatcher; import com.fr.exception.DecryptTemplateException; +import com.fr.exit.DesignerExiter; import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; @@ -54,8 +55,6 @@ import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; -import com.fr.process.engine.core.FineProcessContext; -import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; @@ -1161,7 +1160,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.dispose(); this.ad.shutDown(); - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); + DesignerExiter.getInstance().execute(); } // harry:添加程序外拖拽文件进来打开的功能 diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 93e3e0c1a..d8f5d0116 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -8,13 +8,12 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.UILookAndFeel; import com.fr.design.mainframe.DesignerContext; +import com.fr.exit.DesignerExiter; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; -import com.fr.process.engine.core.FineProcessContext; -import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.ArrayUtils; import com.fr.stable.CommonCodeUtils; import com.fr.stable.StableUtils; @@ -191,8 +190,7 @@ public class DesignUtils { } else if ("check".equals(line)) { clientSend(new String[] {"response"}, socket); } else if ("end".equals(line)) { - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); - } + DesignerExiter.getInstance().execute(); } else if (StringUtils.isNotEmpty(line)) { File f = new File(line); String path = f.getAbsolutePath(); diff --git a/designer-base/src/main/java/com/fr/exit/DesignerExiter.java b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java new file mode 100644 index 000000000..8264d8db9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java @@ -0,0 +1,30 @@ +package com.fr.exit; + +import com.fr.process.engine.core.FineProcessContext; +import com.fr.process.engine.core.FineProcessEngineEvent; +import com.fr.stable.StableUtils; + + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/12 + */ +public class DesignerExiter { + + public static final DesignerExiter INSTANCE = new DesignerExiter(); + + private static final String DOT = "."; + + public static DesignerExiter getInstance() { + return INSTANCE; + } + + public void execute() { + if (FineProcessContext.getParentPipe() == null && DOT.equals(StableUtils.getInstallHome())) { + System.exit(0); + } else { + FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); + } + } +} diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 5c0e8d013..a36c29822 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -14,18 +14,16 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.ui.util.UIUtil; -import com.fr.design.utils.DesignUtils; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.event.Null; +import com.fr.exit.DesignerExiter; import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; -import com.fr.process.engine.core.FineProcessContext; -import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.OperatingSystem; import java.awt.*; @@ -137,7 +135,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { if (!isException) { showDesignerFrame(true); } else { - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); + DesignerExiter.getInstance().execute(); } } } diff --git a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java index 0bfbbceab..f6a2f8500 100644 --- a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java +++ b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java @@ -11,13 +11,9 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.locale.impl.UserInfoMark; import com.fr.design.mainframe.ActiveKeyGenerator; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.CloudCenter; -import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralContext; +import com.fr.exit.DesignerExiter; import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleMark; -import com.fr.process.engine.core.FineProcessContext; -import com.fr.process.engine.core.FineProcessEngineEvent; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -157,7 +153,7 @@ public class CollectUserInformationDialog extends UIDialog { exitButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); + DesignerExiter.getInstance().execute(); } }); // set default pane. 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 56aa76389..ec32a6469 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -42,6 +42,7 @@ import com.fr.design.menu.ShortCut; import com.fr.design.module.DesignModuleFactory; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.exit.DesignerExiter; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.module.Module; @@ -130,7 +131,7 @@ public class MainDesigner extends BaseDesigner { @Override protected void okEvent() { dispose(); - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); + DesignerExiter.getInstance().execute(); } @Override diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 5f8ad4ed5..0adb4a6e2 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -13,11 +13,10 @@ import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignerPort; +import com.fr.exit.DesignerExiter; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; -import com.fr.process.engine.core.FineProcessContext; -import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.Metrics; import com.fr.stable.BuildContext; @@ -85,7 +84,7 @@ public class DesignerStartup extends Activator { }; dialog.setVisible(true); } - FineProcessContext.getChildPipe().fire(FineProcessEngineEvent.DESTROY); + DesignerExiter.getInstance().execute(); return; } // 快快显示启动画面