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

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

Introduction

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

Prototype

String YES_LABEL

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

Click Source Link

Document

The label for yes buttons.

Usage

From source file:org.eclipse.rcptt.ui.wizards.imports.BaseProjectsImportPage.java

License:Open Source License

/**
 * The <code>WizardDataTransfer</code> implementation of this
 * <code>IOverwriteQuery</code> method asks the user whether the existing
 * resource at the given path should be overwritten.
 * /*from  w w w .  j  a v a2s . co m*/
 * @param pathString
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
 *         <code>"ALL"</code>, or <code>"CANCEL"</code>
 */
public String queryOverwrite(String pathString) {

    Path path = new Path(pathString);

    String messageString;
    // Break the message up if there is a file name and a directory
    // and there are at least 2 segments.
    if (path.getFileExtension() == null || path.segmentCount() < 2) {
        messageString = NLS.bind(Messages.BaseProjectsImportPage_29, pathString);
    } else {
        messageString = NLS.bind(Messages.BaseProjectsImportPage_30, path.lastSegment(),
                path.removeLastSegments(1).toOSString());
    }

    final MessageDialog dialog = new MessageDialog(getContainer().getShell(),
            Messages.BaseProjectsImportPage_31, null, messageString, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0) {
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
    // run in syncExec because callback is from an operation,
    // which is probably not running in the UI thread.
    getControl().getDisplay().syncExec(new Runnable() {
        public void run() {
            dialog.open();
        }
    });
    return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}

From source file:org.eclipse.remote.internal.jsch.ui.JSchUserAuthenticator.java

License:Open Source License

@Override
public int prompt(final int promptType, final String title, final String message, final int[] promptResponses,
        final int defaultResponseIndex) {
    final Display display = getDisplay();
    final int[] retval = new int[1];
    final String[] buttons = new String[promptResponses.length];
    for (int i = 0; i < promptResponses.length; i++) {
        int prompt = promptResponses[i];
        switch (prompt) {
        case IDialogConstants.OK_ID:
            buttons[i] = IDialogConstants.OK_LABEL;
            break;
        case IDialogConstants.CANCEL_ID:
            buttons[i] = IDialogConstants.CANCEL_LABEL;
            break;
        case IDialogConstants.NO_ID:
            buttons[i] = IDialogConstants.NO_LABEL;
            break;
        case IDialogConstants.YES_ID:
            buttons[i] = IDialogConstants.YES_LABEL;
            break;
        }/*from  w  w w  .  j  av a  2  s.c  om*/
    }

    display.syncExec(new Runnable() {
        @Override
        public void run() {
            final MessageDialog dialog = new MessageDialog(display.getActiveShell(), title,
                    null /* title image */, message, promptType, buttons, defaultResponseIndex);
            retval[0] = dialog.open();
        }
    });
    return promptResponses[retval[0]];
}

From source file:org.eclipse.remote.internal.ui.preferences.ConnectionsPreferencePage.java

License:Open Source License

/**
 * Add a new connection/*from w w  w .j  ava2s .  com*/
 */
private void addConnection() {
    if (fIsDirty) {
        MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions,
                null, Messages.ConnectionsPreferencePage_There_are_unsaved_changes, MessageDialog.QUESTION,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        if (dialog.open() == 1) {
            return;
        }
        performOk();
    }
    if (fUIConnectionManager != null) {
        IRemoteUIConnectionWizard wizard = fUIConnectionManager.getConnectionWizard(getShell());
        if (wizard != null) {
            wizard.setConnectionName(initialConnectionName());
            wizard.setInvalidConnectionNames(invalidConnectionNames());
            IRemoteConnectionWorkingCopy conn = wizard.open();
            if (conn != null) {
                fWorkingCopies.put(conn.getName(), conn);
                if (!fConnectionViewer.getTable().isDisposed()) {
                    fConnectionViewer.refresh();
                }
                fIsDirty = true;
            }
        }
    }
}

From source file:org.eclipse.remote.internal.ui.preferences.ConnectionsPreferencePage.java

License:Open Source License

/**
 * Toggle the connection//  ww w . j a va  2 s  . c om
 */
private void toggleConnection() {
    TableItem[] items = fConnectionTable.getSelection();
    if (items.length > 0) {
        IRemoteConnection conn = getOriginalIfClean((IRemoteConnection) items[0].getData());
        if (conn.hasService(IRemoteConnectionControlService.class) && conn.isOpen()) {
            conn.close();
        } else {
            if (conn instanceof IRemoteConnectionWorkingCopy) {
                IRemoteConnectionWorkingCopy wc = (IRemoteConnectionWorkingCopy) conn;
                if (wc.isDirty()) {
                    MessageDialog dialog = new MessageDialog(getShell(),
                            Messages.ConnectionsPreferencePage_Confirm_Actions, null,
                            Messages.ConnectionsPreferencePage_This_connection_contains_unsaved_changes,
                            MessageDialog.QUESTION,
                            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
                    if (dialog.open() == 1) {
                        return;
                    }
                    try {
                        conn = wc.save();
                    } catch (RemoteConnectionException e) {
                        RemoteUIPlugin.log(e);
                    }
                    /*
                     * Replace working copy with original so that the correct version will be used in the future
                     */
                    fWorkingCopies.put(conn.getName(), conn);
                }
            }
            IRemoteUIConnectionService mgr = conn.getConnectionType()
                    .getService(IRemoteUIConnectionService.class);
            if (mgr != null) {
                mgr.openConnectionWithProgress(getShell(), null, conn);
            }
        }
        fConnectionViewer.refresh();
        updateEnablement();
    }
}

From source file:org.eclipse.riena.internal.ui.ridgets.swt.MessageBoxRidgetTest.java

License:Open Source License

public void testSetOptions() throws Exception {

    // show message box to transfer values set
    getRidget().show();//w  w w.  ja  v  a 2 s  .  c  om

    assertEquals(1, getWidget().buttonLabels.length);
    assertEquals(IDialogConstants.OK_LABEL, getWidget().buttonLabels[0]);
    assertEquals(IMessageBoxRidget.OPTIONS_OK, getRidget().getOptions());

    getRidget().setOptions(IMessageBoxRidget.OPTIONS_YES_NO);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(2, getWidget().buttonLabels.length);
    assertEquals(IDialogConstants.YES_LABEL, getWidget().buttonLabels[0]);
    assertEquals(IDialogConstants.NO_LABEL, getWidget().buttonLabels[1]);
    assertEquals(IMessageBoxRidget.OPTIONS_YES_NO, getRidget().getOptions());

    getRidget().setOptions(IMessageBoxRidget.OPTIONS_OK_CANCEL);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(2, getWidget().buttonLabels.length);
    assertEquals(IDialogConstants.OK_LABEL, getWidget().buttonLabels[0]);
    assertEquals(IDialogConstants.CANCEL_LABEL, getWidget().buttonLabels[1]);
    assertEquals(IMessageBoxRidget.OPTIONS_OK_CANCEL, getRidget().getOptions());

    getRidget().setOptions(IMessageBoxRidget.OPTIONS_YES_NO_CANCEL);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(3, getWidget().buttonLabels.length);
    assertEquals(IDialogConstants.YES_LABEL, getWidget().buttonLabels[0]);
    assertEquals(IDialogConstants.NO_LABEL, getWidget().buttonLabels[1]);
    assertEquals(IDialogConstants.CANCEL_LABEL, getWidget().buttonLabels[2]);
    assertEquals(IMessageBoxRidget.OPTIONS_YES_NO_CANCEL, getRidget().getOptions());

    final MessageBoxOption[] semiCustomOptions = new IMessageBoxRidget.MessageBoxOption[] {
            IMessageBoxRidget.OK, new IMessageBoxRidget.MessageBoxOption("TestCustomOptionText") };
    getRidget().setOptions(semiCustomOptions);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(2, getWidget().buttonLabels.length);
    assertEquals("OK", getWidget().buttonLabels[0]);
    assertEquals("TestCustomOptionText", getWidget().buttonLabels[1]);
    assertEquals(semiCustomOptions, getRidget().getOptions());

    final MessageBoxOption[] customOptions = new IMessageBoxRidget.MessageBoxOption[] {
            new IMessageBoxRidget.MessageBoxOption("TestCustomOptionText1"),
            new IMessageBoxRidget.MessageBoxOption("TestCustomOptionText2"),
            new IMessageBoxRidget.MessageBoxOption("TestCustomOptionText3") };
    getRidget().setOptions(customOptions);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(3, getWidget().buttonLabels.length);
    assertEquals("TestCustomOptionText1", getWidget().buttonLabels[0]);
    assertEquals("TestCustomOptionText2", getWidget().buttonLabels[1]);
    assertEquals("TestCustomOptionText3", getWidget().buttonLabels[2]);
    assertEquals(customOptions, getRidget().getOptions());

    getRidget().setOptions(IMessageBoxRidget.OPTIONS_OK);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(1, getWidget().buttonLabels.length);
    assertEquals(IDialogConstants.OK_LABEL, getWidget().buttonLabels[0]);
    assertEquals(IMessageBoxRidget.OPTIONS_OK, getRidget().getOptions());
}

From source file:org.eclipse.riena.ui.swt.facades.DialogConstantsFacadeRCP.java

License:Open Source License

@Override
public String getYesLabel() {
    return IDialogConstants.YES_LABEL;
}

From source file:org.eclipse.scada.sec.ui.ConfirmationDialogFuture.java

License:Open Source License

private Boolean showDialog(final ConfirmationCallback cb, final Display display, final Shell parentShell,
        final String dialogTitle) {
    switch (cb.getConfirmationType()) {
    case CONFIRM:
        return MessageDialog.openConfirm(parentShell, dialogTitle, cb.getLabel()) ? true : null;
    case ERROR://from w  w w.  jav  a  2s  . c  o  m
        MessageDialog.openError(parentShell, dialogTitle, cb.getLabel());
        return true;
    case WARNING:
        MessageDialog.openWarning(parentShell, dialogTitle, cb.getLabel());
        return true;
    case INFORMATION:
        MessageDialog.openInformation(parentShell, dialogTitle, cb.getLabel());
        return true;
    case QUESTION:
        return MessageDialog.openQuestion(parentShell, dialogTitle, cb.getLabel());
    case QUESTION_WITH_CANCEL: {
        final MessageDialog dialog = new MessageDialog(parentShell, dialogTitle, null, cb.getLabel(),
                MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL,
                        IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                0);
        final int result = dialog.open();
        if (result == 2 /*CANCEL*/) {
            return null;
        } else {
            return result == Window.OK;
        }
    }
    default:
        throw new IllegalArgumentException(
                String.format("Unable to process type: %s", cb.getConfirmationType()));
    }
}

From source file:org.eclipse.sirius.common.ui.tools.api.dialog.SiriusMessageDialogWithToggle.java

License:Open Source License

/**
 * Attempt to find a standard JFace button id that matches the specified
 * button label. If no match can be found, use the default id provided.
 * /*from  www.j  a  va  2s . c  o m*/
 * Overridden to investigate the provided buttons.
 * 
 * @param buttonLabel
 *            the button label whose id is sought
 * @param defaultId
 *            the id to use for the button if there is no standard id
 * @return the id for the specified button label
 */
// CHECKSTYLE:OFF
private int mapButtonLabelToButtonID(String buttonLabel, int defaultId) {
    // CHECKSTYLE:OON
    // Not pretty but does the job...
    if (IDialogConstants.OK_LABEL.equals(buttonLabel)) {
        return IDialogConstants.OK_ID;
    }

    if (IDialogConstants.YES_LABEL.equals(buttonLabel)) {
        return IDialogConstants.YES_ID;
    }

    if (IDialogConstants.NO_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NO_ID;
    }

    if (IDialogConstants.CANCEL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.CANCEL_ID;
    }

    if (IDialogConstants.YES_TO_ALL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.YES_TO_ALL_ID;
    }

    if (IDialogConstants.SKIP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.SKIP_ID;
    }

    if (IDialogConstants.STOP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.STOP_ID;
    }

    if (IDialogConstants.ABORT_LABEL.equals(buttonLabel)) {
        return IDialogConstants.ABORT_ID;
    }

    if (IDialogConstants.RETRY_LABEL.equals(buttonLabel)) {
        return IDialogConstants.RETRY_ID;
    }

    if (IDialogConstants.IGNORE_LABEL.equals(buttonLabel)) {
        return IDialogConstants.IGNORE_ID;
    }

    if (IDialogConstants.PROCEED_LABEL.equals(buttonLabel)) {
        return IDialogConstants.PROCEED_ID;
    }

    if (IDialogConstants.OPEN_LABEL.equals(buttonLabel)) {
        return IDialogConstants.OPEN_ID;
    }

    if (IDialogConstants.CLOSE_LABEL.equals(buttonLabel)) {
        return IDialogConstants.CLOSE_ID;
    }

    if (IDialogConstants.BACK_LABEL.equals(buttonLabel)) {
        return IDialogConstants.BACK_ID;
    }

    if (IDialogConstants.NEXT_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NEXT_ID;
    }

    if (IDialogConstants.FINISH_LABEL.equals(buttonLabel)) {
        return IDialogConstants.FINISH_ID;
    }

    if (IDialogConstants.HELP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.HELP_ID;
    }

    if (IDialogConstants.NO_TO_ALL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NO_TO_ALL_ID;
    }

    if (IDialogConstants.SHOW_DETAILS_LABEL.equals(buttonLabel)) {
        return IDialogConstants.DETAILS_ID;
    }

    if (IDialogConstants.HIDE_DETAILS_LABEL.equals(buttonLabel)) {
        return IDialogConstants.DETAILS_ID;
    }

    for (String providedButton : buttonsMap.keySet()) {
        if (providedButton.equals(buttonLabel)) {
            return buttonsMap.get(providedButton);
        }
    }

    // No XXX_LABEL in IDialogConstants for these. Unlikely
    // they would be used in a message dialog though.
    // public int SELECT_ALL_ID = 18;
    // public int DESELECT_ALL_ID = 19;
    // public int SELECT_TYPES_ID = 20;

    return defaultId;
}

From source file:org.eclipse.sirius.common.ui.tools.api.selection.EMFMessageDialog.java

License:Open Source License

/**
 * Convenience method to open a simple Yes/No question dialog.
 * //from w  ww .  jav  a2s .  c o m
 * @param parent
 *            the parent shell of the dialog, or <code>null</code> if none
 * @param factory
 *            the adapter factory for EMF instances.
 * @param eObjects
 *            the list of EObjects to display.
 * @param title
 *            the dialog's title, or <code>null</code> if none
 * @param message
 *            the message
 * @return <code>true</code> if the user presses the OK button,
 *         <code>false</code> otherwise
 */
public static boolean openQuestionWithEObjects(final Shell parent, final AdapterFactory factory,
        final Collection<EObject> eObjects, final String title, final String message) {
    final MessageDialog dialog = new EMFMessageDialog(parent, factory, eObjects, title, null, // accept
            message, QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // yes
    return dialog.open() == 0;
}

From source file:org.eclipse.sirius.common.ui.tools.api.util.SWTUtil.java

License:Open Source License

/**
 * Show a dialog to ask the user to save or not the content of the Session.
 * The window's return codes can be ISaveablePart2.CANCEL,
 * ISaveablePart2.YES or ISaveablePart2.NO.
 * //from   w  w  w.j  a v a2 s  .c  o  m
 * @param label
 *            the name of the element to save or any other label
 * @param canCancel
 *            <code>true</code> if the save can be cancel,
 *            <code>false</code> otherwise
 * @param stillOpenElsewhere
 *            <code>true</code> the object to save is open elsewhere,
 *            <code>false</code> otherwise
 * @return the return code
 */
private static int showStandardSaveDialog(final String label, final boolean canCancel,
        boolean stillOpenElsewhere) {
    // Step 1: getting the save buttons
    Map<String, Integer> buttons = Maps.newLinkedHashMap();
    buttons.put(IDialogConstants.YES_LABEL, IDialogConstants.YES_ID);
    buttons.put(IDialogConstants.NO_LABEL, IDialogConstants.NO_ID);

    // Step 2 :opening window
    int temporaryResult = openSaveDialog(label, canCancel, buttons, stillOpenElsewhere);

    return temporaryResult;
}