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