Browse Source

REPORT-8630 插件管理的国际化都有问题(先改回去,后面统一改下国际化)

master
kerry 7 years ago
parent
commit
43d8270a47
  1. 51
      designer-base/src/com/fr/design/bbs/BBSLoginUtils.java
  2. 11
      designer-base/src/com/fr/design/extra/PluginWebBridge.java
  3. 6
      designer-base/src/com/fr/design/extra/PluginWebPane.java
  4. 23
      designer-base/src/com/fr/design/extra/WebViewDlgHelper.java

51
designer-base/src/com/fr/design/bbs/BBSLoginUtils.java

@ -1,8 +1,11 @@
package com.fr.design.bbs; package com.fr.design.bbs;
import com.fr.base.FRContext; import com.fr.config.Configuration;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import java.util.List; import java.util.List;
@ -11,26 +14,46 @@ import java.util.List;
*/ */
public class BBSLoginUtils { public class BBSLoginUtils {
public static void bbsLogin(String username, String password) { public static void bbsLogin(final String username, final String password) {
try { try {
MarketConfig.getInstance().setBbsUsername(username); Configurations.update(new Worker() {
MarketConfig.getInstance().setBbsPassword(password); @Override
public void run() {
MarketConfig.getInstance().setBbsUsername(username);
MarketConfig.getInstance().setBbsPassword(password);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{MarketConfig.class};
}
});
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }
} }
public static void bbsLogin(List<String> list) { public static void bbsLogin(List<String> list) {
try { try {
String uid = list.get(0); final String uid = list.get(0);
String username = list.get(1); final String username = list.get(1);
String password = list.get(2); final String password = list.get(2);
MarketConfig.getInstance().setBbsUsername(username); Configurations.update(new Worker() {
MarketConfig.getInstance().setBbsPassword(password); @Override
MarketConfig.getInstance().setBbsUid(Integer.parseInt(uid)); public void run() {
MarketConfig.getInstance().setInShowBBsName(username); MarketConfig.getInstance().setBbsUsername(username);
MarketConfig.getInstance().setBbsPassword(password);
MarketConfig.getInstance().setBbsUid(Integer.parseInt(uid));
MarketConfig.getInstance().setInShowBBsName(username);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{MarketConfig.class};
}
});
} catch (Exception e) { } 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().setBbsUid(0);
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }
} }
} }

11
designer-base/src/com/fr/design/extra/PluginWebBridge.java

@ -1,6 +1,5 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.bbs.BBSLoginUtils;
@ -20,9 +19,7 @@ import com.fr.general.SiteCenter;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javafx.concurrent.Task; import javafx.concurrent.Task;
@ -56,7 +53,7 @@ public class PluginWebBridge {
private static final String PLUGIN_INFO = "pluginInfo"; private static final String PLUGIN_INFO = "pluginInfo";
private static final int COREPOOLSIZE = 3; private static final int COREPOOLSIZE = 3;
private static final int MAXPOOLSIZE = 5; private static final int MAXPOOLSIZE = 5;
private static final String I18N_PREFIX = "Fine-"; private static final String I18N_PREFIX = "FR-";
private static PluginWebBridge helper; private static PluginWebBridge helper;
@ -109,7 +106,7 @@ public class PluginWebBridge {
jsonObject.put(key, config.get(key).toString()); jsonObject.put(key, config.get(key).toString());
} }
} catch (JSONException e) { } catch (JSONException e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return jsonObject.toString(); return jsonObject.toString();
} }
@ -443,7 +440,7 @@ public class PluginWebBridge {
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default"); String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default");
Desktop.getDesktop().browse(new URI(loginUrl)); Desktop.getDesktop().browse(new URI(loginUrl));
} catch (Exception exp) { } catch (Exception exp) {
FRContext.getLogger().info(exp.getMessage()); FineLoggerFactory.getLogger().info(exp.getMessage());
} }
} }
@ -519,7 +516,7 @@ public class PluginWebBridge {
try { try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.reset"))); Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.reset")));
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FineLoggerFactory.getLogger().info(e.getMessage());
} }
} }

6
designer-base/src/com/fr/design/extra/PluginWebPane.java

@ -1,8 +1,8 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.base.TemplateUtils; import com.fr.base.TemplateUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javafx.application.Platform; import javafx.application.Platform;
@ -56,7 +56,7 @@ public class PluginWebPane extends JFXPanel {
webView.setContextMenuEnabled(false);//屏蔽右键 webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView); root.setCenter(webView);
}catch (Exception e){ }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{ try{
htmlString = TemplateUtils.renderParameter4Tpl(sb.toString(), map4Tpl); htmlString = TemplateUtils.renderParameter4Tpl(sb.toString(), map4Tpl);
}catch (Exception e){ }catch (Exception e){
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
reader.close(); reader.close();
inp.close(); inp.close();

23
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.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginStoreConstants; import com.fr.plugin.PluginStoreConstants;
import com.fr.plugin.PluginVerifyException; import com.fr.plugin.PluginVerifyException;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
@ -42,6 +43,7 @@ public class WebViewDlgHelper {
private static final String SHOP_SCRIPTS = "shop_scripts"; private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8; private static final int VERSION_8 = 8;
private static String installHome = FRContext.getCurrentEnv().getWebReportPath(); private static String installHome = FRContext.getCurrentEnv().getWebReportPath();
private static final String MAIN_JS_PATH = "/scripts/plugin.html";
private static final int BYTES_NUM = 1024; private static final int BYTES_NUM = 1024;
static { static {
@ -55,8 +57,7 @@ public class WebViewDlgHelper {
public static void createPluginDialog() { public static void createPluginDialog() {
if (StableUtils.getMajorJavaVersion() >= VERSION_8) { if (StableUtils.getMajorJavaVersion() >= VERSION_8) {
String relativePath = "/scripts/plugin.html"; String mainJsPath = StableUtils.pathJoin(installHome, MAIN_JS_PATH);
String mainJsPath = StableUtils.pathJoin(installHome, relativePath);
File file = new File(mainJsPath); File file = new File(mainJsPath);
if (!file.exists()) { if (!file.exists()) {
int rv = JOptionPane.showConfirmDialog( int rv = JOptionPane.showConfirmDialog(
@ -70,10 +71,7 @@ public class WebViewDlgHelper {
downloadShopScripts(SHOP_SCRIPTS); downloadShopScripts(SHOP_SCRIPTS);
} }
} else { } else {
String indexPath = "plugin.html"; showPluginDlg();
String mainIndexPath = StableUtils.pathJoin(installHome, indexPath);
checkAndCopyMainFile(mainIndexPath, mainJsPath);
showPluginDlg(indexPath);
updateShopScripts(SHOP_SCRIPTS); updateShopScripts(SHOP_SCRIPTS);
} }
} else { } else {
@ -107,7 +105,7 @@ public class WebViewDlgHelper {
try { try {
CommonIOUtils.copy(new File(mainJsPath), new File(installHome)); CommonIOUtils.copy(new File(mainJsPath), new File(installHome));
} catch (IOException e) { } 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 { try {
Class<?> clazz = Class.forName("com.fr.design.extra.PluginWebPane"); Class<?> clazz = Class.forName("com.fr.design.extra.PluginWebPane");
Constructor constructor = clazz.getConstructor(String.class, String.class); 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); BasicPane managerPane = new ShopManagerPane(webPane);
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane); UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg); PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true); dlg.setVisible(true);
} catch (Throwable ignored) { } catch (Exception e) {
// ignored // 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); JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false; return false;
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false; return false;
} }
return true; 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); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), Inter.getLocText("FR-Designer_Tooltips"), JOptionPane.INFORMATION_MESSAGE);
} }
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }

Loading…
Cancel
Save