Search in sources :

Example 56 with ConfirmationModel

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

the class StorageSnapshotListModel method onRemove.

private void onRemove() {
    ConfirmationModel model = (ConfirmationModel) getWindow();
    ArrayList<ActionParametersBase> paramerterList = new ArrayList<>();
    Map<Guid, List<Guid>> diskImageIdsMap = groupImageIdsByDiskId(getSelectedItems());
    for (List<Guid> imageIds : diskImageIdsMap.values()) {
        RemoveDiskSnapshotsParameters parameters = new RemoveDiskSnapshotsParameters(new ArrayList<>(imageIds));
        paramerterList.add(parameters);
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.RemoveDiskSnapshots, paramerterList, result -> {
        StorageSnapshotListModel localModel = (StorageSnapshotListModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, this);
}
Also used : RemoveDiskSnapshotsParameters(org.ovirt.engine.core.common.action.RemoveDiskSnapshotsParameters) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 57 with ConfirmationModel

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

the class ConsoleModel method displayConsoleConnectConfirmPopup.

private void displayConsoleConnectConfirmPopup(final UICommand onConfirmCommand) {
    ConfirmationModel model = new ConfirmationModel();
    parentModel.setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().confirmConsoleConnect());
    model.setHelpTag(HelpTag.confirm_console_connect);
    // $NON-NLS-1$
    model.setHashName("confirm_console_connect");
    model.setMessage(ConstantsManager.getInstance().getConstants().confirmConsoleConnectMessage());
    UICommand confirmAndCloseCommand = new UICommand("Confirm", new // $NON-NLS-1$
    BaseCommandTarget() {

        @Override
        public void executeCommand(UICommand uiCommand) {
            onConfirmCommand.execute();
            parentModel.setWindow(null);
        }
    });
    confirmAndCloseCommand.setTitle(ConstantsManager.getInstance().getConstants().ok());
    confirmAndCloseCommand.setIsDefault(true);
    model.getCommands().add(confirmAndCloseCommand);
    UICommand cancelCommand = new UICommand("Cancel", new // $NON-NLS-1$
    BaseCommandTarget() {

        @Override
        public void executeCommand(UICommand uiCommand) {
            parentModel.setWindow(null);
        }
    });
    cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel());
    cancelCommand.setIsCancel(true);
    model.getCommands().add(cancelCommand);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 58 with ConfirmationModel

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

the class ConsoleModelErrorEventListener method consoleModelError.

private void consoleModelError(Object sender, String message) {
    ConfirmationModel model = new ConfirmationModel();
    if (parentModel.getConfirmWindow() == null) {
        parentModel.setConfirmWindow(model);
    }
    model.setTitle(ConstantsManager.getInstance().getConstants().consoleDisconnectedTitle());
    model.setHelpTag(HelpTag.console_disconnected);
    // $NON-NLS-1$
    model.setHashName("console_disconnected");
    model.setMessage(message);
    // $NON-NLS-1$
    UICommand tempVar = new UICommand("CancelError", this);
    tempVar.setTitle(ConstantsManager.getInstance().getConstants().close());
    tempVar.setIsDefault(true);
    tempVar.setIsCancel(true);
    model.getCommands().add(tempVar);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 59 with ConfirmationModel

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

the class ModelBoundPopupHandler method handleWindowModelChange.

/**
 * Handles the change of given property (as defined by {@code propertyName})
 * for the given model.
 * <p>
 * {@code currentPopup} represents the GWTP popup instance associated with the
 * property (can be {@code null} to indicate that the associated popup is not
 * active at the moment).
 * <p>
 * {@code isConfirmation} is used to differentiate between "Window"-like and
 * "ConfirmWindow"-like properties:
 * <ul>
 * <li>"Window"-like properties have popups resolved via
 *      {@link ModelBoundPopupResolver#getModelPopup} method</li>
 * <li>"ConfirmWindow"-like properties have popups resolved via
 *      {@link ModelBoundPopupResolver#getConfirmModelPopup} method</li>
 * </ul>
 */
@SuppressWarnings("unchecked")
void handleWindowModelChange(M sourceModel, String propertyName, AbstractModelBoundPopupPresenterWidget<?, ?> currentPopup, boolean isConfirmation) {
    // Model behind the popup
    Model windowModel = isConfirmation ? sourceModel.getConfirmWindowProperties().get(propertyName) : sourceModel.getWindowProperties().get(propertyName);
    // Reveal new popup
    if (windowModel != null && currentPopup == null) {
        // 1. Resolve
        AbstractModelBoundPopupPresenterWidget<?, ?> newPopup = null;
        UICommand lastExecutedCommand = sourceModel.getLastExecutedCommand();
        if (windowModel instanceof ConfirmationModel) {
            // Resolve confirmation popup
            newPopup = popupResolver.getConfirmModelPopup(sourceModel, lastExecutedCommand);
            if (newPopup == null && defaultConfirmPopupProvider != null) {
                // Fall back to basic confirmation popup
                newPopup = defaultConfirmPopupProvider.get();
            }
        } else {
            // Resolve main popup
            newPopup = popupResolver.getModelPopup(sourceModel, lastExecutedCommand, windowModel);
        }
        // 2. Reveal
        if (newPopup != null) {
            revealAndAssignPopup(windowModel, propertyName, (AbstractModelBoundPopupPresenterWidget<Model, ?>) newPopup, isConfirmation);
        } else {
            if (isConfirmation) {
                sourceModel.setConfirmWindowProperty(propertyName, null);
            } else {
                sourceModel.setWindowProperty(propertyName, null);
            }
        }
    } else // Close existing popup
    if (windowModel == null && currentPopup != null) {
        hideAndClearPopup(propertyName, currentPopup, isConfirmation);
    }
}
Also used : IModel(org.ovirt.engine.ui.uicommonweb.models.IModel) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 60 with ConfirmationModel

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

the class DataCenterGuideModel method onSaveSanStorage.

private void onSaveSanStorage() {
    ConfirmationModel confirmationModel = (ConfirmationModel) getConfirmWindow();
    if (confirmationModel != null && !confirmationModel.validate()) {
        return;
    }
    cancelConfirm();
    getWindow().startProgress();
    StorageModel model = (StorageModel) getWindow();
    SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
    VDS host = model.getHost().getSelectedItem();
    boolean force = sanModel.isForce();
    HashSet<String> lunIds = new HashSet<>();
    for (LunModel lun : sanModel.getAddedLuns()) {
        lunIds.add(lun.getLunId());
    }
    AddSANStorageDomainParameters params = new AddSANStorageDomainParameters(storageDomain);
    params.setVdsId(host.getId());
    params.setLunIds(new HashSet<>(lunIds));
    params.setForce(force);
    Frontend.getInstance().runAction(ActionType.AddSANStorageDomain, params, result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        StorageModel storageModel = (StorageModel) dataCenterGuideModel.getWindow();
        StoragePool dataCenter = storageModel.getDataCenter().getSelectedItem();
        if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
            ActionReturnValue returnValue = result.getReturnValue();
            Guid storageId = returnValue.getActionReturnValue();
            dataCenterGuideModel.attachStorageToDataCenter(storageId, dataCenter.getId());
        }
        dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
    }, this);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) VDS(org.ovirt.engine.core.common.businessentities.VDS) PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) Guid(org.ovirt.engine.core.compat.Guid) AddSANStorageDomainParameters(org.ovirt.engine.core.common.action.AddSANStorageDomainParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) LunModel(org.ovirt.engine.ui.uicommonweb.models.storage.LunModel) HashSet(java.util.HashSet)

Aggregations

ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)184 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)112 ArrayList (java.util.ArrayList)105 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)54 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)23 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)22 List (java.util.List)21 ActionType (org.ovirt.engine.core.common.action.ActionType)20 Frontend (org.ovirt.engine.ui.frontend.Frontend)20 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)20 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)20 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)20 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)18 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)17 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)17 QueryType (org.ovirt.engine.core.common.queries.QueryType)17 Guid (org.ovirt.engine.core.compat.Guid)17 Model (org.ovirt.engine.ui.uicommonweb.models.Model)15 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)14