Kanagaraj M has uploaded a new change for review. Change subject: webadmin: refactor volume list action availability ......................................................................
webadmin: refactor volume list action availability Refactored update available actions code which depends on volume selections. Introduced individual boolean flags for deciding the availability of the actions to avoid multiple calls to the actual command availablity methods. Change-Id: I7f003dfe536189e1fa1d38e380e7acb7db208a22 Signed-off-by: Kanagaraj M <kmayi...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java 1 file changed, 30 insertions(+), 24 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/83/18383/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java index 04316c7..e4a1317 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java @@ -332,32 +332,35 @@ } private void updateActionAvailability() { - if (getSelectedItems() == null || getSelectedItems().size() == 0) - { - getRemoveVolumeCommand().setIsExecutionAllowed(false); - getStopCommand().setIsExecutionAllowed(false); - getStartCommand().setIsExecutionAllowed(false); - getRebalanceCommand().setIsExecutionAllowed(false); - getOptimizeForVirtStoreCommand().setIsExecutionAllowed(false); + + boolean allowStart = true; + boolean allowStop = true; + boolean allowRemove = true; + boolean allowStartRebalance = true; + boolean allowOptimize = true; + + if (getSelectedItems() == null || getSelectedItems().size() == 0) { + allowStart = false; + allowStop = false; + allowRemove = false; + allowStartRebalance = false; + allowOptimize = false; } else { - getRemoveVolumeCommand().setIsExecutionAllowed(true); - getStopCommand().setIsExecutionAllowed(true); - getStartCommand().setIsExecutionAllowed(true); - getRebalanceCommand().setIsExecutionAllowed(true); - getOptimizeForVirtStoreCommand().setIsExecutionAllowed(true); + allowStart = true; + allowStop = true; + allowRemove = true; + allowStartRebalance = true; + allowOptimize = true; - for (GlusterVolumeEntity volume : Linq.<GlusterVolumeEntity> cast(getSelectedItems())) - { - if (volume.getStatus() == GlusterStatus.UP) - { - getRemoveVolumeCommand().setIsExecutionAllowed(false); - getStartCommand().setIsExecutionAllowed(false); + for (GlusterVolumeEntity volume : Linq.<GlusterVolumeEntity> cast(getSelectedItems())) { + if (volume.getStatus() == GlusterStatus.UP) { + allowStart = false; + allowRemove = false; } - else if (volume.getStatus() == GlusterStatus.DOWN) - { - getStopCommand().setIsExecutionAllowed(false); - getRebalanceCommand().setIsExecutionAllowed(false); + else if (volume.getStatus() == GlusterStatus.DOWN) { + allowStop = false; + allowStartRebalance = false; } } } @@ -367,8 +370,11 @@ !(getSystemTreeSelectedItem() != null && getSystemTreeSelectedItem().getType() == SystemTreeItemType.Volume); getNewVolumeCommand().setIsAvailable(isAvailable); - getRemoveVolumeCommand().setIsAvailable(isAvailable); - + getStartCommand().setIsAvailable(allowStart); + getStopCommand().setIsAvailable(allowStop); + getRemoveVolumeCommand().setIsAvailable(isAvailable && allowRemove); + getRebalanceCommand().setIsAvailable(allowStartRebalance); + getOptimizeForVirtStoreCommand().setIsAvailable(allowOptimize); } private void cancel() { -- To view, visit http://gerrit.ovirt.org/18383 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7f003dfe536189e1fa1d38e380e7acb7db208a22 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Kanagaraj M <kmayi...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches