Search in sources :

Example 76 with UICommand

use of org.ovirt.engine.ui.uicommonweb.UICommand 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 77 with UICommand

use of org.ovirt.engine.ui.uicommonweb.UICommand 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 78 with UICommand

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

the class TabModelProvider method modelBoundWidgetChange.

/**
 * Called when the widget-model property of a model is changed
 * TODO this seems important. What does it do? What is a widget model?
 */
@SuppressWarnings("unchecked")
void modelBoundWidgetChange() {
    UICommand lastExecutedCommand = getModel().getLastExecutedCommand();
    ModelBoundPresenterWidget<?> modelBoundPresenterWidget = getModelBoundWidget(lastExecutedCommand);
    ((ModelBoundPresenterWidget<Model>) modelBoundPresenterWidget).init(getModel().getWidgetModel());
}
Also used : ModelBoundPresenterWidget(org.ovirt.engine.ui.common.presenter.ModelBoundPresenterWidget) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 79 with UICommand

use of org.ovirt.engine.ui.uicommonweb.UICommand 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 80 with UICommand

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

the class DataCenterGuideModel method updateAddAndSelectHostAvailability.

private void updateAddAndSelectHostAvailability(List<VDS> hosts, List<VDS> availableHosts) {
    // $NON-NLS-1$
    UICommand addHostAction = new UICommand("AddHost", this);
    addHostAction.setIsExecutionAllowed(clusters.size() > 0);
    if (hosts.isEmpty()) {
        addHostAction.setTitle(DataCenterConfigureHostsAction);
        getCompulsoryActions().add(addHostAction);
    } else {
        addHostAction.setTitle(DataCenterAddAnotherHostAction);
        getOptionalActions().add(addHostAction);
    }
    // Select host action.
    // $NON-NLS-1$
    UICommand selectHostAction = new UICommand("SelectHost", this);
    // If now compatible hosts are found - disable the select host button
    selectHostAction.setIsChangeable(availableHosts.size() > 0);
    selectHostAction.setIsExecutionAllowed(availableHosts.size() > 0);
    if (clusters.size() > 0) {
        if (hosts.isEmpty()) {
            selectHostAction.setTitle(DataCenterSelectHostsAction);
            getCompulsoryActions().add(selectHostAction);
        } else {
            selectHostAction.setTitle(DataCenterSelectHostsAction);
            getOptionalActions().add(selectHostAction);
        }
    }
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Aggregations

UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)257 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)134 ArrayList (java.util.ArrayList)105 List (java.util.List)49 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)49 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)49 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)48 ActionType (org.ovirt.engine.core.common.action.ActionType)47 Frontend (org.ovirt.engine.ui.frontend.Frontend)47 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)44 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)41 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)36 Guid (org.ovirt.engine.core.compat.Guid)36 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)33 QueryType (org.ovirt.engine.core.common.queries.QueryType)33 VDS (org.ovirt.engine.core.common.businessentities.VDS)30 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)29 Linq (org.ovirt.engine.ui.uicommonweb.Linq)28 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)26 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)24