Search in sources :

Example 1 with NewEditStorageModelBehavior

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

the class VmDiskPopupWidget method edit.

@Override
@SuppressWarnings("unchecked")
public void edit(final AbstractDiskModel disk) {
    driver.edit(disk);
    disk.getIsDirectLunDiskAvaialable().getEntityChangedEvent().addListener((ev, sender, args) -> {
        boolean isDirectLunDiskAvaialable = ((EntityModel<Boolean>) sender).getEntity();
        externalDiskPanel.setVisible(isDirectLunDiskAvaialable);
    });
    disk.getIsUsingScsiReservation().getPropertyChangedEvent().addListener((ev, sender, args) -> {
        if ("Entity".equals(args.propertyName) || "IsAvailable".equals(args.propertyName)) {
            // $NON-NLS-1$ $NON-NLS-2$
            EntityModel<Boolean> entity = disk.getIsUsingScsiReservation();
            scsiReservationInfoIcon.setVisible(entity.getEntity() && entity.getIsAvailable());
        }
    });
    disk.getIsVirtioScsiEnabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
        if (disk.getVm() == null) {
            // not relevant for floating disks
            return;
        }
        boolean isVirtioScsiEnabled = ((EntityModel<Boolean>) sender).getEntity();
        // Show the info icon if VirtIO-SCSI is supported by the cluster but disabled for the VM
        interfaceInfoIcon.setVisible(!isVirtioScsiEnabled);
        // Make room for it by making the control widget narrower
        interfaceEditor.removeWidgetColSize(isVirtioScsiEnabled ? ColumnSize.SM_7 : ColumnSize.SM_8);
        interfaceEditor.addWidgetColSize(!isVirtioScsiEnabled ? ColumnSize.SM_7 : ColumnSize.SM_8);
    });
    disk.getCinderVolumeType().getItemsChangedEvent().addListener((ev, sender, args) -> {
        Collection<String> volumeTypes = disk.getCinderVolumeType().getItems();
        boolean showIcon = volumeTypes == null || volumeTypes.isEmpty();
        cinderVolumeTypeInfoIcon.setVisible(showIcon);
        cinderVolumeTypeEditor.removeWidgetColSize(!showIcon ? ColumnSize.SM_7 : ColumnSize.SM_8);
        cinderVolumeTypeEditor.addWidgetColSize(showIcon ? ColumnSize.SM_7 : ColumnSize.SM_8);
    });
    disk.getIsModelDisabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
        if (disk.getIsModelDisabled().getEntity()) {
            disableWidget(getWidget());
            enableWidget(radioButtonPanel);
            enableWidget(datacenterEditor);
            disk.getDefaultCommand().setIsExecutionAllowed(false);
            disk.setIsChangeable(false);
        } else {
            enableWidget(getWidget());
            disk.getDefaultCommand().setIsExecutionAllowed(true);
            disk.setIsChangeable(true);
            driver.edit(disk);
        }
    });
    radioButtonPanel.addRadioButton(constants.imageDisk(), disk.getDisk() == null || disk.getDisk().getDiskStorageType() == DiskStorageType.IMAGE, disk.getIsNew(), event -> {
        if (disk.getIsNew()) {
            disk.getDiskStorageType().setEntity(DiskStorageType.IMAGE);
            revealDiskPanel(disk);
        }
    });
    radioButtonPanel.addRadioButton(constants.directLunDisk(), disk.getDisk() != null && disk.getDisk().getDiskStorageType() == DiskStorageType.LUN, disk.getIsNew(), event -> {
        if (disk.getIsNew()) {
            disk.getDiskStorageType().setEntity(DiskStorageType.LUN);
            revealStorageView(disk);
            revealDiskPanel(disk);
        }
    });
    radioButtonPanel.addRadioButton(constants.cinderDisk(), disk.getDisk() != null && disk.getDisk().getDiskStorageType() == DiskStorageType.CINDER, disk.getIsNew(), event -> {
        if (disk.getIsNew()) {
            disk.getDiskStorageType().setEntity(DiskStorageType.CINDER);
            revealDiskPanel(disk);
        }
    });
    if (disk.getStorageModel() == null) {
        storageModel = new StorageModel(new NewEditStorageModelBehavior());
        // Create IscsiStorageModel
        iscsiStorageModel = new IscsiStorageModel();
        iscsiStorageModel.setContainer(storageModel);
        iscsiStorageModel.setIsGroupedByTarget(true);
        iscsiStorageModel.setIgnoreGrayedOut(true);
        // Create FcpStorageModel
        fcpStorageModel = new FcpStorageModel();
        fcpStorageModel.setContainer(storageModel);
        fcpStorageModel.setIsGroupedByTarget(false);
        fcpStorageModel.setIgnoreGrayedOut(true);
        // Set 'StorageModel' items
        ArrayList<IStorageModel> items = new ArrayList<>();
        items.add(iscsiStorageModel);
        items.add(fcpStorageModel);
        storageModel.setStorageModels(items);
        storageModel.setHost(disk.getHost());
        disk.setStorageModel(storageModel);
    } else {
        storageModel = disk.getStorageModel();
        iscsiStorageModel = Linq.findByType(storageModel.getStorageModels(), IscsiStorageModel.class);
        iscsiStorageModel.getPropertyChangedEvent().clearListeners();
        fcpStorageModel = Linq.findByType(storageModel.getStorageModels(), FcpStorageModel.class);
        fcpStorageModel.getPropertyChangedEvent().clearListeners();
    }
    iscsiStorageView = new IscsiStorageView(false, 196, 304, 244, 275, 142, 55, -67);
    iscsiStorageView.setBarTop(0, Unit.PX);
    iscsiStorageView.edit(iscsiStorageModel);
    fcpStorageView = new FcpStorageView(false, 278, 240);
    fcpStorageView.edit(fcpStorageModel);
    // SelectedItemChangedEvent handlers
    disk.getStorageType().getSelectedItemChangedEvent().addListener((ev, sender, args) -> revealStorageView(disk));
    disk.getHost().getSelectedItemChangedEvent().addListener((ev, sender, args) -> revealStorageView(disk));
    disk.getDiskStorageType().getPropertyChangedEvent().addListener((ev, sender, args) -> {
        String propName = args.propertyName;
        if ("IsChangable".equals(propName)) {
            // $NON-NLS-1$
            if (disk.getDiskStorageType().getIsChangable() && disk.isEditEnabled()) {
                enableWidget(radioButtonPanel);
            } else {
                disableWidget(radioButtonPanel);
            }
        }
    });
    revealStorageView(disk);
    revealDiskPanel(disk);
}
Also used : FcpStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.FcpStorageModel) IscsiStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IscsiStorageModel) IscsiStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IscsiStorageModel) FcpStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.FcpStorageModel) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) IscsiStorageView(org.ovirt.engine.ui.common.widget.uicommon.storage.IscsiStorageView) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) FcpStorageView(org.ovirt.engine.ui.common.widget.uicommon.storage.FcpStorageView) NewEditStorageModelBehavior(org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior)

Example 2 with NewEditStorageModelBehavior

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

the class DataCenterGuideModel method addLocalStorage.

private void addLocalStorage() {
    final StorageModel model = new StorageModel(new NewEditStorageModelBehavior());
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().newLocalDomainTitle());
    model.setHelpTag(HelpTag.new_local_domain);
    // $NON-NLS-1$
    model.setHashName("new_local_domain");
    LocalStorageModel localStorageModel = new LocalStorageModel();
    localStorageModel.setRole(StorageDomainType.Data);
    ArrayList<IStorageModel> list = new ArrayList<>();
    list.add(localStorageModel);
    model.setStorageModels(list);
    model.setCurrentStorageItem(list.get(0));
    AsyncDataProvider.getInstance().getLocalStorageHost(new AsyncQuery<>(localHost -> {
        model.getHost().setItems(new ArrayList<>(Arrays.asList(new VDS[] { localHost })));
        model.getHost().setSelectedItem(localHost);
        model.getDataCenter().setItems(Collections.singletonList(getEntity()), getEntity());
        // $NON-NLS-1$
        UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAddStorage", DataCenterGuideModel.this);
        model.getCommands().add(tempVar);
        // $NON-NLS-1$
        UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", DataCenterGuideModel.this);
        model.getCommands().add(tempVar2);
    }), getEntity().getName());
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) Arrays(java.util.Arrays) RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) NewHostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.NewHostModel) GuideModel(org.ovirt.engine.ui.uicommonweb.models.GuideModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) NewEditStorageModelBehavior(org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) AddSANStorageDomainParameters(org.ovirt.engine.core.common.action.AddSANStorageDomainParameters) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) Collectors(java.util.stream.Collectors) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) HostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostModel) ITaskTarget(org.ovirt.engine.ui.uicompat.ITaskTarget) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) TaskContext(org.ovirt.engine.ui.uicompat.TaskContext) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) FrontendMultipleActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult) Task(org.ovirt.engine.ui.uicompat.Task) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) GetDeviceListQueryParameters(org.ovirt.engine.core.common.queries.GetDeviceListQueryParameters) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) ClusterListModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterListModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) LunModel(org.ovirt.engine.ui.uicommonweb.models.storage.LunModel) Timer(com.google.gwt.user.client.Timer) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) NewEditStorageModelBehavior(org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior) PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) ArrayList(java.util.ArrayList) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 3 with NewEditStorageModelBehavior

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

the class DataCenterGuideModel method addStorageInternal.

private void addStorageInternal(String title, StorageDomainType type) {
    StorageModel model = new StorageModel(new NewEditStorageModelBehavior());
    setWindow(model);
    model.setTitle(title);
    model.setHelpTag(HelpTag.new_domain);
    // $NON-NLS-1$
    model.setHashName("new_domain");
    ArrayList<StoragePool> dataCenters = new ArrayList<>();
    dataCenters.add(getEntity());
    model.getDataCenter().setItems(dataCenters, getEntity());
    model.getDataCenter().setIsChangeable(false);
    List<IStorageModel> items = null;
    if (type == StorageDomainType.Data) {
        items = AsyncDataProvider.getInstance().getDataStorageModels();
    } else if (type == StorageDomainType.ISO) {
        items = AsyncDataProvider.getInstance().getIsoStorageModels();
    }
    model.setStorageModels(items);
    model.initialize();
    // $NON-NLS-1$
    UICommand tempVar6 = UICommand.createDefaultOkUiCommand("OnAddStorage", this);
    model.getCommands().add(tempVar6);
    // $NON-NLS-1$
    UICommand tempVar7 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar7);
}
Also used : IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) NewEditStorageModelBehavior(org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior) PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Aggregations

ArrayList (java.util.ArrayList)3 IStorageModel (org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel)3 NewEditStorageModelBehavior (org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior)3 StorageModel (org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 LocalStorageModel (org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel)2 NfsStorageModel (org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel)2 PosixStorageModel (org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel)2 Timer (com.google.gwt.user.client.Timer)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 AddSANStorageDomainParameters (org.ovirt.engine.core.common.action.AddSANStorageDomainParameters)1