Search in sources :

Example 46 with Model

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

the class StorageDataCenterListModel method onAttach.

private void onAttach() {
    final ListModel<EntityModel<StoragePool>> model = (ListModel<EntityModel<StoragePool>>) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (getEntity() == null) {
        cancel();
        return;
    }
    ArrayList<StoragePool> items = new ArrayList<>();
    for (EntityModel<StoragePool> a : model.getItems()) {
        if (a.getIsSelected()) {
            items.add(a.getEntity());
        }
    }
    if (items.size() == 0) {
        cancel();
        return;
    }
    setSelectedDataCentersForAttach(items);
    model.startProgress();
    if (getEntity().getStorageDomainType() == StorageDomainType.Data) {
        StoragePool dataCenter = items.get(0);
        ArrayList<StorageDomain> storageDomains = new ArrayList<>();
        storageDomains.add(getEntity());
        AsyncDataProvider.getInstance().getStorageDomainsWithAttachedStoragePoolGuid(new AsyncQuery<>(attachedStorageDomains -> {
            if (!attachedStorageDomains.isEmpty()) {
                ConfirmationModel confirmationModel = new ConfirmationModel();
                setWindow(null);
                setWindow(confirmationModel);
                List<String> stoageDomainNames = new ArrayList<>();
                for (StorageDomainStatic domain : attachedStorageDomains) {
                    stoageDomainNames.add(domain.getStorageName());
                }
                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", StorageDataCenterListModel.this);
                onApprove.setTitle(ConstantsManager.getInstance().getConstants().ok());
                onApprove.setIsDefault(true);
                confirmationModel.getCommands().add(onApprove);
                // $NON-NLS-1$
                UICommand cancel = new UICommand("Cancel", StorageDataCenterListModel.this);
                cancel.setTitle(ConstantsManager.getInstance().getConstants().cancel());
                cancel.setIsCancel(true);
                confirmationModel.getCommands().add(cancel);
            } else {
                executeAttachStorageDomains(model);
            }
        }), dataCenter, storageDomains);
    } else {
        executeAttachStorageDomains(model);
    }
}
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) 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) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) 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) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Comparator(java.util.Comparator) Collections(java.util.Collections) 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) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) 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 47 with Model

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

the class NewEditStorageModelBehavior method updateItemSelectability.

private void updateItemSelectability(IStorageModel item, boolean isSelectable) {
    Model model = (Model) item;
    model.setIsSelectable(isSelectable);
    onStorageModelUpdated(item);
}
Also used : Model(org.ovirt.engine.ui.uicommonweb.models.Model)

Example 48 with Model

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

the class ImportStorageModelBehavior method postUpdateItemsAvailability.

public void postUpdateItemsAvailability(IStorageModel item, boolean isNoStorageAttached) {
    Model model = (Model) item;
    StoragePool dataCenter = getModel().getDataCenter().getSelectedItem();
    boolean isItemSelectable = isItemSelectable(item, dataCenter, isNoStorageAttached);
    model.setIsSelectable(isItemSelectable);
    onStorageModelUpdated(item);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Model(org.ovirt.engine.ui.uicommonweb.models.Model)

Example 49 with Model

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

the class VmBaseListModel method displayHighPerformanceConfirmationPopup.

protected void displayHighPerformanceConfirmationPopup() {
    final UnitVmModel model = (UnitVmModel) getWindow();
    if (model == null || model.getProgress() != null) {
        return;
    }
    VmHighPerformanceConfigurationModel confirmModel = new VmHighPerformanceConfigurationModel();
    // Handle CPU Pinning topology
    final boolean isVmAssignedToSpecificHosts = !model.getIsAutoAssign().getEntity();
    final boolean isVmCpuPinningSet = model.getCpuPinning().getIsChangable() && model.getCpuPinning().getEntity() != null && !model.getCpuPinning().getEntity().isEmpty();
    confirmModel.addRecommendationForCpuPinning(isVmAssignedToSpecificHosts, isVmCpuPinningSet);
    // Handle NUMA
    final boolean isVmVirtNumaSet = model.getNumaEnabled().getEntity() && model.getNumaNodeCount().getEntity() > 0;
    final boolean isVmVirtNumaPinned = model.getVmNumaNodes() != null && !model.getVmNumaNodes().isEmpty() && model.getVmNumaNodes().stream().filter(x -> !x.getVdsNumaNodeList().isEmpty()).count() > 0;
    confirmModel.addRecommendationForVirtNumaSetAndPinned(isVmVirtNumaSet, isVmVirtNumaPinned);
    // Handle Huge Pages
    KeyValueModel keyValue = model.getCustomPropertySheet();
    // $NON-NLS-1$
    final boolean isVmHugePagesSet = keyValue != null && keyValue.getUsedKeys().contains("hugepages");
    confirmModel.addRecommendationForHugePages(isVmHugePagesSet);
    // Handle KSM (Kernel Same Page Merging)
    confirmModel.addRecommendationForKsm(model.getSelectedCluster().isEnableKsm(), model.getSelectedCluster().getName());
    // If there are recommendations to display and it is not a Pool VM then display the popup
    if (!confirmModel.getRecommendationsList().isEmpty() && !model.isVmAttachedToPool()) {
        confirmModel.setTitle(ConstantsManager.getInstance().getConstants().configurationChangesForHighPerformanceVmTitle());
        confirmModel.setHelpTag(HelpTag.configuration_changes_for_high_performance_vm);
        // $NON-NLS-1$
        confirmModel.setHashName("configuration_changes_for_high_performance_vm");
        confirmModel.getCommands().add(// $NON-NLS-1$
        new UICommand("SaveOrUpdateVM", VmBaseListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
        confirmModel.getCommands().add(// $NON-NLS-1$
        UICommand.createCancelUiCommand("CancelConfirmation", VmBaseListModel.this));
        setConfirmWindow(null);
        setConfirmWindow(confirmModel);
    } else {
        saveOrUpdateVM(model);
    }
}
Also used : ExportVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) FrontendActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult) VmType(org.ovirt.engine.core.common.businessentities.VmType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) VmWatchdogType(org.ovirt.engine.core.common.businessentities.VmWatchdogType) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) Map(java.util.Map) VmInterfaceCreatingManager(org.ovirt.engine.ui.uicommonweb.models.vms.VmInterfaceCreatingManager) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) StringHelper(org.ovirt.engine.core.compat.StringHelper) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) List(java.util.List) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) HasDiskWindow(org.ovirt.engine.ui.uicommonweb.models.vms.HasDiskWindow) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) UnitVmModelNetworkAsyncCallback(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModelNetworkAsyncCallback) Frontend(org.ovirt.engine.ui.frontend.Frontend) ExportOvaModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportOvaModel) BalloonEnabled(org.ovirt.engine.ui.uicommonweb.models.vms.BalloonEnabled) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) IconUtils(org.ovirt.engine.ui.uicommonweb.IconUtils) VM(org.ovirt.engine.core.common.businessentities.VM) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmSpecificUnitToVmBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmSpecificUnitToVmBuilder) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 50 with Model

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

the class StorageModel method host_SelectedItemChanged.

private void host_SelectedItemChanged() {
    VDS host = getHost().getSelectedItem();
    if (getCurrentStorageItem() != null) {
        // When changing host clear items for san storage model.
        if (getCurrentStorageItem() instanceof SanStorageModelBase) {
            SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem();
            if (getStorage() == null) {
                sanStorageModel.setItems(null);
            }
        }
        if (host != null) {
            getCurrentStorageItem().getUpdateCommand().execute();
            // $NON-NLS-1$
            String prefix = host.isOvirtVintageNode() ? localFSPath : "";
            if (!StringHelper.isNullOrEmpty(prefix)) {
                getStorageModels().stream().filter(item -> item instanceof LocalStorageModel).map(item -> (LocalStorageModel) item).forEach(model -> {
                    model.getPath().setEntity(prefix);
                    model.getPath().setIsChangeable(false);
                });
            }
        }
    }
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Guid(org.ovirt.engine.core.compat.Guid) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) Event(org.ovirt.engine.ui.uicompat.Event) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) VersionStorageFormatUtil(org.ovirt.engine.core.common.utils.VersionStorageFormatUtil) Model(org.ovirt.engine.ui.uicommonweb.models.Model) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ValidationResult(org.ovirt.engine.ui.uicommonweb.validation.ValidationResult) Collection(java.util.Collection) StorageConstants(org.ovirt.engine.core.common.constants.StorageConstants) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Collectors(java.util.stream.Collectors) VdsSpmStatus(org.ovirt.engine.core.common.businessentities.VdsSpmStatus) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VDS(org.ovirt.engine.core.common.businessentities.VDS)

Aggregations

Model (org.ovirt.engine.ui.uicommonweb.models.Model)56 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)46 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)41 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)39 ArrayList (java.util.ArrayList)37 List (java.util.List)37 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)35 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)35 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)35 ActionType (org.ovirt.engine.core.common.action.ActionType)34 Frontend (org.ovirt.engine.ui.frontend.Frontend)34 QueryType (org.ovirt.engine.core.common.queries.QueryType)33 VDS (org.ovirt.engine.core.common.businessentities.VDS)32 Guid (org.ovirt.engine.core.compat.Guid)32 Linq (org.ovirt.engine.ui.uicommonweb.Linq)32 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)30 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)30 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)29 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)28 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)28