List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL
String YES_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.
Click Source Link
From source file:org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock.java
License:Open Source License
/** * If there are changed settings, save them and ask user whether to rebuild. * This is called by performOk() and performApply(). * @param container null when called from performApply(). * @return false to abort exiting the preference pane. *//* ww w . ja va 2s .c om*/ protected boolean processChanges(IWorkbenchPreferenceContainer container) { boolean projectSpecificnessChanged = false; boolean isProjectSpecific = (fProject != null) && fBlockControl.getEnabled(); if (fOriginallyHadProjectSettings ^ isProjectSpecific) { // the project-specificness changed. projectSpecificnessChanged = true; } else if ((fProject != null) && !isProjectSpecific) { // no project specific data, and there never was, and this // is a project preferences pane, so nothing could have changed. return true; } if (!projectSpecificnessChanged && !settingsChanged(fLookupOrder[0])) { return true; } int response = 1; // "NO" rebuild unless we put up the dialog. String[] strings = getFullBuildDialogStrings(fProject == null); 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); response = dialog.open(); } if (response == 0 || response == 1) { // "YES" or "NO" - either way, save. saveSettings(); if (container == null) { // we're doing an Apply, so update the reference values. cacheOriginalValues(); } } if (response == 0) { // "YES", rebuild if (container != null) { // build after dialog exits container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } else { // build immediately CoreUtility.getBuildJob(fProject).schedule(); } } else if (response != 1) { // "CANCEL" - no save, no rebuild. return false; } return true; }
From source file:org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<Key> changedOptions = new ArrayList<Key>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { return true; }/*w w w.ja v a 2s . c o m*/ if (needsBuild) { int count = getRebuildCount(); if (count > fRebuildCount) { needsBuild = false; // build already requested fRebuildCount = count; } } boolean doBuild = false; if (needsBuild) { String[] strings = getFullBuildDialogStrings(fProject == null); if (strings != null) { if (ResourcesPlugin.getWorkspace().getRoot().getProjects().length == 0) { doBuild = true; // don't bother the user } else { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } } if (container != null) { // no need to apply the changes to the original store: will be done by the page container if (doBuild) { // post build incrementRebuildCount(); container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { JavaPlugin.log(e); return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:org.eclipse.jdt.internal.ui.preferences.ProblemSeveritiesConfigurationBlock.java
License:Open Source License
@Override protected void validateSettings(Key changedKey, String oldValue, String newValue) { if (!areSettingsEnabled()) { return;//from w w w . ja va2 s .c o m } if (changedKey != null) { if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) || PREF_PB_DEPRECATION.equals(changedKey) || PREF_PB_LOCAL_VARIABLE_HIDING.equals(changedKey) || PREF_15_PB_INCOMPLETE_ENUM_SWITCH.equals(changedKey) || PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey) || PREF_PB_SUPPRESS_WARNINGS.equals(changedKey) || PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey)) { updateEnableStates(); } if (checkValue(PREF_ANNOTATION_NULL_ANALYSIS, ENABLED) && (PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey) || PREF_PB_NULL_REFERENCE.equals(changedKey) || PREF_PB_POTENTIAL_NULL_REFERENCE.equals(changedKey) || PREF_PB_NULL_SPECIFICATION_VIOLATION.equals(changedKey) || PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT.equals(changedKey))) { boolean badNullRef = lessSevere(getValue(PREF_PB_NULL_REFERENCE), getValue(PREF_PB_NULL_SPECIFICATION_VIOLATION)); boolean badPotNullRef = lessSevere(getValue(PREF_PB_POTENTIAL_NULL_REFERENCE), getValue(PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT)); boolean ask = false; ask |= badNullRef && (PREF_PB_NULL_REFERENCE.equals(changedKey) || PREF_PB_NULL_SPECIFICATION_VIOLATION.equals(changedKey)); ask |= badPotNullRef && (PREF_PB_POTENTIAL_NULL_REFERENCE.equals(changedKey) || PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT.equals(changedKey)); ask |= (badNullRef || badPotNullRef) && PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey); if (ask) { final Combo comboBoxNullRef = getComboBox(PREF_PB_NULL_REFERENCE); final Label labelNullRef = fLabels.get(comboBoxNullRef); int highlightNullRef = getHighlight(labelNullRef); final Combo comboBoxPotNullRef = getComboBox(PREF_PB_POTENTIAL_NULL_REFERENCE); final Label labelPotNullRef = fLabels.get(comboBoxPotNullRef); int highlightPotNullRef = getHighlight(labelPotNullRef); getShell().getDisplay().asyncExec(new Runnable() { public void run() { highlight(comboBoxNullRef.getParent(), labelNullRef, comboBoxNullRef, HIGHLIGHT_FOCUS); highlight(comboBoxPotNullRef.getParent(), labelPotNullRef, comboBoxPotNullRef, HIGHLIGHT_FOCUS); } }); MessageDialog messageDialog = new MessageDialog(getShell(), PreferencesMessages.ProblemSeveritiesConfigurationBlock_adapt_null_pointer_access_settings_dialog_title, null, PreferencesMessages.ProblemSeveritiesConfigurationBlock_adapt_null_pointer_access_settings_dialog_message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); messageDialog.create(); Shell messageShell = messageDialog.getShell(); messageShell.setLocation(messageShell.getLocation().x, getShell().getLocation().y + 40); if (messageDialog.open() == 0) { if (badNullRef) { setValue(PREF_PB_NULL_REFERENCE, getValue(PREF_PB_NULL_SPECIFICATION_VIOLATION)); updateCombo(getComboBox(PREF_PB_NULL_REFERENCE)); } if (badPotNullRef) { setValue(PREF_PB_POTENTIAL_NULL_REFERENCE, getValue(PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT)); updateCombo(getComboBox(PREF_PB_POTENTIAL_NULL_REFERENCE)); } } highlight(comboBoxNullRef.getParent(), labelNullRef, comboBoxNullRef, highlightNullRef); highlight(comboBoxPotNullRef.getParent(), labelPotNullRef, comboBoxPotNullRef, highlightPotNullRef); } } else if (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) { // merging the two options setValue(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, newValue); } else if (INTR_DEFAULT_NULL_ANNOTATIONS.equals(changedKey)) { if (ENABLED.equals(newValue)) { setValue(PREF_NULLABLE_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[0]); setValue(PREF_NONNULL_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[1]); setValue(PREF_NONNULL_BY_DEFAULT_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[2]); } else { openNullAnnotationsConfigurationDialog(); } } else { return; } } else { updateEnableStates(); updateNullAnnotationsSetting(); } }
From source file:org.eclipse.jsch.internal.ui.authenticator.WorkbenchUserAuthenticator.java
License:Open Source License
public int prompt(IJSchLocation location, final int promptType, final String title, final String message, final int[] promptResponses, final int defaultResponse) { final Display display = getStandardDisplay(); 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 IUserAuthenticator.OK_ID: buttons[i] = IDialogConstants.OK_LABEL; break; case IUserAuthenticator.CANCEL_ID: buttons[i] = IDialogConstants.CANCEL_LABEL; break; case IUserAuthenticator.NO_ID: buttons[i] = IDialogConstants.NO_LABEL; break; case IUserAuthenticator.YES_ID: buttons[i] = IDialogConstants.YES_LABEL; break; }/*from w ww . j a va 2 s . co m*/ } display.syncExec(new Runnable() { public void run() { final MessageDialog dialog = new MessageDialog(new Shell(display), title, null, message, promptType, buttons, 1); retval[0] = dialog.open(); } }); return retval[0]; }
From source file:org.eclipse.jsch.ui.UserInfoPrompter.java
License:Open Source License
private int prompt(final int promptType, final String title, final String message, final int[] promptResponses, final int defaultResponse) { final Display display = getStandardDisplay(); 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 ww w.ja v a 2 s. co m } display.syncExec(new Runnable() { public void run() { final MessageDialog dialog = new MessageDialog(new Shell(display), title, null /* title image */, message, promptType, buttons, defaultResponse); retval[0] = dialog.open(); } }); return retval[0]; }
From source file:org.eclipse.jst.j2ee.internal.dialogs.ListMessageDialog.java
License:Open Source License
/** * Convenience method to open a simple Yes/No question dialog. * /*from w ww. jav a2 s . c o 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, String[] items) { ListMessageDialog dialog = new ListMessageDialog(parent, title, null, // accept the default // window icon message, QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, items); // yes // is // the // default return dialog.open() == 0; }
From source file:org.eclipse.jubula.client.ui.rcp.properties.ProjectGeneralPropertyPage.java
License:Open Source License
/** * creates and opens a dialog if a search for the deprecated Modules * should be done/*from w w w .j a v a2s.com*/ * @return the boolean if the search should be done */ private boolean openSearchForDeprecatedDialog() { MessageDialog mdiag = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.ProjectPropertyPageSearchForDeprProjModuleTitle, null, Messages.ProjectPropertyPageSearchForDeprProjModuleMsg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); mdiag.create(); Plugin.getHelpSystem().setHelp(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ContextHelpIds.SEARCH_FOR_DEPRECATED_MODULES_DIALOG); return (mdiag.open() == Window.OK); }
From source file:org.eclipse.jubula.client.ui.utils.OpenViewUtils.java
License:Open Source License
/** * /*from ww w . jav a 2s . c om*/ * @param preferenceKey * the key for the preference to save the remembered value to * @param activeWindow * the active {@link IWorkbenchWindow} * @param preferenceStore * the instance of the {@link IPreferenceStore} * @param viewName * the name of the view to activate * @return the return value of the dialog {@link IDialogConstants#NO_ID}, * {@link IDialogConstants#YES_ID} or <code>-1</code> if aborted */ private static int createQuestionDialog(final String preferenceKey, IWorkbenchWindow activeWindow, final IPreferenceStore preferenceStore, String viewName) { MessageDialogWithToggle dialog = new MessageDialogWithToggle(activeWindow.getShell(), Messages.UtilsOpenViewTitle, null, NLS.bind(Messages.UtilsViewQuestion, viewName), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, Messages.UtilsRemember, false) { /** * {@inheritDoc} */ protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); int val = Constants.UTILS_PROMPT; if (getToggleState() && getReturnCode() == IDialogConstants.NO_ID) { val = Constants.UTILS_NO; } else if (getToggleState() && getReturnCode() == IDialogConstants.YES_ID) { val = Constants.UTILS_YES; } preferenceStore.setValue(preferenceKey, val); } }; dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); int i = dialog.open(); return i; }
From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { if (fHasAdditionalPages) createPreviousAndNextButtons(parent); else/*ww w. ja v a 2 s.c o m*/ createPreviewButton(parent); String OK_LABEL = (fHasAdditionalPages) ? IDialogConstants.FINISH_LABEL : IDialogConstants.OK_LABEL; String CANCEL_LABEL = IDialogConstants.CANCEL_LABEL; if (fWizard.internalIsYesNoStyle(InternalAPI.INSTANCE)) { OK_LABEL = IDialogConstants.YES_LABEL; CANCEL_LABEL = IDialogConstants.NO_LABEL; } createButton(parent, IDialogConstants.OK_ID, OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, CANCEL_LABEL, false); Button okButton = getButton(IDialogConstants.OK_ID); okButton.setFocus(); }
From source file:org.eclipse.m2m.internal.qvt.oml.samples.ui.SampleProjectsCreationOperation.java
License:Open Source License
protected IOverwriteQuery createOverwriteQuery(final Shell shell) { return new OverwriteQuery(shell) { @Override//from w w w. ja v a 2 s . c om protected String[] getOptions() { return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }; } @Override protected String[] getReturnCodes() { return new String[] { YES, NO, ALL, CANCEL }; } }; }