From 111b87f08b4862f55a5c82162c3405dfe51eb337 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 22 Jun 2017 17:16:52 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-2354=20=E4=BE=9D=E8=B5=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/extra/PluginOperateUtils.java | 28 +++++++++-- .../exe/callback/InstallOnlineCallback.java | 46 +++++-------------- .../exe/callback/UpdateOnlineCallback.java | 43 ++++------------- .../exe/extratask/InstallPluginTask.java | 26 ----------- .../extra/exe/extratask/UpdatePluginTask.java | 26 ----------- 5 files changed, 43 insertions(+), 126 deletions(-) delete mode 100644 designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java delete mode 100644 designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java index 516d1f0e19..e55d6fc355 100644 --- a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -3,8 +3,6 @@ package com.fr.design.extra; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.extra.exe.callback.*; -import com.fr.design.extra.exe.extratask.InstallPluginTask; -import com.fr.design.extra.exe.extratask.UpdatePluginTask; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.general.SiteCenter; @@ -16,7 +14,8 @@ import com.fr.plugin.context.PluginMarker; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.bbs.BBSPluginLogin; import com.fr.plugin.manage.bbs.BBSUserInfo; -import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.manage.control.*; +import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; @@ -36,7 +35,8 @@ public class PluginOperateUtils { LoginCheckContext.fireLoginCheckListener(); } if (BBSPluginLogin.getInstance().hasLogin()) { - PluginManager.getController().download(pluginMarker, new DownloadCallback(new InstallPluginTask(pluginMarker, jsCallback), jsCallback)); + PluginTask pluginTask = PluginTask.installTask(pluginMarker, pluginMarker); + PluginControllerHelper.installOnline(pluginMarker, new InstallOnlineCallback(pluginTask, jsCallback)); } } @@ -61,7 +61,8 @@ public class PluginOperateUtils { JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); String latestPluginVersion = (String) latestPluginInfo.get("version"); PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion); - PluginManager.getController().download(toPluginMarker, new DownloadCallback(new UpdatePluginTask(pluginMarker, toPluginMarker, jsCallback), jsCallback)); + PluginTask pluginTask = PluginTask.updateTask(pluginMarker, toPluginMarker); + PluginControllerHelper.updateOnline(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginTask, jsCallback)); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); } @@ -280,4 +281,21 @@ public class PluginOperateUtils { && StringUtils.isNotEmpty(pluginView.getEnvVersion()); } + public static String getSuccessInfo(PluginTaskResult result){ + StringBuilder pluginInfo = new StringBuilder(); + PluginTask currentTask = result.getCurrentTask(); + PluginContext context = PluginManager.getContext(currentTask.getMarker()); + if(context != null){ + pluginInfo.append(context.getName()); + } + List pluginTasks = result.getPreTasks(); + for(PluginTask pluginTask : pluginTasks){ + PluginContext pluginContext = PluginManager.getContext(pluginTask.getMarker()); + if(pluginContext != null){ + pluginInfo.append(pluginContext.getName()); + } + } + return pluginInfo.toString(); + } + } diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index c123950210..e0c5f4ce5e 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -3,25 +3,21 @@ package com.fr.design.extra.exe.callback; import com.fr.design.extra.PluginOperateUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; import com.fr.plugin.error.PluginErrorCode; -import com.fr.plugin.manage.PluginManager; -import com.fr.plugin.manage.control.PluginTask; -import com.fr.plugin.manage.control.PluginTaskResult; +import com.fr.plugin.manage.control.*; import javax.swing.*; -import java.util.List; /** * Created by ibm on 2017/5/26. */ -public class InstallOnlineCallback extends AbstractPluginTaskCallback { +public class InstallOnlineCallback extends AbstractDealPreTaskCallback { protected JSCallback jsCallback; private static int HUNDRED_PERCENT = 100; - public InstallOnlineCallback(PluginMarker pluginMarker, JSCallback jsCallback){ - this.pluginMarker = pluginMarker; + public InstallOnlineCallback(PluginTask pluginTask, JSCallback jsCallback){ + super(pluginTask); this.jsCallback = jsCallback; } @@ -32,34 +28,12 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback { @Override - public void done(PluginTaskResult result) { + protected void allDone(PluginTaskResult result) { if (result.isSuccess()) { - PluginContext pluginContext = PluginManager.getContext(pluginMarker); - String pluginName = pluginContext.getName(); + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); jsCallback.execute("success"); - FRLogger.getLogger().info(pluginName + Inter.getLocText("FR-Designer-Plugin_Install_Success")); - JOptionPane.showMessageDialog(null, pluginName + Inter.getLocText("FR-Designer-Plugin_Install_Success")); - } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { - int rv = JOptionPane.showOptionDialog( - null, - Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - null, - null - ); - if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { - return; - } - List pluginTasks = result.getPreTasks(); - for(PluginTask pluginTask : pluginTasks){ - PluginMarker marker = pluginTask.getMarker(); - PluginOperateUtils.installPluginOnline(marker, jsCallback ); - } - //执行JS回调 - PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback); + FRLogger.getLogger().info(pluginInfo + Inter.getLocText("FR-Designer-Plugin_Install_Success")); + JOptionPane.showMessageDialog(null, pluginInfo + Inter.getLocText("FR-Designer-Plugin_Install_Success")); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ int rv = JOptionPane.showOptionDialog( null, @@ -74,6 +48,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback { if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { return; } + PluginMarker pluginMarker = result.getCurrentTask().getMarker(); PluginOperateUtils.updatePluginOnline(pluginMarker, jsCallback); }else { jsCallback.execute("failed"); @@ -81,4 +56,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback { JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } + + + } diff --git a/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index f68f34b952..9f7325fe06 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -3,27 +3,21 @@ package com.fr.design.extra.exe.callback; import com.fr.design.extra.PluginOperateUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.context.PluginContext; -import com.fr.plugin.context.PluginMarker; -import com.fr.plugin.error.PluginErrorCode; -import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; import com.fr.plugin.manage.control.PluginTask; import com.fr.plugin.manage.control.PluginTaskResult; import javax.swing.*; -import java.util.List; /** * Created by ibm on 2017/5/26. */ -public class UpdateOnlineCallback extends AbstractPluginTaskCallback { - public PluginMarker toPluginMarker; +public class UpdateOnlineCallback extends AbstractDealPreTaskCallback { protected JSCallback jsCallback; private static int HUNDRED_PERCENT = 100; - public UpdateOnlineCallback(PluginMarker pluginMarker, PluginMarker toPluginMarker, JSCallback jsCallback) { - this.pluginMarker = pluginMarker; - this.toPluginMarker = toPluginMarker; + public UpdateOnlineCallback(PluginTask pluginTask, JSCallback jsCallback) { + super(pluginTask); this.jsCallback = jsCallback; } @@ -33,33 +27,12 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback { } @Override - public void done(PluginTaskResult result) { + public void allDone(PluginTaskResult result) { if (result.isSuccess()) { - PluginContext pluginContext = PluginManager.getContext(toPluginMarker); - String pluginName = pluginContext.getName(); + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); jsCallback.execute("success"); - FRLogger.getLogger().info(pluginName + Inter.getLocText("FR-Designer-Plugin_Update_Success")); - JOptionPane.showMessageDialog(null,pluginName + Inter.getLocText("FR-Designer-Plugin_Update_Success")); - } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { - int rv = JOptionPane.showOptionDialog( - null, - Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Update_Dependence")), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, - null, - null, - null - ); - if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { - return; - } - List pluginTasks = result.getPreTasks(); - for(PluginTask pluginTask : pluginTasks){ - PluginMarker marker = pluginTask.getMarker(); - PluginOperateUtils.updatePluginOnline(marker, jsCallback); - } - PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback)); + FRLogger.getLogger().info(pluginInfo + Inter.getLocText("FR-Designer-Plugin_Update_Success")); + JOptionPane.showMessageDialog(null,pluginInfo + Inter.getLocText("FR-Designer-Plugin_Update_Success")); } else { jsCallback.execute("failed"); FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Failed")); diff --git a/designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java b/designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java deleted file mode 100644 index 37ac42d4d5..0000000000 --- a/designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.fr.design.extra.exe.extratask; - - -import com.fr.design.extra.exe.callback.InstallOnlineCallback; -import com.fr.design.extra.exe.callback.JSCallback; -import com.fr.plugin.context.PluginMarker; -import com.fr.plugin.manage.PluginManager; - - -/** - * Created by ibm on 2017/5/27. - */ -public class InstallPluginTask extends AbstractExtraPluginTask { - protected JSCallback jsCallback; - - - public InstallPluginTask(PluginMarker pluginMarker, JSCallback jsCallback) { - this.pluginMarker = pluginMarker; - this.jsCallback = jsCallback; - } - - @Override - public void doExtraPluginTask() { - PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback)); - } -} diff --git a/designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java b/designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java deleted file mode 100644 index 7cfdf96227..0000000000 --- a/designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.fr.design.extra.exe.extratask; - -import com.fr.design.extra.exe.callback.JSCallback; -import com.fr.design.extra.exe.callback.UpdateOnlineCallback; -import com.fr.plugin.context.PluginMarker; -import com.fr.plugin.manage.PluginManager; - -/** - * Created by ibm on 2017/5/27. - */ -public class UpdatePluginTask extends AbstractExtraPluginTask { - - public PluginMarker toPluginMarker; - protected JSCallback jsCallback; - - public UpdatePluginTask(PluginMarker pluginMarker, PluginMarker toPluginMarker, JSCallback jsCallback) { - this.pluginMarker = pluginMarker; - this.toPluginMarker = toPluginMarker; - this.jsCallback = jsCallback; - } - - @Override - public void doExtraPluginTask() { - PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback)); - } -} From 050f9c884e25a283c1ad66a143a0b153dff097a8 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 22 Jun 2017 17:24:30 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginOperateUtils.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java index e55d6fc355..22458b85dd 100644 --- a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -288,11 +288,14 @@ public class PluginOperateUtils { if(context != null){ pluginInfo.append(context.getName()); } - List pluginTasks = result.getPreTasks(); - for(PluginTask pluginTask : pluginTasks){ - PluginContext pluginContext = PluginManager.getContext(pluginTask.getMarker()); - if(pluginContext != null){ - pluginInfo.append(pluginContext.getName()); + List pluginTaskResults = result.asList(); + for(PluginTaskResult pluginTaskResult : pluginTaskResults){ + List pluginTasks = pluginTaskResult.getPreTasks(); + for(PluginTask pluginTask : pluginTasks){ + PluginContext pluginContext = PluginManager.getContext(pluginTask.getMarker()); + if(pluginContext != null){ + pluginInfo.append(pluginContext.getName()); + } } } return pluginInfo.toString(); From 0044dca1ccc9814ab3c06a569afd642365c0e63b Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 22 Jun 2017 17:38:56 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginOperateUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java index 22458b85dd..0e1943a71a 100644 --- a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -35,7 +35,7 @@ public class PluginOperateUtils { LoginCheckContext.fireLoginCheckListener(); } if (BBSPluginLogin.getInstance().hasLogin()) { - PluginTask pluginTask = PluginTask.installTask(pluginMarker, pluginMarker); + PluginTask pluginTask = PluginTask.installTask(pluginMarker); PluginControllerHelper.installOnline(pluginMarker, new InstallOnlineCallback(pluginTask, jsCallback)); } } From 386a738c653b1b8acbdd120c7e46ec54d13e5542 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 23 Jun 2017 16:19:17 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0final?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/exe/callback/JSCallback.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java index a46f73b30e..c246ebfa8f 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java @@ -22,7 +22,7 @@ public class JSCallback { public void init(final WebEngine webEngine, final JSObject callback){ executeScript = new JSExecutor() { @Override - public void executor(String newValue) { + public void executor(final String newValue) { Platform.runLater(new Runnable() { @Override public void run() { From 3dbc967abcc6d91e9120aa0b76f3baca79111b7e Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 23 Jun 2017 16:24:03 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/extra/exe/callback/InstallFromDiskCallback.java | 1 - .../fr/design/extra/exe/callback/InstallOnlineCallback.java | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 16c46ebe7d..2fdb2e45a0 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -3,7 +3,6 @@ package com.fr.design.extra.exe.callback; import com.fr.design.extra.PluginOperateUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.PluginManager; diff --git a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index e0c5f4ce5e..059b5125e2 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -5,10 +5,13 @@ import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.plugin.context.PluginMarker; import com.fr.plugin.error.PluginErrorCode; -import com.fr.plugin.manage.control.*; +import com.fr.plugin.manage.control.AbstractDealPreTaskCallback; +import com.fr.plugin.manage.control.PluginTask; +import com.fr.plugin.manage.control.PluginTaskResult; import javax.swing.*; + /** * Created by ibm on 2017/5/26. */ From f70a24d40b3ed25e766c0aa42e4863c30a753f17 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 23 Jun 2017 16:27:02 +0800 Subject: [PATCH 6/6] =?UTF-8?q?import=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginOperateUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java index 0e1943a71a..48b3d4b28c 100644 --- a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -14,8 +14,10 @@ import com.fr.plugin.context.PluginMarker; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.bbs.BBSPluginLogin; import com.fr.plugin.manage.bbs.BBSUserInfo; -import com.fr.plugin.manage.control.*; +import com.fr.plugin.manage.control.PluginControllerHelper; import com.fr.plugin.manage.control.PluginTask; +import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils;