Browse Source

KERNEL-896 修改vcs目录位置

research/10.0
Hugh.C 5 years ago
parent
commit
6374c2d6f2
  1. 17
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsFolderManagerActivator.java
  2. 18
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java
  3. 8
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

17
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() {
}
}

18
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.WorkContext;
import com.fr.workspace.resource.WorkResourceOutputStream; import com.fr.workspace.resource.WorkResourceOutputStream;
import com.fr.workspace.server.lock.TplOperator; import com.fr.workspace.server.lock.TplOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
@ -34,16 +35,15 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
if (node == null) { if (node == null) {
return null; return null;
} }
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
String envPath = node.getEnvPath(); String envPath = node.getEnvPath();
// envPath必须以vcs开头 // envPath必须以VcsCacheRelativePath开头
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) { if (!envPath.startsWith(vcsCacheDir)) {
return null; return null;
} }
InputStream in = new ByteArrayInputStream( InputStream in = new ByteArrayInputStream(
WorkContext.getCurrent().get(TplOperator.class).readAndLockFile( 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)) { if (ComparatorUtils.equals(node, null)) {
return null; return null;
} }
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
String envPath = node.getEnvPath(); String envPath = node.getEnvPath();
// envPath必须以reportLets开头 // envPath必须以VcsCacheRelativePath开头
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) { if (!envPath.startsWith(vcsCacheDir)) {
return null; 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)));
} }
} }

8
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.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.border.EmptyBorder; 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_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 Icon VCS_REVERT = IOUtils.readIcon("/com/fr/design/images/vcs/icon_revert.png");
public final static int OFFSET = 2; 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 static final int MINUTE = 60 * 1000;
private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10"; private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
private static final VcsHelper instance = new VcsHelper(); private static final VcsHelper instance = new VcsHelper();
@ -89,12 +88,13 @@ public class VcsHelper implements JTemplateActionListener {
} }
private String getEditingFilename() { private String getEditingFilename() {
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editingFilePath = jt.getEditingFILE().getPath(); String editingFilePath = jt.getEditingFILE().getPath();
if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) { if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY); editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY);
} else if (editingFilePath.startsWith(VcsHelper.VCS_CACHE_DIR)) { } else if (editingFilePath.startsWith(vcsCacheDir)) {
editingFilePath = editingFilePath.replaceFirst(VcsHelper.VCS_CACHE_DIR, StringUtils.EMPTY); editingFilePath = editingFilePath.replaceFirst(vcsCacheDir, StringUtils.EMPTY);
} }
if (editingFilePath.startsWith("/")) { if (editingFilePath.startsWith("/")) {
editingFilePath = editingFilePath.substring(1); editingFilePath = editingFilePath.substring(1);

Loading…
Cancel
Save