Tal Nisan has uploaded a new change for review.

Change subject: webadmin: Make updateActionAvailability in VmListModel more 
readable
......................................................................

webadmin: Make updateActionAvailability in VmListModel more readable

Change-Id: I6882f2312a246e02b1b1caa960864b30197d14af
Signed-off-by: Tal Nisan <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
1 file changed, 21 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/16/38416/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
index 073d8eb..b090ce6 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
@@ -2257,48 +2257,48 @@
     }
 
     private void updateActionAvailability() {
-        List items =
-                getSelectedItems() != null && getSelectedItem() != null ? 
getSelectedItems()
-                        : new ArrayList();
+        List items = getSelectedItems() != null && getSelectedItem() != null ? 
getSelectedItems() : new ArrayList();
 
-        getCloneVmCommand().setIsExecutionAllowed(items.size() == 1);
+        boolean singleVmSelected = items.size() == 1;
+        boolean vmsSelected = items.size() > 0;
+
+        getCloneVmCommand().setIsExecutionAllowed(singleVmSelected);
         
getEditCommand().setIsExecutionAllowed(isEditCommandExecutionAllowed(items));
-        getRemoveCommand().setIsExecutionAllowed(items.size() > 0
+        getRemoveCommand().setIsExecutionAllowed(vmsSelected
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.RemoveVm));
-        getRunCommand().setIsExecutionAllowed(items.size() > 0
+        getRunCommand().setIsExecutionAllowed(vmsSelected
                 && VdcActionUtils.canExecutePartially(items, VM.class, 
VdcActionType.RunVm));
-        getCloneVmCommand().setIsExecutionAllowed(items.size() == 1
+        getCloneVmCommand().setIsExecutionAllowed(singleVmSelected
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.CloneVm));
-        getPauseCommand().setIsExecutionAllowed(items.size() > 0
+        getPauseCommand().setIsExecutionAllowed(vmsSelected
                                                         && 
VdcActionUtils.canExecutePartially(items, VM.class, VdcActionType.HibernateVm)
                                                         && 
AsyncDataProvider.getInstance().canVmsBePaused(items));
-        getShutdownCommand().setIsExecutionAllowed(items.size() > 0
+        getShutdownCommand().setIsExecutionAllowed(vmsSelected
                 && VdcActionUtils.canExecutePartially(items, VM.class, 
VdcActionType.ShutdownVm));
-        getStopCommand().setIsExecutionAllowed(items.size() > 0
+        getStopCommand().setIsExecutionAllowed(vmsSelected
                 && VdcActionUtils.canExecutePartially(items, VM.class, 
VdcActionType.StopVm));
         
getRebootCommand().setIsExecutionAllowed(AsyncDataProvider.getInstance().isRebootCommandExecutionAllowed(items));
-        getMigrateCommand().setIsExecutionAllowed(items.size() > 0
+        getMigrateCommand().setIsExecutionAllowed(vmsSelected
                 && VdcActionUtils.canExecutePartially(items, VM.class, 
VdcActionType.MigrateVm));
-        getCancelMigrateCommand().setIsExecutionAllowed(items.size() > 0
+        getCancelMigrateCommand().setIsExecutionAllowed(vmsSelected
                 && VdcActionUtils.canExecutePartially(items, VM.class, 
VdcActionType.CancelMigrateVm));
-        getNewTemplateCommand().setIsExecutionAllowed(items.size() == 1
+        getNewTemplateCommand().setIsExecutionAllowed(singleVmSelected
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.AddVmTemplate));
-        getRunOnceCommand().setIsExecutionAllowed(items.size() == 1
+        getRunOnceCommand().setIsExecutionAllowed(singleVmSelected
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.RunVmOnce));
-        getExportCommand().setIsExecutionAllowed(items.size() > 0
+        getExportCommand().setIsExecutionAllowed(vmsSelected
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.ExportVm));
-        getCreateSnapshotCommand().setIsExecutionAllowed(items.size() == 1
+        getCreateSnapshotCommand().setIsExecutionAllowed(singleVmSelected
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.CreateAllSnapshotsFromVm));
-        getRetrieveIsoImagesCommand().setIsExecutionAllowed(items.size() == 1
+        getRetrieveIsoImagesCommand().setIsExecutionAllowed(singleVmSelected
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.ChangeDisk));
-        getChangeCdCommand().setIsExecutionAllowed(items.size() == 1
+        getChangeCdCommand().setIsExecutionAllowed(singleVmSelected
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.ChangeDisk));
-        getAssignTagsCommand().setIsExecutionAllowed(items.size() > 0);
+        getAssignTagsCommand().setIsExecutionAllowed(vmsSelected);
 
         updateHaMaintenanceAvailability(items);
 
-        getGuideCommand().setIsExecutionAllowed(getGuideContext() != null
-                || (getSelectedItem() != null && getSelectedItems() != null && 
getSelectedItems().size() == 1));
+        getGuideCommand().setIsExecutionAllowed(getGuideContext() != null || 
singleVmSelected);
 
         
getConsoleConnectCommand().setIsExecutionAllowed(isConsoleCommandsExecutionAllowed());
         getEditConsoleCommand().setIsExecutionAllowed(isConsoleEditEnabled());


-- 
To view, visit https://gerrit.ovirt.org/38416
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6882f2312a246e02b1b1caa960864b30197d14af
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tal Nisan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to