Browse Source

Merge pull request #30 in PF/design from ~KERRY/design-pf:9.0 to 9.0

* commit 'c156cbc9add19429b2f6409f33cb658a66f7172a':
  PMD
  REPORT-2354 将平台的插件管理和设计器的插件管理统一起来
master
superman 8 years ago
parent
commit
01a2b55909
  1. 37
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  2. 7
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  3. 3
      designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java

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

@ -8,6 +8,7 @@ import com.fr.design.extra.exe.extratask.UpdatePluginTask;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
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,7 +18,7 @@ import com.fr.plugin.manage.bbs.BBSUserInfo;
import com.fr.plugin.manage.control.PluginTaskCallback; import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import org.json.JSONArray;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -107,25 +108,35 @@ public class PluginOperateUtils {
} }
public static void searchPlugin(String keyword, JSCallback jsCallback) { public static void searchPlugin(String keyword, JSCallback jsCallback) {
try {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword); try {
// HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword);
HttpClient httpClient = new HttpClient("http://shop.finereport.com/searchApi?type=all" + "&keyword=" + keyword);
httpClient.asGet();
String result = httpClient.getResponseText(); String result = httpClient.getResponseText();
jsCallback.execute(result); JSONObject jsonObject = new JSONObject(result);
} JSONArray jsonArray = jsonObject.getJSONArray("result");
}).start(); jsCallback.execute(jsonArray.toString());
} catch (Exception e) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
} }
}).start();
}
public static void getPluginFromStore(String category, String seller, String fee, JSCallback jsCallback) { public static void getPluginFromStore(String category, String seller, String fee, JSCallback jsCallback) {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.plist"); // String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.plist");
String plistUrl = "http://shop.finereport.com/shopServer?pg=plist";
boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee);
if (getRecommend){
plistUrl = "http://shop.finereport.com/ShopServer?pg=feature";
}
if (StringUtils.isNotBlank(plistUrl)) { if (StringUtils.isNotBlank(plistUrl)) {
StringBuilder url = new StringBuilder(); StringBuilder url = new StringBuilder();
url.append(plistUrl); url.append(plistUrl);
@ -159,7 +170,7 @@ public class PluginOperateUtils {
@Override @Override
public void run() { public void run() {
String result; String result;
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); String url = "http://shop.finereport.com/shopServer?pg=category";
if (url != null) { if (url != null) {
HttpClient httpClient = new HttpClient(url); HttpClient httpClient = new HttpClient(url);
result = httpClient.getResponseText(); result = httpClient.getResponseText();
@ -171,6 +182,16 @@ public class PluginOperateUtils {
}).start(); }).start();
} }
public static void getPluginPrefix(JSCallback jsCallback) {
new Thread(new Runnable() {
@Override
public void run() {
String result = SiteCenter.getInstance().acquireUrlByKind("plugin.url.prefix");
jsCallback.execute(result);
}
}).start();
}
public static void getLoginInfo(JSCallback jsCallback) { public static void getLoginInfo(JSCallback jsCallback) {
BBSUserInfo bbsUserInfo = BBSPluginLogin.getInstance().getUserInfo(); BBSUserInfo bbsUserInfo = BBSPluginLogin.getInstance().getUserInfo();
String username = bbsUserInfo == null ? "" : bbsUserInfo.getUserName(); String username = bbsUserInfo == null ? "" : bbsUserInfo.getUserName();

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

@ -312,6 +312,13 @@ public class PluginWebBridge {
PluginOperateUtils.getPluginFromStore(category, seller, fee, jsCallback); PluginOperateUtils.getPluginFromStore(category, seller, fee, jsCallback);
} }
public void getPluginPrefix(final JSObject callback){
JSCallback jsCallback = new JSCallback(webEngine, callback);
PluginOperateUtils.getPluginPrefix(jsCallback);
}
/** /**
* 在线获取插件分类 * 在线获取插件分类
* *

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

@ -55,13 +55,14 @@ public class JSCallback<T> extends Task<T> {
* 2.js字符串中的\n会导致js字符串变成多行,而js字符串不支持多行拼接 * 2.js字符串中的\n会导致js字符串变成多行,而js字符串不支持多行拼接
* 3.由JSONObject.toString()得到的字符串中html标签的属性会自动加上\造成替换难度加大 * 3.由JSONObject.toString()得到的字符串中html标签的属性会自动加上\造成替换难度加大
* 这边建议去除所有的html标签 * 这边建议去除所有的html标签
* 字符\在java中实际存储的是\\,替换字符串\\n, 需要用\\\\n
* *
* @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("\'", "\\\\\'"); return old.replaceAll("\\\\n", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'");
} }
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }

Loading…
Cancel
Save