List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:org.eclipse.cdt.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) { 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(); // do a re-index? // container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { CUIPlugin.log(e); return false; } if (doBuild) { // do a re-index? // CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationBlock.java
License:Open Source License
/** * Builds the projects that were reconfigured by the dialog, if any. The user is prompted (if prompting is * not disabled via the preference) before building. The user has the options to build, not build, or * cancel. The result indicates cancellation. * /*from ww w . jav a 2 s.c om*/ * @return <code>true</code> if the user opted to save changes and exit the dialog (with or without * build); <code>false</code> if the user cancelled and the dialog should remain open and unsaved */ public boolean build() { boolean result = true; Collection<IProject> projects = workspace.getProjectsToBuild(); if (!projects.isEmpty()) { int defaultButton = OptionalMessageDialog.getDialogDetail(BUILD_PROMPT_DIALOG_ID); if (defaultButton == OptionalMessageDialog.NO_DETAIL) { defaultButton = BUILD_PROMPT_DIALOG_YES; // yes button is the default-default } int button = OptionalMessageDialog.open(BUILD_PROMPT_DIALOG_ID, contents.getShell(), WorkingSetMessages.WSConfigDialog_buildPrompt_title, null, WorkingSetMessages.WSConfigDialog_buildPrompt_message, MessageDialog.QUESTION, new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL, IDialogConstants.YES_LABEL }, defaultButton); if (button == OptionalMessageDialog.NOT_SHOWN) { // handle the case where the dialog was suppressed. Get the current default button = defaultButton; } else if (button != BUILD_PROMPT_DIALOG_CANCEL) { // store non-cancel selection as the new default answer OptionalMessageDialog.setDialogDetail(BUILD_PROMPT_DIALOG_ID, button); } switch (button) { case BUILD_PROMPT_DIALOG_YES: // do the build new BuildJob(projects).schedule(); break; case BUILD_PROMPT_DIALOG_NO: // just don't build break; default: // BUILD_PROMPT_DIALOG_CANCEL result = false; break; } } return result; }
From source file:org.eclipse.cdt.launch.internal.ui.BuildErrPrompter.java
License:Open Source License
/** * Source is an array of three things, in the following order * <ul>//from w ww . j a va2 s .com * <li>launch configuration that was invoked * <li>the name of the project the launch first attempted to build * <li>the name of the build configuration that was built, or empty string * if it was the active one. This argument should be non-empty ONLY if a * not-active configuration was built. * <ul> * * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, * java.lang.Object) */ @Override public Object handleStatus(IStatus status, Object source) throws CoreException { if (!(source instanceof Object[])) { assert false : "status handler not given expected arguments"; //$NON-NLS-1$ return Boolean.TRUE; } Object[] args = (Object[]) source; if (args.length != 3 || !(args[0] instanceof ILaunchConfiguration) || !(args[1] instanceof String) || !(args[2] instanceof String)) { assert false : "status handler not given expected arguments"; //$NON-NLS-1$ return Boolean.TRUE; } final ILaunchConfiguration launchConfig = (ILaunchConfiguration) args[0]; final String projectName = (String) args[1]; final String buildConfigName = (String) args[2]; // The platform does this check; we should, too if (DebugUITools.isPrivate(launchConfig)) { return Boolean.TRUE; } Shell shell = DebugUIPlugin.getShell(); String title = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_0; String message; if (status.getCode() == STATUS_CODE_ERR_IN_MAIN_PROJ) { if (buildConfigName.length() > 0) { message = MessageFormat.format(LaunchMessages.BuildErrPrompter_error_in_specific_config, projectName, buildConfigName); } else { message = MessageFormat.format(LaunchMessages.BuildErrPrompter_error_in_active_config, projectName); } } else if (status.getCode() == STATUS_CODE_ERR_IN_REFERENCED_PROJS) { if (buildConfigName.length() > 0) { message = MessageFormat.format(LaunchMessages.BuildErrPrompter_error_in_referenced_project_specific, projectName, buildConfigName); } else { message = MessageFormat.format(LaunchMessages.BuildErrPrompter_error_in_referenced_project_active, projectName); } } else { assert false : "this prompter was called for an unexpected status"; //$NON-NLS-1$ return Boolean.TRUE; } // The rest is monkey-see, monkey-do (copied from // CompileErrorProjectPromptStatusHandler) IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return Boolean.TRUE; } } MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.PROCEED_LABEL, IDialogConstants.CANCEL_LABEL }, 0, LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_1, false); int open = dialog.open(); if (open == IDialogConstants.PROCEED_ID) { if (dialog.getToggleState()) { store.setValue(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, MessageDialogWithToggle.ALWAYS); } return Boolean.TRUE; } else { return Boolean.FALSE; } }
From source file:org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil.java
License:Open Source License
/** * Overwrite Make Target dialog./*from w ww .j av a 2 s . com*/ * * @param name - name of make target to display to a user. * @param shell - shell where to display the dialog. * * @return user's answer. */ private static int overwriteMakeTargetDialog(String name, Shell shell) { if (lastUserAnswer == IDialogConstants.YES_TO_ALL_ID || lastUserAnswer == IDialogConstants.NO_TO_ALL_ID || lastUserAnswer == RENAME_TO_ALL_ID) { return lastUserAnswer; } String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, MakeUIPlugin.getResourceString("MakeTargetDnD.button.rename"), //$NON-NLS-1$ IDialogConstants.CANCEL_LABEL, }; String title = MakeUIPlugin.getResourceString("MakeTargetDnD.title.overwriteTargetConfirm"); //$NON-NLS-1$ String question = MessageFormat.format( MakeUIPlugin.getResourceString("MakeTargetDnD.message.overwriteTargetConfirm"), //$NON-NLS-1$ new Object[] { name }); String toggleApplyToAll = MakeUIPlugin.getResourceString("MakeTargetDnD.toggle.applyToAll"); //$NON-NLS-1$ MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, question, MessageDialog.QUESTION, labels, 0, toggleApplyToAll, false); try { dialog.open(); lastUserAnswer = dialog.getReturnCode(); boolean toAll = dialog.getToggleState(); if (toAll && lastUserAnswer == IDialogConstants.YES_ID) { lastUserAnswer = IDialogConstants.YES_TO_ALL_ID; } else if (toAll && lastUserAnswer == IDialogConstants.NO_ID) { lastUserAnswer = IDialogConstants.NO_TO_ALL_ID; } else if (toAll && lastUserAnswer == RENAME_ID) { lastUserAnswer = RENAME_TO_ALL_ID; } } catch (SWTException e) { MakeUIPlugin.log(e); lastUserAnswer = IDialogConstants.CANCEL_ID; } if (lastUserAnswer == SWT.DEFAULT) { // A window close returns SWT.DEFAULT, which has to be // mapped to a cancel lastUserAnswer = IDialogConstants.CANCEL_ID; } return lastUserAnswer; }
From source file:org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryOptionsBlock.java
License:Open Source License
/** * @return true - OK to continue/*from w w w. j a v a2 s. c o m*/ */ public boolean checkDialogForChanges() { boolean rc = true; if (isProfileDifferentThenPersisted()) { String title = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_TITLE); String message = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_MESSAGE); String[] buttonLabels = new String[] { MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BSAVE), MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BCANCEL), }; MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0); int res = dialog.open(); if (res == 0) { // OK callPerformApply(); rc = true; } else if (res == 1) { // CANCEL rc = false; } } return rc; }
From source file:org.eclipse.cdt.ui.newui.AbstractPage.java
License:Open Source License
private void rebuildIndex() { final Shell shell = getShell(); final String title = getTitle(); final String msg = Messages.AbstractPage_rebuildIndex_question; int result = OptionalMessageDialog.open(PREF_ASK_REINDEX, shell, title, null /* default image */, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (result == OptionalMessageDialog.NOT_SHOWN) { result = OptionalMessageDialog.getDialogDetail(PREF_ASK_REINDEX); } else if (result != SWT.DEFAULT) { OptionalMessageDialog.setDialogDetail(PREF_ASK_REINDEX, result); }/* www . j ava 2 s .co m*/ if (result == 0) { // first button final IProject project = getProject(); CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(project)); } }
From source file:org.eclipse.compare.codereview.compareEditor.RefacContentMergeViewer.java
License:Open Source License
/** * This method is called from the <code>Viewer</code> method <code>inputChanged</code> * to save any unsaved changes of the old input. * <p>//from w ww . j a v a 2 s . c o m * The <code>ContentMergeViewer</code> implementation of this * method calls <code>saveContent(...)</code>. If confirmation has been turned on * with <code>setConfirmSave(true)</code>, a confirmation alert is posted before saving. * </p> * Clients can override this method and are free to decide whether * they want to call the inherited method. * @param newInput the new input of this viewer, or <code>null</code> if there is no new input * @param oldInput the old input element, or <code>null</code> if there was previously no input * @return <code>true</code> if saving was successful, or if the user didn't want to save (by pressing 'NO' in the confirmation dialog). * @since 2.0 */ protected boolean doSave(Object newInput, Object oldInput) { // before setting the new input we have to save the old if (isLeftDirty() || isRightDirty()) { if (Utilities.RUNNING_TESTS) { if (Utilities.TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE) { flushContent(oldInput, null); } } else if (fConfirmSave) { // post alert Shell shell = fComposite.getShell(); MessageDialog dialog = new MessageDialog(shell, Utilities.getString(getResourceBundle(), "saveDialog.title"), //$NON-NLS-1$ null, // accept the default window icon Utilities.getString(getResourceBundle(), "saveDialog.message"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, }, 0); // default button index switch (dialog.open()) { // open returns index of pressed button case 0: flushContent(oldInput, null); break; case 1: setLeftDirty(false); setRightDirty(false); break; case 2: throw new ViewerSwitchingCancelled(); } } else flushContent(oldInput, null); return true; } return false; }
From source file:org.eclipse.compare.codereview.compareEditor.RefacContentMergeViewer.java
License:Open Source License
/** * Handle a change to the given input reported from an {@link org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener}. * This class registers a listener with its input and reports any change events through * this method. By default, this method prompts for any unsaved changes and then refreshes * the viewer. Subclasses may override./*from w w w . j a v a2 s. c om*/ * @since 3.3 */ protected void handleCompareInputChange() { // before setting the new input we have to save the old Object input = getInput(); if (!isSaving() && (isLeftDirty() || isRightDirty())) { if (Utilities.RUNNING_TESTS) { if (Utilities.TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE) { flushContent(input, null); } } else { // post alert Shell shell = fComposite.getShell(); MessageDialog dialog = new MessageDialog(shell, CompareMessages.ContentMergeViewer_resource_changed_title, null, // accept the default window icon CompareMessages.ContentMergeViewer_resource_changed_description, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, // 0 IDialogConstants.NO_LABEL, // 1 }, 0); // default button index switch (dialog.open()) { // open returns index of pressed button case 0: flushContent(input, null); break; case 1: setLeftDirty(false); setRightDirty(false); break; } } } if (isSaving() && (isLeftDirty() || isRightDirty())) { return; // Do not refresh until saving both sides is complete } refresh(); }
From source file:org.eclipse.contribution.visualiser.internal.preference.VisualiserPreferencePage.java
License:Open Source License
/** * Called when the user presses OK. Updates the Visualiser with the * selections chosen./*from www. j a v a2 s .c o m*/ * * @see PreferencePage#performOk() */ public boolean performOk() { if (super.performOk()) { ProviderDefinition[] definitions = ProviderManager.getAllProviderDefinitions(); for (int i = 0; i < definitions.length; i++) { boolean checked = checkboxViewer.getChecked(definitions[i]); if (definitions[i].isEnabled() != checked) { definitions[i].setEnabled(checked); } } String rname = styleList.getSelection()[0]; VisualiserPreferences.setRendererName(rname); String pname = colourList.getSelection()[0]; ProviderDefinition def = ProviderManager.getCurrent(); String defp = PaletteManager.getDefaultForProvider(def).getName(); if (PaletteManager.getPaletteByName(pname).getPalette() instanceof PatternVisualiserPalette) { // Using Patterns if (stripeHeight.getSelection() < VisualiserPreferences.getDefaultPatternStripeHeight() && !VisualiserPreferences.getUsePatterns() && !VisualiserPreferences.getDontAutoIncreaseStripeHeight()) { if (VisualiserPreferences.getDoAutoIncreaseStripeHeight()) { VisualiserPreferences .setStripeHeight(VisualiserPreferences.getDefaultPatternStripeHeight()); } else { MessageDialogWithToggle toggleDialog = new MessageDialogWithToggle(null, VisualiserMessages.VisualiserPreferencePage_stripeSizeDialog_title, null, VisualiserMessages.VisualiserPreferencePage_stripeSizeDialog_message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, VisualiserMessages.VisualiserPreferencePage_stripeSizeDialog_togglemessage, VisualiserPreferences.getDoAutoIncreaseStripeHeight()); if (toggleDialog.getReturnCode() == 0) { // Yes pressed VisualiserPreferences.setDoIncreaseStripeHeight(toggleDialog.getToggleState()); VisualiserPreferences .setStripeHeight(VisualiserPreferences.getDefaultPatternStripeHeight()); } else // No pressed VisualiserPreferences.setDontIncreaseStripeHeight(toggleDialog.getToggleState()); } } else VisualiserPreferences.setStripeHeight(stripeHeight.getSelection()); VisualiserPreferences.setBarWidth(prefWidth.getSelection()); VisualiserPreferences.setUsePatterns(true); String pid = PaletteManager.getPaletteByName(pname).getID(); VisualiserPreferences.setPaletteIDForProvider(def, pid); } else { // Not using patterns VisualiserPreferences.setStripeHeight(stripeHeight.getSelection()); VisualiserPreferences.setBarWidth(prefWidth.getSelection()); VisualiserPreferences.setUsePatterns(false); if (defp.equals(pname)) { // going with provider defintion, clear preference setting VisualiserPreferences.setPaletteIDForProvider(def, ""); //$NON-NLS-1$ } else { // update preference setting for this provider String pid = PaletteManager.getPaletteByName(pname).getID(); VisualiserPreferences.setPaletteIDForProvider(def, pid); } } PaletteManager.resetCurrent(); IMarkupProvider markupP = ProviderManager.getMarkupProvider(); if (markupP instanceof SimpleMarkupProvider) { ((SimpleMarkupProvider) markupP).resetColours(); } // if the Visualiser is showing, update to use the new settings if (VisualiserPlugin.visualiser != null) { if (VisualiserPlugin.menu != null) { VisualiserPlugin.menu.setVisMarkupProvider(markupP); } VisualiserPlugin.visualiser.updateDisplay(true); } return true; } return false; }
From source file:org.eclipse.datatools.enablement.sybase.asa.schemaobjecteditor.examples.routineeditor.ProceduralObjectEditorHandler.java
License:Open Source License
public Object getAdapter(Class adapter) { if (adapter == SQLEditor.class) { return getSQLEditor(); } else if (IContentOutlinePage.class.equals(adapter)) { IEditorPart editor = getSQLEditor(); if (editor != null) { _outlinePage = (SQLOutlinePage) editor.getAdapter(adapter); _fOutlineSelectionChangedListener.install(_outlinePage); return _outlinePage; }/*from w w w . j a va 2s. c o m*/ } else if (IRoutineEditorDocumentProvider.class.equals(adapter)) { return new RoutineFormDocumentProviderAdapter() { public void refreshFromDatabase(Object element, IControlConnection controlCon, ProcIdentifier proc) throws CoreException, SQLException { if (_editor == null) { return; } if (_editor.isDirty()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog d = new MessageDialog(ExamplePlugin.getActiveWorkbenchShell(), Messages.ProceduralObjectEditorHandler_refresh_editor, null, Messages.ProceduralObjectEditorHandler_refresh_q, MessageDialog.QUESTION, buttons, 0); int result = d.open(); switch (result) { case IDialogConstants.CANCEL_ID: return; default: break; } } RefreshSchemaEditorJob refreshJob = new RefreshSchemaEditorJob( Messages.ProceduralObjectEditorHandler_refresh, ProceduralObjectEditorHandler.this); refreshJob.setUser(true); refreshJob.schedule(); } }; } return super.getAdapter(adapter); }