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:com.safi.workshop.sqlexplorer.dbproduct.ConnectionJob.java

License:Open Source License

/**
 * Prompts the user for a new username/password to attempt login with; if the dialog is
 * cancelled then this.user is set to null.
 * //from  www  .  j a v a2 s.c o m
 * @param message
 */
private void promptForPassword(final String message) {
    final Shell shell = SafiWorkshopEditorUtil.getSafiNavigator().getSite().getShell();

    // Switch to the UI thread to run the password dialog, but run it synchronously so we
    // wait for it to complete
    shell.getDisplay().syncExec(new Runnable() {
        public void run() {
            if (message != null) {
                String title = Messages.getString("Progress.Connection.Title") + ' ' + alias.getName();
                if (user != null && !alias.hasNoUserName())
                    title += '/' + user.getUserName();
                if (alias.hasNoUserName()) {
                    MessageDialog dlg = new MessageDialog(shell, title, null,
                            Messages.getString("Progress.Connection.ErrorMessage_Part1") + "\n\n" + message,
                            MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
                    dlg.open();
                    cancelled = true;
                    return;
                } else {
                    MessageDialog dlg = new MessageDialog(shell, title, null,
                            Messages.getString("Progress.Connection.ErrorMessage_Part1") + "\n\n" + message
                                    + "\n\n" + Messages.getString("Progress.Connection.ErrorMessage_Part2"),
                            MessageDialog.ERROR,
                            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
                    boolean retry = dlg.open() == 0;
                    if (!retry) {
                        cancelled = true;
                        return;
                    }
                }
            }

            Shell shell = Display.getCurrent().getActiveShell();
            PasswordConnDlg dlg = new PasswordConnDlg(shell, user.getAlias(), user);
            if (dlg.open() != Window.OK) {
                cancelled = true;
                return;
            }

            // Create a new user and add it to the alias
            User userTmp = new User(dlg.getUserName(), dlg.getPassword());
            userTmp.setAutoCommit(dlg.getAutoCommit());
            userTmp.setCommitOnClose(dlg.getCommitOnClose());
            user = alias.addUser(userTmp);
        }
    });
}

From source file:com.safi.workshop.sqlexplorer.dialogs.SaveOutsideProjectDlg.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
}

From source file:com.salesforce.ide.core.internal.utils.DialogUtils.java

License:Open Source License

public int yesNoMessage(String title, String message, int severity) {
    MessageDialog dialog = new MessageDialog(getShell(), title, null, message, severity,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, IDialogConstants.NO_ID);
    return dialog.open();
}

From source file:com.salesforce.ide.ui.dialogs.HyperLinkMessageDialog.java

License:Open Source License

/**
 * Convenience method to open a simple Yes/No question dialog.
 * /*from  w w  w  . j a  v a 2s.co m*/
 * @param parent
 *            the parent shell of the dialog, or <code>null</code> if none
 * @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 openQuestion(Shell parent, String title, String message) {
    HyperLinkMessageDialog dialog = new HyperLinkMessageDialog(parent, title, null, // accept
            // the
            // default
            // window
            // icon
            message, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // yes is the default
    return dialog.open() == 0;
}

From source file:com.servoy.eclipse.docgenerator.ui.handler.DocumentationGenerationRequestFromUI.java

License:Open Source License

public boolean confirmResourceOverwrite(final IPath path) {
    // If the settings say to not ask for confirmation, then just say yes.
    boolean mustAsk = Activator.getDefault().getPreferenceStore()
            .getBoolean(Activator.ASK_FOR_FILE_OVERWRITE_PREFERENCE);
    if (!mustAsk) {
        return true;
    }/*  w w  w .j a v a  2  s  .  co m*/

    // If the user already clicked "Confirm All" then just say yes.
    if (confirmAll) {
        return true;
    }

    // Ask the user if it's OK to overwrite.
    final boolean choice[] = new boolean[1];
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            MessageDialog dlg = new MessageDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Confirm file overwrite",
                    null,
                    "The following file already exists and will be overwritten: '" + path.toOSString()
                            + "'. Are you sure you want the file to be overwritten?" + "\n\n"
                            + "You can disable this confirmation dialog from the plugin preferences page.",
                    MessageDialog.CONFIRM, new String[] { IDialogConstants.NO_LABEL, IDialogConstants.YES_LABEL,
                            IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL },
                    3);
            int result = dlg.open();
            if (result == 2) // the "Yes to All" button
            {
                confirmAll = true;
            }
            if (result == 3) // the "Cancel" button
            {
                canceled = true;
            }
            choice[0] = result == 1 || result == 2; // The "Yes" or "Yes to All" buttons were pressed.
        }
    });
    return choice[0];
}

From source file:com.simplifide.core.ui.wizard.other.NewFilePage.java

License:Open Source License

/**
 * Creates a new file resource in the selected container and with the
 * selected name. Creates any missing resource containers along the path;
 * does nothing if the container resources already exist.
 * <p>/*from   w  w  w. ja  v a2 s  .  c  om*/
 * In normal usage, this method is invoked after the user has pressed Finish
 * on the wizard; the enablement of the Finish button implies that all
 * controls on on this page currently contain valid values.
 * </p>
 * <p>
 * Note that this page caches the new file once it has been successfully
 * created; subsequent invocations of this method will answer the same file
 * resource without attempting to create it again.
 * </p>
 * <p>
 * This method should be called within a workspace modify operation since it
 * creates resources.
 * </p>
 * 
 * @return the created file resource, or <code>null</code> if the file was
 *         not created
 */
public IFile createNewFile() {
    if (newFile != null) {
        return newFile;
    }

    // create the new file and cache it if successful

    final IPath containerPath = resourceGroup.getContainerFullPath();
    IPath newFilePath = containerPath.append(resourceGroup.getResource());
    final IFile newFileHandle = createFileHandle(newFilePath);
    final InputStream initialContents = getInitialContents();

    createLinkTarget();

    if (linkTargetPath != null) {
        // Not compatible with 3.5
        URI resolvedPath = linkTargetPath;//newFileHandle.getPathVariableManager().resolveURI(linkTargetPath);
        try {
            if (resolvedPath.getScheme() != null && resolvedPath.getSchemeSpecificPart() != null) {
                IFileStore store = EFS.getStore(resolvedPath);
                if (!store.fetchInfo().exists()) {
                    MessageDialog dlg = new MessageDialog(getContainer().getShell(), LINK_TITLE, null,
                            NLS.bind(LINK_NOTSURE, linkTargetPath), MessageDialog.QUESTION_WITH_CANCEL,
                            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                                    IDialogConstants.CANCEL_LABEL },
                            0);
                    int result = dlg.open();
                    if (result == Window.OK) {
                        store.getParent().mkdir(0, new NullProgressMonitor());
                        OutputStream stream = store.openOutputStream(0, new NullProgressMonitor());
                        stream.close();
                    }
                    if (result == 2)
                        return null;
                }
            }
        } catch (CoreException e) {
            MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                    NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                            e.getMessage()),
                    SWT.SHEET);

            return null;
        } catch (IOException e) {
            MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                    NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                            e.getMessage()),
                    SWT.SHEET);

            return null;
        }
    }

    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            CreateFileOperation op = new CreateFileOperation(newFileHandle, linkTargetPath, initialContents,
                    IDEWorkbenchMessages.WizardNewFileCreationPage_title);
            try {
                // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901
                // directly execute the operation so that the undo state is
                // not preserved.  Making this undoable resulted in too many 
                // accidental file deletions.
                op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
            } catch (final ExecutionException e) {
                getContainer().getShell().getDisplay().syncExec(new Runnable() {
                    public void run() {
                        if (e.getCause() instanceof CoreException) {
                            ErrorDialog.openError(getContainer().getShell(), // Was
                                    // Utilities.getFocusShell()
                                    IDEWorkbenchMessages.WizardNewFileCreationPage_errorTitle, null, // no special
                                    // message
                                    ((CoreException) e.getCause()).getStatus());
                        } else {
                            IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getCause()); //$NON-NLS-1$
                            MessageDialog.openError(getContainer().getShell(),
                                    IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                                    NLS.bind(
                                            IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                                            e.getCause().getMessage()));
                        }
                    }
                });
            }
        }
    };
    try {
        getContainer().run(true, true, op);
    } catch (InterruptedException e) {
        return null;
    } catch (InvocationTargetException e) {
        // Execution Exceptions are handled above but we may still get
        // unexpected runtime errors.
        IDEWorkbenchPlugin.log(getClass(), "createNewFile()", e.getTargetException()); //$NON-NLS-1$
        MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
                IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorTitle,
                NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_internalErrorMessage,
                        e.getTargetException().getMessage()),
                SWT.SHEET);

        return null;
    }

    newFile = newFileHandle;

    return newFile;
}

From source file:com.siteview.mde.internal.ui.editor.monitor.MonitorOverviewPage.java

License:Open Source License

private void activateExtensionPages(String activePageId) {
    MessageDialog mdiag = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(),
            MDEUIMessages.OverviewPage_extensionPageMessageTitle, null,
            MDEUIMessages.OverviewPage_extensionPageMessageBody, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    if (mdiag.open() != Window.OK)
        return;/*from  w  w w  . ja v  a 2 s .c  om*/
    try {
        MonitorEditor manifestEditor = (MonitorEditor) getEditor();
        manifestEditor.addExtensionTabs();
        manifestEditor.setShowExtensions(true);
        manifestEditor.setActivePage(activePageId);
    } catch (PartInitException e) {
    } catch (BackingStoreException e) {
    }
}

From source file:com.siteview.mde.internal.ui.editor.monitor.OverviewPage.java

License:Open Source License

private void activateExtensionPages(String activePageId) {
    MessageDialog mdiag = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(),
            MDEUIMessages.OverviewPage_extensionPageMessageTitle, null,
            MDEUIMessages.OverviewPage_extensionPageMessageBody, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    if (mdiag.open() != Window.OK)
        return;//from  w w w .  j a  va  2 s. c  o m
    try {
        MonitorEditor monitorEditor = (MonitorEditor) getEditor();
        monitorEditor.addExtensionTabs();
        monitorEditor.setShowExtensions(true);
        monitorEditor.setActivePage(activePageId);
    } catch (PartInitException e) {
    } catch (BackingStoreException e) {
    }
}

From source file:com.siteview.mde.internal.ui.editor.product.IntroSection.java

License:Open Source License

private void handleNewIntro() {
    boolean needNewProduct = false;
    if (!productDefined()) {
        needNewProduct = true;//from  w ww .j a  v a  2s  .c o m
        MessageDialog mdiag = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(),
                MDEUIMessages.IntroSection_undefinedProductId, null,
                MDEUIMessages.IntroSection_undefinedProductIdMessage, MessageDialog.QUESTION,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        if (mdiag.open() != Window.OK)
            return;
    }
    ProductIntroWizard wizard = new ProductIntroWizard(getProduct(), needNewProduct);
    WizardDialog dialog = new WizardDialog(MDEPlugin.getActiveWorkbenchShell(), wizard);
    dialog.create();
    if (dialog.open() == Window.OK) {
        String id = wizard.getIntroId();
        fIntroCombo.add(id, 0);
        fIntroCombo.setText(id);
        getIntroInfo().setId(id);
        addDependenciesAndPlugins();
    }
}

From source file:com.siteview.mde.internal.ui.launcher.LauncherUtilsStatusHandler.java

License:Open Source License

/**
 * Creates a message dialog using a syncExec in case we are launching in the background.
 * Dialog will be a question dialog with Yes, No and Cancel buttons.
 * @param message Message to use in the dialog
 * @return int representing the button clicked (-1 or 2 for cancel, 0 for yes, 1 for no).
 *///from  w  ww .  j  a  v a 2s . co m
private static Integer generateDialog(final String message) {
    final int[] result = new int[1];
    getDisplay().syncExec(new Runnable() {
        public void run() {
            String title = MDEUIMessages.LauncherUtils_title;
            MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message,
                    MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                            IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                    0);
            result[0] = dialog.open();
        }
    });
    return new Integer(result[0]);
}