From b79066246268df749f89fc2f2d255c671be165f7 Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 19 Apr 2016 20:01:51 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=8F=92=E4=BB=B6=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=202=E3=80=81=E6=96=B0=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=89=93=E5=BC=80=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginWebBridge.java | 12 +++++ .../extra/exe/InstallOnlineExecutor.java | 16 +++++- .../extra/exe/ReadUpdateOnlineExecutor.java | 50 +++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 65ef0c56d..90fcd2af0 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -127,6 +127,14 @@ public class PluginWebBridge { new Thread(task).start(); } + /** + * 已安装插件检查更新 + */ + public void readUpdateOnline(final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new ReadUpdateOnlineExecutor()); + new Thread(task).start(); + } + /** * 选择文件对话框 * @@ -281,6 +289,10 @@ public class PluginWebBridge { } } + public void openUrlAtLocalWebBrowser(String url) { + openUrlAtLocalWebBrowser(webEngine, url); + } + /** * 从硬盘升级 * diff --git a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java index bd3711bd6..d343ec590 100644 --- a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java @@ -2,9 +2,9 @@ package com.fr.design.extra.exe; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; import com.fr.design.extra.After; import com.fr.design.extra.PluginHelper; -import com.fr.design.extra.PluginWebBridge; import com.fr.design.extra.Process; import com.fr.general.Inter; import com.fr.plugin.PluginVerifyException; @@ -64,7 +64,19 @@ public class InstallOnlineExecutor implements Executor { PluginHelper.installPluginFromDisk(PluginHelper.getDownloadTempFile(), new After() { @Override public void done() { - PluginWebBridge.getHelper().showRestartMessage(Inter.getLocText("FR-Designer-Plugin_Update_Successful")); + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText("FR-Designer-Plugin_Install_Successful"), + 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(); + } } }); } catch (PluginVerifyException e) { diff --git a/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java new file mode 100644 index 000000000..8120049e1 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java @@ -0,0 +1,50 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.PluginsReaderFromStore; +import com.fr.design.extra.Process; +import com.fr.general.FRLogger; +import com.fr.plugin.Plugin; +import com.fr.stable.StringUtils; + +/** + * Created by vito on 16/4/19. + */ +public class ReadUpdateOnlineExecutor implements Executor { + private Plugin[] plugins; + private String result; + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return StringUtils.EMPTY; + } + + @Override + public void run(Process process) { + try { + plugins = PluginsReaderFromStore.readPluginsForUpdate(); + StringBuilder sb = new StringBuilder(); + if (plugins != null) { + sb.append("["); + for (Plugin plugin : plugins) { + sb.append("{pluginid:'").append(plugin.getId()).append("'}"); + } + sb.append("]"); + } + result = sb.toString(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + } + }; + } +}