From 14d3a2ebfcccf712f2e969752711617fd433ea4e Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 12 Mar 2019 16:07:14 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-14787=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=8F=A6=E5=AD=98=E8=BF=87=E7=A8=8B=E4=B8=AD=E9=A2=91?= =?UTF-8?q?=E7=B9=81=E8=BF=9B=E8=A1=8CRPC=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/file/FileNodeFILE.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index 7f73fc708..dce2c38e0 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -7,6 +7,9 @@ import com.fr.design.file.NodeAuthProcessor; import com.fr.design.gui.itree.filetree.FileNodeComparator; import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.design.i18n.Toolkit; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.io.EncryptUtils; @@ -15,6 +18,8 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.resource.WorkResourceTempRenameStream; import com.fr.workspace.server.lock.TplOperator; @@ -26,6 +31,21 @@ import java.util.Arrays; public class FileNodeFILE implements FILE { + + private static String webRootPath = FRContext.getCommonOperator().getWebRootPath(); + private static String[] supportTypes = FRContext.getFileNodes().getSupportedTypes(); + + static { + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { + @Override + public void on(Event event, Workspace workspace) { + webRootPath = FRContext.getCommonOperator().getWebRootPath(); + supportTypes = FRContext.getFileNodes().getSupportedTypes(); + } + }); + } + + private FileNode node; //记录下FILE对应的运行环境,每次创建都设置下当前的运行环境 @@ -95,7 +115,7 @@ public class FileNodeFILE implements FILE { @Override public String prefix() { - if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebRootPath())) { + if (ComparatorUtils.equals(getEnvPath(), webRootPath)) { return FILEFactory.WEBREPORT_PREFIX; } return FILEFactory.ENV_PREFIX; @@ -212,7 +232,7 @@ public class FileNodeFILE implements FILE { try { FileNode[] nodeArray; nodeArray = listFile(node.getEnvPath()); - Arrays.sort(nodeArray, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes())); + Arrays.sort(nodeArray, new FileNodeComparator(supportTypes)); return fileNodeArray2FILEArray(nodeArray, envPath); } catch (Exception e) { @@ -235,7 +255,7 @@ public class FileNodeFILE implements FILE { private FileNode[] listFile(String rootFilePath) { try { - if (ComparatorUtils.equals(envPath, FRContext.getCommonOperator().getWebRootPath())) { + if (ComparatorUtils.equals(envPath, webRootPath)) { return FRContext.getFileNodes().listWebRootFile(rootFilePath); } else { return FRContext.getFileNodes().list(rootFilePath);