diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index fcf0091c6c..cd030145cf 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -87,6 +87,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static final int MAX_SHOW_NUM = 10; private static final String VERSION_80 = "80"; + private static final String VERSION_90 = "90"; + private static final String VERSION100 = "100"; private static final int CACHINGTEMPLATE_LIMIT = 5; private static final String WEB_NAME = "webapps"; /** @@ -354,14 +356,21 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { try { fileWriter = new FileWriter(envFile); File oldEnvFile = new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "6-1" + "Env.xml"); - File envFile80 = new File(getEnvHome(VERSION_80) + File.separator + getEnvFile().getName()); - if (oldEnvFile.exists()) { + File envFile80 = getOldEnvFile(VERSION_80); + File envFile90 = getOldEnvFile(VERSION_90); + File envFile100 = getOldEnvFile(VERSION100); + // 从10.0往前递进是否存在更老版本的配置文件 + if (envFile100.exists()) { + compatibilityPrevVersion(envFile90); + } else if (envFile90.exists()) { + compatibilityPrevVersion(envFile90); + } else if (envFile80.exists()) { + compatibilityPrevVersion(envFile80); + } else if (oldEnvFile.exists()) { // marks:兼容DesignerEnv6-1.xml FileReader fileReader = new FileReader(oldEnvFile); Utils.copyCharTo(fileReader, fileWriter); fileReader.close(); - } else if (envFile80.exists()) { - compatibilityPrevVersion(envFile80); } else { // marks:生成一个新的xml文件 StringReader stringReader = new StringReader(""); @@ -383,6 +392,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } + private File getOldEnvFile(String version) { + return new File(getEnvHome(version) + File.separator + getEnvFile().getName()); + } + private static String getEnvHome(String version) { String userHome = System.getProperty("user.home"); if (userHome == null) { 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 da891c5f69..ec1816e4dd 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,17 +1,35 @@ 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; + + static { + Properties properties = new Properties(); + try { + properties.load(LocalDesignerWorkspaceInfo.class.getResourceAsStream("")); + } catch (Exception ignored) { + } + REPORT_ENGINE_JAR = properties.getProperty(REPORT_ENGINE_KEY, "default.jar"); + } private String name; @@ -86,7 +104,13 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return false; } - + File engineLib = new File(StableUtils.pathJoin(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..ae214d2428 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..7eff54deba --- /dev/null +++ b/designer-base/src/main/resources/com/fr/env/jarVersion.properties @@ -0,0 +1 @@ +report-engine-key=fine-report-engine-11.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;