Browse Source

REPORT-135233 调整VcsOperator

fbp/merge
Destiny.Lin 3 months ago
parent
commit
4ab941d666
  1. 3
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 26
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  3. 20
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java
  4. 45
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  5. 19
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java
  6. 5
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java
  7. 18
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java
  8. 20
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java
  9. 16
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java
  10. 11
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java
  11. 13
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java
  12. 21
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java

3
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -64,7 +64,6 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.server.entity.vcs.VcsTaskBean; import com.fr.workspace.server.entity.vcs.VcsTaskBean;
import com.fr.workspace.server.repository.vcs.VcsRepository; import com.fr.workspace.server.repository.vcs.VcsRepository;
import com.fr.workspace.server.vcs.VcsConfig; import com.fr.workspace.server.vcs.VcsConfig;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.git.config.GcConfig; import com.fr.workspace.server.vcs.git.config.GcConfig;
import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanSchedule; import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanSchedule;
import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanService; import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanService;
@ -1214,7 +1213,7 @@ public class PreferencePane extends BasicPane {
@Override @Override
protected Boolean doInBackground() { protected Boolean doInBackground() {
size = WorkContext.getCurrent().get(VcsOperator.class).immediatelyGc(); size = VcsRepository.getInstance().immediatelyGc();
return true; return true;
} }

26
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -3,6 +3,7 @@
*/ */
package com.fr.design.file; package com.fr.design.file;
import com.fanruan.repository.TemplateRepository;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.cache.DesignCacheManager; import com.fr.design.cache.DesignCacheManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
@ -11,10 +12,10 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.lock.LockInfoDialog;
import com.fr.design.lock.LockInfoUtils; import com.fr.design.lock.LockInfoUtils;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.lock.LockInfoDialog;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import com.fr.design.mainframe.manager.search.searcher.control.pane.TemplateSearchRemindPane; import com.fr.design.mainframe.manager.search.searcher.control.pane.TemplateSearchRemindPane;
@ -27,25 +28,20 @@ import com.fr.form.fit.web.editpreview.FileLockStateObservable;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.workspace.base.UserInfo;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
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.base.UserInfo;
import com.fr.workspace.server.repository.vcs.VcsRepository;
import org.jetbrains.annotations.Nullable;
import java.util.UUID; import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.ToolTipManager;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode; import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
@ -60,14 +56,10 @@ import java.util.Objects;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.fanruan.repository.TemplateRepository;
import com.fr.workspace.server.vcs.VcsOperator;
import org.jetbrains.annotations.Nullable;
import static javax.swing.JOptionPane.WARNING_MESSAGE; import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION; import static javax.swing.JOptionPane.YES_NO_OPTION;
@ -408,7 +400,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (nodeFILE.exists()) { if (nodeFILE.exists()) {
if (!VcsHelper.getInstance().isLegacyMode()) { if (!VcsHelper.getInstance().isLegacyMode()) {
try { try {
WorkContext.getCurrent().get(VcsOperator.class).recycleVersion(VcsHelper.getInstance().getCurrentUsername(), nodeFILE.getPath()); VcsRepository.getInstance().recycleVersion(VcsHelper.getInstance().getCurrentUsername(), nodeFILE.getPath());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error("[VcsV2] recycle {} failed", nodeFILE.getName()); FineLoggerFactory.getLogger().error("[VcsV2] recycle {} failed", nodeFILE.getName());
} }

20
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java

@ -9,12 +9,12 @@ import com.fr.log.FineLoggerFactory;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.entity.vcs.VcsBean;
import com.fr.workspace.server.repository.vcs.VcsRepository;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.v2.VcsTaskResult; import com.fr.workspace.server.vcs.v2.VcsTaskResult;
import javax.swing.SwingUtilities; import javax.swing.*;
import javax.swing.SwingWorker;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -108,7 +108,7 @@ public class VcsOperatorWorker {
VcsProcessFailedWrapper wrapper = new VcsProcessFailedWrapper(); VcsProcessFailedWrapper wrapper = new VcsProcessFailedWrapper();
startProcess(vcsEntities, wrapper, (vcsEntity, operator) -> { startProcess(vcsEntities, wrapper, (vcsEntity, operator) -> {
String fileName = vcsEntity.getFilename(); String fileName = vcsEntity.getFilename();
VcsTaskResult result = operator.restoreVersion(fileName); VcsTaskResult result = VcsRepository.getInstance().restoreVersion(fileName);
if (!result.isSuccess()) { if (!result.isSuccess()) {
wrapper.addFailedEntity(vcsEntity); wrapper.addFailedEntity(vcsEntity);
} }
@ -129,9 +129,9 @@ public class VcsOperatorWorker {
String fileName = vcsEntity.getFilename(); String fileName = vcsEntity.getFilename();
VcsTaskResult result; VcsTaskResult result;
if (all) { if (all) {
result = operator.deleteVersionForRecycle(fileName); result = VcsRepository.getInstance().deleteVersionForRecycle(fileName);
} else { } else {
result = operator.deleteVersion(fileName, vcsEntity.getVersion(), VcsEntity.CommitType.TYPE_DEFAULT); result = VcsRepository.getInstance().deleteVersion(new VcsBean(new VcsEntity(null, null, fileName, null, null, vcsEntity.getVersion(), 0, VcsEntity.CommitType.TYPE_DEFAULT)));
} }
if (!result.isSuccess()) { if (!result.isSuccess()) {
wrapper.addFailedEntity(vcsEntity); wrapper.addFailedEntity(vcsEntity);
@ -148,7 +148,7 @@ public class VcsOperatorWorker {
*/ */
public void doDelete(VcsEntity entity, VcsTableOperatorListener listener) { public void doDelete(VcsEntity entity, VcsTableOperatorListener listener) {
String fileName = entity.getFilename(); String fileName = entity.getFilename();
start4Single(entity, (vcsEntity, operator) -> operator.deleteVersionForRecycle(fileName), fileName + everyFailedStr, listener); start4Single(entity, (vcsEntity, operator) -> VcsRepository.getInstance().deleteVersionForRecycle(fileName), fileName + everyFailedStr, listener);
} }
/** /**
@ -160,7 +160,9 @@ public class VcsOperatorWorker {
String fileName = entity.getFilename(); String fileName = entity.getFilename();
int version = entity.getVersion(); int version = entity.getVersion();
VcsEntity.CommitType commitType = entity.getCommitType(); VcsEntity.CommitType commitType = entity.getCommitType();
start4Single(entity, (vcsEntity, operator) -> operator.deleteVersion(fileName, version, commitType), fileName + everyFailedStr, listener); start4Single(entity, (vcsEntity, operator) ->
VcsRepository.getInstance().deleteVersion(new VcsBean(new VcsEntity(null, null, fileName, null, null, version, 0, commitType))),
fileName + everyFailedStr, listener);
} }
@ -171,7 +173,7 @@ public class VcsOperatorWorker {
*/ */
public void updateEntityAnnotation(VcsEntity entity, VcsTableOperatorListener listener) { public void updateEntityAnnotation(VcsEntity entity, VcsTableOperatorListener listener) {
start4Single(entity, (vcsEntity, operator) -> { start4Single(entity, (vcsEntity, operator) -> {
operator.updateVersion(entity); VcsRepository.getInstance().updateVersion(new VcsBean(entity));
return new VcsTaskResult(true); return new VcsTaskResult(true);
}, everyFailedStr, listener); }, everyFailedStr, listener);
} }

45
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -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());

19
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java

@ -18,14 +18,12 @@ import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.server.entity.vcs.VcsBean;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.entity.vcs.VcsQuery;
import com.fr.workspace.server.repository.vcs.VcsRepository;
import javax.swing.JPanel;
import java.awt.BorderLayout; import javax.swing.*;
import java.awt.Component; import java.awt.*;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -118,11 +116,12 @@ public class EditFileVersionDialog extends UIDialog {
*/ */
public void doOK() { public void doOK() {
entity.setCommitMsg(msgTestArea.getText()); entity.setCommitMsg(msgTestArea.getText());
WorkContext.getCurrent().get(VcsOperator.class).updateVersion(entity); VcsRepository.getInstance().updateVersion(new VcsBean(entity));
setVisible(false); setVisible(false);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
FileVersionTable table = FileVersionTable.getInstance(); FileVersionTable table = FileVersionTable.getInstance();
table.updateModel(table.getSelectedRow(), WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", StringUtils.EMPTY)));
table.updateModel(table.getSelectedRow(), VcsRepository.getInstance().getVersions(new VcsQuery(path.replaceFirst("/", StringUtils.EMPTY))));
} }
public UITextArea getMsgTestArea() { public UITextArea getMsgTestArea() {

5
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java

@ -13,6 +13,7 @@ import com.fr.report.entity.VcsEntity;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.repository.vcs.VcsRepository;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.AbstractCellEditor; import javax.swing.AbstractCellEditor;
@ -43,10 +44,10 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe
return editor; return editor;
} else if (row == 0) { } else if (row == 0) {
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
fileOfVersion = vcsOperator.getFileOfCurrent(path.replaceFirst("/", "")); fileOfVersion = VcsRepository.getInstance().getFileOfCurrent(path.replaceFirst("/", ""));
} else { } else {
renderAndEditor.update((VcsEntity) value); renderAndEditor.update((VcsEntity) value);
fileOfVersion = vcsOperator.getFileOfFileVersion(((VcsEntity) value).getFilename(), ((VcsEntity) value).getVersion()); fileOfVersion = VcsRepository.getInstance().getFileOfFileVersion(((VcsEntity) value).getFilename(), ((VcsEntity) value).getVersion(), StringUtils.EMPTY);
} }

18
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java

@ -1,6 +1,5 @@
package com.fr.design.mainframe.vcs.ui; package com.fr.design.mainframe.vcs.ui;
import com.fr.analysis.cloud.DateUtils;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.editor.editor.DateEditor; import com.fr.design.editor.editor.DateEditor;
import com.fr.design.gui.date.UIDatePicker; import com.fr.design.gui.date.UIDatePicker;
@ -11,18 +10,11 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.server.entity.vcs.VcsQuery;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.repository.vcs.VcsRepository;
import javax.swing.AbstractAction; import javax.swing.*;
import javax.swing.BorderFactory; import java.awt.*;
import javax.swing.Box;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Calendar; import java.util.Calendar;
@ -70,7 +62,7 @@ public class FileVersionDialog extends UIDialog {
Date editorDate = dateEditor.getValue(); Date editorDate = dateEditor.getValue();
Date start = editorDate == null ? new Date(0) : editorDate; Date start = editorDate == null ? new Date(0) : editorDate;
Date end = editorDate == null ? getLastHour() : new Date(start.getTime() + DELAY); Date end = editorDate == null ? getLastHour() : new Date(start.getTime() + DELAY);
List<VcsEntity> vcsEntities = WorkContext.getCurrent().get(VcsOperator.class).getFilterVersions(fileName, start, end, textField.getText()); List<VcsEntity> vcsEntities = VcsRepository.getInstance().getVersions(new VcsQuery(fileName, start, end, textField.getText()));
FileVersionTable.getInstance().updateModel(1, vcsEntities); FileVersionTable.getInstance().updateModel(1, vcsEntities);
} }

20
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java

@ -10,19 +10,16 @@ import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.server.entity.vcs.VcsBean;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.entity.vcs.VcsQuery;
import com.fr.workspace.server.repository.vcs.VcsRepository;
import javax.swing.Box; import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.Style; import javax.swing.text.Style;
import javax.swing.text.StyleConstants; import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument; import javax.swing.text.StyledDocument;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -65,7 +62,7 @@ public class FileVersionRowPanel extends JPanel {
if (FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Title"), if (FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Title"),
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
vcsEntity.setUsername(VcsHelper.getInstance().getCurrentUsername()); vcsEntity.setUsername(VcsHelper.getInstance().getCurrentUsername());
WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(vcsEntity); VcsRepository.getInstance().rollbackTo(new VcsBean(vcsEntity));
FileVersionsPanel.getInstance().exitVcs(vcsEntity.getFilename()); FileVersionsPanel.getInstance().exitVcs(vcsEntity.getFilename());
} }
} }
@ -79,14 +76,15 @@ public class FileVersionRowPanel extends JPanel {
if (FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Delete-Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Remove"), if (FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Delete-Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Remove"),
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
try { try {
WorkContext.getCurrent().get(VcsOperator.class).deleteVersion(vcsEntity.getFilename(), vcsEntity.getVersion()); VcsRepository.getInstance().deleteVersion(new VcsBean(new VcsEntity(null, null, vcsEntity.getFilename(), null, null, vcsEntity.getVersion())));
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }
FileVersionTable table = (FileVersionTable) (FileVersionRowPanel.this.getParent()); FileVersionTable table = (FileVersionTable) (FileVersionRowPanel.this.getParent());
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
try { try {
table.updateModel(table.getSelectedRow() - 1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", ""))); table.updateModel(table.getSelectedRow() - 1,
VcsRepository.getInstance().getVersions(new VcsQuery(path.replaceFirst("/", ""))));
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }

16
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java

@ -20,14 +20,11 @@ import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.server.entity.vcs.VcsQuery;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.repository.vcs.VcsRepository;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.Box; import java.awt.*;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -134,7 +131,8 @@ public class FileVersionsPanel extends BasicPane {
} }
titleLabel.setText(filename); titleLabel.setText(filename);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", "")));
FileVersionTable.getInstance().updateModel(1, VcsRepository.getInstance().getVersions(new VcsQuery(path.replaceFirst("/", ""))));
} }
public void showFileVersionsPane() { public void showFileVersionsPane() {

11
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java

@ -11,20 +11,17 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsOperatorWorker;
import com.fr.design.mainframe.vcs.TableEntity; import com.fr.design.mainframe.vcs.TableEntity;
import com.fr.design.mainframe.vcs.TableValueOperator; import com.fr.design.mainframe.vcs.TableValueOperator;
import com.fr.design.mainframe.vcs.VcsOperatorWorker;
import com.fr.design.mainframe.vcs.VcsProcessFailedWrapper; import com.fr.design.mainframe.vcs.VcsProcessFailedWrapper;
import com.fr.design.mainframe.vcs.VcsTableEntity; import com.fr.design.mainframe.vcs.VcsTableEntity;
import com.fr.design.mainframe.vcs.VcsTableOperatorListener; import com.fr.design.mainframe.vcs.VcsTableOperatorListener;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.server.repository.vcs.VcsRepository;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.Icon; import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -101,7 +98,7 @@ public class RecyclePane extends AbstractSupportSelectTablePane<VcsTableEntity>
@Override @Override
protected List<VcsTableEntity> getTableList() { protected List<VcsTableEntity> getTableList() {
List<VcsEntity> entityList = WorkContext.getCurrent().get(VcsOperator.class).getRecycleEntities(); List<VcsEntity> entityList = VcsRepository.getInstance().getRecycleEntities();
List<VcsTableEntity> tableEntities = new ArrayList<>(); List<VcsTableEntity> tableEntities = new ArrayList<>();
for (VcsEntity entity : entityList) { for (VcsEntity entity : entityList) {
tableEntities.add(new VcsTableEntity(entity)); tableEntities.add(new VcsTableEntity(entity));

13
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java

@ -9,7 +9,6 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsOperatorWorker; import com.fr.design.mainframe.vcs.VcsOperatorWorker;
import com.fr.design.mainframe.vcs.VcsTableEntity; import com.fr.design.mainframe.vcs.VcsTableEntity;
import com.fr.design.mainframe.vcs.VcsTableOperatorListener; import com.fr.design.mainframe.vcs.VcsTableOperatorListener;
import com.fr.design.mainframe.vcs.common.VcsCloseTemplateHelper; import com.fr.design.mainframe.vcs.common.VcsCloseTemplateHelper;
@ -17,15 +16,9 @@ import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.server.repository.vcs.VcsRepository;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.Icon; import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
@ -211,7 +204,7 @@ public class VcsCenterPane extends VcsNewPane {
@Override @Override
protected List<VcsTableEntity> getTableList() { protected List<VcsTableEntity> getTableList() {
List<VcsEntity> entities = WorkContext.getCurrent().get(VcsOperator.class).getEveryVersion(); List<VcsEntity> entities = VcsRepository.getInstance().getEveryVersion();
List<VcsTableEntity> tableEntities = new ArrayList<>(); List<VcsTableEntity> tableEntities = new ArrayList<>();
for (VcsEntity entity : entities) { for (VcsEntity entity : entities) {
tableEntities.add(new VcsTableEntity(entity)); tableEntities.add(new VcsTableEntity(entity));

21
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.vcs.ui; package com.fr.design.mainframe.vcs.ui;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fr.base.svg.IconUtils;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.file.MultiTemplateTabPane;
@ -18,8 +17,6 @@ import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.FileNodes;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.report.InconsistentLockException; import com.fr.report.InconsistentLockException;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -27,16 +24,13 @@ 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.resource.WorkResource; import com.fr.workspace.resource.WorkResource;
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.v2.VcsTaskResult; import com.fr.workspace.server.vcs.v2.VcsTaskResult;
import javax.swing.Icon; import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -196,7 +190,7 @@ public class VcsNewPane extends RecyclePane {
//step1.设置还原的用户名 //step1.设置还原的用户名
entity.setUsername(VcsHelper.getInstance().getCurrentUsername()); entity.setUsername(VcsHelper.getInstance().getCurrentUsername());
//step2.rollback到指定版本 //step2.rollback到指定版本
WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(entity); VcsRepository.getInstance().rollbackTo(new VcsBean(entity));
//最里面的文件系统的write会吞异常,这边就一直默认成功吧,日志里会体现失败的情况 //最里面的文件系统的write会吞异常,这边就一直默认成功吧,日志里会体现失败的情况
return new VcsTaskResult(true); return new VcsTaskResult(true);
} }
@ -294,8 +288,7 @@ public class VcsNewPane extends RecyclePane {
@Override @Override
protected String doInBackground() throws Exception { protected String doInBackground() throws Exception {
//step1.将指定版本的历史文件读取出来,加上前缀放到cache中 //step1.将指定版本的历史文件读取出来,加上前缀放到cache中
VcsOperator vcsOperator = WorkContext.getCurrent().get(VcsOperator.class); String fileOfVersion = VcsRepository.getInstance().getFileOfFileVersion(
String fileOfVersion = vcsOperator.getFileOfFileVersion(
entity.getFilename(), entity.getFilename(),
entity.getVersion(), entity.getVersion(),
Toolkit.i18nText("Fine-Design_Vcs_Prefix", entity.getVersion())); Toolkit.i18nText("Fine-Design_Vcs_Prefix", entity.getVersion()));
@ -320,7 +313,7 @@ public class VcsNewPane extends RecyclePane {
@Override @Override
protected List<VcsTableEntity> getTableList() { protected List<VcsTableEntity> getTableList() {
List<VcsEntity> entityList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(VcsFileUtils.dealWithFilePath(filePath)); List<VcsEntity> entityList = VcsRepository.getInstance().getVersions(new VcsQuery(VcsFileUtils.dealWithFilePath(filePath)));
List<VcsTableEntity> tableEntities = new ArrayList<>(); List<VcsTableEntity> tableEntities = new ArrayList<>();
for (VcsEntity entity : entityList) { for (VcsEntity entity : entityList) {
tableEntities.add(new VcsTableEntity(entity)); tableEntities.add(new VcsTableEntity(entity));

Loading…
Cancel
Save