From 2dd0c8b75de43c7dabd749bf52d7648827c8e7cf Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 20 Apr 2016 09:06:21 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E5=8F=B3=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginWebPane.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer_base/src/com/fr/design/extra/PluginWebPane.java b/designer_base/src/com/fr/design/extra/PluginWebPane.java index 4278dd77c..36ce2c5d6 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebPane.java +++ b/designer_base/src/com/fr/design/extra/PluginWebPane.java @@ -48,6 +48,7 @@ public class PluginWebPane extends JFXPanel { }); JSObject obj = (JSObject) webEngine.executeScript("window"); obj.setMember("PluginHelper", PluginWebBridge.getHelper(webEngine)); + webView.setContextMenuEnabled(false);//屏蔽右键 root.setCenter(webView); } }); From 6ce793663d3059059b232c4f36821f0eedf2cb57 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 21 Apr 2016 02:14:16 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1=E3=80=81=E8=87=AA=E5=8A=A8=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E4=B8=8B=E8=BD=BD=E5=95=86=E5=BA=97=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=202=E3=80=81=E8=AF=A6=E6=83=85=E7=82=B9=E5=87=BB=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginHelper.java | 4 +- .../fr/design/extra/PluginManagerPane.java | 71 ++++++++++++++++++- .../com/fr/design/extra/PluginWebBridge.java | 14 ++-- .../com/fr/design/extra/PluginWebPane.java | 25 +------ 4 files changed, 81 insertions(+), 33 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index b50b904a0..86e5f49eb 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -31,8 +31,8 @@ import java.util.concurrent.ExecutionException; */ public class PluginHelper { private static final String TEMP_PATH = System.getProperty("user.dir") + "/tmp"; - private static final String DOWNLOAD_PATH = System.getProperty("user.dir") + "/download"; - private static final String TEMP_FILE = "temp.zip"; + public static final String DOWNLOAD_PATH = System.getProperty("user.dir") + "/download"; + public static final String TEMP_FILE = "temp.zip"; /** * 下载插件 diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index 3a63c685b..7f2280673 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -1,10 +1,17 @@ package com.fr.design.extra; +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.general.IOUtils; import com.fr.general.Inter; +import com.fr.stable.StableUtils; +import javax.swing.*; import java.awt.*; +import java.io.File; import java.net.URL; /** @@ -24,10 +31,29 @@ public class PluginManagerPane extends BasicPane { public PluginManagerPane() { setLayout(new BorderLayout()); if (System.getProperty("java.version").startsWith("1.8")) { - URL url = ClassLoader.getSystemResource(""); - String installHome = url.getPath(); - PluginWebPane webPane = new PluginWebPane(installHome); + String installHome; + if(StableUtils.isDebug()){ + URL url = ClassLoader.getSystemResource(""); + installHome = url.getPath() + "scripts"; + }else{ + installHome = StableUtils.getInstallHome() + File.separator + "scripts"; + File file = new File(installHome); + if (!file.exists()) { + int rv = JOptionPane.showConfirmDialog( + null, + "您还没有插件商店的资源,是否下载?", + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + downloadShopScripts(); + } + } + } + PluginWebPane webPane = new PluginWebPane(new File(installHome).getAbsolutePath()); add(webPane, BorderLayout.CENTER); + } else { initTraditionalStore(); } @@ -42,6 +68,45 @@ public class PluginManagerPane extends BasicPane { tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane)); } + private void downloadShopScripts() { + new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + String id = "shop_scripts"; + String username = DesignerEnvManager.getEnvManager().getBBSName(); + String password = DesignerEnvManager.getEnvManager().getBBSPassword(); + try { + PluginHelper.downloadPluginFile(id, username, password, new Process() { + @Override + public void process(Double integer) { + } + }); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + return null; + } + + @Override + protected void done() { + IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); + int rv = JOptionPane.showOptionDialog( + null, + "商店安装完毕,是否立刻启动?", + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")}, + null + ); + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + } + }.execute(); + } + @Override protected String title4PopupWindow() { return Inter.getLocText("FR-Designer-Plugin_Manager"); diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 90fcd2af0..7e4e70e24 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -261,6 +261,16 @@ public class PluginWebBridge { } } + /** + * 在本地浏览器里打开url + * tips:重载的时候,需要给js调用的方法需要放在前面,否则可能不会被调用(此乃坑) + * + * @param url 要打开的地址 + */ + public void openUrlAtLocalWebBrowser(String url) { + openUrlAtLocalWebBrowser(webEngine, url); + } + /** * 在本地浏览器里打开url * @@ -289,10 +299,6 @@ public class PluginWebBridge { } } - public void openUrlAtLocalWebBrowser(String url) { - openUrlAtLocalWebBrowser(webEngine, url); - } - /** * 从硬盘升级 * diff --git a/designer_base/src/com/fr/design/extra/PluginWebPane.java b/designer_base/src/com/fr/design/extra/PluginWebPane.java index 36ce2c5d6..76e4ef5e8 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebPane.java +++ b/designer_base/src/com/fr/design/extra/PluginWebPane.java @@ -1,9 +1,6 @@ package com.fr.design.extra; -import com.fr.general.FRLogger; import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; import javafx.embed.swing.JFXPanel; import javafx.event.EventHandler; import javafx.scene.Scene; @@ -32,20 +29,13 @@ public class PluginWebPane extends JFXPanel { PluginWebPane.this.setScene(scene); WebView webView = new WebView(); webEngine = webView.getEngine(); - webEngine.load("file:///" + installHome + "/scripts/store/web/index.html"); + webEngine.load("file:///" + installHome + "/store/web/index.html"); webEngine.setOnAlert(new EventHandler>() { @Override public void handle(WebEvent event) { showAlert(event.getData()); } }); - webEngine.locationProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, final String oldValue, String newValue) { - disableLink(webEngine); - PluginWebBridge.getHelper().openUrlAtLocalWebBrowser(webEngine, newValue); - } - }); JSObject obj = (JSObject) webEngine.executeScript("window"); obj.setMember("PluginHelper", PluginWebBridge.getHelper(webEngine)); webView.setContextMenuEnabled(false);//屏蔽右键 @@ -54,19 +44,6 @@ public class PluginWebPane extends JFXPanel { }); } - private void disableLink(final WebEngine webEngine) { - try { - Platform.runLater(new Runnable() { - @Override - public void run() { - webEngine.executeScript("history.go(0)"); - } - }); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } - private void showAlert(final String message) { SwingUtilities.invokeLater(new Runnable() { @Override From cb8e649a275326d78ea279dc9af078d087ec5c3b Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 21 Apr 2016 15:08:48 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=20=E6=8D=A2=E6=96=B0=E7=9A=84api=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E4=BB=A5=E5=8C=BA=E5=88=86=E9=87=8D=E8=BD=BD=E9=98=B2=E6=AD=A2?= =?UTF-8?q?js=E8=B0=83=E7=94=A8=E6=97=B6=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginManagerPane.java | 11 +++++------ .../src/com/fr/design/extra/PluginWebBridge.java | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index 7f2280673..43e9585c3 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -32,16 +32,16 @@ public class PluginManagerPane extends BasicPane { setLayout(new BorderLayout()); if (System.getProperty("java.version").startsWith("1.8")) { String installHome; - if(StableUtils.isDebug()){ + if (StableUtils.isDebug()) { URL url = ClassLoader.getSystemResource(""); - installHome = url.getPath() + "scripts"; - }else{ + installHome = url.getPath() + "scripts"; + } else { installHome = StableUtils.getInstallHome() + File.separator + "scripts"; File file = new File(installHome); if (!file.exists()) { int rv = JOptionPane.showConfirmDialog( null, - "您还没有插件商店的资源,是否下载?", + Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE @@ -53,7 +53,6 @@ public class PluginManagerPane extends BasicPane { } PluginWebPane webPane = new PluginWebPane(new File(installHome).getAbsolutePath()); add(webPane, BorderLayout.CENTER); - } else { initTraditionalStore(); } @@ -92,7 +91,7 @@ public class PluginManagerPane extends BasicPane { IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); int rv = JOptionPane.showOptionDialog( null, - "商店安装完毕,是否立刻启动?", + Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 7e4e70e24..947e8bd3a 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -33,7 +33,7 @@ public class PluginWebBridge { private UIDialog uiDialog; - public static final String PLUGIN_SHOP = "http://192.168.101.20/ShopServer?pg=plist"; + public static final String PLUGIN_SHOP = "http://192.168.101.20/ShopServer?pg=plist";//http://shop.finereport.com/ShopServer?pg=plist(plugin.list) public static PluginWebBridge getHelper() { if (helper != null) { @@ -264,10 +264,11 @@ public class PluginWebBridge { /** * 在本地浏览器里打开url * tips:重载的时候,需要给js调用的方法需要放在前面,否则可能不会被调用(此乃坑) + * 所以最好的是不要重载在js可以访问的接口文件中 * * @param url 要打开的地址 */ - public void openUrlAtLocalWebBrowser(String url) { + public void openShopUrlAtWebBrowser(String url) { openUrlAtLocalWebBrowser(webEngine, url); } From e832e8f77153af2880bb79c7a289eba95108acca Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 21 Apr 2016 16:24:55 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BD=BF=E7=94=A8sitecenter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginManagerPane.java | 7 ++++--- designer_base/src/com/fr/design/extra/PluginWebBridge.java | 3 ++- designer_base/src/com/fr/design/extra/PluginWebPane.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index 43e9585c3..26374d881 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -5,6 +5,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.StableUtils; @@ -34,10 +35,10 @@ public class PluginManagerPane extends BasicPane { String installHome; if (StableUtils.isDebug()) { URL url = ClassLoader.getSystemResource(""); - installHome = url.getPath() + "scripts"; + installHome = url.getPath(); } else { - installHome = StableUtils.getInstallHome() + File.separator + "scripts"; - File file = new File(installHome); + installHome = StableUtils.getInstallHome(); + File file = new File(StableUtils.pathJoin(installHome, "scripts")); if (!file.exists()) { int rv = JOptionPane.showConfirmDialog( null, diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 947e8bd3a..69f65075f 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -6,6 +6,7 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.extra.exe.*; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.general.SiteCenter; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLoader; import com.fr.stable.ArrayUtils; @@ -33,7 +34,7 @@ public class PluginWebBridge { private UIDialog uiDialog; - public static final String PLUGIN_SHOP = "http://192.168.101.20/ShopServer?pg=plist";//http://shop.finereport.com/ShopServer?pg=plist(plugin.list) + public static final String PLUGIN_SHOP = SiteCenter.getInstance().acquireUrlByKind("plugin.plist"); public static PluginWebBridge getHelper() { if (helper != null) { diff --git a/designer_base/src/com/fr/design/extra/PluginWebPane.java b/designer_base/src/com/fr/design/extra/PluginWebPane.java index 76e4ef5e8..0f2bd0760 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebPane.java +++ b/designer_base/src/com/fr/design/extra/PluginWebPane.java @@ -29,7 +29,7 @@ public class PluginWebPane extends JFXPanel { PluginWebPane.this.setScene(scene); WebView webView = new WebView(); webEngine = webView.getEngine(); - webEngine.load("file:///" + installHome + "/store/web/index.html"); + webEngine.load("file:///" + installHome + "/scripts/store/web/index.html"); webEngine.setOnAlert(new EventHandler>() { @Override public void handle(WebEvent event) { From 33b0cb649654912278a66ec7d09264c29d877973 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 21 Apr 2016 17:32:00 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=87=BA=E7=8E=B0null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginTask.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index 5efcdd1d4..eb4a99729 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -71,6 +71,9 @@ public class PluginTask extends Task { * @return 处理之后的字符串 */ private String changText(String old) { - return old.replaceAll("\"", "\\\\\"").replaceAll("\n", ""); + if(StringUtils.isNotBlank(old)){ + return old.replaceAll("\"", "\\\\\"").replaceAll("\n", ""); + } + return StringUtils.EMPTY; } }