From c99f35854f5798f9ed967a94be5df4f5d6beb674 Mon Sep 17 00:00:00 2001 From: "Mata.Li" Date: Wed, 11 Jul 2018 11:08:08 +0800 Subject: [PATCH] REPORT-9480 & REPORT-9159 --- .../java/com/fr/design/DesignerEnvManager.java | 17 +++++++++++------ .../src/main/java/com/fr/start/Demo.java | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) 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 856a5a9e1b..28d532d87f 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -67,6 +67,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static final int MAX_SHOW_NUM = 10; private static final String VERSION_80 = "80"; private static final int CACHINGTEMPLATE_LIMIT = 5; + private static final String WEB_NAME = "webapps"; private static DesignerEnvManager designerEnvManager; // gui. private String activationKey = null; @@ -200,10 +201,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (designerEnvManager == null || designerEnvManager.nameEnvMap.size() > 0) { return; } - String installHome = StableUtils.getInstallHome(); + String installHome = StableUtils.getInstallHome(); if (installHome != null && !".".equals(installHome)) { String name = Inter.getLocText("FR-Engine_DEFAULT"); - String envPath = StableUtils.pathJoin(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); + String envPath = designerEnvManager.getDefaultenvPath(installHome); designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath)); designerEnvManager.setCurEnvName(name); } @@ -486,8 +487,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public boolean isCurrentEnvDefault() { DesignerWorkspaceInfo current = this.getWorkspaceInfo(curEnvName); - String defaultEnvPath = StableUtils.pathJoin(new String[]{StableUtils.getInstallHome(), ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); - return ComparatorUtils.equals(new File(defaultEnvPath).getPath(), current.getPath()); + String defaultEnvPath = getDefaultenvPath(StableUtils.getInstallHome()); + return ComparatorUtils.equals(defaultEnvPath, current.getPath()); } /** @@ -495,7 +496,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { */ public DesignerWorkspaceInfo getDefaultConfig() { String installHome = StableUtils.getInstallHome(); - String defaultenvPath = StableUtils.pathJoin(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); + String defaultenvPath = getDefaultenvPath(installHome); defaultenvPath = new File(defaultenvPath).getPath(); Iterator> entryIt = nameEnvMap.entrySet().iterator(); while (entryIt.hasNext()) { @@ -516,7 +517,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { */ public String getDefaultEnvName() { String installHome = StableUtils.getInstallHome(); - String defaultenvPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); + String defaultenvPath = getDefaultenvPath(installHome); defaultenvPath = new File(defaultenvPath).getPath(); if (nameEnvMap.size() >= 0) { Iterator> entryIt = nameEnvMap.entrySet().iterator(); @@ -531,6 +532,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}); } + + private String getDefaultenvPath(String installHome){ + return StableUtils.pathJoin(installHome, WEB_NAME, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); + } /** * 设置当前环境为默认 */ diff --git a/designer-base/src/main/java/com/fr/start/Demo.java b/designer-base/src/main/java/com/fr/start/Demo.java index 672d618444..4296f5d549 100644 --- a/designer-base/src/main/java/com/fr/start/Demo.java +++ b/designer-base/src/main/java/com/fr/start/Demo.java @@ -5,6 +5,7 @@ import com.fr.base.FRContext; import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; +import java.io.File; import java.io.IOException; public class Demo { @@ -20,7 +21,8 @@ public class Demo { if (OperatingSystem.isMacOS()) { executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app"); } else { - executorPath = StableUtils.pathJoin(installHome, "bin", "designer.exe demo"); + //转成反斜杠格式 + executorPath = new File(StableUtils.pathJoin(installHome, "bin", "designer.exe demo")).getPath(); } if (!new java.io.File(executorPath).exists()) { FRContext.getLogger().error(executorPath + " can not be found.");