From 27d27a7d722fcb55dcb3eae1d09712892c9286d3 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 12 Jun 2017 10:07:03 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-2354=20=E5=B0=86=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E7=9A=84=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=E5=92=8C=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E7=9A=84=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E8=B5=B7=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/extra/PluginOperateUtils.java | 2 +- .../exe/callback/InstallFromDiskCallback.java | 3 ++- .../exe/callback/InstallOnlineCallback.java | 3 ++- .../design/extra/exe/callback/JSCallback.java | 26 ++++++++++++++++++- .../exe/callback/UninstallPluginCallback.java | 24 ++++++++++++++--- .../exe/callback/UpdateFromDiskCallback.java | 11 ++++---- .../exe/callback/UpdateOnlineCallback.java | 10 +++---- 7 files changed, 62 insertions(+), 17 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java index 42d646b11c..dbb03fc68b 100644 --- a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -80,7 +80,7 @@ public class PluginOperateUtils { public static void uninstallPlugin(final String pluginInfo, final boolean isForce, JSCallback jsCallback) { PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); - PluginManager.getController().uninstall(pluginMarker, isForce, new UninstallPluginCallback(jsCallback)); + PluginManager.getController().uninstall(pluginMarker, isForce, new UninstallPluginCallback(pluginMarker, jsCallback)); } public static void readUpdateOnline(JSCallback jsCallback) { diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 64f3ca56d0..d0d517543c 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -34,7 +34,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { + } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { int rv = JOptionPane.showOptionDialog( null, Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), @@ -50,6 +50,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { } PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback)); } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Failed")); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 40bf674eda..d6182c2b4c 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -33,7 +33,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { + } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { int rv = JOptionPane.showOptionDialog( null, Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), @@ -50,6 +50,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback { //执行JS回调 PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback)); } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Failed")); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java index de7d779490..600feceffd 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java @@ -56,16 +56,40 @@ public class JSCallback extends Task { * 3.由JSONObject.toString()得到的字符串中html标签的属性会自动加上\造成替换难度加大, * 这边建议去除所有的html标签 * 字符\在java中实际存储的是\\,替换字符串\\n, 需要用\\\\n + * "\t"和"\n" 都要转义成" " 不然会解析出错 + * "\\"需要转换成"\" + * 过滤掉html标签及内容 * * @param old 原始字符串 * @return 处理之后的字符串 */ private String trimText(String old) { if (StringUtils.isNotBlank(old)) { - return old.replaceAll("\\\\n", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'"); + String a = filterHtmlTag(old, "a"); + String b = filterHtmlTag(a, "font"); + return b.replaceAll("\\\\n", "").replaceAll("\\\\t", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\"); } return StringUtils.EMPTY; } + /** + * 进行html标签过滤 + * @param origin 原始字符串 + * @param tag html标签 + * @return 处理之后的字符串 + */ + private String filterHtmlTag(String origin, String tag) { + String matter1 = "<" + tag; + String matter2 = ""; + int a = origin.indexOf(matter1); + int b = origin.indexOf(matter2); + while (a != -1 && b != -1) { + origin = origin.substring(0, a) + origin.substring(b + matter2.length(), origin.length()); + a = origin.indexOf(matter1); + b = origin.indexOf(matter2); + } + return origin; + } + } diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UninstallPluginCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UninstallPluginCallback.java index 983a2a0c5e..66e39ec88e 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/UninstallPluginCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/UninstallPluginCallback.java @@ -2,7 +2,9 @@ package com.fr.design.extra.exe.callback; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTaskResult; import javax.swing.*; @@ -10,11 +12,12 @@ import javax.swing.*; /** * Created by ibm on 2017/5/27. */ -public class UninstallPluginCallback implements PluginTaskCallback { +public class UninstallPluginCallback extends AbstractPluginTaskCallback { private JSCallback jsCallback; - public UninstallPluginCallback(JSCallback jsCallback){ + public UninstallPluginCallback(PluginMarker pluginMarker, JSCallback jsCallback){ this.jsCallback = jsCallback; + this.pluginMarker = pluginMarker; } @Override @@ -23,6 +26,21 @@ public class UninstallPluginCallback implements PluginTaskCallback { jsCallback.execute("success"); FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Success")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); + }else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Delete_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Delete_Success"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + null, + null + ); + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + return; + } + PluginManager.getController().uninstall(pluginMarker, true, new UninstallPluginCallback(pluginMarker, jsCallback)); } else { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Failed")); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index c2190e25a3..1ea304bfb0 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -32,13 +32,13 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { public void done(PluginTaskResult result) { jsCallback.execute("success"); if (result.isSuccess()) { - FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Update_Success")); + } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { int rv = JOptionPane.showOptionDialog( null, - Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), - Inter.getLocText("FR-Designer-Plugin_Install_Success"), + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Update_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Update_Success"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -50,6 +50,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { } PluginManager.getController().update(zipFile, new UpdateFromDiskCallback(zipFile, jsCallback)); } else { + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Failed")); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index 2285b7a8dd..b858b6eee0 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -33,12 +33,12 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback { jsCallback.execute("success"); if (result.isSuccess()) { FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); - } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Update_Success")); + } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) { int rv = JOptionPane.showOptionDialog( null, - Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), - Inter.getLocText("FR-Designer-Plugin_Install_Success"), + Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Update_Dependence")), + Inter.getLocText("FR-Designer-Plugin_Update_Success"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, @@ -50,7 +50,7 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback { } PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback)); } else { - FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Failed")); + FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Failed")); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } }