|
|
@ -24,19 +24,19 @@ import com.fr.plugin.manage.PluginManager; |
|
|
|
import com.fr.report.entity.VcsEntity; |
|
|
|
import com.fr.report.entity.VcsEntity; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
|
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.Workspace; |
|
|
|
import com.fr.workspace.Workspace; |
|
|
|
import com.fr.workspace.WorkspaceEvent; |
|
|
|
import com.fr.workspace.WorkspaceEvent; |
|
|
|
|
|
|
|
import com.fr.workspace.server.entity.vcs.VcsBean; |
|
|
|
|
|
|
|
import com.fr.workspace.server.entity.vcs.VcsQuery; |
|
|
|
|
|
|
|
import com.fr.workspace.server.repository.vcs.VcsRepository; |
|
|
|
import com.fr.workspace.server.vcs.VcsFileUtils; |
|
|
|
import com.fr.workspace.server.vcs.VcsFileUtils; |
|
|
|
import com.fr.workspace.server.vcs.VcsOperator; |
|
|
|
import com.fr.workspace.server.vcs.VcsOperator; |
|
|
|
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; |
|
|
|
|
|
|
|
import com.fr.workspace.server.vcs.git.config.GcConfig; |
|
|
|
import com.fr.workspace.server.vcs.git.config.GcConfig; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
|
|
|
|
import javax.swing.border.EmptyBorder; |
|
|
|
import javax.swing.border.EmptyBorder; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.*; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.Executors; |
|
|
@ -84,7 +84,7 @@ public class VcsHelper implements JTemplateActionListener { |
|
|
|
// 开了设计器启动页面时一开始取不到VcsOperator,通过下面的切换环境事件再取,这边判断下
|
|
|
|
// 开了设计器启动页面时一开始取不到VcsOperator,通过下面的切换环境事件再取,这边判断下
|
|
|
|
if (op != null) { |
|
|
|
if (op != null) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
legacyMode = op.isLegacyMode(); |
|
|
|
legacyMode = VcsRepository.getInstance().isLegacyMode(); |
|
|
|
root = WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot(); |
|
|
|
root = WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
legacyMode = true; |
|
|
|
legacyMode = true; |
|
|
@ -96,7 +96,7 @@ public class VcsHelper implements JTemplateActionListener { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void on(Event event) { |
|
|
|
protected void on(Event event) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); |
|
|
|
legacyMode = VcsRepository.getInstance().isLegacyMode(); |
|
|
|
FineLoggerFactory.getLogger().info("[VcsHelper] legacyMode:{}", legacyMode); |
|
|
|
FineLoggerFactory.getLogger().info("[VcsHelper] legacyMode:{}", legacyMode); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
//保险起见走老逻辑
|
|
|
|
//保险起见走老逻辑
|
|
|
@ -217,22 +217,22 @@ public class VcsHelper implements JTemplateActionListener { |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
String fileName = getEditingFilename(); |
|
|
|
String fileName = getEditingFilename(); |
|
|
|
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); |
|
|
|
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); |
|
|
|
VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); |
|
|
|
VcsEntity entity = VcsRepository.getInstance().getVersion(new VcsQuery(fileName, 0, null, null)); |
|
|
|
boolean replace = needDeleteVersion(entity); |
|
|
|
boolean replace = needDeleteVersion(entity); |
|
|
|
int latestFileVersion = 0; |
|
|
|
int latestFileVersion = 0; |
|
|
|
if (entity != null) { |
|
|
|
if (entity != null) { |
|
|
|
latestFileVersion = entity.getVersion(); |
|
|
|
latestFileVersion = entity.getVersion(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { |
|
|
|
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { |
|
|
|
operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); |
|
|
|
VcsRepository.getInstance().saveVersionFromCache(new VcsBean(new VcsEntity(getCurrentUsername(), StringUtils.EMPTY, fileName, null, null, latestFileVersion + 1), replace)); |
|
|
|
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); |
|
|
|
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); |
|
|
|
List<VcsEntity> updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); |
|
|
|
List<VcsEntity> updatedList = VcsRepository.getInstance().getVersions(new VcsQuery(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY))); |
|
|
|
SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); |
|
|
|
SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); |
|
|
|
VcsRepository.getInstance().saveVersion(new VcsBean(new VcsEntity(getCurrentUsername(), StringUtils.EMPTY, fileName, null, null, latestFileVersion + 1), replace).setUseVersion(true)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (GcConfig.getInstance().isGcEnable()) { |
|
|
|
if (GcConfig.getInstance().isGcEnable()) { |
|
|
|
operator.gc(); |
|
|
|
VcsRepository.getInstance().gc(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -252,21 +252,20 @@ public class VcsHelper implements JTemplateActionListener { |
|
|
|
moveVcs.execute(new Runnable() { |
|
|
|
moveVcs.execute(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); |
|
|
|
|
|
|
|
String oldPath = oldName.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY); |
|
|
|
String oldPath = oldName.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY); |
|
|
|
List<VcsEntity> oldVcsEntities = operator.getVersions(oldPath); |
|
|
|
List<VcsEntity> oldVcsEntities = VcsRepository.getInstance().getVersions(new VcsQuery(oldPath)); |
|
|
|
String replaceName = newName.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY); |
|
|
|
String replaceName = newName.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY); |
|
|
|
for (VcsEntity oldVcsEntity : oldVcsEntities) { |
|
|
|
for (VcsEntity oldVcsEntity : oldVcsEntities) { |
|
|
|
if (!VcsHelper.getInstance().isLegacyMode()) { |
|
|
|
if (!VcsHelper.getInstance().isLegacyMode()) { |
|
|
|
operator.renameVersion(oldVcsEntity, replaceName); |
|
|
|
VcsRepository.getInstance().renameVersion(new VcsBean(oldVcsEntity, replaceName)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
operator.saveVersion(oldVcsEntity.getUsername(), replaceName, oldVcsEntity.getCommitMsg(), oldVcsEntity.getVersion()); |
|
|
|
VcsRepository.getInstance().saveVersion(new VcsBean(new VcsEntity(oldVcsEntity.getUsername(), oldVcsEntity.getCommitMsg(), replaceName, null, null, oldVcsEntity.getVersion())).setUseVersion(true)); |
|
|
|
operator.deleteVersion(oldPath, oldVcsEntity.getVersion()); |
|
|
|
VcsRepository.getInstance().deleteVersion(new VcsBean(new VcsEntity(null, null, oldPath, null, null, oldVcsEntity.getVersion()))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
FineLoggerFactory.getLogger().debug("moveVcs success. from {} to {}", oldName, replaceName); |
|
|
|
FineLoggerFactory.getLogger().debug("moveVcs success. from {} to {}", oldName, replaceName); |
|
|
|
if (GcConfig.getInstance().isGcEnable() && VcsHelper.getInstance().isLegacyMode()) { |
|
|
|
if (GcConfig.getInstance().isGcEnable() && VcsHelper.getInstance().isLegacyMode()) { |
|
|
|
operator.gc(); |
|
|
|
VcsRepository.getInstance().gc(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -314,7 +313,7 @@ public class VcsHelper implements JTemplateActionListener { |
|
|
|
public void fireAutoSaveVcs(final JTemplate jt) { |
|
|
|
public void fireAutoSaveVcs(final JTemplate jt) { |
|
|
|
String fileName = getEditingFilename(); |
|
|
|
String fileName = getEditingFilename(); |
|
|
|
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); |
|
|
|
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); |
|
|
|
VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); |
|
|
|
VcsEntity entity = VcsRepository.getInstance().getVersion(new VcsQuery(fileName, 0, null, null)); |
|
|
|
boolean replace = needDeleteVersion(entity); |
|
|
|
boolean replace = needDeleteVersion(entity); |
|
|
|
int latestFileVersion = 0; |
|
|
|
int latestFileVersion = 0; |
|
|
|
if (entity != null) { |
|
|
|
if (entity != null) { |
|
|
@ -327,22 +326,22 @@ public class VcsHelper implements JTemplateActionListener { |
|
|
|
|
|
|
|
|
|
|
|
private void doSave(JTemplate jt, String fileName, int latestFileVersion, boolean replace, VcsOperator operator) { |
|
|
|
private void doSave(JTemplate jt, String fileName, int latestFileVersion, boolean replace, VcsOperator operator) { |
|
|
|
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { |
|
|
|
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { |
|
|
|
operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); |
|
|
|
VcsRepository.getInstance().saveVersionFromCache(new VcsBean(new VcsEntity(getCurrentUsername(), StringUtils.EMPTY, fileName, null, null, latestFileVersion + 1), replace)); |
|
|
|
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); |
|
|
|
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); |
|
|
|
List<VcsEntity> updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); |
|
|
|
List<VcsEntity> updatedList = VcsRepository.getInstance().getVersions(new VcsQuery(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY))); |
|
|
|
SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); |
|
|
|
SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
autoSave(jt, getCurrentUsername(), fileName, latestFileVersion + 1, replace, operator); |
|
|
|
autoSave(jt, getCurrentUsername(), fileName, latestFileVersion + 1, replace, operator); |
|
|
|
} |
|
|
|
} |
|
|
|
if (GcConfig.getInstance().isGcEnable()) { |
|
|
|
if (GcConfig.getInstance().isGcEnable()) { |
|
|
|
operator.gc(); |
|
|
|
VcsRepository.getInstance().gc(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void autoSave(JTemplate jt, String currentUsername, String fileName, int nowVersion, boolean replace, VcsOperator operator) { |
|
|
|
private void autoSave(JTemplate jt, String currentUsername, String fileName, int nowVersion, boolean replace, VcsOperator operator) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (JTemplate.isValid(jt) && !jt.isALLSaved()) { |
|
|
|
if (JTemplate.isValid(jt) && !jt.isALLSaved()) { |
|
|
|
operator.autoSave(currentUsername, fileName, StringUtils.EMPTY, nowVersion, jt.exportData(), replace); |
|
|
|
VcsRepository.getInstance().autoSave(new VcsBean(new VcsEntity(currentUsername, StringUtils.EMPTY, fileName, null, null, nowVersion), replace, jt.exportData())); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage()); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage()); |
|
|
|