From 7ca66ff67907181ada372208e7700ce5a99aee25 Mon Sep 17 00:00:00 2001 From: lidongy <1879087903@qq.com> Date: Fri, 11 Feb 2022 13:45:35 +0800 Subject: [PATCH 01/20] =?UTF-8?q?KERNEL-9267=20feat:=20=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E7=9A=84CBB=E7=BB=84=E4=BB=B6=E7=9B=AE?= =?UTF-8?q?=E5=89=8D=E8=BF=87=E4=BA=8E=E5=86=97=E6=9D=82=EF=BC=8C=E6=B2=A1?= =?UTF-8?q?=E6=B3=95=E7=B2=BE=E7=AE=80=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle b/build.gradle index ee08bdeeac..4a634b11d4 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ plugins { // 模块参数 ext { frVersion = "" + cbbVersion = "" outputPath = "build" ignoreTestFailureSetting = true languageLevelSetting = 1.8 @@ -75,6 +76,8 @@ allprojects { implementation 'org.apache.tomcat:tomcat-catalina:8.5.72' implementation 'org.apache.tomcat:tomcat-websocket:8.5.72' implementation 'io.socket:socket.io-client:0.7.0' + implementation 'com.fr.essential:fine-essential:' + cbbVersion + implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.core:fine-core:' + frDevVersion implementation 'com.fr.activator:fine-activator:' + frVersion From 055935a364628583e8613a0067849a3e71ba815d Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 19 May 2023 16:33:25 +0800 Subject: [PATCH 02/20] =?UTF-8?q?REPORT-89867=20=E3=80=90=E9=99=8D?= =?UTF-8?q?=E6=9C=AC=E5=A2=9E=E6=95=88=E3=80=91=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extra/PluginBatchModifyDetailPane.java | 173 ++++++++++++++++++ .../fr/design/extra/PluginOperateUtils.java | 83 ++++++--- .../callback/BatchModifyStatusCallback.java | 139 ++++++++++++++ .../java/com/fr/design/upm/UpmBridge.java | 13 ++ 4 files changed, 387 insertions(+), 21 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java create mode 100644 designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java new file mode 100644 index 0000000000..41f5400387 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java @@ -0,0 +1,173 @@ +package com.fr.design.extra; + +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; + + +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * 插件批量处理弹窗面板 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2023/5/19 + */ +public class PluginBatchModifyDetailPane { + private UILabel message = new UILabel(); + private UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK")); + private UILabel uiLabel = new UILabel(); + private UILabel directUiLabel = new UILabel(); + private UILabel detailLabel = new UILabel(); + + private JPanel upPane; + private JPanel midPane; + private JPanel downPane; + private JPanel hiddenPanel; + private JTextArea jta; + private JDialog dialog; + + public PluginBatchModifyDetailPane(Dialog parent) { + init(parent); + } + + private void init(Dialog parent) { + message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); + dialog = new JDialog(parent, Toolkit.i18nText("Fine-Design_Basic_Plugin_Manager"), true); + dialog.setSize(new Dimension(380, 150)); + JPanel jp = new JPanel(); + initUpPane(); + initDownPane(); + initMidPane(); + initHiddenPanel(); + initListener(); + jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); + jp.add(upPane); + jp.add(midPane); + jp.add(hiddenPanel); + jp.add(downPane); + hiddenPanel.setVisible(false); + dialog.add(jp); + dialog.setResizable(false); + dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(parent)); + } + + private void initDownPane() { + downPane = new JPanel(); + downPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 15, 9)); + downPane.add(cancelButton); + } + + private void initUpPane() { + upPane = new JPanel(); + uiLabel = new UILabel(UIManager.getIcon("OptionPane.errorIcon")); + upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); + upPane.add(uiLabel); + upPane.add(message); + } + + private void initMidPane() { + midPane = new JPanel(); + midPane.add(directUiLabel); + midPane.add(detailLabel); + midPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0)); + detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); + detailLabel.setForeground(Color.BLUE); + detailLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right")); + } + + private void initHiddenPanel() { + hiddenPanel = new JPanel(); + hiddenPanel.setLayout(new BorderLayout(2, 0)); + hiddenPanel.add(new JPanel(), BorderLayout.WEST); + hiddenPanel.add(new JPanel(), BorderLayout.EAST); + JPanel borderPanel = new JPanel(); + borderPanel.setLayout(new BorderLayout()); + jta = new JTextArea(); + JScrollPane jsp = new JScrollPane(jta); + jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + jta.setEditable(false); + borderPanel.add(jsp, BorderLayout.CENTER); + hiddenPanel.add(borderPanel); + } + + public void updateDetailArea(String message) { + jta.append(message + "\n"); + } + + private void initListener() { + detailLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (hiddenPanel.isVisible()) { + hiddenPanel.setVisible(false); + dialog.setSize(new Dimension(380, 150)); + detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); + directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right")); + } else { + dialog.setSize(new Dimension(380, 270)); + hiddenPanel.setVisible(true); + detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail")); + directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down")); + } + } + + }); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + hiddenPanel.removeAll(); + dialog.dispose(); + } + }); + } + + /** + * 更新标题(启用插件还是禁用插件) + * @param isActive 是否启用 + */ + public void updateTitle(boolean isActive) { + if (isActive) { + dialog.setTitle(Toolkit.i18nText("Fine-Design_Basic_Plugin_Stop")); + } else { + dialog.setTitle(Toolkit.i18nText("Fine-Design_Basic_Plugin_Start")); + } + } + + /** + * 更新展示信息 + * + * @param failedCount 处理失败个数 + * @param successCount 处理成功个数 + */ + public void updateMessage(int failedCount, int successCount) { + message.setText(Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Info", failedCount, successCount)); + } + + /** + * 显示面板 + */ + public void show() { + dialog.setVisible(true); + } +} diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index 379daab28e..b6b86f11ff 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -3,6 +3,7 @@ package com.fr.design.extra; import com.fr.design.DesignerEnvManager; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.extra.exe.callback.BatchModifyStatusCallback; import com.fr.design.extra.exe.callback.InstallFromDiskCallback; import com.fr.design.extra.exe.callback.InstallOnlineCallback; import com.fr.design.extra.exe.callback.ModifyStatusCallback; @@ -28,11 +29,13 @@ import com.fr.plugin.view.PluginView; import com.fr.plugin.xml.PluginElementName; import com.fr.plugin.xml.PluginXmlElement; import com.fr.stable.StringUtils; +import com.teamdev.jxbrowser.chromium.JSArray; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import java.io.File; import java.net.HttpURLConnection; +import java.util.ArrayList; import java.util.List; @@ -92,6 +95,64 @@ public class PluginOperateUtils { } + /** + * 批量启用或禁用插件 + * + * @param pluginIDs 要处理的插件信息 + * @param jsCallback 回调函数 + */ + public static void setPluginActive(JSArray pluginIDs, JSCallback jsCallback) { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + List pluginInfos = new ArrayList<>(); + for (int i = 0, len = pluginIDs.length(); i < len; i++) { + String pluginInfo = pluginIDs.get(i).asString().getValue(); + pluginInfos.add(pluginInfo); + + } + BatchModifyStatusCallback modifyStatusCallback = new BatchModifyStatusCallback(jsCallback, pluginIDs.length()); + for (String pluginInfo : pluginInfos) { + PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); + dealWithPluginActive(pluginMarker, modifyStatusCallback); + } + } + }); + } + + private static void dealWithPluginActive(PluginMarker pluginMarker, BatchModifyStatusCallback modifyStatusCallback) { + PluginContext plugin = PluginManager.getContext(pluginMarker); + boolean isRunning = plugin.isRunning(); + modifyStatusCallback.setActive(isRunning); + changePluginActive(isRunning, pluginMarker, modifyStatusCallback, plugin); + + } + + private static void changePluginActive(boolean isRunning, PluginMarker pluginMarker, PluginTaskCallback modifyStatusCallback, PluginContext plugin) { + if (isRunning) { + PluginXmlElement forbidReminder = plugin.getXml().getElement(PluginElementName.ForbidReminder); + if (forbidReminder != null && forbidReminder.getContent() != null) { + // 禁用前提示 + int rv = FineJOptionPane.showConfirmDialog( + null, + forbidReminder.getContent(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.WARNING_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback); + } + } else { + // 正常禁用 + PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback); + } + } else { + PluginManager.getController().enablePersistently(pluginMarker, modifyStatusCallback); + } + } + public static void setPluginActive(String pluginInfo, JSCallback jsCallback) { SwingUtilities.invokeLater(new Runnable() { @@ -101,27 +162,7 @@ public class PluginOperateUtils { PluginContext plugin = PluginManager.getContext(pluginMarker); boolean isRunning = plugin.isRunning(); PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(isRunning, jsCallback); - if (isRunning) { - PluginXmlElement forbidReminder = plugin.getXml().getElement(PluginElementName.ForbidReminder); - if (forbidReminder != null && forbidReminder.getContent() != null) { - // 禁用前提示 - int rv = FineJOptionPane.showConfirmDialog( - null, - forbidReminder.getContent(), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.WARNING_MESSAGE - ); - if (rv == JOptionPane.OK_OPTION) { - PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback); - } - } else { - // 正常禁用 - PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback); - } - } else { - PluginManager.getController().enablePersistently(pluginMarker, modifyStatusCallback); - } + changePluginActive(isRunning, pluginMarker, modifyStatusCallback, plugin); } }); } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java new file mode 100644 index 0000000000..a815a8e369 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java @@ -0,0 +1,139 @@ +package com.fr.design.extra.exe.callback; + + +import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.bridge.exec.JSExecutor; + +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.extra.PluginBatchModifyDetailPane; +import com.fr.design.extra.PluginOperateUtils; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.plugin.DesignerPluginContext; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.context.PluginMarkerAdapter; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTask; +import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.manage.control.PluginTaskResult; +import com.fr.stable.StringUtils; + +import javax.swing.JOptionPane; +import java.util.HashMap; +import java.util.Map; + +/** + * 批量处理Callback + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2023/5/18 + */ +public class BatchModifyStatusCallback implements PluginTaskCallback { + private boolean isActive; + private JSCallback jsCallback = new JSCallback(JSExecutor.DEFAULT); + private Map resultMap = new HashMap<>(); + private int pluginCount = 0; + private int allPluginCount = 0; + private int successCount = 0; + private int failedCount = 0; + + + public BatchModifyStatusCallback(boolean isActive) { + this.isActive = isActive; + } + + public BatchModifyStatusCallback(boolean isActive, JSCallback jsCallback) { + this.isActive = isActive; + this.jsCallback = jsCallback; + } + + public BatchModifyStatusCallback(JSCallback jsCallback, int size) { + this.jsCallback = jsCallback; + allPluginCount = size; + } + + @Override + public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); + if (result.isSuccess()) { + successCount++; + String modifyMessage = isActive ? + pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : + pluginInfo + Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); + FineLoggerFactory.getLogger().info(modifyMessage); + updateMapAndCheckDone(); + } else { + failedCount++; + resultMap.put(getPluginName(result), pluginInfo); + updateMapAndCheckDone(); + } + } + + /** + * 更新当前Map状态,如果全部都更新完了就回调 + */ + public void updateMapAndCheckDone() { + pluginCount++; + if (pluginCount == allPluginCount) { + jsCallback.execute("success"); + showMessageDialog(); + } + } + + /** + * 获取插件名 + * + * @param result 任务结果 + * @return 插件名 + */ + public String getPluginName(PluginTaskResult result) { + PluginTask pluginTask = result.getCurrentTask(); + if (pluginTask != null) { + PluginMarker pluginMarker = pluginTask.getToMarker(); + PluginContext pluginContext = PluginManager.getContext(pluginMarker.getPluginID()); + if (pluginContext != null) { + return pluginContext.getName(); + } else if (pluginMarker instanceof PluginMarkerAdapter) { + return ((PluginMarkerAdapter) pluginMarker).getPluginName(); + } + return pluginMarker.getPluginID(); + } + return StringUtils.EMPTY; + } + + /** + * 展示信息面板 + */ + public void showMessageDialog() { + if (failedCount == 0) { + if (isActive) { + FineJOptionPane.showMessageDialog(DesignerPluginContext.getPluginDialog(), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Stop_Success"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Stop"), + JOptionPane.INFORMATION_MESSAGE); + } else { + FineJOptionPane.showMessageDialog(DesignerPluginContext.getPluginDialog(), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Start_Success"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Start"), + JOptionPane.INFORMATION_MESSAGE); + } + } else { + PluginBatchModifyDetailPane detailPane = new PluginBatchModifyDetailPane(DesignerPluginContext.getPluginDialog()); + for (String key : resultMap.keySet()) { + detailPane.updateDetailArea(resultMap.get(key)); + } + detailPane.updateMessage(failedCount, successCount); + detailPane.updateTitle(isActive); + detailPane.show(); + } + } + + public void setActive(boolean active) { + isActive = active; + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java index 01369116d7..11079561ab 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java @@ -40,6 +40,7 @@ import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.JSArray; import com.teamdev.jxbrowser.chromium.JSFunction; import com.teamdev.jxbrowser.chromium.JSObject; +import com.teamdev.jxbrowser.chromium.JSValue; import java.awt.Desktop; import javax.swing.JFileChooser; @@ -291,6 +292,18 @@ public class UpmBridge { PluginOperateUtils.setPluginActive(pluginID, jsCallback); } + /** + * 批量修改选中的插件的活跃状态 + * + * @param pluginIDs 要处理的插件ID + * @param callback 回调函数 + */ + @JSBridge + public void setAllPluginActive(JSArray pluginIDs, final JSFunction callback) { + JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); + PluginOperateUtils.setPluginActive(pluginIDs, jsCallback); + } + /** * 选择文件对话框 * From 649224ca52bad1ab089296641bfa566d33c12859 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 19 May 2023 16:35:40 +0800 Subject: [PATCH 03/20] =?UTF-8?q?REPORT-89867=20=E3=80=90=E9=99=8D?= =?UTF-8?q?=E6=9C=AC=E5=A2=9E=E6=95=88=E3=80=91=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginBatchModifyDetailPane.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java index 41f5400387..5f29293913 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java @@ -111,6 +111,11 @@ public class PluginBatchModifyDetailPane { hiddenPanel.add(borderPanel); } + /** + * 补充更详细的报错信息 + * + * @param message 信息 + */ public void updateDetailArea(String message) { jta.append(message + "\n"); } From a03030630c1b36a76f0be2d0659da5019dee28d7 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 19 May 2023 16:40:44 +0800 Subject: [PATCH 04/20] =?UTF-8?q?REPORT-89867=20=E3=80=90=E9=99=8D?= =?UTF-8?q?=E6=9C=AC=E5=A2=9E=E6=95=88=E3=80=91=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginOperateUtils.java | 6 +++--- .../exe/callback/BatchModifyStatusCallback.java | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index b6b86f11ff..e2324d1c08 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -123,9 +123,9 @@ public class PluginOperateUtils { private static void dealWithPluginActive(PluginMarker pluginMarker, BatchModifyStatusCallback modifyStatusCallback) { PluginContext plugin = PluginManager.getContext(pluginMarker); - boolean isRunning = plugin.isRunning(); - modifyStatusCallback.setActive(isRunning); - changePluginActive(isRunning, pluginMarker, modifyStatusCallback, plugin); + boolean running = plugin.isRunning(); + modifyStatusCallback.setActive(running); + changePluginActive(running, pluginMarker, modifyStatusCallback, plugin); } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java index a815a8e369..2e36590a56 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java @@ -32,7 +32,7 @@ import java.util.Map; * Created on 2023/5/18 */ public class BatchModifyStatusCallback implements PluginTaskCallback { - private boolean isActive; + private boolean active; private JSCallback jsCallback = new JSCallback(JSExecutor.DEFAULT); private Map resultMap = new HashMap<>(); private int pluginCount = 0; @@ -42,11 +42,11 @@ public class BatchModifyStatusCallback implements PluginTaskCallback { public BatchModifyStatusCallback(boolean isActive) { - this.isActive = isActive; + this.active = isActive; } public BatchModifyStatusCallback(boolean isActive, JSCallback jsCallback) { - this.isActive = isActive; + this.active = isActive; this.jsCallback = jsCallback; } @@ -60,7 +60,7 @@ public class BatchModifyStatusCallback implements PluginTaskCallback { String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { successCount++; - String modifyMessage = isActive ? + String modifyMessage = active ? pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : pluginInfo + Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); FineLoggerFactory.getLogger().info(modifyMessage); @@ -109,7 +109,7 @@ public class BatchModifyStatusCallback implements PluginTaskCallback { */ public void showMessageDialog() { if (failedCount == 0) { - if (isActive) { + if (active) { FineJOptionPane.showMessageDialog(DesignerPluginContext.getPluginDialog(), Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Stop_Success"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Stop"), @@ -126,13 +126,13 @@ public class BatchModifyStatusCallback implements PluginTaskCallback { detailPane.updateDetailArea(resultMap.get(key)); } detailPane.updateMessage(failedCount, successCount); - detailPane.updateTitle(isActive); + detailPane.updateTitle(active); detailPane.show(); } } public void setActive(boolean active) { - isActive = active; + this.active = active; } From 2a106e06538742c4531e06a39f63481f006a6feb Mon Sep 17 00:00:00 2001 From: "coral.chen@fanruan.com" Date: Wed, 24 May 2023 09:48:00 +0800 Subject: [PATCH 05/20] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=81=97=E6=BC=8F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/mobile/ui/MobileStylePane.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java index 6fefd7b7e3..aafc5d4e2b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java @@ -5,7 +5,7 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicPane; import com.fr.design.fun.MobileWidgetStyleProvider; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.mobile.processor.MobileStyleDefinePaneProcessor; +import com.fr.design.mainframe.mobile.processor.MobileStyleDefinePaneCreator; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; @@ -129,13 +129,13 @@ public class MobileStylePane extends BasicPane { listModel.addElement(displayName); try { - MobileStyleDefinePaneProcessor processor = ExtraDesignClassManager.getInstance().getSingle(MobileStyleDefinePaneProcessor.XML_TAG); + MobileStyleDefinePaneCreator processor = ExtraDesignClassManager.getInstance().getSingle(MobileStyleDefinePaneCreator.XML_TAG); BasicBeanPane mobileStyleBasicBeanPane = new MobileStyleDefinePane(widget, appearanceClazz, mobileStyleClazz); if (checkFlag && processor != null && processor.createBaseBeanPane(widget, appearanceClazz, mobileStyleClazz) != null) { mobileStyleBasicBeanPane = processor.createBaseBeanPane(widget, appearanceClazz, mobileStyleClazz); Class extraStyle = processor.classForCommonExtraStyle(widget); if (extraStyle != null) { - StyleClassMap.getCommonStyleMap().put(extraStyle.getName(), extraStyle.getName()); + StyleClassMap.putCommonStyle(extraStyle.getName(), extraStyle.getName()); } } right.add(displayName, mobileStyleBasicBeanPane); @@ -168,7 +168,7 @@ public class MobileStylePane extends BasicPane { EventDispatcher.listen(PluginEventType.AfterRun, new Listener() { @Override public void on(Event event, PluginContext pluginContext) { - if (pluginContext.getRuntime().contain(MobileStyleDefinePaneProcessor.XML_TAG)) { + if (pluginContext.getRuntime().contain(MobileStyleDefinePaneCreator.XML_TAG)) { checkFlag = true; refreshDockingView(); } @@ -177,7 +177,7 @@ public class MobileStylePane extends BasicPane { EventDispatcher.listen(PluginEventType.BeforeStop, new Listener() { @Override public void on(Event event, PluginContext pluginContext) { - if (pluginContext.getRuntime().contain(MobileStyleDefinePaneProcessor.XML_TAG)) { + if (pluginContext.getRuntime().contain(MobileStyleDefinePaneCreator.XML_TAG)) { checkFlag = false; refreshDockingView(); } From bd2d5847fb954dbd8693a4bc73f83d9f1b4594dd Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 6 Jun 2023 17:10:40 +0800 Subject: [PATCH 06/20] =?UTF-8?q?REPORT-89867=20=E3=80=90=E9=99=8D?= =?UTF-8?q?=E6=9C=AC=E5=A2=9E=E6=95=88=E3=80=91=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extra/PluginBatchModifyDetailPane.java | 12 +- .../fr/design/extra/PluginOperateUtils.java | 21 ++- .../AbstractBatchModifyStatusCallback.java | 128 ++++++++++++++++++ .../callback/BatchModifyStatusCallback.java | 126 ++--------------- .../callback/BatchUpdateOnlineCallback.java | 77 +++++++++++ 5 files changed, 240 insertions(+), 124 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/extra/exe/callback/AbstractBatchModifyStatusCallback.java create mode 100644 designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchUpdateOnlineCallback.java diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java index 5f29293913..31117a93c2 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java @@ -148,15 +148,11 @@ public class PluginBatchModifyDetailPane { } /** - * 更新标题(启用插件还是禁用插件) - * @param isActive 是否启用 + * 更新标题 + * @param title 标题 */ - public void updateTitle(boolean isActive) { - if (isActive) { - dialog.setTitle(Toolkit.i18nText("Fine-Design_Basic_Plugin_Stop")); - } else { - dialog.setTitle(Toolkit.i18nText("Fine-Design_Basic_Plugin_Start")); - } + public void updateTitle(String title) { + dialog.setTitle(title); } /** diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index e2324d1c08..bc0239eda6 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -4,6 +4,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.exe.callback.BatchModifyStatusCallback; +import com.fr.design.extra.exe.callback.BatchUpdateOnlineCallback; import com.fr.design.extra.exe.callback.InstallFromDiskCallback; import com.fr.design.extra.exe.callback.InstallOnlineCallback; import com.fr.design.extra.exe.callback.ModifyStatusCallback; @@ -68,12 +69,14 @@ public class PluginOperateUtils { public static void updatePluginOnline(List pluginMarkerList, JSCallback jsCallback) { - for (int i = 0; i < pluginMarkerList.size(); i++) { - updatePluginOnline(pluginMarkerList.get(i), jsCallback); + int size = pluginMarkerList.size(); + BatchUpdateOnlineCallback batchUpdateOnlineCallback = new BatchUpdateOnlineCallback(jsCallback, size); + for (int i = 0; i < size; i++) { + updatePluginOnline(pluginMarkerList.get(i), jsCallback, batchUpdateOnlineCallback); } } - public static void updatePluginOnline(PluginMarker pluginMarker, JSCallback jsCallback) { + private static void updatePluginOnline(PluginMarker pluginMarker, JSCallback jsCallback, BatchUpdateOnlineCallback batchUpdateOnlineCallback) { try { JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); String latestPluginVersion = latestPluginInfo.getString("version"); @@ -82,11 +85,19 @@ public class PluginOperateUtils { //当前已经安装的相同ID插件marker PluginMarker currentMarker = PluginMarkerAdapter.create(PluginUtils.getInstalledPluginMarkerByID(pluginMarker.getPluginID()), pluginName); PluginTask pluginTask = PluginTask.updateTask(currentMarker, toPluginMarker); - PluginControllerHelper.updateOnline(currentMarker, toPluginMarker, new UpdateOnlineCallback(pluginTask, jsCallback), PluginExtraInfo.newBuilder().username(DesignerEnvManager.getEnvManager().getDesignerLoginUsername()).build()); + if (!batchUpdateOnlineCallback.equals(BatchUpdateOnlineCallback.NONE)) { + batchUpdateOnlineCallback.createInnerPreTaskCallback(pluginTask, jsCallback); + PluginControllerHelper.updateOnline(currentMarker, toPluginMarker, batchUpdateOnlineCallback.getInnerPreTaskCallback(), PluginExtraInfo.newBuilder().username(DesignerEnvManager.getEnvManager().getDesignerLoginUsername()).build()); + } else { + PluginControllerHelper.updateOnline(currentMarker, toPluginMarker, new UpdateOnlineCallback(pluginTask, jsCallback), PluginExtraInfo.newBuilder().username(DesignerEnvManager.getEnvManager().getDesignerLoginUsername()).build()); + } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } + } + public static void updatePluginOnline(PluginMarker pluginMarker, JSCallback jsCallback) { + updatePluginOnline(pluginMarker, jsCallback, BatchUpdateOnlineCallback.NONE); } @@ -124,7 +135,7 @@ public class PluginOperateUtils { private static void dealWithPluginActive(PluginMarker pluginMarker, BatchModifyStatusCallback modifyStatusCallback) { PluginContext plugin = PluginManager.getContext(pluginMarker); boolean running = plugin.isRunning(); - modifyStatusCallback.setActive(running); + modifyStatusCallback.updateActiveStatus(running); changePluginActive(running, pluginMarker, modifyStatusCallback, plugin); } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/AbstractBatchModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/AbstractBatchModifyStatusCallback.java new file mode 100644 index 0000000000..2aaef96b22 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/AbstractBatchModifyStatusCallback.java @@ -0,0 +1,128 @@ +package com.fr.design.extra.exe.callback; + +import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.extra.PluginBatchModifyDetailPane; +import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.design.plugin.DesignerPluginContext; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.manage.control.PluginTask; +import com.fr.plugin.manage.control.PluginTaskResult; +import com.fr.plugin.manage.control.ProgressCallback; +import com.fr.stable.StringUtils; + +import javax.swing.JOptionPane; +import java.util.HashMap; +import java.util.Map; + +/** + * 带进度条的批量处理的callback + *
  • content与title是处理完成后弹出的面板的内容与标题,子类需要在done之前设定好对应的信息 + *
  • 进度条是以 当前完成任务数/总任务数 来计算的 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2023/6/6 + */ +public abstract class AbstractBatchModifyStatusCallback implements ProgressCallback { + protected JSCallback jsCallback; + protected Map resultMap = new HashMap<>(); + protected String content = StringUtils.EMPTY; + protected String title = StringUtils.EMPTY; + public int pluginCount = 0; + public int allPluginCount = 0; + public int successCount = 0; + public int failedCount = 0; + public static final int HUNDRED_PERCENT = 100; + public static final String PERCENT = "%"; + public static final String DEFAULT = "default"; + + public AbstractBatchModifyStatusCallback() { + } + + public AbstractBatchModifyStatusCallback(JSCallback jsCallback, int size) { + this.jsCallback = jsCallback; + this.allPluginCount = size; + } + + @Override + public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); + if (result.isSuccess()) { + successCount++; + String modifyMessage = updateMessage(pluginInfo); + FineLoggerFactory.getLogger().info(modifyMessage); + } else { + failedCount++; + resultMap.put(getPluginName(result), pluginInfo); + } + updateProgressAndCheckCompletion(); + } + + + /** + * 获取插件名 + * + * @param result 任务结果 + * @return 插件名 + */ + public String getPluginName(PluginTaskResult result) { + PluginTask pluginTask = result.getCurrentTask(); + if (pluginTask != null) { + PluginMarker pluginMarker = pluginTask.getToMarker(); + if (pluginMarker != null) { + return pluginMarker.getPluginID(); + } + } + return DEFAULT; + } + + + /** + * 更新当前Map状态,进度条,如果全部都更新完了就回调 + */ + public void updateProgressAndCheckCompletion() { + pluginCount++; + updateProgress(StringUtils.EMPTY, (double) pluginCount / allPluginCount); + FineLoggerFactory.getLogger().error("(double) pluginCount / allPluginCount:{}", (double) pluginCount / allPluginCount); + if (pluginCount == allPluginCount) { + jsCallback.execute("success"); + showMessageDialog(); + } + } + + /** + * 展示信息面板 + */ + public void showMessageDialog() { + if (failedCount == 0) { + FineJOptionPane.showMessageDialog(DesignerPluginContext.getPluginDialog(), + content, + title, + JOptionPane.INFORMATION_MESSAGE); + } else { + PluginBatchModifyDetailPane detailPane = new PluginBatchModifyDetailPane(DesignerPluginContext.getPluginDialog()); + for (String key : resultMap.keySet()) { + detailPane.updateDetailArea(resultMap.get(key)); + } + detailPane.updateMessage(failedCount, successCount); + detailPane.updateTitle(title); + detailPane.show(); + } + } + + + @Override + public void updateProgress(String description, double progress) { + jsCallback.execute(progress * HUNDRED_PERCENT + PERCENT); + } + + /** + * 更新处理成功返回的日志信息 + * + * @return 返回的日志信息 + */ + abstract public String updateMessage(String pluginInfo); +} diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java index 2e36590a56..00c0e8b07a 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchModifyStatusCallback.java @@ -2,138 +2,42 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; -import com.fr.design.bridge.exec.JSExecutor; - -import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.extra.PluginBatchModifyDetailPane; -import com.fr.design.extra.PluginOperateUtils; import com.fr.design.i18n.Toolkit; -import com.fr.design.plugin.DesignerPluginContext; -import com.fr.log.FineLoggerFactory; -import com.fr.plugin.context.PluginContext; -import com.fr.plugin.context.PluginMarker; -import com.fr.plugin.context.PluginMarkerAdapter; -import com.fr.plugin.manage.PluginManager; -import com.fr.plugin.manage.control.PluginTask; -import com.fr.plugin.manage.control.PluginTaskCallback; -import com.fr.plugin.manage.control.PluginTaskResult; -import com.fr.stable.StringUtils; -import javax.swing.JOptionPane; -import java.util.HashMap; -import java.util.Map; /** - * 批量处理Callback + * 批量启用/禁用插件的Callback * * @author Destiny.Lin * @since 11.0 * Created on 2023/5/18 */ -public class BatchModifyStatusCallback implements PluginTaskCallback { +public class BatchModifyStatusCallback extends AbstractBatchModifyStatusCallback { private boolean active; - private JSCallback jsCallback = new JSCallback(JSExecutor.DEFAULT); - private Map resultMap = new HashMap<>(); - private int pluginCount = 0; - private int allPluginCount = 0; - private int successCount = 0; - private int failedCount = 0; - - - public BatchModifyStatusCallback(boolean isActive) { - this.active = isActive; - } - - public BatchModifyStatusCallback(boolean isActive, JSCallback jsCallback) { - this.active = isActive; - this.jsCallback = jsCallback; - } + private boolean operatorFlag = false; public BatchModifyStatusCallback(JSCallback jsCallback, int size) { - this.jsCallback = jsCallback; - allPluginCount = size; + super(jsCallback, size); } - @Override - public void done(PluginTaskResult result) { - String pluginInfo = PluginOperateUtils.getSuccessInfo(result); - if (result.isSuccess()) { - successCount++; - String modifyMessage = active ? - pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : - pluginInfo + Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); - FineLoggerFactory.getLogger().info(modifyMessage); - updateMapAndCheckDone(); - } else { - failedCount++; - resultMap.put(getPluginName(result), pluginInfo); - updateMapAndCheckDone(); - } - } - /** - * 更新当前Map状态,如果全部都更新完了就回调 - */ - public void updateMapAndCheckDone() { - pluginCount++; - if (pluginCount == allPluginCount) { - jsCallback.execute("success"); - showMessageDialog(); - } + @Override + public String updateMessage(String pluginInfo) { + return active ? pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : pluginInfo + Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); } /** - * 获取插件名 + * 更新启用/禁用信息 * - * @param result 任务结果 - * @return 插件名 + * @param active */ - public String getPluginName(PluginTaskResult result) { - PluginTask pluginTask = result.getCurrentTask(); - if (pluginTask != null) { - PluginMarker pluginMarker = pluginTask.getToMarker(); - PluginContext pluginContext = PluginManager.getContext(pluginMarker.getPluginID()); - if (pluginContext != null) { - return pluginContext.getName(); - } else if (pluginMarker instanceof PluginMarkerAdapter) { - return ((PluginMarkerAdapter) pluginMarker).getPluginName(); - } - return pluginMarker.getPluginID(); + public void updateActiveStatus(boolean active) { + if (!operatorFlag) { + this.active = active; + this.operatorFlag = true; + this.title = active ? Toolkit.i18nText("Fine-Design_Basic_Plugin_Stop") : Toolkit.i18nText("Fine-Design_Basic_Plugin_Start"); + this.content = active ? Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Stop_Success") : Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Start_Success"); } - return StringUtils.EMPTY; } - - /** - * 展示信息面板 - */ - public void showMessageDialog() { - if (failedCount == 0) { - if (active) { - FineJOptionPane.showMessageDialog(DesignerPluginContext.getPluginDialog(), - Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Stop_Success"), - Toolkit.i18nText("Fine-Design_Basic_Plugin_Stop"), - JOptionPane.INFORMATION_MESSAGE); - } else { - FineJOptionPane.showMessageDialog(DesignerPluginContext.getPluginDialog(), - Toolkit.i18nText("Fine-Design_Basic_Plugin_Batch_Modify_Start_Success"), - Toolkit.i18nText("Fine-Design_Basic_Plugin_Start"), - JOptionPane.INFORMATION_MESSAGE); - } - } else { - PluginBatchModifyDetailPane detailPane = new PluginBatchModifyDetailPane(DesignerPluginContext.getPluginDialog()); - for (String key : resultMap.keySet()) { - detailPane.updateDetailArea(resultMap.get(key)); - } - detailPane.updateMessage(failedCount, successCount); - detailPane.updateTitle(active); - detailPane.show(); - } - } - - public void setActive(boolean active) { - this.active = active; - } - - } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchUpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchUpdateOnlineCallback.java new file mode 100644 index 0000000000..6d93ac1a10 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/BatchUpdateOnlineCallback.java @@ -0,0 +1,77 @@ +package com.fr.design.extra.exe.callback; + + +import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.i18n.Toolkit; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.manage.control.PluginTask; +import com.fr.plugin.manage.control.PluginTaskResult; + + +/** + * 批量更新的callback + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2023/6/6 + */ +public class BatchUpdateOnlineCallback extends AbstractBatchModifyStatusCallback{ + public static final BatchUpdateOnlineCallback NONE = new BatchUpdateOnlineCallback(); + + /** + * 可自动处理前置任务的callback,用来处理实际更新逻辑 + */ + private InnerUpdateCallback innerPreTaskCallback; + + public BatchUpdateOnlineCallback() { + } + + public BatchUpdateOnlineCallback(JSCallback jsCallback, int size) { + super(jsCallback, size); + this.title = Toolkit.i18nText("Fine-Design_Basic_Plugin_Update"); + this.content = Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"); + } + + /** + * 更新任务 + * + * @param pluginTask 任务 + * @param jsCallback callback + */ + public void createInnerPreTaskCallback(PluginTask pluginTask, JSCallback jsCallback) { + innerPreTaskCallback = new InnerUpdateCallback(pluginTask, jsCallback); + } + + + + public InnerUpdateCallback getInnerPreTaskCallback() { + return innerPreTaskCallback; + } + + @Override + public String updateMessage(String pluginInfo) { + return pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"); + } + + /** + * 可自动处理前置任务的callback,用来处理实际更新逻辑 + */ + public class InnerUpdateCallback extends UpdateOnlineCallback { + + + public InnerUpdateCallback(PluginTask pluginTask, JSCallback jsCallback) { + super(pluginTask, jsCallback); + + } + + @Override + public void updateProgress(String description, double aProgress) { + //不进行处理 + } + + @Override + public void allDone(PluginTaskResult result) { + BatchUpdateOnlineCallback.this.done(result); + } + } +} From da1d66e66388faf758ba462d04e617f93fcaecbc Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 6 Jun 2023 17:18:17 +0800 Subject: [PATCH 07/20] =?UTF-8?q?REPORT-89867=20=E3=80=90=E9=99=8D?= =?UTF-8?q?=E6=9C=AC=E5=A2=9E=E6=95=88=E3=80=91=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extra/exe/callback/AbstractBatchModifyStatusCallback.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/AbstractBatchModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/AbstractBatchModifyStatusCallback.java index 2aaef96b22..1b3663a2ba 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/AbstractBatchModifyStatusCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/AbstractBatchModifyStatusCallback.java @@ -86,7 +86,6 @@ public abstract class AbstractBatchModifyStatusCallback implements ProgressCallb public void updateProgressAndCheckCompletion() { pluginCount++; updateProgress(StringUtils.EMPTY, (double) pluginCount / allPluginCount); - FineLoggerFactory.getLogger().error("(double) pluginCount / allPluginCount:{}", (double) pluginCount / allPluginCount); if (pluginCount == allPluginCount) { jsCallback.execute("success"); showMessageDialog(); From f276fa142701590365aff769e0cfe00aa97791cf Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 7 Jun 2023 09:31:13 +0800 Subject: [PATCH 08/20] =?UTF-8?q?REPORT-89867=20=E3=80=90=E9=99=8D?= =?UTF-8?q?=E6=9C=AC=E5=A2=9E=E6=95=88=E3=80=91=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/extra/PluginOperateUtils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index bc0239eda6..a5aa14a300 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -96,6 +96,12 @@ public class PluginOperateUtils { } } + /** + * 更新插件 + * + * @param pluginMarker 插件marker + * @param jsCallback 回调 + */ public static void updatePluginOnline(PluginMarker pluginMarker, JSCallback jsCallback) { updatePluginOnline(pluginMarker, jsCallback, BatchUpdateOnlineCallback.NONE); } From c72da02f57af4166037580f9bc47e15745364a45 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 7 Jun 2023 09:50:57 +0800 Subject: [PATCH 09/20] =?UTF-8?q?REPORT-89867=20=E3=80=90=E9=99=8D?= =?UTF-8?q?=E6=9C=AC=E5=A2=9E=E6=95=88=E3=80=91=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BC=98=E5=8C=96=20=E5=8E=BB=E9=99=A4=E4=B8=A4?= =?UTF-8?q?=E6=AC=A1for=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginOperateUtils.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index a5aa14a300..8baccba847 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -123,14 +123,10 @@ public class PluginOperateUtils { @Override public void run() { - List pluginInfos = new ArrayList<>(); - for (int i = 0, len = pluginIDs.length(); i < len; i++) { + int len = pluginIDs.length(); + BatchModifyStatusCallback modifyStatusCallback = new BatchModifyStatusCallback(jsCallback, len); + for (int i = 0; i < len; i++) { String pluginInfo = pluginIDs.get(i).asString().getValue(); - pluginInfos.add(pluginInfo); - - } - BatchModifyStatusCallback modifyStatusCallback = new BatchModifyStatusCallback(jsCallback, pluginIDs.length()); - for (String pluginInfo : pluginInfos) { PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); dealWithPluginActive(pluginMarker, modifyStatusCallback); } @@ -313,8 +309,7 @@ public class PluginOperateUtils { private static String getPluginName(PluginContext pluginContext, PluginMarker pluginMarker) { if (pluginContext != null) { return pluginContext.getName(); - } - else if (pluginMarker instanceof PluginMarkerAdapter) { + } else if (pluginMarker instanceof PluginMarkerAdapter) { return ((PluginMarkerAdapter) pluginMarker).getPluginName(); } return pluginMarker == null ? StringUtils.EMPTY : pluginMarker.getPluginID(); From 609e9ce595488b0da58b4ad326d69b15c217576c Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 7 Jun 2023 10:44:59 +0800 Subject: [PATCH 10/20] =?UTF-8?q?REPORT-89867=20=E3=80=90=E9=99=8D?= =?UTF-8?q?=E6=9C=AC=E5=A2=9E=E6=95=88=E3=80=91=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BC=98=E5=8C=96=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extra/PluginBatchModifyDetailPane.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java index 31117a93c2..3c086b7ea8 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginBatchModifyDetailPane.java @@ -45,6 +45,16 @@ public class PluginBatchModifyDetailPane { private JTextArea jta; private JDialog dialog; + /** + * 弹窗面板默认大小 + */ + public static final Dimension DEFAULT = new Dimension(380, 150); + + /** + * 弹窗面板展开大小 + */ + public static final Dimension DEFAULT_PRO = new Dimension(380, 270); + public PluginBatchModifyDetailPane(Dialog parent) { init(parent); } @@ -52,7 +62,7 @@ public class PluginBatchModifyDetailPane { private void init(Dialog parent) { message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); dialog = new JDialog(parent, Toolkit.i18nText("Fine-Design_Basic_Plugin_Manager"), true); - dialog.setSize(new Dimension(380, 150)); + dialog.setSize(DEFAULT); JPanel jp = new JPanel(); initUpPane(); initDownPane(); @@ -126,11 +136,11 @@ public class PluginBatchModifyDetailPane { public void mouseClicked(MouseEvent e) { if (hiddenPanel.isVisible()) { hiddenPanel.setVisible(false); - dialog.setSize(new Dimension(380, 150)); + dialog.setSize(DEFAULT); detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right")); } else { - dialog.setSize(new Dimension(380, 270)); + dialog.setSize(DEFAULT_PRO); hiddenPanel.setVisible(true); detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail")); directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down")); From be7a11b1033621d9f3914d65a725cd7f5d52b7b6 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 8 Jun 2023 15:05:53 +0800 Subject: [PATCH 11/20] =?UTF-8?q?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 --- .../design/actions/file/PreferencePane.java | 5 ++- .../DesignerFrameFileDealerPane.java | 9 +++- .../mainframe/vcs/common/VcsHelper.java | 41 +++++++++++++++---- 3 files changed, 45 insertions(+), 10 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 46485409bb..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 @@ -390,7 +390,10 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); - vcsPane.add(gcControlPane); + 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 fc2f9c658c..174655127c 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 980ccb5a3a..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 @@ -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,11 +23,14 @@ 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; @@ -55,10 +61,26 @@ 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) { @@ -137,20 +159,18 @@ 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); + operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); - FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY))); + List updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); + SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); } else { - 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()); + operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); } if (GcConfig.getInstance().isGcEnable()) { operator.gc(); @@ -188,6 +208,13 @@ public class VcsHelper implements JTemplateActionListener { moveVcs.shutdown(); } + /** + * 判断是否为老模式 + * @return 是否为老模式 + */ + public boolean isLegacyMode() { + return legacyMode; + } @Override public void templateOpened(JTemplate jt) { From b077f84d04caeb52353fc1cf4274e14f204fc4b5 Mon Sep 17 00:00:00 2001 From: lidongy <1879087903@qq.com> Date: Thu, 15 Jun 2023 11:46:24 +0800 Subject: [PATCH 12/20] =?UTF-8?q?REPORT-86153=E3=80=90=E4=BF=A1=E5=88=9B?= =?UTF-8?q?=E3=80=91=E8=BE=BE=E6=A2=A6=E6=95=B0=E6=8D=AE=E5=BA=93=E9=80=82?= =?UTF-8?q?=E9=85=8D=E5=AD=98=E5=82=A8=E8=BF=87=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/tabledata/tabledatapane/ProcedureDataPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java index d2a1918d4f..a71f883194 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java @@ -59,7 +59,8 @@ public class ProcedureDataPane extends AbstractTableDataPane imp "com.microsoft.sqlserver.jdbc.SQLServerDriver", "com.ibm.db2.jcc.DB2Driver", "com.mysql.jdbc.Driver", - "org.gjt.mm.mysql.Driver" + "org.gjt.mm.mysql.Driver", + "dm.jdbc.driver.DmDriver" }; // 需要隐藏面板的数据库的驱动 private static final String PREVIEW_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); private ConnectionTableProcedurePane connectionTableProcedurePane; From b06b2416055469c5711e4bc8d065f96ce591afe8 Mon Sep 17 00:00:00 2001 From: lidongy <1879087903@qq.com> Date: Thu, 15 Jun 2023 11:49:07 +0800 Subject: [PATCH 13/20] =?UTF-8?q?REPORT-86153=20=E8=AF=AF=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.gradle b/build.gradle index 4a634b11d4..ee08bdeeac 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,6 @@ plugins { // 模块参数 ext { frVersion = "" - cbbVersion = "" outputPath = "build" ignoreTestFailureSetting = true languageLevelSetting = 1.8 @@ -76,8 +75,6 @@ allprojects { implementation 'org.apache.tomcat:tomcat-catalina:8.5.72' implementation 'org.apache.tomcat:tomcat-websocket:8.5.72' implementation 'io.socket:socket.io-client:0.7.0' - implementation 'com.fr.essential:fine-essential:' + cbbVersion - implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.core:fine-core:' + frDevVersion implementation 'com.fr.activator:fine-activator:' + frVersion From b5518abfb66cfcf1e6a06b9e8032b23643ad38b1 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 16 Jun 2023 17:47:29 +0800 Subject: [PATCH 14/20] =?UTF-8?q?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 --- .../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, 691 insertions(+), 14 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java create mode 100644 designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg create mode 100644 designer-base/src/main/resources/com/fr/design/vcs/move_success.svg create 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 a83bcfd771..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 @@ -36,6 +36,7 @@ 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; @@ -54,9 +55,12 @@ 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; @@ -77,14 +81,7 @@ import javax.swing.UIManager; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -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.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -149,6 +146,32 @@ 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; @@ -186,8 +209,17 @@ 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; @@ -227,13 +259,26 @@ 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); - createVcsSettingPane(generalPane); + + // vcsPane + createVcsSettingPane(vcsPane, vcsParentPane, cardLayout); // ConfPane JPanel confLocationPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane(); @@ -345,21 +390,31 @@ public class PreferencePane extends BasicPane { return generalPanelWithScroll; } - private void createVcsSettingPane(JPanel generalPane) { - JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); - generalPane.add(vcsPane); + 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); 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")); @@ -368,6 +423,7 @@ 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) { @@ -390,12 +446,44 @@ 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 配置操作面板 * @@ -799,6 +887,10 @@ 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()); @@ -878,6 +970,21 @@ 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. */ @@ -923,6 +1030,17 @@ 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 @@ -997,6 +1115,31 @@ 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 f61bba67a8..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 @@ -16,6 +16,10 @@ 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; } @@ -48,6 +52,23 @@ 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; } @@ -58,7 +79,8 @@ 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)); } } @@ -69,6 +91,8 @@ 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 dd7187be23..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 @@ -36,6 +36,8 @@ 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. @@ -61,6 +63,8 @@ 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() { @@ -81,6 +85,37 @@ 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) { @@ -218,9 +253,73 @@ 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()); + } + } + + + + /** * 模板保存时 处理. * @@ -237,6 +336,29 @@ 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 new file mode 100644 index 0000000000..d92171d26a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java @@ -0,0 +1,375 @@ +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 new file mode 100644 index 0000000000..6d36a9dc0c --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg @@ -0,0 +1,5 @@ + + + + + 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 new file mode 100644 index 0000000000..8b92bd8a04 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/vcs/move_success.svg @@ -0,0 +1,5 @@ + + + + + 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 new file mode 100644 index 0000000000..a5ad91d09c --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg @@ -0,0 +1,3 @@ + + + From fa34777dd506b4fc32e8811cd0ff1f7d10dcf6f1 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 16 Jun 2023 18:01:03 +0800 Subject: [PATCH 15/20] =?UTF-8?q?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 --- .../mainframe/vcs/common/VcsHelper.java | 5 ++-- .../design/mainframe/vcs/ui/VcsMovePanel.java | 28 +++++++++++-------- 2 files changed, 19 insertions(+), 14 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 7ec79ca938..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 @@ -190,7 +190,6 @@ 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); @@ -213,7 +212,9 @@ public class VcsHelper implements JTemplateActionListener { } }); - fireVcs.shutdown(); + if (!fireVcs.isShutdown()) { + 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 d92171d26a..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 @@ -26,7 +26,11 @@ 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 javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -76,7 +80,7 @@ public class VcsMovePanel extends BasicPane { private BasicPane choosePane; private CardLayout parentCard; private JPanel parentPane; - private static final JProgressBar progressBar = new JProgressBar(); + private static final JProgressBar PROGRESS_BAR = new JProgressBar(); private JPanel progressPanel; private UILabel tipLabel; @@ -141,13 +145,13 @@ public class VcsMovePanel extends BasicPane { 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); + 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); body.add(new UILabel(StringUtils.BLANK)); tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_While_Moving")); tipLabel.setAlignmentX(CENTER_ALIGNMENT); @@ -330,7 +334,7 @@ public class VcsMovePanel extends BasicPane { protected Void doInBackground() throws Exception { try { //开始迁移 - VcsMoveService.getInstance().startMove(new VcsMoveService.MoveServiceWhileMoving() { + VcsMoveService.getInstance().startMove(new VcsMoveService.BaseMoveServiceWhileMoving() { @Override public void publishProgress() { int num = VcsMoveService.getInstance().getCurrentMove(); @@ -338,7 +342,7 @@ public class VcsMovePanel extends BasicPane { } @Override public void prepare4Move() { - progressBar.setMaximum(VcsMoveService.getInstance().getTotal()); + PROGRESS_BAR.setMaximum(VcsMoveService.getInstance().getTotal()); } }, strategy); } catch (Exception e) { @@ -353,7 +357,7 @@ public class VcsMovePanel extends BasicPane { @Override protected void process(List chunks) { - progressBar.setValue(chunks.get(chunks.size() - 1)); + PROGRESS_BAR.setValue(chunks.get(chunks.size() - 1)); } @Override From 4bd02cf06aae5999a8b3f69c870284e044289ceb Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 16 Jun 2023 19:06:48 +0800 Subject: [PATCH 16/20] =?UTF-8?q?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 --- .../java/com/fr/design/mainframe/vcs/common/VcsHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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..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 @@ -25,6 +25,7 @@ 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; @@ -351,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()); } /** @@ -360,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()); } } From 6694648b918db44813a7db75d03421d51bc5ebb0 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Sun, 18 Jun 2023 19:52:39 +0800 Subject: [PATCH 17/20] =?UTF-8?q?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 --- .../mainframe/vcs/common/VcsHelper.java | 27 ++++++++++++------- .../design/mainframe/vcs/ui/VcsMovePanel.java | 1 + 2 files changed, 19 insertions(+), 9 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..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 @@ -2,6 +2,7 @@ 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; @@ -14,7 +15,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.Listener; +import com.fr.event.ListenerAdaptor; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; @@ -23,9 +24,6 @@ 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; @@ -78,9 +76,9 @@ public class VcsHelper implements JTemplateActionListener { if (op != null) { legacyMode = op.isLegacyMode(); } - EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { + EventDispatcher.listen(ConfigEvent.READY, new ListenerAdaptor() { @Override - public void on(Event event, Workspace param) { + protected void on(Event event) { legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); } }); @@ -253,6 +251,15 @@ public class VcsHelper implements JTemplateActionListener { return legacyMode; } + /** + * 更新当前的legacyMode状态 + *
  • 目前用在迁移结束后更新模式为新模式
  • + * + */ + public void updateLegacyMode() { + this.legacyMode = !legacyMode; + } + @Override public void templateOpened(JTemplate jt) { try { @@ -292,7 +299,9 @@ public class VcsHelper implements JTemplateActionListener { } } }); - fireVcs.shutdown(); + if (!fireVcs.isShutdown()) { + fireVcs.shutdown(); + } } private void doSave(JTemplate jt, String fileName, int latestFileVersion, boolean replace, VcsOperator operator) { @@ -352,7 +361,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 +370,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()); } } 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..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 @@ -372,6 +372,7 @@ public class VcsMovePanel extends BasicPane { } }); VcsManager.getInstance().updateManager(); + VcsHelper.getInstance().updateLegacyMode(); } } From 4682898c6763b0720024035948a68964aa72a65e Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Sun, 18 Jun 2023 20:45:49 +0800 Subject: [PATCH 18/20] =?UTF-8?q?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 --- .../design/actions/file/PreferencePane.java | 23 ++++- .../design/mainframe/vcs/ui/VcsMovePanel.java | 95 +++++++++++++------ 2 files changed, 86 insertions(+), 32 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 d816131dee..4d31904f1f 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,6 +220,9 @@ 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; @@ -392,7 +395,7 @@ public class PreferencePane extends BasicPane { private void createVcsSettingPane(JPanel generalPane,JPanel parentPane, CardLayout cardLayout) { //迁移面板 - movePanel = new VcsMovePanel(cardLayout, parentPane); + movePanel = createMovePane(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")); @@ -404,7 +407,7 @@ public class PreferencePane extends BasicPane { remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); vcsEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_SaveAuto")); - JPanel saveIntervalPane = createSaveIntervalPane(); + saveIntervalPane = createSaveIntervalPane(); saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete")); saveIntervalEditor = new IntegerEditor(60); useIntervalCheckBox = new UICheckBox(); @@ -423,7 +426,7 @@ public class PreferencePane extends BasicPane { intervalPanel.add(everyLabel); intervalPanel.add(saveIntervalEditor); intervalPanel.add(delayLabel); - JPanel autoCleanPane = createAutoCleanPane(); + autoCleanPane = createAutoCleanPane(); vcsEnableCheckBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -447,12 +450,24 @@ 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(); @@ -467,6 +482,7 @@ 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; } @@ -479,6 +495,7 @@ 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 9a3235cd15..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 @@ -32,6 +32,8 @@ 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; @@ -102,12 +104,19 @@ public class VcsMovePanel extends BasicPane { private UISpinner spinner; + private MoveCallBack callBack; - public VcsMovePanel(CardLayout cardLayout, JPanel parentPane) { + private JPanel updatePane; + + private boolean visible = false; + + + public VcsMovePanel(CardLayout cardLayout, JPanel parentPane, MoveCallBack callBack) { this.parentCard = cardLayout; this.parentPane = parentPane; + this.callBack = callBack; this.setLayout(new BorderLayout()); - JPanel updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); + updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); updatePane.setBackground(BACK_GROUND_COLOR); //初始化迁移的面板 initVcsLabel(updatePane); @@ -261,25 +270,37 @@ 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")); - 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); + 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); } @@ -300,25 +321,30 @@ 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")); - failedTipLabel.setForeground(TIP_COLOR); - body.add(failedIconLabel); + 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); body.add(new UILabel(StringUtils.BLANK)); - body.add(failedLabel); + body.add(label); body.add(new UILabel(StringUtils.BLANK)); - body.add(failedTipLabel); + body.add(tipLabel); 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); + 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); } @@ -377,4 +403,15 @@ public class VcsMovePanel extends BasicPane { } + /** + * 迁移回调事件 + * + */ + public static class MoveCallBack { + /** + * 处理回调 + */ + public void doCallBack(boolean visible){} + } + } From 9d19e9c93e4649e905ba6a9ce1a2c6983ca10e5a Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 19 Jun 2023 09:58:18 +0800 Subject: [PATCH 19/20] =?UTF-8?q?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 --- .../main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java | 1 + 1 file changed, 1 insertion(+) 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..8551f735b9 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,6 +79,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.setVcsEnable(reader.getAttrAsBoolean("vcsEnable", true)); this.setAutoSaveInterval(reader.getAttrAsInt("autoSaveInterval", 15)); this.setUseAutoSave(reader.getAttrAsBoolean("useAutoSave", false)); } From b8f7eda1b0fbc2bb30f0281d6b4a6abcf6b788b3 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 20 Jun 2023 15:12:41 +0800 Subject: [PATCH 20/20] =?UTF-8?q?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 --- .../mainframe/vcs/common/VcsHelper.java | 54 +++++++++++-------- .../design/mainframe/vcs/ui/VcsMovePanel.java | 11 ---- 2 files changed, 31 insertions(+), 34 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..b245eff66c 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,7 +79,14 @@ public class VcsHelper implements JTemplateActionListener { EventDispatcher.listen(ConfigEvent.READY, new ListenerAdaptor() { @Override protected void on(Event event) { - legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); + 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()); + } } }); } @@ -99,7 +106,6 @@ 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); @@ -263,7 +269,7 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateOpened(JTemplate jt) { try { - if (VcsConfigManager.getInstance().isUseAutoSave()) { + if (checkAutoSaveSupport()) { startAutoSave(VcsConfigManager.getInstance().getAutoSaveInterval()); } } catch (Exception e) { @@ -282,25 +288,16 @@ public class VcsHelper implements JTemplateActionListener { * @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); - } - } - }); - if (!fireVcs.isShutdown()) { - fireVcs.shutdown(); + 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); } } @@ -348,7 +345,9 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateClosed(JTemplate jt) { try { - stopAutoSave(); + if (checkAutoSaveSupport()) { + stopAutoSave(); + } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage()); } @@ -372,4 +371,13 @@ 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 cf68c33bc3..af450d8250 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,10 +19,6 @@ 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; @@ -391,13 +387,6 @@ 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(); } }