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

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

Introduction

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

Prototype

String NO_LABEL

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

Click Source Link

Document

The label for no buttons.

Usage

From source file:org.eclipse.rcptt.ui.launching.aut.AUTConnectionErrorDialog.java

License:Open Source License

private static String[] getDialogButtonsLabels(boolean showLogFile) {
    if (showLogFile) {
        return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
    }// w  w  w. ja va2s .com
    return new String[] { IDialogConstants.OK_LABEL };
}

From source file:org.eclipse.rcptt.ui.panels.main.ControlPanelWindow.java

License:Open Source License

private void save() {
    try {//from  w w  w  . j a v  a 2s  .co  m
        ITestCase model = getModel();
        NullProgressMonitor monitor = new NullProgressMonitor();
        if (model.exists()) {
            model = (ITestCase) model.getWorkingCopy(monitor);
            copyContent(scenario, (Scenario) model.getNamedElement());
            WriteAccessChecker writeAccessChecker = new WriteAccessChecker(getShell());

            try {
                if (!writeAccessChecker.makeResourceWritable(model)) {
                    return;
                }
                model.commitWorkingCopy(true, monitor);
            } catch (CoreException e) {
                Q7UIPlugin.log(e);
            } finally {
                model.discardWorkingCopy();
            }
            contextsTable.setProject(getSavedProject());
            verificationsTable.setProject(getSavedProject());
            copyContent((Scenario) model.getNamedElement(), this.scenario);
        } else {
            MessageDialog dialog = new MessageDialog(getShell(), Messages.ControlPanelWindow_SaveDialogTitle,
                    null, "Failed to save testcase because underlying resources is not exist.",
                    MessageDialog.ERROR, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL },
                    0);
            int value = dialog.open(); // Number of pressed button
            if (value == 0) {
                saveAs();
            }
        }
    } catch (ModelException e) {
        Q7UIPlugin.log(e);
    }
}

From source file:org.eclipse.rcptt.ui.panels.main.ControlPanelWindow.java

License:Open Source License

private boolean openSaveDialog() {
    if (getModel() != null && !getModel().exists()) {
        return true;
    }/* w  w  w .j a v a2  s  .  co m*/
    MessageDialog dialog = new MessageDialog(getShell(), Messages.ControlPanelWindow_SaveDialogTitle, null,
            Messages.ControlPanelWindow_SaveDialogMsg, MessageDialog.QUESTION_WITH_CANCEL, new String[] {
                    IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0);
    int returnCode = dialog.open(); // Number of pressed button
    if (returnCode == 0) {
        if (getModel() != null) {
            save();
        } else {
            if (!saveAs()) {
                return false;
            }
        }
    }
    switch (returnCode) {
    case 2:
        return false; // User clicked Cancel button
    default:
        return true;
    }
}

From source file:org.eclipse.rcptt.ui.resources.wizards.WizardFileSystemResourceImportPage1.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.
 * //w  w w.  j a  va  2s.c o 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(
                org.eclipse.ui.internal.ide.IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString);
    } else {
        messageString = NLS.bind(
                org.eclipse.ui.internal.ide.IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
                path.lastSegment(), path.removeLastSegments(1).toOSString());
    }

    final MessageDialog dialog = new MessageDialog(getContainer().getShell(),
            org.eclipse.ui.internal.ide.IDEWorkbenchMessages.Question, 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.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.
 * /*w  ww . j av  a  2s  .c o 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  .  java2s .com*/
    }

    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 ww  .ja  va  2 s. 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/*  www .j  av a 2 s.c  o m*/
 */
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();// www  .j  a v  a 2  s  .  co m

    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 getNoLabel() {
    return IDialogConstants.NO_LABEL;
}