From 43d8270a47a9b9df5b8970164c01d43bea61f10b Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 8 Jun 2018 10:22:05 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-8630=09=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=9A=84=E5=9B=BD=E9=99=85=E5=8C=96=E9=83=BD=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98(=E5=85=88=E6=94=B9=E5=9B=9E=E5=8E=BB?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E9=9D=A2=E7=BB=9F=E4=B8=80=E6=94=B9=E4=B8=8B?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/bbs/BBSLoginUtils.java | 51 ++++++++++++++----- .../com/fr/design/extra/PluginWebBridge.java | 11 ++-- .../com/fr/design/extra/PluginWebPane.java | 6 +-- .../com/fr/design/extra/WebViewDlgHelper.java | 23 ++++----- 4 files changed, 55 insertions(+), 36 deletions(-) diff --git a/designer-base/src/com/fr/design/bbs/BBSLoginUtils.java b/designer-base/src/com/fr/design/bbs/BBSLoginUtils.java index 8e8b5bd568..9a8eef094f 100644 --- a/designer-base/src/com/fr/design/bbs/BBSLoginUtils.java +++ b/designer-base/src/com/fr/design/bbs/BBSLoginUtils.java @@ -1,8 +1,11 @@ package com.fr.design.bbs; -import com.fr.base.FRContext; +import com.fr.config.Configuration; import com.fr.config.MarketConfig; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.transaction.Configurations; +import com.fr.transaction.Worker; import java.util.List; @@ -11,26 +14,46 @@ import java.util.List; */ public class BBSLoginUtils { - public static void bbsLogin(String username, String password) { + public static void bbsLogin(final String username, final String password) { try { - MarketConfig.getInstance().setBbsUsername(username); - MarketConfig.getInstance().setBbsPassword(password); + Configurations.update(new Worker() { + @Override + public void run() { + MarketConfig.getInstance().setBbsUsername(username); + MarketConfig.getInstance().setBbsPassword(password); + } + @Override + public Class[] targets() { + return new Class[]{MarketConfig.class}; + } + }); + } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage()); } } public static void bbsLogin(List list) { try { - String uid = list.get(0); - String username = list.get(1); - String password = list.get(2); - MarketConfig.getInstance().setBbsUsername(username); - MarketConfig.getInstance().setBbsPassword(password); - MarketConfig.getInstance().setBbsUid(Integer.parseInt(uid)); - MarketConfig.getInstance().setInShowBBsName(username); + final String uid = list.get(0); + final String username = list.get(1); + final String password = list.get(2); + Configurations.update(new Worker() { + @Override + public void run() { + MarketConfig.getInstance().setBbsUsername(username); + MarketConfig.getInstance().setBbsPassword(password); + MarketConfig.getInstance().setBbsUid(Integer.parseInt(uid)); + MarketConfig.getInstance().setInShowBBsName(username); + } + @Override + public Class[] targets() { + return new Class[]{MarketConfig.class}; + } + }); + } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage()); } } @@ -41,7 +64,7 @@ public class BBSLoginUtils { MarketConfig.getInstance().setBbsUid(0); MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage()); } } } diff --git a/designer-base/src/com/fr/design/extra/PluginWebBridge.java b/designer-base/src/com/fr/design/extra/PluginWebBridge.java index 92b053a424..787626985d 100644 --- a/designer-base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer-base/src/com/fr/design/extra/PluginWebBridge.java @@ -1,6 +1,5 @@ package com.fr.design.extra; -import com.fr.base.FRContext; import com.fr.config.MarketConfig; import com.fr.design.RestartHelper; import com.fr.design.bbs.BBSLoginUtils; @@ -20,9 +19,7 @@ import com.fr.general.SiteCenter; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; -import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; -import com.fr.plugin.manage.PluginManager; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import javafx.concurrent.Task; @@ -56,7 +53,7 @@ public class PluginWebBridge { private static final String PLUGIN_INFO = "pluginInfo"; private static final int COREPOOLSIZE = 3; private static final int MAXPOOLSIZE = 5; - private static final String I18N_PREFIX = "Fine-"; + private static final String I18N_PREFIX = "FR-"; private static PluginWebBridge helper; @@ -109,7 +106,7 @@ public class PluginWebBridge { jsonObject.put(key, config.get(key).toString()); } } catch (JSONException e) { - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return jsonObject.toString(); } @@ -443,7 +440,7 @@ public class PluginWebBridge { String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default"); Desktop.getDesktop().browse(new URI(loginUrl)); } catch (Exception exp) { - FRContext.getLogger().info(exp.getMessage()); + FineLoggerFactory.getLogger().info(exp.getMessage()); } } @@ -519,7 +516,7 @@ public class PluginWebBridge { try { Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.reset"))); } catch (Exception e) { - FRContext.getLogger().info(e.getMessage()); + FineLoggerFactory.getLogger().info(e.getMessage()); } } diff --git a/designer-base/src/com/fr/design/extra/PluginWebPane.java b/designer-base/src/com/fr/design/extra/PluginWebPane.java index c82f6af595..1d3f1ac2b7 100644 --- a/designer-base/src/com/fr/design/extra/PluginWebPane.java +++ b/designer-base/src/com/fr/design/extra/PluginWebPane.java @@ -1,8 +1,8 @@ package com.fr.design.extra; -import com.fr.base.FRContext; import com.fr.base.TemplateUtils; import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import javafx.application.Platform; @@ -56,7 +56,7 @@ public class PluginWebPane extends JFXPanel { webView.setContextMenuEnabled(false);//屏蔽右键 root.setCenter(webView); }catch (Exception e){ - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -85,7 +85,7 @@ public class PluginWebPane extends JFXPanel { try{ htmlString = TemplateUtils.renderParameter4Tpl(sb.toString(), map4Tpl); }catch (Exception e){ - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } reader.close(); inp.close(); diff --git a/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java index a8ca35831d..749c004472 100644 --- a/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java @@ -13,6 +13,7 @@ import com.fr.general.Inter; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.PluginStoreConstants; import com.fr.plugin.PluginVerifyException; import com.fr.stable.EnvChangedListener; @@ -42,6 +43,7 @@ public class WebViewDlgHelper { private static final String SHOP_SCRIPTS = "shop_scripts"; private static final int VERSION_8 = 8; private static String installHome = FRContext.getCurrentEnv().getWebReportPath(); + private static final String MAIN_JS_PATH = "/scripts/plugin.html"; private static final int BYTES_NUM = 1024; static { @@ -55,8 +57,7 @@ public class WebViewDlgHelper { public static void createPluginDialog() { if (StableUtils.getMajorJavaVersion() >= VERSION_8) { - String relativePath = "/scripts/plugin.html"; - String mainJsPath = StableUtils.pathJoin(installHome, relativePath); + String mainJsPath = StableUtils.pathJoin(installHome, MAIN_JS_PATH); File file = new File(mainJsPath); if (!file.exists()) { int rv = JOptionPane.showConfirmDialog( @@ -70,10 +71,7 @@ public class WebViewDlgHelper { downloadShopScripts(SHOP_SCRIPTS); } } else { - String indexPath = "plugin.html"; - String mainIndexPath = StableUtils.pathJoin(installHome, indexPath); - checkAndCopyMainFile(mainIndexPath, mainJsPath); - showPluginDlg(indexPath); + showPluginDlg(); updateShopScripts(SHOP_SCRIPTS); } } else { @@ -107,7 +105,7 @@ public class WebViewDlgHelper { try { CommonIOUtils.copy(new File(mainJsPath), new File(installHome)); } catch (IOException e) { - FRContext.getLogger().error(e.getMessage()); + FineLoggerFactory.getLogger().error(e.getMessage()); } } @@ -185,18 +183,19 @@ public class WebViewDlgHelper { } } - private static void showPluginDlg(String mainJsPath) { + private static void showPluginDlg() { try { Class clazz = Class.forName("com.fr.design.extra.PluginWebPane"); Constructor constructor = clazz.getConstructor(String.class, String.class); - Component webPane = (Component) constructor.newInstance(installHome, mainJsPath); + Component webPane = (Component) constructor.newInstance(installHome, MAIN_JS_PATH); BasicPane managerPane = new ShopManagerPane(webPane); UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane); PluginWebBridge.getHelper().setDialogHandle(dlg); dlg.setVisible(true); - } catch (Throwable ignored) { + } catch (Exception e) { // ignored + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -242,7 +241,7 @@ public class WebViewDlgHelper { JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); return false; } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; } return true; @@ -261,7 +260,7 @@ public class WebViewDlgHelper { JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), Inter.getLocText("FR-Designer_Tooltips"), JOptionPane.INFORMATION_MESSAGE); } } catch (InterruptedException | ExecutionException e) { - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } }