diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 1babe368ec..b526b6ae2b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/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.repository.vcs.VcsRepository; 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.v2.scheduler.VcsAutoCleanSchedule; import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanService; @@ -1214,7 +1213,7 @@ public class PreferencePane extends BasicPane { @Override protected Boolean doInBackground() { - size = WorkContext.getCurrent().get(VcsOperator.class).immediatelyGc(); + size = VcsRepository.getInstance().immediatelyGc(); return true; } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 4eb45fface..262da62117 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -3,6 +3,7 @@ */ package com.fr.design.file; +import com.fanruan.repository.TemplateRepository; import com.fr.design.ExtraDesignClassManager; import com.fr.design.cache.DesignCacheManager; 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.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.lock.LockInfoDialog; import com.fr.design.lock.LockInfoUtils; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; -import com.fr.design.lock.LockInfoDialog; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; 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.IOUtils; import com.fr.log.FineLoggerFactory; -import com.fr.workspace.base.UserInfo; import com.fr.stable.ArrayUtils; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; 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.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; -import javax.swing.ToolTipManager; +import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.BorderLayout; -import java.awt.Desktop; -import java.awt.Dimension; +import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; @@ -60,14 +56,10 @@ import java.util.Objects; import java.util.Observable; import java.util.Observer; import java.util.Set; +import java.util.UUID; import java.util.concurrent.ExecutionException; 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.YES_NO_OPTION; @@ -408,7 +400,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { if (nodeFILE.exists()) { if (!VcsHelper.getInstance().isLegacyMode()) { try { - WorkContext.getCurrent().get(VcsOperator.class).recycleVersion(VcsHelper.getInstance().getCurrentUsername(), nodeFILE.getPath()); + VcsRepository.getInstance().recycleVersion(VcsHelper.getInstance().getCurrentUsername(), nodeFILE.getPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error("[VcsV2] recycle {} failed", nodeFILE.getName()); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java index 799abcf17c..99c1187bc3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java +++ b/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.stable.StringUtils; 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.v2.VcsTaskResult; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; -import java.util.ArrayList; +import javax.swing.*; import java.util.List; import java.util.concurrent.ExecutionException; @@ -108,7 +108,7 @@ public class VcsOperatorWorker { VcsProcessFailedWrapper wrapper = new VcsProcessFailedWrapper(); startProcess(vcsEntities, wrapper, (vcsEntity, operator) -> { String fileName = vcsEntity.getFilename(); - VcsTaskResult result = operator.restoreVersion(fileName); + VcsTaskResult result = VcsRepository.getInstance().restoreVersion(fileName); if (!result.isSuccess()) { wrapper.addFailedEntity(vcsEntity); } @@ -129,9 +129,9 @@ public class VcsOperatorWorker { String fileName = vcsEntity.getFilename(); VcsTaskResult result; if (all) { - result = operator.deleteVersionForRecycle(fileName); + result = VcsRepository.getInstance().deleteVersionForRecycle(fileName); } 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()) { wrapper.addFailedEntity(vcsEntity); @@ -148,7 +148,7 @@ public class VcsOperatorWorker { */ public void doDelete(VcsEntity entity, VcsTableOperatorListener listener) { 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(); int version = entity.getVersion(); 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) { start4Single(entity, (vcsEntity, operator) -> { - operator.updateVersion(entity); + VcsRepository.getInstance().updateVersion(new VcsBean(entity)); return new VcsTaskResult(true); }, everyFailedStr, listener); } 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 15787348fe..082faf09fd 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 @@ -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 updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); + List 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 oldVcsEntities = operator.getVersions(oldPath); + List 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 updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); + List 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()); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java index db92ab3eef..64568feac4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java +++ b/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.report.entity.VcsEntity; import com.fr.stable.StringUtils; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.vcs.VcsOperator; - -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Frame; +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 javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -118,11 +116,12 @@ public class EditFileVersionDialog extends UIDialog { */ public void doOK() { entity.setCommitMsg(msgTestArea.getText()); - WorkContext.getCurrent().get(VcsOperator.class).updateVersion(entity); + VcsRepository.getInstance().updateVersion(new VcsBean(entity)); setVisible(false); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); 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() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java index 8cff3ffbb1..7d161ead0d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java +++ b/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.StringUtils; import com.fr.workspace.WorkContext; +import com.fr.workspace.server.repository.vcs.VcsRepository; import com.fr.workspace.server.vcs.VcsOperator; import javax.swing.AbstractCellEditor; @@ -43,10 +44,10 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe return editor; } else if (row == 0) { String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); - fileOfVersion = vcsOperator.getFileOfCurrent(path.replaceFirst("/", "")); + fileOfVersion = VcsRepository.getInstance().getFileOfCurrent(path.replaceFirst("/", "")); } else { 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); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java index f023b6b92f..57b9d27d5f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java @@ -1,6 +1,5 @@ package com.fr.design.mainframe.vcs.ui; -import com.fr.analysis.cloud.DateUtils; import com.fr.design.dialog.UIDialog; import com.fr.design.editor.editor.DateEditor; 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.report.entity.VcsEntity; import com.fr.stable.StringUtils; -import com.fr.workspace.WorkContext; -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.AbstractAction; -import javax.swing.BorderFactory; -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 javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Calendar; @@ -70,7 +62,7 @@ public class FileVersionDialog extends UIDialog { Date editorDate = dateEditor.getValue(); Date start = editorDate == null ? new Date(0) : editorDate; Date end = editorDate == null ? getLastHour() : new Date(start.getTime() + DELAY); - List vcsEntities = WorkContext.getCurrent().get(VcsOperator.class).getFilterVersions(fileName, start, end, textField.getText()); + List vcsEntities = VcsRepository.getInstance().getVersions(new VcsQuery(fileName, start, end, textField.getText())); FileVersionTable.getInstance().updateModel(1, vcsEntities); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java index 2bd441c19e..b6dce1fd8f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java +++ b/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.report.entity.VcsEntity; import com.fr.stable.StringUtils; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.vcs.VcsOperator; +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 javax.swing.Box; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.text.BadLocationException; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; -import java.awt.BorderLayout; -import java.awt.Color; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; 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"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { vcsEntity.setUsername(VcsHelper.getInstance().getCurrentUsername()); - WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(vcsEntity); + VcsRepository.getInstance().rollbackTo(new VcsBean(vcsEntity)); 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"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { 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) { FineLoggerFactory.getLogger().error(e.getMessage()); } FileVersionTable table = (FileVersionTable) (FileVersionRowPanel.this.getParent()); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); 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) { FineLoggerFactory.getLogger().error(e.getMessage()); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java index 58393a3067..3207c1fbc2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java +++ b/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.stable.StableUtils; import com.fr.stable.project.ProjectConstants; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.vcs.VcsOperator; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.SwingConstants; -import java.awt.BorderLayout; -import java.awt.Dimension; +import com.fr.workspace.server.entity.vcs.VcsQuery; +import com.fr.workspace.server.repository.vcs.VcsRepository; + +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -134,7 +131,8 @@ public class FileVersionsPanel extends BasicPane { } titleLabel.setText(filename); 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() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java index aca6ad2409..d89838e362 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java +++ b/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.i18n.Toolkit; 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.TableValueOperator; +import com.fr.design.mainframe.vcs.VcsOperatorWorker; import com.fr.design.mainframe.vcs.VcsProcessFailedWrapper; import com.fr.design.mainframe.vcs.VcsTableEntity; import com.fr.design.mainframe.vcs.VcsTableOperatorListener; import com.fr.report.entity.VcsEntity; import com.fr.stable.StringUtils; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.vcs.VcsOperator; +import com.fr.workspace.server.repository.vcs.VcsRepository; -import javax.swing.Icon; -import javax.swing.JOptionPane; -import javax.swing.JPanel; +import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -101,7 +98,7 @@ public class RecyclePane extends AbstractSupportSelectTablePane @Override protected List getTableList() { - List entityList = WorkContext.getCurrent().get(VcsOperator.class).getRecycleEntities(); + List entityList = VcsRepository.getInstance().getRecycleEntities(); List tableEntities = new ArrayList<>(); for (VcsEntity entity : entityList) { tableEntities.add(new VcsTableEntity(entity)); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java index b95b35b7de..d9d67e4dff 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java +++ b/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.mainframe.DesignerContext; import com.fr.design.mainframe.vcs.VcsOperatorWorker; - import com.fr.design.mainframe.vcs.VcsTableEntity; import com.fr.design.mainframe.vcs.VcsTableOperatorListener; 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.report.entity.VcsEntity; import com.fr.stable.StringUtils; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.vcs.VcsOperator; +import com.fr.workspace.server.repository.vcs.VcsRepository; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JTable; -import javax.swing.SwingWorker; -import javax.swing.UIManager; +import javax.swing.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -211,7 +204,7 @@ public class VcsCenterPane extends VcsNewPane { @Override protected List getTableList() { - List entities = WorkContext.getCurrent().get(VcsOperator.class).getEveryVersion(); + List entities = VcsRepository.getInstance().getEveryVersion(); List tableEntities = new ArrayList<>(); for (VcsEntity entity : entities) { tableEntities.add(new VcsTableEntity(entity)); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java index f0615bfa49..5a413cf954 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe.vcs.ui; import com.fine.theme.icon.LazyIcon; -import com.fr.base.svg.IconUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; 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.file.FileNodeFILE; 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.entity.VcsEntity; import com.fr.stable.StableUtils; @@ -27,16 +24,13 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; 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.VcsOperator; import com.fr.workspace.server.vcs.v2.VcsTaskResult; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JTable; -import javax.swing.SwingWorker; -import javax.swing.UIManager; +import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -196,7 +190,7 @@ public class VcsNewPane extends RecyclePane { //step1.设置还原的用户名 entity.setUsername(VcsHelper.getInstance().getCurrentUsername()); //step2.rollback到指定版本 - WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(entity); + VcsRepository.getInstance().rollbackTo(new VcsBean(entity)); //最里面的文件系统的write会吞异常,这边就一直默认成功吧,日志里会体现失败的情况 return new VcsTaskResult(true); } @@ -294,8 +288,7 @@ public class VcsNewPane extends RecyclePane { @Override protected String doInBackground() throws Exception { //step1.将指定版本的历史文件读取出来,加上前缀放到cache中 - VcsOperator vcsOperator = WorkContext.getCurrent().get(VcsOperator.class); - String fileOfVersion = vcsOperator.getFileOfFileVersion( + String fileOfVersion = VcsRepository.getInstance().getFileOfFileVersion( entity.getFilename(), entity.getVersion(), Toolkit.i18nText("Fine-Design_Vcs_Prefix", entity.getVersion())); @@ -320,7 +313,7 @@ public class VcsNewPane extends RecyclePane { @Override protected List getTableList() { - List entityList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(VcsFileUtils.dealWithFilePath(filePath)); + List entityList = VcsRepository.getInstance().getVersions(new VcsQuery(VcsFileUtils.dealWithFilePath(filePath))); List tableEntities = new ArrayList<>(); for (VcsEntity entity : entityList) { tableEntities.add(new VcsTableEntity(entity));