From e6295278f45261dcb041feaa54b3e18f5afa6459 Mon Sep 17 00:00:00 2001 From: vito Date: Fri, 20 May 2016 17:44:43 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=88=A0=E9=99=A4=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=80=E4=B8=AA=E6=88=90=E5=8A=9F=E6=B6=88?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E4=BE=9B=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=202=E3=80=81=E6=9B=B4=E6=96=B0=E8=BF=87=E6=9C=9F=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=BC=B9=E5=87=BA=E4=B8=A4=E4=B8=AA=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E6=A1=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginWebBridge.java | 1 + .../design/extra/exe/UninstallExecutor.java | 6 +- .../extra/exe/UpdateOnlineExecutor.java | 112 +++++++++--------- 3 files changed, 63 insertions(+), 56 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 5c7c2e8a37..947104bf99 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -153,6 +153,7 @@ public class PluginWebBridge { * @param des 过滤文件描述 * @param filter 文件的后缀 * @return 选择的文件的路径 + * 这里换用JFileChooser会卡死,不知道为什么 */ public String showFileChooserWithFilter(String des, String filter) { FileChooser fileChooser = new FileChooser(); diff --git a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java index 3f0845a7af..d8fc7d9ec6 100644 --- a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java @@ -16,6 +16,7 @@ import javax.swing.*; public class UninstallExecutor implements Executor { private String[] pluginIDs; + private String result = "undo"; public UninstallExecutor(String[] pluginIDs) { this.pluginIDs = pluginIDs; @@ -23,7 +24,7 @@ public class UninstallExecutor implements Executor { @Override public String getTaskFinishMessage() { - return "插件已卸载完毕,重启后生效"; + return result; } @Override @@ -32,7 +33,7 @@ public class UninstallExecutor implements Executor { new Command() { @Override public String getExecuteMessage() { - return "删除成功"; + return null; } @Override @@ -62,6 +63,7 @@ public class UninstallExecutor implements Executor { JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } + result = "done"; if (rv == JOptionPane.OK_OPTION) { RestartHelper.restart(); } diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java index 30fe078969..0d3a03fc1b 100644 --- a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java @@ -10,6 +10,7 @@ import com.fr.design.extra.Process; import com.fr.general.Inter; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLoader; +import com.fr.plugin.PluginVerifyException; import com.fr.stable.StringUtils; import javax.swing.*; @@ -43,44 +44,51 @@ public class UpdateOnlineExecutor implements Executor { @Override public void run(Process process) { - if(StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())){ + if (StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())) { LoginCheckContext.fireLoginCheckListener(); } - if(StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())){ - for (int i = 0; i < pluginIDs.length; i++) { - Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); - String id = null; - if (plugin != null) { - id = plugin.getId(); - } - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String password = DesignerEnvManager.getEnvManager().getBBSPassword(); - try { - PluginHelper.downloadPluginFile(id, username, password, new Process() { - @Override - public void process(Double integer) { + if (StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())) { + try { + for (int i = 0; i < pluginIDs.length; i++) { + try { + Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); + String id = null; + if (plugin != null) { + id = plugin.getId(); + } + String username = DesignerEnvManager.getEnvManager().getBBSName(); + String password = DesignerEnvManager.getEnvManager().getBBSPassword(); + PluginHelper.downloadPluginFile(id, username, password, new Process() { + @Override + public void process(Double integer) { + } + }); + updateFileFromDisk(PluginHelper.getDownloadTempFile()); + process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); + } catch (Exception e) { + if (e instanceof PluginVerifyException) { + throw (PluginVerifyException) e; } - }); - updateFileFromDisk(PluginHelper.getDownloadTempFile()); - process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FRContext.getLogger().error(e.getMessage()); + } } - } - int rv = JOptionPane.showOptionDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Update_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(); + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText("FR-Designer-Plugin_Update_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) { + JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } @@ -88,26 +96,22 @@ public class UpdateOnlineExecutor implements Executor { }; } - private void updateFileFromDisk(File fileOnDisk) { - try { - Plugin plugin = PluginHelper.readPlugin(fileOnDisk); - if (plugin == null) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - return; - } - Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); - if (oldPlugin != null) { - String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); - PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { - @Override - public void done() { - } - }); - } else { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + private void updateFileFromDisk(File fileOnDisk) throws Exception { + Plugin plugin = PluginHelper.readPlugin(fileOnDisk); + if (plugin == null) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + return; + } + Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); + if (oldPlugin != null) { + String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); + PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { + @Override + public void done() { + } + }); + } else { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } }