zack 7 years ago
parent
commit
f7cf0dc38a
  1. 39
      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

39
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 {
Configurations.update(new Worker() {
@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) {
FRContext.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
public static void bbsLogin(List<String> list) {
try {
String uid = list.get(0);
String username = list.get(1);
String password = list.get(2);
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<? extends Configuration>[] 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());
}
}
}

11
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());
}
}

6
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();

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.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);
}
}

Loading…
Cancel
Save