From 90ff0ce4c5281abf7510492c85de61f9d5ab2efb Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:28 +0800 Subject: [PATCH 1/9] =?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(); } } From 718080f6227ccd3ad2eb84d6236e31efab8098e7 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:29 +0800 Subject: [PATCH 2/9] =?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?=E5=A4=9A=E5=88=A0=E4=BA=86=E4=B8=80=E9=83=A8=E5=88=86"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9d19e9c93e4649e905ba6a9ce1a2c6983ca10e5a. --- .../main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java index 8551f735b9..1129df5a1f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java @@ -79,7 +79,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { this.setSaveCommit(reader.getAttrAsBoolean("saveCommit", true)); this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60)); this.setUseInterval(reader.getAttrAsBoolean("useInterval", true)); - this.setVcsEnable(reader.getAttrAsBoolean("vcsEnable", true)); this.setAutoSaveInterval(reader.getAttrAsInt("autoSaveInterval", 15)); this.setUseAutoSave(reader.getAttrAsBoolean("useAutoSave", false)); } From 58b1b29cbfbf54486e052dfc6ebefcb3caf94989 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:30 +0800 Subject: [PATCH 3/9] =?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?=E8=A1=A5=E5=85=85=E6=8C=89=E9=92=AE=E4=BA=A4=E4=BA=92=EF=BC=8C?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4682898c6763b0720024035948a68964aa72a65e. --- .../design/actions/file/PreferencePane.java | 23 +---- .../design/mainframe/vcs/ui/VcsMovePanel.java | 95 ++++++------------- 2 files changed, 32 insertions(+), 86 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 4d31904f1f..d816131dee 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 @@ -220,9 +220,6 @@ public class PreferencePane extends BasicPane { private UICheckBox saveCommitCheckBox; private UICheckBox useIntervalCheckBox; private VcsMovePanel movePanel; - - private JPanel saveIntervalPane; - private JPanel autoCleanPane; private UICheckBox startupPageEnabledCheckBox; private IntegerEditor saveIntervalEditor; private UICheckBox gcEnableCheckBox; @@ -395,7 +392,7 @@ public class PreferencePane extends BasicPane { private void createVcsSettingPane(JPanel generalPane,JPanel parentPane, CardLayout cardLayout) { //迁移面板 - movePanel = createMovePane(cardLayout, parentPane); + movePanel = new VcsMovePanel(cardLayout, parentPane); generalPane.add(movePanel, BorderLayout.NORTH); JPanel savePane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Save_Setting")); JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Clean_Setting")); @@ -407,7 +404,7 @@ public class PreferencePane extends BasicPane { remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); vcsEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_SaveAuto")); - saveIntervalPane = createSaveIntervalPane(); + JPanel saveIntervalPane = createSaveIntervalPane(); saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete")); saveIntervalEditor = new IntegerEditor(60); useIntervalCheckBox = new UICheckBox(); @@ -426,7 +423,7 @@ public class PreferencePane extends BasicPane { intervalPanel.add(everyLabel); intervalPanel.add(saveIntervalEditor); intervalPanel.add(delayLabel); - autoCleanPane = createAutoCleanPane(); + JPanel autoCleanPane = createAutoCleanPane(); vcsEnableCheckBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -450,24 +447,12 @@ public class PreferencePane extends BasicPane { vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); vcsPane.add(autoCleanPane); - saveIntervalPane.setVisible(!VcsHelper.getInstance().isLegacyMode()); - autoCleanPane.setVisible(!VcsHelper.getInstance().isLegacyMode()); if (VcsHelper.getInstance().isLegacyMode()) { // 老版本时才显示gc选项 vcsPane.add(gcControlPane); } } - private VcsMovePanel createMovePane(CardLayout cardLayout, JPanel parentPane) { - return new VcsMovePanel(cardLayout, parentPane, new VcsMovePanel.MoveCallBack(){ - @Override - public void doCallBack(boolean visible) { - saveIntervalPane.setVisible(visible); - autoCleanPane.setVisible(visible); - } - }); - }; - private JPanel createAutoCleanPane() { JPanel autoCleanPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); useVcsAutoCleanScheduleCheckBox = new UICheckBox(); @@ -482,7 +467,6 @@ public class PreferencePane extends BasicPane { autoCleanPane.add(autoCleanRetainIntervalComboBox); autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Last"))); useVcsAutoCleanScheduleCheckBox.setEnabled(!VcsHelper.getInstance().isLegacyMode()); - autoCleanPane.setVisible(false); return autoCleanPane; } @@ -495,7 +479,6 @@ public class PreferencePane extends BasicPane { saveIntervalPane.add(autoSaveIntervalEditor); saveIntervalPane.add(new UILabel(i18nText("Fine-Design_Vcs_Save_Delay"))); useVcsAutoSaveScheduleCheckBox.setEnabled(!VcsHelper.getInstance().isLegacyMode()); - saveIntervalPane.setVisible(false); return saveIntervalPane; } 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 cf68c33bc3..9a3235cd15 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 @@ -32,8 +32,6 @@ import javax.swing.JProgressBar; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.List; @@ -104,19 +102,12 @@ public class VcsMovePanel extends BasicPane { private UISpinner spinner; - private MoveCallBack callBack; - private JPanel updatePane; - - private boolean visible = false; - - - public VcsMovePanel(CardLayout cardLayout, JPanel parentPane, MoveCallBack callBack) { + public VcsMovePanel(CardLayout cardLayout, JPanel parentPane) { this.parentCard = cardLayout; this.parentPane = parentPane; - this.callBack = callBack; this.setLayout(new BorderLayout()); - updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); + JPanel updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); updatePane.setBackground(BACK_GROUND_COLOR); //初始化迁移的面板 initVcsLabel(updatePane); @@ -270,37 +261,25 @@ public class VcsMovePanel extends BasicPane { JPanel successPane = new JPanel(); JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); successButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Go")); - initSuccessButtonListener(); iconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_success.svg")); successLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success")); successLabel.setFont(FONT); successTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Tip")); - initStatusPane(successTipLabel, iconLabel, successLabel, successButton, body, SUCCESS, successPane); - } - - private void initSuccessButtonListener() { - successButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - doAfterMove(); - } - }); - } - - private void initFailedButtonListener() { - failedButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - doAfterMove(); - } - }); - } - - private void doAfterMove() { - visible = !VcsHelper.getInstance().isLegacyMode(); - updatePane.setVisible(!visible); - callBack.doCallBack(visible); - parentCard.show(parentPane, SETTING); + successTipLabel.setForeground(TIP_COLOR); + body.add(iconLabel); + body.add(new UILabel(StringUtils.BLANK)); + body.add(successLabel); + body.add(new UILabel(StringUtils.BLANK)); + body.add(successTipLabel); + body.add(new UILabel(StringUtils.BLANK)); + body.add(successButton); + successPane.add(body); + successPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); + parentPane.add(successPane, SUCCESS); + iconLabel.setAlignmentX(CENTER_ALIGNMENT); + successLabel.setAlignmentX(CENTER_ALIGNMENT); + successButton.setAlignmentX(CENTER_ALIGNMENT); + successTipLabel.setAlignmentX(CENTER_ALIGNMENT); } @@ -321,30 +300,25 @@ public class VcsMovePanel extends BasicPane { JPanel failedPane = new JPanel(); JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); failedButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Go")); - initFailedButtonListener(); failedIconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_failed.svg")); failedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed")); failedLabel.setFont(FONT); failedTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Tip")); - initStatusPane(failedTipLabel, failedIconLabel, failedLabel, failedButton, body, FAILED, failedPane); - } - - private void initStatusPane(UILabel tipLabel, UILabel iconLabel, UILabel label, UIButton button, JPanel body, String tag,JPanel statusPane) { - tipLabel.setForeground(TIP_COLOR); - body.add(iconLabel); + failedTipLabel.setForeground(TIP_COLOR); + body.add(failedIconLabel); body.add(new UILabel(StringUtils.BLANK)); - body.add(label); + body.add(failedLabel); body.add(new UILabel(StringUtils.BLANK)); - body.add(tipLabel); + body.add(failedTipLabel); body.add(new UILabel(StringUtils.BLANK)); - body.add(button); - statusPane.add(body); - statusPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); - parentPane.add(statusPane, tag); - iconLabel.setAlignmentX(CENTER_ALIGNMENT); - label.setAlignmentX(CENTER_ALIGNMENT); - button.setAlignmentX(CENTER_ALIGNMENT); - tipLabel.setAlignmentX(CENTER_ALIGNMENT); + body.add(failedButton); + failedPane.add(body); + failedPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); + parentPane.add(failedPane, FAILED); + failedIconLabel.setAlignmentX(CENTER_ALIGNMENT); + failedLabel.setAlignmentX(CENTER_ALIGNMENT); + failedButton.setAlignmentX(CENTER_ALIGNMENT); + failedTipLabel.setAlignmentX(CENTER_ALIGNMENT); } @@ -403,15 +377,4 @@ public class VcsMovePanel extends BasicPane { } - /** - * 迁移回调事件 - * - */ - public static class MoveCallBack { - /** - * 处理回调 - */ - public void doCallBack(boolean visible){} - } - } From 3258151e7df95826391ac0b854aac323f79b4139 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:32 +0800 Subject: [PATCH 4/9] =?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=BC=98=E5=8C=96=E5=88=A4=E6=96=AD=E6=96=B0=E8=80=81=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E6=94=B9=E4=B8=BAConfig=E5=87=86=E5=A4=87?= =?UTF-8?q?=E5=90=8E=E8=BF=9B=E8=A1=8C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 6694648b918db44813a7db75d03421d51bc5ebb0. --- .../mainframe/vcs/common/VcsHelper.java | 27 +++++++------------ .../design/mainframe/vcs/ui/VcsMovePanel.java | 1 - 2 files changed, 9 insertions(+), 19 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 1c81481bb9..ce7f4094b9 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 @@ -2,7 +2,6 @@ package com.fr.design.mainframe.vcs.common; import com.fr.concurrent.NamedThreadFactory; -import com.fr.config.ConfigEvent; import com.fr.design.DesignerEnvManager; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.TemplateTreePane; @@ -15,7 +14,7 @@ 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.ListenerAdaptor; +import com.fr.event.Listener; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; @@ -24,6 +23,9 @@ 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.VcsConfig; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.git.config.GcConfig; @@ -76,9 +78,9 @@ public class VcsHelper implements JTemplateActionListener { if (op != null) { legacyMode = op.isLegacyMode(); } - EventDispatcher.listen(ConfigEvent.READY, new ListenerAdaptor() { + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { @Override - protected void on(Event event) { + public void on(Event event, Workspace param) { legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); } }); @@ -251,15 +253,6 @@ public class VcsHelper implements JTemplateActionListener { return legacyMode; } - /** - * 更新当前的legacyMode状态 - *
  • 目前用在迁移结束后更新模式为新模式
  • - * - */ - public void updateLegacyMode() { - this.legacyMode = !legacyMode; - } - @Override public void templateOpened(JTemplate jt) { try { @@ -299,9 +292,7 @@ public class VcsHelper implements JTemplateActionListener { } } }); - if (!fireVcs.isShutdown()) { - fireVcs.shutdown(); - } + fireVcs.shutdown(); } private void doSave(JTemplate jt, String fileName, int latestFileVersion, boolean replace, VcsOperator operator) { @@ -361,7 +352,7 @@ public class VcsHelper implements JTemplateActionListener { * @return 支持返回true */ public boolean checkV2FunctionSupport() { - return !VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); + return VcsConfig.getInstance().isUseV2() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } /** @@ -370,6 +361,6 @@ public class VcsHelper implements JTemplateActionListener { * @return 支持返回true */ public boolean checkMoveFunctionSupport() { - return VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); + return !VcsConfig.getInstance().isUseV2() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } } 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 9a3235cd15..350d20424e 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 @@ -372,7 +372,6 @@ public class VcsMovePanel extends BasicPane { } }); VcsManager.getInstance().updateManager(); - VcsHelper.getInstance().updateLegacyMode(); } } From e54b89675dbe782d6a819854de41efa600ad1dcd Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:33 +0800 Subject: [PATCH 5/9] =?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?=E5=AE=8C=E5=96=84=E4=B8=80=E4=B8=8B=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=A0=87=E7=AD=BE=E8=AE=BE=E7=BD=AE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4bd02cf06aae5999a8b3f69c870284e044289ceb. --- .../java/com/fr/design/mainframe/vcs/common/VcsHelper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 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 ce7f4094b9..77ab8db68e 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 @@ -25,7 +25,6 @@ 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.VcsConfig; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.git.config.GcConfig; @@ -352,7 +351,7 @@ public class VcsHelper implements JTemplateActionListener { * @return 支持返回true */ public boolean checkV2FunctionSupport() { - return VcsConfig.getInstance().isUseV2() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); + return !VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } /** @@ -361,6 +360,6 @@ public class VcsHelper implements JTemplateActionListener { * @return 支持返回true */ public boolean checkMoveFunctionSupport() { - return !VcsConfig.getInstance().isUseV2() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); + return VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } } From b103a0de083d3cd3f10d50ab0a940d5a899cdc5e Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:35 +0800 Subject: [PATCH 6/9] =?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=8D=E8=A7=84=E8=8C=83=E9=97=AE=E9=A2=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fa34777dd506b4fc32e8811cd0ff1f7d10dcf6f1. --- .../mainframe/vcs/common/VcsHelper.java | 5 ++-- .../design/mainframe/vcs/ui/VcsMovePanel.java | 28 ++++++++----------- 2 files changed, 14 insertions(+), 19 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 77ab8db68e..7ec79ca938 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 @@ -190,6 +190,7 @@ public class VcsHelper implements JTemplateActionListener { fireVcs.execute(new Runnable() { @Override public void run() { + String fileName = getEditingFilename(); VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); @@ -212,9 +213,7 @@ public class VcsHelper implements JTemplateActionListener { } }); - if (!fireVcs.isShutdown()) { - fireVcs.shutdown(); - } + fireVcs.shutdown(); } /** 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 350d20424e..d92171d26a 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 @@ -26,11 +26,7 @@ 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; -import javax.swing.ButtonGroup; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; +import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -80,7 +76,7 @@ public class VcsMovePanel extends BasicPane { private BasicPane choosePane; private CardLayout parentCard; private JPanel parentPane; - private static final JProgressBar PROGRESS_BAR = new JProgressBar(); + private static final JProgressBar progressBar = new JProgressBar(); private JPanel progressPanel; private UILabel tipLabel; @@ -145,13 +141,13 @@ public class VcsMovePanel extends BasicPane { private void initProcessPane() { JPanel processPane = new JPanel(); JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - PROGRESS_BAR.setStringPainted(true); - PROGRESS_BAR.setUI(new ModernUIProgressBarUI()); - PROGRESS_BAR.setBorderPainted(false); - PROGRESS_BAR.setOpaque(false); - PROGRESS_BAR.setBorder(null); - PROGRESS_BAR.setSize(BasicDialog.MEDIUM); - body.add(PROGRESS_BAR); + progressBar.setStringPainted(true); + progressBar.setUI(new ModernUIProgressBarUI()); + progressBar.setBorderPainted(false); + progressBar.setOpaque(false); + progressBar.setBorder(null); + progressBar.setSize(BasicDialog.MEDIUM); + body.add(progressBar); body.add(new UILabel(StringUtils.BLANK)); tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_While_Moving")); tipLabel.setAlignmentX(CENTER_ALIGNMENT); @@ -334,7 +330,7 @@ public class VcsMovePanel extends BasicPane { protected Void doInBackground() throws Exception { try { //开始迁移 - VcsMoveService.getInstance().startMove(new VcsMoveService.BaseMoveServiceWhileMoving() { + VcsMoveService.getInstance().startMove(new VcsMoveService.MoveServiceWhileMoving() { @Override public void publishProgress() { int num = VcsMoveService.getInstance().getCurrentMove(); @@ -342,7 +338,7 @@ public class VcsMovePanel extends BasicPane { } @Override public void prepare4Move() { - PROGRESS_BAR.setMaximum(VcsMoveService.getInstance().getTotal()); + progressBar.setMaximum(VcsMoveService.getInstance().getTotal()); } }, strategy); } catch (Exception e) { @@ -357,7 +353,7 @@ public class VcsMovePanel extends BasicPane { @Override protected void process(List chunks) { - PROGRESS_BAR.setValue(chunks.get(chunks.size() - 1)); + progressBar.setValue(chunks.get(chunks.size() - 1)); } @Override From 392240edd9e2ef9d20ad985918da3aa9ea2f5a55 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:36 +0800 Subject: [PATCH 7/9] =?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"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b5518abfb66cfcf1e6a06b9e8032b23643ad38b1. --- .../design/actions/file/PreferencePane.java | 169 +------- .../mainframe/vcs/VcsConfigManager.java | 26 +- .../mainframe/vcs/common/VcsHelper.java | 122 ------ .../design/mainframe/vcs/ui/VcsMovePanel.java | 375 ------------------ .../com/fr/design/vcs/move_failed.svg | 5 - .../com/fr/design/vcs/move_success.svg | 5 - .../com/fr/design/vcs/vcs_move_icon.svg | 3 - 7 files changed, 14 insertions(+), 691 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java delete mode 100644 designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg delete mode 100644 designer-base/src/main/resources/com/fr/design/vcs/move_success.svg delete mode 100644 designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg 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 d816131dee..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 @@ -36,7 +36,6 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.mainframe.vcs.ui.VcsMovePanel; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.unit.UnitConvertUtil; import com.fr.design.utils.gui.GUICoreUtils; @@ -55,12 +54,9 @@ import com.fr.stable.os.OperatingSystem; import com.fr.third.apache.logging.log4j.Level; import com.fr.transaction.Configurations; import com.fr.transaction.Worker; -import com.fr.transaction.WorkerAdaptor; import com.fr.workspace.WorkContext; -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.VcsAutoCleanOperator; import org.jetbrains.annotations.NotNull; import javax.swing.BorderFactory; @@ -81,7 +77,14 @@ import javax.swing.UIManager; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -146,32 +149,6 @@ public class PreferencePane extends BasicPane { private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG}; - private static final int ONE_DAY_INT = 1; - private static final int ONE_WEEK_INT = 7; - private static final int ONE_MONTH_INT = 30; - private static final int THREE_MONTH_INT = 90; - private static final int SIX_MONTH_INT = 180; - - private static final int ONE_DAY_INDEX = 0; - private static final int ONE_WEEK_INDEX = 1; - private static final int ONE_MONTH_INDEX = 2; - private static final int THREE_MONTH_INDEX = 3; - private static final int SIX_MONTH_INDEX = 4; - private static final String ONE_DAY = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_ONE_DAY"); - private static final String ONE_WEEK = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_ONE_WEEK"); - private static final String ONE_MONTH = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_ONE_MONTH"); - private static final String THREE_MONTH = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_THREE_MONTH"); - private static final String SIX_MONTH = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_SIX_MONTH"); - private static final String[] INTERVAL = { - ONE_DAY, - ONE_WEEK, - ONE_MONTH, - THREE_MONTH, - SIX_MONTH - }; - - private static final int DEFAULT_INDEX = 3; - private boolean languageChanged; // 是否修改了设计器语言设置 //设置是否支持undo private UICheckBox supportUndoCheckBox; @@ -209,17 +186,8 @@ public class PreferencePane extends BasicPane { private UICheckBox cloudAnalyticsDelayCheckBox; private UICheckBox vcsEnableCheckBox; - private UICheckBox useVcsAutoSaveScheduleCheckBox; - - private UICheckBox useVcsAutoCleanScheduleCheckBox; - - private UIComboBox autoCleanIntervalComboBox; - private UIComboBox autoCleanRetainIntervalComboBox; - - private IntegerEditor autoSaveIntervalEditor; private UICheckBox saveCommitCheckBox; private UICheckBox useIntervalCheckBox; - private VcsMovePanel movePanel; private UICheckBox startupPageEnabledCheckBox; private IntegerEditor saveIntervalEditor; private UICheckBox gcEnableCheckBox; @@ -259,26 +227,13 @@ public class PreferencePane extends BasicPane { JPanel advancePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); UIScrollPane adviceScrollPane = patchScroll(advancePane); jtabPane.addTab(i18nText("Fine-Design_Basic_Advanced"), adviceScrollPane); - //初始化vcs总面板 - JPanel vcsParentPane = new JPanel(); - CardLayout cardLayout = new CardLayout(); - vcsParentPane.setLayout(cardLayout); - //vcs配置面板 - JPanel vcsPane = new JPanel(new BorderLayout()); - //添加滚动条 - UIScrollPane vcsScrollPane = patchScroll(vcsPane); - //配置面板作为vcs总面板的一张卡片 - vcsParentPane.add(vcsScrollPane, VcsMovePanel.SETTING); - jtabPane.addTab(i18nText("Fine-Design_Vcs_Title"), vcsParentPane); contentPane.add(jtabPane, BorderLayout.NORTH); createFunctionPane(generalPane); createEditPane(generalPane); createColorSettingPane(generalPane); - - // vcsPane - createVcsSettingPane(vcsPane, vcsParentPane, cardLayout); + createVcsSettingPane(generalPane); // ConfPane JPanel confLocationPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane(); @@ -390,31 +345,21 @@ public class PreferencePane extends BasicPane { return generalPanelWithScroll; } - private void createVcsSettingPane(JPanel generalPane,JPanel parentPane, CardLayout cardLayout) { - //迁移面板 - movePanel = new VcsMovePanel(cardLayout, parentPane); - generalPane.add(movePanel, BorderLayout.NORTH); - JPanel savePane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Save_Setting")); - JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Clean_Setting")); - JPanel containPane = new JPanel(new GridLayout(10,1,0,8)); - containPane.add(savePane); - containPane.add(vcsPane); - generalPane.add(containPane, BorderLayout.CENTER); + private void createVcsSettingPane(JPanel generalPane) { + JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); + generalPane.add(vcsPane); remindVcsLabel = new UILabel(i18nText("Fine-Design_Vcs_Remind")); remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); vcsEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_SaveAuto")); - - JPanel saveIntervalPane = createSaveIntervalPane(); saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete")); saveIntervalEditor = new IntegerEditor(60); useIntervalCheckBox = new UICheckBox(); - savePane.add(vcsEnableCheckBox); - savePane.add(saveIntervalPane); //gc面板 JPanel gcControlPane = createGcControlPane(); JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); + enableVcsPanel.add(vcsEnableCheckBox); enableVcsPanel.add(remindVcsLabel); JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); final UILabel everyLabel = new UILabel(i18nText("Fine-Design_Vcs_Every")); @@ -423,7 +368,6 @@ public class PreferencePane extends BasicPane { intervalPanel.add(everyLabel); intervalPanel.add(saveIntervalEditor); intervalPanel.add(delayLabel); - JPanel autoCleanPane = createAutoCleanPane(); vcsEnableCheckBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -446,44 +390,12 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); - vcsPane.add(autoCleanPane); if (VcsHelper.getInstance().isLegacyMode()) { // 老版本时才显示gc选项 vcsPane.add(gcControlPane); } } - private JPanel createAutoCleanPane() { - JPanel autoCleanPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); - useVcsAutoCleanScheduleCheckBox = new UICheckBox(); - autoCleanIntervalComboBox = new UIComboBox(INTERVAL); - autoCleanIntervalComboBox.setSelectedIndex(DEFAULT_INDEX); - autoCleanRetainIntervalComboBox = new UIComboBox(INTERVAL); - autoCleanRetainIntervalComboBox.setSelectedIndex(DEFAULT_INDEX); - autoCleanPane.add(useVcsAutoCleanScheduleCheckBox); - autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Every"))); - autoCleanPane.add(autoCleanIntervalComboBox); - autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Content"))); - autoCleanPane.add(autoCleanRetainIntervalComboBox); - autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Last"))); - useVcsAutoCleanScheduleCheckBox.setEnabled(!VcsHelper.getInstance().isLegacyMode()); - return autoCleanPane; - } - - private JPanel createSaveIntervalPane() { - JPanel saveIntervalPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); - useVcsAutoSaveScheduleCheckBox = new UICheckBox(); - autoSaveIntervalEditor = new IntegerEditor(60); - saveIntervalPane.add(useVcsAutoSaveScheduleCheckBox); - saveIntervalPane.add(new UILabel(i18nText("Fine-Design_Vcs_Every"))); - saveIntervalPane.add(autoSaveIntervalEditor); - saveIntervalPane.add(new UILabel(i18nText("Fine-Design_Vcs_Save_Delay"))); - useVcsAutoSaveScheduleCheckBox.setEnabled(!VcsHelper.getInstance().isLegacyMode()); - return saveIntervalPane; - } - - - /** * 模创建板版本gc 配置操作面板 * @@ -887,10 +799,6 @@ public class PreferencePane extends BasicPane { gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable()); gcButton.setEnabled(gcEnableCheckBox.isSelected()); - useVcsAutoSaveScheduleCheckBox.setSelected(vcsConfigManager.isUseAutoSave()); - useVcsAutoCleanScheduleCheckBox.setSelected(VcsConfig.getInstance().isUseV2AutoClean()); - autoSaveIntervalEditor.setValue(vcsConfigManager.getAutoSaveInterval()); - gridLineColorTBButton.setColor(designerEnvManager.getGridLineColor()); paginationLineColorTBButton.setColor(designerEnvManager.getPaginationLineColor()); @@ -970,21 +878,6 @@ public class PreferencePane extends BasicPane { } } - private int getDay(int dateIndex) { - switch (dateIndex) { - case ONE_DAY_INDEX: - return ONE_DAY_INT; - case ONE_WEEK_INDEX: - return ONE_WEEK_INT; - case ONE_MONTH_INDEX: - return ONE_MONTH_INT; - case SIX_MONTH_INDEX: - return SIX_MONTH_INT; - default: - return THREE_MONTH_INT; - } - } - /** * The method of update. */ @@ -1030,17 +923,6 @@ public class PreferencePane extends BasicPane { vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected()); vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected()); - vcsConfigManager.setUseAutoSave(this.useVcsAutoSaveScheduleCheckBox.isSelected()); - vcsConfigManager.setAutoSaveInterval(this.autoSaveIntervalEditor.getValue()); - Configurations.update(new WorkerAdaptor(VcsConfig.class) { - @Override - public void run() { - VcsConfig.getInstance().setUseV2AutoClean(useVcsAutoCleanScheduleCheckBox.isSelected()); - VcsConfig.getInstance().setV2CleanInterval(getDay(autoCleanIntervalComboBox.getSelectedIndex())); - VcsConfig.getInstance().setV2RetainInterval(getDay(autoCleanRetainIntervalComboBox.getSelectedIndex())); - } - }); - dealWithSchedule(); designerEnvManager.setStartupPageEnabled(this.startupPageEnabledCheckBox.isSelected()); Configurations.update(new Worker() { @Override @@ -1115,31 +997,6 @@ public class PreferencePane extends BasicPane { } - private void dealWithSchedule() { - new SwingWorker() { - @Override - protected Void doInBackground() throws Exception { - boolean v2FunctionSupport = VcsHelper.getInstance().checkV2FunctionSupport(); - if (v2FunctionSupport) { - //如果支持V2 - if (useVcsAutoSaveScheduleCheckBox.isSelected()) { - FineLoggerFactory.getLogger().info("[VcsV2] start auto save!"); - VcsHelper.getInstance().startAutoSave(autoSaveIntervalEditor.getValue()); - } else { - VcsHelper.getInstance().stopAutoSave(); - } - if (useVcsAutoCleanScheduleCheckBox.isSelected()) { - FineLoggerFactory.getLogger().info("[VcsV2] start auto clean!"); - WorkContext.getCurrent().get(VcsAutoCleanOperator.class).addOrUpdateVcsAutoCleanJob(getDay(autoCleanIntervalComboBox.getSelectedIndex())); - } else { - WorkContext.getCurrent().get(VcsAutoCleanOperator.class).stopVcsAutoCleanJob(); - } - } - return null; - } - }.execute(); - } - // 如果语言设置改变了,则显示重启对话框 public void showRestartDialog() { if (!languageChanged) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java index 1129df5a1f..f61bba67a8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java @@ -16,10 +16,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { private boolean useInterval = true; private int saveInterval = 60; - private boolean useAutoSave = false; - - private int autoSaveInterval = 15; - public static VcsConfigManager getInstance() { return instance; } @@ -52,23 +48,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { return saveInterval; } - public int getAutoSaveInterval() { - return autoSaveInterval; - } - - public void setAutoSaveInterval(int autoSaveInterval) { - this.autoSaveInterval = autoSaveInterval; - } - - public boolean isUseAutoSave() { - return useAutoSave; - } - - public void setUseAutoSave(boolean useAutoSave) { - this.useAutoSave = useAutoSave; - } - - public void setSaveInterval(int saveInterval) { this.saveInterval = saveInterval; } @@ -79,8 +58,7 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { this.setSaveCommit(reader.getAttrAsBoolean("saveCommit", true)); this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60)); this.setUseInterval(reader.getAttrAsBoolean("useInterval", true)); - this.setAutoSaveInterval(reader.getAttrAsInt("autoSaveInterval", 15)); - this.setUseAutoSave(reader.getAttrAsBoolean("useAutoSave", false)); + this.setVcsEnable(reader.getAttrAsBoolean("vcsEnable", true)); } } @@ -91,8 +69,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { writer.attr("saveInterval", this.getSaveInterval()); writer.attr("useInterval", this.isUseInterval()); writer.attr("vcsEnable", this.isVcsEnable()); - writer.attr("autoSaveInterval", this.getAutoSaveInterval()); - writer.attr("useAutoSave", this.isUseAutoSave()); writer.end(); } } 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 7ec79ca938..dd7187be23 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 @@ -36,8 +36,6 @@ import java.awt.Color; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; /** * Created by XiaXiang on 2019/4/17. @@ -63,8 +61,6 @@ public class VcsHelper implements JTemplateActionListener { private final static String SERVICE_NAME_MOVE = "moveVcs"; private static final VcsHelper INSTANCE = new VcsHelper(); - private static ScheduledExecutorService saveSchedule; - private volatile boolean legacyMode; public static VcsHelper getInstance() { @@ -85,37 +81,6 @@ public class VcsHelper implements JTemplateActionListener { }); } - /** - * 开始自动保存任务 - * - * @param interval 时间间隔 - */ - public void startAutoSave(int interval) { - stopAutoSave(); - saveSchedule = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("VcsAutoSaveSchedule")); - saveSchedule.scheduleWithFixedDelay(new Runnable() { - @Override - public void run() { - FineLoggerFactory.getLogger().info("[VcsV2] start to run auto save schedule"); - 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); - } - - /** - * 停止任务 - */ - public void stopAutoSave() { - if (saveSchedule != null && !saveSchedule.isShutdown()) { - saveSchedule.shutdown(); - } - } - - private int containsFolderCounts() { TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { @@ -253,73 +218,9 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateOpened(JTemplate jt) { - try { - if (VcsConfigManager.getInstance().isUseAutoSave()) { - startAutoSave(VcsConfigManager.getInstance().getAutoSaveInterval()); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - - } - - /** - * 响应版本管理自动保存 - * - *
  • 直接用template的file来保存的话相当于拿源文件来保存模板,这样用户做的改动会丢失
  • - *
  • 因此需要自己实现一下自动保存的逻辑,将当前模板的数据导出,再拿这个Byte[]去做我们需要的保存处理
  • - *
  • 保存后需要触发清理逻辑
  • - * - * @param jt 模板 - */ - public void fireAutoSaveVcs(final JTemplate jt) { - 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); - } - } - }); - fireVcs.shutdown(); - } - 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); - String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); - List updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(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(); - } } - private void autoSave(JTemplate jt, String currentUsername, String fileName, int nowVersion, boolean replace, VcsOperator operator) { - try { - if (JTemplate.isValid(jt)) { - operator.autoSave(currentUsername, fileName, StringUtils.EMPTY, nowVersion, jt.exportData(), replace); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - - - - /** * 模板保存时 处理. * @@ -336,29 +237,6 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateClosed(JTemplate jt) { - try { - stopAutoSave(); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - - } - /** - * 判断是否支持V2功能 - * - * @return 支持返回true - */ - public boolean checkV2FunctionSupport() { - return !VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); - } - - /** - * 判断是否支持迁移功能 - * - * @return 支持返回true - */ - public boolean checkMoveFunctionSupport() { - return VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } } 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 deleted file mode 100644 index d92171d26a..0000000000 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java +++ /dev/null @@ -1,375 +0,0 @@ -package com.fr.design.mainframe.vcs.ui; - - -import com.fr.base.svg.IconUtils; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.BasicPane; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.iprogressbar.ModernUIProgressBarUI; -import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.VerticalFlowLayout; -import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.utils.DesignUtils; -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; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.List; -import java.util.concurrent.ExecutionException; - - -/** - * 迁移面板 - * - * @author Destiny.Lin - * @since 11.0 - * Created on 2023/6/13 - */ -public class VcsMovePanel extends BasicPane { - private static final FRFont FONT = DesignUtils - .getDefaultGUIFont() - .applySize(14) - .applyStyle(FRFont.BOLD); - - private static final Color BACK_GROUND_COLOR = new Color(202,232,255); - - //提示字体的颜色,直接模仿其他面板的写法 - private static final Color TIP_COLOR = new Color(51, 51, 52, (int)Math.round(0.5 * 255)); - - private static final Color LABEL_COLOR = new Color(34,149,233); - - private static final int MIN_VALUE = 1; - - private static final int MAX_VALUE = 999; - - private static final int STEP = 1; - - private static final int DEFAULT_VALUE = 5; - - public static final String SETTING = "SETTING"; - - public static final String PROCESS = "PROCESS"; - - public static final String SUCCESS = "SUCCESS"; - - public static final String FAILED = "FAILED"; - - public static boolean moving = false; - private UILabel vcsUpdateExistLabel; - private UILabel vcsUpdateFireLabel; - private BasicPane choosePane; - private CardLayout parentCard; - private JPanel parentPane; - private static final JProgressBar progressBar = new JProgressBar(); - - private JPanel progressPanel; - private UILabel tipLabel; - private UIButton successButton; - private UILabel iconLabel; - private UILabel successLabel; - private UILabel successTipLabel; - private UIButton failedButton; - private UILabel failedIconLabel; - private UILabel failedLabel; - private UILabel failedTipLabel; - - //保留全部 - private UIRadioButton moveAllButton; - //默认选项,保留部分 - private UIRadioButton moveDefaultButton; - //全部放弃 - private UIRadioButton moveNothingButton; - - private UISpinner spinner; - - - public VcsMovePanel(CardLayout cardLayout, JPanel parentPane) { - this.parentCard = cardLayout; - this.parentPane = parentPane; - this.setLayout(new BorderLayout()); - JPanel updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); - updatePane.setBackground(BACK_GROUND_COLOR); - //初始化迁移的面板 - initVcsLabel(updatePane); - //initVcsChoosePane - initVcsChoosePane(); - //初始化listener - initListener(); - this.add(updatePane); - checkVisible(); - //如果已经在迁移 - if (VcsMoveService.getInstance().isMoving()) { - initProcessPane(); - VcsMovePanel.this.getParentCard().show(getParentPane(), PROCESS); - } - } - - private void checkVisible() { - new SwingWorker() { - @Override - protected Boolean doInBackground() throws Exception { - return VcsHelper.getInstance().checkMoveFunctionSupport(); - } - @Override - protected void done() { - try { - boolean useMove = get(); - VcsMovePanel.this.setVisible(useMove); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - } - }.execute(); - } - - private void initProcessPane() { - JPanel processPane = new JPanel(); - JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - progressBar.setStringPainted(true); - progressBar.setUI(new ModernUIProgressBarUI()); - progressBar.setBorderPainted(false); - progressBar.setOpaque(false); - progressBar.setBorder(null); - progressBar.setSize(BasicDialog.MEDIUM); - body.add(progressBar); - body.add(new UILabel(StringUtils.BLANK)); - tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_While_Moving")); - tipLabel.setAlignmentX(CENTER_ALIGNMENT); - body.add(tipLabel); - processPane.add(body); - processPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); - parentPane.add(processPane, PROCESS); - } - - private void initVcsChoosePane() { - choosePane = new BasicPane() { - @Override - protected String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Vcs_Deal_With_Entry"); - } - }; - VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP); - layout.setAlignLeft(true); - choosePane.setLayout(layout); - - //初始化上方的文字板块 - initTopDesc(); - //初始化中间区域的单选框 - initRadioButton(); - //初始化下方的Tip描述 - initTipDesc(); - } - - private void initTopDesc() { - UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_How_To_Deal_With_Entry")); - choosePane.add(label); - } - - private void initTipDesc() { - UILabel descLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Desc")); - descLabel.setForeground(TIP_COLOR); - choosePane.add(descLabel); - } - - private void initRadioButton() { - //保留全部 - moveAllButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_All")); - //默认选项,保留部分 - moveDefaultButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Default")); - //全部放弃 - moveNothingButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Nothing")); - // 将按钮"保留部分"设置为选中状态 - moveDefaultButton.setSelected(true); - // 创建一个按钮组,添加三个按钮 - ButtonGroup buttonGroup = new ButtonGroup(); - buttonGroup.add(moveAllButton); - buttonGroup.add(moveDefaultButton); - buttonGroup.add(moveNothingButton); - - JPanel moveDefaultPanel = new JPanel(); - JPanel moveAllPane = new JPanel(); - JPanel moveNothingPane = new JPanel(); - moveAllPane.add(moveAllButton); - moveDefaultPanel.add(moveDefaultButton); - moveDefaultPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Default_Text_Left"))); - spinner = new UISpinner(MIN_VALUE, MAX_VALUE, STEP, DEFAULT_VALUE); - moveDefaultPanel.add(spinner); - moveDefaultPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Default_Text_Right"))); - moveNothingPane.add(moveNothingButton); - choosePane.add(moveAllPane); - choosePane.add(moveDefaultPanel); - choosePane.add(moveNothingPane); - } - - private void initVcsLabel(JPanel parent) { - vcsUpdateExistLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/vcs_move_icon.svg")); - vcsUpdateExistLabel.setText(Toolkit.i18nText("Fine-Design_Vcs_Can_Update")); - vcsUpdateFireLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Update")); - vcsUpdateFireLabel.setForeground(LABEL_COLOR); - vcsUpdateFireLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); - parent.add(vcsUpdateExistLabel); - parent.add(vcsUpdateFireLabel); - } - - private void initListener() { - vcsUpdateFireLabel.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - BasicDialog dlg = choosePane.showMediumWindow(SwingUtilities.getWindowAncestor(VcsMovePanel.this), new DialogActionAdapter() { - @Override - public void doOk() { - //进度条面板 - initProcessPane(); - VcsMovePanel.this.getParentCard().next(getParentPane()); - VcsMoveStrategy strategy; - if (moveDefaultButton.isSelected()) { - strategy = VcsMoveStrategy.createNumStrategy((int) spinner.getValue()); - } else if (moveNothingButton.isSelected()) { - strategy = VcsMoveStrategy.ALL_GIVE_UP; - } else { - strategy = VcsMoveStrategy.ALL_RETAIN; - } - new MoveWorker(strategy).execute(); - } - }); - dlg.setVisible(true); - } - }); - } - - private void initSuccessPane() { - JPanel successPane = new JPanel(); - JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - successButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Go")); - iconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_success.svg")); - successLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success")); - successLabel.setFont(FONT); - successTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Tip")); - successTipLabel.setForeground(TIP_COLOR); - body.add(iconLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(successLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(successTipLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(successButton); - successPane.add(body); - successPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); - parentPane.add(successPane, SUCCESS); - iconLabel.setAlignmentX(CENTER_ALIGNMENT); - successLabel.setAlignmentX(CENTER_ALIGNMENT); - successButton.setAlignmentX(CENTER_ALIGNMENT); - successTipLabel.setAlignmentX(CENTER_ALIGNMENT); - } - - - @Override - protected String title4PopupWindow() { - return StringUtils.EMPTY; - } - - public CardLayout getParentCard() { - return parentCard; - } - - public JPanel getParentPane() { - return parentPane; - } - - private void initFailedPane() { - JPanel failedPane = new JPanel(); - JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - failedButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Go")); - failedIconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_failed.svg")); - failedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed")); - failedLabel.setFont(FONT); - failedTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Tip")); - failedTipLabel.setForeground(TIP_COLOR); - body.add(failedIconLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(failedLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(failedTipLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(failedButton); - failedPane.add(body); - failedPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); - parentPane.add(failedPane, FAILED); - failedIconLabel.setAlignmentX(CENTER_ALIGNMENT); - failedLabel.setAlignmentX(CENTER_ALIGNMENT); - failedButton.setAlignmentX(CENTER_ALIGNMENT); - failedTipLabel.setAlignmentX(CENTER_ALIGNMENT); - } - - - private class MoveWorker extends SwingWorker { - - private VcsMoveStrategy strategy; - - public MoveWorker(VcsMoveStrategy strategy) { - this.strategy = strategy; - } - - @Override - protected Void doInBackground() throws Exception { - try { - //开始迁移 - VcsMoveService.getInstance().startMove(new VcsMoveService.MoveServiceWhileMoving() { - @Override - public void publishProgress() { - int num = VcsMoveService.getInstance().getCurrentMove(); - publish(num); - } - @Override - public void prepare4Move() { - progressBar.setMaximum(VcsMoveService.getInstance().getTotal()); - } - }, strategy); - } catch (Exception e) { - this.cancel(true); - VcsMoveService.getInstance().stopMoving(); - initFailedPane(); - VcsMovePanel.this.getParentCard().show(getParentPane(), FAILED); - FineLoggerFactory.getLogger().error("[VcsV2] Vcs move failed!"); - } - return null; - } - - @Override - protected void process(List chunks) { - progressBar.setValue(chunks.get(chunks.size() - 1)); - } - - @Override - protected void done() { - 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(); - } - } - - -} diff --git a/designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg b/designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg deleted file mode 100644 index 6d36a9dc0c..0000000000 --- a/designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/designer-base/src/main/resources/com/fr/design/vcs/move_success.svg b/designer-base/src/main/resources/com/fr/design/vcs/move_success.svg deleted file mode 100644 index 8b92bd8a04..0000000000 --- a/designer-base/src/main/resources/com/fr/design/vcs/move_success.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg b/designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg deleted file mode 100644 index a5ad91d09c..0000000000 --- a/designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - From 2614d67ebb456b262dfef8251ee843f7fec5f82f Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:59 +0800 Subject: [PATCH 8/9] =?UTF-8?q?Revert=20"REPORT-80651=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E9=87=8D=E6=9E=84=E4=B8=80?= =?UTF-8?q?=E6=9C=9F=E8=A1=A5=E4=BA=A4"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit be7a11b1033621d9f3914d65a725cd7f5d52b7b6. --- .../design/actions/file/PreferencePane.java | 5 +-- .../DesignerFrameFileDealerPane.java | 9 +--- .../mainframe/vcs/common/VcsHelper.java | 41 ++++--------------- 3 files changed, 10 insertions(+), 45 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 a83bcfd771..46485409bb 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 @@ -390,10 +390,7 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); - if (VcsHelper.getInstance().isLegacyMode()) { - // 老版本时才显示gc选项 - vcsPane.add(gcControlPane); - } + 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 174655127c..fc2f9c658c 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 (!isLegacyOnCluster()) { + if (!WorkContext.getCurrent().isCluster()) { 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() - || isLegacyOnCluster()) { + || WorkContext.getCurrent().isCluster()) { setEnabled(false); return; } @@ -810,11 +810,6 @@ 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 dd7187be23..980ccb5a3a 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,9 +12,6 @@ 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; @@ -23,14 +20,11 @@ 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; import javax.swing.Icon; -import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import java.awt.Color; import java.util.List; @@ -61,26 +55,10 @@ public class VcsHelper implements JTemplateActionListener { private final static String SERVICE_NAME_MOVE = "moveVcs"; private static final VcsHelper INSTANCE = new VcsHelper(); - private volatile boolean legacyMode; - public static VcsHelper getInstance() { return INSTANCE; } - private VcsHelper() { - VcsOperator op = WorkContext.getCurrent().get(VcsOperator.class); - // 开了设计器启动页面时一开始取不到VcsOperator,通过下面的切换环境事件再取,这边判断下 - if (op != null) { - legacyMode = op.isLegacyMode(); - } - EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { - @Override - public void on(Event event, Workspace param) { - legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); - } - }); - } - private int containsFolderCounts() { TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { @@ -159,18 +137,20 @@ public class VcsHelper implements JTemplateActionListener { 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 (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { - operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); + operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); - List updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); - SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); + FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY))); } else { - operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); + operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); + } + VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndexAndUsername(fileName, getCurrentUsername(), 1); + if (needDeleteVersion(oldEntity)) { + operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion()); } if (GcConfig.getInstance().isGcEnable()) { operator.gc(); @@ -208,13 +188,6 @@ public class VcsHelper implements JTemplateActionListener { moveVcs.shutdown(); } - /** - * 判断是否为老模式 - * @return 是否为老模式 - */ - public boolean isLegacyMode() { - return legacyMode; - } @Override public void templateOpened(JTemplate jt) { From c3434d1c1f9f7d1e3126d9b01b04218b49cfb59f Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 27 Jun 2023 12:09:37 +0800 Subject: [PATCH 9/9] =?UTF-8?q?REPORT-98879=20=E4=BF=AE=E5=A4=8Djxbrowser7?= =?UTF-8?q?=E5=9C=A8windows=E4=B8=8B=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/jxbrowser/JxUIPane.java | 25 ++++++++++++++++--- .../jxbrowser/NxInterceptRequestCallback.java | 10 ++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java index 1a968551df..efbca4a47e 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java @@ -8,6 +8,7 @@ import com.fr.design.ui.ModernUIConstants; import com.fr.design.ui.ModernUIPane; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; +import com.fr.stable.os.OperatingSystem; import com.fr.web.struct.AssembleComponent; import com.teamdev.jxbrowser.browser.Browser; import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; @@ -47,6 +48,12 @@ import static com.fr.design.ui.ModernUIConstants.WINDOW; */ public class JxUIPane extends ModernUIPane { + /** + * 冒号 + */ + public static final String COLON = ":"; + private static final String COLON_ESCAPE = "\\:"; + private Browser browser; private String namespace = "Pool"; private String variable = "data"; @@ -126,7 +133,7 @@ public class JxUIPane extends ModernUIPane { */ @Override public void redirect(String url) { - browser.navigation().loadUrl(url); + browser.navigation().loadUrl(encodeWindowsPath(url)); } /** @@ -138,7 +145,7 @@ public class JxUIPane extends ModernUIPane { @Override public void redirect(String url, Map map) { setMap(map); - browser.navigation().loadUrl(url); + browser.navigation().loadUrl(encodeWindowsPath(url)); } private void setMap(Map map) { @@ -220,6 +227,18 @@ public class JxUIPane extends ModernUIPane { return Optional.ofNullable(frame.executeJavaScript(name)); } + /** + * 由于自定义scheme目前走的是url,因此路径会被自动转化,比如windows路径下对冒号问题 + * C:\\abc 变成 /C/abc,这里对冒号进行编码转义 + */ + private static String encodeWindowsPath(String path) { + if (OperatingSystem.isWindows() && path.startsWith(EMB_TAG + SCHEME_HEADER)) { + String s = path.split(EMB_TAG + SCHEME_HEADER)[1]; + return EMB_TAG + SCHEME_HEADER + s.replace(COLON, COLON_ESCAPE); + } + return path; + } + /** * JxUIPane 的建造者 * @@ -492,7 +511,7 @@ public class JxUIPane extends ModernUIPane { pane.browser.navigation().on(listenerPair.getFirst(), listenerPair.getSecond()); } if (StringUtils.isNotEmpty(this.url)) { - pane.browser.navigation().loadUrl(this.url); + pane.browser.navigation().loadUrl(encodeWindowsPath(this.url)); } else if (StringUtils.isNotEmpty(this.html)) { pane.browser.mainFrame().ifPresent(f -> f.loadHtml(html)); } diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java index 6a578afa6e..ada7b2fff8 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java @@ -20,6 +20,7 @@ import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback; import org.jetbrains.annotations.NotNull; import java.io.InputStream; +import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.Optional; @@ -36,6 +37,8 @@ import static com.fr.design.ui.ModernUIConstants.COMPONENT_TAG; */ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { + private static final String COLON_DECODE_ESCAPE = "/:"; + private static final String SCHEME_SPLIT = ":/"; private Supplier component; private Supplier> renderParameterBuild; @@ -61,7 +64,7 @@ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { @Override public Response on(Params params) { UrlRequest urlRequest = params.urlRequest(); - String path = urlRequest.url(); + String path = urlRequest.url().replace(COLON_DECODE_ESCAPE, JxUIPane.COLON); Optional urlRequestJobOptional; if (path.startsWith(COMPONENT_TAG)) { String text = htmlText(renderParameterBuild.get()); @@ -107,7 +110,10 @@ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { path = path.substring(index + 1); } else { // jxbrowser 7之后,协议会自动补齐双斜杠// - path = path.split(":/")[1]; + int i = path.indexOf(SCHEME_SPLIT); + path = path.substring(i + SCHEME_SPLIT.length()); + // 通过自定义协议之后的url会自动encode一些中文字符,这里做一个decode,否则会导致路径访问失败 + path = URLDecoder.decode(path, StandardCharsets.UTF_8.name()); } return IOUtils.readResource(path); }