Lior Vernia has uploaded a new change for review. Change subject: webadmin: Removed recursion for readability's sake ......................................................................
webadmin: Removed recursion for readability's sake The attach and detach commands were being run in parallel, so that when both terminate the dialog is closed and the source tab is refreshed. However, this was implemented in a bizarre recursion which wasn't trivial to follow. Hopefully it is more readable now. Change-Id: I4cb3238dbc82cbf8f41d9bf93889649f8d021f54 Signed-off-by: Lior Vernia <lver...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterNetworkManageModel.java 1 file changed, 34 insertions(+), 29 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/05/22905/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterNetworkManageModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterNetworkManageModel.java index b4507ac..b32135d 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterNetworkManageModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterNetworkManageModel.java @@ -18,6 +18,8 @@ private final SearchableListModel<?> sourceListModel; private final UICommand okCommand; private final UICommand cancelCommand; + private boolean needsAttach; + private boolean needsDetach; public ClusterNetworkManageModel(SearchableListModel<?> sourceListModel) { this.sourceListModel = sourceListModel; @@ -110,41 +112,44 @@ } } - final IFrontendMultipleActionAsyncCallback callback = new IFrontendMultipleActionAsyncCallback() { - Boolean needsAttach = !toAttach.isEmpty(); - Boolean needsDetach = !toDetach.isEmpty(); + startProgress(null); + needsAttach = !toAttach.isEmpty(); + needsDetach = !toDetach.isEmpty(); + if (needsAttach) { + Frontend.getInstance().runMultipleAction(VdcActionType.AttachNetworkToVdsGroup, + toAttach, + new IFrontendMultipleActionAsyncCallback() { - @Override - public void executed(FrontendMultipleActionAsyncResult result) { - if (result.getActionType() == VdcActionType.DetachNetworkToVdsGroup) { - needsDetach = false; - } - if (result.getActionType() == VdcActionType.AttachNetworkToVdsGroup) { + @Override + public void executed(FrontendMultipleActionAsyncResult result) { needsAttach = false; - } - - if (needsAttach) { - Frontend.getInstance().runMultipleAction(VdcActionType.AttachNetworkToVdsGroup, toAttach, this, null); - } - - if (needsDetach) { - Frontend.getInstance().runMultipleAction(VdcActionType.DetachNetworkToVdsGroup, toDetach, this, null); - } - - if (!needsAttach && !needsDetach) { doFinish(); } - } + }); + } + if (needsDetach) { + Frontend.getInstance().runMultipleAction(VdcActionType.DetachNetworkToVdsGroup, + toDetach, + new IFrontendMultipleActionAsyncCallback() { - private void doFinish() { - stopProgress(); - cancel(); - sourceListModel.forceRefresh(); - } - }; + @Override + public void executed(FrontendMultipleActionAsyncResult result) { + needsDetach = false; + doFinish(); + } + }); + } + doFinish(); + } - callback.executed(new FrontendMultipleActionAsyncResult(null, null, null)); - startProgress(null); + private void doFinish() { + if (needsAttach || needsDetach) { + return; + } + + stopProgress(); + cancel(); + sourceListModel.forceRefresh(); } private void cancel() { -- To view, visit http://gerrit.ovirt.org/22905 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4cb3238dbc82cbf8f41d9bf93889649f8d021f54 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <lver...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches