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/56] =?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 e9383fb4bf276ed8db82fb70b628e2feb681ffca Mon Sep 17 00:00:00 2001 From: shine Date: Thu, 20 Apr 2023 14:55:51 +0800 Subject: [PATCH 02/56] =?UTF-8?q?fix:=20fvs=E5=9B=BE=E8=A1=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=8D=E4=BF=9D=E5=AD=98=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=20#REPORT-94359?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/chart/BaseChartPropertyPane.java | 9 +++++++-- .../com/fr/design/mainframe/ChartPropertyPane.java | 10 +++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java b/designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java index d4be14dcdd..9e8c1481a1 100644 --- a/designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java @@ -3,6 +3,7 @@ package com.fr.design.gui.chart; import com.fr.base.chart.BaseChartCollection; import com.fr.design.designer.TargetComponent; import com.fr.design.mainframe.DockingView; +import org.jetbrains.annotations.Nullable; /** * 图表属性界面 抽象, 用于多工程协作.. @@ -14,8 +15,12 @@ public abstract class BaseChartPropertyPane extends DockingView { * 设置是否支持单元格数据. */ public abstract void setSupportCellData(boolean supportCellData); - - public abstract void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane); + + public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane) { + populateChartPropertyPane(collection, ePane, null); + } + + public abstract void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane, @Nullable Runnable callback); public abstract ChartEditPaneProvider getChartEditPane(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java index 8e6b80c53a..239eb8b8f3 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java @@ -17,6 +17,7 @@ import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.utils.gui.GUICoreUtils; +import org.jetbrains.annotations.Nullable; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -96,7 +97,7 @@ public class ChartPropertyPane extends BaseChartPropertyPane { * @param collection 收集图表 * @param ePane 面板 */ - public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane) { + public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane, @Nullable Runnable callback) { new SwingWorker() { @Override protected Void doInBackground() throws Exception { @@ -114,6 +115,9 @@ public class ChartPropertyPane extends BaseChartPropertyPane { } else { GUICoreUtils.setEnabled(chartEditPane, false); } + if (callback != null) { + callback.run(); + } } }.execute(); } @@ -123,9 +127,9 @@ public class ChartPropertyPane extends BaseChartPropertyPane { * @param collection 收集图表 * @param ePane 面板 */ - public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane) { + public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane, @Nullable Runnable callback) { if (collection instanceof ChartCollection) { - populateChartPropertyPane((ChartCollection) collection, ePane); + populateChartPropertyPane((ChartCollection) collection, ePane, callback); } } From f7531bd0c70a83f145a5dbdbda920f3c3c7097fd Mon Sep 17 00:00:00 2001 From: shine Date: Thu, 20 Apr 2023 15:18:07 +0800 Subject: [PATCH 03/56] =?UTF-8?q?Revert=20"fix:=20fvs=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8D=E4=BF=9D=E5=AD=98=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=20#REPORT-94359"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e9383fb4bf276ed8db82fb70b628e2feb681ffca. --- .../com/fr/design/gui/chart/BaseChartPropertyPane.java | 9 ++------- .../com/fr/design/mainframe/ChartPropertyPane.java | 10 +++------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java b/designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java index 9e8c1481a1..d4be14dcdd 100644 --- a/designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java @@ -3,7 +3,6 @@ package com.fr.design.gui.chart; import com.fr.base.chart.BaseChartCollection; import com.fr.design.designer.TargetComponent; import com.fr.design.mainframe.DockingView; -import org.jetbrains.annotations.Nullable; /** * 图表属性界面 抽象, 用于多工程协作.. @@ -15,12 +14,8 @@ public abstract class BaseChartPropertyPane extends DockingView { * 设置是否支持单元格数据. */ public abstract void setSupportCellData(boolean supportCellData); - - public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane) { - populateChartPropertyPane(collection, ePane, null); - } - - public abstract void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane, @Nullable Runnable callback); + + public abstract void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane); public abstract ChartEditPaneProvider getChartEditPane(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java index 239eb8b8f3..8e6b80c53a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java @@ -17,7 +17,6 @@ import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.utils.gui.GUICoreUtils; -import org.jetbrains.annotations.Nullable; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -97,7 +96,7 @@ public class ChartPropertyPane extends BaseChartPropertyPane { * @param collection 收集图表 * @param ePane 面板 */ - public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane, @Nullable Runnable callback) { + public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane) { new SwingWorker() { @Override protected Void doInBackground() throws Exception { @@ -115,9 +114,6 @@ public class ChartPropertyPane extends BaseChartPropertyPane { } else { GUICoreUtils.setEnabled(chartEditPane, false); } - if (callback != null) { - callback.run(); - } } }.execute(); } @@ -127,9 +123,9 @@ public class ChartPropertyPane extends BaseChartPropertyPane { * @param collection 收集图表 * @param ePane 面板 */ - public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane, @Nullable Runnable callback) { + public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane) { if (collection instanceof ChartCollection) { - populateChartPropertyPane((ChartCollection) collection, ePane, callback); + populateChartPropertyPane((ChartCollection) collection, ePane); } } From 055935a364628583e8613a0067849a3e71ba815d Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 19 May 2023 16:33:25 +0800 Subject: [PATCH 04/56] =?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 05/56] =?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 06/56] =?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 07/56] =?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 b74d96cf19681397ab4f2c056dabf7ead6af2e88 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 31 May 2023 19:39:36 +0800 Subject: [PATCH 08/56] =?UTF-8?q?REPORT-95741=20=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=96=B0=E5=BB=BA=E7=9A=84cpt=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=EF=BC=8C=E5=9B=9E=E5=88=B0=E4=BA=86fvs-tab=EF=BC=9B?= =?UTF-8?q?=E9=A2=84=E6=9C=9F=E6=98=AF=E6=89=93=E5=BC=80=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E5=BC=A0cpt/frm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/MultiTemplateTabPane.java | 14 +- .../fr/design/file/MultiTemplateTabUtils.java | 36 +++ .../design/file/MultiTemplateTabPaneTest.java | 289 ++++++++++++++++++ 3 files changed, 327 insertions(+), 12 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java create mode 100644 designer-base/src/test/java/com/fr/design/file/MultiTemplateTabPaneTest.java diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 9236deb4ad..6658fc6638 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -1108,18 +1108,8 @@ public class MultiTemplateTabPane extends JComponent { * @return */ public int calNextShowJTemplateIndex(int currentIndex) { - //先看是否有可以展示的模板 - for (int i = currentIndex; i >= 0; i--) { - if (showJTemplateTab(openedTemplate.get(i))) { - return i; - } - } - for (int i = currentIndex; i >= 0; i--) { - if (!showJTemplateTab(openedTemplate.get(i))) { - return i; - } - } - return -1; + JTemplate jTemplate= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return MultiTemplateTabUtils.calShowTemplateIndex(currentIndex, openedTemplate, jTemplate.getTemplateTabOperatorType()); } diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java new file mode 100644 index 0000000000..5a8c504189 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java @@ -0,0 +1,36 @@ +package com.fr.design.file; + +import com.fr.design.mainframe.JTemplate; +import com.fr.general.ComparatorUtils; + +import java.util.List; +import java.util.function.Predicate; + +public class MultiTemplateTabUtils { + public static int calShowTemplateIndex(int currentIndex, List> openedTemplate, String type) { + if (currentIndex < 0 || currentIndex > openedTemplate.size() - 1) { + return -1; + } + int result = getShowJTemplateTab(currentIndex, openedTemplate, template -> showJTemplateTab(type, template)); + if (result != -1) return result; + return getShowJTemplateTab(currentIndex, openedTemplate, template -> !showJTemplateTab(type, template)); + } + + private static int getShowJTemplateTab(int currentIndex, List> openedTemplate, Predicate> predicate) { + for (int i = currentIndex; i >= 0; i--) { + if (predicate.test(openedTemplate.get(i))) { + return i; + } + } + for (int i = currentIndex + 1; i < openedTemplate.size(); i++) { + if (predicate.test(openedTemplate.get(i))) { + return i; + } + } + return -1; + } + + private static boolean showJTemplateTab(String type, JTemplate jTemplate) { + return ComparatorUtils.equals(type, jTemplate.getTemplateTabOperatorType()); + } +} diff --git a/designer-base/src/test/java/com/fr/design/file/MultiTemplateTabPaneTest.java b/designer-base/src/test/java/com/fr/design/file/MultiTemplateTabPaneTest.java new file mode 100644 index 0000000000..c00976abb3 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/file/MultiTemplateTabPaneTest.java @@ -0,0 +1,289 @@ +package com.fr.design.file; + +import com.fr.design.DesignModelAdapter; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.designer.TargetComponent; +import com.fr.design.gui.frpane.HyperlinkGroupPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.mainframe.AuthorityEditPane; +import com.fr.design.mainframe.BaseUndoState; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import com.fr.design.menu.ShortCut; +import com.fr.design.menu.ToolBarDef; +import com.fr.plugin.injectable.PluginModule; +import junit.framework.TestCase; +import org.junit.Assert; + +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; + +public class MultiTemplateTabPaneTest extends TestCase { + @Override + protected void setUp() throws Exception { + PluginModule.registerAgent(PluginModule.ExtraDesign, new ExtraDesignClassManager()); + } + + /** + * 当前显示模式A,传入index左边(含当前)或右边有模式A的模板,返回最近的模式A模板index(优先左边) + */ + public void test_index_left_has_same_mode_temp() { + //当前显示模式A,传入index左边(含当前)有模式A的模板,返回左边最近的模式A模板index + List> openedTemplateList = new ArrayList<>(); + openedTemplateList.add(new A_Mode()); + Assert.assertEquals(0, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode")); + openedTemplateList.add(new A_Mode()); + Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode")); + openedTemplateList.add(new B_Mode()); + Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode")); + } + + public void test_index_left_has_not_but_right_has_same_mode_temp() { + //当前显示模式A,传入index左边没有但是右边有模式A的模板,返回右边最近的模式A模板index + List> openedTemplateList = new ArrayList<>(); + openedTemplateList.add(new B_Mode()); + openedTemplateList.add(new A_Mode()); + Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode")); + openedTemplateList.add(1, new B_Mode()); + openedTemplateList.add(new A_Mode()); + Assert.assertEquals(2, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode")); + openedTemplateList.add(new A_Mode()); + Assert.assertEquals(2, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode")); + } + + /** + * 当前显示模式A,没有模式A的模板,左边(含当前)或者右边有其他模式的模板,返回最近的其他模式模式模板index(优先左边) + */ + public void test_no_same_mode_temp_but_index_left_has_other_mode_temp() { + //当前显示模式A,没有模式A的模板,左边(含当前)有其他模式模板,返回左边最近的其他模式模板index + List> openedTemplateList = new ArrayList<>(); + openedTemplateList.add(new B_Mode()); + Assert.assertEquals(0, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode")); + openedTemplateList.add(new B_Mode()); + Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode")); + } + + + public void test_has_no_temp() { + //当前显示模式A,没有模式A的模板,也没有其他模式的模板,返回-1 + List> openedTemplateList = new ArrayList<>(); + Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode")); + } + + + public void test_if_index_less_than_zero_or_more_than_open_temp_size() { + //index<0 或者超出openTemplateList.size时,返回-1 + List> openedTemplateList = new ArrayList<>(); + Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(-1, openedTemplateList, "A_Mode")); + Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode")); + openedTemplateList.add(new A_Mode()); + Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode")); + } + + private class A_Mode extends AbstractTestMode { + public String getTemplateTabOperatorType() { + return "A_Mode"; + } + } + + private class B_Mode extends AbstractTestMode { + public String getTemplateTabOperatorType() { + return "B_Mode"; + } + } + + private abstract class AbstractTestMode extends JTemplate { + public AbstractTestMode() { + } + + @Override + public void copy() { + + } + + @Override + public boolean paste() { + return false; + } + + @Override + public boolean cut() { + return false; + } + + @Override + public AuthorityEditPane createAuthorityEditPane() { + return null; + } + + @Override + public JPanel getEastUpPane() { + return null; + } + + @Override + public JPanel getEastDownPane() { + return null; + } + + @Override + public ToolBarDef[] toolbars4Target() { + return new ToolBarDef[0]; + } + + @Override + public JPanel[] toolbarPanes4Form() { + return new JPanel[0]; + } + + @Override + public JComponent[] toolBarButton4Form() { + return new JComponent[0]; + } + + @Override + public JComponent toolBar4Authority() { + return null; + } + + @Override + public int getToolBarHeight() { + return 0; + } + + @Override + public void refreshEastPropertiesPane() { + + } + + @Override + public TargetComponent getCurrentElementCasePane() { + return null; + } + + @Override + public JComponent getCurrentReportComponentPane() { + return null; + } + + @Override + public TemplateProcessInfo getProcessInfo() { + return null; + } + + @Override + public void setJTemplateResolution(int resolution) { + + } + + @Override + public int getJTemplateResolution() { + return 0; + } + + @Override + protected JComponent createCenterPane() { + return null; + } + + @Override + public void removeTemplateSelection() { + + } + + @Override + public void refreshContainer() { + + } + + @Override + public void removeParameterPaneSelection() { + + } + + @Override + public void setScale(int resolution) { + + } + + @Override + public int getScale() { + return 0; + } + + @Override + public int selfAdaptUpdate() { + return 0; + } + + @Override + protected DesignModelAdapter createDesignModel() { + return null; + } + + @Override + public UIMenuItem[] createMenuItem4Preview() { + return new UIMenuItem[0]; + } + + @Override + protected BaseUndoState createUndoState() { + return null; + } + + @Override + public String suffix() { + return null; + } + + @Override + public ShortCut[] shortcut4TemplateMenu() { + return new ShortCut[0]; + } + + @Override + public ShortCut[] shortCuts4Authority() { + return new ShortCut[0]; + } + + @Override + public boolean isJWorkBook() { + return false; + } + + @Override + public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return null; + } + + @Override + public HyperlinkGroupPane getHyperLinkPaneNoPop(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return null; + } + + @Override + public void setAuthorityMode(boolean isUpMode) { + + } + + @Override + public Icon getIcon() { + return null; + } + + @Override + public String route() { + return null; + } + + @Override + protected void applyUndoState(BaseUndoState baseUndoState) { + + } + + } +} From 4531ad7d5fd22a0ea979b7544bbbfdc23a892c08 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 1 Jun 2023 12:00:33 +0800 Subject: [PATCH 09/56] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/MultiTemplateTabUtils.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java index 5a8c504189..e5883a3987 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java @@ -7,6 +7,13 @@ import java.util.List; import java.util.function.Predicate; public class MultiTemplateTabUtils { + /** + * 计算离currentIndex最近的相同模式的模板index值(优先左边) + * @param currentIndex 当前index + * @param openedTemplate 模板list + * @param type 当前显示模式 + * @return + */ public static int calShowTemplateIndex(int currentIndex, List> openedTemplate, String type) { if (currentIndex < 0 || currentIndex > openedTemplate.size() - 1) { return -1; @@ -16,6 +23,13 @@ public class MultiTemplateTabUtils { return getShowJTemplateTab(currentIndex, openedTemplate, template -> !showJTemplateTab(type, template)); } + /** + * 先从左找,再从右找离得最近的满足条件的模板 + * @param currentIndex 当前index + * @param openedTemplate 模板list + * @param predicate + * @return + */ private static int getShowJTemplateTab(int currentIndex, List> openedTemplate, Predicate> predicate) { for (int i = currentIndex; i >= 0; i--) { if (predicate.test(openedTemplate.get(i))) { @@ -30,6 +44,12 @@ public class MultiTemplateTabUtils { return -1; } + /** + * 是否显示模板 + * @param type 模板类型 + * @param jTemplate 模板 + * @return + */ private static boolean showJTemplateTab(String type, JTemplate jTemplate) { return ComparatorUtils.equals(type, jTemplate.getTemplateTabOperatorType()); } From c8b3cd6ce396bf9e09bfb8566575cbf54a189ad7 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 1 Jun 2023 13:57:09 +0800 Subject: [PATCH 10/56] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/file/MultiTemplateTabUtils.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java index e5883a3987..344abe64f2 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java @@ -9,9 +9,10 @@ import java.util.function.Predicate; public class MultiTemplateTabUtils { /** * 计算离currentIndex最近的相同模式的模板index值(优先左边) - * @param currentIndex 当前index + * + * @param currentIndex 当前index * @param openedTemplate 模板list - * @param type 当前显示模式 + * @param type 当前显示模式 * @return */ public static int calShowTemplateIndex(int currentIndex, List> openedTemplate, String type) { @@ -25,7 +26,8 @@ public class MultiTemplateTabUtils { /** * 先从左找,再从右找离得最近的满足条件的模板 - * @param currentIndex 当前index + * + * @param currentIndex 当前index * @param openedTemplate 模板list * @param predicate * @return @@ -46,7 +48,8 @@ public class MultiTemplateTabUtils { /** * 是否显示模板 - * @param type 模板类型 + * + * @param type 模板类型 * @param jTemplate 模板 * @return */ From bd2d5847fb954dbd8693a4bc73f83d9f1b4594dd Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 6 Jun 2023 17:10:40 +0800 Subject: [PATCH 11/56] =?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 12/56] =?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 13/56] =?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 14/56] =?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 15/56] =?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 16/56] =?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 272ca3fd86daf5c13630b5129c66a055ed489649 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 14 Jun 2023 15:10:57 +0800 Subject: [PATCH 17/56] =?UTF-8?q?REPORT-93559=20JxUIPane=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E6=94=AF=E6=8C=81Jxbrowser7=E6=9B=BF=E6=8D=A2ModernUIPane?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/help/FineUIAction.java | 21 +- .../fr/design/dcm/UniversalDatabasePane.java | 19 +- .../com/fr/design/dcm/UniversalDcmBridge.java | 22 +- .../fr/design/jxbrowser/BrowserExecutor.java | 40 ++ .../com/fr/design/jxbrowser/JxEngine.java | 125 +++++ .../com/fr/design/jxbrowser/JxUIPane.java | 456 ++++++++++++++++++ .../com/fr/design/jxbrowser/MimeType.java | 113 +++++ .../jxbrowser/NxInterceptRequestCallback.java | 171 +++++++ .../fr/design/jxbrowser/PropertyBuild.java | 20 + .../fr/design/login/DesignerLoginBridge.java | 54 +-- .../fr/design/login/DesignerLoginPane.java | 20 +- .../login/guide/DesignerGuideBridge.java | 68 +-- .../login/guide/DesignerGuideHelper.java | 3 + .../design/login/guide/DesignerGuidePane.java | 20 +- .../com/fr/design/ui/ModernUIConstants.java | 16 + .../java/com/fr/design/ui/ModernUIPane.java | 43 +- .../fr/design/ui/compatible/BuilderDiff.java | 26 - .../ui/compatible/ModernUIPaneFactory.java | 36 -- .../design/ui/compatible/NewModernUIPane.java | 362 -------------- .../NxComplexInterceptRequestCallback.java | 86 ---- .../NxInterceptRequestCallback.java | 148 ------ .../update/push/DesignerPushUpdateDialog.java | 42 +- .../update/push/DesignerUpdateInfo.java | 10 +- .../java/com/fr/design/upm/UpmBridge.java | 10 +- .../{NewUpmBridge.java => UpmBridgeV7.java} | 9 +- .../java/com/fr/design/upm/UpmFinder.java | 4 +- .../java/com/fr/design/upm/UpmShowPane.java | 30 +- .../com/fr/design/jxbrowser/JxUIPaneTest.java | 72 +++ .../com/fr/design/jxbrowser/MimeTypeTest.java | 21 + .../java/com/fr/design/ui/FineUIDemo.java | 3 +- .../ui/report/TemplateWebSettingDemo.java | 10 +- ...ChartBoxRichTextDetailedFieldListPane.java | 4 +- ...anChartBoxRichTextResultFieldListPane.java | 4 +- .../box/VanChartBoxTooltipContentPane.java | 6 +- .../component/VanChartTooltipContentPane.java | 6 +- .../richText/VanChartFieldListPane.java | 6 +- .../richText/VanChartRichEditorModel.java | 2 + .../richText/VanChartRichEditorPane.java | 85 ++-- .../richText/VanChartRichTextPane.java | 6 +- .../TooltipContentPaneWithOutSeries.java | 6 +- .../VanChartFieldListPaneWithOutSeries.java | 4 +- .../style/VanChartFunnelLabelContentPane.java | 6 +- .../VanChartFunnelRichTextFieldListPane.java | 4 +- .../VanChartFunnelTooltipContentPane.java | 6 +- .../VanChartGanttRichTextFieldListPane.java | 4 +- .../VanChartGanttTooltipContentPane.java | 6 +- .../VanChartMapRichTextFieldListPane.java | 4 +- .../label/VanChartMapLabelContentPane.java | 6 +- .../VanChartMapTooltipContentPane.java | 6 +- .../VanChartLineMapRichTextFieldListPane.java | 4 +- .../VanChartLineMapTooltipContentPane.java | 6 +- .../VanChartMultiPieLabelContentPane.java | 6 +- ...VanChartMultiPieRichTextFieldListPane.java | 4 +- .../VanChartMultiPieTooltipContentPane.java | 6 +- .../VanChartPieCategoryLabelContentPane.java | 6 +- ...ChartPieCategoryRichTextFieldListPane.java | 4 +- .../VanChartPieValueLabelContentPane.java | 6 +- ...VanChartPieValueRichTextFieldListPane.java | 4 +- .../VanChartScatterRichTextFieldListPane.java | 4 +- .../VanChartScatterTooltipContentPane.java | 6 +- ...anChartStructureRichTextFieldListPane.java | 4 +- .../VanChartStructureTooltipContentPane.java | 6 +- ...anChartWordCloudRichTextFieldListPane.java | 4 +- .../VanChartWordCloudTooltipContentPane.java | 6 +- .../com/fr/design/editor/rich_editor.html | 4 +- .../ui/online/mini/MiniComponentShopPane.java | 35 +- 66 files changed, 1364 insertions(+), 1002 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/jxbrowser/BrowserExecutor.java create mode 100644 designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java create mode 100644 designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java create mode 100644 designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java create mode 100644 designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java create mode 100644 designer-base/src/main/java/com/fr/design/jxbrowser/PropertyBuild.java delete mode 100644 designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java delete mode 100644 designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java delete mode 100644 designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java delete mode 100644 designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java delete mode 100644 designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java rename designer-base/src/main/java/com/fr/design/upm/{NewUpmBridge.java => UpmBridgeV7.java} (98%) create mode 100644 designer-base/src/test/java/com/fr/design/jxbrowser/JxUIPaneTest.java create mode 100644 designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java diff --git a/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java index 0839c14767..4436154739 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java @@ -3,14 +3,15 @@ package com.fr.design.actions.help; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.ui.ModernUIPane; import com.fr.locale.InterProviderFactory; import com.fr.web.struct.AssembleComponent; import com.fr.web.struct.Atom; import com.fr.web.struct.browser.RequestClient; import com.fr.web.struct.category.ScriptPath; import com.fr.web.struct.impl.FineUI; +import com.teamdev.jxbrowser.js.JsAccessible; import java.awt.event.ActionEvent; @@ -27,14 +28,9 @@ public class FineUIAction extends UpdateAction { @Override public void actionPerformed(final ActionEvent e) { - ModernUIPane pane = new ModernUIPane.Builder<>() -// .prepare(new ScriptContextAdapter() { -// @Override -// public void onScriptContextCreated(ScriptContextEvent event) { -// JSValue pool = event.getBrowser().executeJavaScriptAndReturnValue("window.Pool"); -// pool.asObject().setProperty("i18n", new I18n()); -// } -// }) + JxUIPane pane = new JxUIPane.Builder<>() + .variable("i18n") + .property(new I18n()) .withComponent(new AssembleComponent() { @Override @@ -44,20 +40,21 @@ public class FineUIAction extends UpdateAction { @Override public Atom[] refer() { - return new Atom[] {FineUI.KEY}; + return new Atom[]{FineUI.KEY}; } }) .build(); - BasicDialog dialog = pane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + BasicDialog dialog = pane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { // Do nothing } }); - dialog.setVisible(true); + dialog.setVisible(true); } + @JsAccessible public static class I18n { public String i18nText(String key) { diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java index e29a9f6698..84c5c2f7b3 100644 --- a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java @@ -1,12 +1,9 @@ package com.fr.design.dcm; import com.fr.design.dialog.BasicPane; -import com.fr.design.ui.ModernUIPane; -import com.teamdev.jxbrowser.chromium.JSValue; -import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; -import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; +import com.fr.design.jxbrowser.JxUIPane; -import java.awt.*; +import java.awt.BorderLayout; /** * @author richie @@ -15,8 +12,6 @@ import java.awt.*; */ public class UniversalDatabasePane extends BasicPane { - private ModernUIPane modernUIPane; - @Override protected String title4PopupWindow() { return "Database"; @@ -24,15 +19,9 @@ public class UniversalDatabasePane extends BasicPane { public UniversalDatabasePane() { setLayout(new BorderLayout()); - modernUIPane = new ModernUIPane.Builder<>() + JxUIPane modernUIPane = new JxUIPane.Builder<>() .withComponent(UniversalDatabaseComponent.KEY) - .prepare(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); - window.asObject().setProperty("DcmHelper", UniversalDcmBridge.getBridge(event.getBrowser())); - } - }) + .buildProperty("DcmHelper", UniversalDcmBridge::getBridge) .build(); add(modernUIPane, BorderLayout.CENTER); } diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java index 577acada97..3d569ea2c9 100644 --- a/designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java @@ -2,8 +2,8 @@ package com.fr.design.dcm; import com.fr.decision.webservice.bean.BaseBean; import com.fr.design.bridge.exec.JSBridge; -import com.teamdev.jxbrowser.chromium.Browser; -import com.teamdev.jxbrowser.chromium.JSObject; +import com.teamdev.jxbrowser.js.JsAccessible; +import com.teamdev.jxbrowser.js.JsObject; /** * @author richie @@ -11,20 +11,28 @@ import com.teamdev.jxbrowser.chromium.JSObject; * Created by richie on 2019-05-17 * 桥接Java和JavaScript的类 */ +@JsAccessible public class UniversalDcmBridge { - public static UniversalDcmBridge getBridge(Browser browser) { - return new UniversalDcmBridge(browser); + /** + * 获取 js-java bridge + * + * @param window 全局环境 + * @return bridge + */ + public static UniversalDcmBridge getBridge(JsObject window) { + return new UniversalDcmBridge(window); } - private JSObject window; + private JsObject window; - private UniversalDcmBridge(Browser browser) { - this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); + private UniversalDcmBridge(JsObject window) { + this.window = window; } /** * 获取所有的数据连接 + * * @return 数据连接集合 */ @JSBridge diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/BrowserExecutor.java b/designer-base/src/main/java/com/fr/design/jxbrowser/BrowserExecutor.java new file mode 100644 index 0000000000..f21609ef6b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/BrowserExecutor.java @@ -0,0 +1,40 @@ +package com.fr.design.jxbrowser; + +import com.fr.design.bridge.exec.JSExecutor; +import com.teamdev.jxbrowser.js.JsFunction; +import com.teamdev.jxbrowser.js.JsObject; + +/** + * 用于 jxbrowser 执行后的回调执行器 + * 适配7.15之后 + * + * @author vito + * @since 11.0 + * Created on 2023/6/8 + */ +public class BrowserExecutor implements JSExecutor { + + /** + * 创建一个回调执行器 + * + * @param window js环境的window对象 + * @param callback 回调 + * @return 执行器 + */ + public static BrowserExecutor create(JsObject window, JsFunction callback) { + return new BrowserExecutor(window, callback); + } + + private final JsObject window; + private final JsFunction callback; + + private BrowserExecutor(JsObject window, JsFunction callback) { + this.window = window; + this.callback = callback; + } + + @Override + public void executor(String newValue) { + callback.invoke(window, newValue); + } +} diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java b/designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java new file mode 100644 index 0000000000..c207b660e5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java @@ -0,0 +1,125 @@ +package com.fr.design.jxbrowser; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.ui.ModernUIConstants; +import com.fr.log.FineLoggerFactory; +import com.fr.value.ClearableLazyValue; +import com.fr.web.struct.AssembleComponent; +import com.teamdev.jxbrowser.engine.Engine; +import com.teamdev.jxbrowser.engine.EngineOptions; +import com.teamdev.jxbrowser.engine.RenderingMode; +import com.teamdev.jxbrowser.engine.event.EngineCrashed; +import com.teamdev.jxbrowser.net.Network; +import com.teamdev.jxbrowser.net.Scheme; +import com.teamdev.jxbrowser.net.callback.VerifyCertificateCallback; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.Map; + +/** + * 可重复启动的 Jxbrowser 引擎 + * 手动创建的引擎,应当自己负责管理声明周期 {@link #newInstance()} + * 单例的引擎,由系统管理生命周期,使用后仅需清理browser和map等数据 + * {@link #getEngine()} 和 {@link #getPublicEngineInstance()} + * + * @author vito + * @since 11.0 + * Created on 2023/6/8 + */ +public class JxEngine { + + private static final JxEngine INSTANCE = new JxEngine(); + + private AssembleComponent component; + private Map parameterMap = Collections.emptyMap(); + + + private final ClearableLazyValue ENGINE = ClearableLazyValue.create(() -> { + EngineOptions.Builder builder = EngineOptions + .newBuilder(RenderingMode.HARDWARE_ACCELERATED) + .addSwitch("--disable-google-traffic") + .addScheme(Scheme.of(ModernUIConstants.EMB_TAG), + new NxInterceptRequestCallback(this::getComponent, this::getParameterMap)); + Engine engine = Engine.newInstance(builder.build()); + engine.on(EngineCrashed.class, (event) -> { + FineLoggerFactory.getLogger().error("jxBrowser engine crashed with exitCode: {}", event.exitCode()); + event.engine().close(); + }); + if (DesignerEnvManager.getEnvManager().isOpenDebug()) { + // 调试模式下,禁止HTTPS证书验证,使得可以正常访问商城测试服务器等 + Network network = engine.network(); + network.set(VerifyCertificateCallback.class, params -> VerifyCertificateCallback.Response.valid()); + } + return engine; + }); + + public Map getParameterMap() { + return Collections.unmodifiableMap(parameterMap); + } + + public void setMap(Map parameterMap) { + if (parameterMap == null) { + return; + } + this.parameterMap = parameterMap; + } + + public void clearMap() { + this.parameterMap = Collections.emptyMap(); + } + + public AssembleComponent getComponent() { + return component; + } + + public void setComponent(AssembleComponent component) { + this.component = component; + } + + public void clearComponent() { + this.component = null; + } + + /** + * 获取单例引擎包装,能够更新渲染 + * 从单例获取的引擎不用负责关闭, + * 应用系统管理声明周期 + * + * @return jxbrowser 引擎包装类 + */ + public static JxEngine getInstance() { + return INSTANCE; + } + + @NotNull + public Engine getEngine() { + return ENGINE.getValue(); + } + + public void close() { + ENGINE.getValue().close(); + ENGINE.drop(); + } + + + /** + * 获取公共引擎,公共引擎使用后不用关闭引擎,但需要自己管理 browser。 + * 应用系统管理引擎生命周期 + * + * @return 引擎 + */ + public static Engine getPublicEngineInstance() { + return getInstance().ENGINE.getValue(); + } + + /** + * 创建一个新的引擎,创建引擎使用后需负责关闭引擎 + * 但可以独立使用 map 和 component + * + * @return 引擎 + */ + public static JxEngine newInstance() { + return new JxEngine(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java new file mode 100644 index 0000000000..68dbc9362c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java @@ -0,0 +1,456 @@ +package com.fr.design.jxbrowser; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.ModernUIConstants; +import com.fr.design.ui.ModernUIPane; +import com.fr.stable.StringUtils; +import com.fr.web.struct.AssembleComponent; +import com.teamdev.jxbrowser.browser.Browser; +import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; +import com.teamdev.jxbrowser.frame.Frame; +import com.teamdev.jxbrowser.js.JsObject; +import com.teamdev.jxbrowser.view.swing.BrowserView; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import static com.fr.design.ui.ModernUIConstants.COMPONENT_TAG; +import static com.fr.design.ui.ModernUIConstants.DEFAULT_EXPRESSION; +import static com.fr.design.ui.ModernUIConstants.DEFAULT_NAMESPACE; +import static com.fr.design.ui.ModernUIConstants.DEFAULT_VARIABLE; +import static com.fr.design.ui.ModernUIConstants.DOT; +import static com.fr.design.ui.ModernUIConstants.EMB_TAG; +import static com.fr.design.ui.ModernUIConstants.SCHEME_HEADER; +import static com.fr.design.ui.ModernUIConstants.WINDOW; + +/** + * 基于v7 jxbrowser 实现 + * 用于加载 html5 的Swing容器,可以在设计选项设置中打开调试窗口, + * 示例可查看:com.fr.design.ui.JxUIPaneTest + * + * @author vito + * @since 11.0 + * Created on 2023-06-12 + */ +public class JxUIPane extends ModernUIPane { + + private Browser browser; + private String namespace = "Pool"; + private String variable = "data"; + private String expression = "update()"; + + private JxUIPane() { + super(); + } + + private void initialize() { + setLayout(new BorderLayout()); + if (browser != null) { + return; + } + initDebugIfNeeded(); + // 使用公共引擎创建浏览器 + browser = JxEngine.getPublicEngineInstance().newBrowser(); + add(BrowserView.newInstance(browser), BorderLayout.CENTER); + } + + /** + * 按需初始化debug界面UI + */ + private void initDebugIfNeeded() { + if (DesignerEnvManager.getEnvManager().isOpenDebug()) { + UIToolbar toolbar = new UIToolbar(); + add(toolbar, BorderLayout.NORTH); + UIButton openDebugButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window")); + openDebugButton.addActionListener(e -> browser.devTools().show()); + toolbar.add(openDebugButton); + UIButton reloadButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Reload")); + reloadButton.addActionListener(e -> browser.navigation().reloadIgnoringCache()); + toolbar.add(reloadButton); + UIButton closeButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Close_Window")); + closeButton.addActionListener(e -> SwingUtilities.getWindowAncestor(JxUIPane.this).setVisible(false)); + toolbar.add(closeButton); + } + } + + /** + * 在初始化时进行注入JS的方法,只被build调用 + * + * @param injectJsCallback 回调 + */ + private void initInjectJs(InjectJsCallback injectJsCallback) { + browser.set(InjectJsCallback.class, params -> { + // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 + params.frame().executeJavaScript(String.format(ModernUIConstants.SCRIPT_INIT_NAME_SPACE, namespace)); + return injectJsCallback.on(params); + }); + } + + /** + * 设置 InjectJsCallback。 + * 这个方法解决重复InjectJsCallback被覆盖的问题。 + * 用于本类内部方法使用,如{@link #populate(Object)} + * + * @param injectJsCallback 回调 + */ + private void setInjectJsCallback(InjectJsCallback injectJsCallback) { + Optional callback = browser.get(InjectJsCallback.class); + if (callback.isPresent()) { + browser.set(InjectJsCallback.class, params -> { + callback.get().on(params); + return injectJsCallback.on(params); + }); + } else { + browser.set(InjectJsCallback.class, injectJsCallback); + } + } + + + /** + * 转向一个新的地址,相当于重新加载 + * + * @param url 新的地址 + */ + @Override + public void redirect(String url) { + browser.navigation().loadUrl(url); + } + + /** + * 转向一个新的地址,相当于重新加载 + * + * @param url 新的地址 + * @param map 初始化参数 + */ + @Override + public void redirect(String url, Map map) { + setMap(map); + browser.navigation().loadUrl(url); + } + + private void setMap(Map map) { + JxEngine.getInstance().setMap(map); + } + + private void setComponent(AssembleComponent component) { + JxEngine.getInstance().setComponent(component); + } + + @Override + protected String title4PopupWindow() { + return "ModernUI7"; + } + + + @Override + public void populate(final T t) { + setInjectJsCallback(params -> { + executeJsObject(params.frame(), WINDOW + DOT + namespace) + .ifPresent(ns -> ns.putProperty(variable, t)); + return InjectJsCallback.Response.proceed(); + }); + } + + @Override + @Nullable + public T update() { + if (browser.mainFrame().isPresent()) { + return browser.mainFrame().get().executeJavaScript("window." + namespace + "." + expression); + } + return null; + } + + /** + * 关闭浏览器 + */ + public void disposeBrowser() { + if (browser != null) { + browser.close(); + browser = null; + JxEngine.getInstance().clearMap(); + JxEngine.getInstance().clearComponent(); + } + + } + + /** + * 清理浏览器缓存 + */ + public void clearCache() { + if (browser != null) { + browser.engine().httpCache().clear(); + } + } + + /** + * 执行一段js + * + * @param javaScript 待执行的js脚本 + */ + public void executeJavaScript(String javaScript) { + if (browser != null) { + browser.mainFrame().ifPresent(frame -> { + frame.executeJavaScript(javaScript); + }); + } + } + + /** + * 获取js对象 + * 注意:类内部使用,用于简化编码,提供 Optional 包装 + * + * @param frame 页面frame对象 + * @param name 变量命名 + * @return js对象 + */ + private static Optional executeJsObject(Frame frame, String name) { + return Optional.ofNullable(frame.executeJavaScript(name)); + } + + /** + * JxUIPane 的建造者 + * + * @param 参数 + */ + public static class Builder { + private String namespace; + private String variable; + private String expression; + private InjectJsCallback callback; + private final Map propertyMap; + private final Map buildPropertyMap; + private Object variableProperty; + private Map parameterMap; + private AssembleComponent component; + private String url; + private String html; + + public Builder() { + this.namespace = DEFAULT_NAMESPACE; + this.variable = DEFAULT_VARIABLE; + this.expression = DEFAULT_EXPRESSION; + this.callback = null; + this.propertyMap = new HashMap<>(); + this.buildPropertyMap = new HashMap<>(); + this.variableProperty = null; + this.parameterMap = null; + this.component = null; + this.url = StringUtils.EMPTY; + this.html = StringUtils.EMPTY; + } + + /** + * 注入一个回调,回调的js会在初始化进行执行 + * + * @param callback 回调 + * @return builder + */ + public JxUIPane.Builder prepare(InjectJsCallback callback) { + this.callback = callback; + return this; + } + + /** + * 加载jar包中的资源 + * + * @param path 资源路径 + */ + public JxUIPane.Builder withEMB(final String path) { + this.url = EMB_TAG + SCHEME_HEADER + path; + return this; + } + + /** + * 加载jar包中的资源 + * + * @param path 资源路径 + */ + public JxUIPane.Builder withEMB(final String path, Map map) { + this.parameterMap = map; + this.url = EMB_TAG + SCHEME_HEADER + path; + return this; + } + + /** + * 加载url指向的资源 + * + * @param url 文件的地址 + */ + public JxUIPane.Builder withURL(final String url) { + this.url = url; + return this; + } + + /** + * 加载url指向的资源 + * + * @param url 文件的地址 + */ + public JxUIPane.Builder withURL(final String url, Map map) { + this.parameterMap = map; + this.url = url; + return this; + } + + /** + * 加载Atom组件 + * + * @param component Atom组件 + */ + public JxUIPane.Builder withComponent(AssembleComponent component) { + return withComponent(component, null); + } + + /** + * 加载Atom组件 + * + * @param component Atom组件 + */ + public JxUIPane.Builder withComponent(AssembleComponent component, Map map) { + this.parameterMap = map; + this.component = component; + this.url = COMPONENT_TAG; + return this; + } + + + /** + * 加载html文本内容 + * + * @param html 要加载html文本内容 + */ + public JxUIPane.Builder withHTML(String html) { + this.html = html; + return this; + } + + /** + * 设置该前端页面做数据交换所使用的对象 + * + * @param namespace 对象名 + */ + public JxUIPane.Builder namespace(String namespace) { + this.namespace = namespace; + return this; + } + + /** + * java端往js端传数据时使用的变量名字 + * 默认值为 data + * + * @param name 变量的名字 + */ + public JxUIPane.Builder variable(String name) { + this.variable = name; + return this; + } + + /** + * js端往java端传数据时执行的函数表达式 + * + * @param expression 函数表达式 + */ + public JxUIPane.Builder expression(String expression) { + this.expression = expression; + return this; + } + + /** + * 注入一个java对象到js中,绑定在全局变量 window的 + * property指定的变量。这个方法仅在在加载的网页上执 + * 行 JavaScript 之前注入 + * + * @param property 属性 + * @param obj java对象 + * @return 链式对象 + */ + public JxUIPane.Builder property(String property, @Nullable Object obj) { + this.propertyMap.put(property, obj); + return this; + } + + /** + * 注入一个java对象到js中,绑定在全局变量window的指定变量variable。 + * variable 可由 {@link #variable(String)} 设置,默认值为 data + * 这个方法仅在在加载的网页上执行 JavaScript 之前注入 + * + * @param obj java对象 + * @return 链式对象 + */ + public JxUIPane.Builder property(@NotNull Object obj) { + this.variableProperty = obj; + return this; + } + + /** + * 注入一个java对象到js中。绑定在全局变量 window的property指定的变量。 + * PropertyBuild用于动态生成绑定属性。个方法仅在在加载的网页上执行 + * JavaScript 之前注入 + * + * @param property 属性构建器 + * @param obj java对象 + * @return 链式对象 + */ + public JxUIPane.Builder buildProperty(String property, PropertyBuild obj) { + buildPropertyMap.put(property, obj); + return this; + } + + /** + * 构建 + */ + public JxUIPane build() { + JxUIPane pane = new JxUIPane<>(); + pane.namespace = namespace; + pane.variable = variable; + pane.expression = expression; + pane.setMap(parameterMap); + pane.setComponent(component); + pane.initialize(); + injectJs(pane); + if (StringUtils.isNotEmpty(this.url)) { + pane.browser.navigation().loadUrl(this.url); + } else if (StringUtils.isNotEmpty(this.html)) { + pane.browser.mainFrame().ifPresent(f -> f.loadHtml(html)); + } + return pane; + } + + /** + * 由于 InjectJsCallback 的回调机制,在初始化期间,只有 + * 在 InjectJsCallback 中 putProperty 才能生效。 + * 因此,嵌套回调分别做默认初始化、putProperty、外置初始化 + */ + private void injectJs(JxUIPane pane) { + pane.initInjectJs(params -> { + Frame frame = params.frame(); + if (!propertyMap.isEmpty()) { + propertyMap.forEach((key, value) -> + executeJsObject(frame, WINDOW) + .ifPresent(window -> window.putProperty(key, value))); + } + if (!buildPropertyMap.isEmpty()) { + buildPropertyMap.forEach((key, value) -> + executeJsObject(frame, WINDOW) + .ifPresent(window -> window.putProperty(key, value.build(window)))); + } + if (variableProperty != null) { + executeJsObject(frame, WINDOW + DOT + namespace) + .ifPresent(pool -> pool.putProperty(variable, variableProperty)); + } + if (callback != null) { + return callback.on(params); + } + return InjectJsCallback.Response.proceed(); + }); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java b/designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java new file mode 100644 index 0000000000..583340ccf4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java @@ -0,0 +1,113 @@ +package com.fr.design.jxbrowser; + +import com.fr.stable.StringUtils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Optional; + +/** + * jxbrowser 使用的一些媒体类型 + * + * @author vito + * @since 11.0 + * Created on 2023/6/13 + */ +public enum MimeType { + /** + * html 格式 + */ + HTML(".html", "text/html"), + /** + * CSS 格式 + */ + CSS(".css", "text/css"), + /** + * js 格式 + */ + JS(".js", "text/css"), + /** + * svg 格式 + */ + SVG(".svg", "text/javascript"), + /** + * png 格式 + */ + PNG(".png", "image/png"), + + /** + * jpg 格式 + */ + JPG(".jpg", "image/jpeg"), + + /** + * jpeg 格式 + */ + JPEG(".jpeg", "image/jpeg"), + + /** + * gif 格式 + */ + GIF(".gif", "image/gif"), + /** + * woff 字体格式 + */ + WOFF(".woff", "font/woff"), + /** + * ttf 字体格式 + */ + TTF(".ttf", "truetype"), + + /** + * MS 嵌入式开放字体 + */ + EOT(".eot", "embedded-opentype"); + + private final String suffix; + private final String mimeType; + + MimeType(String suffix, String mimeType) { + this.suffix = suffix; + this.mimeType = mimeType; + } + + public String parseMimeType() { + return mimeType; + } + + /** + * 获取指定路径对应的 mimetype,优先匹配常量中的类型 + * 如果没有,尝试使用 Files.probeContentType 检测 + * 如果没有,默认返回 text/html + * + * @param url url路径 + * @return MimeType + */ + public static String parseMimeType(String url) { + if (StringUtils.isBlank(url)) { + return HTML.mimeType; + } + String finalPath = url.split("\\?")[0]; + Optional mimeType = Arrays.stream(values()) + .filter(type -> finalPath.endsWith(type.suffix)) + .findFirst(); + if (mimeType.isPresent()) { + return mimeType.get().mimeType; + } else { + return getFileMimeType(finalPath); + } + } + + private static String getFileMimeType(String finalPath) { + Path file = new File(finalPath).toPath(); + try { + String s = Files.probeContentType(file); + return StringUtils.isEmpty(s) ? HTML.mimeType : s; + } catch (IOException e) { + return HTML.mimeType; + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java new file mode 100644 index 0000000000..014c52ff2d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java @@ -0,0 +1,171 @@ +package com.fr.design.jxbrowser; + +import com.fr.base.TemplateUtils; +import com.fr.design.ui.ModernRequestClient; +import com.fr.design.ui.ModernUIConstants; +import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.EncodeConstants; +import com.fr.stable.StringUtils; +import com.fr.web.struct.AssembleComponent; +import com.fr.web.struct.AtomBuilder; +import com.fr.web.struct.PathGroup; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; +import com.teamdev.jxbrowser.net.HttpHeader; +import com.teamdev.jxbrowser.net.HttpStatus; +import com.teamdev.jxbrowser.net.UrlRequest; +import com.teamdev.jxbrowser.net.UrlRequestJob; +import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback; +import org.jetbrains.annotations.NotNull; + +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.Optional; +import java.util.function.Supplier; + +import static com.fr.design.ui.ModernUIConstants.COMPONENT_TAG; + +/** + * jxbrowser7 自定义 scheme 处理回调 + * + * @author vito + * @since 11.0 + * Created on 2023/6/8 + */ +public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { + + private Supplier component; + + private Supplier> renderParameterBuild; + + public NxInterceptRequestCallback(Supplier> renderParameterBuild) { + this.renderParameterBuild = renderParameterBuild; + } + + public NxInterceptRequestCallback(Supplier component, + Supplier> renderParameterBuild) { + this.component = component; + this.renderParameterBuild = renderParameterBuild; + } + + /** + * 主要包括 atom 和 emb协议的文件链接处理, + * 去掉file文件协议的支持,因此jxbrowser 7之后不支持覆盖内置协议,详细见 + * {@link com.teamdev.jxbrowser.net.internal.NonInterceptableScheme} + * + * @param params 参数 + * @return 响应 + */ + @Override + public Response on(Params params) { + UrlRequest urlRequest = params.urlRequest(); + String path = urlRequest.url(); + Optional urlRequestJobOptional; + if (path.startsWith(COMPONENT_TAG)) { + String text = htmlText(renderParameterBuild.get()); + urlRequestJobOptional = generateBasicUrlRequestJob(params, + "text/html", text.getBytes(StandardCharsets.UTF_8)); + } else { + urlRequestJobOptional = generateFileProtocolUrlRequestJob(params, path); + } + return urlRequestJobOptional + .map(Response::intercept) + .orElseGet(Response::proceed); + } + + protected Optional generateFileProtocolUrlRequestJob(Params params, String path) { + try { + InputStream inputStream = getResourceStream(path); + String mimeType = MimeType.parseMimeType(path); + byte[] bytes; + if (isHtml(mimeType)) { + String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); + text = TemplateUtils.renderParameter4Tpl(text, renderParameterBuild.get()); + bytes = text.getBytes(StandardCharsets.UTF_8); + } else { + bytes = IOUtils.inputStream2Bytes(inputStream); + } + return generateBasicUrlRequestJob(params, mimeType, bytes); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return Optional.empty(); + } + + /** + * 获取资源文件流 + * + * @param path 文件路径 + * @return 输入流 + * @throws Exception IO异常 + */ + private InputStream getResourceStream(String path) throws Exception { + int index = path.indexOf("="); + if (index > 0) { + path = path.substring(index + 1); + } else { + // jxbrowser 7之后,协议会自动补齐双斜杠// + path = path.split(":/")[1]; + } + return IOUtils.readResource(path); + } + + private boolean isHtml(String mimeType) { + return MimeType.HTML.parseMimeType().equals(mimeType); + } + + private Optional generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) { + if (StringUtils.isEmpty(mimeType)) { + return Optional.empty(); + } + UrlRequestJob.Options options = UrlRequestJob.Options + .newBuilder(HttpStatus.OK) + .addHttpHeader(HttpHeader.of("Content-Type", mimeType)) + .build(); + UrlRequestJob urlRequestJob = params.newUrlRequestJob(options); + urlRequestJob.write(bytes); + urlRequestJob.complete(); + return Optional.of(urlRequestJob); + } + + private String htmlText(Map map) { + return component.get() == null ? + StringUtils.EMPTY : + parseComponent(component.get(), map); + } + + @NotNull + private static String parseComponent(AssembleComponent component, Map map) { + PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component); + StylePath[] stylePaths = pathGroup.toStylePathGroup(); + StringBuilder styleText = new StringBuilder(); + for (StylePath path : stylePaths) { + if (StringUtils.isNotBlank(path.toFilePath())) { + styleText.append(""); + } + } + String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString()); + ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup(); + StringBuilder scriptText = new StringBuilder(); + for (ScriptPath path : scriptPaths) { + if (StringUtils.isNotBlank(path.toFilePath())) { + scriptText.append(""); + } + } + result = result.replaceAll("##script##", scriptText.toString()); + if (map != null) { + for (Map.Entry entry : map.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + result = result.replaceAll("\\$\\{" + key + "}", value); + } + } + return result; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/PropertyBuild.java b/designer-base/src/main/java/com/fr/design/jxbrowser/PropertyBuild.java new file mode 100644 index 0000000000..ca82ca2475 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/PropertyBuild.java @@ -0,0 +1,20 @@ +package com.fr.design.jxbrowser; + +import com.teamdev.jxbrowser.js.JsObject; + +/** + * 属性构建器 + * + * @author vito + * @since 11.0 + * Created on 2023/6/8 + */ +public interface PropertyBuild { + /** + * 构建属性 + * + * @param window js环境的window对象 + * @return 待注入java对象 + */ + Object build(JsObject window); +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java index 4789cc4f9b..1b196bedd1 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java @@ -7,9 +7,9 @@ import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; +import com.fr.design.jxbrowser.BrowserExecutor; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.locale.impl.BbsResetMark; -import com.fr.design.login.executor.DesignerLoginBrowserExecutor; import com.fr.design.login.executor.DesignerLoginExecutor; import com.fr.design.login.executor.DesignerSendCaptchaExecutor; import com.fr.design.login.executor.DesignerSmsLoginExecutor; @@ -21,25 +21,26 @@ import com.fr.general.CloudCenter; import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleMark; import com.fr.log.FineLoggerFactory; -import com.teamdev.jxbrowser.chromium.Browser; -import com.teamdev.jxbrowser.chromium.JSFunction; -import com.teamdev.jxbrowser.chromium.JSObject; +import com.teamdev.jxbrowser.js.JsAccessible; +import com.teamdev.jxbrowser.js.JsFunction; +import com.teamdev.jxbrowser.js.JsObject; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingUtilities; import java.awt.Desktop; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.net.URI; import java.util.Map; import java.util.Set; /** + * 设计器登录通行证js-java桥 + * * @author Lanlan * @version 10.0 * Created by Lanlan on 2021/5/21 */ +@JsAccessible public class DesignerLoginBridge { /** @@ -52,20 +53,20 @@ public class DesignerLoginBridge { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Template_Default"; - private Map params; + private final Map params; - public static DesignerLoginBridge getBridge(Browser browser, Map params) { - return new DesignerLoginBridge(browser, params); + public static DesignerLoginBridge getBridge(JsObject window, Map params) { + return new DesignerLoginBridge(window, params); } - private JSObject window; + private final JsObject window; - private DesignerLoginBridge(Browser browser, Map params) { + private DesignerLoginBridge(JsObject window, Map params) { this.params = params; - this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); + this.window = window; Set> entries = params.entrySet(); for (Map.Entry entry : entries) { - this.window.setProperty(entry.getKey(), entry.getValue()); + this.window.putProperty(entry.getKey(), entry.getValue()); } } @@ -183,9 +184,9 @@ public class DesignerLoginBridge { * @param callback 回调函数 */ @JSBridge - public void normalLogin(String username, String password, final JSFunction callback) { + public void normalLogin(String username, String password, final JsFunction callback) { DesignerLoginTaskWorker worker = new DesignerLoginTaskWorker<>( - new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)), + new JSCallback(BrowserExecutor.create(window, callback)), new DesignerLoginExecutor(username, password)); worker.execute(); } @@ -198,9 +199,9 @@ public class DesignerLoginBridge { * @param callback 回调函数 */ @JSBridge - public void sendCaptcha(String regionCode, String phone, final JSFunction callback) { + public void sendCaptcha(String regionCode, String phone, final JsFunction callback) { DesignerLoginTaskWorker worker = new DesignerLoginTaskWorker<>( - new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)), + new JSCallback(BrowserExecutor.create(window, callback)), new DesignerSendCaptchaExecutor(regionCode, phone)); worker.execute(); } @@ -214,9 +215,9 @@ public class DesignerLoginBridge { * @param callback 回调函数 */ @JSBridge - public void smsLogin(String regionCode, String phone, String code, final JSFunction callback) { + public void smsLogin(String regionCode, String phone, String code, final JsFunction callback) { DesignerLoginTaskWorker worker = new DesignerLoginTaskWorker<>( - new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)), + new JSCallback(BrowserExecutor.create(window, callback)), new DesignerSmsLoginExecutor(regionCode, phone, code)); worker.execute(); } @@ -231,9 +232,9 @@ public class DesignerLoginBridge { * @param callback 回调函数 */ @JSBridge - public void smsRegister(String regionCode, String phone, String password, String regToken, final JSFunction callback) { + public void smsRegister(String regionCode, String phone, String password, String regToken, final JsFunction callback) { DesignerLoginTaskWorker worker = new DesignerLoginTaskWorker<>( - new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)), + new JSCallback(BrowserExecutor.create(window, callback)), new DesignerSmsRegisterExecutor(regionCode, phone, password, regToken)); worker.execute(); } @@ -275,13 +276,10 @@ public class DesignerLoginBridge { private JPanel getHyperlinkPane(String title, String hyperlinkText, String hyperlink) { ActionLabel actionLabel = new ActionLabel(hyperlinkText); - actionLabel.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - try { - Desktop.getDesktop().browse(new URI(hyperlink)); - } catch (Exception ignore) { - } + actionLabel.addActionListener(e -> { + try { + Desktop.getDesktop().browse(new URI(hyperlink)); + } catch (Exception ignore) { } }); JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java index be5df3a84d..830a0a1023 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java @@ -2,21 +2,23 @@ package com.fr.design.login; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.BasicPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.login.utils.DesignerLoginUtils; -import com.fr.design.ui.ModernUIPane; -import com.teamdev.jxbrowser.chromium.JSValue; -import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; -import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; + import java.awt.BorderLayout; import java.util.Map; /** + * 设计器登录通行证面板 + * * @author Lanlan * @version 10.0 * Created by Lanlan on 2021/5/21 */ public class DesignerLoginPane extends BasicPane { + private static final String DESIGNER_LOGIN_HELPER = "DesignerLoginHelper"; + @Override protected String title4PopupWindow() { return "DESIGNER_LOGIN"; @@ -27,14 +29,8 @@ public class DesignerLoginPane extends BasicPane { params.put("lastLoginType", String.valueOf(DesignerEnvManager.getEnvManager().getLastLoginType().getType())); params.put("lastLoginAccount", DesignerEnvManager.getEnvManager().getLastLoginAccount()); setLayout(new BorderLayout()); - ModernUIPane modernUIPane = new ModernUIPane.Builder<>() - .prepare(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); - window.asObject().setProperty("DesignerLoginHelper", DesignerLoginBridge.getBridge(event.getBrowser(), params)); - } - }) + JxUIPane modernUIPane = new JxUIPane.Builder<>() + .buildProperty(DESIGNER_LOGIN_HELPER, window -> DesignerLoginBridge.getBridge(window, params)) .withEMB(DesignerLoginHelper.getMainResourcePath(), DesignerLoginUtils.renderMap()) .build(); add(modernUIPane, BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideBridge.java b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideBridge.java index 9b9c561e7c..e45323a0ed 100644 --- a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideBridge.java +++ b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideBridge.java @@ -6,26 +6,31 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.i18n.Toolkit; import com.fr.design.login.DesignerLoginHelper; import com.fr.design.login.DesignerLoginSource; -import com.teamdev.jxbrowser.chromium.Browser; -import com.teamdev.jxbrowser.chromium.JSObject; +import com.teamdev.jxbrowser.js.JsAccessible; + import javax.swing.JOptionPane; import javax.swing.SwingUtilities; /** + * 设计器登录指南面板的js-java桥 + * * @author Lanlan * @version 10.0 * Created by Lanlan on 2021/5/21 */ +@JsAccessible public class DesignerGuideBridge { - public static DesignerGuideBridge getBridge(Browser browser) { - return new DesignerGuideBridge(browser); + /** + * 获取 js-java bridge + * + * @return bridge + */ + public static DesignerGuideBridge getBridge() { + return new DesignerGuideBridge(); } - private JSObject window; - - private DesignerGuideBridge(Browser browser) { - this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); + private DesignerGuideBridge() { } @JSBridge @@ -40,31 +45,28 @@ public class DesignerGuideBridge { DesignerLoginHelper.showLoginDialog(DesignerLoginSource.GUIDE); checkDoNotRemind(doNotRemind); } else { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - String[] options = new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Quit"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Return_Login") - }; - int rv = FineJOptionPane.showConfirmDialog( - DesignerGuideHelper.getDialog(), - com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Quit_Tip"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - JOptionPane.YES_NO_OPTION, - JOptionPane.WARNING_MESSAGE, - null, - options, - options[1] - ); - if (rv == JOptionPane.YES_OPTION) { - DesignerGuideHelper.closeWindow(); - checkDoNotRemind(doNotRemind); - } else if (rv == JOptionPane.NO_OPTION) { - DesignerLoginHelper.showLoginDialog(DesignerLoginSource.GUIDE); - DesignerGuideHelper.closeWindow(); - checkDoNotRemind(doNotRemind); - } + SwingUtilities.invokeLater(() -> { + String[] options = new String[]{ + Toolkit.i18nText("Fine-Designer_Login_Quit"), + Toolkit.i18nText("Fine-Designer_Login_Return_Login") + }; + int rv = FineJOptionPane.showConfirmDialog( + DesignerGuideHelper.getDialog(), + Toolkit.i18nText("Fine-Designer_Login_Quit_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.YES_NO_OPTION, + JOptionPane.WARNING_MESSAGE, + null, + options, + options[1] + ); + if (rv == JOptionPane.YES_OPTION) { + DesignerGuideHelper.closeWindow(); + checkDoNotRemind(doNotRemind); + } else if (rv == JOptionPane.NO_OPTION) { + DesignerLoginHelper.showLoginDialog(DesignerLoginSource.GUIDE); + DesignerGuideHelper.closeWindow(); + checkDoNotRemind(doNotRemind); } }); } diff --git a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java index 3e4c0dae51..05956da7c3 100644 --- a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java +++ b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java @@ -10,9 +10,12 @@ import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; + import javax.swing.WindowConstants; /** + * 设计器登录指南帮助类 + * * @author Lanlan * @version 10.0 * Created by Lanlan on 2021/5/21 diff --git a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java index 64bd316ef5..9157b616a7 100644 --- a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java +++ b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java @@ -1,20 +1,22 @@ package com.fr.design.login.guide; import com.fr.design.dialog.BasicPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.login.guide.utils.DesignerGuideUtils; -import com.fr.design.ui.ModernUIPane; -import com.teamdev.jxbrowser.chromium.JSValue; -import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; -import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; + import java.awt.BorderLayout; /** + * 设计器登录帆软通行证的指南面板 + * * @author Lanlan * @version 10.0 * Created by Lanlan on 2021/5/21 */ public class DesignerGuidePane extends BasicPane { + private static final String DESIGNER_GUIDE_HELPER = "DesignerGuideHelper"; + @Override protected String title4PopupWindow() { return "DESIGNER_GUIDE"; @@ -22,14 +24,8 @@ public class DesignerGuidePane extends BasicPane { public DesignerGuidePane() { setLayout(new BorderLayout()); - ModernUIPane modernUIPane = new ModernUIPane.Builder<>() - .prepare(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); - window.asObject().setProperty("DesignerGuideHelper", DesignerGuideBridge.getBridge(event.getBrowser())); - } - }) + JxUIPane modernUIPane = new JxUIPane.Builder<>() + .buildProperty(DESIGNER_GUIDE_HELPER, w -> DesignerGuideBridge.getBridge()) .withEMB(DesignerGuideHelper.getMainResourcePath(), DesignerGuideUtils.renderMap()) .build(); add(modernUIPane, BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/ui/ModernUIConstants.java b/designer-base/src/main/java/com/fr/design/ui/ModernUIConstants.java index 8f7bf07034..9edd5bd57c 100644 --- a/designer-base/src/main/java/com/fr/design/ui/ModernUIConstants.java +++ b/designer-base/src/main/java/com/fr/design/ui/ModernUIConstants.java @@ -3,12 +3,28 @@ package com.fr.design.ui; import com.fr.general.IOUtils; /** + * 新式面板常量 + * * @author richie * @version 10.0 * Created by richie on 2019-03-05 */ public class ModernUIConstants { + public static final String WINDOW = "window"; + public static final String DOT = "."; + public static final String EMB_TAG = "emb"; + /** + * 从emb:dynamic 改为 emb://dynamic + * 7之后协议会自动在":"后加上斜杠,导致识别错误 + */ + public static final String COMPONENT_TAG = "emb://dynamic"; + + public static final String SCHEME_HEADER = "://"; + + public static final String DEFAULT_NAMESPACE = "Pool"; + public static final String DEFAULT_VARIABLE = "data"; + public static final String DEFAULT_EXPRESSION = "update()"; public static final String SCRIPT_INIT_NAME_SPACE = IOUtils.readResourceAsString("/com/fr/design/ui/InitNameSpace.js"); public static final String HTML_TPL = IOUtils.readResourceAsString("/com/fr/design/ui/tpl.html"); diff --git a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java index 5a0ead41e7..69c7a81ab3 100644 --- a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java +++ b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java @@ -5,10 +5,8 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.compatible.BuilderDiff; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.web.struct.AssembleComponent; -import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.BrowserType; import com.teamdev.jxbrowser.chromium.JSValue; @@ -17,7 +15,6 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; import com.teamdev.jxbrowser.chromium.swing.BrowserView; -import com.teamdev.jxbrowser.event.Observer; import javax.swing.JDialog; import javax.swing.SwingUtilities; @@ -34,7 +31,10 @@ import java.util.Map; * @version 10.0 * Created by richie on 2019-03-04 * 用于加载html5的Swing容器,可以在设计选项设置中打开调试窗口,示例可查看:com.fr.design.ui.ModernUIPaneTest + * @see com.fr.design.jxbrowser.JxUIPane + * @deprecated 主要用于jxbrowser6,将在下个版本删除 */ +@Deprecated public class ModernUIPane extends BasicPane { private Browser browser; @@ -119,6 +119,7 @@ public class ModernUIPane extends BasicPane { /** * 转向一个新的地址,相当于重新加载 + * * @param url 新的地址 */ public void redirect(String url) { @@ -127,6 +128,7 @@ public class ModernUIPane extends BasicPane { /** * 转向一个新的地址,相当于重新加载 + * * @param url 新的地址 * @param map 初始化参数 */ @@ -161,7 +163,7 @@ public class ModernUIPane extends BasicPane { public void disposeBrowser() { - if(browser != null) { + if (browser != null) { browser.dispose(); browser = null; } @@ -191,7 +193,13 @@ public class ModernUIPane extends BasicPane { return null; } - public static class Builder implements BuilderDiff { + + /** + * ModernUIPane 建造者 + * + * @param + */ + public static class Builder { private ModernUIPane pane; @@ -219,6 +227,7 @@ public class ModernUIPane extends BasicPane { /** * 加载jar包中的资源 + * * @param path 资源路径 */ public Builder withEMB(final String path) { @@ -229,6 +238,7 @@ public class ModernUIPane extends BasicPane { /** * 加载jar包中的资源 + * * @param path 资源路径 */ public Builder withEMB(final String path, Map map) { @@ -239,6 +249,7 @@ public class ModernUIPane extends BasicPane { /** * 加载url指向的资源 + * * @param url 文件的地址 */ public Builder withURL(final String url) { @@ -249,6 +260,7 @@ public class ModernUIPane extends BasicPane { /** * 加载url指向的资源 + * * @param url 文件的地址 */ public Builder withURL(final String url, Map map) { @@ -259,6 +271,7 @@ public class ModernUIPane extends BasicPane { /** * 加载Atom组件 + * * @param component Atom组件 */ public Builder withComponent(AssembleComponent component) { @@ -269,6 +282,7 @@ public class ModernUIPane extends BasicPane { /** * 加载Atom组件 + * * @param component Atom组件 */ public Builder withComponent(AssembleComponent component, Map map) { @@ -277,9 +291,9 @@ public class ModernUIPane extends BasicPane { return this; } - /** * 加载html文本内容 + * * @param html 要加载html文本内容 */ public Builder withHTML(String html) { @@ -290,6 +304,7 @@ public class ModernUIPane extends BasicPane { /** * 设置该前端页面做数据交换所使用的对象 + * * @param namespace 对象名 */ public Builder namespace(String namespace) { @@ -299,6 +314,7 @@ public class ModernUIPane extends BasicPane { /** * java端往js端传数据时使用的变量名字 + * * @param name 变量的名字 */ public Builder variable(String name) { @@ -308,6 +324,7 @@ public class ModernUIPane extends BasicPane { /** * js端往java端传数据时执行的函数表达式 + * * @param expression 函数表达式 */ public Builder expression(String expression) { @@ -315,28 +332,14 @@ public class ModernUIPane extends BasicPane { return this; } - @Override public Builder prepareForV6(ScriptContextListener contextListener) { return prepare(contextListener); } - @Override public Builder prepareForV6(LoadListener loadListener) { return prepare(loadListener); } - @Override - public Builder prepareForV7(InjectJsCallback callback) { - // do nothing - return this; - } - - @Override - public Builder prepareForV7(Class event, Observer listener) { - // do nothing - return this; - } - public ModernUIPane build() { return pane; } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java b/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java deleted file mode 100644 index 9e6168514f..0000000000 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.fr.design.ui.compatible; - -import com.fr.design.ui.ModernUIPane; -import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; -import com.teamdev.jxbrowser.chromium.events.LoadListener; -import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; -import com.teamdev.jxbrowser.event.Observer; - -/** - * 封装jxbrwoser v6/v7的构建方式的差异 - * - * @author hades - * @version 10.0 - * Created by hades on 2021/6/13 - */ -public interface BuilderDiff { - - ModernUIPane.Builder prepareForV6(ScriptContextListener contextListener); - - ModernUIPane.Builder prepareForV6(LoadListener loadListener); - - ModernUIPane.Builder prepareForV7(InjectJsCallback callback); - - ModernUIPane.Builder prepareForV7(Class event, Observer listener); - -} diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java deleted file mode 100644 index 68b8950f7c..0000000000 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.fr.design.ui.compatible; - -import com.fr.design.ui.ModernUIPane; -import com.fr.stable.os.OperatingSystem; - -/** - * @author hades - * @version 10.0 - * Created by hades on 2021/6/13 - */ -public class ModernUIPaneFactory { - - public static ModernUIPane.Builder modernUIPaneBuilder() { - - if (isV7()) { - return new NewModernUIPane.Builder<>(); - } else { - return new ModernUIPane.Builder<>(); - } - - } - - public static boolean isV7() { - - // 7.15的class不存在时 走老版本 - boolean hasJxBrowserV7_15 = true; - try { - Class.forName("com.teamdev.jxbrowser.net.Scheme"); - } catch (ClassNotFoundException e) { - hasJxBrowserV7_15 = false; - } - - return OperatingSystem.isWindows() && hasJxBrowserV7_15; - - } -} diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java deleted file mode 100644 index 59df782cde..0000000000 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java +++ /dev/null @@ -1,362 +0,0 @@ -package com.fr.design.ui.compatible; - -import com.fr.design.DesignerEnvManager; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.itoolbar.UIToolbar; -import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIConstants; -import com.fr.design.ui.ModernUIPane; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.web.struct.AssembleComponent; -import com.teamdev.jxbrowser.browser.Browser; -import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; -import com.teamdev.jxbrowser.chromium.events.LoadListener; -import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; -import com.teamdev.jxbrowser.engine.Engine; -import com.teamdev.jxbrowser.engine.EngineOptions; -import com.teamdev.jxbrowser.engine.RenderingMode; -import com.teamdev.jxbrowser.event.Observer; -import com.teamdev.jxbrowser.js.JsObject; -import com.teamdev.jxbrowser.net.Network; -import com.teamdev.jxbrowser.net.Scheme; -import com.teamdev.jxbrowser.net.callback.VerifyCertificateCallback; -import com.teamdev.jxbrowser.view.swing.BrowserView; -import org.jetbrains.annotations.Nullable; - - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.util.Map; - -import javax.swing.JDialog; -import javax.swing.SwingUtilities; -import javax.swing.WindowConstants; - -/** - * 基于v7 jxbrowser实现 - * - * @author richie - * @version 10.0 - * Created by richie on 2019-03-04 - * 用于加载html5的Swing容器,可以在设计选项设置中打开调试窗口,示例可查看:com.fr.design.ui.ModernUIPaneTest - */ -public class NewModernUIPane extends ModernUIPane { - - private Browser browser; - private String namespace = "Pool"; - private String variable = "data"; - private String expression = "update()"; - private Scheme scheme; - private NxInterceptRequestCallback requestCallback; - - private NewModernUIPane() { - super(); - initialize(); - } - - private void initialize() { - setLayout(new BorderLayout()); - if (browser == null) { - if (DesignerEnvManager.getEnvManager().isOpenDebug()) { - UIToolbar toolbar = new UIToolbar(); - add(toolbar, BorderLayout.NORTH); - UIButton openDebugButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window")); - toolbar.add(openDebugButton); - UIButton reloadButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Reload")); - toolbar.add(reloadButton); - UIButton closeButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Close_Window")); - toolbar.add(closeButton); - - openDebugButton.addActionListener(e -> showDebuggerDialog()); - - reloadButton.addActionListener(e -> browser.navigation().reloadIgnoringCache()); - - closeButton.addActionListener(e -> SwingUtilities.getWindowAncestor( - NewModernUIPane.this).setVisible(false)); - initializeBrowser(); - add(BrowserView.newInstance(browser), BorderLayout.CENTER); - } else { - initializeBrowser(); - add(BrowserView.newInstance(browser), BorderLayout.CENTER); - } - } - } - - private void showDebuggerDialog() { - JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this)); - - Browser debugger = browser.engine().newBrowser(); - BrowserView debuggerView = BrowserView.newInstance(debugger); - dialog.add(debuggerView, BorderLayout.CENTER); - dialog.setSize(new Dimension(800, 400)); - GUICoreUtils.centerWindow(dialog); - dialog.setVisible(true); - dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - - browser.devTools().remoteDebuggingUrl().ifPresent(url -> { - debugger.navigation().loadUrl(url); - }); - } - - private void initializeBrowser() { - EngineOptions.Builder builder; - if (scheme != null && requestCallback != null) { - builder = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback); - } else { - builder = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic"); - } - - if (DesignerEnvManager.getEnvManager().isOpenDebug()) { - builder.remoteDebuggingPort(9222); - } - - Engine engine = Engine.newInstance(builder.build()); - if (DesignerEnvManager.getEnvManager().isOpenDebug()) { - // 调试模式下,禁止HTTPS证书验证,使得可以正常访问商城测试服务器等 - Network network = engine.network(); - network.set(VerifyCertificateCallback.class, new VerifyCertificateCallback() { - @Nullable - @Override - public Response on(Params params) { - return VerifyCertificateCallback.Response.valid(); - } - }); - } - browser = engine.newBrowser(); - - // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 - browser.set(InjectJsCallback.class, params -> { - params.frame().executeJavaScript(String.format(ModernUIConstants.SCRIPT_INIT_NAME_SPACE, namespace)); - return InjectJsCallback.Response.proceed(); - }); - } - - /** - * 转向一个新的地址,相当于重新加载 - * - * @param url 新的地址 - */ - @Override - public void redirect(String url) { - browser.navigation().loadUrl(url); - } - - /** - * 转向一个新的地址,相当于重新加载 - * - * @param url 新的地址 - * @param map 初始化参数 - */ - @Override - public void redirect(String url, Map map) { - if (requestCallback != null) { - requestCallback.setMap(map); - } - browser.navigation().loadUrl(url); - } - - @Override - protected String title4PopupWindow() { - return "Modern"; - } - - @Override - public void populate(final T t) { - browser.set(InjectJsCallback.class, params -> { - JsObject ns = params.frame().executeJavaScript("window." + namespace); - if (ns != null) { - ns.putProperty(variable, t); - } - return InjectJsCallback.Response.proceed(); - }); - } - - @Override - public T update() { - if (browser.mainFrame().isPresent()) { - return browser.mainFrame().get().executeJavaScript("window." + namespace + "." + expression); - } - return null; - } - - public void disposeBrowser() { - - if (browser != null) { - browser.engine().close(); - browser = null; - } - - } - - public void clearCache() { - if (browser != null) { - browser.engine().httpCache().clear(); - } - } - - public void executeJavaScript(String javaScript) { - if (browser != null) { - browser.mainFrame().ifPresent(frame -> { - frame.executeJavaScript(javaScript); - }); - } - } - - public static class Builder extends ModernUIPane.Builder { - - private NewModernUIPane pane = new NewModernUIPane<>(); - - public Builder() { - super((ModernUIPane)null); - } - - public NewModernUIPane.Builder prepare(InjectJsCallback callback) { - pane.browser.set(InjectJsCallback.class, callback); - return this; - } - - /** - * 加载jar包中的资源 - * - * @param path 资源路径 - */ - @Override - public NewModernUIPane.Builder withEMB(final String path) { - pane.scheme = Scheme.of("emb"); - pane.requestCallback = new NxComplexInterceptRequestCallback(null); - pane.browser.navigation().loadUrl("emb:" + path); - return this; - } - - /** - * 加载url指向的资源 - * - * @param url 文件的地址 - */ - @Override - public NewModernUIPane.Builder withURL(final String url) { - pane.scheme = Scheme.of("file"); - pane.requestCallback = new NxComplexInterceptRequestCallback(null); - pane.browser.navigation().loadUrl(url); - return this; - } - - /** - * 加载url指向的资源 - * - * @param url 文件的地址 - */ - @Override - public NewModernUIPane.Builder withURL(final String url, Map map) { - pane.scheme = Scheme.of("file"); - pane.requestCallback = new NxInterceptRequestCallback(map); - pane.browser.navigation().loadUrl(url); - return this; - } - - /** - * 加载Atom组件 - * - * @param component Atom组件 - */ - @Override - public NewModernUIPane.Builder withComponent(AssembleComponent component) { - pane.scheme = Scheme.of("emb"); - pane.requestCallback = new NxComplexInterceptRequestCallback(component); - pane.browser.navigation().loadUrl("emb:dynamic"); - return this; - } - - /** - * 加载Atom组件 - * - * @param component Atom组件 - */ - @Override - public NewModernUIPane.Builder withComponent(AssembleComponent component, Map map) { - pane.scheme = Scheme.of("emb"); - pane.requestCallback = new NxComplexInterceptRequestCallback(component, map); - pane.browser.navigation().loadUrl("emb:dynamic"); - return this; - } - - - /** - * 加载html文本内容 - * - * @param html 要加载html文本内容 - */ - @Override - public NewModernUIPane.Builder withHTML(String html) { - pane.scheme = Scheme.of("html"); - pane.requestCallback = new NxInterceptRequestCallback(); - pane.browser.mainFrame().ifPresent(frame -> { - frame.loadHtml(html); - }); - return this; - } - - /** - * 设置该前端页面做数据交换所使用的对象 - * - * @param namespace 对象名 - */ - @Override - public NewModernUIPane.Builder namespace(String namespace) { - pane.namespace = namespace; - return this; - } - - /** - * java端往js端传数据时使用的变量名字 - * - * @param name 变量的名字 - */ - @Override - public NewModernUIPane.Builder variable(String name) { - pane.variable = name; - return this; - } - - /** - * js端往java端传数据时执行的函数表达式 - * - * @param expression 函数表达式 - */ - @Override - public NewModernUIPane.Builder expression(String expression) { - pane.expression = expression; - return this; - } - - @Override - public NewModernUIPane.Builder prepareForV6(ScriptContextListener contextListener) { - // do nothing - return this; - } - - @Override - public NewModernUIPane.Builder prepareForV6(LoadListener loadListener) { - // do nothing - return this; - } - - @Override - public NewModernUIPane.Builder prepareForV7(InjectJsCallback callback) { - return prepare(callback); - } - - @Override - public ModernUIPane.Builder prepareForV7(Class event, Observer listener) { - - pane.browser.navigation().on(event, listener); - - return this; - } - - @Override - public NewModernUIPane build() { - return pane; - } - } -} diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java deleted file mode 100644 index eb85495d40..0000000000 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.fr.design.ui.compatible; - -import com.fr.design.ui.ModernRequestClient; -import com.fr.design.ui.ModernUIConstants; -import com.fr.general.IOUtils; -import com.fr.stable.StringUtils; -import com.fr.web.struct.AssembleComponent; -import com.fr.web.struct.AtomBuilder; -import com.fr.web.struct.PathGroup; -import com.fr.web.struct.category.ScriptPath; -import com.fr.web.struct.category.StylePath; - -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.Map; - -/** - * @author richie - * @version 10.0 - * Created by richie on 2020/3/25 - */ -public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallback { - - private AssembleComponent component; - - public NxComplexInterceptRequestCallback(AssembleComponent component) { - this.component = component; - } - - public NxComplexInterceptRequestCallback(AssembleComponent component, Map map) { - super(map); - this.component = component; - } - - @Override - protected Response next(Params params, String path) { - if (path.startsWith("emb:dynamic")) { - String text = htmlText(map); - return Response.intercept(generateBasicUrlRequestJob(params, "text/html", text.getBytes(StandardCharsets.UTF_8))); - } else { - int index = path.indexOf("="); - if (index > 0) { - path = path.substring(index + 1); - } else { - path = path.substring(4); - } - InputStream inputStream = IOUtils.readResource(path); - if (inputStream == null) { - return Response.proceed(); - } - return Response.intercept(generateBasicUrlRequestJob(params, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); - } - } - - private String htmlText(Map map) { - PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component); - StylePath[] stylePaths = pathGroup.toStylePathGroup(); - StringBuilder styleText = new StringBuilder(); - for (StylePath path : stylePaths) { - if (StringUtils.isNotBlank(path.toFilePath())) { - styleText.append(""); - } - } - String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString()); - ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup(); - StringBuilder scriptText = new StringBuilder(); - for (ScriptPath path : scriptPaths) { - if (StringUtils.isNotBlank(path.toFilePath())) { - scriptText.append(""); - } - } - result = result.replaceAll("##script##", scriptText.toString()); - if (map != null) { - for (Map.Entry entry : map.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - result = result.replaceAll("\\$\\{" + key + "}", value); - } - } - return result; - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java deleted file mode 100644 index 32a8f8b610..0000000000 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.fr.design.ui.compatible; - -import com.fr.base.TemplateUtils; -import com.fr.general.IOUtils; -import com.fr.log.FineLoggerFactory; -import com.fr.stable.ArrayUtils; -import com.fr.stable.EncodeConstants; -import com.fr.stable.StringUtils; -import com.fr.third.org.apache.commons.codec.net.URLCodec; -import com.teamdev.jxbrowser.net.HttpHeader; -import com.teamdev.jxbrowser.net.HttpStatus; -import com.teamdev.jxbrowser.net.UrlRequest; -import com.teamdev.jxbrowser.net.UrlRequestJob; - -import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Map; -import java.util.Optional; - -/** - * @author richie - * @version 10.0 - * Created by richie on 2020/3/25 - */ -public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { - - Map map; - - public NxInterceptRequestCallback() { - } - - public NxInterceptRequestCallback(Map map) { - this.map = map; - } - - @Override - public Response on(Params params) { - UrlRequest urlRequest = params.urlRequest(); - String path = urlRequest.url(); - if (path.startsWith("file:")) { - Optional optional = generateFileProtocolUrlRequestJob(params, path); - if (optional.isPresent()) { - return Response.intercept(optional.get()); - } - } else { - return next(params, path); - } - return Response.proceed(); - } - - Response next(Params params, String path) { - return Response.proceed(); - } - - private Optional generateFileProtocolUrlRequestJob(Params params, String path) { - try { - String url = new URLCodec().decode(path); - String filePath = TemplateUtils.renderParameter4Tpl(url, map); - File file = new File(URI.create(filePath).getPath()); - InputStream inputStream = IOUtils.readResource(file.getAbsolutePath()); - String mimeType = getMimeType(path); - byte[] bytes; - if (isPlainText(mimeType)) { - String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); - text = TemplateUtils.renderParameter4Tpl(text, map); - bytes = text.getBytes(StandardCharsets.UTF_8); - } else { - bytes = IOUtils.inputStream2Bytes(inputStream); - } - return Optional.of(generateBasicUrlRequestJob(params, mimeType, bytes)); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - return Optional.empty(); - } - - private boolean isPlainText(String mimeType) { - return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType); - } - - UrlRequestJob generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) { - UrlRequestJob.Options options = UrlRequestJob.Options - .newBuilder(HttpStatus.OK) - .addHttpHeader(HttpHeader.of("Content-Type", mimeType)) - .build(); - UrlRequestJob urlRequestJob = params.newUrlRequestJob(options); - urlRequestJob.write(bytes); - urlRequestJob.complete(); - return urlRequestJob; - } - - String getMimeType(String path) { - // 去除 xxx?xxx 后面部分 - int index = path.indexOf("?"); - if (index != -1) { - path = path.substring(0, path.indexOf("?")); - } - if (StringUtils.isBlank(path)) { - return "text/html"; - } - if (path.endsWith(".html")) { - return "text/html"; - } - if (path.endsWith(".css")) { - return "text/css"; - } - if (path.endsWith(".js")) { - return "text/javascript"; - } - if (path.endsWith(".svg")) { - return "image/svg+xml"; - } - if (path.endsWith(".png")) { - return "image/png"; - } - if (path.endsWith(".jpeg")) { - return "image/jpeg"; - } - if (path.endsWith(".gif")) { - return "image/gif"; - } - if (path.endsWith(".woff")) { - return "font/woff"; - } - if (path.endsWith(".ttf")) { - return "truetype"; - } - if (path.endsWith(".eot")) { - return "embedded-opentype"; - } - Path file = new File(path).toPath(); - try { - return Files.probeContentType(file); - } catch (IOException e) { - return "text/html"; - } - } - - public void setMap(Map map) { - this.map = map; - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java index e37877a4bb..1db0832c65 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java @@ -1,7 +1,7 @@ package com.fr.design.update.push; import com.fr.design.dialog.UIDialog; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.intelli.record.FocusPoint; @@ -14,20 +14,24 @@ import com.fr.web.struct.browser.RequestClient; import com.fr.web.struct.category.ScriptPath; import com.fr.web.struct.category.StylePath; import com.fr.web.struct.impl.FineUI; +import com.teamdev.jxbrowser.js.JsAccessible; import javax.swing.JPanel; -import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Frame; /** - * Created by plough on 2019/4/10. + * 设计器推送更新对话框 + * + * @author plough + * @since 10.0 + * Created on 2019/4/10. */ -class DesignerPushUpdateDialog extends UIDialog { +public class DesignerPushUpdateDialog extends UIDialog { public static final Dimension DEFAULT = new Dimension(640, 360); - private ModernUIPane jsPane; + private JxUIPane jsPane; private DesignerPushUpdateDialog(Frame parent) { super(parent); @@ -35,23 +39,23 @@ class DesignerPushUpdateDialog extends UIDialog { initComponents(); } - static void createAndShow(final Frame parent, final DesignerUpdateInfo updateInfo) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - DesignerPushUpdateDialog dialog = new DesignerPushUpdateDialog(parent); - dialog.populate(updateInfo); - dialog.showDialog(); - } - }); - + /** + * 创建并展示窗口 + * + * @param parent 父窗体 + * @param updateInfo 要展示的更新数据 + */ + public static void createAndShow(final Frame parent, final DesignerUpdateInfo updateInfo) { + DesignerPushUpdateDialog dialog = new DesignerPushUpdateDialog(parent); + dialog.populate(updateInfo); + dialog.showDialog(); } private void initComponents() { JPanel contentPane = (JPanel) getContentPane(); contentPane.setLayout(new BorderLayout()); - jsPane = new ModernUIPane.Builder() + jsPane = new JxUIPane.Builder() .withComponent(new AssembleComponent() { @Override public ScriptPath script(RequestClient req) { @@ -67,7 +71,7 @@ class DesignerPushUpdateDialog extends UIDialog { public Atom[] refer() { return new Atom[]{FineUI.KEY}; } - }).namespace("Pool").build(); + }).build(); contentPane.add(jsPane); } @@ -101,6 +105,7 @@ class DesignerPushUpdateDialog extends UIDialog { setVisible(true); } + @JsAccessible public class Model { private String version; private String content; @@ -163,6 +168,7 @@ class DesignerPushUpdateDialog extends UIDialog { exit(); } + @JsAccessible public String i18nText(String key) { return com.fr.design.i18n.Toolkit.i18nText(key); } @@ -180,9 +186,11 @@ class DesignerPushUpdateDialog extends UIDialog { private enum OperateType { CLOSE_WINDOW(0), UPDATE(1), REMIND_NEXT_TIME(2), SKIP(3); private int index; + OperateType(int index) { this.index = index; } + private String toText() { return String.valueOf(this.index); } diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java index 3f7c23cd30..47fbca1716 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java @@ -12,9 +12,13 @@ import com.fr.stable.StringUtils; import java.security.InvalidParameterException; /** - * Created by plough on 2019/4/8. + * 设计器更新信息bean + * + * @author plough + * @since 10.0 + * Created on 2019/4/8. */ -class DesignerUpdateInfo { +public class DesignerUpdateInfo { private static final String KEY_VERSION = "version"; private static final String KEY_CONTENT = "content"; private static final String KEY_BACKGROUND_URL = "background"; @@ -32,7 +36,7 @@ class DesignerUpdateInfo { private final String backgroundUrl; // 推送背景图片 url private final String moreInfoUrl; // 更多新特性 - DesignerUpdateInfo(String currentVersion, String latestVersion, String lastIgnoredVersion, JSONObject pushData) { + public DesignerUpdateInfo(String currentVersion, String latestVersion, String lastIgnoredVersion, JSONObject pushData) { this.currentVersion = currentVersion; this.latestVersion = latestVersion; this.latestFullVersion = initLatestFullVersion(); 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..4eb154e2d1 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 @@ -41,11 +41,11 @@ import com.teamdev.jxbrowser.chromium.JSArray; import com.teamdev.jxbrowser.chromium.JSFunction; import com.teamdev.jxbrowser.chromium.JSObject; -import java.awt.Desktop; import javax.swing.JFileChooser; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.filechooser.FileNameExtensionFilter; +import java.awt.Desktop; import java.io.File; import java.net.URI; import java.util.ArrayList; @@ -59,7 +59,9 @@ import java.util.concurrent.RunnableFuture; * @version 10.0 * Created by richie on 2019-04-12 * 桥接Java和JavaScript的类 + * @deprecated 用于jxbrowser6,下版本删除 */ +@Deprecated public class UpmBridge { public static UpmBridge getBridge(Browser browser) { @@ -78,6 +80,7 @@ public class UpmBridge { /** * 更新插件管理中心资源文件,这个方法仅仅是为了语义上的作用(更新) + * * @param callback 安装完成后的回调函数 */ @JSBridge @@ -96,6 +99,7 @@ public class UpmBridge { /** * 下载并安装插件管理中心的资源文件 + * * @param callback 安装完成后的回调函数 */ @JSBridge @@ -126,6 +130,7 @@ public class UpmBridge { /** * 获取upm的版本信息 + * * @return 版本信息 */ @JSBridge @@ -315,7 +320,7 @@ public class UpmBridge { @Override public String call() { FileChooserProvider fileChooserProvider = FileChooserFactory.createFileChooser( - FileChooserArgs.newBuilder(). + FileChooserArgs.newBuilder(). setFileSelectionMode(FileSelectionMode.FILE). setFilter(des, filter).build()); int result = fileChooserProvider.showDialog(UpmFinder.getDialog()); @@ -468,6 +473,7 @@ public class UpmBridge { /** * 使用系统浏览器打开网页 + * * @param url 要打开的网页 */ @JSBridge diff --git a/designer-base/src/main/java/com/fr/design/upm/NewUpmBridge.java b/designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java similarity index 98% rename from designer-base/src/main/java/com/fr/design/upm/NewUpmBridge.java rename to designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java index 6b9f1f85fc..a7714621b7 100644 --- a/designer-base/src/main/java/com/fr/design/upm/NewUpmBridge.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java @@ -45,15 +45,16 @@ import java.util.concurrent.RunnableFuture; * Created by richie on 2019-04-12 * 桥接Java和JavaScript的类 */ -public class NewUpmBridge extends UpmBridge { +@JsAccessible +public class UpmBridgeV7 extends UpmBridge { - public static NewUpmBridge getBridge(JsObject jsObject) { - return new NewUpmBridge(jsObject); + public static UpmBridgeV7 getBridge(JsObject jsObject) { + return new UpmBridgeV7(jsObject); } private JsObject jsObject; - private NewUpmBridge(JsObject jsObject) { + private UpmBridgeV7(JsObject jsObject) { this.jsObject = jsObject; } diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 576c5a9b96..ede9b45d81 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -8,6 +8,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.login.utils.DesignerLoginUtils; import com.fr.design.mainframe.DesignerContext; import com.fr.design.plugin.DesignerPluginContext; +import com.fr.design.ui.ModernUIConstants; import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -57,7 +58,8 @@ public class UpmFinder { } public static String getMainResourcePath() { - return "file:///" + StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH); + return ModernUIConstants.EMB_TAG + ModernUIConstants.SCHEME_HEADER + + StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH); } public static UIDialog getDialog() { diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java index 23a712508e..83de627c4e 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java @@ -1,19 +1,13 @@ package com.fr.design.upm; import com.fr.design.dialog.BasicPane; -import com.fr.design.ui.ModernUIPane; -import com.fr.design.ui.compatible.ModernUIPaneFactory; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.upm.event.DownloadEvent; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; -import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; -import com.teamdev.jxbrowser.chromium.JSValue; -import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; -import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; -import com.teamdev.jxbrowser.js.JsObject; -import java.awt.*; +import java.awt.BorderLayout; /** * @author richie @@ -23,7 +17,9 @@ import java.awt.*; */ public class UpmShowPane extends BasicPane { - private ModernUIPane modernUIPane; + public static final String PLUGIN_HELPER = "PluginHelper"; + + private final JxUIPane jxUIPane; @Override protected String title4PopupWindow() { @@ -32,28 +28,22 @@ public class UpmShowPane extends BasicPane { UpmShowPane() { setLayout(new BorderLayout()); - modernUIPane = new ModernUIPane.Builder<>() - .prepare(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); - window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); - } - }) + jxUIPane = new JxUIPane.Builder<>() + .buildProperty(PLUGIN_HELPER, UpmBridgeV7::getBridge) .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) .build(); EventDispatcher.listen(DownloadEvent.UPDATE, new Listener() { @Override public void on(Event event, String param) { - modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); + jxUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); } }); EventDispatcher.listen(DownloadEvent.UPDATE, new Listener() { @Override public void on(Event event, String param) { - modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); + jxUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); } }); - add(modernUIPane, BorderLayout.CENTER); + add(jxUIPane, BorderLayout.CENTER); } } diff --git a/designer-base/src/test/java/com/fr/design/jxbrowser/JxUIPaneTest.java b/designer-base/src/test/java/com/fr/design/jxbrowser/JxUIPaneTest.java new file mode 100644 index 0000000000..0b4bea61c5 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/jxbrowser/JxUIPaneTest.java @@ -0,0 +1,72 @@ +package com.fr.design.jxbrowser; + +import com.fr.design.DesignerEnvManager; +import com.teamdev.jxbrowser.js.JsAccessible; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.WindowConstants; +import java.awt.BorderLayout; +import java.awt.FlowLayout; + +public class JxUIPaneTest { + + public static void main(String... args) { + final JFrame frame = new JFrame(); + frame.setSize(1200, 800); + JPanel contentPane = (JPanel) frame.getContentPane(); + // 是否需要开启调试窗口 + DesignerEnvManager.getEnvManager().setOpenDebug(true); + final JxUIPane pane = new JxUIPane.Builder() + .withEMB("/com/fr/design/ui/demo.html").namespace("Pool").build(); + contentPane.add(pane, BorderLayout.CENTER); + + Model model = new Model(); + model.setAge(20); + model.setName("Pick"); + pane.populate(model); + + JPanel panel = new JPanel(new FlowLayout()); + contentPane.add(panel, BorderLayout.SOUTH); + JButton button = new JButton("点击我可以看到Swing的弹框,输出填写的信息"); + panel.add(button); + button.addActionListener(e -> { + Model returnValue = pane.update(); + if (returnValue != null) { + JOptionPane.showMessageDialog(frame, String.format("姓名为:%s,年龄为:%d", returnValue.getName(), returnValue.getAge())); + } + }); + frame.setVisible(true); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + } + + @JsAccessible + public static class Model { + private String name; + private int age; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public void print(String message) { + System.out.println(message); + } + + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java b/designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java new file mode 100644 index 0000000000..6a5fcf7f42 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java @@ -0,0 +1,21 @@ +package com.fr.design.jxbrowser; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author vito + * @since 11.0 + * Created on 2023/6/13 + */ +public class MimeTypeTest { + + @Test + public void getMimeType() { + Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.html")); + Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.html?a=ji")); + Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.xml?a=ji")); + Assert.assertEquals("image/jpeg", MimeType.parseMimeType("http://a.jpg?a=ji")); + Assert.assertEquals("image/jpeg", MimeType.parseMimeType("http://a.jpeg?a=ji")); + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java b/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java index c7dd4b6821..23ac04a05c 100644 --- a/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java +++ b/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java @@ -1,6 +1,7 @@ package com.fr.design.ui; import com.fr.design.DesignerEnvManager; +import com.fr.design.jxbrowser.JxUIPane; import javax.swing.*; import java.awt.*; @@ -19,7 +20,7 @@ public class FineUIDemo { // 是否需要开启调试窗口 DesignerEnvManager.getEnvManager().setOpenDebug(true); - final ModernUIPane pane = new ModernUIPane.Builder() + final JxUIPane pane = new JxUIPane.Builder() .withComponent(StartComponent.KEY).build(); contentPane.add(pane, BorderLayout.CENTER); frame.setVisible(true); diff --git a/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java b/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java index b267b1346a..d1067c4e79 100644 --- a/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java +++ b/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java @@ -1,11 +1,13 @@ package com.fr.design.ui.report; import com.fr.design.DesignerEnvManager; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.ui.ModernUIPaneTest; -import javax.swing.*; -import java.awt.*; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.WindowConstants; +import java.awt.BorderLayout; /** * Created by windy on 2019/3/26. @@ -19,7 +21,7 @@ public class TemplateWebSettingDemo { // 是否需要开启调试窗口 DesignerEnvManager.getEnvManager().setOpenDebug(true); - final ModernUIPane pane = new ModernUIPane.Builder() + final JxUIPane pane = new JxUIPane.Builder() .withComponent(TemplateWebSettingComponent.KEY).build(); contentPane.add(pane, BorderLayout.CENTER); frame.setVisible(true); diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java index d780a44eb1..011551108f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.box; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat; @@ -33,7 +33,7 @@ public class VanChartBoxRichTextDetailedFieldListPane extends VanChartFieldListP private VanChartFieldButton richTextMin; private VanChartFieldButton richTextOutlier; - public VanChartBoxRichTextDetailedFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartBoxRichTextDetailedFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java index 9816967ff0..cb62787c21 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java @@ -1,6 +1,6 @@ package com.fr.van.chart.box; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; import com.fr.van.chart.designer.component.richText.VanChartFieldButton; import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; @@ -11,7 +11,7 @@ import java.util.List; public class VanChartBoxRichTextResultFieldListPane extends VanChartBoxRichTextDetailedFieldListPane { - public VanChartBoxRichTextResultFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartBoxRichTextResultFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java index 4e7a657d6b..1a76f548b1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java @@ -2,9 +2,9 @@ package com.fr.van.chart.box; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat; @@ -103,11 +103,11 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { return commonPanel; } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { if (detailed) { return new VanChartBoxRichTextDetailedFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index ab84b88b89..d89a7d31e5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -7,11 +7,11 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; -import com.fr.design.ui.ModernUIPane; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipRichText; @@ -390,7 +390,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText); + JxUIPane richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText); VanChartRichTextPane richTextPane = this.createRichTextPane(richEditorPane); BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane); @@ -431,7 +431,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java index 02a62de3b6..891bf9bdaa 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java @@ -4,7 +4,7 @@ import com.fr.data.util.function.AbstractDataFunction; import com.fr.data.util.function.DataFunction; import com.fr.design.event.UIObserverListener; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.base.AttrTooltipContent; @@ -43,14 +43,14 @@ public class VanChartFieldListPane extends JPanel { private VanChartFieldButton percentButton; private VanChartFieldAttrPane fieldAttrPane; - private ModernUIPane richEditorPane; + private JxUIPane richEditorPane; private List tableFieldNameList; private List tableFieldButtonList = new ArrayList<>(); private TableFieldCollection tableFieldCollection = new TableFieldCollection(); private VanChartFieldListener fieldListener; - public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { List richEditorFieldNames = VanChartRichEditorPane.getFieldNames(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java index 83df27c0fb..77abd347de 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java @@ -2,7 +2,9 @@ package com.fr.van.chart.designer.component.richText; import com.fr.plugin.chart.type.TextAlign; import com.fr.stable.StringUtils; +import com.teamdev.jxbrowser.js.JsAccessible; +@JsAccessible public class VanChartRichEditorModel { private String content = StringUtils.EMPTY; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java index d36ef487c7..de141f8638 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java @@ -11,7 +11,7 @@ import com.fr.data.impl.NameTableData; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.data.DesignTableDataManager; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.plugin.chart.base.AttrTooltipRichText; @@ -21,11 +21,9 @@ import com.fr.plugin.chart.type.TextAlign; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.lang3.SystemUtils; import com.fr.van.chart.designer.PlotFactory; -import com.teamdev.jxbrowser.chromium.Browser; -import com.teamdev.jxbrowser.chromium.BrowserType; -import com.teamdev.jxbrowser.chromium.JSValue; -import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; -import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; +import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; +import com.teamdev.jxbrowser.frame.Frame; +import com.teamdev.jxbrowser.js.JsObject; import java.util.ArrayList; import java.util.Arrays; @@ -45,8 +43,8 @@ public class VanChartRichEditorPane { private static final String REFRESH = "refresh()"; private static final String ADD_FIELD = "addField()"; - private static ModernUIPane richEditorPane; - private static Browser browser; + private static JxUIPane richEditorPane; + private static Frame frame; private static List fieldNames; private static final boolean USE_LIGHT_WEIGHT = SystemUtils.IS_OS_WINDOWS_10; @@ -123,12 +121,12 @@ public class VanChartRichEditorPane { fieldNames.addAll(Arrays.asList(columnNames)); } - public static ModernUIPane createRichEditorPane(AttrTooltipRichText richEditor) { + public static JxUIPane createRichEditorPane(AttrTooltipRichText richEditor) { VanChartRichEditorModel model = getRichEditorModel(richEditor); return createRichEditorPane(model); } - public static ModernUIPane createRichEditorPane(VanChartRichEditorModel model) { + public static JxUIPane createRichEditorPane(VanChartRichEditorModel model) { if (richEditorPane == null) { richEditorPane = initPane(model); } else { @@ -139,50 +137,57 @@ public class VanChartRichEditorPane { } public static void richEditorRefresh(VanChartRichEditorModel model) { - if (richEditorPane != null && browser != null) { - refresh(browser, model); + if (richEditorPane != null && frame != null) { + refresh(frame, model); } } public static void richEditorAddField(VanChartRichEditorModel model) { - if (richEditorPane != null && browser != null) { - addField(browser, model); + if (richEditorPane != null && frame != null) { + addField(frame, model); } } - public static ModernUIPane initPane(VanChartRichEditorModel model) { - BrowserType type = USE_LIGHT_WEIGHT ? BrowserType.LIGHTWEIGHT : BrowserType.HEAVYWEIGHT; - return new ModernUIPane.Builder(type) - .prepare(new ScriptContextAdapter() { - public void onScriptContextCreated(ScriptContextEvent event) { - browser = event.getBrowser(); - browser.getCacheStorage().clearCache(); - - browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); - browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); - browser.executeJavaScript(generateTransformI18nJS()); - browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); - - JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); - ns.asObject().setProperty(VARIABLE, model); + /** + * 初始化富文本编辑器 + * + * @param model 模型 + * @return pane + */ + public static JxUIPane initPane(VanChartRichEditorModel model) { + return new JxUIPane.Builder() + .prepare(params -> { + frame = params.frame(); + frame.browser().engine().httpCache().clear(); + frame.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); + frame.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); + frame.executeJavaScript(generateTransformI18nJS()); + frame.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); + + JsObject ns = frame.executeJavaScript("window." + NAME_SPACE); + if (ns != null) { + ns.putProperty(VARIABLE, model); } + return InjectJsCallback.Response.proceed(); }) .withEMB(RICH_EDITOR_HTML) .namespace(NAME_SPACE).build(); } - public static void refresh(Browser browser, VanChartRichEditorModel model) { - stateChange(browser, model, REFRESH); + private static void refresh(Frame frame, VanChartRichEditorModel model) { + stateChange(frame, model, REFRESH); } - public static void addField(Browser browser, VanChartRichEditorModel model) { - stateChange(browser, model, ADD_FIELD); + private static void addField(Frame frame, VanChartRichEditorModel model) { + stateChange(frame, model, ADD_FIELD); } - public static void stateChange(Browser browser, VanChartRichEditorModel model, String trigger) { - JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); - ns.asObject().setProperty(VARIABLE, model); - browser.executeJavaScript("window." + NAME_SPACE + "." + trigger); + private static void stateChange(Frame frame, VanChartRichEditorModel model, String trigger) { + JsObject ns = frame.executeJavaScript("window." + NAME_SPACE); + if (ns != null) { + ns.putProperty(VARIABLE, model); + frame.executeJavaScript("window." + NAME_SPACE + "." + trigger); + } } public static VanChartRichEditorModel getRichEditorModel(AttrTooltipRichText richText) { @@ -231,9 +236,7 @@ public class VanChartRichEditorPane { } public static void checkDispose() { - if (USE_LIGHT_WEIGHT) { - browser.dispose(); - richEditorPane = null; - } + frame.browser().close(); + richEditorPane = null; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java index 8b3d063960..e4e4745d30 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java @@ -2,8 +2,8 @@ package com.fr.van.chart.designer.component.richText; import com.fr.design.beans.BasicBeanPane; import com.fr.design.i18n.Toolkit; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.stable.StringUtils; @@ -25,7 +25,7 @@ public class VanChartRichTextPane extends BasicBeanPane { private VanChartFieldListPane fieldListPane; private VanChartFieldAttrPane fieldAttrPane; - public VanChartRichTextPane(ModernUIPane richEditor) { + public VanChartRichTextPane(JxUIPane richEditor) { fieldAttrPane = new VanChartFieldAttrPane(); fieldListPane = createFieldListPane(fieldAttrPane, richEditor); @@ -63,7 +63,7 @@ public class VanChartRichTextPane extends BasicBeanPane { return fieldPane; } - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java index 9c7ea0eb7a..6788063310 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java @@ -1,7 +1,7 @@ package com.fr.van.chart.designer.component.tooltip; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; @@ -63,11 +63,11 @@ public class TooltipContentPaneWithOutSeries extends VanChartTooltipContentPane }; } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartFieldListPaneWithOutSeries(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/VanChartFieldListPaneWithOutSeries.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/VanChartFieldListPaneWithOutSeries.java index 7e67886acb..39a4fb9168 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/VanChartFieldListPaneWithOutSeries.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/VanChartFieldListPaneWithOutSeries.java @@ -1,7 +1,7 @@ package com.fr.van.chart.designer.component.tooltip; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipTargetValueFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; @@ -20,7 +20,7 @@ public class VanChartFieldListPaneWithOutSeries extends VanChartFieldListPane { private VanChartFieldButton targetValueButton; - public VanChartFieldListPaneWithOutSeries(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartFieldListPaneWithOutSeries(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java index 55c3e3e78e..3bf8ac7a36 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.funnel.designer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; @@ -49,11 +49,11 @@ public class VanChartFunnelLabelContentPane extends VanChartLabelContentPane { setPercentFormatPane(new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartFunnelRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRichTextFieldListPane.java index c63f112a7c..8ce2521869 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.funnel.designer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; @@ -18,7 +18,7 @@ import java.util.List; public class VanChartFunnelRichTextFieldListPane extends VanChartFieldListPane { - public VanChartFunnelRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartFunnelRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java index e8c741b14c..d23d6ed0d0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.funnel.designer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; @@ -48,11 +48,11 @@ public class VanChartFunnelTooltipContentPane extends VanChartTooltipContentPane setPercentFormatPane(new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartFunnelRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttRichTextFieldListPane.java index 6332c6757a..520250cfd3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.gantt.designer.style.tooltip; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; import com.fr.plugin.chart.base.format.AttrTooltipEndTimeFormat; @@ -28,7 +28,7 @@ public class VanChartGanttRichTextFieldListPane extends VanChartFieldListPane { private VanChartFieldButton richTextDurationFormatPane; private VanChartFieldButton richTextProgressFormatPane; - public VanChartGanttRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartGanttRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java index 6868a0c879..267bbcd79a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.gantt.designer.style.tooltip; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; import com.fr.plugin.chart.base.format.AttrTooltipEndTimeFormat; @@ -66,11 +66,11 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane }; } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartGanttRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java index 91e1817ef5..1e4666d473 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.map.designer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; @@ -14,7 +14,7 @@ import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; public class VanChartMapRichTextFieldListPane extends VanChartFieldListPane { - public VanChartMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java index 680a7e4f24..1afffc8964 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java @@ -3,8 +3,8 @@ package com.fr.van.chart.map.designer.style.label; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.layout.TableLayout; -import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; @@ -50,11 +50,11 @@ public class VanChartMapLabelContentPane extends VanChartLabelContentPane { setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartMapRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java index 718cfc3584..25f0c6acc4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.map.designer.style.tooltip; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; @@ -39,11 +39,11 @@ public class VanChartMapTooltipContentPane extends VanChartTooltipContentPane { setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartMapRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapRichTextFieldListPane.java index 0a1e2bbb6b..cdf3da0d2d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.map.line; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipStartAndEndNameFormat; @@ -14,7 +14,7 @@ import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; public class VanChartLineMapRichTextFieldListPane extends VanChartFieldListPane { - public VanChartLineMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartLineMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java index 04ab53b6a8..1a6b2f8db0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.map.line; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; @@ -36,11 +36,11 @@ public class VanChartLineMapTooltipContentPane extends VanChartTooltipContentPan setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartLineMapRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java index b62655a263..e3ae145f29 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.multilayer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; @@ -36,10 +36,10 @@ public class VanChartMultiPieLabelContentPane extends VanChartLabelContentPane { setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartMultiPieRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieRichTextFieldListPane.java index 2a0aea8194..07b28c77f7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.multilayer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; @@ -14,7 +14,7 @@ import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; public class VanChartMultiPieRichTextFieldListPane extends VanChartFieldListPane { - public VanChartMultiPieRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartMultiPieRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java index 76d536d5bc..dd0f9a891d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.multilayer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; @@ -35,10 +35,10 @@ public class VanChartMultiPieTooltipContentPane extends VanChartTooltipContentPa setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartMultiPieRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java index 5039f53881..d347b40718 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java @@ -1,8 +1,8 @@ package com.fr.van.chart.pie.style; import com.fr.design.i18n.Toolkit; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; -import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; @@ -45,11 +45,11 @@ public class VanChartPieCategoryLabelContentPane extends VanChartLabelContentPan summaryValueFormatPane = new SummaryValueFormatPaneWithCheckBox(parent, showOnPane); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartPieCategoryRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryRichTextFieldListPane.java index 15361b490e..ea3e6ffeed 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.pie.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipSummaryValueFormat; import com.fr.plugin.chart.pie.attr.PieCategoryLabelContent; @@ -19,7 +19,7 @@ public class VanChartPieCategoryRichTextFieldListPane extends VanChartFieldListP private VanChartFieldButton summaryValueButton; - public VanChartPieCategoryRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartPieCategoryRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java index f8c094aa5c..018b86a441 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.pie.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; @@ -43,11 +43,11 @@ public class VanChartPieValueLabelContentPane extends VanChartLabelContentPane { setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartPieValueRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueRichTextFieldListPane.java index 072b3a8012..daa2f73ed4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueRichTextFieldListPane.java @@ -1,6 +1,6 @@ package com.fr.van.chart.pie.style; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; import com.fr.van.chart.designer.component.richText.VanChartFieldButton; import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; @@ -12,7 +12,7 @@ import java.util.List; public class VanChartPieValueRichTextFieldListPane extends VanChartFieldListPane { - public VanChartPieValueRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartPieValueRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java index 776d5397d8..62ec1a430e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.scatter; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipSizeFormat; import com.fr.plugin.chart.base.format.AttrTooltipXFormat; @@ -23,7 +23,7 @@ public class VanChartScatterRichTextFieldListPane extends VanChartFieldListPane private VanChartFieldButton richTextYFormatPane; private VanChartFieldButton richTextSizeFormatPane; - public VanChartScatterRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartScatterRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java index 396edc6fe1..7f1eba4c4f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.scatter; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; @@ -60,11 +60,11 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa sizeFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartScatterRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRichTextFieldListPane.java index 49f81968cf..3586e52f45 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.structure.desinger.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; @@ -18,7 +18,7 @@ import java.util.List; public class VanChartStructureRichTextFieldListPane extends VanChartFieldListPane { - public VanChartStructureRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartStructureRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java index a2cb16308f..c5e1637c08 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java @@ -2,7 +2,7 @@ package com.fr.van.chart.structure.desinger.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; @@ -62,11 +62,11 @@ public class VanChartStructureTooltipContentPane extends VanChartTooltipContentP setPercentFormatPane(percentFormatPane); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartStructureRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java index 3394e6f05b..156b0bddbd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.wordcloud.designer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; @@ -14,7 +14,7 @@ import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; public class VanChartWordCloudRichTextFieldListPane extends VanChartFieldListPane { - public VanChartWordCloudRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + public VanChartWordCloudRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditorPane) { super(fieldAttrPane, richEditorPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java index 0abd60ac1b..7df1b4acc4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java @@ -2,7 +2,7 @@ package com.fr.van.chart.wordcloud.designer.style; import com.fr.design.i18n.Toolkit; -import com.fr.design.ui.ModernUIPane; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; @@ -58,10 +58,10 @@ public class VanChartWordCloudTooltipContentPane extends VanChartTooltipContentP setPercentFormatPane(percentFormatPane); } - protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + protected VanChartRichTextPane createRichTextPane(JxUIPane richEditorPane) { return new VanChartRichTextPane(richEditorPane) { - protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane richEditor) { return new VanChartWordCloudRichTextFieldListPane(fieldAttrPane, richEditor); } diff --git a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html index da8dd5bed1..afbd858e81 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html +++ b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html @@ -3,8 +3,8 @@ - - + + diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java index f9d3849f78..2e8e7ce495 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java @@ -1,19 +1,12 @@ package com.fr.design.mainframe.share.ui.online.mini; +import com.fr.design.jxbrowser.JxUIPane; import com.fr.design.mainframe.share.ui.online.mini.bridge.ComposedNativeBridges; import com.fr.design.mainframe.share.util.OnlineShopUtils; -import com.fr.design.ui.ModernUIPane; -import com.fr.design.ui.compatible.ModernUIPaneFactory; import com.fr.design.upm.event.CertificateEvent; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; -import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; -import com.teamdev.jxbrowser.chromium.JSObject; -import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; -import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; -import com.teamdev.jxbrowser.js.JsObject; -import org.jetbrains.annotations.Nullable; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -24,34 +17,16 @@ import java.awt.BorderLayout; * Created by Starryi on 2021/12/20 */ public class MiniComponentShopPane extends JPanel { - private final ModernUIPane modernUIPane; + private static final String SHOP_HELPER = "ShopHelper"; + private final JxUIPane modernUIPane; private final Listener loginListener; private final Listener logoutListener; public MiniComponentShopPane() { setLayout(new BorderLayout()); - modernUIPane = ModernUIPaneFactory.modernUIPaneBuilder() + modernUIPane = new JxUIPane.Builder<>() .withURL(OnlineShopUtils.getWebMiniShopPath()) - .prepareForV6(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - super.onScriptContextCreated(event); - JSObject window = event.getBrowser().executeJavaScriptAndReturnValue("window").asObject(); - window.setProperty("ShopHelper", new ComposedNativeBridges(window)); - } - }) - .prepareForV7(new InjectJsCallback() { - @Nullable - @Override - public Response on(Params params) { - // 7.x - JsObject window = params.frame().executeJavaScript("window"); - if (window != null) { - window.putProperty("ShopHelper", new ComposedNativeBridges(window)); - } - return InjectJsCallback.Response.proceed(); - } - }) + .buildProperty(SHOP_HELPER, ComposedNativeBridges::new) .build(); add(modernUIPane, BorderLayout.CENTER); From 86d5d100d97663125addb99fa819af74b666b996 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 14 Jun 2023 16:10:15 +0800 Subject: [PATCH 18/56] =?UTF-8?q?REPORT-93559=20api=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/help/FineUIAction.java | 3 +- .../fr/design/dcm/UniversalDatabasePane.java | 2 +- .../com/fr/design/jxbrowser/JxEngine.java | 15 +++++ .../com/fr/design/jxbrowser/JxUIPane.java | 64 ++++++++++++++++--- .../fr/design/login/DesignerLoginPane.java | 2 +- .../design/login/guide/DesignerGuidePane.java | 2 +- .../java/com/fr/design/upm/UpmShowPane.java | 2 +- .../ui/online/mini/MiniComponentShopPane.java | 2 +- 8 files changed, 76 insertions(+), 16 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java index 4436154739..3037322275 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java @@ -29,8 +29,7 @@ public class FineUIAction extends UpdateAction { @Override public void actionPerformed(final ActionEvent e) { JxUIPane pane = new JxUIPane.Builder<>() - .variable("i18n") - .property(new I18n()) + .bindNamespace("i18n", new I18n()) .withComponent(new AssembleComponent() { @Override diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java index 84c5c2f7b3..f195acaca1 100644 --- a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java @@ -21,7 +21,7 @@ public class UniversalDatabasePane extends BasicPane { setLayout(new BorderLayout()); JxUIPane modernUIPane = new JxUIPane.Builder<>() .withComponent(UniversalDatabaseComponent.KEY) - .buildProperty("DcmHelper", UniversalDcmBridge::getBridge) + .bindWindow("DcmHelper", UniversalDcmBridge::getBridge) .build(); add(modernUIPane, BorderLayout.CENTER); } diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java b/designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java index c207b660e5..bb2c1f7375 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java @@ -65,6 +65,9 @@ public class JxEngine { this.parameterMap = parameterMap; } + /** + * 清理map + */ public void clearMap() { this.parameterMap = Collections.emptyMap(); } @@ -77,6 +80,9 @@ public class JxEngine { this.component = component; } + /** + * 清理component + */ public void clearComponent() { this.component = null; } @@ -92,11 +98,20 @@ public class JxEngine { return INSTANCE; } + /** + * 获取公共引擎,公共引擎使用后不用关闭引擎,但需要自己管理 browser。 + * 应用系统管理引擎生命周期 + * + * @return 引擎 + */ @NotNull public Engine getEngine() { return ENGINE.getValue(); } + /** + * 关闭引擎 + */ public void close() { ENGINE.getValue().close(); ENGINE.drop(); diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java index 68dbc9362c..44f81ef3d6 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java @@ -225,6 +225,7 @@ public class JxUIPane extends ModernUIPane { private String variable; private String expression; private InjectJsCallback callback; + private final Map namespacePropertyMap; private final Map propertyMap; private final Map buildPropertyMap; private Object variableProperty; @@ -238,6 +239,7 @@ public class JxUIPane extends ModernUIPane { this.variable = DEFAULT_VARIABLE; this.expression = DEFAULT_EXPRESSION; this.callback = null; + this.namespacePropertyMap = new HashMap<>(); this.propertyMap = new HashMap<>(); this.buildPropertyMap = new HashMap<>(); this.variableProperty = null; @@ -334,6 +336,12 @@ public class JxUIPane extends ModernUIPane { /** * 设置该前端页面做数据交换所使用的对象 + * 相当于: + * const namespace = "Pool"; + * 调用: + * window[namespace]; + * 默认下结构如: + * window.Pool * * @param namespace 对象名 */ @@ -345,6 +353,12 @@ public class JxUIPane extends ModernUIPane { /** * java端往js端传数据时使用的变量名字 * 默认值为 data + * 相当于: + * const variable = "data"; + * 调用: + * window[namespace][variable]; + * 默认下结构如: + * window.Pool.data * * @param name 变量的名字 */ @@ -364,16 +378,19 @@ public class JxUIPane extends ModernUIPane { } /** - * 注入一个java对象到js中,绑定在全局变量 window的 - * property指定的变量。这个方法仅在在加载的网页上执 - * 行 JavaScript 之前注入 + * 注入一个java对象到js中,绑定在全局变量window的指定变量variable。 + * variable 可由 {@link #namespace(String)} 设置,默认值为 data + * 这个方法仅在在加载的网页上执行 JavaScript 之前注入 + * 相当于: + * window[namespace][property] = javaObject + * 默认下: + * window.Pool[property] = javaObject * - * @param property 属性 - * @param obj java对象 + * @param obj java对象 * @return 链式对象 */ - public JxUIPane.Builder property(String property, @Nullable Object obj) { - this.propertyMap.put(property, obj); + public JxUIPane.Builder bindNamespace(String property, @Nullable Object obj) { + this.namespacePropertyMap.put(property, obj); return this; } @@ -381,25 +398,49 @@ public class JxUIPane extends ModernUIPane { * 注入一个java对象到js中,绑定在全局变量window的指定变量variable。 * variable 可由 {@link #variable(String)} 设置,默认值为 data * 这个方法仅在在加载的网页上执行 JavaScript 之前注入 + * 相当于: + * window[namespace][variable] = javaObject + * 默认下: + * window.Pool.data = javaObject * * @param obj java对象 * @return 链式对象 */ - public JxUIPane.Builder property(@NotNull Object obj) { + public JxUIPane.Builder bindVariable(@NotNull Object obj) { this.variableProperty = obj; return this; } + /** + * 注入一个java对象到js中,绑定在全局变量 window的 + * property指定的变量。这个方法仅在在加载的网页上执 + * 行 JavaScript 之前注入 + * 相当于: + * window[property] = javaObject + * + * @param property 属性 + * @param obj java对象 + * @return 链式对象 + * @see #bindWindow(String, PropertyBuild) + */ + public JxUIPane.Builder bindWindow(String property, @Nullable Object obj) { + this.propertyMap.put(property, obj); + return this; + } + /** * 注入一个java对象到js中。绑定在全局变量 window的property指定的变量。 * PropertyBuild用于动态生成绑定属性。个方法仅在在加载的网页上执行 * JavaScript 之前注入 + * 相当于: + * window[property] = javaObject * * @param property 属性构建器 * @param obj java对象 * @return 链式对象 + * @see #bindWindow(String, Object) */ - public JxUIPane.Builder buildProperty(String property, PropertyBuild obj) { + public JxUIPane.Builder bindWindow(String property, PropertyBuild obj) { buildPropertyMap.put(property, obj); return this; } @@ -442,6 +483,11 @@ public class JxUIPane extends ModernUIPane { executeJsObject(frame, WINDOW) .ifPresent(window -> window.putProperty(key, value.build(window)))); } + if (!namespacePropertyMap.isEmpty()) { + namespacePropertyMap.forEach((key, value) -> + executeJsObject(frame, WINDOW + DOT + namespace) + .ifPresent(pool -> pool.putProperty(key, value))); + } if (variableProperty != null) { executeJsObject(frame, WINDOW + DOT + namespace) .ifPresent(pool -> pool.putProperty(variable, variableProperty)); diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java index 830a0a1023..73811c0c83 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java @@ -30,7 +30,7 @@ public class DesignerLoginPane extends BasicPane { params.put("lastLoginAccount", DesignerEnvManager.getEnvManager().getLastLoginAccount()); setLayout(new BorderLayout()); JxUIPane modernUIPane = new JxUIPane.Builder<>() - .buildProperty(DESIGNER_LOGIN_HELPER, window -> DesignerLoginBridge.getBridge(window, params)) + .bindWindow(DESIGNER_LOGIN_HELPER, window -> DesignerLoginBridge.getBridge(window, params)) .withEMB(DesignerLoginHelper.getMainResourcePath(), DesignerLoginUtils.renderMap()) .build(); add(modernUIPane, BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java index 9157b616a7..9e2277b1fb 100644 --- a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java +++ b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java @@ -25,7 +25,7 @@ public class DesignerGuidePane extends BasicPane { public DesignerGuidePane() { setLayout(new BorderLayout()); JxUIPane modernUIPane = new JxUIPane.Builder<>() - .buildProperty(DESIGNER_GUIDE_HELPER, w -> DesignerGuideBridge.getBridge()) + .bindWindow(DESIGNER_GUIDE_HELPER, w -> DesignerGuideBridge.getBridge()) .withEMB(DesignerGuideHelper.getMainResourcePath(), DesignerGuideUtils.renderMap()) .build(); add(modernUIPane, BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java index 83de627c4e..3035835cf1 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java @@ -29,7 +29,7 @@ public class UpmShowPane extends BasicPane { UpmShowPane() { setLayout(new BorderLayout()); jxUIPane = new JxUIPane.Builder<>() - .buildProperty(PLUGIN_HELPER, UpmBridgeV7::getBridge) + .bindWindow(PLUGIN_HELPER, UpmBridgeV7::getBridge) .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) .build(); EventDispatcher.listen(DownloadEvent.UPDATE, new Listener() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java index 2e8e7ce495..ccd13cc4a4 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java @@ -26,7 +26,7 @@ public class MiniComponentShopPane extends JPanel { setLayout(new BorderLayout()); modernUIPane = new JxUIPane.Builder<>() .withURL(OnlineShopUtils.getWebMiniShopPath()) - .buildProperty(SHOP_HELPER, ComposedNativeBridges::new) + .bindWindow(SHOP_HELPER, ComposedNativeBridges::new) .build(); add(modernUIPane, BorderLayout.CENTER); From 833dc98a7f594b206bba0dd5b93df4b5f19290fc Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 15 Jun 2023 10:30:44 +0800 Subject: [PATCH 19/56] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/jxbrowser/MimeType.java | 2 +- .../design/jxbrowser/NxInterceptRequestCallback.java | 2 +- .../com/fr/design/login/DesignerLoginBridge.java | 6 ++++++ .../component/richText/VanChartRichEditorPane.java | 12 ++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java b/designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java index 583340ccf4..602e463803 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java @@ -74,7 +74,7 @@ public enum MimeType { this.mimeType = mimeType; } - public String parseMimeType() { + public String getMimeType() { return mimeType; } diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java index 014c52ff2d..6a578afa6e 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java @@ -113,7 +113,7 @@ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { } private boolean isHtml(String mimeType) { - return MimeType.HTML.parseMimeType().equals(mimeType); + return MimeType.HTML.getMimeType().equals(mimeType); } private Optional generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) { diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java index 1b196bedd1..ad7d180552 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java @@ -55,6 +55,12 @@ public class DesignerLoginBridge { private final Map params; + /** + * 获取 js-java bridge + * + * @param window 全局环境 + * @return bridge + */ public static DesignerLoginBridge getBridge(JsObject window, Map params) { return new DesignerLoginBridge(window, params); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java index de141f8638..4a976ef42d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java @@ -121,11 +121,23 @@ public class VanChartRichEditorPane { fieldNames.addAll(Arrays.asList(columnNames)); } + /** + * 创建富文本编辑器 + * + * @param richEditor 属性 + * @return 富文本编辑器 + */ public static JxUIPane createRichEditorPane(AttrTooltipRichText richEditor) { VanChartRichEditorModel model = getRichEditorModel(richEditor); return createRichEditorPane(model); } + /** + * 创建富文本编辑器 + * + * @param model 模型 + * @return 富文本编辑器 + */ public static JxUIPane createRichEditorPane(VanChartRichEditorModel model) { if (richEditorPane == null) { richEditorPane = initPane(model); 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 20/56] =?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 21/56] =?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 1e1da080d604d90cc62f61dc2c39aa518e5ed330 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 15 Jun 2023 16:13:29 +0800 Subject: [PATCH 22/56] =?UTF-8?q?REPORT-93559=20=E6=8F=90=E5=8D=87jxbrowse?= =?UTF-8?q?r=207.26?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index e0bf79aefe..73aede69a1 100644 --- a/build.gradle +++ b/build.gradle @@ -14,6 +14,7 @@ ext { outputPath = "build" ignoreTestFailureSetting = true languageLevelSetting = 1.8 + jxBrowserVersion = '7.26' } applyGlobalConfigPathIfExist() @@ -66,8 +67,8 @@ allprojects { implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion implementation 'com.install4j:install4j-runtime:8.0.4' implementation 'com.fr.third:jxbrowser:6.23' - implementation 'com.fr.third:jxbrowser-v7:7.22' - implementation 'com.fr.third:jxbrowser-swing-v7:7.22' + implementation "com.fr.third:jxbrowser-v7:${jxBrowserVersion}" + implementation "com.fr.third:jxbrowser-swing-v7:${jxBrowserVersion}" implementation 'com.fr.third.server:servlet-api:3.0' implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swag:1.0' @@ -95,12 +96,11 @@ allprojects { if (OperatingSystem.current().isMacOsX()) { dependencies { implementation 'com.fr.third:jxbrowser-mac:6.23' - implementation 'com.fr.third:jxbrowser-mac-v7:7.22' + implementation "com.fr.third:jxbrowser-mac-v7:${jxBrowserVersion}" } } else if (OperatingSystem.current().isWindows()) { dependencies { - implementation 'com.fr.third:jxbrowser-win64:6.23' - implementation 'com.fr.third:jxbrowser-win64-v7:7.22' + implementation "com.fr.third:jxbrowser-win64-v7:${jxBrowserVersion}" } } } From b5518abfb66cfcf1e6a06b9e8032b23643ad38b1 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 16 Jun 2023 17:47:29 +0800 Subject: [PATCH 23/56] =?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 24/56] =?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 25/56] =?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 26/56] =?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 27/56] =?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 28/56] =?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 07361237d8467de77e3d2c86046090433f041b92 Mon Sep 17 00:00:00 2001 From: "Levy.Xie" Date: Mon, 19 Jun 2023 17:04:07 +0800 Subject: [PATCH 29/56] =?UTF-8?q?REPORT-94637=20=E5=8D=95=E6=B5=8B?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../com/fr/design/formula/FormulaPaneTest.java | 2 +- .../design/formula/FunctionConstantsTest.java | 12 +++++++++++- .../icombocheckbox/UICheckListPopupTest.java | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 73aede69a1..68e9681694 100644 --- a/build.gradle +++ b/build.gradle @@ -90,6 +90,7 @@ allprojects { testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-api-easymock:1.7.1' + testImplementation 'org.powermock:powermock-api-mockito2:1.7.4' testImplementation 'junit:junit:4.12' } diff --git a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java index 4ac71b5ac0..d804ec532b 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java @@ -17,7 +17,7 @@ public class FormulaPaneTest extends TestCase { @Test public void testSimilarComparator() { String[] strs = new String[] {"ScriptEval", "SPLIT", "SUMPRECISE"}; - String[] result = new String[] {"SPLIT", "ScriptEval", "SUMPRECISE"}; + String[] result = new String[] {"SPLIT", "SUMPRECISE", "ScriptEval",}; Arrays.sort(strs, new FormulaPane.SimilarComparator("sp")); Assert.assertArrayEquals(result, strs); } diff --git a/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java b/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java index b53d47780c..1c00f5bdc1 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java @@ -1,12 +1,16 @@ package com.fr.design.formula; +import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; import org.easymock.EasyMock; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.powermock.api.easymock.PowerMock; +import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -19,9 +23,15 @@ import static org.junit.Assert.fail; * Created by plough on 2018/12/7. */ @RunWith(PowerMockRunner.class) -@PrepareForTest(GeneralUtils.class) +@PrepareForTest({GeneralUtils.class, Toolkit.class}) public class FunctionConstantsTest { + @Before + public void setUp() { + PowerMockito.mockStatic(Toolkit.class); + PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test"); + } + @Test public void testNewInstanceFail() throws Exception { try { diff --git a/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java b/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java index 33a98e078d..a35055c2fd 100644 --- a/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java +++ b/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java @@ -1,8 +1,16 @@ package com.fr.design.gui.icombocheckbox; +import com.fr.design.i18n.Toolkit; import junit.framework.TestCase; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.util.ArrayList; import java.util.List; @@ -14,8 +22,17 @@ import java.util.TreeMap; * @version 10.0 * Created by hades on 2020/4/3 */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(Toolkit.class) +@PowerMockIgnore("javax.swing.*") public class UICheckListPopupTest extends TestCase { + @Before + public void setUp() { + PowerMockito.mockStatic(Toolkit.class); + PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test"); + } + @Test public void testGetSelectedValues() { Object[] values = new Object[]{"a", "b", "c"}; From d545ba2b7d7b22d2d7f1a9344731c69d3cb90e84 Mon Sep 17 00:00:00 2001 From: "Levy.Xie" Date: Mon, 19 Jun 2023 17:05:23 +0800 Subject: [PATCH 30/56] =?UTF-8?q?REPORT-94637=20=E5=8D=95=E6=B5=8B?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/java/com/fr/design/formula/FormulaPaneTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java index d804ec532b..c6a646bbc7 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java @@ -16,8 +16,8 @@ public class FormulaPaneTest extends TestCase { @Test public void testSimilarComparator() { - String[] strs = new String[] {"ScriptEval", "SPLIT", "SUMPRECISE"}; - String[] result = new String[] {"SPLIT", "SUMPRECISE", "ScriptEval",}; + String[] strs = new String[]{"ScriptEval", "SPLIT", "SUMPRECISE"}; + String[] result = new String[]{"SPLIT", "SUMPRECISE", "ScriptEval"}; Arrays.sort(strs, new FormulaPane.SimilarComparator("sp")); Assert.assertArrayEquals(result, strs); } From dfc5d0bd98ee5756468cd35290150096072be2dc Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 19 Jun 2023 19:26:51 +0800 Subject: [PATCH 31/56] =?UTF-8?q?REPORT-93559=20=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=8F=92=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../com/fr/design/jxbrowser/JxUIPane.java | 38 +++++++++++++++- .../java/com/fr/design/ui/ModernUIPane.java | 21 ++++++++- .../fr/design/ui/compatible/BuilderDiff.java | 30 +++++++++++++ .../ui/compatible/ModernUIPaneFactory.java | 45 +++++++++++++++++++ 5 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java create mode 100644 designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java diff --git a/build.gradle b/build.gradle index 73aede69a1..a0599e7549 100644 --- a/build.gradle +++ b/build.gradle @@ -100,6 +100,7 @@ allprojects { } } else if (OperatingSystem.current().isWindows()) { dependencies { + implementation 'com.fr.third:jxbrowser-win64:6.23' implementation "com.fr.third:jxbrowser-win64-v7:${jxBrowserVersion}" } } diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java index 44f81ef3d6..1a968551df 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java @@ -7,9 +7,13 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.ui.ModernUIConstants; import com.fr.design.ui.ModernUIPane; import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; import com.fr.web.struct.AssembleComponent; import com.teamdev.jxbrowser.browser.Browser; import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; +import com.teamdev.jxbrowser.chromium.events.LoadListener; +import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; +import com.teamdev.jxbrowser.event.Observer; import com.teamdev.jxbrowser.frame.Frame; import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.view.swing.BrowserView; @@ -20,6 +24,7 @@ import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Optional; import static com.fr.design.ui.ModernUIConstants.COMPONENT_TAG; @@ -220,13 +225,16 @@ public class JxUIPane extends ModernUIPane { * * @param 参数 */ - public static class Builder { + public static class Builder extends ModernUIPane.Builder { private String namespace; private String variable; private String expression; private InjectJsCallback callback; + + private Pair listenerPair; private final Map namespacePropertyMap; private final Map propertyMap; + private final Map buildPropertyMap; private Object variableProperty; private Map parameterMap; @@ -239,6 +247,7 @@ public class JxUIPane extends ModernUIPane { this.variable = DEFAULT_VARIABLE; this.expression = DEFAULT_EXPRESSION; this.callback = null; + this.listenerPair = null; this.namespacePropertyMap = new HashMap<>(); this.propertyMap = new HashMap<>(); this.buildPropertyMap = new HashMap<>(); @@ -255,11 +264,33 @@ public class JxUIPane extends ModernUIPane { * @param callback 回调 * @return builder */ - public JxUIPane.Builder prepare(InjectJsCallback callback) { + public Builder prepare(InjectJsCallback callback) { this.callback = callback; return this; } + @Override + public Builder prepareForV6(ScriptContextListener contextListener) { + return this; + } + + @Override + public Builder prepareForV6(LoadListener loadListener) { + return this; + } + + @Override + public JxUIPane.Builder prepareForV7(InjectJsCallback callback) { + prepare(callback); + return this; + } + + @Override + public JxUIPane.Builder prepareForV7(Class event, Observer listener) { + listenerPair = new Pair<>(event, listener); + return this; + } + /** * 加载jar包中的资源 * @@ -457,6 +488,9 @@ public class JxUIPane extends ModernUIPane { pane.setComponent(component); pane.initialize(); injectJs(pane); + if (!Objects.isNull(listenerPair)) { + pane.browser.navigation().on(listenerPair.getFirst(), listenerPair.getSecond()); + } if (StringUtils.isNotEmpty(this.url)) { pane.browser.navigation().loadUrl(this.url); } else if (StringUtils.isNotEmpty(this.html)) { diff --git a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java index 69c7a81ab3..f3aceb8476 100644 --- a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java +++ b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java @@ -5,8 +5,10 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.compatible.BuilderDiff; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.web.struct.AssembleComponent; +import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.BrowserType; import com.teamdev.jxbrowser.chromium.JSValue; @@ -15,6 +17,7 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; import com.teamdev.jxbrowser.chromium.swing.BrowserView; +import com.teamdev.jxbrowser.event.Observer; import javax.swing.JDialog; import javax.swing.SwingUtilities; @@ -31,7 +34,7 @@ import java.util.Map; * @version 10.0 * Created by richie on 2019-03-04 * 用于加载html5的Swing容器,可以在设计选项设置中打开调试窗口,示例可查看:com.fr.design.ui.ModernUIPaneTest - * @see com.fr.design.jxbrowser.JxUIPane + * @see {@link com.fr.design.jxbrowser.JxUIPane} * @deprecated 主要用于jxbrowser6,将在下个版本删除 */ @Deprecated @@ -199,7 +202,7 @@ public class ModernUIPane extends BasicPane { * * @param */ - public static class Builder { + public static class Builder implements BuilderDiff { private ModernUIPane pane; @@ -332,14 +335,28 @@ public class ModernUIPane extends BasicPane { return this; } + @Override public Builder prepareForV6(ScriptContextListener contextListener) { return prepare(contextListener); } + @Override public Builder prepareForV6(LoadListener loadListener) { return prepare(loadListener); } + @Override + public Builder prepareForV7(InjectJsCallback callback) { + // do nothing + return this; + } + + @Override + public Builder prepareForV7(Class event, Observer listener) { + // do nothing + return this; + } + public ModernUIPane build() { return pane; } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java b/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java new file mode 100644 index 0000000000..483257e9b3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java @@ -0,0 +1,30 @@ +package com.fr.design.ui.compatible; + +import com.fr.design.jxbrowser.JxUIPane; +import com.fr.design.ui.ModernUIPane; +import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; +import com.teamdev.jxbrowser.chromium.events.LoadListener; +import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; +import com.teamdev.jxbrowser.event.Observer; + +/** + * 封装jxbrwoser v6/v7的构建方式的差异 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/6/13 + * @see {@link JxUIPane} + * @deprecated 6在下个版本弃用 + */ +@Deprecated +public interface BuilderDiff { + + ModernUIPane.Builder prepareForV6(ScriptContextListener contextListener); + + ModernUIPane.Builder prepareForV6(LoadListener loadListener); + + ModernUIPane.Builder prepareForV7(InjectJsCallback callback); + + ModernUIPane.Builder prepareForV7(Class event, Observer listener); + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java new file mode 100644 index 0000000000..f6e29e81c5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java @@ -0,0 +1,45 @@ +package com.fr.design.ui.compatible; + +import com.fr.design.jxbrowser.JxUIPane; +import com.fr.design.ui.ModernUIPane; + +/** + * 根据版本选择构造器 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/6/13 + * @see {@link JxUIPane} + * @deprecated 6在下个版本弃用 + */ +public class ModernUIPaneFactory { + + /** + * 获取一个 JxBrowser pane 的构造器 + * + * @param 参数 + * @return 构造器 + */ + public static ModernUIPane.Builder modernUIPaneBuilder() { + if (isV7()) { + return new JxUIPane.Builder<>(); + } else { + return new ModernUIPane.Builder<>(); + } + } + + /** + * 判断 JxBrowser 版本是否在7或之上 + * + * @return 是否7或之上 + */ + public static boolean isV7() { + boolean hasJxBrowserV7 = true; + try { + Class.forName("com.teamdev.jxbrowser.net.Scheme"); + } catch (ClassNotFoundException e) { + hasJxBrowserV7 = false; + } + return hasJxBrowserV7; + } +} From 08cf5012c634b51e7366a809acea1e120b6f8fdf Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 19 Jun 2023 19:35:32 +0800 Subject: [PATCH 32/56] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ui/compatible/BuilderDiff.java | 31 +++++++++++++++++-- .../ui/compatible/ModernUIPaneFactory.java | 10 +++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java b/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java index 483257e9b3..99daa4555a 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java @@ -11,20 +11,45 @@ import com.teamdev.jxbrowser.event.Observer; * 封装jxbrwoser v6/v7的构建方式的差异 * * @author hades - * @version 10.0 - * Created by hades on 2021/6/13 * @see {@link JxUIPane} + * @since 10.0 + * Created on 2021/6/13 * @deprecated 6在下个版本弃用 */ @Deprecated public interface BuilderDiff { + /** + * v6准备工作 + * + * @param contextListener 上下文监听器 + * @return 构造器 + */ ModernUIPane.Builder prepareForV6(ScriptContextListener contextListener); + /** + * v6准备工作 + * + * @param loadListener 加载监听器 + * @return 构造器 + */ ModernUIPane.Builder prepareForV6(LoadListener loadListener); + /** + * v7准备工作 + * + * @param callback 注入js回调器 + * @return 构造器 + */ ModernUIPane.Builder prepareForV7(InjectJsCallback callback); + /** + * v7准备工作 + * + * @param event 事件 + * @param listener 监听器 + * @return 构造器 + */ ModernUIPane.Builder prepareForV7(Class event, Observer listener); -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java index f6e29e81c5..31774e90c9 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java @@ -7,9 +7,9 @@ import com.fr.design.ui.ModernUIPane; * 根据版本选择构造器 * * @author hades - * @version 10.0 - * Created by hades on 2021/6/13 * @see {@link JxUIPane} + * @since 10.0 + * Created on 2021/6/13 * @deprecated 6在下个版本弃用 */ public class ModernUIPaneFactory { @@ -34,12 +34,12 @@ public class ModernUIPaneFactory { * @return 是否7或之上 */ public static boolean isV7() { - boolean hasJxBrowserV7 = true; + boolean jxBrowserV7 = true; try { Class.forName("com.teamdev.jxbrowser.net.Scheme"); } catch (ClassNotFoundException e) { - hasJxBrowserV7 = false; + jxBrowserV7 = false; } - return hasJxBrowserV7; + return jxBrowserV7; } } From f95f54514a34e6bd0ebd6c56b70601456f09f839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Tue, 20 Jun 2023 13:58:21 +0800 Subject: [PATCH 33/56] =?UTF-8?q?REPORT-94637=20=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BF=AE=E5=A4=8D=20=E3=80=90=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91com.fr.design=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=8D=95=E6=B5=8B=E4=BF=AE=E5=A4=8D=20=E3=80=90?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E8=AF=A6=E8=A7=81?= =?UTF-8?q?https://kms.fineres.com/pages/viewpage.action=3FpageId=3D742496?= =?UTF-8?q?063=20=E3=80=90review=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/help/TutorialActionTest.java | 20 +++ .../base/clipboard/DesignerClipboardTest.java | 12 +- .../data/DesignTableDataManagerTest.java | 17 +-- .../datapane/TableDataPaneListPaneTest.java | 20 ++- .../TableDataFollowingPasteUtilsTest.java | 6 +- .../toolbar/ToolBarMenuDockTest.java | 128 ++++++++++++------ 6 files changed, 146 insertions(+), 57 deletions(-) diff --git a/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java b/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java index dc1e871b4b..5ae51d380f 100644 --- a/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java +++ b/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java @@ -1,14 +1,34 @@ package com.fr.design.actions.help; +import com.fr.base.svg.SystemScaleUtils; +import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralContext; import com.fr.stable.ProductConstants; import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.util.Locale; import java.util.UUID; +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({"javax.management.*","javax.net.ssl.*"}) +@PrepareForTest({Toolkit.class, SystemScaleUtils.class}) public class TutorialActionTest extends TestCase { + public void setUp() { + PowerMock.mockStatic(Toolkit.class); + EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); + PowerMock.mockStatic(SystemScaleUtils.class); + EasyMock.expect(SystemScaleUtils.sysScale()).andReturn(1F).anyTimes(); + EasyMock.expect(SystemScaleUtils.isJreHiDPIEnabled()).andReturn(false).anyTimes(); + PowerMock.replayAll(); + } + public void testCreateKey() { TutorialAction action = new TutorialAction(); GeneralContext.setLocale(Locale.US); diff --git a/designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java b/designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java index 36cdc54f04..bc4a11d6a9 100644 --- a/designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java +++ b/designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java @@ -1,5 +1,6 @@ package com.fr.design.base.clipboard; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.ClipboardHandlerProvider; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.dnd.ArrayListTransferable; @@ -41,11 +42,20 @@ public class DesignerClipboardTest { .andReturn(providers) .anyTimes(); EasyMock.replay(formClassManager); + + ExtraDesignClassManager designClassManager = EasyMock.mock(ExtraDesignClassManager.class); + EasyMock.expect(designClassManager.getArray(ClipboardHandlerProvider.XML_TAG)) + .andReturn(providers) + .anyTimes(); + EasyMock.replay(designClassManager); PowerMock.mockStatic(PluginModule.class); EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraForm)) .andReturn(formClassManager) .anyTimes(); + EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraDesign)) + .andReturn(designClassManager) + .anyTimes(); PowerMock.replayAll(); } @@ -72,4 +82,4 @@ public class DesignerClipboardTest { Assert.assertEquals(transferData.get(0), transferData2.get(0)); } -} \ No newline at end of file +} diff --git a/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java index 1a23555f61..3b3f8cad8e 100644 --- a/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java @@ -141,18 +141,15 @@ public class DesignTableDataManagerTest { } @Test - public void testAddDsColumnNames() { - DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"}); - Map> map = Reflect.on(DesignTableDataManager.class).field( - "columnCache").get(); - Assert.assertEquals(new String[]{"a", "b", "c"}, map.get(null).get("ds1")); - } - - @Test - public void testGetDsColumnNames() { - Assert.assertTrue(ArrayUtils.isEmpty(DesignTableDataManager.getDsColumnNames("ds1"))); + public void testOperateDsColumnNames() { String[] columnNames = new String[]{"a", "b", "c"}; + Assert.assertTrue(ArrayUtils.isEmpty(DesignTableDataManager.getDsColumnNames("ds1"))); + // 测试Add DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"}); + // 测试Get Assert.assertEquals(columnNames, DesignTableDataManager.getDsColumnNames("ds1")); + // 测试Remove + DesignTableDataManager.removeSelectedColumnNames("ds1"); + Assert.assertTrue(ArrayUtils.isEmpty(DesignTableDataManager.getDsColumnNames("ds1"))); } } diff --git a/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java b/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java index dd5e5bc5ce..48b11be333 100644 --- a/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java +++ b/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java @@ -1,6 +1,14 @@ package com.fr.design.data.datapane; +import com.fr.design.i18n.Toolkit; +import org.easymock.EasyMock; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.util.Map; @@ -11,8 +19,18 @@ import static org.junit.Assert.*; * @version 10.0 * Created by Yyming on 2020/9/29 */ +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({"javax.management.*", "javax.swing.*"}) +@PrepareForTest(Toolkit.class) public class TableDataPaneListPaneTest { + @Before + public void setUp() { + PowerMock.mockStatic(Toolkit.class); + EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); + PowerMock.replayAll(); + } + @Test public void rename() { TableDataPaneListPane listPane = new TableDataPaneListPane(); @@ -23,4 +41,4 @@ public class TableDataPaneListPaneTest { listPane.rename("333","111"); assertEquals(0, dsNameChangedMap.size()); } -} \ No newline at end of file +} diff --git a/designer-base/src/test/java/com/fr/design/data/tabledata/paste/TableDataFollowingPasteUtilsTest.java b/designer-base/src/test/java/com/fr/design/data/tabledata/paste/TableDataFollowingPasteUtilsTest.java index 2435f363fc..b82857c98e 100644 --- a/designer-base/src/test/java/com/fr/design/data/tabledata/paste/TableDataFollowingPasteUtilsTest.java +++ b/designer-base/src/test/java/com/fr/design/data/tabledata/paste/TableDataFollowingPasteUtilsTest.java @@ -62,6 +62,7 @@ public class TableDataFollowingPasteUtilsTest extends TestCase { PowerMock.mockStatic(DesignTableDataManager.class); EasyMock.expect(DesignTableDataManager.getEditingTableDataSource()).andReturn(tableDataSource).anyTimes(); EasyMock.expect(DesignTableDataManager.getEditingDataSet(tableDataSource)).andReturn(list).anyTimes(); + EasyMock.expect(DesignTableDataManager.getAllDataSetIncludingProcedure(templateDataMap)).andReturn(templateDataMap).anyTimes(); PowerMock.replayAll(); } @@ -107,6 +108,7 @@ public class TableDataFollowingPasteUtilsTest extends TestCase { set.add("ds3"); MockWidget widget1 = EasyMock.mock(MockWidget.class); EasyMock.expect(widget1.getUsedTableDataSets()).andReturn(set).anyTimes(); + EasyMock.expect(widget1.getChartCollections()).andReturn(new ArrayList<>()).anyTimes(); EasyMock.replay(widget1); DataBinding dataBinding = new DataBinding("ds4", ""); @@ -114,6 +116,7 @@ public class TableDataFollowingPasteUtilsTest extends TestCase { widgetValue2.setValue(dataBinding); AbstractDataControl widget2 = EasyMock.mock(AbstractDataControl.class); EasyMock.expect(widget2.getWidgetValue()).andReturn(widgetValue2).anyTimes(); + EasyMock.expect(widget2.getChartCollections()).andReturn(new ArrayList<>()).anyTimes(); EasyMock.replay(widget2); DataTableConfig dataTableConfig = EasyMock.mock(DataTableConfig.class); @@ -122,6 +125,7 @@ public class TableDataFollowingPasteUtilsTest extends TestCase { widgetValue3.setValue(dataTableConfig); AbstractDataControl widget3 = EasyMock.mock(AbstractDataControl.class); EasyMock.expect(widget3.getWidgetValue()).andReturn(widgetValue3).anyTimes(); + EasyMock.expect(widget3.getChartCollections()).andReturn(new ArrayList<>()).anyTimes(); EasyMock.replay(dataTableConfig, widget3); Widget[] widgets = new Widget[3]; @@ -198,4 +202,4 @@ public class TableDataFollowingPasteUtilsTest extends TestCase { return new String[0]; } } -} \ No newline at end of file +} diff --git a/designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java b/designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java index c5f9f0a700..a198dace8f 100644 --- a/designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java +++ b/designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java @@ -1,30 +1,35 @@ package com.fr.design.mainfarme.toolbar; +import java.util.HashMap; import java.util.Locale; +import com.fr.base.svg.SystemScaleUtils; import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.community.TechSupportAction; import com.fr.design.actions.community.VideoAction; import com.fr.design.actions.help.AboutAction; -import com.fr.design.actions.help.FineUIAction; import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.help.alphafine.AlphaFineAction; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.platform.ServicePlatformAction; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.update.actions.SoftwareUpdateAction; +import com.fr.env.detect.ui.EnvDetectorAction; import com.fr.general.GeneralContext; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import org.easymock.EasyMock; -import org.easymock.Mock; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; @@ -42,66 +47,99 @@ import org.powermock.reflect.Whitebox; Locale.class, WorkContext.class, DesignerEnvManager.class, + Toolkit.class, + SystemScaleUtils.class, AlphaFineConfigManager.class}) +@PowerMockIgnore({"javax.management.*"}) public class ToolBarMenuDockTest { - @Mock - VideoAction videoAction; - @Mock - TutorialAction tutorialAction; - @Mock - WebDemoAction webDemoAction; - @Mock - SoftwareUpdateAction softwareUpdateAction; - @Mock - AlphaFineAction alphaFineAction; - @Mock - FineUIAction fineUIAction; - @Mock - AboutAction aboutAction; - @Before public void testCreateHelpShortCutsBefore() { - try { - PowerMock.expectNew(VideoAction.class).andReturn(videoAction).anyTimes(); - PowerMock.expectNew(TutorialAction.class).andReturn(tutorialAction).anyTimes(); - PowerMock.expectNew(WebDemoAction.class).andReturn(webDemoAction).anyTimes(); - PowerMock.expectNew(SoftwareUpdateAction.class).andReturn(softwareUpdateAction).anyTimes(); - PowerMock.expectNew(AlphaFineAction.class).andReturn(alphaFineAction).anyTimes(); - PowerMock.expectNew(FineUIAction.class).andReturn(fineUIAction).anyTimes(); - PowerMock.expectNew(AboutAction.class).andReturn(aboutAction).anyTimes(); - } catch (Exception e) { - Assert.fail(e.getMessage()); - } + PowerMock.mockStatic(Toolkit.class); + EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); + PowerMock.mockStatic(SystemScaleUtils.class); + EasyMock.expect(SystemScaleUtils.sysScale()).andReturn(1F).anyTimes(); + EasyMock.expect(SystemScaleUtils.isJreHiDPIEnabled()).andReturn(false).anyTimes(); + PowerMock.replay(); } @Test - public void testCreateHelpShortCuts() { + public void testCreateHelpShortCutsWithLocaleChina() { // 处理判断条件 GeneralContext context = EasyMock.createMock(GeneralContext.class); PowerMock.mockStatic(GeneralContext.class); - EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.CHINA).once(); - EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.US).once(); + EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.CHINA).anyTimes(); + Workspace workspace = EasyMock.createMock(Workspace.class); PowerMock.mockStatic(WorkContext.class); EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); - - EasyMock.expect(workspace.isLocal()).andReturn(false).once(); - EasyMock.expect(workspace.isLocal()).andReturn(true).once(); + EasyMock.expect(workspace.isLocal()).andReturn(true).anyTimes(); DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class); PowerMock.mockStatic(DesignerEnvManager.class); EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes(); + EasyMock.expect(envManager.isOpenDebug()).andReturn(true).anyTimes(); + + AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class); + PowerMock.mockStatic(AlphaFineConfigManager.class); + EasyMock.expect(AlphaFineConfigManager.getInstance()).andReturn(configManager).anyTimes(); + EasyMock.expect(configManager.isALPHALicAvailable()).andReturn(true).anyTimes(); + EasyMock.expect(configManager.getActionSearchTextCache()).andReturn(new HashMap<>()).anyTimes(); + EasyMock.expect(configManager.getCacheBuildNO()).andReturn("").anyTimes(); + + SupportOSImpl osImpl = EasyMock.createMock(SupportOSImpl.class); + Whitebox.setInternalState(SupportOSImpl.class, "FINEUI", osImpl); + EasyMock.expect(osImpl.support()).andReturn(false).anyTimes(); + + EasyMock.replay(context, workspace, envManager, configManager, osImpl); + PowerMock.replayAll(); + + ToolBarMenuDock menuDock = new ToolBarMenuDock() { + @Override + public ShortCut[] createNewFileShortCuts() { + return new ShortCut[0]; + } + }; + + ShortCut[] shortCuts = new ShortCut[] { + new WebDemoAction(), + new SoftwareUpdateAction(), + new AlphaFineAction(), + new EnvDetectorAction(), + new ServicePlatformAction(), + SeparatorDef.DEFAULT, + new AboutAction()}; + Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts); + + } + + @Test + public void testCreateHelpShortCutsWithLocaleUS() { + + // 处理判断条件 + GeneralContext context = EasyMock.createMock(GeneralContext.class); + PowerMock.mockStatic(GeneralContext.class); + EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.US).anyTimes(); - EasyMock.expect(envManager.isOpenDebug()).andReturn(false).once(); - EasyMock.expect(envManager.isOpenDebug()).andReturn(true).once(); + + Workspace workspace = EasyMock.createMock(Workspace.class); + PowerMock.mockStatic(WorkContext.class); + EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); + EasyMock.expect(workspace.isLocal()).andReturn(false).anyTimes(); + + DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class); + PowerMock.mockStatic(DesignerEnvManager.class); + EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes(); + EasyMock.expect(envManager.isOpenDebug()).andReturn(false).anyTimes(); AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class); PowerMock.mockStatic(AlphaFineConfigManager.class); - EasyMock.expect(AlphaFineConfigManager.isALPHALicAvailable()).andReturn(false).once(); - EasyMock.expect(AlphaFineConfigManager.isALPHALicAvailable()).andReturn(true).once(); + EasyMock.expect(configManager.isALPHALicAvailable()).andReturn(false).anyTimes(); + EasyMock.expect(configManager.getActionSearchTextCache()).andReturn(new HashMap<>()).anyTimes(); + EasyMock.expect(configManager.getCacheBuildNO()).andReturn("").anyTimes(); + EasyMock.expect(AlphaFineConfigManager.getInstance()).andReturn(configManager).anyTimes(); SupportOSImpl osImpl = EasyMock.createMock(SupportOSImpl.class); Whitebox.setInternalState(SupportOSImpl.class, "FINEUI", osImpl); @@ -118,12 +156,14 @@ public class ToolBarMenuDockTest { } }; - ShortCut[] shortCuts1 = new ShortCut[] {SeparatorDef.DEFAULT, aboutAction}; - ShortCut[] shortCuts2 = new ShortCut[] {videoAction, tutorialAction, webDemoAction, - softwareUpdateAction, alphaFineAction, SeparatorDef.DEFAULT, aboutAction}; - - Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts1); - Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts2); + ShortCut[] shortCuts = new ShortCut[] { + new VideoAction(), + new TutorialAction(), + new TechSupportAction(), + new EnvDetectorAction(), + SeparatorDef.DEFAULT, + new AboutAction()}; + Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts); } } From b8f7eda1b0fbc2bb30f0281d6b4a6abcf6b788b3 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 20 Jun 2023 15:12:41 +0800 Subject: [PATCH 34/56] =?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(); } } From f125fc19a680393dbd205874ee810d6b475c90e5 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Wed, 21 Jun 2023 16:23:33 +0800 Subject: [PATCH 35/56] =?UTF-8?q?=20REPORT-97334=20=E5=8D=95=E6=B5=8B?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20com.fr.design.*=20=20=E3=80=90=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E8=A7=81=20https://kms.fin?= =?UTF-8?q?eres.com/pages/viewpage.action=3FpageId=3D743611693=20=20?= =?UTF-8?q?=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E5=90=8C?= =?UTF-8?q?=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/cell/model/ModelTest.java | 18 ++++++++++++++++++ .../manager/impl/FileSearchManagerTest.java | 17 +++++++---------- .../manager/impl/PluginSearchManagerTest.java | 2 +- .../search/manager/impl/SearchManegerTest.java | 18 ++++++++++++++++++ 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java index 8c62b827ee..26cfc71684 100644 --- a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java @@ -1,13 +1,31 @@ package com.fr.design.mainframe.alphafine.cell.model; import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.alphafine.CellType; import com.fr.json.JSONException; import com.fr.json.JSONObject; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +@RunWith(PowerMockRunner.class) +@PrepareForTest(Toolkit.class) +@PowerMockIgnore("javax.swing.*") public class ModelTest { + + @Before + public void setUp() { + PowerMockito.mockStatic(Toolkit.class); + PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test"); + } + @Test public void documentModelTest() { DocumentModel documentModel = new DocumentModel("name", "content", 1); diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java index 093fb533c7..9532db674b 100644 --- a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java @@ -1,7 +1,5 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; -import com.fr.base.FRContext; -import com.fr.base.extension.FileExtension; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.mainframe.alphafine.AlphaFineHelper; @@ -9,9 +7,6 @@ import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.file.filetree.FileNode; import com.fr.invoke.Reflect; -import com.fr.stable.project.ProjectConstants; -import com.fr.web.core.SessionPoolManager; -import com.fr.web.utils.WebUtils; import org.easymock.EasyMock; import org.junit.Test; import org.junit.runner.RunWith; @@ -23,7 +18,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * @author Yyming @@ -43,8 +38,8 @@ public class FileSearchManagerTest { FileNode fileNode2 = EasyMock.createMock(FileNode.class); EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes(); EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes(); - EasyMock.expect(fileNode1.getEnvPath()).andReturn("").anyTimes(); - EasyMock.expect(fileNode2.getEnvPath()).andReturn("").anyTimes(); + EasyMock.expect(fileNode1.getEnvPath()).andReturn("t1").anyTimes(); + EasyMock.expect(fileNode2.getEnvPath()).andReturn("t2").anyTimes(); EasyMock.replay(fileNode1,fileNode2); FileNode[] fileNodes = { fileNode1, fileNode2 }; Reflect.on(instance).set("fileNodes",fileNodes); @@ -65,8 +60,10 @@ public class FileSearchManagerTest { PowerMock.mockStatic(AlphaFineHelper.class); AlphaFineHelper.getFilterResult(); PowerMock.expectLastCall().andReturn(list).anyTimes(); - AlphaFineHelper.findFolderName(""); - PowerMock.expectLastCall().andReturn("").anyTimes(); + AlphaFineHelper.findFolderName("t1"); + PowerMock.expectLastCall().andReturn("t1").anyTimes(); + AlphaFineHelper.findFolderName("t2"); + PowerMock.expectLastCall().andReturn("t2").anyTimes(); AlphaFineHelper.checkCancel(); PowerMock.expectLastCall().andVoid().anyTimes(); PowerMock.replay(AlphaFineHelper.class); diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java index f4c9c1b7a2..7b97ee9f92 100644 --- a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java @@ -19,7 +19,7 @@ public class PluginSearchManagerTest { Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9.0").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9~").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "10").get()); - Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get()); + Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get()); } } diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java index 1b6236f98e..b0fff198f6 100644 --- a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java @@ -1,13 +1,26 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.toolbar.UpdateActionManager; import com.fr.json.JSONObject; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import java.util.ArrayList; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(Toolkit.class) +@PowerMockIgnore("javax.swing.*") public class SearchManegerTest { SimilarSearchManager similarSearchManager; ComplementAdviceManager complementAdviceManager; @@ -21,6 +34,11 @@ public class SearchManegerTest { @Before public void setUp() { + UpdateActionManager.getUpdateActionManager().setUpdateActions(new ArrayList<>()); + + PowerMockito.mockStatic(Toolkit.class); + PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test"); + recentSearchManager = RecentSearchManager.getInstance(); recommendSearchManager = RecommendSearchManager.getInstance(); similarSearchManager = SimilarSearchManager.getInstance(); From 245d66c6cbad8e32bb9d908e7ce087f388ff9393 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Wed, 21 Jun 2023 17:26:06 +0800 Subject: [PATCH 36/56] =?UTF-8?q?REPORT-98450=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E4=BC=9A=E5=BD=B1=E5=93=8D=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=E3=80=91=E5=AE=9E=E9=99=85=E4=BF=AE=E6=94=B9=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9C=AA=E8=80=83=E8=99=91=E5=88=B0style=E6=98=AF=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E5=AD=97=E4=BD=93=E3=80=81=E8=83=8C=E6=99=AF=E7=AD=89?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E6=A0=B7=E5=BC=8F=EF=BC=8C=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=B8=AD=E5=B0=86=E6=95=B4=E4=B8=AAstyle=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=B8=BA=E4=BA=86=E5=B7=A6=E4=B8=8A=E8=A7=92?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E7=9A=84=E6=A0=B7=E5=BC=8F=20?= =?UTF-8?q?=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=93=8D=E4=BD=9C=E6=97=B6=EF=BC=8C=E4=BB=85=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=A0=BC=E5=BC=8F=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/quickeditor/CellQuickEditor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 0b0650478b..7c3c158765 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -446,12 +446,14 @@ public abstract class CellQuickEditor extends QuickEditor { Style oldStyle = cellElement == null ? Style.DEFAULT_STYLE : cellElement.getStyle(); Style style = formatPane.update(oldStyle); for (TemplateCellElement cellElement : allCellElements) { - Format elementFormat = cellElement.getStyle().getFormat(); + Style cellElementStyle = cellElement.getStyle(); + Format elementFormat = cellElementStyle.getFormat(); Format paneFormat = style.getFormat(); if (!Objects.equals(paneFormat, elementFormat)) { // 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态 editingElementCase.addCellElement(cellElement); - cellElement.setStyle(style); + Style newStyle = cellElementStyle.deriveFormat(paneFormat); + cellElement.setStyle(newStyle); updateStyle = true; } } From 206696bd1d0163c1273e9569a5dc4f0b1f529842 Mon Sep 17 00:00:00 2001 From: shine Date: Sun, 25 Jun 2023 10:14:38 +0800 Subject: [PATCH 37/56] =?UTF-8?q?fix:=20fvs=E9=80=82=E9=85=8Djxbrowser7.26?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98=20#REPORT-98648?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/fun/DefaultValueAdjustProvider.java | 2 +- .../design/fun/impl/AbstractDefaultValueAdjustProvider.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java b/designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java index 1e553735dd..f534163b04 100644 --- a/designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java @@ -14,7 +14,7 @@ import java.awt.Font; */ public interface DefaultValueAdjustProvider extends Selectable { String MARK_STRING = "DefaultValueAdjustProvider"; - int CURRENT_LEVEL = 1; + int CURRENT_LEVEL = 2; /** * 调整单元格对象默认值 diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDefaultValueAdjustProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDefaultValueAdjustProvider.java index b2fc58ba8f..cb1357abe3 100644 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDefaultValueAdjustProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDefaultValueAdjustProvider.java @@ -9,9 +9,13 @@ import com.fr.stable.fun.mark.API; @API(level = DefaultValueAdjustProvider.CURRENT_LEVEL) public abstract class AbstractDefaultValueAdjustProvider extends AbstractProvider implements DefaultValueAdjustProvider { + //1.16及之前发布版本插件里面没有实现currentAPILevel方法,运行时候会走到主jar,拿到-2。 + //1.16.1及之后发布版本插件实现currentAPILevel方法,编译插件的时候,会把DefaultValueAdjustProvider.CURRENT_LEVEL的值编译给插件,比如1.16.1会拿到2。 + private static final int OLD_CURRENT_LEVEL = -2; + @Override public int currentAPILevel() { - return CURRENT_LEVEL; + return OLD_CURRENT_LEVEL; } public String mark4Provider() { From bd42d60cc5d3977f303aa095ece40ff1d30876a4 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 26 Jun 2023 10:39:22 +0800 Subject: [PATCH 38/56] =?UTF-8?q?REPORT-94637=20=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../loghandler/DesignerLogHandlerTest.java | 19 +++++++++++++++++ .../ComponentReuseNotificationInfoTest.java | 2 +- .../java/com/fr/file/FILEChooserPaneTest.java | 21 +++++++++++++++---- .../info/ComponentCreateOperateTest.java | 18 ++++++++++++++++ 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/designer-base/src/test/java/com/fr/design/mainframe/loghandler/DesignerLogHandlerTest.java b/designer-base/src/test/java/com/fr/design/mainframe/loghandler/DesignerLogHandlerTest.java index c7dd1de70a..2dd261606e 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/loghandler/DesignerLogHandlerTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/loghandler/DesignerLogHandlerTest.java @@ -1,7 +1,16 @@ package com.fr.design.mainframe.loghandler; +import com.fr.design.i18n.Toolkit; +import junit.framework.TestCase; +import org.easymock.EasyMock; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import static org.junit.Assert.*; @@ -10,8 +19,18 @@ import static org.junit.Assert.*; * @version 10.0 * Created by vito on 2022/1/25 */ +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({"javax.management.*", "javax.swing.*"}) +@PrepareForTest(Toolkit.class) public class DesignerLogHandlerTest { + @Before + public void setUp() { + PowerMock.mockStatic(Toolkit.class); + EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); + PowerMock.replayAll(); + } + @Test public void findTplLink() { Assert.assertArrayEquals( diff --git a/designer-base/src/test/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfoTest.java b/designer-base/src/test/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfoTest.java index 4095390016..7ea643648a 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfoTest.java @@ -37,7 +37,7 @@ public class ComponentReuseNotificationInfoTest { writer.flush(); writer.close(); Assert.assertEquals("\n" + - "\n", sw.toString()); + "\n", sw.toString()); } } diff --git a/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java index 064cd05cec..8db47b9c44 100644 --- a/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java +++ b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java @@ -1,20 +1,33 @@ package com.fr.file; import com.fr.base.extension.FileExtension; +import com.fr.design.i18n.Toolkit; import com.fr.file.filter.ChooseFileFilter; import com.fr.invoke.Reflect; import com.fr.stable.StringUtils; +import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + /** * Created by kerry on 2019-10-15 */ - +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({"javax.management.*", "javax.swing.*"}) +@PrepareForTest({Toolkit.class, FileNodeFILE.class}) public class FILEChooserPaneTest { @Test public void testAddChooseFileFilter() { - FILEChooserPane chooserPane = Reflect.on(FILEChooserPane.class).field("INSTANCE").get(); + PowerMock.mockStatic(Toolkit.class); + EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); + PowerMock.replayAll(); + FILEChooserPane chooserPane = EasyMock.mock(FILEChooserPane.class); Reflect.on(chooserPane).set("suffix", ".cpt"); String result1 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", null).get(); Assert.assertEquals("WorkBook1.cpt", result1); @@ -25,11 +38,11 @@ public class FILEChooserPaneTest { ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get(); - Assert.assertEquals("WorkBook1.cpt.cptx", result3); + Assert.assertEquals("WorkBook1.cptx", result3); ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get(); - Assert.assertEquals("WorkBook1.cptx.cpt", result4); + Assert.assertEquals("WorkBook1.cpt", result4); ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get(); diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java index 474f580e3d..439f2fd609 100644 --- a/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.template.info; +import com.fr.design.i18n.Toolkit; import com.fr.form.ui.CardAddButton; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.ChartEditor; @@ -16,16 +17,33 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.general.ComparatorUtils; import com.fr.json.JSONObject; +import org.easymock.EasyMock; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.awt.Rectangle; /** * Created by kerry on 2020-05-08 */ +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({"javax.management.*", "javax.swing.*"}) +@PrepareForTest(Toolkit.class) public class ComponentCreateOperateTest { + @Before + public void setUp() { + PowerMock.mockStatic(Toolkit.class); + EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); + PowerMock.replayAll(); + } + @Test public void testConstructor() { ElementCaseEditor caseEditor = new ElementCaseEditor(); From 90ff0ce4c5281abf7510492c85de61f9d5ab2efb Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:28 +0800 Subject: [PATCH 39/56] =?UTF-8?q?Revert=20"REPORT-91839=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8Dbug"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b8f7eda1b0fbc2bb30f0281d6b4a6abcf6b788b3. --- .../mainframe/vcs/common/VcsHelper.java | 54 ++++++++----------- .../design/mainframe/vcs/ui/VcsMovePanel.java | 11 ++++ 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index b245eff66c..1c81481bb9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -79,14 +79,7 @@ public class VcsHelper implements JTemplateActionListener { EventDispatcher.listen(ConfigEvent.READY, new ListenerAdaptor() { @Override protected void on(Event event) { - try { - legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); - FineLoggerFactory.getLogger().info("[VcsHelper] legacyMode:{}", legacyMode); - } catch (Exception e) { - //保险起见走老逻辑 - legacyMode = true; - FineLoggerFactory.getLogger().error("[VcsHelper] get legacy failed", e.getMessage()); - } + legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); } }); } @@ -106,6 +99,7 @@ public class VcsHelper implements JTemplateActionListener { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && JTemplate.isValid(template)) { fireAutoSaveVcs(template); + FineLoggerFactory.getLogger().info("[VcsV2] fire Vcs auto save success!"); } } }, interval, interval, TimeUnit.MINUTES); @@ -269,7 +263,7 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateOpened(JTemplate jt) { try { - if (checkAutoSaveSupport()) { + if (VcsConfigManager.getInstance().isUseAutoSave()) { startAutoSave(VcsConfigManager.getInstance().getAutoSaveInterval()); } } catch (Exception e) { @@ -288,16 +282,25 @@ public class VcsHelper implements JTemplateActionListener { * @param jt 模板 */ public void fireAutoSaveVcs(final JTemplate jt) { - String fileName = getEditingFilename(); - VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); - VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); - boolean replace = needDeleteVersion(entity); - int latestFileVersion = 0; - if (entity != null) { - latestFileVersion = entity.getVersion(); - } - if (JTemplate.isValid(jt)) { - doSave(jt, fileName, latestFileVersion, replace, operator); + ExecutorService fireVcs = Executors.newSingleThreadExecutor(new NamedThreadFactory("autoFireVcs")); + fireVcs.execute(new Runnable() { + @Override + public void run() { + String fileName = getEditingFilename(); + VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); + VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); + boolean replace = needDeleteVersion(entity); + int latestFileVersion = 0; + if (entity != null) { + latestFileVersion = entity.getVersion(); + } + if (JTemplate.isValid(jt)) { + doSave(jt, fileName, latestFileVersion, replace, operator); + } + } + }); + if (!fireVcs.isShutdown()) { + fireVcs.shutdown(); } } @@ -345,9 +348,7 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateClosed(JTemplate jt) { try { - if (checkAutoSaveSupport()) { - stopAutoSave(); - } + stopAutoSave(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage()); } @@ -371,13 +372,4 @@ public class VcsHelper implements JTemplateActionListener { public boolean checkMoveFunctionSupport() { return VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } - - /** - * 是否支持自动保存 - * - * @return 支持返回true - */ - public boolean checkAutoSaveSupport() { - return VcsConfigManager.getInstance().isUseAutoSave() && !VcsHelper.getInstance().isLegacyMode(); - } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java index af450d8250..cf68c33bc3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java @@ -19,6 +19,10 @@ import com.fr.design.widget.FRWidgetFactory; import com.fr.general.FRFont; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerAdaptor; +import com.fr.workspace.server.vcs.VcsConfig; +import com.fr.workspace.server.vcs.VcsManager; import com.fr.workspace.server.vcs.v2.move.VcsMoveService; import com.fr.workspace.server.vcs.v2.move.VcsMoveStrategy; @@ -387,6 +391,13 @@ public class VcsMovePanel extends BasicPane { VcsMoveService.getInstance().stopMoving(); initSuccessPane(); VcsMovePanel.this.getParentCard().show(getParentPane(), SUCCESS); + Configurations.update(new WorkerAdaptor(VcsConfig.class) { + @Override + public void run() { + VcsConfig.getInstance().setUseV2(true); + } + }); + VcsManager.getInstance().updateManager(); VcsHelper.getInstance().updateLegacyMode(); } } From 718080f6227ccd3ad2eb84d6236e31efab8098e7 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:29 +0800 Subject: [PATCH 40/56] =?UTF-8?q?Revert=20"REPORT-91839=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=20=E5=A4=9A=E5=88=A0=E4=BA=86=E4=B8=80=E9=83=A8=E5=88=86"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9d19e9c93e4649e905ba6a9ce1a2c6983ca10e5a. --- .../main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java index 8551f735b9..1129df5a1f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java @@ -79,7 +79,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { this.setSaveCommit(reader.getAttrAsBoolean("saveCommit", true)); this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60)); this.setUseInterval(reader.getAttrAsBoolean("useInterval", true)); - this.setVcsEnable(reader.getAttrAsBoolean("vcsEnable", true)); this.setAutoSaveInterval(reader.getAttrAsInt("autoSaveInterval", 15)); this.setUseAutoSave(reader.getAttrAsBoolean("useAutoSave", false)); } From 58b1b29cbfbf54486e052dfc6ebefcb3caf94989 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:30 +0800 Subject: [PATCH 41/56] =?UTF-8?q?Revert=20"REPORT-91839=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=20=E8=A1=A5=E5=85=85=E6=8C=89=E9=92=AE=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E9=99=A4=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4682898c6763b0720024035948a68964aa72a65e. --- .../design/actions/file/PreferencePane.java | 23 +---- .../design/mainframe/vcs/ui/VcsMovePanel.java | 95 ++++++------------- 2 files changed, 32 insertions(+), 86 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 4d31904f1f..d816131dee 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -220,9 +220,6 @@ public class PreferencePane extends BasicPane { private UICheckBox saveCommitCheckBox; private UICheckBox useIntervalCheckBox; private VcsMovePanel movePanel; - - private JPanel saveIntervalPane; - private JPanel autoCleanPane; private UICheckBox startupPageEnabledCheckBox; private IntegerEditor saveIntervalEditor; private UICheckBox gcEnableCheckBox; @@ -395,7 +392,7 @@ public class PreferencePane extends BasicPane { private void createVcsSettingPane(JPanel generalPane,JPanel parentPane, CardLayout cardLayout) { //迁移面板 - movePanel = createMovePane(cardLayout, parentPane); + movePanel = new VcsMovePanel(cardLayout, parentPane); generalPane.add(movePanel, BorderLayout.NORTH); JPanel savePane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Save_Setting")); JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Clean_Setting")); @@ -407,7 +404,7 @@ public class PreferencePane extends BasicPane { remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); vcsEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_SaveAuto")); - saveIntervalPane = createSaveIntervalPane(); + JPanel saveIntervalPane = createSaveIntervalPane(); saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete")); saveIntervalEditor = new IntegerEditor(60); useIntervalCheckBox = new UICheckBox(); @@ -426,7 +423,7 @@ public class PreferencePane extends BasicPane { intervalPanel.add(everyLabel); intervalPanel.add(saveIntervalEditor); intervalPanel.add(delayLabel); - autoCleanPane = createAutoCleanPane(); + JPanel autoCleanPane = createAutoCleanPane(); vcsEnableCheckBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -450,24 +447,12 @@ public class PreferencePane extends BasicPane { vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); vcsPane.add(autoCleanPane); - saveIntervalPane.setVisible(!VcsHelper.getInstance().isLegacyMode()); - autoCleanPane.setVisible(!VcsHelper.getInstance().isLegacyMode()); if (VcsHelper.getInstance().isLegacyMode()) { // 老版本时才显示gc选项 vcsPane.add(gcControlPane); } } - private VcsMovePanel createMovePane(CardLayout cardLayout, JPanel parentPane) { - return new VcsMovePanel(cardLayout, parentPane, new VcsMovePanel.MoveCallBack(){ - @Override - public void doCallBack(boolean visible) { - saveIntervalPane.setVisible(visible); - autoCleanPane.setVisible(visible); - } - }); - }; - private JPanel createAutoCleanPane() { JPanel autoCleanPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); useVcsAutoCleanScheduleCheckBox = new UICheckBox(); @@ -482,7 +467,6 @@ public class PreferencePane extends BasicPane { autoCleanPane.add(autoCleanRetainIntervalComboBox); autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Last"))); useVcsAutoCleanScheduleCheckBox.setEnabled(!VcsHelper.getInstance().isLegacyMode()); - autoCleanPane.setVisible(false); return autoCleanPane; } @@ -495,7 +479,6 @@ public class PreferencePane extends BasicPane { saveIntervalPane.add(autoSaveIntervalEditor); saveIntervalPane.add(new UILabel(i18nText("Fine-Design_Vcs_Save_Delay"))); useVcsAutoSaveScheduleCheckBox.setEnabled(!VcsHelper.getInstance().isLegacyMode()); - saveIntervalPane.setVisible(false); return saveIntervalPane; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java index cf68c33bc3..9a3235cd15 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java @@ -32,8 +32,6 @@ import javax.swing.JProgressBar; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.List; @@ -104,19 +102,12 @@ public class VcsMovePanel extends BasicPane { private UISpinner spinner; - private MoveCallBack callBack; - private JPanel updatePane; - - private boolean visible = false; - - - public VcsMovePanel(CardLayout cardLayout, JPanel parentPane, MoveCallBack callBack) { + public VcsMovePanel(CardLayout cardLayout, JPanel parentPane) { this.parentCard = cardLayout; this.parentPane = parentPane; - this.callBack = callBack; this.setLayout(new BorderLayout()); - updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); + JPanel updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); updatePane.setBackground(BACK_GROUND_COLOR); //初始化迁移的面板 initVcsLabel(updatePane); @@ -270,37 +261,25 @@ public class VcsMovePanel extends BasicPane { JPanel successPane = new JPanel(); JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); successButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Go")); - initSuccessButtonListener(); iconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_success.svg")); successLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success")); successLabel.setFont(FONT); successTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Tip")); - initStatusPane(successTipLabel, iconLabel, successLabel, successButton, body, SUCCESS, successPane); - } - - private void initSuccessButtonListener() { - successButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - doAfterMove(); - } - }); - } - - private void initFailedButtonListener() { - failedButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - doAfterMove(); - } - }); - } - - private void doAfterMove() { - visible = !VcsHelper.getInstance().isLegacyMode(); - updatePane.setVisible(!visible); - callBack.doCallBack(visible); - parentCard.show(parentPane, SETTING); + successTipLabel.setForeground(TIP_COLOR); + body.add(iconLabel); + body.add(new UILabel(StringUtils.BLANK)); + body.add(successLabel); + body.add(new UILabel(StringUtils.BLANK)); + body.add(successTipLabel); + body.add(new UILabel(StringUtils.BLANK)); + body.add(successButton); + successPane.add(body); + successPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); + parentPane.add(successPane, SUCCESS); + iconLabel.setAlignmentX(CENTER_ALIGNMENT); + successLabel.setAlignmentX(CENTER_ALIGNMENT); + successButton.setAlignmentX(CENTER_ALIGNMENT); + successTipLabel.setAlignmentX(CENTER_ALIGNMENT); } @@ -321,30 +300,25 @@ public class VcsMovePanel extends BasicPane { JPanel failedPane = new JPanel(); JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); failedButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Go")); - initFailedButtonListener(); failedIconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_failed.svg")); failedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed")); failedLabel.setFont(FONT); failedTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Tip")); - initStatusPane(failedTipLabel, failedIconLabel, failedLabel, failedButton, body, FAILED, failedPane); - } - - private void initStatusPane(UILabel tipLabel, UILabel iconLabel, UILabel label, UIButton button, JPanel body, String tag,JPanel statusPane) { - tipLabel.setForeground(TIP_COLOR); - body.add(iconLabel); + failedTipLabel.setForeground(TIP_COLOR); + body.add(failedIconLabel); body.add(new UILabel(StringUtils.BLANK)); - body.add(label); + body.add(failedLabel); body.add(new UILabel(StringUtils.BLANK)); - body.add(tipLabel); + body.add(failedTipLabel); body.add(new UILabel(StringUtils.BLANK)); - body.add(button); - statusPane.add(body); - statusPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); - parentPane.add(statusPane, tag); - iconLabel.setAlignmentX(CENTER_ALIGNMENT); - label.setAlignmentX(CENTER_ALIGNMENT); - button.setAlignmentX(CENTER_ALIGNMENT); - tipLabel.setAlignmentX(CENTER_ALIGNMENT); + body.add(failedButton); + failedPane.add(body); + failedPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); + parentPane.add(failedPane, FAILED); + failedIconLabel.setAlignmentX(CENTER_ALIGNMENT); + failedLabel.setAlignmentX(CENTER_ALIGNMENT); + failedButton.setAlignmentX(CENTER_ALIGNMENT); + failedTipLabel.setAlignmentX(CENTER_ALIGNMENT); } @@ -403,15 +377,4 @@ public class VcsMovePanel extends BasicPane { } - /** - * 迁移回调事件 - * - */ - public static class MoveCallBack { - /** - * 处理回调 - */ - public void doCallBack(boolean visible){} - } - } From 3258151e7df95826391ac0b854aac323f79b4139 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:32 +0800 Subject: [PATCH 42/56] =?UTF-8?q?Revert=20"REPORT-91839=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=88=A4=E6=96=AD=E6=96=B0=E8=80=81?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E7=9A=84=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=93=8D=E5=BA=94=E6=94=B9=E4=B8=BAConfig=E5=87=86?= =?UTF-8?q?=E5=A4=87=E5=90=8E=E8=BF=9B=E8=A1=8C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 6694648b918db44813a7db75d03421d51bc5ebb0. --- .../mainframe/vcs/common/VcsHelper.java | 27 +++++++------------ .../design/mainframe/vcs/ui/VcsMovePanel.java | 1 - 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index 1c81481bb9..ce7f4094b9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -2,7 +2,6 @@ package com.fr.design.mainframe.vcs.common; import com.fr.concurrent.NamedThreadFactory; -import com.fr.config.ConfigEvent; import com.fr.design.DesignerEnvManager; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.TemplateTreePane; @@ -15,7 +14,7 @@ import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.ui.FileVersionTable; import com.fr.event.Event; import com.fr.event.EventDispatcher; -import com.fr.event.ListenerAdaptor; +import com.fr.event.Listener; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; @@ -24,6 +23,9 @@ import com.fr.report.entity.VcsEntity; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceEvent; +import com.fr.workspace.server.vcs.VcsConfig; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.git.config.GcConfig; @@ -76,9 +78,9 @@ public class VcsHelper implements JTemplateActionListener { if (op != null) { legacyMode = op.isLegacyMode(); } - EventDispatcher.listen(ConfigEvent.READY, new ListenerAdaptor() { + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { @Override - protected void on(Event event) { + public void on(Event event, Workspace param) { legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); } }); @@ -251,15 +253,6 @@ public class VcsHelper implements JTemplateActionListener { return legacyMode; } - /** - * 更新当前的legacyMode状态 - *
  • 目前用在迁移结束后更新模式为新模式
  • - * - */ - public void updateLegacyMode() { - this.legacyMode = !legacyMode; - } - @Override public void templateOpened(JTemplate jt) { try { @@ -299,9 +292,7 @@ public class VcsHelper implements JTemplateActionListener { } } }); - if (!fireVcs.isShutdown()) { - fireVcs.shutdown(); - } + fireVcs.shutdown(); } private void doSave(JTemplate jt, String fileName, int latestFileVersion, boolean replace, VcsOperator operator) { @@ -361,7 +352,7 @@ public class VcsHelper implements JTemplateActionListener { * @return 支持返回true */ public boolean checkV2FunctionSupport() { - return !VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); + return VcsConfig.getInstance().isUseV2() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } /** @@ -370,6 +361,6 @@ public class VcsHelper implements JTemplateActionListener { * @return 支持返回true */ public boolean checkMoveFunctionSupport() { - return VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); + return !VcsConfig.getInstance().isUseV2() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java index 9a3235cd15..350d20424e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java @@ -372,7 +372,6 @@ public class VcsMovePanel extends BasicPane { } }); VcsManager.getInstance().updateManager(); - VcsHelper.getInstance().updateLegacyMode(); } } From e54b89675dbe782d6a819854de41efa600ad1dcd Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:33 +0800 Subject: [PATCH 43/56] =?UTF-8?q?Revert=20"REPORT-91839=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=20=E5=AE=8C=E5=96=84=E4=B8=80=E4=B8=8B=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=A0=87=E7=AD=BE=E8=AE=BE=E7=BD=AE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4bd02cf06aae5999a8b3f69c870284e044289ceb. --- .../java/com/fr/design/mainframe/vcs/common/VcsHelper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index ce7f4094b9..77ab8db68e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -25,7 +25,6 @@ import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; -import com.fr.workspace.server.vcs.VcsConfig; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.git.config.GcConfig; @@ -352,7 +351,7 @@ public class VcsHelper implements JTemplateActionListener { * @return 支持返回true */ public boolean checkV2FunctionSupport() { - return VcsConfig.getInstance().isUseV2() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); + return !VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } /** @@ -361,6 +360,6 @@ public class VcsHelper implements JTemplateActionListener { * @return 支持返回true */ public boolean checkMoveFunctionSupport() { - return !VcsConfig.getInstance().isUseV2() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); + return VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } } From b103a0de083d3cd3f10d50ab0a940d5a899cdc5e Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:35 +0800 Subject: [PATCH 44/56] =?UTF-8?q?Revert=20"REPORT-91839=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E8=A7=84=E8=8C=83=E9=97=AE=E9=A2=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fa34777dd506b4fc32e8811cd0ff1f7d10dcf6f1. --- .../mainframe/vcs/common/VcsHelper.java | 5 ++-- .../design/mainframe/vcs/ui/VcsMovePanel.java | 28 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index 77ab8db68e..7ec79ca938 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -190,6 +190,7 @@ public class VcsHelper implements JTemplateActionListener { fireVcs.execute(new Runnable() { @Override public void run() { + String fileName = getEditingFilename(); VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); @@ -212,9 +213,7 @@ public class VcsHelper implements JTemplateActionListener { } }); - if (!fireVcs.isShutdown()) { - fireVcs.shutdown(); - } + fireVcs.shutdown(); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java index 350d20424e..d92171d26a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java @@ -26,11 +26,7 @@ import com.fr.workspace.server.vcs.VcsManager; import com.fr.workspace.server.vcs.v2.move.VcsMoveService; import com.fr.workspace.server.vcs.v2.move.VcsMoveStrategy; -import javax.swing.ButtonGroup; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; +import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -80,7 +76,7 @@ public class VcsMovePanel extends BasicPane { private BasicPane choosePane; private CardLayout parentCard; private JPanel parentPane; - private static final JProgressBar PROGRESS_BAR = new JProgressBar(); + private static final JProgressBar progressBar = new JProgressBar(); private JPanel progressPanel; private UILabel tipLabel; @@ -145,13 +141,13 @@ public class VcsMovePanel extends BasicPane { private void initProcessPane() { JPanel processPane = new JPanel(); JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - PROGRESS_BAR.setStringPainted(true); - PROGRESS_BAR.setUI(new ModernUIProgressBarUI()); - PROGRESS_BAR.setBorderPainted(false); - PROGRESS_BAR.setOpaque(false); - PROGRESS_BAR.setBorder(null); - PROGRESS_BAR.setSize(BasicDialog.MEDIUM); - body.add(PROGRESS_BAR); + progressBar.setStringPainted(true); + progressBar.setUI(new ModernUIProgressBarUI()); + progressBar.setBorderPainted(false); + progressBar.setOpaque(false); + progressBar.setBorder(null); + progressBar.setSize(BasicDialog.MEDIUM); + body.add(progressBar); body.add(new UILabel(StringUtils.BLANK)); tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_While_Moving")); tipLabel.setAlignmentX(CENTER_ALIGNMENT); @@ -334,7 +330,7 @@ public class VcsMovePanel extends BasicPane { protected Void doInBackground() throws Exception { try { //开始迁移 - VcsMoveService.getInstance().startMove(new VcsMoveService.BaseMoveServiceWhileMoving() { + VcsMoveService.getInstance().startMove(new VcsMoveService.MoveServiceWhileMoving() { @Override public void publishProgress() { int num = VcsMoveService.getInstance().getCurrentMove(); @@ -342,7 +338,7 @@ public class VcsMovePanel extends BasicPane { } @Override public void prepare4Move() { - PROGRESS_BAR.setMaximum(VcsMoveService.getInstance().getTotal()); + progressBar.setMaximum(VcsMoveService.getInstance().getTotal()); } }, strategy); } catch (Exception e) { @@ -357,7 +353,7 @@ public class VcsMovePanel extends BasicPane { @Override protected void process(List chunks) { - PROGRESS_BAR.setValue(chunks.get(chunks.size() - 1)); + progressBar.setValue(chunks.get(chunks.size() - 1)); } @Override From 392240edd9e2ef9d20ad985918da3aa9ea2f5a55 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:36 +0800 Subject: [PATCH 45/56] =?UTF-8?q?Revert=20"REPORT-91839=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E4=BA=8C=E6=9C=9F?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b5518abfb66cfcf1e6a06b9e8032b23643ad38b1. --- .../design/actions/file/PreferencePane.java | 169 +------- .../mainframe/vcs/VcsConfigManager.java | 26 +- .../mainframe/vcs/common/VcsHelper.java | 122 ------ .../design/mainframe/vcs/ui/VcsMovePanel.java | 375 ------------------ .../com/fr/design/vcs/move_failed.svg | 5 - .../com/fr/design/vcs/move_success.svg | 5 - .../com/fr/design/vcs/vcs_move_icon.svg | 3 - 7 files changed, 14 insertions(+), 691 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java delete mode 100644 designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg delete mode 100644 designer-base/src/main/resources/com/fr/design/vcs/move_success.svg delete mode 100644 designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index d816131dee..a83bcfd771 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -36,7 +36,6 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.mainframe.vcs.ui.VcsMovePanel; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.unit.UnitConvertUtil; import com.fr.design.utils.gui.GUICoreUtils; @@ -55,12 +54,9 @@ import com.fr.stable.os.OperatingSystem; import com.fr.third.apache.logging.log4j.Level; import com.fr.transaction.Configurations; import com.fr.transaction.Worker; -import com.fr.transaction.WorkerAdaptor; import com.fr.workspace.WorkContext; -import com.fr.workspace.server.vcs.VcsConfig; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.git.config.GcConfig; -import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanOperator; import org.jetbrains.annotations.NotNull; import javax.swing.BorderFactory; @@ -81,7 +77,14 @@ import javax.swing.UIManager; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -146,32 +149,6 @@ public class PreferencePane extends BasicPane { private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG}; - private static final int ONE_DAY_INT = 1; - private static final int ONE_WEEK_INT = 7; - private static final int ONE_MONTH_INT = 30; - private static final int THREE_MONTH_INT = 90; - private static final int SIX_MONTH_INT = 180; - - private static final int ONE_DAY_INDEX = 0; - private static final int ONE_WEEK_INDEX = 1; - private static final int ONE_MONTH_INDEX = 2; - private static final int THREE_MONTH_INDEX = 3; - private static final int SIX_MONTH_INDEX = 4; - private static final String ONE_DAY = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_ONE_DAY"); - private static final String ONE_WEEK = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_ONE_WEEK"); - private static final String ONE_MONTH = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_ONE_MONTH"); - private static final String THREE_MONTH = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_THREE_MONTH"); - private static final String SIX_MONTH = Toolkit.i18nText("Fine-Design_Vcs_Auto_Clean_SIX_MONTH"); - private static final String[] INTERVAL = { - ONE_DAY, - ONE_WEEK, - ONE_MONTH, - THREE_MONTH, - SIX_MONTH - }; - - private static final int DEFAULT_INDEX = 3; - private boolean languageChanged; // 是否修改了设计器语言设置 //设置是否支持undo private UICheckBox supportUndoCheckBox; @@ -209,17 +186,8 @@ public class PreferencePane extends BasicPane { private UICheckBox cloudAnalyticsDelayCheckBox; private UICheckBox vcsEnableCheckBox; - private UICheckBox useVcsAutoSaveScheduleCheckBox; - - private UICheckBox useVcsAutoCleanScheduleCheckBox; - - private UIComboBox autoCleanIntervalComboBox; - private UIComboBox autoCleanRetainIntervalComboBox; - - private IntegerEditor autoSaveIntervalEditor; private UICheckBox saveCommitCheckBox; private UICheckBox useIntervalCheckBox; - private VcsMovePanel movePanel; private UICheckBox startupPageEnabledCheckBox; private IntegerEditor saveIntervalEditor; private UICheckBox gcEnableCheckBox; @@ -259,26 +227,13 @@ public class PreferencePane extends BasicPane { JPanel advancePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); UIScrollPane adviceScrollPane = patchScroll(advancePane); jtabPane.addTab(i18nText("Fine-Design_Basic_Advanced"), adviceScrollPane); - //初始化vcs总面板 - JPanel vcsParentPane = new JPanel(); - CardLayout cardLayout = new CardLayout(); - vcsParentPane.setLayout(cardLayout); - //vcs配置面板 - JPanel vcsPane = new JPanel(new BorderLayout()); - //添加滚动条 - UIScrollPane vcsScrollPane = patchScroll(vcsPane); - //配置面板作为vcs总面板的一张卡片 - vcsParentPane.add(vcsScrollPane, VcsMovePanel.SETTING); - jtabPane.addTab(i18nText("Fine-Design_Vcs_Title"), vcsParentPane); contentPane.add(jtabPane, BorderLayout.NORTH); createFunctionPane(generalPane); createEditPane(generalPane); createColorSettingPane(generalPane); - - // vcsPane - createVcsSettingPane(vcsPane, vcsParentPane, cardLayout); + createVcsSettingPane(generalPane); // ConfPane JPanel confLocationPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane(); @@ -390,31 +345,21 @@ public class PreferencePane extends BasicPane { return generalPanelWithScroll; } - private void createVcsSettingPane(JPanel generalPane,JPanel parentPane, CardLayout cardLayout) { - //迁移面板 - movePanel = new VcsMovePanel(cardLayout, parentPane); - generalPane.add(movePanel, BorderLayout.NORTH); - JPanel savePane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Save_Setting")); - JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Clean_Setting")); - JPanel containPane = new JPanel(new GridLayout(10,1,0,8)); - containPane.add(savePane); - containPane.add(vcsPane); - generalPane.add(containPane, BorderLayout.CENTER); + private void createVcsSettingPane(JPanel generalPane) { + JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); + generalPane.add(vcsPane); remindVcsLabel = new UILabel(i18nText("Fine-Design_Vcs_Remind")); remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); vcsEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_SaveAuto")); - - JPanel saveIntervalPane = createSaveIntervalPane(); saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete")); saveIntervalEditor = new IntegerEditor(60); useIntervalCheckBox = new UICheckBox(); - savePane.add(vcsEnableCheckBox); - savePane.add(saveIntervalPane); //gc面板 JPanel gcControlPane = createGcControlPane(); JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); + enableVcsPanel.add(vcsEnableCheckBox); enableVcsPanel.add(remindVcsLabel); JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); final UILabel everyLabel = new UILabel(i18nText("Fine-Design_Vcs_Every")); @@ -423,7 +368,6 @@ public class PreferencePane extends BasicPane { intervalPanel.add(everyLabel); intervalPanel.add(saveIntervalEditor); intervalPanel.add(delayLabel); - JPanel autoCleanPane = createAutoCleanPane(); vcsEnableCheckBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -446,44 +390,12 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); - vcsPane.add(autoCleanPane); if (VcsHelper.getInstance().isLegacyMode()) { // 老版本时才显示gc选项 vcsPane.add(gcControlPane); } } - private JPanel createAutoCleanPane() { - JPanel autoCleanPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); - useVcsAutoCleanScheduleCheckBox = new UICheckBox(); - autoCleanIntervalComboBox = new UIComboBox(INTERVAL); - autoCleanIntervalComboBox.setSelectedIndex(DEFAULT_INDEX); - autoCleanRetainIntervalComboBox = new UIComboBox(INTERVAL); - autoCleanRetainIntervalComboBox.setSelectedIndex(DEFAULT_INDEX); - autoCleanPane.add(useVcsAutoCleanScheduleCheckBox); - autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Every"))); - autoCleanPane.add(autoCleanIntervalComboBox); - autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Content"))); - autoCleanPane.add(autoCleanRetainIntervalComboBox); - autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Last"))); - useVcsAutoCleanScheduleCheckBox.setEnabled(!VcsHelper.getInstance().isLegacyMode()); - return autoCleanPane; - } - - private JPanel createSaveIntervalPane() { - JPanel saveIntervalPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); - useVcsAutoSaveScheduleCheckBox = new UICheckBox(); - autoSaveIntervalEditor = new IntegerEditor(60); - saveIntervalPane.add(useVcsAutoSaveScheduleCheckBox); - saveIntervalPane.add(new UILabel(i18nText("Fine-Design_Vcs_Every"))); - saveIntervalPane.add(autoSaveIntervalEditor); - saveIntervalPane.add(new UILabel(i18nText("Fine-Design_Vcs_Save_Delay"))); - useVcsAutoSaveScheduleCheckBox.setEnabled(!VcsHelper.getInstance().isLegacyMode()); - return saveIntervalPane; - } - - - /** * 模创建板版本gc 配置操作面板 * @@ -887,10 +799,6 @@ public class PreferencePane extends BasicPane { gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable()); gcButton.setEnabled(gcEnableCheckBox.isSelected()); - useVcsAutoSaveScheduleCheckBox.setSelected(vcsConfigManager.isUseAutoSave()); - useVcsAutoCleanScheduleCheckBox.setSelected(VcsConfig.getInstance().isUseV2AutoClean()); - autoSaveIntervalEditor.setValue(vcsConfigManager.getAutoSaveInterval()); - gridLineColorTBButton.setColor(designerEnvManager.getGridLineColor()); paginationLineColorTBButton.setColor(designerEnvManager.getPaginationLineColor()); @@ -970,21 +878,6 @@ public class PreferencePane extends BasicPane { } } - private int getDay(int dateIndex) { - switch (dateIndex) { - case ONE_DAY_INDEX: - return ONE_DAY_INT; - case ONE_WEEK_INDEX: - return ONE_WEEK_INT; - case ONE_MONTH_INDEX: - return ONE_MONTH_INT; - case SIX_MONTH_INDEX: - return SIX_MONTH_INT; - default: - return THREE_MONTH_INT; - } - } - /** * The method of update. */ @@ -1030,17 +923,6 @@ public class PreferencePane extends BasicPane { vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected()); vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected()); - vcsConfigManager.setUseAutoSave(this.useVcsAutoSaveScheduleCheckBox.isSelected()); - vcsConfigManager.setAutoSaveInterval(this.autoSaveIntervalEditor.getValue()); - Configurations.update(new WorkerAdaptor(VcsConfig.class) { - @Override - public void run() { - VcsConfig.getInstance().setUseV2AutoClean(useVcsAutoCleanScheduleCheckBox.isSelected()); - VcsConfig.getInstance().setV2CleanInterval(getDay(autoCleanIntervalComboBox.getSelectedIndex())); - VcsConfig.getInstance().setV2RetainInterval(getDay(autoCleanRetainIntervalComboBox.getSelectedIndex())); - } - }); - dealWithSchedule(); designerEnvManager.setStartupPageEnabled(this.startupPageEnabledCheckBox.isSelected()); Configurations.update(new Worker() { @Override @@ -1115,31 +997,6 @@ public class PreferencePane extends BasicPane { } - private void dealWithSchedule() { - new SwingWorker() { - @Override - protected Void doInBackground() throws Exception { - boolean v2FunctionSupport = VcsHelper.getInstance().checkV2FunctionSupport(); - if (v2FunctionSupport) { - //如果支持V2 - if (useVcsAutoSaveScheduleCheckBox.isSelected()) { - FineLoggerFactory.getLogger().info("[VcsV2] start auto save!"); - VcsHelper.getInstance().startAutoSave(autoSaveIntervalEditor.getValue()); - } else { - VcsHelper.getInstance().stopAutoSave(); - } - if (useVcsAutoCleanScheduleCheckBox.isSelected()) { - FineLoggerFactory.getLogger().info("[VcsV2] start auto clean!"); - WorkContext.getCurrent().get(VcsAutoCleanOperator.class).addOrUpdateVcsAutoCleanJob(getDay(autoCleanIntervalComboBox.getSelectedIndex())); - } else { - WorkContext.getCurrent().get(VcsAutoCleanOperator.class).stopVcsAutoCleanJob(); - } - } - return null; - } - }.execute(); - } - // 如果语言设置改变了,则显示重启对话框 public void showRestartDialog() { if (!languageChanged) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java index 1129df5a1f..f61bba67a8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java @@ -16,10 +16,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { private boolean useInterval = true; private int saveInterval = 60; - private boolean useAutoSave = false; - - private int autoSaveInterval = 15; - public static VcsConfigManager getInstance() { return instance; } @@ -52,23 +48,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { return saveInterval; } - public int getAutoSaveInterval() { - return autoSaveInterval; - } - - public void setAutoSaveInterval(int autoSaveInterval) { - this.autoSaveInterval = autoSaveInterval; - } - - public boolean isUseAutoSave() { - return useAutoSave; - } - - public void setUseAutoSave(boolean useAutoSave) { - this.useAutoSave = useAutoSave; - } - - public void setSaveInterval(int saveInterval) { this.saveInterval = saveInterval; } @@ -79,8 +58,7 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { this.setSaveCommit(reader.getAttrAsBoolean("saveCommit", true)); this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60)); this.setUseInterval(reader.getAttrAsBoolean("useInterval", true)); - this.setAutoSaveInterval(reader.getAttrAsInt("autoSaveInterval", 15)); - this.setUseAutoSave(reader.getAttrAsBoolean("useAutoSave", false)); + this.setVcsEnable(reader.getAttrAsBoolean("vcsEnable", true)); } } @@ -91,8 +69,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { writer.attr("saveInterval", this.getSaveInterval()); writer.attr("useInterval", this.isUseInterval()); writer.attr("vcsEnable", this.isVcsEnable()); - writer.attr("autoSaveInterval", this.getAutoSaveInterval()); - writer.attr("useAutoSave", this.isUseAutoSave()); writer.end(); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index 7ec79ca938..dd7187be23 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -36,8 +36,6 @@ import java.awt.Color; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; /** * Created by XiaXiang on 2019/4/17. @@ -63,8 +61,6 @@ public class VcsHelper implements JTemplateActionListener { private final static String SERVICE_NAME_MOVE = "moveVcs"; private static final VcsHelper INSTANCE = new VcsHelper(); - private static ScheduledExecutorService saveSchedule; - private volatile boolean legacyMode; public static VcsHelper getInstance() { @@ -85,37 +81,6 @@ public class VcsHelper implements JTemplateActionListener { }); } - /** - * 开始自动保存任务 - * - * @param interval 时间间隔 - */ - public void startAutoSave(int interval) { - stopAutoSave(); - saveSchedule = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("VcsAutoSaveSchedule")); - saveSchedule.scheduleWithFixedDelay(new Runnable() { - @Override - public void run() { - FineLoggerFactory.getLogger().info("[VcsV2] start to run auto save schedule"); - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && JTemplate.isValid(template)) { - fireAutoSaveVcs(template); - FineLoggerFactory.getLogger().info("[VcsV2] fire Vcs auto save success!"); - } - } - }, interval, interval, TimeUnit.MINUTES); - } - - /** - * 停止任务 - */ - public void stopAutoSave() { - if (saveSchedule != null && !saveSchedule.isShutdown()) { - saveSchedule.shutdown(); - } - } - - private int containsFolderCounts() { TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { @@ -253,73 +218,9 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateOpened(JTemplate jt) { - try { - if (VcsConfigManager.getInstance().isUseAutoSave()) { - startAutoSave(VcsConfigManager.getInstance().getAutoSaveInterval()); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - - } - - /** - * 响应版本管理自动保存 - * - *
  • 直接用template的file来保存的话相当于拿源文件来保存模板,这样用户做的改动会丢失
  • - *
  • 因此需要自己实现一下自动保存的逻辑,将当前模板的数据导出,再拿这个Byte[]去做我们需要的保存处理
  • - *
  • 保存后需要触发清理逻辑
  • - * - * @param jt 模板 - */ - public void fireAutoSaveVcs(final JTemplate jt) { - ExecutorService fireVcs = Executors.newSingleThreadExecutor(new NamedThreadFactory("autoFireVcs")); - fireVcs.execute(new Runnable() { - @Override - public void run() { - String fileName = getEditingFilename(); - VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); - VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); - boolean replace = needDeleteVersion(entity); - int latestFileVersion = 0; - if (entity != null) { - latestFileVersion = entity.getVersion(); - } - if (JTemplate.isValid(jt)) { - doSave(jt, fileName, latestFileVersion, replace, operator); - } - } - }); - fireVcs.shutdown(); - } - private void doSave(JTemplate jt, String fileName, int latestFileVersion, boolean replace, VcsOperator operator) { - if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { - operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); - String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); - List updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); - SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); - } else { - autoSave(jt, getCurrentUsername(), fileName, latestFileVersion + 1, replace, operator); - } - if (GcConfig.getInstance().isGcEnable()) { - operator.gc(); - } } - private void autoSave(JTemplate jt, String currentUsername, String fileName, int nowVersion, boolean replace, VcsOperator operator) { - try { - if (JTemplate.isValid(jt)) { - operator.autoSave(currentUsername, fileName, StringUtils.EMPTY, nowVersion, jt.exportData(), replace); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - - - - /** * 模板保存时 处理. * @@ -336,29 +237,6 @@ public class VcsHelper implements JTemplateActionListener { @Override public void templateClosed(JTemplate jt) { - try { - stopAutoSave(); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - - } - /** - * 判断是否支持V2功能 - * - * @return 支持返回true - */ - public boolean checkV2FunctionSupport() { - return !VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); - } - - /** - * 判断是否支持迁移功能 - * - * @return 支持返回true - */ - public boolean checkMoveFunctionSupport() { - return VcsHelper.getInstance().isLegacyMode() && (WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot()); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java deleted file mode 100644 index d92171d26a..0000000000 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java +++ /dev/null @@ -1,375 +0,0 @@ -package com.fr.design.mainframe.vcs.ui; - - -import com.fr.base.svg.IconUtils; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.BasicPane; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.iprogressbar.ModernUIProgressBarUI; -import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.VerticalFlowLayout; -import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.utils.DesignUtils; -import com.fr.design.widget.FRWidgetFactory; -import com.fr.general.FRFont; -import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; -import com.fr.transaction.Configurations; -import com.fr.transaction.WorkerAdaptor; -import com.fr.workspace.server.vcs.VcsConfig; -import com.fr.workspace.server.vcs.VcsManager; -import com.fr.workspace.server.vcs.v2.move.VcsMoveService; -import com.fr.workspace.server.vcs.v2.move.VcsMoveStrategy; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.List; -import java.util.concurrent.ExecutionException; - - -/** - * 迁移面板 - * - * @author Destiny.Lin - * @since 11.0 - * Created on 2023/6/13 - */ -public class VcsMovePanel extends BasicPane { - private static final FRFont FONT = DesignUtils - .getDefaultGUIFont() - .applySize(14) - .applyStyle(FRFont.BOLD); - - private static final Color BACK_GROUND_COLOR = new Color(202,232,255); - - //提示字体的颜色,直接模仿其他面板的写法 - private static final Color TIP_COLOR = new Color(51, 51, 52, (int)Math.round(0.5 * 255)); - - private static final Color LABEL_COLOR = new Color(34,149,233); - - private static final int MIN_VALUE = 1; - - private static final int MAX_VALUE = 999; - - private static final int STEP = 1; - - private static final int DEFAULT_VALUE = 5; - - public static final String SETTING = "SETTING"; - - public static final String PROCESS = "PROCESS"; - - public static final String SUCCESS = "SUCCESS"; - - public static final String FAILED = "FAILED"; - - public static boolean moving = false; - private UILabel vcsUpdateExistLabel; - private UILabel vcsUpdateFireLabel; - private BasicPane choosePane; - private CardLayout parentCard; - private JPanel parentPane; - private static final JProgressBar progressBar = new JProgressBar(); - - private JPanel progressPanel; - private UILabel tipLabel; - private UIButton successButton; - private UILabel iconLabel; - private UILabel successLabel; - private UILabel successTipLabel; - private UIButton failedButton; - private UILabel failedIconLabel; - private UILabel failedLabel; - private UILabel failedTipLabel; - - //保留全部 - private UIRadioButton moveAllButton; - //默认选项,保留部分 - private UIRadioButton moveDefaultButton; - //全部放弃 - private UIRadioButton moveNothingButton; - - private UISpinner spinner; - - - public VcsMovePanel(CardLayout cardLayout, JPanel parentPane) { - this.parentCard = cardLayout; - this.parentPane = parentPane; - this.setLayout(new BorderLayout()); - JPanel updatePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); - updatePane.setBackground(BACK_GROUND_COLOR); - //初始化迁移的面板 - initVcsLabel(updatePane); - //initVcsChoosePane - initVcsChoosePane(); - //初始化listener - initListener(); - this.add(updatePane); - checkVisible(); - //如果已经在迁移 - if (VcsMoveService.getInstance().isMoving()) { - initProcessPane(); - VcsMovePanel.this.getParentCard().show(getParentPane(), PROCESS); - } - } - - private void checkVisible() { - new SwingWorker() { - @Override - protected Boolean doInBackground() throws Exception { - return VcsHelper.getInstance().checkMoveFunctionSupport(); - } - @Override - protected void done() { - try { - boolean useMove = get(); - VcsMovePanel.this.setVisible(useMove); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - } - }.execute(); - } - - private void initProcessPane() { - JPanel processPane = new JPanel(); - JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - progressBar.setStringPainted(true); - progressBar.setUI(new ModernUIProgressBarUI()); - progressBar.setBorderPainted(false); - progressBar.setOpaque(false); - progressBar.setBorder(null); - progressBar.setSize(BasicDialog.MEDIUM); - body.add(progressBar); - body.add(new UILabel(StringUtils.BLANK)); - tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_While_Moving")); - tipLabel.setAlignmentX(CENTER_ALIGNMENT); - body.add(tipLabel); - processPane.add(body); - processPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); - parentPane.add(processPane, PROCESS); - } - - private void initVcsChoosePane() { - choosePane = new BasicPane() { - @Override - protected String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Vcs_Deal_With_Entry"); - } - }; - VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP); - layout.setAlignLeft(true); - choosePane.setLayout(layout); - - //初始化上方的文字板块 - initTopDesc(); - //初始化中间区域的单选框 - initRadioButton(); - //初始化下方的Tip描述 - initTipDesc(); - } - - private void initTopDesc() { - UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_How_To_Deal_With_Entry")); - choosePane.add(label); - } - - private void initTipDesc() { - UILabel descLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Desc")); - descLabel.setForeground(TIP_COLOR); - choosePane.add(descLabel); - } - - private void initRadioButton() { - //保留全部 - moveAllButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_All")); - //默认选项,保留部分 - moveDefaultButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Default")); - //全部放弃 - moveNothingButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Nothing")); - // 将按钮"保留部分"设置为选中状态 - moveDefaultButton.setSelected(true); - // 创建一个按钮组,添加三个按钮 - ButtonGroup buttonGroup = new ButtonGroup(); - buttonGroup.add(moveAllButton); - buttonGroup.add(moveDefaultButton); - buttonGroup.add(moveNothingButton); - - JPanel moveDefaultPanel = new JPanel(); - JPanel moveAllPane = new JPanel(); - JPanel moveNothingPane = new JPanel(); - moveAllPane.add(moveAllButton); - moveDefaultPanel.add(moveDefaultButton); - moveDefaultPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Default_Text_Left"))); - spinner = new UISpinner(MIN_VALUE, MAX_VALUE, STEP, DEFAULT_VALUE); - moveDefaultPanel.add(spinner); - moveDefaultPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Default_Text_Right"))); - moveNothingPane.add(moveNothingButton); - choosePane.add(moveAllPane); - choosePane.add(moveDefaultPanel); - choosePane.add(moveNothingPane); - } - - private void initVcsLabel(JPanel parent) { - vcsUpdateExistLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/vcs_move_icon.svg")); - vcsUpdateExistLabel.setText(Toolkit.i18nText("Fine-Design_Vcs_Can_Update")); - vcsUpdateFireLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Update")); - vcsUpdateFireLabel.setForeground(LABEL_COLOR); - vcsUpdateFireLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); - parent.add(vcsUpdateExistLabel); - parent.add(vcsUpdateFireLabel); - } - - private void initListener() { - vcsUpdateFireLabel.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - BasicDialog dlg = choosePane.showMediumWindow(SwingUtilities.getWindowAncestor(VcsMovePanel.this), new DialogActionAdapter() { - @Override - public void doOk() { - //进度条面板 - initProcessPane(); - VcsMovePanel.this.getParentCard().next(getParentPane()); - VcsMoveStrategy strategy; - if (moveDefaultButton.isSelected()) { - strategy = VcsMoveStrategy.createNumStrategy((int) spinner.getValue()); - } else if (moveNothingButton.isSelected()) { - strategy = VcsMoveStrategy.ALL_GIVE_UP; - } else { - strategy = VcsMoveStrategy.ALL_RETAIN; - } - new MoveWorker(strategy).execute(); - } - }); - dlg.setVisible(true); - } - }); - } - - private void initSuccessPane() { - JPanel successPane = new JPanel(); - JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - successButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Go")); - iconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_success.svg")); - successLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success")); - successLabel.setFont(FONT); - successTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Success_Tip")); - successTipLabel.setForeground(TIP_COLOR); - body.add(iconLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(successLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(successTipLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(successButton); - successPane.add(body); - successPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); - parentPane.add(successPane, SUCCESS); - iconLabel.setAlignmentX(CENTER_ALIGNMENT); - successLabel.setAlignmentX(CENTER_ALIGNMENT); - successButton.setAlignmentX(CENTER_ALIGNMENT); - successTipLabel.setAlignmentX(CENTER_ALIGNMENT); - } - - - @Override - protected String title4PopupWindow() { - return StringUtils.EMPTY; - } - - public CardLayout getParentCard() { - return parentCard; - } - - public JPanel getParentPane() { - return parentPane; - } - - private void initFailedPane() { - JPanel failedPane = new JPanel(); - JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - failedButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Go")); - failedIconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_failed.svg")); - failedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed")); - failedLabel.setFont(FONT); - failedTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Tip")); - failedTipLabel.setForeground(TIP_COLOR); - body.add(failedIconLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(failedLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(failedTipLabel); - body.add(new UILabel(StringUtils.BLANK)); - body.add(failedButton); - failedPane.add(body); - failedPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f)); - parentPane.add(failedPane, FAILED); - failedIconLabel.setAlignmentX(CENTER_ALIGNMENT); - failedLabel.setAlignmentX(CENTER_ALIGNMENT); - failedButton.setAlignmentX(CENTER_ALIGNMENT); - failedTipLabel.setAlignmentX(CENTER_ALIGNMENT); - } - - - private class MoveWorker extends SwingWorker { - - private VcsMoveStrategy strategy; - - public MoveWorker(VcsMoveStrategy strategy) { - this.strategy = strategy; - } - - @Override - protected Void doInBackground() throws Exception { - try { - //开始迁移 - VcsMoveService.getInstance().startMove(new VcsMoveService.MoveServiceWhileMoving() { - @Override - public void publishProgress() { - int num = VcsMoveService.getInstance().getCurrentMove(); - publish(num); - } - @Override - public void prepare4Move() { - progressBar.setMaximum(VcsMoveService.getInstance().getTotal()); - } - }, strategy); - } catch (Exception e) { - this.cancel(true); - VcsMoveService.getInstance().stopMoving(); - initFailedPane(); - VcsMovePanel.this.getParentCard().show(getParentPane(), FAILED); - FineLoggerFactory.getLogger().error("[VcsV2] Vcs move failed!"); - } - return null; - } - - @Override - protected void process(List chunks) { - progressBar.setValue(chunks.get(chunks.size() - 1)); - } - - @Override - protected void done() { - VcsMoveService.getInstance().stopMoving(); - initSuccessPane(); - VcsMovePanel.this.getParentCard().show(getParentPane(), SUCCESS); - Configurations.update(new WorkerAdaptor(VcsConfig.class) { - @Override - public void run() { - VcsConfig.getInstance().setUseV2(true); - } - }); - VcsManager.getInstance().updateManager(); - } - } - - -} diff --git a/designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg b/designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg deleted file mode 100644 index 6d36a9dc0c..0000000000 --- a/designer-base/src/main/resources/com/fr/design/vcs/move_failed.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/designer-base/src/main/resources/com/fr/design/vcs/move_success.svg b/designer-base/src/main/resources/com/fr/design/vcs/move_success.svg deleted file mode 100644 index 8b92bd8a04..0000000000 --- a/designer-base/src/main/resources/com/fr/design/vcs/move_success.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg b/designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg deleted file mode 100644 index a5ad91d09c..0000000000 --- a/designer-base/src/main/resources/com/fr/design/vcs/vcs_move_icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - From 2614d67ebb456b262dfef8251ee843f7fec5f82f Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 27 Jun 2023 10:06:59 +0800 Subject: [PATCH 46/56] =?UTF-8?q?Revert=20"REPORT-80651=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E4=B8=80=E6=9C=9F=E8=A1=A5=E4=BA=A4"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit be7a11b1033621d9f3914d65a725cd7f5d52b7b6. --- .../design/actions/file/PreferencePane.java | 5 +-- .../DesignerFrameFileDealerPane.java | 9 +--- .../mainframe/vcs/common/VcsHelper.java | 41 ++++--------------- 3 files changed, 10 insertions(+), 45 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index a83bcfd771..46485409bb 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -390,10 +390,7 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); - if (VcsHelper.getInstance().isLegacyMode()) { - // 老版本时才显示gc选项 - vcsPane.add(gcControlPane); - } + vcsPane.add(gcControlPane); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 174655127c..fc2f9c658c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -325,7 +325,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt if (VcsHelper.getInstance().needInit()) { vcsAction = new VcsAction(); - if (!isLegacyOnCluster()) { + if (!WorkContext.getCurrent().isCluster()) { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); } else { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); @@ -509,7 +509,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt private void fireVcsActionChange(boolean enable) { if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() - || isLegacyOnCluster()) { + || WorkContext.getCurrent().isCluster()) { setEnabled(false); return; } @@ -810,11 +810,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } - private boolean isLegacyOnCluster() { - // 老模式且为集群,用于代替之前的只判断集群逻辑 - return WorkContext.getCurrent().isCluster() && VcsHelper.getInstance().isLegacyMode(); - } - private String doCheck (String userInput, String suffix) { String errorMsg = StringUtils.EMPTY; if (selectedOperation.duplicated(userInput, suffix, true)) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index dd7187be23..980ccb5a3a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -12,9 +12,6 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplateActionListener; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.ui.FileVersionTable; -import com.fr.event.Event; -import com.fr.event.EventDispatcher; -import com.fr.event.Listener; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; @@ -23,14 +20,11 @@ import com.fr.report.entity.VcsEntity; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; -import com.fr.workspace.Workspace; -import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.git.config.GcConfig; import javax.swing.Icon; -import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import java.awt.Color; import java.util.List; @@ -61,26 +55,10 @@ public class VcsHelper implements JTemplateActionListener { private final static String SERVICE_NAME_MOVE = "moveVcs"; private static final VcsHelper INSTANCE = new VcsHelper(); - private volatile boolean legacyMode; - public static VcsHelper getInstance() { return INSTANCE; } - private VcsHelper() { - VcsOperator op = WorkContext.getCurrent().get(VcsOperator.class); - // 开了设计器启动页面时一开始取不到VcsOperator,通过下面的切换环境事件再取,这边判断下 - if (op != null) { - legacyMode = op.isLegacyMode(); - } - EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { - @Override - public void on(Event event, Workspace param) { - legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); - } - }); - } - private int containsFolderCounts() { TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { @@ -159,18 +137,20 @@ public class VcsHelper implements JTemplateActionListener { String fileName = getEditingFilename(); VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); - boolean replace = needDeleteVersion(entity); int latestFileVersion = 0; if (entity != null) { latestFileVersion = entity.getVersion(); } if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { - operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); + operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); - List updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); - SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); + FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY))); } else { - operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); + operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); + } + VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndexAndUsername(fileName, getCurrentUsername(), 1); + if (needDeleteVersion(oldEntity)) { + operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion()); } if (GcConfig.getInstance().isGcEnable()) { operator.gc(); @@ -208,13 +188,6 @@ public class VcsHelper implements JTemplateActionListener { moveVcs.shutdown(); } - /** - * 判断是否为老模式 - * @return 是否为老模式 - */ - public boolean isLegacyMode() { - return legacyMode; - } @Override public void templateOpened(JTemplate jt) { From c3434d1c1f9f7d1e3126d9b01b04218b49cfb59f Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 27 Jun 2023 12:09:37 +0800 Subject: [PATCH 47/56] =?UTF-8?q?REPORT-98879=20=E4=BF=AE=E5=A4=8Djxbrowse?= =?UTF-8?q?r7=E5=9C=A8windows=E4=B8=8B=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/jxbrowser/JxUIPane.java | 25 ++++++++++++++++--- .../jxbrowser/NxInterceptRequestCallback.java | 10 ++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java index 1a968551df..efbca4a47e 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java @@ -8,6 +8,7 @@ import com.fr.design.ui.ModernUIConstants; import com.fr.design.ui.ModernUIPane; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; +import com.fr.stable.os.OperatingSystem; import com.fr.web.struct.AssembleComponent; import com.teamdev.jxbrowser.browser.Browser; import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; @@ -47,6 +48,12 @@ import static com.fr.design.ui.ModernUIConstants.WINDOW; */ public class JxUIPane extends ModernUIPane { + /** + * 冒号 + */ + public static final String COLON = ":"; + private static final String COLON_ESCAPE = "\\:"; + private Browser browser; private String namespace = "Pool"; private String variable = "data"; @@ -126,7 +133,7 @@ public class JxUIPane extends ModernUIPane { */ @Override public void redirect(String url) { - browser.navigation().loadUrl(url); + browser.navigation().loadUrl(encodeWindowsPath(url)); } /** @@ -138,7 +145,7 @@ public class JxUIPane extends ModernUIPane { @Override public void redirect(String url, Map map) { setMap(map); - browser.navigation().loadUrl(url); + browser.navigation().loadUrl(encodeWindowsPath(url)); } private void setMap(Map map) { @@ -220,6 +227,18 @@ public class JxUIPane extends ModernUIPane { return Optional.ofNullable(frame.executeJavaScript(name)); } + /** + * 由于自定义scheme目前走的是url,因此路径会被自动转化,比如windows路径下对冒号问题 + * C:\\abc 变成 /C/abc,这里对冒号进行编码转义 + */ + private static String encodeWindowsPath(String path) { + if (OperatingSystem.isWindows() && path.startsWith(EMB_TAG + SCHEME_HEADER)) { + String s = path.split(EMB_TAG + SCHEME_HEADER)[1]; + return EMB_TAG + SCHEME_HEADER + s.replace(COLON, COLON_ESCAPE); + } + return path; + } + /** * JxUIPane 的建造者 * @@ -492,7 +511,7 @@ public class JxUIPane extends ModernUIPane { pane.browser.navigation().on(listenerPair.getFirst(), listenerPair.getSecond()); } if (StringUtils.isNotEmpty(this.url)) { - pane.browser.navigation().loadUrl(this.url); + pane.browser.navigation().loadUrl(encodeWindowsPath(this.url)); } else if (StringUtils.isNotEmpty(this.html)) { pane.browser.mainFrame().ifPresent(f -> f.loadHtml(html)); } diff --git a/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java index 6a578afa6e..ada7b2fff8 100644 --- a/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java +++ b/designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java @@ -20,6 +20,7 @@ import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback; import org.jetbrains.annotations.NotNull; import java.io.InputStream; +import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.Optional; @@ -36,6 +37,8 @@ import static com.fr.design.ui.ModernUIConstants.COMPONENT_TAG; */ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { + private static final String COLON_DECODE_ESCAPE = "/:"; + private static final String SCHEME_SPLIT = ":/"; private Supplier component; private Supplier> renderParameterBuild; @@ -61,7 +64,7 @@ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { @Override public Response on(Params params) { UrlRequest urlRequest = params.urlRequest(); - String path = urlRequest.url(); + String path = urlRequest.url().replace(COLON_DECODE_ESCAPE, JxUIPane.COLON); Optional urlRequestJobOptional; if (path.startsWith(COMPONENT_TAG)) { String text = htmlText(renderParameterBuild.get()); @@ -107,7 +110,10 @@ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { path = path.substring(index + 1); } else { // jxbrowser 7之后,协议会自动补齐双斜杠// - path = path.split(":/")[1]; + int i = path.indexOf(SCHEME_SPLIT); + path = path.substring(i + SCHEME_SPLIT.length()); + // 通过自定义协议之后的url会自动encode一些中文字符,这里做一个decode,否则会导致路径访问失败 + path = URLDecoder.decode(path, StandardCharsets.UTF_8.name()); } return IOUtils.readResource(path); } From eb709d8024cc382020d5ccb379f116aa34d1852c Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 28 Jun 2023 10:37:14 +0800 Subject: [PATCH 48/56] =?UTF-8?q?REPORT-99073=20=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=95=B4=E4=BD=93=E4=BC=98=E5=8C=96-?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=86=85=EF=BC=8C=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E3=80=81=E5=90=AF=E7=94=A8=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 8 ++++ .../design/actions/file/PreferencePane.java | 17 ++++++-- .../fr/design/extra/PluginOperateUtils.java | 41 ++++++++++--------- .../config/DesignerLoginConfigManager.java | 17 ++++++++ .../com/fr/design/os/impl/PMDialogAction.java | 12 ++++-- .../java/com/fr/design/upm/UpmBridge.java | 7 +++- .../java/com/fr/design/upm/UpmBridgeV7.java | 17 +++++++- 7 files changed, 91 insertions(+), 28 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 199834fb77..43d3edd357 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -1021,6 +1021,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada designerLoginConfigManager.setUseOldVersionLogin(useOldVersionLogin); } + public boolean isUseNewPluginFirst() { + return designerLoginConfigManager.isUseNewPluginFirst(); + } + + public void setUseNewPluginFirst(boolean useNewPluginFirst) { + designerLoginConfigManager.setUseNewPluginFirst(useNewPluginFirst); + } + /** * 内置服务器是否使用时启动 * 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..3da135e7f3 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 @@ -811,8 +811,7 @@ public class PreferencePane extends BasicPane { this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); if (useOptimizedUPMCheckbox != null) { - useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM() - || DesignerEnvManager.getEnvManager().isUseOptimizedUPM4Adapter()); + useOptimizedUPMCheckbox.setSelected(checkOptimizedUPMUse()); } if (useNewVersionLoginCheckbox != null) { @@ -856,6 +855,15 @@ public class PreferencePane extends BasicPane { this.startupPageEnabledCheckBox.setSelected(designerEnvManager.isStartupPageEnabled()); } + private boolean checkOptimizedUPMUse() { + //如果是没手动配置过则默认开启 + //isUseNewPluginFirst如果为true说明没手动配置过,直接开启 + //走到这里说明checkBox不为空,机型肯定符合 + return DesignerEnvManager.getEnvManager().isUseNewPluginFirst() + || ServerPreferenceConfig.getInstance().isUseOptimizedUPM() + || DesignerEnvManager.getEnvManager().isUseOptimizedUPM4Adapter(); + } + private int chooseCase(int sign) { switch (sign) { case 0: @@ -913,7 +921,10 @@ public class PreferencePane extends BasicPane { designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected()); designerEnvManager.setEmbedServerLazyStartup(this.embedServerLazyStartupCheckBox.isSelected()); designerEnvManager.setImageCompress(this.imageCompressPanelCheckBox.isSelected()); - designerEnvManager.setUseOptimizedUPM4Adapter(this.useOptimizedUPMCheckbox != null && this.useOptimizedUPMCheckbox.isSelected()); + boolean optimizedUPMFlag = this.useOptimizedUPMCheckbox != null && this.useOptimizedUPMCheckbox.isSelected(); + designerEnvManager.setUseOptimizedUPM4Adapter(optimizedUPMFlag); + //只有取消掉使用新插件管理器这个选项才需要把useNewPluginFirst置false(意味着用户手动配置了,如果勾选着的话,这个useNewPluginFirst为true就行了) + designerEnvManager.setUseNewPluginFirst(optimizedUPMFlag); designerEnvManager.setCloudAnalyticsDelay(this.cloudAnalyticsDelayCheckBox.isSelected()); VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue()); 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 8baccba847..1248dea6e9 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 @@ -112,27 +112,7 @@ public class PluginOperateUtils { } - /** - * 批量启用或禁用插件 - * - * @param pluginIDs 要处理的插件信息 - * @param jsCallback 回调函数 - */ - public static void setPluginActive(JSArray pluginIDs, JSCallback jsCallback) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - int len = pluginIDs.length(); - BatchModifyStatusCallback modifyStatusCallback = new BatchModifyStatusCallback(jsCallback, len); - for (int i = 0; i < len; i++) { - String pluginInfo = pluginIDs.get(i).asString().getValue(); - PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); - dealWithPluginActive(pluginMarker, modifyStatusCallback); - } - } - }); - } private static void dealWithPluginActive(PluginMarker pluginMarker, BatchModifyStatusCallback modifyStatusCallback) { PluginContext plugin = PluginManager.getContext(pluginMarker); @@ -180,6 +160,27 @@ public class PluginOperateUtils { }); } + /** + * 批量启用或禁用插件 + * + * @param pluginIDs 要处理的插件信息 + * @param jsCallback 回调函数 + */ + public static void setPluginActive(List pluginIDs, JSCallback jsCallback) { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + int len = pluginIDs.size(); + BatchModifyStatusCallback modifyStatusCallback = new BatchModifyStatusCallback(jsCallback, len); + for (String pluginInfo : pluginIDs) { + PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); + dealWithPluginActive(pluginMarker, modifyStatusCallback); + } + } + }); + } + public static void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSCallback jsCallback) { SwingUtilities.invokeLater(new Runnable() { diff --git a/designer-base/src/main/java/com/fr/design/login/config/DesignerLoginConfigManager.java b/designer-base/src/main/java/com/fr/design/login/config/DesignerLoginConfigManager.java index b0fb0e292a..35e97add6a 100644 --- a/designer-base/src/main/java/com/fr/design/login/config/DesignerLoginConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/login/config/DesignerLoginConfigManager.java @@ -75,6 +75,13 @@ public class DesignerLoginConfigManager implements XMLReadable, XMLWriter { */ private boolean useOldVersionLogin = false; + /** + * 是否手动配置过新插件管理 + *
  • 11.0.18版本开始全部认为没有手动配置过,符合机型的都默认开启新插件管理,如果需要关闭需要再次手动配置
  • + *
  • 如果手动配置过则置为false
  • + */ + private boolean useNewPluginFirst = true; + private DesignerLoginConfigManager() { } @@ -103,6 +110,7 @@ public class DesignerLoginConfigManager implements XMLReadable, XMLWriter { this.setLoginRemindBeforeJumpBBS(reader.getAttrAsBoolean("loginRemindBeforeJumpBBS", true)); this.setPluginRemindOnFirstLaunch(reader.getAttrAsBoolean("pluginRemindOnFirstLaunch", true)); this.setUseOldVersionLogin(reader.getAttrAsBoolean("useOldVersionLogin", false)); + this.setUseNewPluginFirst(reader.getAttrAsBoolean("useNewPluginFirst", true)); } } @@ -123,6 +131,7 @@ public class DesignerLoginConfigManager implements XMLReadable, XMLWriter { writer.attr("loginRemindBeforeJumpBBS", loginRemindBeforeJumpBBS); writer.attr("pluginRemindOnFirstLaunch", pluginRemindOnFirstLaunch); writer.attr("useOldVersionLogin", useOldVersionLogin); + writer.attr("useNewPluginFirst", useNewPluginFirst); writer.end(); } @@ -237,4 +246,12 @@ public class DesignerLoginConfigManager implements XMLReadable, XMLWriter { public void setUseOldVersionLogin(boolean useOldVersionLogin) { this.useOldVersionLogin = useOldVersionLogin; } + + public boolean isUseNewPluginFirst() { + return useNewPluginFirst; + } + + public void setUseNewPluginFirst(boolean useNewPluginFirst) { + this.useNewPluginFirst = useNewPluginFirst; + } } diff --git a/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java index 16944da068..d4daa8f8bd 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java @@ -24,12 +24,18 @@ public class PMDialogAction implements OSBasedAction { DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null); return; } - if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM() - || SupportOSImpl.MACOS_NEW_PLUGIN_MANAGEMENT.support() - || DesignerEnvManager.getEnvManager().isUseOptimizedUPM4Adapter()) { + if (checkUPMSupport()) { UpmFinder.showUPMDialog(); } else { WebViewDlgHelper.createPluginDialog(); } } + + private boolean checkUPMSupport() { + return ServerPreferenceConfig.getInstance().isUseOptimizedUPM() + || SupportOSImpl.MACOS_NEW_PLUGIN_MANAGEMENT.support() + || DesignerEnvManager.getEnvManager().isUseOptimizedUPM4Adapter() + //默认开启 + || DesignerEnvManager.getEnvManager().isUseNewPluginFirst(); + } } 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 34ae1ac002..8f44ae197e 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 @@ -306,7 +306,12 @@ public class UpmBridge { @JSBridge public void setAllPluginActive(JSArray pluginIDs, final JSFunction callback) { JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); - PluginOperateUtils.setPluginActive(pluginIDs, jsCallback); + List list = new ArrayList<>(); + int len = pluginIDs.length(); + for (int i = 0; i < len; i++) { + list.add(pluginIDs.get(i).asString().getValue()); + } + PluginOperateUtils.setPluginActive(list, jsCallback); } /** diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java b/designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java index a7714621b7..f35ed11ac0 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java @@ -28,7 +28,7 @@ import com.fr.stable.StringUtils; import com.teamdev.jxbrowser.js.JsAccessible; import com.teamdev.jxbrowser.js.JsFunction; import com.teamdev.jxbrowser.js.JsObject; - +import com.teamdev.jxbrowser.js.internal.JsArrayImpl; import javax.swing.JFileChooser; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; @@ -265,6 +265,21 @@ public class UpmBridgeV7 extends UpmBridge { PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback); } + /** + * 批量修改选中的插件的活跃状态 + * + * @param pluginIDs 要处理的插件ID + * @param callback 回调函数 + */ + @JSBridge + @JsAccessible + public void setAllPluginActive(JsObject pluginIDs, final JsFunction callback) { + JSCallback jsCallback = new JSCallback(NewUpmBrowserExecutor.create(jsObject, callback)); + List array = ((JsArrayImpl) pluginIDs).toList(); + PluginOperateUtils.setPluginActive(array, jsCallback); + } + + /** * 从插件服务器上安装插件 * From 9c6f4c90cd115ca0103109cd86067db07f76761a Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 29 Jun 2023 09:48:16 +0800 Subject: [PATCH 49/56] =?UTF-8?q?REPORT-97972=20=E3=80=90FR=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E3=80=91=E6=96=87=E5=AD=97=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cell/settingpane/CellOtherSetPane.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 5ac64d401a..03ec887fd8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -357,7 +357,8 @@ public class CellOtherSetPane extends AbstractCellAttrPane { showPartPane = new JPanel(showPartLayout); showCharNums = new UISpinner(0, Integer.MAX_VALUE, 1, 10); JPanel showPartNumPane = new JPanel(new BorderLayout(4, 0)); - showPartNumPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums")), BorderLayout.WEST); + UILabel showCharLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums") + ":"); + showPartNumPane.add(showCharLabel, BorderLayout.WEST); showPartNumPane.add(showCharNums, BorderLayout.CENTER); showPartPane.add(new JPanel(), "none"); showPartPane.add(showPartNumPane, "content"); @@ -377,12 +378,20 @@ public class CellOtherSetPane extends AbstractCellAttrPane { textOverflowTypeComboBox = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Ellipsis"), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_NoneSymbol")}); UILabel showPartLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_ShowPart") + ":"); + showCharLabel.setPreferredSize(new Dimension(showPartLabel.getPreferredSize().width, 15)); + JPanel pane = new JPanel(new BorderLayout(4, 0)); + pane.add(showPartLabel, BorderLayout.WEST); + pane.add(showPartComboBox, BorderLayout.CENTER); UILabel hideTypeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideType") + ":"); + JPanel hidePane = new JPanel(new BorderLayout(4, 0)); + hidePane.add(hideTypeLabel, BorderLayout.WEST); + hidePane.add(textOverflowTypeComboBox, BorderLayout.CENTER); Component[][] textOverflowComponents = new Component[][]{ - new Component[]{showPartLabel, showPartComboBox, showPartPane}, - new Component[]{hideTypeLabel, textOverflowTypeComboBox, null} + new Component[]{pane}, + new Component[]{showPartPane}, + new Component[]{hidePane} }; - JPanel textOverflowComPane = TableLayoutHelper.createTableLayoutPane(textOverflowComponents, new double[]{p, p}, new double[]{p, f, p}); + JPanel textOverflowComPane = TableLayoutHelper.createTableLayoutPane(textOverflowComponents, new double[]{p, p, p}, new double[]{p, f, p}); textOverflowComPane.setVisible(false); textOverflowCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideWhenOverflow")); textOverflowCheckBox.addItemListener(new ItemListener() { From a417d401af5d6712119826455096edeec28e4b95 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 29 Jun 2023 14:16:19 +0800 Subject: [PATCH 50/56] =?UTF-8?q?REPORT-97972=20=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=E8=87=AA=E5=B7=B1=E4=BB=A3=E7=A0=81=E5=BA=93?= =?UTF-8?q?=E7=9A=84=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cell/settingpane/CellOtherSetPane.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 03ec887fd8..101ee470d7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -357,8 +357,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { showPartPane = new JPanel(showPartLayout); showCharNums = new UISpinner(0, Integer.MAX_VALUE, 1, 10); JPanel showPartNumPane = new JPanel(new BorderLayout(4, 0)); - UILabel showCharLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums") + ":"); - showPartNumPane.add(showCharLabel, BorderLayout.WEST); + showPartNumPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums")), BorderLayout.WEST); showPartNumPane.add(showCharNums, BorderLayout.CENTER); showPartPane.add(new JPanel(), "none"); showPartPane.add(showPartNumPane, "content"); @@ -378,18 +377,10 @@ public class CellOtherSetPane extends AbstractCellAttrPane { textOverflowTypeComboBox = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Ellipsis"), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_NoneSymbol")}); UILabel showPartLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_ShowPart") + ":"); - showCharLabel.setPreferredSize(new Dimension(showPartLabel.getPreferredSize().width, 15)); - JPanel pane = new JPanel(new BorderLayout(4, 0)); - pane.add(showPartLabel, BorderLayout.WEST); - pane.add(showPartComboBox, BorderLayout.CENTER); UILabel hideTypeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideType") + ":"); - JPanel hidePane = new JPanel(new BorderLayout(4, 0)); - hidePane.add(hideTypeLabel, BorderLayout.WEST); - hidePane.add(textOverflowTypeComboBox, BorderLayout.CENTER); Component[][] textOverflowComponents = new Component[][]{ - new Component[]{pane}, - new Component[]{showPartPane}, - new Component[]{hidePane} + new Component[]{showPartLabel, showPartComboBox, showPartPane}, + new Component[]{hideTypeLabel, textOverflowTypeComboBox, null} }; JPanel textOverflowComPane = TableLayoutHelper.createTableLayoutPane(textOverflowComponents, new double[]{p, p, p}, new double[]{p, f, p}); textOverflowComPane.setVisible(false); From 6c98902cb3bde07d3d48705526ac4ee706be9632 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 29 Jun 2023 14:17:01 +0800 Subject: [PATCH 51/56] =?UTF-8?q?REPORT-97972=20=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=E8=87=AA=E5=B7=B1=E4=BB=A3=E7=A0=81=E5=BA=93?= =?UTF-8?q?=E7=9A=84=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/cell/settingpane/CellOtherSetPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 101ee470d7..5ac64d401a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -382,7 +382,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { new Component[]{showPartLabel, showPartComboBox, showPartPane}, new Component[]{hideTypeLabel, textOverflowTypeComboBox, null} }; - JPanel textOverflowComPane = TableLayoutHelper.createTableLayoutPane(textOverflowComponents, new double[]{p, p, p}, new double[]{p, f, p}); + JPanel textOverflowComPane = TableLayoutHelper.createTableLayoutPane(textOverflowComponents, new double[]{p, p}, new double[]{p, f, p}); textOverflowComPane.setVisible(false); textOverflowCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideWhenOverflow")); textOverflowCheckBox.addItemListener(new ItemListener() { From f2101b9c00507dcd7e213daabfd2125fa22c1532 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 29 Jun 2023 14:34:35 +0800 Subject: [PATCH 52/56] =?UTF-8?q?REPORT-99332=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=96=87=E6=9C=AC=E8=BE=93=E5=85=A5=E6=A1=86=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E8=A2=AB=E8=87=AA=E5=8A=A8=E7=A7=BB=E9=99=A4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20rt=EF=BC=8C=20=E6=8A=8A=20trim=20=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/quickeditor/cellquick/CellStringQuickEditor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java index 126486d13e..29ed7f22c6 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java @@ -37,17 +37,17 @@ public class CellStringQuickEditor extends CellQuickEditor { private DocumentListener documentListener = new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { - changeReportPaneCell(stringTextArea.getText().trim()); + changeReportPaneCell(stringTextArea.getText()); } @Override public void removeUpdate(DocumentEvent e) { - changeReportPaneCell(stringTextArea.getText().trim()); + changeReportPaneCell(stringTextArea.getText()); } @Override public void changedUpdate(DocumentEvent e) { - changeReportPaneCell(stringTextArea.getText().trim()); + changeReportPaneCell(stringTextArea.getText()); } }; From 5c3377d146374d8fa2f6b1df482c81e80c62c874 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 29 Jun 2023 15:13:23 +0800 Subject: [PATCH 53/56] =?UTF-8?q?REPORT-99320=20=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=95=B4=E4=BD=93=E4=BC=98=E5=8C=96-?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=86=85=E5=8D=95=E4=B8=AA=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=9B=B4=E6=96=B0=E7=9A=84=E6=8F=90=E7=A4=BA=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=98=BE=E7=A4=BA=E5=93=AA=E4=B8=AA=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=8C=E5=92=8C=E5=B9=B3=E5=8F=B0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=96=87=E6=9C=AC=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/extra/PluginOperateUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1248dea6e9..d2f1bcc3c2 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 @@ -70,7 +70,7 @@ public class PluginOperateUtils { public static void updatePluginOnline(List pluginMarkerList, JSCallback jsCallback) { int size = pluginMarkerList.size(); - BatchUpdateOnlineCallback batchUpdateOnlineCallback = new BatchUpdateOnlineCallback(jsCallback, size); + BatchUpdateOnlineCallback batchUpdateOnlineCallback = size <= 1 ? BatchUpdateOnlineCallback.NONE : new BatchUpdateOnlineCallback(jsCallback, size); for (int i = 0; i < size; i++) { updatePluginOnline(pluginMarkerList.get(i), jsCallback, batchUpdateOnlineCallback); } From 654c82e2b2f768a6c62be5c5ea90aa91d94bbad6 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 29 Jun 2023 16:06:07 +0800 Subject: [PATCH 54/56] =?UTF-8?q?REPORT-97591=20=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=AE=BE=E7=BD=AE=E9=A2=9C=E8=89=B2=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8E=92=E5=BA=8F=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=B9=B6=E5=85=B3=E9=97=AD=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=EF=BC=8C=E5=86=8D=E6=AC=A1=E6=89=93=E5=BC=80=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=A2=9C=E8=89=B2=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sort/header/HeaderSortRulePane.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java index 01021ed091..0c05d75608 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java @@ -24,6 +24,8 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; public class HeaderSortRulePane extends JPanel { IconButton ascIconButton; @@ -37,7 +39,7 @@ public class HeaderSortRulePane extends JPanel { HeaderSortRulePane() { initComponents(); - initState(true); + initState(true, null); this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); } @@ -78,13 +80,24 @@ public class HeaderSortRulePane extends JPanel { }); } - void initState(boolean selected) { + void initState(boolean selected, SortHeader.SortItem[] items) { ascUICheckBox.setSelected(selected); desUICheckBox.setSelected(selected); nosortUICheckBox.setSelected(selected); - ascIconButton.refreshIconLabelColor(new FineColor(defaultColor)); - desIconButton.refreshIconLabelColor(new FineColor(defaultColor)); - nosortIconButton.refreshIconLabelColor(new FineColor(defaultColor)); + if(items==null){ + ascIconButton.refreshIconLabelColor(new FineColor(defaultColor)); + desIconButton.refreshIconLabelColor(new FineColor(defaultColor)); + nosortIconButton.refreshIconLabelColor(new FineColor(defaultColor)); + } else { + Map colorMap = new HashMap<>(items.length); + for (SortHeader.SortItem item : items) { + colorMap.put(item.getSortRule(), item.getFineColor()); + } + ascIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.ASC, new FineColor(defaultColor))); + desIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.DES, new FineColor(defaultColor))); + nosortIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.NO_SORT, new FineColor(defaultColor))); + } + } class IconButton extends JPanel implements UIObserver, PopupHider { @@ -217,7 +230,7 @@ public class HeaderSortRulePane extends JPanel { } public void populateBean(SortHeader.SortItem[] sortItems) { - initState(sortItems == null); + initState(sortItems == null, sortItems); if (sortItems != null) { for (SortHeader.SortItem sortItem : sortItems) { SortRule sortRule = sortItem.getSortRule(); From d54982191796796accf56f822a00a99d6ac309b9 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 29 Jun 2023 17:02:36 +0800 Subject: [PATCH 55/56] =?UTF-8?q?REPORT-97591=20=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=AE=BE=E7=BD=AE=E9=A2=9C=E8=89=B2=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8E=92=E5=BA=8F=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=B9=B6=E5=85=B3=E9=97=AD=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=EF=BC=8C=E5=86=8D=E6=AC=A1=E6=89=93=E5=BC=80=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=A2=9C=E8=89=B2=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sort/header/HeaderSortRulePane.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java index 0c05d75608..a85238acbd 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java @@ -39,7 +39,7 @@ public class HeaderSortRulePane extends JPanel { HeaderSortRulePane() { initComponents(); - initState(true, null); + initState(true); this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); } @@ -80,24 +80,13 @@ public class HeaderSortRulePane extends JPanel { }); } - void initState(boolean selected, SortHeader.SortItem[] items) { + void initState(boolean selected) { ascUICheckBox.setSelected(selected); desUICheckBox.setSelected(selected); nosortUICheckBox.setSelected(selected); - if(items==null){ - ascIconButton.refreshIconLabelColor(new FineColor(defaultColor)); - desIconButton.refreshIconLabelColor(new FineColor(defaultColor)); - nosortIconButton.refreshIconLabelColor(new FineColor(defaultColor)); - } else { - Map colorMap = new HashMap<>(items.length); - for (SortHeader.SortItem item : items) { - colorMap.put(item.getSortRule(), item.getFineColor()); - } - ascIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.ASC, new FineColor(defaultColor))); - desIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.DES, new FineColor(defaultColor))); - nosortIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.NO_SORT, new FineColor(defaultColor))); - } - + ascIconButton.refreshIconLabelColor(new FineColor(defaultColor)); + desIconButton.refreshIconLabelColor(new FineColor(defaultColor)); + nosortIconButton.refreshIconLabelColor(new FineColor(defaultColor)); } class IconButton extends JPanel implements UIObserver, PopupHider { @@ -230,19 +219,23 @@ public class HeaderSortRulePane extends JPanel { } public void populateBean(SortHeader.SortItem[] sortItems) { - initState(sortItems == null, sortItems); + initState(sortItems == null); if (sortItems != null) { for (SortHeader.SortItem sortItem : sortItems) { SortRule sortRule = sortItem.getSortRule(); BufferedImage bufferedImage = sortItem.getBufferedImage(); + FineColor fineColor = sortItem.getFineColor(); if (sortRule == SortRule.ASC) { ascIconButton.refreshIconLabel(bufferedImage); + ascIconButton.refreshIconLabelColor(fineColor); ascUICheckBox.setSelected(true); } else if (sortRule == SortRule.DES) { desIconButton.refreshIconLabel(bufferedImage); + desIconButton.refreshIconLabelColor(fineColor); desUICheckBox.setSelected(true); } else if (sortRule == SortRule.NO_SORT) { nosortIconButton.refreshIconLabel(bufferedImage); + nosortIconButton.refreshIconLabelColor(fineColor); nosortUICheckBox.setSelected(true); } } From 6771a4e5c86ee69d500e87210b0426f33b66288a Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 29 Jun 2023 17:09:20 +0800 Subject: [PATCH 56/56] =?UTF-8?q?REPORT-97591=20=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=AE=BE=E7=BD=AE=E9=A2=9C=E8=89=B2=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8E=92=E5=BA=8F=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=B9=B6=E5=85=B3=E9=97=AD=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=EF=BC=8C=E5=86=8D=E6=AC=A1=E6=89=93=E5=BC=80=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=A2=9C=E8=89=B2=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/sort/header/HeaderSortRulePane.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java index a85238acbd..d18a73f5d3 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java @@ -24,8 +24,6 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; public class HeaderSortRulePane extends JPanel { IconButton ascIconButton;