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:org.eclipse.cdt.internal.ui.editor.CEditor.java
License:Open Source License
private void updateScalabilityMode(IEditorInput input) { int lines = getDocumentProvider().getDocument(input).getNumberOfLines(); boolean wasEnabled = fEnableScalablilityMode; fEnableScalablilityMode = lines > getPreferenceStore() .getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES); if (fEnableScalablilityMode && !wasEnabled) { // Alert users that scalability mode should be turned on if (getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_ALERT)) { MessageDialogWithToggle dialog = new MessageDialogWithToggle(Display.getCurrent().getActiveShell(), CEditorMessages.Scalability_info, null, CEditorMessages.Scalability_message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, CEditorMessages.Scalability_reappear, false) { {/* ww w.ja va 2s . c om*/ setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS | SWT.ON_TOP | getDefaultOrientation()); } @Override protected void buttonPressed(int buttonId) { PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT, !getToggleState()); super.buttonPressed(buttonId); if (buttonId == IDialogConstants.YES_ID) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getCurrent().getActiveShell(), "org.eclipse.cdt.ui.preferences.CScalabilityPreferences", null, null); //$NON-NLS-1$ dialog.open(); } } }; dialog.setBlockOnOpen(false); dialog.open(); } } }
From source file:org.eclipse.cdt.internal.ui.text.spelling.AddWordProposal.java
License:Open Source License
/** * Asks the user whether he wants to configure * a user dictionary.//from w ww . j a v a 2 s . co m * * @param shell * @return <code>true</code> if the user wants to configure the user dictionary */ 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); PreferenceConstants.getPreferenceStore().setValue(PREF_KEY_DO_NOT_ASK, toggleDialog.getToggleState()); return toggleDialog.getReturnCode() == IDialogConstants.YES_ID; }
From source file:org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil.java
License:Open Source License
/** * Perform action of copying or moving or dropping make targets to specified * container. This action displays a progress bar if user copies more than 1 * target.// w w w.j a va2 s. c o m * * @param makeTargets - array of make targets to copy. * @param container - where to copy the selection. * @param operation - copying operation. Should be one of * {@link org.eclipse.swt.dnd.DND} operations. * @param shell - shell to display a progress bar. * * @see DND#DROP_NONE * @see DND#DROP_COPY * @see DND#DROP_MOVE * @see DND#DROP_LINK * @see DND#DROP_DEFAULT */ public static void copyTargets(IMakeTarget[] makeTargets, IContainer container, int operation, Shell shell) { if (makeTargets == null || makeTargets.length == 0 || container == null) { return; } lastUserAnswer = IDialogConstants.YES_ID; if (makeTargets.length == 1) { try { // Do not slow down generating modal window for a single target copyOneTarget(makeTargets[0], container, operation, shell, false); } catch (CoreException e) { // log any problem then ignore it MakeUIPlugin.log(e); } } else if (makeTargets.length > 1) { copyTargetsWithProgressIndicator(makeTargets, container, operation, shell); } }
From source file:org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil.java
License:Open Source License
/** * Copy/move one make target to the specified container. * * @param makeTarget - make target.// w w w . j av a 2s.com * @param container - container to copy/move to. * @param operation - copying operation. Should be one of * {@link org.eclipse.swt.dnd.DND} operations. * @param shell - shell to display user warnings. * @param offerOverwriteDialog - whether overwrite dialog is provided. * @throws CoreException on the failure of {@link IMakeTargetManager} or * {@link IMakeTarget} operation. * * @see DND#DROP_NONE * @see DND#DROP_COPY * @see DND#DROP_MOVE * @see DND#DROP_LINK * @see DND#DROP_DEFAULT */ public static void copyOneTarget(IMakeTarget makeTarget, IContainer container, final int operation, Shell shell, boolean offerOverwriteDialog) throws CoreException { IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager(); IMakeTarget exists = makeTargetManager.findTarget(container, makeTarget.getName()); if (exists != null) { int userAnswer = IDialogConstants.CANCEL_ID; if (offerOverwriteDialog) { userAnswer = overwriteMakeTargetDialog(makeTarget.getName(), shell); } else { userAnswer = RENAME_ID; } if (userAnswer == IDialogConstants.YES_ID || userAnswer == IDialogConstants.YES_TO_ALL_ID) { copyTargetData(makeTarget, exists); if (operation == DND.DROP_MOVE) { makeTargetManager.removeTarget(makeTarget); } } else if (userAnswer == RENAME_ID || userAnswer == RENAME_TO_ALL_ID) { String name = generateUniqueName(makeTarget.getName(), container); IMakeTarget newMakeTarget = cloneTarget(name, makeTarget, container.getProject()); newMakeTarget.setContainer(container); int dialogReturnCode = Window.OK; if (userAnswer == RENAME_ID) { MakeTargetDialog dialog; try { dialog = new MakeTargetDialog(shell, newMakeTarget); dialogReturnCode = dialog.open(); } catch (CoreException e) { MakeUIPlugin.errorDialog(shell, MakeUIPlugin.getResourceString("AddBuildTargetAction.exception.internal"), //$NON-NLS-1$ e.toString(), e); } } else if (userAnswer == RENAME_TO_ALL_ID) { makeTargetManager.addTarget(container, newMakeTarget); } if (operation == DND.DROP_MOVE && dialogReturnCode != Window.CANCEL) { makeTargetManager.removeTarget(makeTarget); } } } else { makeTargetManager.addTarget(container, cloneTarget(makeTarget.getName(), makeTarget, container.getProject())); if (operation == DND.DROP_MOVE) { makeTargetManager.removeTarget(makeTarget); } } }
From source file:org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil.java
License:Open Source License
/** * Copy/move make targets to a given container. Displays progress bar. * * @param makeTargets - array of make targets to copy. * @param container - container to copy/move to. * @param operation - copying operation. Should be one of * {@link org.eclipse.swt.dnd.DND} operations. * @param shell - shell to display a progress bar. * * @see DND#DROP_NONE// w ww . jav a2 s . c o m * @see DND#DROP_COPY * @see DND#DROP_MOVE * @see DND#DROP_LINK * @see DND#DROP_DEFAULT * */ private static void copyTargetsWithProgressIndicator(final IMakeTarget[] makeTargets, final IContainer container, final int operation, final Shell shell) { IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { boolean isMove = operation == DND.DROP_MOVE; String textHeader = isMove ? MakeUIPlugin.getResourceString("MakeTargetDnD.moving") //$NON-NLS-1$ : MakeUIPlugin.getResourceString("MakeTargetDnD.copying"); //$NON-NLS-1$ String textAction = isMove ? MakeUIPlugin.getResourceString("MakeTargetDnD.moving.one") //$NON-NLS-1$ : MakeUIPlugin.getResourceString("MakeTargetDnD.copying.one"); //$NON-NLS-1$ monitor.beginTask(textHeader + ' ' + container.getName(), makeTargets.length - 1); for (IMakeTarget makeTarget : makeTargets) { if (makeTarget != null) { monitor.subTask(textAction + ' ' + makeTarget.getName()); try { copyOneTarget(makeTarget, container, operation, shell, true); } catch (CoreException e) { // log failures but ignore all targets which failed MakeUIPlugin.log(e); } if (lastUserAnswer == IDialogConstants.CANCEL_ID) { break; } } monitor.worked(1); if (monitor.isCanceled()) { break; } } monitor.done(); lastUserAnswer = IDialogConstants.YES_ID; } }; IRunnableContext context = new ProgressMonitorDialog(shell); try { context.run(false, true, runnable); } catch (InvocationTargetException e) { MakeUIPlugin.log(e); } catch (InterruptedException e) { MakeUIPlugin.log(e); } }
From source file:org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil.java
License:Open Source License
/** * Overwrite Make Target dialog./* w w w . j av a 2 s .c o m*/ * * @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.ui.testplugin.util.VerifyDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { _yesButton = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); _noButton = createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); }
From source file:org.eclipse.contribution.jdt.preferences.WeavingStateConfigurerUI.java
License:Open Source License
/** * must be run from UI thread// w w w .j av a2 s . co m */ public boolean ask() { EnableWeavingDialog dialog = new EnableWeavingDialog(); dialog.open(); JDTWeavingPreferences.setAskToEnableWeaving(!dialog.getToggleState()); if (IDialogConstants.YES_ID == dialog.getReturnCode()) { changeWeavingState(); return true; } else { return false; } }
From source file:org.eclipse.datatools.sqltools.sqleditor.internal.editor.SQLUpdater.java
License:Open Source License
/** * Enable syntax validation based on preference options and user's selection. * /* ww w . jav a2 s. c o m*/ * @return true means syntax validation is enabled. * @author lihuang */ private boolean enableSyntaxValidation() { if (_editor != null && _editor.getConnectionInfo() != null) { ISQLEditorConnectionInfo connInfo = _editor.getConnectionInfo(); SQLDevToolsConfiguration conf = SQLToolsFacade.getConfiguration(_editor.getDatabaseIdentifier(), connInfo.getDatabaseVendorDefinitionId()); SQLParser p = conf.getSQLService().getSQLParser(); if (p == null || !p.isComplete()) { return false; } } IPreferenceStore preferenceStore = SQLEditorPlugin.getDefault().getPreferenceStore(); boolean enableSyntaxValidation = true; boolean isMaxLineLimitation = preferenceStore.getBoolean(PreferenceConstants.SYNTAX_VALIDATION_MAX_LINE); // just return false if syntax validation is turned off. if (preferenceStore.getBoolean(PreferenceConstants.SYNTAX_VALIDATION) == false) { enableSyntaxValidation = false; } else if (isMaxLineLimitation) { // show prompt dialog when the number of lines is more than maximun number of lines. int lines = ((SQLEditor) _editor).getSV().getDocument().getNumberOfLines(); int maximunLines = Integer .parseInt(preferenceStore.getString(PreferenceConstants.SYNTAX_VALIDATION_MAX_LINE_NUMBER)); if (preferenceStore.getBoolean(PreferenceConstants.SHOW_DAILOG_FOR_SYNTAX_VALIDATION) == true) { if (lines >= maximunLines) { Shell shell = SQLEditorPlugin.getActiveWorkbenchShell(); // Activate the shell if necessary so the prompt is visible if (shell.getMinimized()) { shell.setMinimized(false); } MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell, SQLEditorResources.SQLUpdate_dialog_title, NLS.bind(SQLEditorResources.SQLUpdate_dialog_message, (new Object[] { Integer.toString(maximunLines) })), SQLEditorResources.SQLUpdate_dialog_toggle, false, SQLEditorPlugin.getDefault().getPreferenceStore(), PreferenceConstants.SHOW_DAILOG_FOR_SYNTAX_VALIDATION); if (dialog.getReturnCode() == IDialogConstants.YES_ID) { enableSyntaxValidation = false; } else if (dialog.getReturnCode() == IDialogConstants.NO_ID && preferenceStore.getString(PreferenceConstants.SHOW_DAILOG_FOR_SYNTAX_VALIDATION) .equals(MessageDialogWithToggle.NEVER)) { enableSyntaxValidation = true; preferenceStore.setValue(PreferenceConstants.SYNTAX_VALIDATION_MAX_LINE, false); } else { enableSyntaxValidation = true; } } } else { if (lines >= maximunLines) { enableSyntaxValidation = false; } else { enableSyntaxValidation = true; } } } if (enableSyntaxValidation == false) { if (_fOutlinePage != null) { _fOutlinePage.update(null); } if (_annotationModel != null) { removeMarkers(); } return false; } else { return true; } }
From source file:org.eclipse.debug.internal.ui.actions.breakpoints.RemoveAllBreakpointsAction.java
License:Open Source License
public void run(IAction action) { final IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); final IBreakpoint[] breakpoints = breakpointManager.getBreakpoints(); if (breakpoints.length < 1) { return;// www. j a va2s. c o m } IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow(); if (window == null) { return; } IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); boolean prompt = store.getBoolean(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_ALL_BREAKPOINTS); boolean proceed = true; if (prompt) { MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), ActionMessages.RemoveAllBreakpointsAction_0, ActionMessages.RemoveAllBreakpointsAction_1, ActionMessages.RemoveAllBreakpointsAction_3, !prompt, null, null); if (mdwt.getReturnCode() != IDialogConstants.YES_ID) { proceed = false; } else { store.setValue(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_ALL_BREAKPOINTS, !mdwt.getToggleState()); } } if (proceed) { new Job(ActionMessages.RemoveAllBreakpointsAction_2) { protected IStatus run(IProgressMonitor monitor) { try { DebugUITools.deleteBreakpoints(breakpoints, fShell, monitor); } catch (CoreException e) { DebugUIPlugin.log(e); return Status.CANCEL_STATUS; } return Status.OK_STATUS; } }.schedule(); } }