From 630e28c14701ed8ea2bf808c455b4443ef2c7483 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 27 Mar 2020 21:46:35 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-28830=20=E6=8F=90=E7=A4=BA=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/common/report/ReportState.java | 21 +++++++++++++++ .../java/com/fr/design/EnvChangeEntrance.java | 11 +++++++- .../env/DesignerWorkspaceGenerator.java | 9 ++++++- .../com/fr/start/DesignerSuperListener.java | 26 +++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/common/report/ReportState.java diff --git a/designer-base/src/main/java/com/fr/common/report/ReportState.java b/designer-base/src/main/java/com/fr/common/report/ReportState.java new file mode 100644 index 000000000..cc32e439c --- /dev/null +++ b/designer-base/src/main/java/com/fr/common/report/ReportState.java @@ -0,0 +1,21 @@ +package com.fr.common.report; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/27 + */ +public enum ReportState { + + STOP("stop"), ACTIVE("active"); + + private String value; + + ReportState(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } +} \ No newline at end of file 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 43c829822..81e62239b 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -1,5 +1,6 @@ package com.fr.design; +import com.fr.common.report.ReportState; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -24,6 +25,9 @@ import com.fr.json.JSONArray; import com.fr.license.exception.RegistEditionException; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; +import com.fr.process.ProcessEventPipe; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; import com.fr.rpc.Result; import com.fr.stable.AssistUtils; import com.fr.stable.EnvChangedListener; @@ -407,6 +411,10 @@ public class EnvChangeEntrance { @Override public void doOk() { + ProcessEventPipe pipe = FineProcessContext.getParentPipe(); + if (FineProcessContext.getParentPipe() != null) { + pipe.fire(new CarryMessageEvent(ReportState.ACTIVE.getValue())); + } if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { DesignerExiter.getInstance().execute(); } @@ -414,7 +422,8 @@ public class EnvChangeEntrance { @Override public void doCancel() { - DesignerExiter.getInstance().execute(); } + DesignerExiter.getInstance().execute(); + } }); envListDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java index f77debe66..ccbd5170c 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java @@ -1,5 +1,6 @@ package com.fr.design.env; +import com.fr.common.report.ReportState; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.EnvChangeEntrance; import com.fr.design.dialog.FineJOptionPane; @@ -8,6 +9,9 @@ import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; +import com.fr.process.ProcessEventPipe; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; @@ -67,6 +71,10 @@ public class DesignerWorkspaceGenerator { enum RemoteHandler { SELF; public static void handle(DesignerWorkspaceInfo config) { + ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); + if (eventPipe != null) { + eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); + } StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(), DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(), StringUtils.EMPTY); @@ -85,7 +93,6 @@ public class DesignerWorkspaceGenerator { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } else { - EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(); } } } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java b/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java index db8e532dc..ebf135d26 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java @@ -1,5 +1,6 @@ package com.fr.start; +import com.fr.common.report.ReportState; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.dialog.ErrorDialog; import com.fr.design.i18n.Toolkit; @@ -9,12 +10,14 @@ import com.fr.design.utils.DesignUtils; import com.fr.event.Event; import com.fr.event.Listener; import com.fr.event.Null; +import com.fr.general.ComparatorUtils; import com.fr.process.FineProcess; import com.fr.process.ProcessEventPipe; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.StringUtils; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -33,10 +36,12 @@ public class DesignerSuperListener { private static final int FIXED_FREQ = 2; private final ScheduledExecutorService service = Executors.newScheduledThreadPool(2, new NamedThreadFactory("DesignerListener")); + private final ExecutorService helpService = Executors.newSingleThreadExecutor( new NamedThreadFactory("DesignerSuperListener-Help")); private FineProcess process; private ScheduledFuture fixedFuture; private ScheduledFuture onceFuture; + private volatile boolean cancel = false; private DesignerSuperListener() { @@ -49,6 +54,7 @@ public class DesignerSuperListener { public void start() { process = FineProcessContext.getProcess(DesignerProcessType.INSTANCE); startExitListener(); + startHelpLister(); startFrameListener(); startFallBackListener(); } @@ -62,6 +68,24 @@ public class DesignerSuperListener { }); } + private void startHelpLister() { + helpService.submit(new Runnable() { + @Override + public void run() { + while (!cancel) { + ProcessEventPipe pipe = process.getPipe(); + String msg = pipe.info(); + if (ComparatorUtils.equals(ReportState.STOP.getValue(), msg)) { + onceFuture.cancel(false); + } + if (ComparatorUtils.equals(ReportState.ACTIVE.getValue(), msg)) { + startFrameListener(); + } + } + } + }); + } + private void startFrameListener() { onceFuture = service.schedule(new Runnable() { @Override @@ -138,10 +162,12 @@ public class DesignerSuperListener { public void stopTask() { onceFuture.cancel(false); fixedFuture.cancel(false); + cancel = true; } public void stop() { stopTask(); service.shutdown(); + helpService.shutdown(); } }