Example usage for org.eclipse.jface.dialogs IDialogConstants YES_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants YES_ID.

Prototype

int YES_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_ID.

Click Source Link

Document

Button id for a "Yes" button (value 2).

Usage

From source file:org.jkiss.dbeaver.ui.dialogs.data.CursorViewDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    final IValueController valueController = getValueController();
    value = (DBDCursor) valueController.getValue();

    Composite dialogGroup = (Composite) super.createDialogArea(parent);

    if (value != null) {
        DBPPreferenceStore globalPreferenceStore = DBeaverCore.getGlobalPreferenceStore();
        if (!globalPreferenceStore.getBoolean(DBeaverPreferences.KEEP_STATEMENT_OPEN)) {
            if (ConfirmationDialog.showConfirmDialog(getShell(), DBeaverPreferences.CONFIRM_KEEP_STATEMENT_OPEN,
                    ConfirmationDialog.QUESTION) == IDialogConstants.YES_ID) {
                globalPreferenceStore.setValue(DBeaverPreferences.KEEP_STATEMENT_OPEN, true);
                if (valueController.getValueSite().getPart() instanceof IResultSetContainer) {
                    ResultSetViewer rsv = ((IResultSetContainer) valueController.getValueSite().getPart())
                            .getResultSetViewer();
                    if (rsv != null) {
                        rsv.refresh();/* ww w . j  a v  a 2  s. co  m*/
                    }
                }
            }
            dialogGroup.getDisplay().asyncExec(new Runnable() {
                @Override
                public void run() {
                    close();
                }
            });
        }
    }

    resultSetViewer = new ResultSetViewer(dialogGroup, valueController.getValueSite(), this);

    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 300;
    gd.grabExcessVerticalSpace = true;
    resultSetViewer.getControl().setLayoutData(gd);

    resultSetViewer.refresh();
    return dialogGroup;
}

From source file:org.jkiss.dbeaver.ui.editors.entity.EntityEditor.java

License:Open Source License

public void revertChanges() {
    if (isDirty()) {
        if (ConfirmationDialog.showConfirmDialog(null, DBeaverPreferences.CONFIRM_ENTITY_REVERT,
                ConfirmationDialog.QUESTION, getDatabaseObject().getName()) != IDialogConstants.YES_ID) {
            return;
        }/*from  ww  w  .j  av  a  2 s. co  m*/
        getCommandContext().resetChanges();
        firePropertyChange(IEditorPart.PROP_DIRTY);
    }
}

From source file:org.jkiss.dbeaver.ui.editors.entity.EntityEditor.java

License:Open Source License

public void undoChanges() {
    DBECommandContext commandContext = getCommandContext();
    if (commandContext != null && commandContext.getUndoCommand() != null) {
        if (!getDatabaseObject().isPersisted() && commandContext.getUndoCommands().size() == 1) {
            //getSite().getPage().closeEditor(this, true);
            //return;
            // Undo of last command in command context will close editor
            // Let's ask user about it
            if (ConfirmationDialog.showConfirmDialog(null, DBeaverPreferences.CONFIRM_ENTITY_REJECT,
                    ConfirmationDialog.QUESTION, getDatabaseObject().getName()) != IDialogConstants.YES_ID) {
                return;
            }/*  w w  w.  j  a va2 s .c o  m*/
        }
        commandContext.undoCommand();
        firePropertyChange(IEditorPart.PROP_DIRTY);
    }
}

From source file:org.jkiss.dbeaver.ui.editors.entity.EntityEditor.java

License:Open Source License

@Override
public int promptToSaveOnClose() {
    final int result = ConfirmationDialog.showConfirmDialog(getSite().getShell(),
            DBeaverPreferences.CONFIRM_ENTITY_EDIT_CLOSE, ConfirmationDialog.QUESTION_WITH_CANCEL,
            getEditorInput().getNavigatorNode().getNodeName());
    if (result == IDialogConstants.YES_ID) {
        //            getWorkbenchPart().getSite().getPage().saveEditor(this, false);
        return ISaveablePart2.YES;
    } else if (result == IDialogConstants.NO_ID) {
        return ISaveablePart2.NO;
    } else {/* ww w.j  a v  a  2s .  co  m*/
        return ISaveablePart2.CANCEL;
    }
}

From source file:org.key_project.keyide.ui.util.KeYIDEUtil.java

License:Open Source License

/**
 * Checks if a perspective switch to the state visualization perspective should be done.
 * @param activePage The currently active {@link IWorkbenchPage}.
 * @return {@code true} switch to state visualization perspective, {@code false} stay in current perspective.
 *///from  w w w .ja v a 2 s  . c  o m
public static boolean shouldSwitchToKeyPerspective(IWorkbenchPage activePage) {
    boolean switchPerspective = false;
    // Check if a different perspective is currently opened.
    if (!WorkbenchUtil.isPerspectiveOpen("org.key_project.keyide.ui.perspectives", activePage)) {
        String option = KeYIDEPreferences.getSwitchToKeyPerspective();
        if (MessageDialogWithToggle.ALWAYS.equals(option)) {
            switchPerspective = true;
        } else if (MessageDialogWithToggle.NEVER.equals(option)) {
            switchPerspective = false;
        } else {
            MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
                    activePage.getActivePart().getSite().getShell(), "Confirm Perspective Switch",
                    "The Proof management is associated with the "
                            + WorkbenchUtil.getPerspectiveName("org.key_project.keyide.ui.perspectives")
                            + " perspective.\n\nDo you want to open this perspective now?",
                    null, false, KeYIDEPreferences.getStore(), KeYIDEPreferences.SWITCH_TO_KEY_PERSPECTIVE);
            switchPerspective = (dialog.getReturnCode() == IDialogConstants.YES_ID);
        }
    }
    return switchPerspective;
}

From source file:org.key_project.sed.ui.visualization.object_diagram.util.ObjectDiagramUtil.java

License:Open Source License

/**
 * Checks if a perspective switch to the state visualization perspective should be done.
 * @param activePage The currently active {@link IWorkbenchPage}.
 * @return {@code true} switch to state visualization perspective, {@code false} stay in current perspective.
 *//* w  ww  .j  av a2  s.c o  m*/
public static boolean shouldSwitchToStateVisualizationPerspective(IWorkbenchPage activePage) {
    boolean switchPerspective = false;
    // Check if a different perspective is currently opened.
    if (!WorkbenchUtil.isPerspectiveOpen(StateVisualizationPerspectiveFactory.PERSPECTIVE_ID, activePage)) {
        String option = VisualizationPreferences.getSwitchToStateVisualizationPerspective();
        if (MessageDialogWithToggle.ALWAYS.equals(option)) {
            switchPerspective = true;
        } else if (MessageDialogWithToggle.NEVER.equals(option)) {
            switchPerspective = false;
        } else {
            MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
                    activePage.getActivePart().getSite().getShell(), "Confirm Perspective Switch",
                    "The state visualization is associated with the "
                            + WorkbenchUtil
                                    .getPerspectiveName(StateVisualizationPerspectiveFactory.PERSPECTIVE_ID)
                            + " perspective.\n\nDo you want to open this perspective now?",
                    null, false, VisualizationPreferences.getStore(),
                    VisualizationPreferences.SWITCH_TO_STATE_VISUALIZATION_PERSPECTIVE);
            switchPerspective = (dialog.getReturnCode() == IDialogConstants.YES_ID);
        }
    }
    return switchPerspective;
}

From source file:org.mailster.gui.utils.DialogUtils.java

License:Open Source License

/**
 * Creates a question dialog. Note that the dialog will have no visual
 * representation (no widgets) until it is told to open. The
 * <code>open</code> method will return either
 * {@link org.eclipse.jface.dialogs.IDialogConstants#YES_ID} if the question
 * dialog was confirmed with YES,/* w ww.jav  a  2  s.c o  m*/
 * {@link org.eclipse.jface.dialogs.IDialogConstants#NO_ID} if the dialog
 * was left with NO or <i>-1</i> if the dialog was dismissed without
 * pressing a button(ESC, etc.). Note that the <code>open</code> method
 * blocks.
 * 
 * @param parentShell the parent shell
 * @param title the dialog title, or <code>null</code> if none
 * @param message the dialog message
 * @param titleImage the dialog title image, or <code>null</code> if none
 * @return the created <code>MessageDialog</code>
 */
public static MessageDialog createQuestionDialog(Shell parentShell, String title, String message,
        Image titleImage) {
    MessageDialog dialog = new MessageDialog(parentShell, title, titleImage, message, MessageDialog.QUESTION,
            new String[] {}, 0) {
        protected void createButtonsForButtonBar(Composite parent) {
            Button yesButton = null;
            Button noButton = null;

            if (Display.getDefault().getDismissalAlignment() == SWT.LEFT) {
                // Default dismissal button (YES) has to be on the left side

                // Create YES Button
                yesButton = this.createButton(parent, IDialogConstants.YES_ID, Messages.getString("yesButton"),
                        true);

                // Create NO Button
                noButton = this.createButton(parent, IDialogConstants.NO_ID, Messages.getString("noButton"),
                        false);
            } else {
                // Default dismissal button (YES) has to be on the right

                // Create NO Button
                noButton = this.createButton(parent, IDialogConstants.NO_ID, Messages.getString("noButton"),
                        true);

                // Create YES Button
                yesButton = this.createButton(parent, IDialogConstants.YES_ID, Messages.getString("yesButton"),
                        false);
            }

            // Set Image for YES button and adjust layout
            yesButton.setImage(SWTHelper.loadImage("button_ok.png"));
            yesButton.setAlignment(SWT.RIGHT);
            this.setButtonLayoutData(yesButton);

            // Set Image for NO button and adjust layout
            noButton.setImage(SWTHelper.loadImage("button_cancel.png"));
            noButton.setAlignment(SWT.RIGHT);
            this.setButtonLayoutData(noButton);
        }
    };
    return dialog;
}

From source file:org.obeonetwork.dsl.dart.usage.internal.dialog.UsageDialog.java

License:Open Source License

/**
 * {@inheritDoc}/*ww  w. j a  v  a 2s .c  o  m*/
 * 
 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
}

From source file:org.obeonetwork.dsl.dart.usage.internal.preferences.UsagePreferences.java

License:Open Source License

/**
 * Check if the user has answered to the question.
 * /*from   www.j ava2  s. c  o  m*/
 * @return True if answered the question (by yes or no) otherwise false
 */
public boolean hasAnswered() {
    if (preferenceStore.getInt(USAGE_USER_ANSWER_ID) == IDialogConstants.YES_ID
            || preferenceStore.getInt(USAGE_USER_ANSWER_ID) == IDialogConstants.NO_ID) {
        return true;
    }
    return false;
}

From source file:org.obeonetwork.dsl.dart.usage.internal.preferences.UsagePreferences.java

License:Open Source License

/**
 * Store if the user as answer to the question.
 * /*from   w  w  w  . ja  v a  2s.co m*/
 * @param answerId
 *            The answer could be {@link IDialogConstants#YES_ID} if the user clicked on yes,
 *            {@link IDialogConstants#NO_ID} if he clicked on no or {@link IDialogConstants#OK_ID} if he
 *            does not answered
 */
public void storeUserAnswer(int answerId) {
    preferenceStore.setValue(USAGE_USER_ANSWER_ID, answerId);
    if (answerId == IDialogConstants.YES_ID) {
        preferenceStore.setValue(USAGE_ENABLED_ID, true);
    }
    if (answerId == IDialogConstants.NO_ID) {
        preferenceStore.setValue(USAGE_ENABLED_ID, false);
    }
}