Search in sources :

Example 1 with Model

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

the class AbstractModelBoundPopupPresenterWidget method addFooterButtons.

void addFooterButtons(T model) {
    for (int i = model.getCommands().size() - 1; i >= 0; i--) {
        UICommand command = model.getCommands().get(i);
        final HasUiCommandClickHandlers button = getView().addFooterButton(command.getTitle(), command.getName(), model.getDefaultCommand() != null && model.getDefaultCommand().equals(command));
        button.setCommand(command);
        // Register command execution handler
        registerHandler(button.addClickHandler(event -> {
            getView().flush();
            beforeCommandExecuted(button.getCommand());
            button.getCommand().execute();
        }));
    }
}
Also used : ModelBoundPopupHandler(org.ovirt.engine.ui.common.uicommon.model.ModelBoundPopupHandler) WebUtils(org.ovirt.engine.ui.common.utils.WebUtils) ModelBoundPopupResolver(org.ovirt.engine.ui.common.uicommon.model.ModelBoundPopupResolver) EventBus(com.google.gwt.event.shared.EventBus) HasEditorDriver(org.ovirt.engine.ui.common.widget.HasEditorDriver) HasUiCommandClickHandlers(org.ovirt.engine.ui.common.widget.HasUiCommandClickHandlers) AsyncOperationCompleteEvent(org.ovirt.engine.ui.frontend.communication.AsyncOperationCompleteEvent) AsyncOperationStartedEvent(org.ovirt.engine.ui.frontend.communication.AsyncOperationStartedEvent) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ContextSensitiveHelpManager(org.ovirt.engine.ui.common.uicommon.ContextSensitiveHelpManager) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) List(java.util.List) Provider(com.google.inject.Provider) HasCleanup(org.ovirt.engine.ui.uicommonweb.HasCleanup) DeferredModelCommandInvoker(org.ovirt.engine.ui.common.uicommon.model.DeferredModelCommandInvoker) DefaultConfirmationPopupPresenterWidget(org.ovirt.engine.ui.common.presenter.popup.DefaultConfirmationPopupPresenterWidget) ObservableCollection(org.ovirt.engine.ui.uicompat.ObservableCollection) Model(org.ovirt.engine.ui.uicommonweb.models.Model) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HasUiCommandClickHandlers(org.ovirt.engine.ui.common.widget.HasUiCommandClickHandlers)

Example 2 with Model

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

the class VmSnapshotListModel method cloneTemplate.

private void cloneTemplate() {
    Snapshot snapshot = getSelectedItem();
    if (snapshot == null) {
        return;
    }
    if (getWindow() != null) {
        return;
    }
    final UnitVmModel model = new UnitVmModel(createNewTemplateBehavior(), this);
    setWindow(model);
    model.startProgress();
    AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(vm -> {
        NewTemplateVmModelBehavior behavior = (NewTemplateVmModelBehavior) model.getBehavior();
        behavior.setVm(vm);
        model.setTitle(ConstantsManager.getInstance().getConstants().newTemplateTitle());
        model.setHelpTag(HelpTag.clone_template_from_snapshot);
        // $NON-NLS-1$
        model.setHashName("clone_template_from_snapshot");
        model.setIsNew(true);
        model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
        model.initialize();
        model.getVmType().setSelectedItem(vm.getVmType());
        model.getIsHighlyAvailable().setEntity(vm.getStaticData().isAutoStartup());
        model.getCommands().add(// $NON-NLS-1$
        new UICommand("OnNewTemplate", VmSnapshotListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
        // $NON-NLS-1$
        model.getCommands().add(UICommand.createCancelUiCommand("Cancel", VmSnapshotListModel.this));
        model.stopProgress();
    }), snapshot.getId());
}
Also used : CommonUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonUnitToVmBaseBuilder) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) QueryType(org.ovirt.engine.core.common.queries.QueryType) UnitToAddVmTemplateParametersBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.UnitToAddVmTemplateParametersBuilder) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) RemoveSnapshotParameters(org.ovirt.engine.core.common.action.RemoveSnapshotParameters) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SnapshotActionEnum(org.ovirt.engine.core.common.businessentities.SnapshotActionEnum) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) RestoreAllSnapshotsParameters(org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) AddVmFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmBaseToVmBaseForTemplateCompositeBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VmBaseToVmBaseForTemplateCompositeBaseBuilder) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) ActionUtils(org.ovirt.engine.core.common.ActionUtils) SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Set(java.util.Set) TryBackToAllSnapshotsOfVmParameters(org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters) StringHelper(org.ovirt.engine.core.compat.StringHelper) Collectors(java.util.stream.Collectors) SnapshotType(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) AddVmTemplateFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmTemplateFromSnapshotParameters) Comparator(java.util.Comparator) Collections(java.util.Collections) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmSpecificUnitToVmBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmSpecificUnitToVmBuilder) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 3 with Model

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

the class VmSnapshotListModel method cloneVM.

private void cloneVM() {
    Snapshot snapshot = getSelectedItem();
    if (snapshot == null) {
        return;
    }
    if (getWindow() != null) {
        return;
    }
    VM selectedVm = getEntity();
    UnitVmModel model = new UnitVmModel(new CloneVmFromSnapshotModelBehavior(), this);
    model.getVmType().setSelectedItem(selectedVm.getVmType());
    // $NON-NLS-1$
    model.setIsAdvancedModeLocalStorageKey("wa_snapshot_dialog");
    setWindow(model);
    model.startProgress();
    AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(vm -> {
        UnitVmModel unitVmModel = (UnitVmModel) getWindow();
        CloneVmFromSnapshotModelBehavior behavior = (CloneVmFromSnapshotModelBehavior) unitVmModel.getBehavior();
        behavior.setVm(vm);
        unitVmModel.setTitle(ConstantsManager.getInstance().getConstants().cloneVmFromSnapshotTitle());
        unitVmModel.setHelpTag(HelpTag.clone_vm_from_snapshot);
        // $NON-NLS-1$
        unitVmModel.setHashName("clone_vm_from_snapshot");
        unitVmModel.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
        unitVmModel.initialize();
        VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
        switchModeCommand.init(unitVmModel);
        unitVmModel.getCommands().add(switchModeCommand);
        // $NON-NLS-1$
        UICommand tempVar = UICommand.createDefaultOkUiCommand("OnCloneVM", VmSnapshotListModel.this);
        unitVmModel.getCommands().add(tempVar);
        // $NON-NLS-1$
        UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", VmSnapshotListModel.this);
        unitVmModel.getCommands().add(tempVar2);
        stopProgress();
    }), snapshot.getId());
}
Also used : CommonUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonUnitToVmBaseBuilder) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) QueryType(org.ovirt.engine.core.common.queries.QueryType) UnitToAddVmTemplateParametersBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.UnitToAddVmTemplateParametersBuilder) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) RemoveSnapshotParameters(org.ovirt.engine.core.common.action.RemoveSnapshotParameters) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SnapshotActionEnum(org.ovirt.engine.core.common.businessentities.SnapshotActionEnum) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) RestoreAllSnapshotsParameters(org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) AddVmFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmBaseToVmBaseForTemplateCompositeBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VmBaseToVmBaseForTemplateCompositeBaseBuilder) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) ActionUtils(org.ovirt.engine.core.common.ActionUtils) SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Set(java.util.Set) TryBackToAllSnapshotsOfVmParameters(org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters) StringHelper(org.ovirt.engine.core.compat.StringHelper) Collectors(java.util.stream.Collectors) SnapshotType(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) AddVmTemplateFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmTemplateFromSnapshotParameters) Comparator(java.util.Comparator) Collections(java.util.Collections) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmSpecificUnitToVmBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmSpecificUnitToVmBuilder) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VM(org.ovirt.engine.core.common.businessentities.VM) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 4 with Model

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

the class InstanceTypeAttachDetachManager method manageInstanceType.

public void manageInstanceType(InstanceType instanceType) {
    this.managedInstanceType = instanceType;
    setAttachedTo(instanceType);
    modelToProperValue = new HashMap<>();
    for (Model model : detachableModels) {
        if (model instanceof ListModel) {
            modelToProperValue.put(model, ((ListModel) model).getSelectedItem());
        } else if (model instanceof EntityModel) {
            modelToProperValue.put(model, ((EntityModel) model).getEntity());
        }
    }
    if (!alreadyRegistered) {
        model.getInstanceTypes().getSelectedItemChangedEvent().addListener(this);
        listenToDetachableFields(detachableModels);
        alreadyRegistered = true;
    }
}
Also used : ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel)

Example 5 with Model

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

the class AbstractSubTabPanelPresenter method onReveal.

@Override
protected void onReveal() {
    super.onReveal();
    // make sure all detail tabs have their visibility updated
    for (Map.Entry<TabData, Model> entry : detailTabToModelMapping.entrySet()) {
        TabData tabData = entry.getKey();
        Model detailModel = entry.getValue();
        updateTabVisibility(tabData, detailModel);
    }
}
Also used : Model(org.ovirt.engine.ui.uicommonweb.models.Model) TabData(com.gwtplatform.mvp.client.TabData) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Model (org.ovirt.engine.ui.uicommonweb.models.Model)56 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)46 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)41 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)39 ArrayList (java.util.ArrayList)37 List (java.util.List)37 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)35 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)35 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)35 ActionType (org.ovirt.engine.core.common.action.ActionType)34 Frontend (org.ovirt.engine.ui.frontend.Frontend)34 QueryType (org.ovirt.engine.core.common.queries.QueryType)33 VDS (org.ovirt.engine.core.common.businessentities.VDS)32 Guid (org.ovirt.engine.core.compat.Guid)32 Linq (org.ovirt.engine.ui.uicommonweb.Linq)32 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)30 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)30 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)29 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)28 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)28