From 970d9a517e63d0bec183960162ddcf45d7f5e74b Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Thu, 8 Jun 2017 16:45:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=90=88License=E9=83=A8=E5=88=86(?= =?UTF-8?q?=E8=BF=98=E6=98=AF=E6=8F=90=E7=A4=BA=E6=B2=A1=E5=86=99)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/extra/PluginControlPane.java | 19 ++++++++------ .../com/fr/design/extra/PluginWebBridge.java | 14 +--------- designer_base/src/com/fr/env/RemoteEnv.java | 26 +------------------ 3 files changed, 13 insertions(+), 46 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginControlPane.java b/designer_base/src/com/fr/design/extra/PluginControlPane.java index ac63ae7f4e..be3c8601d9 100644 --- a/designer_base/src/com/fr/design/extra/PluginControlPane.java +++ b/designer_base/src/com/fr/design/extra/PluginControlPane.java @@ -8,9 +8,9 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; -import com.fr.plugin.PluginLicense; -import com.fr.plugin.PluginLicenseManager; +import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.license.Licensed; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginTaskCallback; import com.fr.plugin.manage.control.PluginTaskResult; @@ -68,15 +68,18 @@ public class PluginControlPane extends BasicPane { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof PluginView) { - PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(((PluginView) value).getID()); + Licensed context = PluginManager.getContext(PluginMarker.read((PluginView) value)); + if (context == null) { + return this; + } String extraInfo = ""; - if (pluginLicense.isJarDamage()) { + if (context.isLicDamaged()) { extraInfo = "(" + Inter.getLocText("FR-Plugin-Plugin_Damaged") + ")"; - } else if (pluginLicense.getLeftTime() != -1) { - if (pluginLicense.isAvailable()) { - extraInfo = "(" + (pluginLicense.isTrial() ? Inter.getLocText("FR-Plugin-Designer_Trial") : Inter.getLocText("FR-Plugin-Designer_Authorized")) + pluginLicense.getLeftTime() + Inter.getLocText("FR-Plugin-Designer_Left") + ")"; + } else if (!context.isFree()) { + if (context.isAvailable()) { + extraInfo = "(" + (context.isOnTrial() ? Inter.getLocText("FR-Plugin-Designer_Trial") : Inter.getLocText("FR-Plugin-Designer_Authorized")) + context.getLeftDays() + Inter.getLocText("FR-Plugin-Designer_Left") + ")"; } else { - extraInfo = "(" + (pluginLicense.isTrial() ? Inter.getLocText("FR-Plugin-Designer_Trial") : Inter.getLocText("FR-Plugin-Designer_Authorized")) + Inter.getLocText("FR-Plugin-Designer_Expired") + ")"; + extraInfo = "(" + (context.isOnTrial() ? Inter.getLocText("FR-Plugin-Designer_Trial") : Inter.getLocText("FR-Plugin-Designer_Authorized")) + Inter.getLocText("FR-Plugin-Designer_Expired") + ")"; } } setText(((PluginView) value).getName() + extraInfo); diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index a961183ad1..3efa0fd6e9 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -9,8 +9,6 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.general.SiteCenter; -import com.fr.plugin.PluginLicense; -import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; import com.fr.plugin.manage.PluginManager; @@ -278,17 +276,7 @@ public class PluginWebBridge { List plugins = PluginManager.getContexts(); return plugins.toArray(new PluginContext[plugins.size()]); } - - - /** - * 获取已经安装的插件的授权情况 - * - * @return 已安装的插件授权对象 - */ - public PluginLicense getPluginLicenseByID(String pluginID) { - return PluginLicenseManager.getInstance().getPluginLicenseByID(pluginID); - } - + private String[] jsObjectToStringArray(JSObject obj) { if (obj == null) { return ArrayUtils.EMPTY_STRING_ARRAY; diff --git a/designer_base/src/com/fr/env/RemoteEnv.java b/designer_base/src/com/fr/env/RemoteEnv.java index cc60cc6488..a178150921 100644 --- a/designer_base/src/com/fr/env/RemoteEnv.java +++ b/designer_base/src/com/fr/env/RemoteEnv.java @@ -27,9 +27,6 @@ import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; -import com.fr.plugin.PluginLicense; -import com.fr.plugin.PluginLicenseManager; -import com.fr.plugin.xml.PluginXml; import com.fr.share.ShareConstants; import com.fr.stable.*; import com.fr.stable.file.XMLFileManagerProvider; @@ -1991,11 +1988,7 @@ public class RemoteEnv extends AbstractEnv { public void setLicName(String licName) { //do nth } - - @Override - public void checkAndRegisterLic(FileNode node, PluginXml plugin) throws Exception { - - } + /** * 获取当前env的build文件路径 @@ -2034,23 +2027,6 @@ public class RemoteEnv extends AbstractEnv { } - public void readPluginLicenses() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - HashMap para = new HashMap(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_plugin_licenses"); - - InputStream inputStream = postBytes2ServerB(out.toByteArray(), para); - String pluginsLicensesStr = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); - if (StringUtils.isNotBlank(pluginsLicensesStr) && pluginsLicensesStr.startsWith("[")) { - JSONArray jsonArray = new JSONArray(pluginsLicensesStr); - for (int i = 0; i < jsonArray.length(); i++) { - PluginLicense pluginLicense = new PluginLicense(); - pluginLicense.parseJSON(jsonArray.getJSONObject(i)); - PluginLicenseManager.getInstance().addRemotePluginLicense(pluginLicense); - } - } - } @Override public String pluginServiceAction(String serviceID, String req) throws Exception {