From 6374c2d6f20418b64c9278cae4bddeb815907687 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Fri, 19 Jul 2019 11:54:32 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-896=20=E4=BF=AE=E6=94=B9vcs=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vcs/VcsFolderManagerActivator.java | 17 +++++++++++++++++ .../vcs/common/VcsCacheFileNodeFile.java | 18 +++++++++--------- .../design/mainframe/vcs/common/VcsHelper.java | 8 ++++---- 3 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsFolderManagerActivator.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsFolderManagerActivator.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsFolderManagerActivator.java new file mode 100644 index 0000000000..cf44f12074 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsFolderManagerActivator.java @@ -0,0 +1,17 @@ +package com.fr.design.mainframe.vcs; + +import com.fr.module.Activator; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.vcs.VcsOperator; + +public class VcsFolderManagerActivator extends Activator { + @Override + public void start() { + WorkContext.getCurrent().get(VcsOperator.class).moveVscFolder(); + } + + @Override + public void stop() { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java index 40edc01f05..67ab8dfb06 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java @@ -8,6 +8,7 @@ import com.fr.stable.StableUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.resource.WorkResourceOutputStream; import com.fr.workspace.server.lock.TplOperator; +import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -34,16 +35,15 @@ public class VcsCacheFileNodeFile extends FileNodeFILE { if (node == null) { return null; } - + String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath(); String envPath = node.getEnvPath(); - // envPath必须以vcs开头 - if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) { + // envPath必须以VcsCacheRelativePath开头 + if (!envPath.startsWith(vcsCacheDir)) { return null; } - InputStream in = new ByteArrayInputStream( WorkContext.getCurrent().get(TplOperator.class).readAndLockFile( - StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1)) + StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1)) ) ); @@ -63,13 +63,13 @@ public class VcsCacheFileNodeFile extends FileNodeFILE { if (ComparatorUtils.equals(node, null)) { return null; } - + String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath(); String envPath = node.getEnvPath(); - // envPath必须以reportLets开头 - if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) { + // envPath必须以VcsCacheRelativePath开头 + if (!envPath.startsWith(vcsCacheDir)) { return null; } - return new WorkResourceOutputStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1))); + return new WorkResourceOutputStream(StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1))); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index fa649b66a5..0b3213ac52 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -19,6 +19,7 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; +import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import javax.swing.Icon; import javax.swing.border.EmptyBorder; @@ -45,8 +46,6 @@ public class VcsHelper implements JTemplateActionListener { public final static Icon VCS_USER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_user@1x.png"); public final static Icon VCS_REVERT = IOUtils.readIcon("/com/fr/design/images/vcs/icon_revert.png"); public final static int OFFSET = 2; - private final static String VCS_DIR = "vcs"; - public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache"); private static final int MINUTE = 60 * 1000; private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10"; private static final VcsHelper instance = new VcsHelper(); @@ -89,12 +88,13 @@ public class VcsHelper implements JTemplateActionListener { } private String getEditingFilename() { + String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath(); JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); String editingFilePath = jt.getEditingFILE().getPath(); if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) { editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY); - } else if (editingFilePath.startsWith(VcsHelper.VCS_CACHE_DIR)) { - editingFilePath = editingFilePath.replaceFirst(VcsHelper.VCS_CACHE_DIR, StringUtils.EMPTY); + } else if (editingFilePath.startsWith(vcsCacheDir)) { + editingFilePath = editingFilePath.replaceFirst(vcsCacheDir, StringUtils.EMPTY); } if (editingFilePath.startsWith("/")) { editingFilePath = editingFilePath.substring(1);