Java Code Examples for org.eclipse.jface.dialogs.MessageDialogWithToggle#openYesNoQuestion()
The following examples show how to use
org.eclipse.jface.dialogs.MessageDialogWithToggle#openYesNoQuestion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowAnnotationOperation.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Returns true if the user wishes to always use the live annotate view, false otherwise. * @return */ private boolean promptForQuickDiffAnnotate(){ //check whether we should ask the user. final IPreferenceStore store = SVNUIPlugin.getPlugin().getPreferenceStore(); final String option = store.getString(ISVNUIConstants.PREF_USE_QUICKDIFFANNOTATE); if (option.equals(MessageDialogWithToggle.ALWAYS)) return true; //use live annotate else if (option.equals(MessageDialogWithToggle.NEVER)) return false; //don't use live annotate final MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(Utils.getShell(null), Policy.bind("AnnotateOperation_QDAnnotateTitle"), Policy.bind("AnnotateOperation_QDAnnotateMessage"), Policy.bind("AnnotateOperation_4"), false, store, ISVNUIConstants.PREF_USE_QUICKDIFFANNOTATE); final int result = dialog.getReturnCode(); switch (result) { //yes case IDialogConstants.YES_ID: case IDialogConstants.OK_ID : return true; } return false; }
Example 2
Source File: CommitCommentArea.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public String getCommentWithPrompt(Shell shell) { final String comment= getComment(false); if (comment.length() == 0) { final IPreferenceStore store= SVNUIPlugin.getPlugin().getPreferenceStore(); final String value= store.getString(ISVNUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); if (MessageDialogWithToggle.NEVER.equals(value)) return null; if (MessageDialogWithToggle.PROMPT.equals(value)) { final String title= Policy.bind("CommitCommentArea_2"); final String message= Policy.bind("CommitCommentArea_3"); final String toggleMessage= Policy.bind("CommitCommentArea_4"); final MessageDialogWithToggle dialog= MessageDialogWithToggle.openYesNoQuestion(shell, title, message, toggleMessage, false, store, ISVNUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); if (dialog.getReturnCode() != IDialogConstants.YES_ID) { fTextBox.setFocus(); return null; } } } return getComment(true); }
Example 3
Source File: DialogUtils.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * openIgnoreMessageDialogConfirm * * @param shell * @param title * @param message * @param store * @param key * Key to store the show/hide this message. Message will be hidden if true * @return int */ public static int openIgnoreMessageDialogConfirm(Shell shell, String title, String message, IPreferenceStore store, String key) { String value = store.getString(key); if (!shouldShowDialog(key)) { return value == MessageDialogWithToggle.ALWAYS ? IDialogConstants.YES_ID : IDialogConstants.NO_ID; } MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell, title, message, Messages.DialogUtils_doNotShowMessageAgain, false, store, key); if (dialog.getToggleState()) { setShouldShowDialog(key, false); store.putValue(key, dialog.getReturnCode() == IDialogConstants.YES_ID ? MessageDialogWithToggle.ALWAYS : MessageDialogWithToggle.NEVER); } return dialog.getReturnCode(); }
Example 4
Source File: PyDialogHelpers.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public static boolean openQuestionWithIgnoreToggle(String title, String message, String key) { Shell shell = EditorUtils.getShell(); IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore(); String val = store.getString(key); if (val.trim().length() == 0) { val = MessageDialogWithToggle.PROMPT; //Initial value if not specified } if (!val.equals(MessageDialogWithToggle.ALWAYS)) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell, title, message, "Don't show this message again", false, store, key); if (dialog.getReturnCode() != IDialogConstants.YES_ID) { return false; } } return true; }
Example 5
Source File: AddWordProposal.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * Asks the user whether he wants to configure a user dictionary. * * @param shell the shell * @return <code>true</code> if the user wants to configure the user dictionary * @since 3.3 */ private boolean askUserToConfigureUserDictionary(Shell shell) { MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion( shell, Messages.Spelling_add_askToConfigure_title, Messages.Spelling_add_askToConfigure_question, Messages.Spelling_add_askToConfigure_ignoreMessage, false, null, null); PREF_KEY_PREF_KEY_DO_NOT_ASK.setStoredBoolean(toggleDialog.getToggleState()); return toggleDialog.getReturnCode() == IDialogConstants.YES_ID; }
Example 6
Source File: AbstractValidPreferencePage.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Perform OK button. * * @return true, if successful {@inheritDoc} */ @Override public boolean performOk() { try { if (preferences.needsSaving()) { preferences.save(); } } catch (final IOException e) { LOGGER.error("Unable to save general preference page preferences", e); //$NON-NLS-1$ } boolean preferenceChanged = false; for (final IPreferenceItem item : (IPreferenceItem[]) ((ValidModelTreeContentProvider) treeViewer.getContentProvider()).getElements(null)) { preferenceChanged = preferenceChanged | preferenceChanged(item); } if (preferenceChanged) { final MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(this.getShell(), REVALIDATE_DIALOG_TITLE, REVALIDATE_DIALOG_MESSAGE, EXPENSIVE_CHECKS_TOGGLE_MESSAGE, getPreferenceStore().getBoolean(PERFORM_EXPENSIVE_VALIDATION), null, null); final boolean yesWeCan = (dialog.getReturnCode() == IDialogConstants.YES_ID); final boolean performExpensiveValidations = dialog.getToggleState(); getPreferenceStore().setValue(PERFORM_EXPENSIVE_VALIDATION, dialog.getToggleState()); if (yesWeCan) { final ValidMarkerUpdateJob updateJob = new ValidMarkerUpdateJob(VALIDATION_JOB_MESSAGE, this.fileExtensions, this.resourceSet, this.markerCreator, this.resourceDescriptions, this.resourceServiceProvider, performExpensiveValidations, storage2UriMapper); // The following gets a global lock on all updateJob, no matter what the language is. // The reason is that we want to avoid the update job to consume too much memory, but // we may decide to change that to a lock on a language basis... updateJob.setRule(ResourcesPlugin.getWorkspace().getRoot()); updateJob.schedule(); } } return super.performOk(); }
Example 7
Source File: AbstractNewProjectWizard.java From typescript.java with MIT License | 5 votes |
/** * Prompts the user for whether to switch perspectives. * * @param window * The workbench window in which to switch perspectives; must not * be <code>null</code> * @param finalPersp * The perspective to switch to; must not be <code>null</code>. * * @return <code>true</code> if it's OK to switch, <code>false</code> * otherwise */ private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor finalPersp) { IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); String pspm = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) { // Return whether or not we should always switch return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm); } String desc = finalPersp.getDescription(); String message; if (desc == null || desc.length() == 0) message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel()); else message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessageWithDesc, new String[] { finalPersp.getLabel(), desc }); MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), ResourceMessages.NewProject_perspSwitchTitle, message, null /* use the default message for the toggle */, false /* toggle is initially unchecked */, store, IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); int result = dialog.getReturnCode(); // If we are not going to prompt anymore propogate the choice. if (dialog.getToggleState()) { String preferenceValue; if (result == IDialogConstants.YES_ID) { // Doesn't matter if it is replace or new window // as we are going to use the open perspective setting preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE; } else { preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE; } // update PROJECT_OPEN_NEW_PERSPECTIVE to correspond PrefUtil.getAPIPreferenceStore().setValue(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE, preferenceValue); } return result == IDialogConstants.YES_ID; }
Example 8
Source File: TmfPerspectiveManager.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Returns whether or not the user wishes to switch to the specified * perspective when a launch occurs. * * @param perspectiveName * the name of the perspective that will be presented to the user * for confirmation if they've asked to be prompted about * perspective switching * @param message * a message to be presented to the user. This message is * expected to contain a slot for the perspective name to be * inserted ("{0}"). * @param preferenceKey * the preference key of the perspective switching preference * @return whether or not the user wishes to switch to the specified * perspective automatically */ private boolean shouldSwitchPerspective(IWorkbenchWindow window, String perspectiveId, String preferenceKey) { if (isCurrentPerspective(window, perspectiveId)) { return false; } IPerspectiveDescriptor perspective = PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(perspectiveId); String perspectiveName = (perspective == null) ? null : perspective.getLabel(); if (perspectiveName == null) { return false; } String switchPerspective = Activator.getDefault().getPreferenceStore().getString(preferenceKey); if (MessageDialogWithToggle.ALWAYS.equals(switchPerspective)) { return true; } else if (MessageDialogWithToggle.NEVER.equals(switchPerspective)) { return false; } Shell shell= window.getShell(); if (shell == null || fPrompting) { return false; } fPrompting = true; MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( shell, Messages.TmfPerspectiveManager_SwitchPerspectiveDialogTitle, MessageFormat.format(Messages.TmfPerspectiveManager_SwitchPerspectiveDialogMessage, perspectiveName), null, false, Activator.getDefault().getPreferenceStore(), preferenceKey); boolean answer = (dialog.getReturnCode() == IDialogConstants.YES_ID); synchronized (this) { fPrompting= false; notifyAll(); } if (isCurrentPerspective(window, perspectiveId)) { answer = false; } return answer; }
Example 9
Source File: PerspectiveUtil.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public static void switchToModelingPerspective(IWorkbenchWindow window) { IPreferenceStore prefs = UIPluginActivator.getDefault() .getPreferenceStore(); boolean hide = prefs.getBoolean(AUTO_SWITCH_PERSPECTIVE); IWorkbenchPage page = window.getActivePage(); if (!hide) { IWorkbench workbench = window.getWorkbench(); IPerspectiveRegistry registry = workbench.getPerspectiveRegistry(); IPerspectiveDescriptor descriptor = registry .findPerspectiveWithId(IYakinduSctPerspectives.ID_PERSPECTIVE_SCT_MODELING); if ((page != null) && (page.getPerspective() != descriptor)) { MessageDialogWithToggle dialog = MessageDialogWithToggle .openYesNoQuestion( window.getShell(), "Confirm Perspective Switch", "This kind of editor is associated with the YAKINDU Modeling perspective. Do you want to switch to this perspective now?", "Do not offer to switch perspective in the future", hide, prefs, AUTO_SWITCH_PERSPECTIVE); if (dialog.getReturnCode() == 2) page.setPerspective(descriptor); hide = dialog.getToggleState(); prefs.setValue(AUTO_SWITCH_PERSPECTIVE, hide); try { InstanceScope.INSTANCE.getNode(UIPluginActivator.PLUGIN_ID) .flush(); } catch (BackingStoreException e) { e.printStackTrace(); } } } }
Example 10
Source File: ActionUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean isEditable(Shell shell, IJavaElement element) { if (! isProcessable(shell, element)) return false; IJavaElement cu= element.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null) { IResource resource= cu.getResource(); if (resource != null && resource.isDerived(IResource.CHECK_ANCESTORS)) { // see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#validateEditorInputState() final String warnKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED; IPreferenceStore store= EditorsUI.getPreferenceStore(); if (!store.getBoolean(warnKey)) return true; MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion( shell, ActionMessages.ActionUtil_warning_derived_title, Messages.format(ActionMessages.ActionUtil_warning_derived_message, BasicElementLabels.getPathLabel(resource.getFullPath(), false)), ActionMessages.ActionUtil_warning_derived_dontShowAgain, false, null, null); EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState()); return toggleDialog.getReturnCode() == IDialogConstants.YES_ID; } } return true; }
Example 11
Source File: AddWordProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Asks the user whether he wants to configure a user dictionary. * * @param shell the shell * @return <code>true</code> if the user wants to configure the user dictionary * @since 3.3 */ private boolean askUserToConfigureUserDictionary(Shell shell) { MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion( shell, JavaUIMessages.Spelling_add_askToConfigure_title, JavaUIMessages.Spelling_add_askToConfigure_question, JavaUIMessages.Spelling_add_askToConfigure_ignoreMessage, false, null, null); PreferenceConstants.getPreferenceStore().setValue(PREF_KEY_DO_NOT_ASK, toggleDialog.getToggleState()); return toggleDialog.getReturnCode() == IDialogConstants.YES_ID; }
Example 12
Source File: HostLeftAloneInSessionHandler.java From saros with GNU General Public License v2.0 | 5 votes |
private void handleHostLeftAlone() { String stopSessionPreference = preferenceStore.getString(EclipsePreferenceConstants.AUTO_STOP_EMPTY_SESSION); boolean prompt = MessageDialogWithToggle.PROMPT.equals(stopSessionPreference); boolean stopSession = MessageDialogWithToggle.ALWAYS.equals(stopSessionPreference); if (prompt) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( SWTUtils.getShell(), Messages.HostLeftAloneInSessionDialog_title, Messages.HostLeftAloneInSessionDialog_message, "Remember decision", false, preferenceStore, EclipsePreferenceConstants.AUTO_STOP_EMPTY_SESSION); stopSession = dialog.getReturnCode() == IDialogConstants.YES_ID; } if (stopSession) { SWTUtils.runSafeSWTAsync( log, new Runnable() { @Override public void run() { CollaborationUtils.leaveSession(); } }); } }
Example 13
Source File: CheckstylePropertyPage.java From eclipse-cs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public boolean performOk() { try { IProject project = mProjectConfig.getProject(); // save the edited project configuration if (mProjectConfig.isDirty()) { mProjectConfig.store(); } boolean checkstyleEnabled = mChkEnable.getSelection(); boolean needRebuild = mProjectConfig.isRebuildNeeded(); // check if checkstyle nature has to be configured/deconfigured if (checkstyleEnabled != mCheckstyleInitiallyActivated) { ConfigureDeconfigureNatureJob configOperation = new ConfigureDeconfigureNatureJob(project, CheckstyleNature.NATURE_ID); configOperation.setRule(ResourcesPlugin.getWorkspace().getRoot()); configOperation.schedule(); needRebuild = needRebuild || !mCheckstyleInitiallyActivated; } if (checkstyleEnabled && mProjectConfig.isSyncFormatter()) { TransformCheckstyleRulesJob transFormJob = new TransformCheckstyleRulesJob(project); transFormJob.schedule(); } // if a rebuild is advised, check/prompt if the rebuild should // really be done. if (checkstyleEnabled && needRebuild) { String promptRebuildPref = CheckstyleUIPluginPrefs .getString(CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD); boolean doRebuild = MessageDialogWithToggle.ALWAYS.equals(promptRebuildPref) && needRebuild; // // Prompt for rebuild // if (MessageDialogWithToggle.PROMPT.equals(promptRebuildPref) && needRebuild) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getShell(), Messages.CheckstylePropertyPage_titleRebuild, Messages.CheckstylePropertyPage_msgRebuild, Messages.CheckstylePropertyPage_nagRebuild, false, CheckstyleUIPlugin.getDefault().getPreferenceStore(), CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD); doRebuild = dialog.getReturnCode() == IDialogConstants.YES_ID; } // check if a rebuild is necessary if (checkstyleEnabled && doRebuild) { BuildProjectJob rebuildOperation = new BuildProjectJob(project, IncrementalProjectBuilder.FULL_BUILD); rebuildOperation.setRule(ResourcesPlugin.getWorkspace().getRoot()); rebuildOperation.schedule(); } } } catch (CheckstylePluginException e) { CheckstyleUIPlugin.errorDialog(getShell(), e, true); } return true; }
Example 14
Source File: UpdateCheck.java From cppcheclipse with Apache License 2.0 | 4 votes |
public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(); // if no new version found, just display a dialog if not in silent mode if (newVersion == null) { if (!isSilent) { MessageDialog.openInformation(shell, Messages.UpdateCheck_NoUpdateTitle, Messages.UpdateCheck_NoUpdateMessage); } } else { boolean downloadUpdate = false; // only have toggle switch for update check if silent (not // started from preferences) if (isSilent) { MessageDialogWithToggle msgDialog = MessageDialogWithToggle .openYesNoQuestion(shell, Messages.UpdateCheck_UpdateTitle, Messages.bind( Messages.UpdateCheck_UpdateMessage, newVersion), Messages.UpdateCheck_NeverCheckAgain, false, null, null); IPersistentPreferenceStore configuration = CppcheclipsePlugin .getConfigurationPreferenceStore(); configuration.setValue( IPreferenceConstants.P_USE_AUTOMATIC_UPDATE_CHECK, !msgDialog.getToggleState()); if (msgDialog.getReturnCode() == IDialogConstants.YES_ID) { downloadUpdate = true; } try { configuration.save(); } catch (IOException e1) { CppcheclipsePlugin.logError("Could not save changes for update checks", e1); } } else { downloadUpdate = MessageDialog.openQuestion(shell, Messages.UpdateCheck_UpdateTitle, Messages.bind( Messages.UpdateCheck_UpdateMessage, newVersion)); } if (downloadUpdate) { try { Utils.openUrl(DOWNLOAD_URL); } catch (Exception e) { CppcheclipsePlugin.logError("Could not open cppcheck download page", e); } } } }
Example 15
Source File: CrosstabAdaptUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
public static boolean needRemoveInvaildBindings( CrosstabReportItemHandle handle ) { String preferenceData = PreferenceFactory.getInstance( ) .getPreferences( CrosstabPlugin.getDefault( ) ) .getString( CrosstabPlugin.PREFERENCE_AUTO_DEL_BINDINGS ); if ( preferenceData == null || preferenceData.length( ) == 0 || preferenceData.equals( MessageDialogWithToggle.PROMPT ) ) { MessageDialogWithToggle msgDlg = MessageDialogWithToggle.openYesNoQuestion( UIUtil.getDefaultShell( ), Messages.getString( "DeleteBindingDialog.Title" ), //$NON-NLS-1$ Messages.getString( "DeleteBindingDialog.Message" ), //$NON-NLS-1$ Messages.getString( "DeleteBindingDialog.ToggleMessage" ), //$NON-NLS-1$ false, null, null ); if ( msgDlg.getToggleState( ) ) { String value = ""; if ( msgDlg.getReturnCode( ) == IDialogConstants.YES_ID ) { value = MessageDialogWithToggle.ALWAYS; } else if ( msgDlg.getReturnCode( ) == IDialogConstants.NO_ID ) { value = MessageDialogWithToggle.NEVER; } PreferenceFactory.getInstance( ) .getPreferences( CrosstabPlugin.getDefault( ) ) .setValue( CrosstabPlugin.PREFERENCE_AUTO_DEL_BINDINGS, value ); } if ( msgDlg.getReturnCode( ) == IDialogConstants.YES_ID ) { return true; // removeInvalidBindings( handle ); } else if ( msgDlg.getReturnCode( ) == IDialogConstants.NO_ID ) { return false; // dothing } } else if ( preferenceData != null && preferenceData.equals( MessageDialogWithToggle.ALWAYS ) ) { return true; // removeInvalidBindings( handle ); } return false; // removeInvalidBindings(handle); }