Browse Source

REPORT-235

master
kerry 8 years ago
parent
commit
94113f6b0e
  1. 81
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  2. 20
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  3. 1
      designer_base/src/com/fr/design/extra/exe/callback/AbstractPluginTaskCallback.java
  4. 1
      designer_base/src/com/fr/design/extra/exe/callback/DownloadCallback.java
  5. 2
      designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  6. 1
      designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java

81
designer_base/src/com/fr/design/extra/PluginOperateUtils.java

@ -1,11 +1,14 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.exe.callback.*; import com.fr.design.extra.exe.callback.*;
import com.fr.design.extra.exe.extratask.InstallPluginTask; import com.fr.design.extra.exe.extratask.InstallPluginTask;
import com.fr.design.extra.exe.extratask.UpdatePluginTask; import com.fr.design.extra.exe.extratask.UpdatePluginTask;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
@ -17,6 +20,7 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javafx.scene.web.WebEngine; import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject; import netscape.javascript.JSObject;
import org.json.JSONArray;
import sun.plugin2.main.server.Plugin; import sun.plugin2.main.server.Plugin;
import javax.swing.*; import javax.swing.*;
@ -96,6 +100,83 @@ public class PluginOperateUtils {
PluginManager.getController().uninstall(pluginMarker, isForce, new UnistallPluginCallback()); PluginManager.getController().uninstall(pluginMarker, isForce, new UnistallPluginCallback());
} }
public static void readUpdateOnline(JSCallback jsCallback){
try {
String [] plugins = PluginReaderForDesigner.readPluginsForUpdate();
JSONArray jsonArray = new JSONArray();
for (String plugin : plugins) {
org.json.JSONObject jsonObject = new org.json.JSONObject();
jsonObject.put("pluginid", plugin);
jsonArray.put(jsonObject);
}
String result = jsonArray.toString();
jsCallback.execute(result);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
public static void searchPlugin(String keyword, JSCallback jsCallback) {
try {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword);
String result = httpClient.getResponseText();
jsCallback.execute(result);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
public static void getPluginFromStore(String category, String seller, String fee, JSCallback jsCallback){
String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.plist");
if (StringUtils.isNotBlank(plistUrl)) {
StringBuilder url = new StringBuilder();
url.append(plistUrl);
if (StringUtils.isNotBlank(category)) {
url.append("&cid=").append(category.split("-")[1]);
}
if (StringUtils.isNotBlank(seller)) {
url.append("&seller=").append(seller.split("-")[1]);
}
if (StringUtils.isNotBlank(fee)) {
url.append("&fee=").append(fee.split("-")[1]);
}
try {
HttpClient httpClient = new HttpClient(url.toString());
String result = httpClient.getResponseText();
jsCallback.execute(result);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
} else {
String result = PluginConstants.CONNECTION_404;
jsCallback.execute(result);
}
}
public static void getPluginCategories(JSCallback jsCallback){
String result;
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category");
if (url != null) {
HttpClient httpClient = new HttpClient(url);
result = httpClient.getResponseText();
} else {
result = PluginConstants.CONNECTION_404;
}
jsCallback.execute(result);
}
public static void getLoginInfo(JSCallback jsCallback){
String username = BBSPluginLogin.getInstance().getUserInfo().getUserName();
String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName();
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) {
return;
}else {
String result = StringUtils.isEmpty(inShowUsername) ? username : inShowUsername;
jsCallback.execute(result);
}
}
private static String[] jsObjectToStringArray(JSObject obj) { private static String[] jsObjectToStringArray(JSObject obj) {
if (obj == null) { if (obj == null) {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayUtils.EMPTY_STRING_ARRAY;

20
designer_base/src/com/fr/design/extra/PluginWebBridge.java

@ -209,8 +209,8 @@ public class PluginWebBridge {
* 已安装插件检查更新 * 已安装插件检查更新
*/ */
public void readUpdateOnline(final JSObject callback) { public void readUpdateOnline(final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new ReadUpdateOnlineExecutor()); JSCallback jsCallback = new JSCallback(webEngine, callback);
new Thread(task).start(); PluginOperateUtils.readUpdateOnline(jsCallback);
} }
/** /**
@ -303,8 +303,8 @@ public class PluginWebBridge {
* @param keyword 关键字 * @param keyword 关键字
*/ */
public void searchPlugin(String keyword, final JSObject callback) { public void searchPlugin(String keyword, final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new SearchOnlineExecutor(keyword)); JSCallback jsCallback = new JSCallback(webEngine, callback);
new Thread(task).start(); PluginOperateUtils.searchPlugin(keyword, jsCallback);
} }
/** /**
@ -316,8 +316,8 @@ public class PluginWebBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
public void getPluginFromStore(String category, String seller, String fee, final JSObject callback) { public void getPluginFromStore(String category, String seller, String fee, final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(category, seller, fee)); JSCallback jsCallback = new JSCallback(webEngine, callback);
new Thread(task).start(); PluginOperateUtils.getPluginFromStore(category, seller, fee, jsCallback);
} }
/** /**
@ -326,8 +326,8 @@ public class PluginWebBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
public void getPluginCategories(final JSObject callback) { public void getPluginCategories(final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginCategoriesExecutor()); JSCallback jsCallback = new JSCallback(webEngine, callback);
new Thread(task).start(); PluginOperateUtils.getPluginCategories(jsCallback);
} }
/** /**
@ -377,8 +377,8 @@ public class PluginWebBridge {
* @param callback * @param callback
*/ */
public void getLoginInfo(final JSObject callback) { public void getLoginInfo(final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new GetLoginInfoExecutor()); JSCallback jsCallback = new JSCallback(webEngine, callback);
new Thread(task).start(); PluginOperateUtils.getLoginInfo(jsCallback);
} }
/** /**

1
designer_base/src/com/fr/design/extra/exe/callback/AbstractPluginTaskCallback.java

@ -3,7 +3,6 @@ package com.fr.design.extra.exe.callback;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.control.ProgressCallback; import com.fr.plugin.manage.control.ProgressCallback;
import java.io.File;
/** /**
* Created by ibm on 2017/5/26. * Created by ibm on 2017/5/26.

1
designer_base/src/com/fr/design/extra/exe/callback/DownloadCallback.java

@ -3,7 +3,6 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.extra.exe.extratask.ExtraPluginTask; import com.fr.design.extra.exe.extratask.ExtraPluginTask;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.manage.control.ProgressCallback;
import javax.swing.*; import javax.swing.*;

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

@ -13,6 +13,7 @@ import java.io.File;
*/ */
public class InstallFromDiskCallback extends AbstractPluginTaskCallback { public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
private File zipFile; private File zipFile;
public InstallFromDiskCallback(File zipFile, JSCallback jsCallback) { public InstallFromDiskCallback(File zipFile, JSCallback jsCallback) {
this.zipFile = zipFile; this.zipFile = zipFile;
this.jsCallback = jsCallback; this.jsCallback = jsCallback;
@ -44,7 +45,6 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback{
return; return;
} }
PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback)); PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback));
// jsCallback.execute("installDependence");
} else { } else {
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);
} }

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

@ -45,7 +45,6 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
} }
//执行JS回调 //执行JS回调
PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback)); PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback));
// jsCallback.execute("installDependence");
} else { } else {
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