Browse Source

REPORT-2354 将平台的插件管理和设计器的插件管理统一起来

master
kerry 8 years ago
parent
commit
27d27a7d72
  1. 2
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  2. 3
      designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  3. 3
      designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  4. 26
      designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java
  5. 24
      designer_base/src/com/fr/design/extra/exe/callback/UninstallPluginCallback.java
  6. 11
      designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java
  7. 10
      designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java

2
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) { public static void uninstallPlugin(final String pluginInfo, final boolean isForce, JSCallback jsCallback) {
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); 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) { public static void readUpdateOnline(JSCallback jsCallback) {

3
designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java

@ -34,7 +34,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
if (result.isSuccess()) { if (result.isSuccess()) {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); 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( int rv = JOptionPane.showOptionDialog(
null, null,
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), 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)); PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback));
} else { } 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); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} }
} }

3
designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java

@ -33,7 +33,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
if (result.isSuccess()) { if (result.isSuccess()) {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); 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( int rv = JOptionPane.showOptionDialog(
null, null,
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")),
@ -50,6 +50,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
//执行JS回调 //执行JS回调
PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback)); PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback));
} else { } 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); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} }
} }

26
designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java

@ -56,16 +56,40 @@ public class JSCallback<T> extends Task<T> {
* 3.由JSONObject.toString()得到的字符串中html标签的属性会自动加上\造成替换难度加大 * 3.由JSONObject.toString()得到的字符串中html标签的属性会自动加上\造成替换难度加大
* 这边建议去除所有的html标签 * 这边建议去除所有的html标签
* 字符\在java中实际存储的是\\,替换字符串\\n, 需要用\\\\n * 字符\在java中实际存储的是\\,替换字符串\\n, 需要用\\\\n
* "\t""\n" 都要转义成" " 不然会解析出错
* "\\"需要转换成"\"
* 过滤掉html标签及内容
* *
* @param old 原始字符串 * @param old 原始字符串
* @return 处理之后的字符串 * @return 处理之后的字符串
*/ */
private String trimText(String old) { private String trimText(String old) {
if (StringUtils.isNotBlank(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; return StringUtils.EMPTY;
} }
/**
* 进行html标签过滤
* @param origin 原始字符串
* @param tag html标签
* @return 处理之后的字符串
*/
private String filterHtmlTag(String origin, String tag) {
String matter1 = "<" + tag;
String matter2 = "</" + tag + ">";
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;
}
} }

24
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.FRLogger;
import com.fr.general.Inter; 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 com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*; import javax.swing.*;
@ -10,11 +12,12 @@ import javax.swing.*;
/** /**
* Created by ibm on 2017/5/27. * Created by ibm on 2017/5/27.
*/ */
public class UninstallPluginCallback implements PluginTaskCallback { public class UninstallPluginCallback extends AbstractPluginTaskCallback {
private JSCallback jsCallback; private JSCallback jsCallback;
public UninstallPluginCallback(JSCallback jsCallback){ public UninstallPluginCallback(PluginMarker pluginMarker, JSCallback jsCallback){
this.jsCallback = jsCallback; this.jsCallback = jsCallback;
this.pluginMarker = pluginMarker;
} }
@Override @Override
@ -23,6 +26,21 @@ public class UninstallPluginCallback implements PluginTaskCallback {
jsCallback.execute("success"); jsCallback.execute("success");
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Success")); FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); 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 { } else {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Failed")); FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Failed"));
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);

11
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) { public void done(PluginTaskResult result) {
jsCallback.execute("success"); jsCallback.execute("success");
if (result.isSuccess()) { if (result.isSuccess()) {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Update_Success"));
} else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) {
int rv = JOptionPane.showOptionDialog( int rv = JOptionPane.showOptionDialog(
null, null,
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Update_Dependence")),
Inter.getLocText("FR-Designer-Plugin_Install_Success"), Inter.getLocText("FR-Designer-Plugin_Update_Success"),
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE, JOptionPane.INFORMATION_MESSAGE,
null, null,
@ -50,6 +50,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback {
} }
PluginManager.getController().update(zipFile, new UpdateFromDiskCallback(zipFile, jsCallback)); PluginManager.getController().update(zipFile, new UpdateFromDiskCallback(zipFile, jsCallback));
} else { } 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); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} }
} }

10
designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java

@ -33,12 +33,12 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback {
jsCallback.execute("success"); jsCallback.execute("success");
if (result.isSuccess()) { if (result.isSuccess()) {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Update_Success"));
} else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { } else if (result.errorCode() == PluginErrorCode.NeedInstallInterPluginDependency) {
int rv = JOptionPane.showOptionDialog( int rv = JOptionPane.showOptionDialog(
null, null,
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Update_Dependence")),
Inter.getLocText("FR-Designer-Plugin_Install_Success"), Inter.getLocText("FR-Designer-Plugin_Update_Success"),
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE, JOptionPane.INFORMATION_MESSAGE,
null, null,
@ -50,7 +50,7 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback {
} }
PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback)); PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback));
} else { } 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); JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} }
} }

Loading…
Cancel
Save