Search in sources :

Example 1 with ExistingPoolModelBehavior

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

Aggregations

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 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1