From 90ff0ce4c5281abf7510492c85de61f9d5ab2efb Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:28 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"REPORT-91839=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E4=BA=8C=E6=9C=9F=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b8f7eda1b0fbc2bb30f0281d6b4a6abcf6b788b3. --- .../mainframe/vcs/common/VcsHelper.java | 54 ++++++++----------- .../design/mainframe/vcs/ui/VcsMovePanel.java | 11 ++++ 2 files changed, 34 insertions(+), 31 deletions(-) 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 b245eff66c..1c81481bb9 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 @@ -79,14 +79,7 @@ public class VcsHelper implements JTemplateActionListener { EventDispatcher.listen(ConfigEvent.READY, new ListenerAdaptor() { @Override protected void on(Event event) { - try { - legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); - FineLoggerFactory.getLogger().info("[VcsHelper] legacyMode:{}", legacyMode); - } catch (Exception e) { - //保险起见走老逻辑 - legacyMode = true; - FineLoggerFactory.getLogger().error("[VcsHelper] get legacy failed", e.getMessage()); - } + legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); } }); } @@ -106,6 +99,7 @@ public class VcsHelper implements JTemplateActionListener { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && JTemplate.isValid(template)) { fireAutoSaveVcs(template); + FineLoggerFactory.getLogger().info("[VcsV2] fire Vcs auto save success!"); } } }, interval, interval, TimeUnit.MINUTES); @@ -269,7 +263,7 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateOpened(JTemplate jt) { try { - if (checkAutoSaveSupport()) { + if (VcsConfigManager.getInstance().isUseAutoSave()) { startAutoSave(VcsConfigManager.getInstance().getAutoSaveInterval()); } } catch (Exception e) { @@ -288,16 +282,25 @@ public class VcsHelper implements JTemplateActionListener { * @param jt 模板 */ public void fireAutoSaveVcs(final JTemplate jt) { - String fileName = getEditingFilename(); - VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); - VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); - boolean replace = needDeleteVersion(entity); - int latestFileVersion = 0; - if (entity != null) { - latestFileVersion = entity.getVersion(); - } - if (JTemplate.isValid(jt)) { - doSave(jt, fileName, latestFileVersion, replace, operator); + ExecutorService fireVcs = Executors.newSingleThreadExecutor(new NamedThreadFactory("autoFireVcs")); + fireVcs.execute(new Runnable() { + @Override + public void run() { + String fileName = getEditingFilename(); + VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); + VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); + boolean replace = needDeleteVersion(entity); + int latestFileVersion = 0; + if (entity != null) { + latestFileVersion = entity.getVersion(); + } + if (JTemplate.isValid(jt)) { + doSave(jt, fileName, latestFileVersion, replace, operator); + } + } + }); + if (!fireVcs.isShutdown()) { + fireVcs.shutdown(); } } @@ -345,9 +348,7 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateClosed(JTemplate jt) { try { - if (checkAutoSaveSupport()) { - stopAutoSave(); - } + stopAutoSave(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage()); } @@ -371,13 +372,4 @@ public class VcsHelper implements JTemplateActionListener { public boolean checkMoveFunctionSupport() { return VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } - - /** - * 是否支持自动保存 - * - * @return 支持返回true - */ - public boolean checkAutoSaveSupport() { - return VcsConfigManager.getInstance().isUseAutoSave() && !VcsHelper.getInstance().isLegacyMode(); - } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java index af450d8250..cf68c33bc3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java @@ -19,6 +19,10 @@ import com.fr.design.widget.FRWidgetFactory; import com.fr.general.FRFont; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerAdaptor; +import com.fr.workspace.server.vcs.VcsConfig; +import com.fr.workspace.server.vcs.VcsManager; import com.fr.workspace.server.vcs.v2.move.VcsMoveService; import com.fr.workspace.server.vcs.v2.move.VcsMoveStrategy; @@ -387,6 +391,13 @@ public class VcsMovePanel extends BasicPane { VcsMoveService.getInstance().stopMoving(); initSuccessPane(); VcsMovePanel.this.getParentCard().show(getParentPane(), SUCCESS); + Configurations.update(new WorkerAdaptor(VcsConfig.class) { + @Override + public void run() { + VcsConfig.getInstance().setUseV2(true); + } + }); + VcsManager.getInstance().updateManager(); VcsHelper.getInstance().updateLegacyMode(); } }