List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_ID
int YES_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_ID.
Click Source Link
From source file:eclipse.testframework.ui.util.VerifyDialog.java
License:Open Source License
protected void buttonPressed(int buttonId) { if (IDialogConstants.YES_ID == buttonId) { setReturnCode(IDialogConstants.YES_ID); if (_testDialog.getShell() != null) { _testDialog.close();//ww w . j av a2 s .co m } close(); } else if (IDialogConstants.NO_ID == buttonId) { handleFailure(); } }
From source file:eu.geclipse.ui.wizards.NewGridProjectWizard.java
License:Open Source License
private void switchPerspective() { final IWorkbench workBench = Activator.getDefault().getWorkbench(); Display display = workBench.getDisplay(); display.asyncExec(new Runnable() { public void run() { IWorkbenchPage page = null;/* ww w .j a v a 2s .c om*/ IWorkbenchWindow window = workBench.getActiveWorkbenchWindow(); if (window != null) { page = window.getActivePage(); if (page != null) { IPreferenceStore ps = Activator.getDefault().getPreferenceStore(); String newPerspectiveId = ps.getString(PerspectivePreferencePage.KEY_DEFAULT_PERSPECTIVE); if (newPerspectiveId == null) { return; } IPerspectiveDescriptor perspectiveDescriptor = page.getPerspective(); if (perspectiveDescriptor != null && !perspectiveDescriptor.getId().equals(newPerspectiveId)) { //check if we are in one of g-Eclipse perspectives if (perspectiveDescriptor.getId().equals(Activator.ID_USER_PERSPECTIVE) || perspectiveDescriptor.getId().equals(Activator.ID_OPERATOR_PERSPECTIVE) || perspectiveDescriptor.getId().equals(Activator.ID_DEVELOPER_PERSPECTIVE)) { //check if it is allowed to switch from g-Eclipse perspective if (ps.getBoolean( PerspectivePreferencePage.KEY_NOT_SWITCH_FROM_GECLIPSE_PERSPECTIVE)) { return; } } try { String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ String message = Messages .getString("NewGridProjectWizard.PerspectiveSwitchingInfo_line1"); //$NON-NLS-1$ message += newLine + newLine; message += Messages .getString("NewGridProjectWizard.PerspectiveSwitchingInfo_line2"); //$NON-NLS-1$ message += newLine + newLine; message += Messages .getString("NewGridProjectWizard.PerspectiveSwitchingInfo_line3"); //$NON-NLS-1$ String toggleMessage = Messages.getString("NewGridProjectWizard.RememberQuestion"); //$NON-NLS-1$ String ask = ps.getString(PerspectivePreferencePage.KEY_REMEMBER_SWITCHING); if (MessageDialogWithToggle.NEVER.equalsIgnoreCase(ask)) { return; } if (MessageDialogWithToggle.ALWAYS.equalsIgnoreCase(ask) || MessageDialogWithToggle .openYesNoQuestion(window.getShell(), Messages.getString( "NewGridProjectWizard.ConfirmPerpectiveSwitch"), //$NON-NLS-1$ message, toggleMessage, false, ps, PerspectivePreferencePage.KEY_REMEMBER_SWITCHING) .getReturnCode() == IDialogConstants.YES_ID) { String pId = ps.getString(PerspectivePreferencePage.KEY_DEFAULT_PERSPECTIVE); window.getWorkbench().showPerspective(pId, window); } } catch (Exception e) { Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.getString("NewGridProjectWizard.PerspectiveSwitchingError"), //$NON-NLS-1$ e); ErrorDialog.openError(window.getShell(), Messages.getString("NewGridProjectWizard.PerspectiveSwitchingError"), //$NON-NLS-1$ Messages.getString("NewGridProjectWizard.ManualPerspectiveSwitching"), //$NON-NLS-1$ status); } } } } } }); }
From source file:eu.modelwriter.marker.command.AddRemoveTypeHandler.java
License:Open Source License
private void addRemoveType() { if (!MarkerPage.isParsed()) { final MessageDialog parseCtrlDialog = new MessageDialog(MarkerActivator.getShell(), "Type Information", null,//from w w w . j a v a2 s .c o m "You dont have any marker type registered to system! \n" + "Please parse an alloy file first", MessageDialog.INFORMATION, new String[] { "OK" }, 0); parseCtrlDialog.open(); return; } final ActionSelectionDialog actionSelectionDialog = new ActionSelectionDialog(MarkerActivator.getShell()); actionSelectionDialog.open(); if (actionSelectionDialog.getReturnCode() == IDialogConstants.CANCEL_ID) { return; } if (selectedMarker != null && selectedMarker.exists()) { findCandidateToTypeChangingMarkers(selectedMarker); if (actionSelectionDialog.getReturnCode() == IDialogConstants.YES_ID) { addType(selectedMarker); } else if (actionSelectionDialog.getReturnCode() == IDialogConstants.NO_ID) { final MessageDialog warningDialog = new MessageDialog(MarkerActivator.getShell(), "Warning!", null, "If you remove marker's type, all relations of this marker has been removed! Do you want to continue to remove marker's type?", MessageDialog.WARNING, new String[] { "Yes", "No" }, 0); final int returnCode = warningDialog.open(); if (returnCode != 0) { return; } removeType(selectedMarker); } // MarkerUpdater.updateTargets(selectedMarker); // MarkerUpdater.updateSources(selectedMarker); } else { final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "There is no marker in this position", null, "Please select valid marker", MessageDialog.INFORMATION, new String[] { "Ok" }, 0); dialog.open(); return; } }
From source file:eu.modelwriter.marker.ui.internal.views.visualizationview.commands.AddRemoveTypeCommand.java
License:Open Source License
private void addRemoveType() { if (!MarkerPage.isParsed()) { final MessageDialog parseCtrlDialog = new MessageDialog(Activator.getShell(), "Type Information", null, "You dont have any marker type registered to system! \n" + "Please parse an alloy file first", MessageDialog.INFORMATION, new String[] { "OK" }, 0); parseCtrlDialog.open();//from w ww . j a v a 2 s .c o m return; } final ActionSelectionDialog actionSelectionDialog = new ActionSelectionDialog(Activator.getShell()); actionSelectionDialog.open(); if (actionSelectionDialog.getReturnCode() == IDialogConstants.CANCEL_ID) { return; } IMarker selectedMarker = this.marker; selectedMarker = MarkUtilities.getLeaderOfMarker(selectedMarker); if (selectedMarker != null && selectedMarker.exists()) { this.findCandidateToTypeChangingMarkers(selectedMarker); if (actionSelectionDialog.getReturnCode() == IDialogConstants.YES_ID) { AddRemoveTypeCommand.addType(selectedMarker); } else if (actionSelectionDialog.getReturnCode() == IDialogConstants.NO_ID) { final MessageDialog warningDialog = new MessageDialog(Activator.getShell(), "Warning!", null, "If you remove marker's type, all relations of this marker has been removed! Do you want to continue to remove marker's type?", MessageDialog.WARNING, new String[] { "YES", "NO" }, 0); final int returnCode = warningDialog.open(); if (returnCode != 0) { return; } this.removeType(selectedMarker); } } else { final MessageDialog dialog = new MessageDialog(Activator.getShell(), "There is no marker in this position", null, "Please select valid marker", MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); return; } }
From source file:ext.org.eclipse.jdt.internal.ui.actions.ActionUtil.java
License:Open Source License
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; }// w w w . jav a 2 s .c om } return true; }
From source file:ext.org.eclipse.jdt.internal.ui.text.spelling.AddWordProposal.java
License:Open Source License
/** * Asks the user whether he wants to configure a user dictionary. * //from w w w . ja v a 2s. c o m * @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; }
From source file:gov.redhawk.ide.spd.internal.ui.editor.wizard.OpenAssociatedPerspectiveJob.java
License:Open Source License
/** * {@inheritDoc}//from w ww . j a v a2 s . c o m */ @Override public IStatus runInUIThread(final IProgressMonitor monitor) { final String perspectiveId = this.descriptor.getAssociatedPerspectiveId(); if (perspectiveId != null && !perspectiveId.isEmpty()) { final IPreferenceStore store = ComponentUiPlugin.getDefault().getPreferenceStore(); final String pref = store.getString(this.descriptor.getId()); if (pref.equals(MessageDialogWithToggle.PROMPT)) { final MessageDialogWithToggle dialog = this.createDialog(); final int result = dialog.open(); this.updatePreferences(this.descriptor.getId(), result, dialog.getToggleState()); if (result == IDialogConstants.YES_ID) { this.changePerspective(); } } else if (pref.equals(MessageDialogWithToggle.ALWAYS)) { this.changePerspective(); } } return Status.OK_STATUS; }
From source file:gov.redhawk.ide.spd.internal.ui.editor.wizard.OpenAssociatedPerspectiveJob.java
License:Open Source License
/** * Updates the preference with the specified value. * /* www . j a va 2 s. c om*/ * @param key the key to update * @param value the value to associate with the preference * @param save whether to update the preference with the specified value */ private void updatePreferences(final String key, final int value, final boolean save) { if (save) { final IPreferenceStore store = ComponentUiPlugin.getDefault().getPreferenceStore(); if (value == IDialogConstants.YES_ID) { store.setValue(key, MessageDialogWithToggle.ALWAYS); } else { store.setValue(key, MessageDialogWithToggle.NEVER); } } }
From source file:me.dollyn.goide.ui.wizards.NewGoProjectWizard.java
License:Open Source License
/** * Prompts the user for whether to switch perspectives. * //from w w w .j a va 2 s . c om * @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( org.eclipse.ui.internal.wizards.newresource.ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel()); else message = NLS.bind( org.eclipse.ui.internal.wizards.newresource.ResourceMessages.NewProject_perspSwitchMessageWithDesc, new String[] { finalPersp.getLabel(), desc }); MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), org.eclipse.ui.internal.wizards.newresource.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; }
From source file:net.bioclipse.bioinformatics.ciba.Activator.java
License:Open Source License
/** * This is the hook that will veto any shutdown events if the user wants to keep Bioclipse * open while the processes are running. *//* w w w. ja v a 2 s .c o m*/ @Override public boolean preShutdown(IWorkbench workbench, boolean forced) { // TODO: This is wrong for preference access. Fix. Preferences preferences = CibaPreferences.getStore(); // Activator act = getDefault(); // ScopedPreferenceStore preferences = (ScopedPreferenceStore) act.getPreferenceStore(); String existingPreference = preferences.get(CibaPreferences.CONTINUE_PROCS_POST_CLOSE, "default-didn't exist"); System.out.println("Existing: " + existingPreference); // If the user wishes to always continue the executing process post-close, then just return // true and exit the SW. if (existingPreference.equals(MessageDialogWithToggle.ALWAYS)) { return true; } // Or else, promt the user MessageDialogWithToggle mdt = MessageDialogWithToggle.openYesNoQuestion( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Background Process", "There are currently CIBA Processes running in the background.\nExiting now will stop all processes.\n\nDo you wish to exit now?", "Always allow processes to continue after exit (not recommended)", false, null, CibaPreferences.CONTINUE_PROCS_POST_CLOSE); int retCode = mdt.getReturnCode(); boolean toggleState = mdt.getToggleState(); /* * * STORE A NEW BOOLEAN USING preferences.setValue("different.string.for.key.", true); * AS THE CHECKED/UNCHECKED STATUS OF THE BOXba * */ System.out.println("Toggle State: " + toggleState); // The user wishes to continue letting Bioclipse close, AND let the processes run in // the background. if (toggleState && (retCode == IDialogConstants.YES_ID)) { CibaPreferences.save(); } return retCode == IDialogConstants.YES_ID; }