Source:
private void updateActionAvailability() { ArrayList<StorageDomain> items = getItems() != null ? Linq.<StorageDomain> cast(getItems()) : new ArrayList<StorageDomain>(); ArrayList<StorageDomain> selectedItems = getSelectedItems() != null ? Linq.<StorageDomain> cast(getSelectedItems()) : new ArrayList<StorageDomain>(); if (getEntity() != null) { getAttachStorageCommand().setIsExecutionAllowed(!getEntity().isLocal()); } boolean isMasterPresents = false; boolean isISOPresents = false; boolean isBackupPresents = false; for (StorageDomain domain : items) { if (isMasterDomain(domain)) { isMasterPresents = true; } if (domain.getStorageDomainType() == StorageDomainType.ISO) { isISOPresents = true; } if (domain.getStorageDomainType() == StorageDomainType.ImportExport) { isBackupPresents = true; } } getAttachISOCommand().setIsExecutionAllowed(false); getAttachISOCommand().setIsExecutionAllowed(items.size() > 0 && isMasterPresents && !isISOPresents); getAttachBackupCommand().setIsExecutionAllowed(items.size() > 0 && isMasterPresents && !isBackupPresents); getDetachCommand().setIsExecutionAllowed(selectedItems.size() > 0 && VdcActionUtils.canExecute(selectedItems, StorageDomain.class, VdcActionType.DetachStorageDomainFromPool)); getActivateCommand().setIsExecutionAllowed(selectedItems.size() == 1 && VdcActionUtils.canExecute(selectedItems, StorageDomain.class, VdcActionType.ActivateStorageDomain)); getMaintenanceCommand().setIsExecutionAllowed(selectedItems.size() == 1 && VdcActionUtils.canExecute(selectedItems, StorageDomain.class, VdcActionType.DeactivateStorageDomainWithOvfUpdate)); }

Target:
private void updateActionAvailability() { ArrayList<StorageDomain> items = getItems() != null ? Linq.<StorageDomain> cast(getItems()) : new ArrayList<StorageDomain>(); ArrayList<StorageDomain> selectedItems = getSelectedItems() != null ? Linq.<StorageDomain> cast(getSelectedItems()) : new ArrayList<StorageDomain>(); if (getEntity() != null) { getAttachStorageCommand().setIsExecutionAllowed(!getEntity().isLocal()); } boolean isMasterPresents = false; boolean isISOPresents = false; boolean isBackupPresents = false; for (StorageDomain domain : items) { if (isMasterDomain(domain)) { isMasterPresents = true; } else if (domain.getStorageDomainType() == StorageDomainType.ISO) { isISOPresents = true; } else if (domain.getStorageDomainType() == StorageDomainType.ImportExport) { isBackupPresents = true; } if (isMasterPresents && isISOPresents && isBackupPresents) { break; } } getAttachISOCommand().setIsExecutionAllowed(false); getAttachISOCommand().setIsExecutionAllowed(items.size() > 0 && isMasterPresents && !isISOPresents); getAttachBackupCommand().setIsExecutionAllowed(items.size() > 0 && isMasterPresents && !isBackupPresents); getDetachCommand().setIsExecutionAllowed(selectedItems.size() > 0 && VdcActionUtils.canExecute(selectedItems, StorageDomain.class, VdcActionType.DetachStorageDomainFromPool)); getActivateCommand().setIsExecutionAllowed(selectedItems.size() == 1 && VdcActionUtils.canExecute(selectedItems, StorageDomain.class, VdcActionType.ActivateStorageDomain)); getMaintenanceCommand().setIsExecutionAllowed(selectedItems.size() == 1 && VdcActionUtils.canExecute(selectedItems, StorageDomain.class, VdcActionType.DeactivateStorageDomainWithOvfUpdate)); }