Search in sources :

Example 1 with VmBasedWidgetSwitchModeCommand

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

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

the class TemplateListModel method vmInitLoaded.

private void vmInitLoaded(VmTemplate template) {
    UnitVmModel model = createModel(createBehavior(template));
    model.setIsAdvancedModeLocalStorageKey(getEditTemplateAdvancedModelKey());
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().editTemplateTitle());
    model.setHelpTag(HelpTag.edit_template);
    // $NON-NLS-1$
    model.setHashName("edit_template");
    model.getVmType().setSelectedItem(template.getVmType());
    model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
    model.initialize();
    VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
    switchModeCommand.init(model);
    model.getCommands().add(switchModeCommand);
    // $NON-NLS-1$
    UICommand onSaveCommand = UICommand.createDefaultOkUiCommand("OnSave", this);
    model.getCommands().add(onSaveCommand);
    // $NON-NLS-1$
    UICommand cancelCommand = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(cancelCommand);
    model.getIsHighlyAvailable().setEntity(template.isAutoStartup());
    if (template.getDefaultDisplayType() == DisplayType.none) {
        model.getIsHeadlessModeEnabled().setEntity(true);
    }
}
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 3 with VmBasedWidgetSwitchModeCommand

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

the class VmBaseListModel method setupNewVmModel.

protected void setupNewVmModel(UnitVmModel model, VmType vmtype, List<UICommand> uiCommands) {
    model.setTitle(ConstantsManager.getInstance().getConstants().newVmTitle());
    model.setHelpTag(HelpTag.new_vm);
    // $NON-NLS-1$
    model.setHashName("new_vm");
    model.setIsNew(true);
    model.getVmType().setSelectedItem(vmtype);
    model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
    // $NON-NLS-1$
    model.setIsAdvancedModeLocalStorageKey("wa_vm_dialog");
    setWindow(model);
    model.initialize();
    VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
    switchModeCommand.init(model);
    model.getCommands().add(switchModeCommand);
    model.getProvisioning().setEntity(true);
    for (UICommand uicommand : uiCommands) {
        model.getCommands().add(uicommand);
    }
    model.initForemanProviders(null);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand)

Example 4 with VmBasedWidgetSwitchModeCommand

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

the class PoolListModel method edit.

public void edit() {
    final VmPool pool = getSelectedItem();
    if (getWindow() != null) {
        return;
    }
    final PoolListModel poolListModel = this;
    Frontend.getInstance().runQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(pool.getVmPoolId()), new AsyncQuery<QueryReturnValue>(result -> {
        final VM vm = result.getReturnValue();
        final ExistingPoolModelBehavior behavior = new ExistingPoolModelBehavior(vm, pool);
        behavior.getPoolModelBehaviorInitializedEvent().addListener((ev, sender, args) -> {
            final PoolModel model = behavior.getModel();
            for (EntityModel<VmPoolType> item : model.getPoolType().getItems()) {
                if (item.getEntity() == pool.getVmPoolType()) {
                    model.getPoolType().setSelectedItem(item);
                    break;
                }
            }
            String cdImage = null;
            if (vm != null) {
                model.getDataCenterWithClustersList().setSelectedItem(null);
                model.getDataCenterWithClustersList().setSelectedItem(Linq.firstOrNull(model.getDataCenterWithClustersList().getItems(), new Linq.DataCenterWithClusterPredicate(vm.getStoragePoolId(), vm.getClusterId())));
                model.getTemplateWithVersion().setIsChangeable(false);
                cdImage = vm.getIsoPath();
                model.getVmType().setSelectedItem(vm.getVmType());
            } else {
                model.getDataCenterWithClustersList().setSelectedItem(Linq.firstOrNull(model.getDataCenterWithClustersList().getItems()));
            }
            model.getDataCenterWithClustersList().setIsChangeable(vm == null);
            boolean hasCd = !StringHelper.isNullOrEmpty(cdImage);
            model.getCdImage().setIsChangeable(hasCd);
            model.getCdAttached().setEntity(hasCd);
            model.getProvisioning().setIsChangeable(false);
            model.getStorageDomain().setIsChangeable(false);
        });
        PoolModel model = new PoolModel(behavior);
        model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
        // $NON-NLS-1$
        model.setIsAdvancedModeLocalStorageKey("wa_pool_dialog");
        setWindow(model);
        VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
        switchModeCommand.init(model);
        model.getCommands().add(switchModeCommand);
        // $NON-NLS-1$
        UICommand command = UICommand.createDefaultOkUiCommand("OnSave", poolListModel);
        model.getCommands().add(command);
        // $NON-NLS-1$
        model.getCommands().add(UICommand.createCancelUiCommand("Cancel", poolListModel));
        model.setTitle(ConstantsManager.getInstance().getConstants().editPoolTitle());
        model.setHelpTag(HelpTag.edit_pool);
        // $NON-NLS-1$
        model.setHashName("edit_pool");
        model.initialize();
        model.getName().setEntity(pool.getName());
        model.getDescription().setEntity(pool.getVmPoolDescription());
        model.getComment().setEntity(pool.getComment());
        model.getPoolStateful().setEntity(pool.isStateful());
        model.getAssignedVms().setEntity(pool.getAssignedVmsCount());
        model.getPrestartedVms().setEntity(pool.getPrestartedVms());
        // $NON-NLS-1$
        model.setPrestartedVmsHint("0-" + pool.getAssignedVmsCount());
        model.getMaxAssignedVmsPerUser().setEntity(pool.getMaxAssignedVmsPerUser());
    }));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) VmType(org.ovirt.engine.core.common.businessentities.VmType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) CoreUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CoreUnitToVmBaseBuilder) Inject(com.google.inject.Inject) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) KernelParamsUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.KernelParamsUnitToVmBaseBuilder) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) CpuProfileUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CpuProfileUnitToVmBaseBuilder) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) AddVmPoolParameters(org.ovirt.engine.core.common.action.AddVmPoolParameters) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DedicatedVmForVdsUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.DedicatedVmForVdsUnitToVmBaseBuilder) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UsbPolicyUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UsbPolicyUnitToVmBaseBuilder) 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) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) NewPoolModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.NewPoolModelBehavior) 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) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) 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) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmPoolType(org.ovirt.engine.core.common.businessentities.VmPoolType) NameUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameUnitToVmBaseBuilder) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmPoolParametersBase(org.ovirt.engine.core.common.action.VmPoolParametersBase) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) MigrationOptionsUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.MigrationOptionsUnitToVmBaseBuilder) ExistingPoolModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.ExistingPoolModelBehavior) VM(org.ovirt.engine.core.common.businessentities.VM) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmSpecificUnitToVmBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmSpecificUnitToVmBuilder) Linq(org.ovirt.engine.ui.uicommonweb.Linq) ExistingPoolModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.ExistingPoolModelBehavior) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) VM(org.ovirt.engine.core.common.businessentities.VM) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 5 with VmBasedWidgetSwitchModeCommand

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

the class PoolListModel method newEntity.

public void newEntity() {
    if (getWindow() != null) {
        return;
    }
    PoolModel model = new PoolModel(new NewPoolModelBehavior());
    model.setIsNew(true);
    model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
    // $NON-NLS-1$
    model.setIsAdvancedModeLocalStorageKey("wa_pool_dialog");
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().newPoolTitle());
    model.setHelpTag(HelpTag.new_pool);
    // $NON-NLS-1$
    model.setHashName("new_pool");
    model.getVmType().setSelectedItem(VmType.Desktop);
    model.initialize();
    VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
    switchModeCommand.init(model);
    model.getCommands().add(switchModeCommand);
    // $NON-NLS-1$
    UICommand command = UICommand.createDefaultOkUiCommand("OnSave", this);
    model.getCommands().add(command);
    // $NON-NLS-1$
    model.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Also used : NewPoolModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.NewPoolModelBehavior) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand)

Aggregations

UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 VmBasedWidgetSwitchModeCommand (org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand)5 NewPoolModelBehavior (org.ovirt.engine.ui.uicommonweb.models.vms.NewPoolModelBehavior)2 UnitVmModel (org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)2 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 AddVmPoolParameters (org.ovirt.engine.core.common.action.AddVmPoolParameters)1 VmPoolParametersBase (org.ovirt.engine.core.common.action.VmPoolParametersBase)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 VmPool (org.ovirt.engine.core.common.businessentities.VmPool)1 VmPoolType (org.ovirt.engine.core.common.businessentities.VmPoolType)1 VmType (org.ovirt.engine.core.common.businessentities.VmType)1 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)1 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1