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 98c079ee2b..6881c8445c 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -20,7 +20,7 @@ import com.fr.design.notification.NotificationCenter; import com.fr.design.utils.DesignUtils; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; -import com.fr.env.handler.RemoteDesignExceptionHandler; +import com.fr.env.handler.WorkspaceExceptionHandler; import com.fr.exit.DesignerExiter; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; @@ -139,7 +139,7 @@ public class EnvChangeEntrance { pluginErrorRemind(); } catch (Exception exception) { // 失败的处理 - RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); + WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); return false; } TemplateTreePane.getInstance().refreshDockingView(); @@ -436,7 +436,7 @@ public class EnvChangeEntrance { } }); if (e != null) { - RemoteDesignExceptionHandler.getInstance().handleInStart(e, workspaceInfo); + WorkspaceExceptionHandler.getInstance().handleInStart(e, workspaceInfo); } envListDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java index ef1f420d62..6bb8ec37a5 100644 --- a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -1,18 +1,37 @@ package com.fr.design.env; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; +import com.fr.locale.InterProviderFactory; +import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.exception.MainVersionNotMatchException; import java.io.File; +import java.util.Properties; /** * Created by juhaoyu on 2018/6/15. */ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { - + + private static final String REPORT_ENGINE_KEY = "report-engine-key"; + private static final String REPORT_ENGINE_JAR; + private static final String PROP_PATH = "/com/fr/env/jarVersion.properties"; + + static { + Properties properties = new Properties(); + try { + properties.load(LocalDesignerWorkspaceInfo.class.getResourceAsStream(PROP_PATH)); + } catch (Exception ignored) { + } + REPORT_ENGINE_JAR = properties.getProperty(REPORT_ENGINE_KEY, "default.jar"); + } + private String name; private String path; @@ -86,6 +105,14 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return false; } + File engineLib = new File(StableUtils.pathJoin(this.path, ProjectConstants.LIB_NAME, REPORT_ENGINE_JAR)); + // 非安装版本允许自由切换 + boolean notExistLib = !ComparatorUtils.equals(GeneralUtils.readFullBuildNO(), InterProviderFactory.getProvider().getLocText("Fine-Core_Basic_About_No_Build")) + && !engineLib.exists(); + if (notExistLib) { + throw new MainVersionNotMatchException(); + } + return true; } } diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 17dc72dba5..56f90e804e 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -21,7 +21,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.scrollruler.ModLineBorder; -import com.fr.env.handler.RemoteDesignExceptionHandler; +import com.fr.env.handler.WorkspaceExceptionHandler; import com.fr.stable.StringUtils; import com.fr.third.guava.base.Strings; import com.fr.workspace.WorkContext; @@ -596,7 +596,7 @@ public class RemoteEnvPane extends BasicBeanPane { } } catch (Exception e) { dialog.dispose(); - RemoteDesignExceptionHandler.getInstance().handleInTest(e, remoteEnv); + WorkspaceExceptionHandler.getInstance().handleInTest(e, remoteEnv); } dialogDownPane.remove(cancelButton); dialogDownPane.revalidate(); diff --git a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java b/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java similarity index 72% rename from designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java rename to designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java index 7e6154eeee..367cd6bbb6 100644 --- a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java @@ -1,5 +1,6 @@ package com.fr.env.handler; +import com.fr.base.exception.ExceptionDescriptor; import com.fr.design.EnvChangeEntrance; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; @@ -11,6 +12,7 @@ import com.fr.env.handler.impl.CommonHandler; import com.fr.env.handler.impl.ExecutionHandler; import com.fr.env.handler.impl.UnexpectedHandler; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import java.util.ArrayList; import java.util.List; import javax.swing.UIManager; @@ -23,11 +25,11 @@ import static javax.swing.JOptionPane.ERROR_MESSAGE; * @version 10.0 * Created by hades on 2021/8/5 */ -public class RemoteDesignExceptionHandler { +public class WorkspaceExceptionHandler { - private static final RemoteDesignExceptionHandler INSTANCE = new RemoteDesignExceptionHandler(); + private static final WorkspaceExceptionHandler INSTANCE = new WorkspaceExceptionHandler(); - public static RemoteDesignExceptionHandler getInstance() { + public static WorkspaceExceptionHandler getInstance() { return INSTANCE; } @@ -35,7 +37,7 @@ public class RemoteDesignExceptionHandler { private final List> switchList = new ArrayList<>(); - private RemoteDesignExceptionHandler() { + private WorkspaceExceptionHandler() { // 要保证顺序 testList.add(new CancelHandler()); testList.add(new ExecutionHandler()); @@ -65,11 +67,15 @@ public class RemoteDesignExceptionHandler { public void handleInSwitch(Throwable e, DesignerWorkspaceInfo workspaceInfo) { if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(), - Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon")); + if (e instanceof ExceptionDescriptor) { + new CommonHandler(true).handle(new RefWrapper(e, StringUtils.EMPTY)); + } else { + FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(), + Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon")); + } return; } handle(e, switchList, workspaceInfo); @@ -78,6 +84,7 @@ public class RemoteDesignExceptionHandler { public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) { if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + new CommonHandler(false).handle(new RefWrapper(e, StringUtils.EMPTY)); return; } handle(e, testList, workspaceInfo); diff --git a/designer-base/src/main/resources/com/fr/env/jarVersion.properties b/designer-base/src/main/resources/com/fr/env/jarVersion.properties new file mode 100644 index 0000000000..8619fca7c3 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/env/jarVersion.properties @@ -0,0 +1 @@ +report-engine-key=fine-report-engine-10.0.jar \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index d5b6cdb632..0035e1e608 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -9,7 +9,6 @@ import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.versioncheck.VersionCheckUtils; -import com.fr.env.handler.RemoteDesignExceptionHandler; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener;