Search in sources :

Example 16 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class DataCenterGuideModel method onAttachStorage.

public void onAttachStorage() {
    ListModel<EntityModel<StorageDomain>> model = (ListModel<EntityModel<StorageDomain>>) getWindow();
    ArrayList<StorageDomain> items = new ArrayList<>();
    for (EntityModel<StorageDomain> a : model.getItems()) {
        if (a.getIsSelected()) {
            items.add(a.getEntity());
        }
    }
    if (items.size() > 0) {
        for (StorageDomain sd : items) {
            attachStorageToDataCenter(sd.getId(), getEntity().getId());
        }
    }
    cancel();
    postAction();
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ClusterListModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList)

Example 17 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class DataCenterStorageListModel method attachISO.

public void attachISO() {
    ListModel listModel = new ListModel();
    listModel.setTitle(ConstantsManager.getInstance().getConstants().attachISOLibraryTitle());
    listModel.setHelpTag(HelpTag.attach_iso_library);
    // $NON-NLS-1$
    listModel.setHashName("attach_iso_library");
    attachInternal(listModel, StorageDomainType.ISO);
}
Also used : SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel)

Example 18 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class DataCenterStorageListModel method onAttach.

public void onAttach() {
    ListModel<EntityModel<StorageDomain>> model = (ListModel<EntityModel<StorageDomain>>) getWindow();
    List<StorageDomain> selectedDataStorageDomains = new ArrayList<>();
    if (getEntity() == null) {
        cancel();
        return;
    }
    selectedStorageDomains = new ArrayList<>();
    for (EntityModel<StorageDomain> a : model.getItems()) {
        if (a.getIsSelected()) {
            StorageDomain storageDomain = a.getEntity();
            selectedStorageDomains.add(storageDomain);
            if (storageDomain.getStorageDomainType() == StorageDomainType.Data) {
                selectedDataStorageDomains.add(storageDomain);
            }
        }
    }
    if (selectedStorageDomains.isEmpty()) {
        cancel();
        return;
    }
    AsyncDataProvider.getInstance().getStorageDomainsWithAttachedStoragePoolGuid(new AsyncQuery<>(attachedStorageDomains -> {
        if (!attachedStorageDomains.isEmpty()) {
            ConfirmationModel confirmationModel = new ConfirmationModel();
            setWindow(null);
            setWindow(confirmationModel);
            List<String> stoageDomainNames = attachedStorageDomains.stream().map(StorageDomainStatic::getStorageName).collect(Collectors.toList());
            confirmationModel.setItems(stoageDomainNames);
            confirmationModel.setTitle(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningTitle());
            confirmationModel.setMessage(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningMessage());
            confirmationModel.setHelpTag(HelpTag.attach_storage_domain_confirmation);
            // $NON-NLS-1$
            confirmationModel.setHashName("attach_storage_domain_confirmation");
            confirmationModel.getLatch().setIsAvailable(true);
            confirmationModel.getLatch().setIsChangeable(true);
            // $NON-NLS-1$
            UICommand onApprove = new UICommand("OnAttachApprove", DataCenterStorageListModel.this);
            onApprove.setTitle(ConstantsManager.getInstance().getConstants().ok());
            onApprove.setIsDefault(true);
            confirmationModel.getCommands().add(onApprove);
            // $NON-NLS-1$
            UICommand cancel = new UICommand("Cancel", DataCenterStorageListModel.this);
            cancel.setTitle(ConstantsManager.getInstance().getConstants().cancel());
            cancel.setIsCancel(true);
            confirmationModel.getCommands().add(cancel);
        } else {
            executeAttachStorageDomains();
        }
    }), getEntity(), selectedDataStorageDomains);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) Model(org.ovirt.engine.ui.uicommonweb.models.Model) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) Collectors(java.util.stream.Collectors) NotifyCollectionChangedEventArgs(org.ovirt.engine.ui.uicompat.NotifyCollectionChangedEventArgs) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) DeactivateStorageDomainWithOvfUpdateParameters(org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) List(java.util.List) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 19 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class DataCenterStorageListModel method attachStorage.

public void attachStorage() {
    ListModel listModel = new ListModel();
    listModel.setTitle(ConstantsManager.getInstance().getConstants().attachStorageTitle());
    listModel.setHelpTag(HelpTag.attach_storage);
    // $NON-NLS-1$
    listModel.setHashName("attach_storage");
    attachInternal(listModel, StorageDomainType.Data);
}
Also used : SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel)

Example 20 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class DataCenterStorageListModel method postAttachInternal.

private void postAttachInternal(List<EntityModel> models) {
    ListModel listModel = (ListModel) getWindow();
    listModel.setItems(models);
    if (models.isEmpty()) {
        listModel.setMessage(ConstantsManager.getInstance().getConstants().thereAreNoCompatibleStorageDomainsAttachThisDcMsg());
        // $NON-NLS-1$
        UICommand tempVar = new UICommand("Cancel", this);
        tempVar.setTitle(ConstantsManager.getInstance().getConstants().close());
        tempVar.setIsDefault(true);
        tempVar.setIsCancel(true);
        listModel.getCommands().add(tempVar);
    } else {
        // $NON-NLS-1$
        UICommand tempVar2 = UICommand.createDefaultOkUiCommand("OnAttach", this);
        listModel.getCommands().add(tempVar2);
        // $NON-NLS-1$
        UICommand tempVar3 = UICommand.createCancelUiCommand("Cancel", this);
        listModel.getCommands().add(tempVar3);
    }
}
Also used : SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Aggregations

ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)43 ArrayList (java.util.ArrayList)29 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)19 List (java.util.List)17 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)8 EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)8 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)8 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)7 TreeItem (com.google.gwt.user.client.ui.TreeItem)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 Model (org.ovirt.engine.ui.uicommonweb.models.Model)6 Provider (org.ovirt.engine.core.common.businessentities.Provider)5 QueryType (org.ovirt.engine.core.common.queries.QueryType)5 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)5 Collections (java.util.Collections)4 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)4 Linq (org.ovirt.engine.ui.uicommonweb.Linq)4