From 8056cf9d09116afd22debe8cbd119323bcde049f Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Tue, 27 Feb 2018 23:55:19 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-5856=20=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8F=92=E4=BB=B6=E6=96=B0=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/extra/PluginOperateUtils.java | 14 +++- .../com/fr/design/extra/PluginWebBridge.java | 75 +++++++++++++------ .../extra/exe/GetPluginFromStoreExecutor.java | 17 ++++- 3 files changed, 77 insertions(+), 29 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java index 5ce0852c8e..121ecc7970 100644 --- a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -122,7 +122,7 @@ public class PluginOperateUtils { return resultArray.toString(); } - public static void dealParams(StringBuilder url, String category, String seller, String fee) { + public static void dealParams(StringBuilder url, String category, String seller, String fee, String scope) { if (StringUtils.isNotBlank(category)) { url.append("cid=").append(category.split("-")[1]); } else { @@ -152,6 +152,18 @@ public class PluginOperateUtils { url.append("&fee=").append(StringUtils.EMPTY); } } + if (StringUtils.isNotBlank(scope)) { + switch (scope.split("-")[1]) { + case "universal": + url.append("&scope=").append(1); + break; + case "program": + url.append("&scope=").append(2); + break; + default: + url.append("&scope=").append(StringUtils.EMPTY); + } + } } public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) { diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index fed3c6855d..dd5f50295f 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -54,6 +54,7 @@ public class PluginWebBridge { private static final String THREAD_NAME_TEMPLATE = "pluginbridge-thread-%s"; private static final String ACTION = "action"; private static final String KEYWORD = "keyword"; + private static final String PLUGIN_INFO = "pluginInfo"; private static final int COREPOOLSIZE = 3; private static final int MAXPOOLSIZE = 5; @@ -72,20 +73,7 @@ public class PluginWebBridge { new LinkedBlockingQueue(COREPOOLSIZE), new ThreadFactoryBuilder().setNameFormat(THREAD_NAME_TEMPLATE).build()); - /** - * 动作枚举 - */ - public enum ACTIONS { - SEARCH("search"); - private String context; - - ACTIONS(String context) { - this.context = context; - } - - public String getContext() { - return context; - } + private PluginWebBridge() { } public static PluginWebBridge getHelper() { @@ -106,9 +94,6 @@ public class PluginWebBridge { return helper; } - private PluginWebBridge() { - } - /** * 获取打开动作配置 * @@ -155,12 +140,26 @@ public class PluginWebBridge { * * @param keyword 关键词 */ + public void openWithSearch(String keyword) { HashMap map = new HashMap(2); map.put(KEYWORD, keyword); setRunConfig(ACTIONS.SEARCH, map); } + /** + * 根据插件信息跳转到应用中心 + * + * @param keyword + * @param pluginInfo + */ + public void showResultInStore(String keyword, String pluginInfo) { + HashMap map = new HashMap<>(); + map.put(KEYWORD, keyword); + map.put(PLUGIN_INFO, pluginInfo); + setRunConfig(ACTIONS.SHOW_RESULT, map); + } + public void setEngine(WebEngine webEngine) { this.webEngine = webEngine; } @@ -182,7 +181,6 @@ public class PluginWebBridge { PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback); } - /** * 从磁盘上选择插件安装包进行安装 * @@ -204,7 +202,6 @@ public class PluginWebBridge { PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback); } - /** * 从插件服务器上更新选中的插件 * @@ -342,17 +339,31 @@ public class PluginWebBridge { * @param callback 回调函数 */ public void getPluginFromStore(String category, String seller, String fee, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(category, seller, fee)); + Task task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(category, seller, fee, "")); threadPoolExecutor.submit(task); } + /** + * 根据条件获取在线插件 + * + * @param info 插件信息 + * @param callback 回调函数 + */ + public void getPluginFromStoreNew(String info, final JSObject callback) { + try { + Task task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(new JSONObject(info))); + threadPoolExecutor.submit(task); + } catch (JSONException e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + public void getPluginPrefix(final JSObject callback) { Task task = new PluginTask<>(webEngine, callback, new GetPluginPrefixExecutor()); threadPoolExecutor.submit(task); } - /** * 在线获取插件分类 * @@ -487,9 +498,6 @@ public class PluginWebBridge { } } - - /*-------------------------------登录部分的处理----------------------------------*/ - /** * 注册页面 */ @@ -501,6 +509,9 @@ public class PluginWebBridge { } } + + /*-------------------------------登录部分的处理----------------------------------*/ + /** * 忘记密码 */ @@ -577,4 +588,20 @@ public class PluginWebBridge { return true; } + /** + * 动作枚举 + */ + public enum ACTIONS { + SEARCH("search"), SHOW_RESULT("showResult"); + private String context; + + ACTIONS(String context) { + this.context = context; + } + + public String getContext() { + return context; + } + } + } diff --git a/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java index 123c3ceed3..4b4bddab4a 100644 --- a/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java @@ -20,11 +20,20 @@ public class GetPluginFromStoreExecutor implements Executor { private String category; private String seller; private String fee; + private String scope; - public GetPluginFromStoreExecutor(String category, String seller, String fee) { + public GetPluginFromStoreExecutor(JSONObject info) { + this.category = info.optString("category"); + this.fee = info.optString("fee"); + this.seller = info.optString("seller"); + this.scope = info.optString("scope"); + } + + public GetPluginFromStoreExecutor(String category, String seller, String fee, String scope) { this.category = category; this.seller = seller; this.fee = fee; + this.scope = scope; } @Override @@ -44,7 +53,7 @@ public class GetPluginFromStoreExecutor implements Executor { @Override public void run(Process process) { String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.plist") + "?"; - boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee); + boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee) && StringUtils.isEmpty(scope); if (getRecommend) { result = PluginOperateUtils.getRecommendPlugins(); return; @@ -53,7 +62,7 @@ public class GetPluginFromStoreExecutor implements Executor { if (StringUtils.isNotBlank(plistUrl)) { StringBuilder url = new StringBuilder(); url.append(plistUrl); - PluginOperateUtils.dealParams(url, category, seller, fee); + PluginOperateUtils.dealParams(url, category, seller, fee, scope); try { HttpClient httpClient = new HttpClient(url.toString()); httpClient.asGet(); @@ -66,7 +75,7 @@ public class GetPluginFromStoreExecutor implements Executor { FRLogger.getLogger().error(e.getMessage()); } } else { - result = PluginConstants.CONNECTION_404; + result = PluginConstants.CONNECTION_404; } } }