Search in sources :

Example 1 with TemplateVmModelBehavior

use of org.ovirt.engine.ui.uicommonweb.models.vms.TemplateVmModelBehavior 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)

Aggregations

Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ActionUtils (org.ovirt.engine.core.common.ActionUtils)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 MoveOrCopyParameters (org.ovirt.engine.core.common.action.MoveOrCopyParameters)1 UpdateVmTemplateParameters (org.ovirt.engine.core.common.action.UpdateVmTemplateParameters)1 VmTemplateManagementParameters (org.ovirt.engine.core.common.action.VmTemplateManagementParameters)1 DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1 VmTemplateStatus (org.ovirt.engine.core.common.businessentities.VmTemplateStatus)1 VmType (org.ovirt.engine.core.common.businessentities.VmType)1 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)1