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.tigris.subversion.subclipse.ui.util.SimpleDialogsHelper.java

License:Open Source License

public boolean promptYesNo(String title, String question, boolean yesIsDefault) {
    MessageDialogRunnable mdr = new MessageDialogRunnable(null, title, null, question, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, yesIsDefault ? 0 : 1);
    SVNUIPlugin.getStandardDisplay().syncExec(mdr);
    return mdr.getResult() == 0;
}

From source file:org.tigris.subversion.subclipse.ui.util.SimpleDialogsHelper.java

License:Open Source License

public boolean promptYesCancel(String title, String question, boolean yesIsDefault) {
    MessageDialogRunnable mdr = new MessageDialogRunnable(null, title, null, question, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, yesIsDefault ? 0 : 1);
    SVNUIPlugin.getStandardDisplay().syncExec(mdr);
    return mdr.getResult() == 0;
}

From source file:org.tigris.subversion.subclipse.ui.wizards.generatediff.GenerateDiffFileWizard.java

License:Open Source License

/**
 * Completes processing of the wizard. If this method returns <code>
 * true</code>, the wizard will close; otherwise, it will stay active.
 *//*from ww  w .  j  a v a 2 s. c  om*/
public boolean performFinish() {
    String fs = mainPage.getFilesystemFile();
    IFile ws = mainPage.getWorkspaceFile();
    int type = mainPage.getSaveType();
    boolean eclipseFormat = optionsPage.isMultiPatch();
    boolean projectRelative = optionsPage.isProjectRelative();

    try {
        if (type != mainPage.CLIPBOARD) {
            File file = new File(fs != null ? fs : ws.getLocation().toOSString());
            if (file.exists()) {
                // prompt then delete
                String title = Policy.bind("GenerateSVNDiff.overwriteTitle"); //$NON-NLS-1$
                String msg = Policy.bind("GenerateSVNDiff.overwriteMsg"); //$NON-NLS-1$
                final MessageDialog dialog = new MessageDialog(getShell(), title, null, msg,
                        MessageDialog.QUESTION,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0);

                dialog.open();

                if (dialog.getReturnCode() != 0) {
                    // cancel
                    return false;
                }
            }
            GenerateDiffFileOperation generateDiffFileOperation = new GenerateDiffFileOperation(getResources(),
                    getUnaddedResources(), file, false, false, eclipseFormat, projectRelative, getShell());
            generateDiffFileOperation.setSelectedResources(selectedResources);
            getContainer().run(true, true, generateDiffFileOperation);
            if (type == mainPage.WORKSPACE) {
                ws.getParent().refreshLocal(IResource.DEPTH_ONE, null);
            }
        } else {
            GenerateDiffFileOperation generateDiffFileOperation = new GenerateDiffFileOperation(getResources(),
                    getUnaddedResources(), null, true, false, eclipseFormat, projectRelative, getShell());
            generateDiffFileOperation.setSelectedResources(selectedResources);
            getContainer().run(true, true, generateDiffFileOperation);
        }
        return true;
    } catch (InterruptedException e1) {
        return true;
    } catch (CoreException e) {
        SVNUIPlugin.openError(getShell(), Policy.bind("GenerateSVNDiff.error"), null, e); //$NON-NLS-1$
        return false;
    } catch (InvocationTargetException e2) {
        SVNUIPlugin.openError(getShell(), Policy.bind("GenerateSVNDiff.error"), null, e2); //$NON-NLS-1$
        return false;
    }
}

From source file:org.wesnoth.ui.editor.WMLEditor.java

License:Open Source License

@Override
protected void performSaveAs(IProgressMonitor progressMonitor) {

    Shell shell = getSite().getShell();/*from ww w.j a  v a  2 s . co  m*/
    final IEditorInput input = getEditorInput();

    // Customize save as if the file is linked, and it is in the special
    // external link project
    //
    if (input instanceof IFileEditorInput && ((IFileEditorInput) input).getFile().isLinked()
            && ((IFileEditorInput) input).getFile().getProject().getName().equals(AUTOLINK_PROJECT_NAME)) {
        final IEditorInput newInput;
        IDocumentProvider provider = getDocumentProvider();

        FileDialog dialog = new FileDialog(shell, SWT.SAVE);
        IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI());
        if (oldPath != null) {
            dialog.setFileName(oldPath.lastSegment());
            dialog.setFilterPath(oldPath.toOSString());
        }

        dialog.setFilterExtensions(new String[] { "*.b3", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
        String path = dialog.open();
        if (path == null) {
            if (progressMonitor != null) {
                progressMonitor.setCanceled(true);
            }
            return;
        }

        // Check whether file exists and if so, confirm overwrite
        final File localFile = new File(path);
        if (localFile.exists()) {
            MessageDialog overwriteDialog = new MessageDialog(shell, Messages.WMLEditor_0, null,
                    path + Messages.WMLEditor_1, MessageDialog.WARNING,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the
                                                                                                                                                                                                                                         // default
            if (overwriteDialog.open() != Window.OK) {
                if (progressMonitor != null) {
                    progressMonitor.setCanceled(true);
                    return;
                }
            }
        }

        IFileStore fileStore;
        try {
            fileStore = EFS.getStore(localFile.toURI());
        } catch (CoreException ex) {
            Logger.getInstance().logException(ex);
            String title = Messages.WMLEditor_2;
            String msg = Messages.WMLEditor_3 + ex.getMessage();
            MessageDialog.openError(shell, title, msg);
            return;
        }

        IFile file = getWorkspaceFile(fileStore);
        if (file != null) {
            newInput = new FileEditorInput(file);
        } else {
            IURIEditorInput uriInput = new FileStoreEditorInput(fileStore);
            java.net.URI uri = uriInput.getURI();
            IFile linkedFile = obtainLink(uri);

            newInput = new FileEditorInput(linkedFile);
        }

        if (provider == null) {
            // editor has programmatically been closed while the dialog was
            // open
            return;
        }

        boolean success = false;
        try {

            provider.aboutToChange(newInput);
            provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true);
            success = true;

        } catch (CoreException x) {
            Logger.getInstance().logException(x);
            final IStatus status = x.getStatus();
            if (status == null || status.getSeverity() != IStatus.CANCEL) {
                String title = Messages.WMLEditor_4;
                String msg = Messages.WMLEditor_5 + x.getMessage();
                MessageDialog.openError(shell, title, msg);
            }
        } finally {
            provider.changed(newInput);
            if (success) {
                setInput(newInput);
            }
        }

        if (progressMonitor != null) {
            progressMonitor.setCanceled(!success);
        }

        return;
    }

    super.performSaveAs(progressMonitor);
}

From source file:org.wso2.developerstudio.eclipse.platform.ui.dialogs.TrustCertificateDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
    createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    createButton(parent, TEMP_ALLOW_ID, "Allow this once", false);
}

From source file:org.xmind.cathy.internal.CathyWorkbenchAdvisor.java

License:Open Source License

private int promptToSaveOnClose(IWorkbenchWindow window, IWorkbenchPage page, IEditorPart editor) {
    if (editor instanceof ISaveablePart2) {
        int answer = ((ISaveablePart2) editor).promptToSaveOnClose();
        if (answer != ISaveablePart2.DEFAULT)
            return answer;
    }//w  w w.  j  a va2  s  .  com
    page.activate(editor);
    MessageDialog dialog = new MessageDialog(window.getShell(), DialogMessages.Save_title, null,
            NLS.bind(WorkbenchMessages.PromptSaveEditorOnClosing_message, editor.getTitle()),
            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0);
    int answerIndex = dialog.open();
    switch (answerIndex) {
    case 0:
        return ISaveablePart2.YES;
    case 1:
        return ISaveablePart2.NO;
    default:
        return ISaveablePart2.CANCEL;
    }
}

From source file:org.xwalk.ide.eclipse.xdt.wizards.export.ExportProjectWizard.java

License:Apache License

private void showDialog() {
    MessageDialog dialog = new MessageDialog(getShell(), "Export Error", null,
            "Android SDK or Crosswalk path have not been set correctly.  Go on setting it now?", 1,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    switch (dialog.open()) {
    case 0:/*from   w  ww.ja va2s. c o m*/
        showQuickPreferenceDialog();
        break;
    case 1:
        break;
    }
}

From source file:org2.eclipse.php.internal.debug.core.launching.PHPLaunchUtilities.java

License:Open Source License

/**
 * Returns true in case a first line breakpoint should hit on a JIT remote sessions that have no reference in the
 * launch view. This method will prompt the user in case the option is set in the Debug preferences.
 * /*from  w ww. j a v a 2  s  .c  om*/
 * @param remoteIP
 *            A remote IP to display when displaying the message.
 * @return True, if a JIT first line breakpoint should be set; False, otherwise.
 * @since Aptana PHP 1.1
 */
public static boolean shouldBreakOnJitFirstLine(final String remoteIP) {
    final IPreferenceStore store = PHPDebugEPLPlugin.getDefault().getPreferenceStore();
    String option = store.getString(IPHPDebugCorePreferenceKeys.BREAK_ON_FIRST_LINE_FOR_UNKNOWN_JIT);
    if (MessageDialogWithToggle.ALWAYS.equals(option)) {
        return true;
    } else if (MessageDialogWithToggle.PROMPT.equals(option)) {
        final DialogResultHolder resultHolder = new DialogResultHolder();
        Display.getDefault().syncExec(new Runnable() {
            public void run() {
                Shell shell = getActiveShell();
                MessageDialogWithToggle dialog = new PHPLaunchUtilities.BlinkingMessageDialogWithToggle(shell,
                        PHPDebugCoreMessages.Debugger_incomingDebuggerJitRequestTitle, null,
                        NLS.bind(PHPDebugCoreMessages.Debugger_incomingDebuggerJitRequest,
                                new Object[] { remoteIP }),
                        MessageDialogWithToggle.QUESTION,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0,
                        PHPDebugCoreMessages.PHPLaunchUtilities_rememberDecision, false);
                dialog.setPrefStore(store);
                dialog.setPrefKey(IPHPDebugCorePreferenceKeys.BREAK_ON_FIRST_LINE_FOR_UNKNOWN_JIT);
                dialog.open();

                resultHolder.setReturnCode(dialog.getReturnCode());
            }

        });

        if (resultHolder.getReturnCode() == IDialogConstants.YES_ID) {
            return true;
        }
    }
    return false;
}

From source file:sernet.verinice.rcp.InfoDialogWithShowToggle.java

License:Open Source License

public static InfoDialogWithShowToggle openYesNoCancelQuestion(Shell parent, String title, String message,
        String toggleMessage, IPreferenceStore store, String key) {
    InfoDialogWithShowToggle dialog = new InfoDialogWithShowToggle(parent, title, null, // accept the default window icon
            message, QUESTION_WITH_CANCEL,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0, // YES_LABEL is the default (first entry of array)
            toggleMessage, false);// w ww.ja  v a  2 s  .  c  o m
    dialog.setPrefStore(store);
    dialog.setPrefKey(key);
    boolean open = true;
    if (dialog.getPrefStore() != null && dialog.getPrefKey() != null
            && dialog.getPrefStore().contains(dialog.getPrefKey())) {
        open = !dialog.getPrefStore().getBoolean(dialog.getPrefKey());
    }
    if (open) {
        dialog.open();
    } else {
        dialog.setReturnCode(IDialogConstants.YES_ID);
    }
    return dialog;
}

From source file:spritey.ui.wizards.SpriteSheetWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    isOverwrite = saveAsPage.isOverwrite();

    OverwriteQuery callback = new OverwriteQuery() {
        @Override//from   www .j a v a  2 s.c  om
        public int queryOverwrite(String path) {
            if (isOverwrite) {
                return OverwriteQuery.ALL;
            }

            String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL };

            File file = new File(path);
            String message = NLS.bind(Messages.SAVE_AS_OVERWRITE_FILE, file.getName(), file.getParent());
            final MessageDialog dialog = new MessageDialog(getShell(), Messages.SPRITE_SHEET_WIZARD_TITLE, null,
                    message, MessageDialog.QUESTION, buttons, 0) {
                @Override
                protected int getShellStyle() {
                    return super.getShellStyle() | SWT.SHEET;
                }
            };

            // This method is called from a non-UI thread, therefore,
            // opening dialog has to be wrapped into runnable and executed
            // in the UI thread.
            getShell().getDisplay().syncExec(new Runnable() {
                @Override
                public void run() {
                    dialog.open();
                }
            });
            return dialog.getReturnCode();
        }
    };

    try {
        SaveSheetOperation op = new SaveSheetOperation(newSheetPage.getConstraints(), newSheetPage.getSheet(),
                saveAsPage.getImageFile(), saveAsPage.getMetadataFile(), callback);
        getContainer().run(true, true, op);

        Shell parent = getContainer().getShell();
        IStatus status = op.getStatus();

        if (!status.isOK()) {
            // To make dialogs consistent throughout the application,
            // display a custom error dialog with details button only when
            // there are multiple problems. Otherwise display an OS native
            // dialog.
            if (status.isMultiStatus()) {
                ErrorDialog.openError(parent, Messages.SPRITE_SHEET_WIZARD_TITLE, null, status);
            } else {
                MessageDialog.open(MessageDialog.ERROR, parent, Messages.SPRITE_SHEET_WIZARD_TITLE,
                        status.getMessage(), SWT.SHEET);
            }
        } else {
            MessageDialog.open(MessageDialog.INFORMATION, parent, Messages.SPRITE_SHEET_WIZARD_TITLE,
                    Messages.SPRITE_SHEET_WIZARD_BUILT_SUCCESSFULLY, SWT.SHEET);
        }
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        throw new InternalError("Error occurred during save operation.", e);
    }
    return false;
}