Search in sources :

Example 1 with UnitVmModel

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

the class InstanceTypeListModel method createWindow.

private void createWindow(VmModelBehaviorBase<UnitVmModel> behavior, String hashName, String onOkAction, boolean isNew, String title, HelpTag helpTag) {
    if (getWindow() != null) {
        return;
    }
    UnitVmModel model = new UnitVmModel(behavior, this);
    // $NON-NLS-1$
    model.setIsAdvancedModeLocalStorageKey("instance_type_dialog");
    setWindow(model);
    model.setTitle(title);
    model.setHelpTag(helpTag);
    // $NON-NLS-1$
    model.setHashName(hashName);
    model.setIsNew(isNew);
    model.initialize();
    VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
    switchModeCommand.init(model);
    model.getCommands().add(switchModeCommand);
    UICommand newTemplate = UICommand.createDefaultOkUiCommand(onOkAction, this);
    model.getCommands().add(newTemplate);
    // $NON-NLS-1$
    UICommand cancel = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(cancel);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 2 with UnitVmModel

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

the class InstanceTypeListModel method onEditInstanceType.

private void onEditInstanceType() {
    UnitVmModel model = (UnitVmModel) getWindow();
    if (!model.validateInstanceTypePart()) {
        return;
    }
    VmTemplate instanceType = (VmTemplate) Cloner.clone(selectedItem);
    instanceType.setTemplateType(VmEntityType.INSTANCE_TYPE);
    buildVmStatic(instanceType);
    instanceType.setDescription(model.getDescription().getEntity());
    UpdateVmTemplateParameters updateInstanceTypeParameters = new UpdateVmTemplateParameters(instanceType);
    updateInstanceTypeParameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    updateInstanceTypeParameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    updateInstanceTypeParameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
    updateInstanceTypeParameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    if (model.getIsHeadlessModeEnabled().getEntity()) {
        updateInstanceTypeParameters.getVmTemplateData().setDefaultDisplayType(DisplayType.none);
    }
    setVmWatchdogToParams(model, updateInstanceTypeParameters);
    setRngDeviceToParams(model, updateInstanceTypeParameters);
    BuilderExecutor.build(model, updateInstanceTypeParameters, new UnitToGraphicsDeviceParamsBuilder());
    getWindow().startProgress();
    Frontend.getInstance().runAction(ActionType.UpdateVmTemplate, updateInstanceTypeParameters, new UnitVmModelNetworkAsyncCallback(model, addInstanceTypeNetworkManager, instanceType.getId()), this);
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) UnitVmModelNetworkAsyncCallback(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModelNetworkAsyncCallback) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) UpdateVmTemplateParameters(org.ovirt.engine.core.common.action.UpdateVmTemplateParameters) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 3 with UnitVmModel

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

the class TemplateListModel method postUpdateVmTemplate.

public void postUpdateVmTemplate(ActionReturnValue returnValue) {
    UnitVmModel model = (UnitVmModel) getWindow();
    model.stopProgress();
    if (returnValue != null && returnValue.getSucceeded()) {
        cancel();
    }
}
Also used : UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 4 with UnitVmModel

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

the class TemplateListModel method onSave.

private void onSave() {
    final UnitVmModel model = (UnitVmModel) getWindow();
    if (!model.validate()) {
        return;
    }
    final String name = model.getName().getEntity();
    boolean isBaseTemplate = false;
    if (model.getBehavior().isExistingTemplateBehavior()) {
        isBaseTemplate = ((TemplateVmModelBehavior) model.getBehavior()).getVmTemplate().isBaseTemplate();
    } else if (model.getBehavior().isBlankTemplateBehavior()) {
        isBaseTemplate = true;
    }
    if (isBaseTemplate) {
        AsyncDataProvider.getInstance().isTemplateNameUnique(new AsyncQuery<>(isNameUnique -> {
            if (model.getBehavior().isExistingTemplateBehavior()) {
                selectedItem = ((TemplateVmModelBehavior) model.getBehavior()).getVmTemplate();
            } else {
                selectedItem = ((ExistingBlankTemplateModelBehavior) model.getBehavior()).getVmTemplate();
            }
            if (!isNameUnique && name.compareToIgnoreCase(selectedItem.getName()) != 0) {
                model.getName().getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason());
                model.getName().setIsValid(false);
                model.setValidTab(TabName.GENERAL_TAB, false);
                model.fireValidationCompleteEvent();
                return;
            }
            String selectedCpu = model.getCustomCpu().getSelectedItem();
            if (selectedCpu != null && !selectedCpu.isEmpty() && !model.getCustomCpu().getItems().contains(selectedCpu)) {
                ConfirmationModel confirmModel = new ConfirmationModel();
                confirmModel.setTitle(ConstantsManager.getInstance().getConstants().vmUnsupportedCpuTitle());
                confirmModel.setMessage(ConstantsManager.getInstance().getConstants().vmUnsupportedCpuMessage());
                confirmModel.setHelpTag(HelpTag.edit_unsupported_cpu);
                // $NON-NLS-1$
                confirmModel.setHashName("edit_unsupported_cpu");
                confirmModel.getCommands().add(// $NON-NLS-1$
                new UICommand("postNameUniqueCheck", TemplateListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
                confirmModel.getCommands().add(// $NON-NLS-1$
                UICommand.createCancelUiCommand("CancelConfirmation", TemplateListModel.this));
                setConfirmWindow(confirmModel);
            } else {
                postNameUniqueCheck();
            }
        }), name, model.getSelectedDataCenter() == null ? null : model.getSelectedDataCenter().getId());
    } else {
        postNameUniqueCheck();
    }
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) ExportVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) VmType(org.ovirt.engine.core.common.businessentities.VmType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Inject(com.google.inject.Inject) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) 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) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) 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) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) List(java.util.List) VersionNameUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VersionNameUnitToVmBaseBuilder) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) VmModelBehaviorBase(org.ovirt.engine.ui.uicommonweb.models.vms.VmModelBehaviorBase) 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) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) UpdateVmTemplateParameters(org.ovirt.engine.core.common.action.UpdateVmTemplateParameters) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmTemplateManagementParameters(org.ovirt.engine.core.common.action.VmTemplateManagementParameters) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) TemplateVmModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.TemplateVmModelBehavior) VmTemplateStatus(org.ovirt.engine.core.common.businessentities.VmTemplateStatus) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) IconUtils(org.ovirt.engine.ui.uicommonweb.IconUtils) IconCache(org.ovirt.engine.ui.uicommonweb.models.vms.IconCache) VM(org.ovirt.engine.core.common.businessentities.VM) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) NewVmFromTemplateModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.NewVmFromTemplateModelBehavior) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) TemplateVmModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.TemplateVmModelBehavior) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 5 with UnitVmModel

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

the class TemplateListModel method createVMFromTemplate.

private void createVMFromTemplate() {
    VmTemplate template = getSelectedItem();
    final List<UICommand> commands = new ArrayList<>();
    // $NON-NLS-1$
    commands.add(UICommand.createDefaultOkUiCommand("OnSaveVm", this));
    // $NON-NLS-1$
    commands.add(UICommand.createCancelUiCommand("Cancel", this));
    AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(withVmInit -> setupNewVmModel(new UnitVmModel(new NewVmFromTemplateModelBehavior(withVmInit), TemplateListModel.this), withVmInit.getVmType(), commands)), template.getId());
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) ExportVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) VmType(org.ovirt.engine.core.common.businessentities.VmType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Inject(com.google.inject.Inject) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) 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) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) 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) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) List(java.util.List) VersionNameUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VersionNameUnitToVmBaseBuilder) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) VmModelBehaviorBase(org.ovirt.engine.ui.uicommonweb.models.vms.VmModelBehaviorBase) 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) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) UpdateVmTemplateParameters(org.ovirt.engine.core.common.action.UpdateVmTemplateParameters) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmTemplateManagementParameters(org.ovirt.engine.core.common.action.VmTemplateManagementParameters) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) TemplateVmModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.TemplateVmModelBehavior) VmTemplateStatus(org.ovirt.engine.core.common.businessentities.VmTemplateStatus) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) IconUtils(org.ovirt.engine.ui.uicommonweb.IconUtils) IconCache(org.ovirt.engine.ui.uicommonweb.models.vms.IconCache) VM(org.ovirt.engine.core.common.businessentities.VM) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) NewVmFromTemplateModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.NewVmFromTemplateModelBehavior) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) NewVmFromTemplateModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.NewVmFromTemplateModelBehavior) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Aggregations

UnitVmModel (org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)13 VM (org.ovirt.engine.core.common.businessentities.VM)6 UnitToGraphicsDeviceParamsBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder)6 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 UpdateVmTemplateParameters (org.ovirt.engine.core.common.action.UpdateVmTemplateParameters)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 VmBasedWidgetSwitchModeCommand (org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 ActionType (org.ovirt.engine.core.common.action.ActionType)3 DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 VmType (org.ovirt.engine.core.common.businessentities.VmType)3 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)3 VmWatchdogType (org.ovirt.engine.core.common.businessentities.VmWatchdogType)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3 Guid (org.ovirt.engine.core.compat.Guid)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3