Search in sources :

Example 31 with UICommand

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

the class QuotaModel method editQuotaStorage.

public void editQuotaStorage(QuotaStorage object) {
    this.quotaStorage = object;
    getEditQuotaStorageCommand().execute();
    EditQuotaStorageModel model = new EditQuotaStorageModel();
    model.setTitle(ConstantsManager.getInstance().getConstants().defineStorageQuotaOnDataCenterTitle());
    model.setEntity(object);
    if (object.getStorageSizeGB() == null || object.getStorageSizeGB().equals(QuotaStorage.UNLIMITED)) {
        model.getUnlimitedStorage().setEntity(true);
    } else {
        model.getSpecificStorage().setEntity(true);
        model.getSpecificStorageValue().setEntity(object.getStorageSizeGB());
    }
    setWindow(model);
    // $NON-NLS-1$
    UICommand command = UICommand.createDefaultOkUiCommand("OnEditStorageQuota", this);
    model.getCommands().add(command);
    // $NON-NLS-1$
    model.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 32 with UICommand

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

the class VmListModel method powerAction.

private void powerAction(String actionName, String title, String message, boolean reasonVisible) {
    ConfirmationModel model = new ConfirmationModel();
    setWindow(model);
    model.setTitle(title);
    model.setReasonVisible(reasonVisible);
    if (actionName.equals(SHUTDOWN)) {
        model.setHelpTag(HelpTag.shutdown_virtual_machine);
        // $NON-NLS-1$
        model.setHashName("shutdown_virtual_machine");
    } else if (actionName.equals(STOP)) {
        model.setHelpTag(HelpTag.stop_virtual_machine);
        // $NON-NLS-1$
        model.setHashName("stop_virtual_machine");
    } else if (actionName.equals(REBOOT)) {
        model.setHelpTag(HelpTag.reboot_virtual_machine);
        // $NON-NLS-1$
        model.setHashName("reboot_virtual_machine");
    }
    model.setMessage(message);
    ArrayList<String> items = new ArrayList<>();
    boolean stoppingSingleVM = getSelectedItems().size() == 1 && (actionName.equals(SHUTDOWN) || actionName.equals(STOP));
    for (Object item : getSelectedItems()) {
        VM vm = (VM) item;
        items.add(vm.getName());
        // is populated with the current reason so the user can edit it.
        if (stoppingSingleVM && reasonVisible && VMStatus.PoweringDown.equals(vm.getStatus())) {
            model.getReason().setEntity(vm.getStopReason());
        }
    }
    model.setItems(items);
    // $NON-NLS-1$
    UICommand tempVar = new UICommand("On" + actionName, this);
    tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok());
    tempVar.setIsDefault(true);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 33 with UICommand

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

the class VmListModel method updateVM.

@Override
protected void updateVM(final UnitVmModel model) {
    final VM selectedItem = getSelectedItem();
    // explicitly pass non-editable field from the original VM
    getcurrentVm().setCreatedByUserId(selectedItem.getCreatedByUserId());
    getcurrentVm().setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
    if (selectedItem.isRunningOrPaused() && !selectedItem.isHostedEngine()) {
        AsyncDataProvider.getInstance().getVmChangedFieldsForNextRun(editedVm, getcurrentVm(), getUpdateVmParameters(false), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {

            @Override
            public void onSuccess(QueryReturnValue returnValue) {
                List<String> changedFields = returnValue.getReturnValue();
                final boolean cpuHotPluggable = VmCommonUtils.isCpusToBeHotpluggedOrUnplugged(selectedItem, getcurrentVm());
                final boolean isHeadlessModeChanged = isHeadlessModeChanged(editedVm, getUpdateVmParameters(false));
                final boolean memoryHotPluggable = VmCommonUtils.isMemoryToBeHotplugged(selectedItem, getcurrentVm());
                final boolean minAllocatedMemoryChanged = selectedItem.getMinAllocatedMem() != getcurrentVm().getMinAllocatedMem();
                final boolean vmLeaseUpdated = VmCommonUtils.isVmLeaseToBeHotPluggedOrUnplugged(selectedItem, getcurrentVm());
                if (isHeadlessModeChanged) {
                    changedFields.add(constants.headlessMode());
                }
                // provide warnings if isVmUnpinned()
                if (!changedFields.isEmpty() || isVmUnpinned() || memoryHotPluggable || cpuHotPluggable || vmLeaseUpdated) {
                    VmNextRunConfigurationModel confirmModel = new VmNextRunConfigurationModel();
                    if (isVmUnpinned()) {
                        confirmModel.setVmUnpinned();
                    }
                    confirmModel.setTitle(ConstantsManager.getInstance().getConstants().editNextRunConfigurationTitle());
                    confirmModel.setHelpTag(HelpTag.edit_next_run_configuration);
                    // $NON-NLS-1$
                    confirmModel.setHashName("edit_next_run_configuration");
                    confirmModel.setChangedFields(changedFields);
                    confirmModel.setCpuPluggable(cpuHotPluggable);
                    confirmModel.setMemoryPluggable(memoryHotPluggable);
                    // it can be plugged only together with the memory, never alone
                    confirmModel.setMinAllocatedMemoryPluggable(memoryHotPluggable && minAllocatedMemoryChanged);
                    confirmModel.setVmLeaseUpdated(vmLeaseUpdated);
                    confirmModel.getCommands().add(// $NON-NLS-1$
                    new UICommand("updateExistingVm", VmListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
                    // $NON-NLS-1$
                    confirmModel.getCommands().add(UICommand.createCancelUiCommand("CancelConfirmation", VmListModel.this));
                    setConfirmWindow(confirmModel);
                } else {
                    updateExistingVm(false);
                }
            }

            private boolean isVmUnpinned() {
                if (selectedItem.isRunning()) {
                    if (selectedItem.getMigrationSupport() == MigrationSupport.PINNED_TO_HOST && getcurrentVm().getMigrationSupport() != MigrationSupport.PINNED_TO_HOST) {
                        return true;
                    }
                }
                return false;
            }
        }));
    } else {
        updateExistingVm(false);
    }
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 34 with UICommand

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

the class VmListModel method assignTags.

private void assignTags() {
    if (getWindow() != null) {
        return;
    }
    TagListModel model = new TagListModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().assignTagsTitle());
    model.setHelpTag(HelpTag.assign_tags_vms);
    // $NON-NLS-1$
    model.setHashName("assign_tags_vms");
    getAttachedTagsToSelectedVMs(model);
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAssignTags", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)

Example 35 with UICommand

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

the class VmListModel method changeCD.

private void changeCD() {
    final VM vm = getSelectedItem();
    if (vm == null) {
        return;
    }
    AttachCdModel model = new AttachCdModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().changeCDTitle());
    model.setHelpTag(HelpTag.change_cd);
    // $NON-NLS-1$
    model.setHashName("change_cd");
    AttachCdModel attachCdModel = (AttachCdModel) getWindow();
    List<RepoImage> images1 = new ArrayList<>(Arrays.asList(new RepoImage(ConstantsManager.getInstance().getConstants().noCds())));
    attachCdModel.getIsoImage().setItems(images1);
    attachCdModel.getIsoImage().setSelectedItem(Linq.firstOrNull(images1));
    ImagesDataProvider.getISOImagesList(new AsyncQuery<>(images -> {
        AttachCdModel _attachCdModel = (AttachCdModel) getWindow();
        RepoImage eject = new RepoImage(ConsoleModel.getEjectLabel());
        images.add(0, eject);
        _attachCdModel.getIsoImage().setItems(images);
        if (_attachCdModel.getIsoImage().getIsChangable()) {
            RepoImage selectedIso = Linq.firstOrNull(images, s -> vm.getCurrentCd() != null && vm.getCurrentCd().equals(s.getRepoImageId()));
            _attachCdModel.getIsoImage().setSelectedItem(selectedIso == null ? eject : selectedIso);
        }
    }), vm.getStoragePoolId());
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnChangeCD", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : Arrays(java.util.Arrays) Event(org.ovirt.engine.ui.uicompat.Event) ImagesDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.ImagesDataProvider) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ICancelable(org.ovirt.engine.ui.uicompat.ICancelable) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) VmBaseToVmBaseForTemplateCompositeBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VmBaseToVmBaseForTemplateCompositeBaseBuilder) ChangeDiskCommandParameters(org.ovirt.engine.core.common.action.ChangeDiskCommandParameters) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ShutdownVmParameters(org.ovirt.engine.core.common.action.ShutdownVmParameters) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VmConsoles(org.ovirt.engine.ui.uicommonweb.models.VmConsoles) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) VmWithStatusForExclusiveLock(org.ovirt.engine.core.common.businessentities.VmWithStatusForExclusiveLock) QueryType(org.ovirt.engine.core.common.queries.QueryType) ChangeVMClusterParameters(org.ovirt.engine.core.common.action.ChangeVMClusterParameters) VmBaseListModel(org.ovirt.engine.ui.uicommonweb.models.templates.VmBaseListModel) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) MigrateVmParameters(org.ovirt.engine.core.common.action.MigrateVmParameters) StopVmTypeEnum(org.ovirt.engine.core.common.action.StopVmTypeEnum) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ConsoleContext(org.ovirt.engine.ui.uicommonweb.ConsoleOptionsFrontendPersister.ConsoleContext) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) Pair(org.ovirt.engine.core.common.utils.Pair) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) ConsolePopupModel(org.ovirt.engine.ui.uicommonweb.models.ConsolePopupModel) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) VmHostDeviceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.VmHostDeviceListModel) ConsolesFactory(org.ovirt.engine.ui.uicommonweb.models.ConsolesFactory) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VmCommonUtils(org.ovirt.engine.core.common.utils.VmCommonUtils) VM(org.ovirt.engine.core.common.businessentities.VM) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) StopVmParameters(org.ovirt.engine.core.common.action.StopVmParameters) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) UnitToAddVmTemplateParametersBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.UnitToAddVmTemplateParametersBuilder) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) VmType(org.ovirt.engine.core.common.businessentities.VmType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) VmIconUnitAndVmToParameterBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmIconUnitAndVmToParameterBuilder) Inject(com.google.inject.Inject) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmAffinityGroupListModel(org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.affinity_groups.list.VmAffinityGroupListModel) VmErrataCountModel(org.ovirt.engine.ui.uicommonweb.models.VmErrataCountModel) RemoveVmParameters(org.ovirt.engine.core.common.action.RemoveVmParameters) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) ChangeCDModel(org.ovirt.engine.ui.uicommonweb.models.configure.ChangeCDModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Collectors(java.util.stream.Collectors) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) Objects(java.util.Objects) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) Entry(java.util.Map.Entry) ObservableCollection(org.ovirt.engine.ui.uicompat.ObservableCollection) CommonUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonUnitToVmBaseBuilder) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) MigrateVmToServerParameters(org.ovirt.engine.core.common.action.MigrateVmToServerParameters) VmAffinityLabelListModel(org.ovirt.engine.ui.uicommonweb.models.configure.labels.list.VmAffinityLabelListModel) HashMap(java.util.HashMap) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) ExportOvaParameters(org.ovirt.engine.core.common.action.ExportOvaParameters) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Provider(com.google.inject.Provider) VmOperationParameterBase(org.ovirt.engine.core.common.action.VmOperationParameterBase) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Aggregations

UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)257 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)134 ArrayList (java.util.ArrayList)105 List (java.util.List)49 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)49 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)49 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)48 ActionType (org.ovirt.engine.core.common.action.ActionType)47 Frontend (org.ovirt.engine.ui.frontend.Frontend)47 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)44 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)41 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)36 Guid (org.ovirt.engine.core.compat.Guid)36 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)33 QueryType (org.ovirt.engine.core.common.queries.QueryType)33 VDS (org.ovirt.engine.core.common.businessentities.VDS)30 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)29 Linq (org.ovirt.engine.ui.uicommonweb.Linq)28 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)26 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)24