From 25fd375c88e25af5f73ff3a3dce64916d79d134c Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 21 Dec 2020 15:29:02 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 19 +++ .../fr/design/extra/PluginOperateUtils.java | 43 +++-- .../java/com/fr/design/extra/PluginUtils.java | 3 +- .../exe/callback/InstallFromDiskCallback.java | 17 +- .../exe/callback/InstallOnlineCallback.java | 16 +- .../exe/callback/ModifyStatusCallback.java | 14 +- .../exe/callback/UninstallPluginCallback.java | 19 ++- .../exe/callback/UpdateFromDiskCallback.java | 22 +-- .../exe/callback/UpdateOnlineCallback.java | 12 +- .../com/fr/env/PluginErrorRemindDialog.java | 108 ++++++++++++ .../com/fr/design/EnvChangeEntranceTest.java | 62 +++++-- .../design/extra/PluginOperateUtilsTest.java | 155 ++++++++++++++++++ .../com/fr/design/extra/PluginUtilsTest.java | 23 +++ .../manager/impl/PluginSearchManager.java | 3 +- .../module/DesignerWorkspaceProvider.java | 1 + .../manager/impl/PluginSearchManagerTest.java | 25 +++ 16 files changed, 476 insertions(+), 66 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java create mode 100644 designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java create mode 100644 designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java create mode 100644 designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 0ddb749269..ed67299f6d 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -1,6 +1,7 @@ package com.fr.design; import com.fr.common.report.ReportState; +import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -35,6 +36,7 @@ import com.fr.process.engine.core.FineProcessContext; import com.fr.rpc.Result; import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; +import com.fr.env.PluginErrorRemindDialog; import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; @@ -144,6 +146,7 @@ public class EnvChangeEntrance { template.refreshToolArea(); } showServiceDialog(selectedEnv); + pluginErrorRemind(selectedEnv); } catch (WorkspaceAuthException | RegistEditionException e) { // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); @@ -297,6 +300,22 @@ public class EnvChangeEntrance { } } + /** + * 插件启动错误信息提示 + * @param selectedEnv 选择的工作环境 + */ + public void pluginErrorRemind(DesignerWorkspaceInfo selectedEnv) { + if (selectedEnv.getType() == DesignerWorkspaceType.Remote) { + return; + } + + String content = PluginErrorRemindHandler.pluginErrorContent(); + if (StringUtils.isNotEmpty(content)) { + PluginErrorRemindDialog dialog = new PluginErrorRemindDialog(DesignerContext.getDesignerFrame(), content); + dialog.setVisible(true); + } + } + /** * 判断是否需要做版本验证,判断依据为 * 1、选择的环境为远程环境 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 801b4e369a..46683e0a05 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 @@ -18,6 +18,7 @@ import com.fr.json.JSONObject; 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.PluginControllerHelper; import com.fr.plugin.manage.control.PluginTask; @@ -26,7 +27,8 @@ import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import java.io.File; import java.net.HttpURLConnection; import java.util.List; @@ -38,11 +40,23 @@ import java.util.List; public class PluginOperateUtils { public static void installPluginOnline(final PluginMarker pluginMarker, JSCallback jsCallback) { + PluginMarker marker = updateMarker2Online(pluginMarker); //下载插件 - PluginTask pluginTask = PluginTask.installTask(pluginMarker); + PluginTask pluginTask = PluginTask.installTask(marker); PluginControllerHelper.installOnline(pluginMarker, new InstallOnlineCallback(pluginTask, jsCallback)); } + public static PluginMarker updateMarker2Online(PluginMarker pluginMarker) { + try { + JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); + String pluginName = latestPluginInfo.getString("name"); + return PluginMarkerAdapter.create(pluginMarker, pluginName); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return pluginMarker; + } + public static void installPluginFromDisk(File zipFile, JSCallback jsCallback) { PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback)); } @@ -57,10 +71,11 @@ public class PluginOperateUtils { public static void updatePluginOnline(PluginMarker pluginMarker, JSCallback jsCallback) { try { JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); - String latestPluginVersion = (String) latestPluginInfo.get("version"); - PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion); + String latestPluginVersion = latestPluginInfo.getString("version"); + String pluginName = latestPluginInfo.getString("name"); + PluginMarker toPluginMarker = PluginMarkerAdapter.create(pluginMarker.getPluginID(), latestPluginVersion, pluginName); //当前已经安装的相同ID插件marker - PluginMarker currentMarker = PluginUtils.getInstalledPluginMarkerByID(pluginMarker.getPluginID()); + PluginMarker currentMarker = PluginMarkerAdapter.create(PluginUtils.getInstalledPluginMarkerByID(pluginMarker.getPluginID()), pluginName); PluginTask pluginTask = PluginTask.updateTask(currentMarker, toPluginMarker); PluginControllerHelper.updateOnline(currentMarker, toPluginMarker, new UpdateOnlineCallback(pluginTask, jsCallback)); } catch (Exception e) { @@ -203,16 +218,22 @@ public class PluginOperateUtils { continue; } PluginMarker pluginMarker = pluginTask.getToMarker(); - PluginContext pluginContext = PluginManager.getContext(pluginMarker); - if (pluginContext != null) { - pluginInfo.append(pluginContext.getName()).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); - } else { - pluginInfo.append(pluginMarker.getPluginID()).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); - } + PluginContext pluginContext = PluginManager.getContext(pluginMarker.getPluginID()); + pluginInfo.append(getPluginName(pluginContext, pluginMarker)).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); } return pluginInfo.toString(); } + private static String getPluginName(PluginContext pluginContext, PluginMarker pluginMarker) { + if (pluginContext != null) { + return pluginContext.getName(); + } + else if (pluginMarker instanceof PluginMarkerAdapter) { + return ((PluginMarkerAdapter) pluginMarker).getPluginName(); + } + return pluginMarker == null ? null : pluginMarker.getPluginID(); + } + public static String getSwitchedInfo(PluginTaskResult result) { StringBuilder pluginInfo = new StringBuilder(); List pluginTaskResults = result.asList(); diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index bec02a200e..81f4769616 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -10,6 +10,7 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.PluginVerifyException; import com.fr.plugin.basic.version.Version; +import com.fr.plugin.basic.version.VersionCompatibleType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; @@ -248,7 +249,7 @@ public class PluginUtils { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); + return VersionCompatibleType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 19bd89ef10..14a6de9421 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -3,7 +3,7 @@ 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.PluginOperateUtils; -import com.fr.design.extra.PluginUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -12,7 +12,7 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; import java.io.File; import java.util.List; @@ -41,8 +41,9 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); - FineJOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo; + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { int rv = JOptionPane.showOptionDialog( null, @@ -66,8 +67,8 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -80,8 +81,8 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { PluginOperateUtils.updatePluginFromDisk(zipFile, jsCallback); }else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index f597180e87..38c1bc7802 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -3,6 +3,7 @@ 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.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -11,7 +12,7 @@ import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; /** @@ -38,13 +39,14 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { if (result.isSuccess()) { String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); - FineJOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo; + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -58,8 +60,8 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { PluginOperateUtils.updatePluginOnline(pluginMarker, jsCallback); }else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java index c48a47faeb..8015e00fbd 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java @@ -2,12 +2,14 @@ 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.PluginUtils; +import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.manage.control.PluginTaskCallback; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; /** * Created by ibm on 2017/5/27. @@ -22,12 +24,16 @@ public class ModifyStatusCallback implements PluginTaskCallback{ } @Override public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { jsCallback.execute("success"); - String modifyMessage = isActive ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); + 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); FineJOptionPane.showMessageDialog(null, modifyMessage); } else { - FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java index b3773ef6f9..bfa921125d 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java @@ -2,7 +2,8 @@ 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.PluginUtils; +import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -10,7 +11,7 @@ import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; /** * Created by ibm on 2017/5/27. @@ -25,15 +26,17 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { @Override public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success")); - FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success")); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success"); + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); }else if (result.errorCode() == PluginErrorCode.NeedUninstallDependingPluginFirst) { int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Dependence"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Dependence"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -46,8 +49,8 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { PluginManager.getController().uninstall(pluginMarker, true, new UninstallPluginCallback(pluginMarker, jsCallback)); } else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed")); - FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index 7cced40f0b..551d944888 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -3,7 +3,7 @@ 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.PluginOperateUtils; -import com.fr.design.extra.PluginUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -12,7 +12,7 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; import java.io.File; import java.util.List; @@ -37,15 +37,17 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { @Override public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); - FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"); + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Dependence"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Dependence"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -64,8 +66,8 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { } else if(result.errorCode() == PluginErrorCode.NoPluginToUpdate){ int rv = JOptionPane.showOptionDialog( null, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_No_Plugin_Update"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_No_Plugin_Update"), + Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -78,8 +80,8 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { PluginOperateUtils.installPluginFromDisk(zipFile, jsCallback); }else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index 69998a3169..deeed74974 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -3,13 +3,14 @@ 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.PluginOperateUtils; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.*; +import javax.swing.JOptionPane; /** * Created by ibm on 2017/5/26. @@ -33,12 +34,13 @@ public class UpdateOnlineCallback extends AbstractDealPreTaskCallback { String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); - FineJOptionPane.showMessageDialog(null,pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"); + FineLoggerFactory.getLogger().info(successInfo); + FineJOptionPane.showMessageDialog(null, successInfo); } else { jsCallback.execute("failed"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java b/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java new file mode 100644 index 0000000000..3654cca2d9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java @@ -0,0 +1,108 @@ +package com.fr.env; + +import com.fr.design.actions.server.PluginManagerAction; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Locale; + +/** + * 插件启动失败提示窗 + */ +public class PluginErrorRemindDialog extends JDialog implements ActionListener { + + public PluginErrorRemindDialog(Frame parent, String areaText) { + super(parent, true); + //上面的标签面板 + JPanel topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel imagePanel = new JPanel(); + Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning5.png"); + + JLabel imageLabel = new JLabel(); + imageLabel.setIcon(icon); + imagePanel.add(imageLabel); + imagePanel.setPreferredSize(new Dimension(130, 100)); + + JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + + JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Title")); + label.setFont(FRFont.getInstance().applySize(18).applyStyle(1)); + label.setPreferredSize(new Dimension(650, 100)); + + verticalPanel.add(label); + + topPanel.add(imagePanel, BorderLayout.WEST); + topPanel.add(verticalPanel, BorderLayout.CENTER); + topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); + + //中间的文本域面板 + JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); + centerPanel.setPreferredSize(new Dimension(480, 320)); + + JTextArea checkArea = new JTextArea(areaText); + checkArea.setEnabled(false); + centerPanel.add(checkArea, BorderLayout.CENTER); + + UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Not_Deal_With")); + UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Deal_With")); + + cancelButton.addActionListener(this); + okButton.addActionListener(new PluginManagerActionAdapter(this)); + + // 按钮 + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); + buttonPanel.add(cancelButton); + buttonPanel.add(okButton); + + + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")); + this.setResizable(false); + + this.add(topPanel, BorderLayout.NORTH); + this.add(centerPanel, BorderLayout.CENTER); + this.add(buttonPanel, BorderLayout.SOUTH); + this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 750 : 600, 500)); + + GUICoreUtils.centerWindow(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + this.dispose(); + } + + private static class PluginManagerActionAdapter extends PluginManagerAction { + + private JDialog jDialog; + + public PluginManagerActionAdapter(JDialog jDialog) { + this.jDialog = jDialog; + } + + @Override + public void actionPerformed(ActionEvent e) { + this.jDialog.dispose(); + super.actionPerformed(e); + } + } + +} diff --git a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java index d9d6e44844..7f53d05ded 100644 --- a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java +++ b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java @@ -1,10 +1,12 @@ package com.fr.design; +import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.env.CheckServiceDialog; +import com.fr.env.PluginErrorRemindDialog; import com.fr.invoke.Reflect; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; @@ -16,13 +18,19 @@ import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.awt.Frame; + /** * @author: Maksim * @Date: Created in 2020/3/5 * @Description: */ @RunWith(PowerMockRunner.class) -@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class, DesignerEnvManager.class}) +@PrepareForTest({FunctionalHttpRequest.class, + EnvChangeEntrance.class, + CheckServiceDialog.class, + DesignerEnvManager.class, + PluginErrorRemindHandler.class}) public class EnvChangeEntranceTest { @Test @@ -44,17 +52,15 @@ public class EnvChangeEntranceTest { EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch); CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class); - PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject()).andReturn(dialog); + PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString()).andReturn(dialog); - EasyMock.replay(request); - EasyMock.replay(selectedEnv); - EasyMock.replay(connectionInfo); + EasyMock.replay(request, selectedEnv, connectionInfo); PowerMock.replayAll(); entrance.showServiceDialog(selectedEnv); - Assert.assertTrue(true); + }catch (Exception e){ - Assert.assertTrue(false); + Assert.fail(); } } @@ -94,10 +100,44 @@ public class EnvChangeEntranceTest { DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path"); DesignerWorkspaceInfo info4 = null; - Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info1).get()); - Assert.assertTrue((boolean) Reflect.on(entrance).call("isNotRememberPwd", info2).get()); - Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info3).get()); - Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info4).get()); + Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info1).get()); + Assert.assertTrue(Reflect.on(entrance).call("isNotRememberPwd", info2).get()); + Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info3).get()); + Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info4).get()); } + @Test + public void testPluginErrorRemind() throws Exception { + + try { + DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class); + EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote).once(); + EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Local).times(2); + + PowerMock.mockStatic(PluginErrorRemindHandler.class); + EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once(); + EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("111").once(); + + PluginErrorRemindDialog dialog = EasyMock.mock(PluginErrorRemindDialog.class); + PowerMock.expectNew(PluginErrorRemindDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString()).andReturn(dialog).once(); + + dialog.setVisible(true); + EasyMock.expectLastCall(); + + EasyMock.replay(selectedEnv, dialog); + PowerMock.replayAll(); + + EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); + + entrance.pluginErrorRemind(selectedEnv); + entrance.pluginErrorRemind(selectedEnv); + entrance.pluginErrorRemind(selectedEnv); + + + EasyMock.verify(selectedEnv, dialog); + PowerMock.verifyAll(); + } catch (Exception e) { + Assert.fail(); + } + } } \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java b/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java new file mode 100644 index 0000000000..887cde43e0 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java @@ -0,0 +1,155 @@ +package com.fr.design.extra; + +import com.fr.invoke.Reflect; +import com.fr.json.JSONObject; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.context.PluginMarkerAdapter; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTask; +import com.fr.plugin.manage.control.PluginTaskResult; +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.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/12/17 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({PluginManager.class, PluginUtils.class}) +public class PluginOperateUtilsTest { + + @Test + public void testGetSuccessInfo() { + PluginTaskResult pluginTaskResult = EasyMock.mock(PluginTaskResult.class); + PluginTaskResult pluginTaskResult1 = EasyMock.mock(PluginTaskResult.class); + PluginTaskResult pluginTaskResult2 = EasyMock.mock(PluginTaskResult.class); + + List pluginTaskResults1 = new ArrayList<>(); + pluginTaskResults1.add(pluginTaskResult1); + List pluginTaskResults2 = new ArrayList<>(); + pluginTaskResults2.add(pluginTaskResult1); + pluginTaskResults2.add(pluginTaskResult2); + + PluginMarker pluginMarker1 = PluginMarker.create("plugin-1", "1.0"); + PluginMarker pluginMarker2 = PluginMarkerAdapter.create("plugin-2", "2.0", "name-2"); + PluginTask pluginTask1 = PluginTask.installTask(pluginMarker1); + PluginTask pluginTask2 = PluginTask.installTask(pluginMarker2); + + EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults1).times(2); + EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults2).times(2); + EasyMock.expect(pluginTaskResult1.getCurrentTask()).andReturn(pluginTask1).anyTimes(); + EasyMock.expect(pluginTaskResult2.getCurrentTask()).andReturn(pluginTask2).anyTimes(); + + EasyMock.expect(pluginTaskResult1.errorCode()).andReturn(PluginErrorCode.BelowSystem).anyTimes(); + EasyMock.expect(pluginTaskResult2.errorCode()).andReturn(PluginErrorCode.BeyondSystem).anyTimes(); + + PluginContext plugin1 = EasyMock.mock(PluginContext.class); + PluginContext plugin2 = EasyMock.mock(PluginContext.class); + EasyMock.expect(plugin1.getName()).andReturn("context-1").anyTimes(); + EasyMock.expect(plugin2.getName()).andReturn("context-2").anyTimes(); + PowerMock.mockStatic(PluginManager.class); + EasyMock.expect(PluginManager.getContext(pluginMarker1.getPluginID())) + .andReturn(plugin1).once().andReturn(null).once().andReturn(plugin1).once().andReturn(null).once(); + EasyMock.expect(PluginManager.getContext(pluginMarker2.getPluginID())) + .andReturn(plugin2).once().andReturn(null).once(); + + EasyMock.replay(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); + PowerMock.replayAll(); + + // 1个 + Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem"); + Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem"); + + + // 2个 + Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem\ncontext-2Fine-Core_Plugin_Error_BeyondSystem"); + Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem\nname-2Fine-Core_Plugin_Error_BeyondSystem"); + + EasyMock.verify(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); + PowerMock.verifyAll(); + + } + + + @Test + public void testGetPluginName() { + PluginContext pluginContext = EasyMock.mock(PluginContext.class); + EasyMock.expect(pluginContext.getName()).andReturn("pluginContext").once(); + + PluginMarker pluginMarker1 = PluginMarker.create("id-1", "1"); + PluginMarker pluginMarker2 = PluginMarkerAdapter.create("id-2", "2", "name-2"); + + EasyMock.replay(pluginContext); + + Assert.assertNull(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get()); + Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", pluginContext, pluginMarker1).get(), "pluginContext"); + Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker1).get(), "id-1"); + Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2"); + + EasyMock.verify(pluginContext); + } + + @Test + public void testUpdateMarker2Online() { + + try { + PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); + String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; + JSONObject object = new JSONObject(pluginJson); + + PowerMock.mockStatic(PluginUtils.class); + EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); + EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andThrow(new NullPointerException()).once(); + + PowerMock.replayAll(); + + PluginMarker marker1 = PluginOperateUtils.updateMarker2Online(pluginMarker); + PluginMarker marker2 = PluginOperateUtils.updateMarker2Online(pluginMarker); + + Assert.assertTrue(marker1 instanceof PluginMarkerAdapter); + Assert.assertEquals(marker1.getPluginID(), "plugin-1"); + Assert.assertEquals(marker1.getVersion(), "1.0"); + Assert.assertEquals(((PluginMarkerAdapter) marker1).getPluginName(), "图表(新特性)"); + Assert.assertEquals(marker2, pluginMarker); + + PowerMock.verifyAll(); + } catch (Exception e) { + Assert.fail(); + } + + } + + + @Test + public void testUpdatePluginOnline() { + try { + PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); + String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; + JSONObject object = new JSONObject(pluginJson); + + PowerMock.mockStatic(PluginUtils.class); + EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); + EasyMock.expect(PluginUtils.getInstalledPluginMarkerByID("plugin-1")).andReturn(pluginMarker).once(); + + PowerMock.replayAll(); + + PluginOperateUtils.updatePluginOnline(pluginMarker, null); + + PowerMock.verifyAll(); + } catch (Exception e) { + Assert.fail(); + } + } + +} diff --git a/designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java b/designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java new file mode 100644 index 0000000000..bbb809ebfe --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java @@ -0,0 +1,23 @@ +package com.fr.design.extra; + +import com.fr.invoke.Reflect; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/12/18 + */ +public class PluginUtilsTest { + + @Test + public void testIsCompatibleCurrentEnv() { + Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "~9.0").get()); + Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9.0").get()); + Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9~").get()); + Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "10").get()); + Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "11").get()); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index a902d0e00c..8efc5323e5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -15,6 +15,7 @@ import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.basic.version.Version; +import com.fr.plugin.basic.version.VersionCompatibleType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; @@ -44,7 +45,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); + return VersionCompatibleType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); } private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index 420f0f2b65..14bb23b18d 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -71,6 +71,7 @@ public class DesignerWorkspaceProvider extends Activator { } catch (Exception e) { FineLoggerFactory.getLogger().warn("Check Service Failed"); } + EnvChangeEntrance.getInstance().pluginErrorRemind(selectEnv); } }); } 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 new file mode 100644 index 0000000000..f4c9c1b7a2 --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java @@ -0,0 +1,25 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + + +import com.fr.invoke.Reflect; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/12/17 + */ +public class PluginSearchManagerTest { + + @Test + public void testIsCompatibleCurrentEnv() { + + Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "~9.0").get()); + 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()); + } + +} From 563617b9a3b2dba5b656cbf7a1e2f83704157c41 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 21 Dec 2020 15:50:53 +0800 Subject: [PATCH 2/7] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/extra/PluginUtils.java | 4 ++-- .../alphafine/search/manager/impl/PluginSearchManager.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index 81f4769616..7fa050f607 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -10,7 +10,7 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.PluginVerifyException; import com.fr.plugin.basic.version.Version; -import com.fr.plugin.basic.version.VersionCompatibleType; +import com.fr.plugin.basic.version.VersionIntervalType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; @@ -249,7 +249,7 @@ public class PluginUtils { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionCompatibleType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); + return VersionIntervalType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 8efc5323e5..fbc3ce57b0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -11,16 +11,14 @@ import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvi import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; -import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.basic.version.Version; -import com.fr.plugin.basic.version.VersionCompatibleType; +import com.fr.plugin.basic.version.VersionIntervalType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; -import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -45,7 +43,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionCompatibleType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); + return VersionIntervalType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); } private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { From 3d15e4b6fd17720ad81abe2ab3c3ab44c6649de6 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 21 Dec 2020 17:40:29 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/extra/PluginUtils.java | 2 +- .../alphafine/search/manager/impl/PluginSearchManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index 7fa050f607..ed7253bad2 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -249,7 +249,7 @@ public class PluginUtils { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionIntervalType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); + return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index fbc3ce57b0..31a1b18ed9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -43,7 +43,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } private static boolean isCompatibleCurrentEnv(String envVersion) { - return VersionIntervalType.isSupported(VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion())); + return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); } private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { From 9b9fd7a297748f88e4547dd85b06a3ebda411d11 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 21 Dec 2020 17:57:16 +0800 Subject: [PATCH 4/7] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exe/callback/InstallFromDiskCallback.java | 19 +++++++++---------- .../exe/callback/InstallOnlineCallback.java | 12 +++++------- .../exe/callback/UninstallPluginCallback.java | 12 +++++------- .../exe/callback/UpdateFromDiskCallback.java | 19 +++++++++---------- .../exe/callback/UpdateOnlineCallback.java | 4 +--- 5 files changed, 29 insertions(+), 37 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 14a6de9421..81e76fa451 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -12,7 +12,6 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; import java.io.File; import java.util.List; @@ -45,17 +44,17 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Dependence"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } List pluginTasks = result.getPreTasks(); @@ -65,24 +64,24 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { } PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback)); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } PluginOperateUtils.updatePluginFromDisk(zipFile, jsCallback); }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 0fd43c43b5..c7059f50d5 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -12,8 +12,6 @@ import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; - /** * Created by ibm on 2017/5/26. @@ -43,17 +41,17 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { jsCallback.execute("success"); return; } @@ -62,7 +60,7 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java index bfa921125d..df3839427d 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java @@ -11,8 +11,6 @@ import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; - /** * Created by ibm on 2017/5/27. */ @@ -33,24 +31,24 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); }else if (result.errorCode() == PluginErrorCode.NeedUninstallDependingPluginFirst) { - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Dependence"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } PluginManager.getController().uninstall(pluginMarker, true, new UninstallPluginCallback(pluginMarker, jsCallback)); } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index 551d944888..e5396d35ce 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -12,7 +12,6 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; import java.io.File; import java.util.List; @@ -44,17 +43,17 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Dependence"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } List pluginTasks = result.getPreTasks(); @@ -64,24 +63,24 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { } PluginManager.getController().update(zipFile, new UpdateFromDiskCallback(zipFile, jsCallback)); } else if(result.errorCode() == PluginErrorCode.NoPluginToUpdate){ - int rv = JOptionPane.showOptionDialog( + int rv = FineJOptionPane.showOptionDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_No_Plugin_Update"), Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, + FineJOptionPane.YES_NO_CANCEL_OPTION, + FineJOptionPane.INFORMATION_MESSAGE, null, FineJOptionPane.OPTION_YES_NO_CANCEL, null ); - if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) { return; } PluginOperateUtils.installPluginFromDisk(zipFile, jsCallback); }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index deeed74974..8dbad6a541 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -10,8 +10,6 @@ import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; -import javax.swing.JOptionPane; - /** * Created by ibm on 2017/5/26. */ @@ -40,7 +38,7 @@ public class UpdateOnlineCallback extends AbstractDealPreTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); } } } From bb555ecedcfbd94eb0f7cdbdb10410204717f4b8 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 22 Dec 2020 15:54:06 +0800 Subject: [PATCH 5/7] =?UTF-8?q?REPORT-45558=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=9F=8B=E7=82=B9=E3=80=91process=E8=A1=A8reuseCmptLi?= =?UTF-8?q?st=E5=AD=97=E6=AE=B5=E5=87=86=E7=A1=AE=E6=80=A7=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/info/JFormProcessInfo.java | 45 +++++++++++++------ .../template/info/JFormProcessInfoTest.java | 33 ++++++++++++-- 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java b/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java index 180215a247..c8d52dae70 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java @@ -10,7 +10,10 @@ import com.fr.form.main.WidgetUtil; import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditorProvider; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WLayout; @@ -18,7 +21,6 @@ import com.fr.general.ComparatorUtils; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.report.cell.DefaultTemplateCellElement; - import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -94,23 +96,40 @@ public class JFormProcessInfo extends TemplateProcessInfo
{ private boolean hasTestECReport() { ElementCaseEditorProvider[] elementCaseEditorProviders = this.template.getElementCases(); for (ElementCaseEditorProvider elementCaseEditorProvider : elementCaseEditorProviders) { - FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase(); - Iterator it = elementCase.cellIterator(); - if (!it.hasNext()) { + if (isTestECReport(elementCaseEditorProvider)) { return true; } - while (it.hasNext()) { - DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next(); - Object value = ce.getValue(); - if (isTestCell(value, ce.getStyle())) { - return true; - } - } - } return false; } + private boolean isTestECReport(ElementCaseEditorProvider elementCaseEditorProvider) { + FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase(); + if (!isTestElementCaseEditor((ElementCaseEditor) elementCaseEditorProvider)) { + return false; + } + Iterator it = elementCase.cellIterator(); + if (!it.hasNext()) { + return true; + } + while (it.hasNext()) { + DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next(); + Object value = ce.getValue(); + if (!isTestCell(value, ce.getStyle())) { + return false; + } + } + return true; + } + + private boolean isTestElementCaseEditor(ElementCaseEditor editor) { + return editor.getToolBars().length == 0 && editor.getListenerSize() == 0 + && ComparatorUtils.equals(editor.getBorderStyle(), new LayoutBorderStyle()) + && ComparatorUtils.equals(editor.getMargin(), new PaddingMargin()) + && editor.getBackground() == null; + + } + private boolean hasTestChart() { final boolean[] hasTestChart = {false}; Form.traversalWidget(this.template.getContainer(), new WidgetGather() { @@ -226,7 +245,7 @@ public class JFormProcessInfo extends TemplateProcessInfo { private void addComponentRemoveInfo(JSONObject jsonObject) { String componentID = jsonObject.getString("componentID"); - if (componentID == null){ + if (componentID == null) { return; } JSONObject info = componentProcessInfoMap.get(componentID); diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java index 663be87581..04327d354b 100644 --- a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.template.info; +import com.fr.base.background.ColorBackground; import com.fr.chart.chartattr.ChartCollection; import com.fr.form.main.Form; import com.fr.form.ui.CardSwitchButton; @@ -21,6 +22,8 @@ import com.fr.report.worksheet.FormElementCase; import org.junit.Assert; import org.junit.Test; +import java.awt.Color; + /** * Created by kerry on 2020-05-08 */ @@ -35,14 +38,36 @@ public class JFormProcessInfoTest { wFitLayout.addWidget(editor); form.setContainer(wFitLayout); JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); - boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); - Assert.assertTrue(result1); + boolean result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); elementCase.addCellElement(new DefaultTemplateCellElement()); - boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); - Assert.assertTrue(result2); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); + + DefaultTemplateCellElement templateCellElement = new DefaultTemplateCellElement(); + templateCellElement.setValue(123); + + elementCase.addCellElement(templateCellElement); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertFalse(result); + + elementCase.removeCellElement(templateCellElement); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); + + editor.setBackground(ColorBackground.getInstance(Color.WHITE)); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertFalse(result); + + + editor.setBackground(null); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); } + + @Test public void testHasTestChart() { Form form = new Form(); From 8eec120925afadc3200340e0a86dc18984ef23c5 Mon Sep 17 00:00:00 2001 From: lucian Date: Tue, 22 Dec 2020 17:28:49 +0800 Subject: [PATCH 6/7] =?UTF-8?q?REPORT-43744=20=E3=80=9010.0.13=E3=80=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8Ejar=E5=8C=85=E4=B8=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= 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 +- .../test/java/com/fr/design/extra/PluginOperateUtilsTest.java | 2 +- 2 files changed, 2 insertions(+), 2 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 46683e0a05..499254aeb7 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 @@ -231,7 +231,7 @@ public class PluginOperateUtils { else if (pluginMarker instanceof PluginMarkerAdapter) { return ((PluginMarkerAdapter) pluginMarker).getPluginName(); } - return pluginMarker == null ? null : pluginMarker.getPluginID(); + return pluginMarker == null ? StringUtils.EMPTY : pluginMarker.getPluginID(); } public static String getSwitchedInfo(PluginTaskResult result) { diff --git a/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java b/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java index 887cde43e0..bc81cb2c36 100644 --- a/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java +++ b/designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java @@ -92,7 +92,7 @@ public class PluginOperateUtilsTest { EasyMock.replay(pluginContext); - Assert.assertNull(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get()); + Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get(), ""); Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", pluginContext, pluginMarker1).get(), "pluginContext"); Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker1).get(), "id-1"); Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2"); From 25de90af700a821b76bd0a44e4b1e3810802aa98 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Tue, 22 Dec 2020 21:28:58 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=A0=87=E8=AE=B0=E7=82=B9=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../map/designer/style/series/VanChartMapAnchorMarkerPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java index 458de4a188..d4c1f477bd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java @@ -19,7 +19,7 @@ public class VanChartMapAnchorMarkerPane extends BasicBeanPane