From d3b6873102eec2261969173f997e4c7ac97d4a99 Mon Sep 17 00:00:00 2001 From: loy Date: Wed, 22 Mar 2023 14:48:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-92308=20=E7=89=88=E6=9C=AC=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8F=AF=E7=94=A8=E6=80=A7=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E9=80=82=E9=85=8D=E6=96=B0=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/PreferencePane.java | 31 ++++--------------- .../DesignerFrameFileDealerPane.java | 9 ++++-- .../mainframe/vcs/common/VcsHelper.java | 24 ++++++++++++++ 3 files changed, 37 insertions(+), 27 deletions(-) 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 e09d6f7a05..a83bcfd771 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 @@ -356,6 +356,8 @@ public class PreferencePane extends BasicPane { useIntervalCheckBox = new UICheckBox(); //gc面板 + JPanel gcControlPane = createGcControlPane(); + JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); enableVcsPanel.add(vcsEnableCheckBox); enableVcsPanel.add(remindVcsLabel); @@ -388,31 +390,10 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); - - initGcControlPane(vcsPane); - } - - private void initGcControlPane(JPanel vcsPane) { - JPanel gcControlPane = createGcControlPane(); - new SwingWorker() { - @Override - protected Boolean doInBackground() throws Exception { - return WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); - } - - @Override - protected void done() { - try { - if (Boolean.TRUE.equals(get())) { - // 老版本时才显示gc选项 - vcsPane.add(gcControlPane); - vcsPane.updateUI(); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e, "[Vcs] retrieve legacy mode error: {}", e.getMessage()); - } - } - }.execute(); + if (VcsHelper.getInstance().isLegacyMode()) { + // 老版本时才显示gc选项 + vcsPane.add(gcControlPane); + } } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 8cfd263421..d21dd1b7cf 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -325,7 +325,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt if (VcsHelper.getInstance().needInit()) { vcsAction = new VcsAction(); - if (!WorkContext.getCurrent().isCluster()) { + if (!isLegacyOnCluster()) { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); } else { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); @@ -509,7 +509,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt private void fireVcsActionChange(boolean enable) { if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() - || WorkContext.getCurrent().isCluster()) { + || isLegacyOnCluster()) { setEnabled(false); return; } @@ -810,6 +810,11 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } + private boolean isLegacyOnCluster() { + // 老模式且为集群,用于代替之前的只判断集群逻辑 + return WorkContext.getCurrent().isCluster() && VcsHelper.getInstance().isLegacyMode(); + } + private String doCheck (String userInput, String suffix) { String errorMsg = StringUtils.EMPTY; if (selectedOperation.duplicated(userInput, suffix, true)) { 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 c72fa68dc4..335e3c9a7b 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 @@ -12,6 +12,9 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplateActionListener; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.ui.FileVersionTable; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; @@ -20,6 +23,8 @@ import com.fr.report.entity.VcsEntity; 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.vcs.VcsOperator; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.git.config.GcConfig; @@ -56,10 +61,22 @@ public class VcsHelper implements JTemplateActionListener { private final static String SERVICE_NAME_MOVE = "moveVcs"; private static final VcsHelper INSTANCE = new VcsHelper(); + private volatile boolean isLegacyMode; + public static VcsHelper getInstance() { return INSTANCE; } + private VcsHelper() { + isLegacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { + @Override + public void on(Event event, Workspace param) { + isLegacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); + } + }); + } + private int containsFolderCounts() { TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { @@ -187,6 +204,13 @@ public class VcsHelper implements JTemplateActionListener { moveVcs.shutdown(); } + /** + * 判断是否为老模式 + * @return 是否为老模式 + */ + public boolean isLegacyMode() { + return isLegacyMode; + } @Override public void templateOpened(JTemplate jt) { From 204e83c90042d9b411d5cfbaf92be72c92a59e70 Mon Sep 17 00:00:00 2001 From: loy Date: Wed, 22 Mar 2023 14:55:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-92308=20=E7=89=88=E6=9C=AC=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8F=AF=E7=94=A8=E6=80=A7=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E9=80=82=E9=85=8D=E6=96=B0=E6=A8=A1=E5=BC=8F=20-=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/vcs/common/VcsHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 335e3c9a7b..0c8924e9d0 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 @@ -61,18 +61,18 @@ public class VcsHelper implements JTemplateActionListener { private final static String SERVICE_NAME_MOVE = "moveVcs"; private static final VcsHelper INSTANCE = new VcsHelper(); - private volatile boolean isLegacyMode; + private volatile boolean legacyMode; public static VcsHelper getInstance() { return INSTANCE; } private VcsHelper() { - isLegacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); + legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { @Override public void on(Event event, Workspace param) { - isLegacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); + legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); } }); } @@ -209,7 +209,7 @@ public class VcsHelper implements JTemplateActionListener { * @return 是否为老模式 */ public boolean isLegacyMode() { - return isLegacyMode; + return legacyMode; } @Override