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.codecover.eclipse.views.controls.DeleteTSCsConfirmDialog.java

License:Open Source License

DeleteTSCsConfirmDialog(Shell shell, List<TSContainerInfo> selection) {
    super(shell, TITLE, null, MESSAGE, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1);
    this.selection = selection;
    this.setShellStyle(this.getShellStyle() | SWT.RESIZE);
}

From source file:org.codehaus.groovy.eclipse.wizards.ListMessageDialog.java

License:Open Source License

public ListMessageDialog(Shell shell, IProject[] mismatchedProjects) {
    super(shell, TITLE, null, createMessage(mismatchedProjects), QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    this.mismatchedProjects = mismatchedProjects;
}

From source file:org.csstudio.sds.util.SaveAsDialog.java

License:Open Source License

/**
 * {@inheritDoc}//from  w  ww.  j  a va 2s.  c  o  m
 */
protected void okPressed() {
    // Get new path.
    IPath path = _resourceGroup.getContainerFullPath().append(_resourceGroup.getResource());

    // If the user does not supply a file extension and if the save
    // as dialog was provided a default file name append the extension
    // of the default filename to the new name
    if (path.getFileExtension() == null) {
        if (_originalFile != null && _originalFile.getFileExtension() != null) {
            path = path.addFileExtension(_originalFile.getFileExtension());
        } else if (_originalName != null) {
            int pos = _originalName.lastIndexOf('.');
            if (++pos > 0 && pos < _originalName.length()) {
                path = path.addFileExtension(_originalName.substring(pos));
            }
        }
    }

    // If the path already exists then confirm overwrite.
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    if (file.exists()) {
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
        String question = NLS.bind(Messages.SaveAsDialog_OVERWRITE_QUESTION, path.toOSString());
        MessageDialog d = new MessageDialog(getShell(), Messages.SaveAsDialog_QUESTION, null, question,
                MessageDialog.QUESTION, buttons, 0);
        int overwrite = d.open();
        switch (overwrite) {
        case 0: // Yes
            break;
        case 1: // No
            return;
        case 2: // Cancel
        default:
            cancelPressed();
            return;
        }
    }

    // Store path and close.
    _result = path;
    close();
}

From source file:org.csstudio.ui.fx.util.FXMessageDialog.java

License:Open Source License

private static String[] getButtonLabels(DialogType kind) {
    String[] dialogButtonLabels;/*from  w  ww  .j a  va2 s. c  o m*/
    switch (kind) {
    case ERROR:
    case INFORMATION:
    case WARNING:
        dialogButtonLabels = new String[] { trim(IDialogConstants.OK_LABEL) };
        break;
    case CONFIRM:
        dialogButtonLabels = new String[] { trim(IDialogConstants.OK_LABEL),
                trim(IDialogConstants.CANCEL_LABEL) };
        break;
    case QUESTION:
        dialogButtonLabels = new String[] { trim(IDialogConstants.YES_LABEL), trim(IDialogConstants.NO_LABEL) };
        break;
    case QUESTION_WITH_CANCEL:
        dialogButtonLabels = new String[] { trim(IDialogConstants.YES_LABEL), trim(IDialogConstants.NO_LABEL),
                trim(IDialogConstants.CANCEL_LABEL) };
        break;
    default:
        throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
    }
    return dialogButtonLabels;
}

From source file:org.eclipse.ajdt.internal.ui.ajdocexport.AJdocWizard.java

License:Open Source License

private void setAllJavadocLocations(IJavaProject[] projects, URL newURL) {
    Shell shell = getShell();//from  ww  w  . ja  v  a2  s  .c  o m
    Image image = shell == null ? null : shell.getDisplay().getSystemImage(SWT.ICON_QUESTION);
    String[] buttonlabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
            IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL };

    for (int j = 0; j < projects.length; j++) {
        IJavaProject iJavaProject = projects[j];
        //          AspectJ Extension - message
        String message = Messages.format(JavadocExportMessages.JavadocWizard_updatejavadoclocation_message,
                new String[] { iJavaProject.getElementName(), fDestination.toOSString() });
        MessageDialog dialog = new MessageDialog(shell,
                JavadocExportMessages.JavadocWizard_updatejavadocdialog_label, image, message, 4, buttonlabels,
                1);

        switch (dialog.open()) {
        case YES:
            JavaUI.setProjectJavadocLocation(iJavaProject, newURL);
            break;
        case YES_TO_ALL:
            for (int i = j; i < projects.length; i++) {
                iJavaProject = projects[i];
                JavaUI.setProjectJavadocLocation(iJavaProject, newURL);
                j++;
            }
            break;
        case NO_TO_ALL:
            j = projects.length;
            break;
        case NO:
        default:
            break;
        }
    }
}

From source file:org.eclipse.ajdt.internal.ui.preferences.AJCompilerPreferencePage.java

License:Open Source License

@SuppressWarnings("deprecation")
public boolean performOk() {
    if (isProjectPreferencePage()) {
        return projectPerformOK();
    } else {/*  w w  w . j  a v  a2  s  .  c  om*/
        IPreferenceStore store = getPreferenceStore();
        Preferences ajCorePreferences = getAspectJCorePLuginPreferences();

        boolean lintChanges = false;
        for (int i = fComboBoxes.size() - 1; i >= 0; i--) {
            Combo curr = (Combo) fComboBoxes.get(i);
            ControlData data = (ControlData) curr.getData();
            String currValue = data.getValue(curr.getSelectionIndex());
            String storedValue = usesAspectJCorePreferences(curr) ? ajCorePreferences.getString(data.getKey())
                    : store.getString(data.getKey());
            if (!currValue.equals(storedValue)) {
                lintChanges = true;

                if (usesAspectJCorePreferences(curr)) {
                    ajCorePreferences.setValue(data.getKey(), currValue);
                } else {
                    store.setValue(data.getKey(), currValue);
                }
            }
        }

        boolean advancedOrOtherChanges = false;
        for (int i = fCheckBoxes.size() - 1; i >= 0; i--) {
            Button curr = (Button) fCheckBoxes.get(i);

            // has the data changed?
            ControlData data = (ControlData) curr.getData();
            boolean currValue = curr.getSelection();
            boolean storedValue = usesAspectJCorePreferences(curr) ? ajCorePreferences.getBoolean(data.getKey())
                    : store.getBoolean(data.getKey());
            if (currValue != storedValue) {
                // check to see if we should ignore the change in the checkbox
                // change should be ignored if the NO_BUILD_ON_CHANGE flag exists
                if (curr.getData(NO_BUILD_ON_CHANGE) == null) {
                    advancedOrOtherChanges = true;
                }

                // determine where this preference is stored
                if (usesAspectJCorePreferences(curr)) {
                    ajCorePreferences.setValue(data.getKey(), currValue);
                } else {
                    store.setValue(data.getKey(), currValue);
                }
            }
        }

        boolean compilerChanges = false;
        String value = nonStandardOptionsEditor.getStringValue();
        if (!value.equals(store.getString(AspectJPreferences.COMPILER_OPTIONS))) {
            store.setValue(AspectJPreferences.COMPILER_OPTIONS, nonStandardOptionsEditor.getStringValue());
            AJLog.log("Non Standard Compiler properties changed: " //$NON-NLS-1$
                    + store.getString(AspectJPreferences.COMPILER_OPTIONS));
            compilerChanges = true;
        }

        AspectJUIPlugin.getDefault().savePluginPreferences();
        AspectJPlugin.getDefault().savePluginPreferences();

        if (lintChanges || advancedOrOtherChanges || compilerChanges) {
            String[] strings = getFullBuildDialogStrings();
            if (strings != null) {
                MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1],
                        MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                                IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                        2);
                if (isTesting) {
                    dialog.setBlockOnOpen(false);
                }
                int res = dialog.open();
                // simulate user input if we're testing
                if (isTesting) {
                    // choices are "Yes", "No" or "Cancel"
                    dialog.close();
                    if (buildNow) {
                        res = Window.OK;
                    } else {
                        res = Window.CANCEL; // simulating cancel or no being pressed.
                    }
                }
                if (res == 0) {
                    projects = (ResourcesPlugin.getWorkspace().getRoot().getProjects());
                } else if (res != 1) {
                    return false; // cancel pressed
                }
            }
            // PreferencePageBuilder handles building so
            // don't need to do it here
            //            if (doBuild) {
            //               doFullBuild();
            //            }
        }

        return true;
    }
}

From source file:org.eclipse.ajdt.internal.ui.preferences.AJCompilerPreferencePage.java

License:Open Source License

private boolean projectPerformOK() {
    boolean projectSettingsChanged = updateProjectSettings();

    boolean projectWorkspaceChanges = false;
    if (AspectJPreferences.isUsingProjectSettings(getProject()) != useProjectSettings()) {
        projectWorkspaceChanges = true;//from  w  w  w .  j  av  a 2  s . co m
        // don't want to overwrite existing project settings
        // because have just set them in the above call to
        // updateProjectSettings();
        AspectJPreferences.setUsingProjectSettings(getProject(), useProjectSettings(), false);
    }

    AspectJUIPlugin.getDefault().savePluginPreferences();

    if (projectWorkspaceChanges || (projectSettingsChanged && useProjectSettings())) {
        String[] strings = getProjectBuildDialogStrings();
        if (strings != null) {
            MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1],
                    MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                            IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                    2);
            // if we're testing then we don't want to block
            // the dialog on open otherwise we require real user input
            // rather than being able to simulate it
            if (isTesting) {
                dialog.setBlockOnOpen(false);
            }
            int res = dialog.open();
            // simulate user input if we're testing
            if (isTesting) {
                // choices are "Yes", "No" or "Cancel"
                dialog.close();
                if (buildNow) {
                    res = Window.OK;
                } else {
                    res = Window.CANCEL; // simulating cancel or no being pressed.
                }
            }
            if ((res == 0)) {
                // by only setting compilerSettingsUpdated to be true here,
                // means that
                // the user wont select "don't want to build" here and then
                // get a build
                // from other pages.
            } else if (res != 1) {
                return false; // cancel pressed
            }
        }
    }
    return true;
}

From source file:org.eclipse.andmore.android.common.utilities.EclipseUtils.java

License:Apache License

/**
 * Show a question message using the given title and message
 * /*from  w w w.ja va 2  s  .c  o  m*/
 * @param title
 *            of the dialog
 * @param message
 *            to be displayed in the dialog.
 */
public static int showQuestionWithCancelDialog(final String title, final String message) {
    class IntWrapper {
        public int diagReturn = 0;
    }

    final IntWrapper intWrapper = new IntWrapper();
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            IWorkbench workbench = PlatformUI.getWorkbench();
            IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow();
            Shell shell = ww.getShell();
            MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL },
                    0);
            int diagResults = dialog.open();
            switch (diagResults) {
            case 0:
                intWrapper.diagReturn = SWT.YES;
                break;
            case 1:
                intWrapper.diagReturn = SWT.NO;
                break;
            case 2:
            default:
                intWrapper.diagReturn = SWT.CANCEL;
                break;
            }
        }
    });

    return intWrapper.diagReturn;
}

From source file:org.eclipse.andmore.android.common.utilities.EclipseUtils.java

License:Apache License

/**
 * Show a question message using the given title and message
 * /*from w w  w  . java  2  s.co  m*/
 * @param title
 *            of the dialog
 * @param message
 *            to be displayed in the dialog.
 */
public static int showQuestionYesAllCancelDialog(final String title, final String message) {
    class IntWrapper {
        public int diagReturn = 0;
    }

    final IntWrapper intWrapper = new IntWrapper();
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            IWorkbench workbench = PlatformUI.getWorkbench();
            IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow();
            Shell shell = ww.getShell();
            MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                            IDialogConstants.NO_LABEL },
                    0);
            int diagResults = dialog.open();
            switch (diagResults) {
            case 0:
                intWrapper.diagReturn = IDialogConstants.YES_ID;
                break;
            case 1:
                intWrapper.diagReturn = IDialogConstants.YES_TO_ALL_ID;
                break;
            case 2:
            default:
                intWrapper.diagReturn = IDialogConstants.NO_ID;
                break;
            }
        }
    });

    return intWrapper.diagReturn;
}

From source file:org.eclipse.andmore.traceview.editors.TraceviewEditor.java

License:Apache License

@Override
public void doSaveAs() {
    Shell shell = getSite().getShell();//  www .java  2s.c  o  m
    final IEditorInput input = getEditorInput();

    final IEditorInput newInput;

    if (input instanceof FileEditorInput) {
        // the file is part of the current workspace
        FileEditorInput fileEditorInput = (FileEditorInput) input;
        SaveAsDialog dialog = new SaveAsDialog(shell);

        IFile original = fileEditorInput.getFile();
        if (original != null) {
            dialog.setOriginalFile(original);
        }

        dialog.create();

        if (original != null && !original.isAccessible()) {
            String message = String.format("The original file ''%s'' has been deleted or is not accessible.",
                    original.getName());
            dialog.setErrorMessage(null);
            dialog.setMessage(message, IMessageProvider.WARNING);
        }

        if (dialog.open() == Window.CANCEL) {
            return;
        }

        IPath filePath = dialog.getResult();
        if (filePath == null) {
            return;
        }

        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IFile file = workspace.getRoot().getFile(filePath);

        if (copy(shell, fileEditorInput.getURI(), file.getLocationURI()) == null) {
            return;
        }

        try {
            file.refreshLocal(IResource.DEPTH_ZERO, null);
        } catch (CoreException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        newInput = new FileEditorInput(file);
        setInput(newInput);
        setPartName(newInput.getName());
    } else if (input instanceof FileStoreEditorInput) {
        // the file is not part of the current workspace
        FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) input;
        FileDialog dialog = new FileDialog(shell, SWT.SAVE);
        IPath oldPath = URIUtil.toPath(fileStoreEditorInput.getURI());
        if (oldPath != null) {
            dialog.setFileName(oldPath.lastSegment());
            dialog.setFilterPath(oldPath.toOSString());
        }

        String path = dialog.open();
        if (path == null) {
            return;
        }

        // Check whether file exists and if so, confirm overwrite
        final File localFile = new File(path);
        if (localFile.exists()) {
            MessageDialog overwriteDialog = new MessageDialog(shell, "Save As", null,
                    String.format("%s already exists.\nDo you want to replace it?", path),
                    MessageDialog.WARNING,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No'
            // is
            // the
            // default
            if (overwriteDialog.open() != Window.OK) {
                return;
            }
        }

        IFileStore destFileStore = copy(shell, fileStoreEditorInput.getURI(), localFile.toURI());
        if (destFileStore != null) {
            IFile file = getWorkspaceFile(destFileStore);
            if (file != null) {
                newInput = new FileEditorInput(file);
            } else {
                newInput = new FileStoreEditorInput(destFileStore);
            }
            setInput(newInput);
            setPartName(newInput.getName());
        }
    }
}