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.obeonetwork.dsl.uml2.usage.dialog.UsageDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); }
From source file:org.obeonetwork.dsl.uml2.usage.preferences.UsagePreferences.java
License:Open Source License
/** * Check if the user has answered to the question. * /*from w w w . java 2 s. co m*/ * @return True if answered the question (by yes or no) otherwise false */ public boolean hasAnswered() { if (preferenceStore.getInt(USAGE_USER_ANSWER_ID) == IDialogConstants.YES_ID || (preferenceStore.getInt(USAGE_USER_ANSWER_ID) == IDialogConstants.NO_ID)) { return true; } return false; }
From source file:org.obeonetwork.dsl.uml2.usage.preferences.UsagePreferences.java
License:Open Source License
/** * Store if the user as answer to the question. * //from ww w . j a va2 s .c o m * @param answerId * The answer could be {@link IDialogConstants.YES_ID} if the * user clicked on yes, {@link IDialogConstants.NO_ID} if he * clicked on no or {@link IDialogConstants.OK_ID} if he does not * answered */ public void storeUserAnswer(int answerId) { preferenceStore.setValue(USAGE_USER_ANSWER_ID, answerId); if (answerId == IDialogConstants.YES_ID) preferenceStore.setValue(USAGE_ENABLED_ID, true); if (answerId == IDialogConstants.NO_ID) preferenceStore.setValue(USAGE_ENABLED_ID, false); }
From source file:org.objectstyle.wolips.wizards.NewWOProjectWizard.java
License:Open Source License
/** * Prompts the user for whether to switch perspectives. * /* w w w .java2s .com*/ * @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, false, 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:org.python.pydev.navigator.actions.copied.CopyFilesAndFoldersOperation.java
License:Open Source License
/** * Check if the user wishes to overwrite the supplied resource or all * resources./*from w ww .j a va 2 s . c o m*/ * * @param source * the source resource * @param destination * the resource to be overwritten * @return one of IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, * IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID indicating * whether the current resource or all resources can be overwritten, * or if the operation should be canceled. */ private int checkOverwrite(final IResource source, final IResource destination) { final int[] result = new int[1]; // Dialogs need to be created and opened in the UI thread Runnable query = new Runnable() { public void run() { String message; int resultId[] = { IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID }; String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; if (destination.getType() == IResource.FOLDER) { if (homogenousResources(source, destination)) { message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteMergeQuestion, destination.getFullPath().makeRelative()); } else { if (destination.isLinked()) { message = NLS.bind( IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeLinkQuestion, destination.getFullPath().makeRelative()); } else { message = NLS.bind( IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeNoLinkQuestion, destination.getFullPath().makeRelative()); } resultId = new int[] { IDialogConstants.YES_ID, IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID }; labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; } } else { String[] bindings = new String[] { IDEResourceInfoUtils.getLocationText(destination), IDEResourceInfoUtils.getDateStringValue(destination), IDEResourceInfoUtils.getLocationText(source), IDEResourceInfoUtils.getDateStringValue(source) }; message = NLS.bind( IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteWithDetailsQuestion, bindings); } MessageDialog dialog = new MessageDialog(messageShell, IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceExists, null, message, MessageDialog.QUESTION, labels, 0); dialog.open(); if (dialog.getReturnCode() == SWT.DEFAULT) { // A window close returns SWT.DEFAULT, which has to be // mapped to a cancel result[0] = IDialogConstants.CANCEL_ID; } else { result[0] = resultId[dialog.getReturnCode()]; } } }; messageShell.getDisplay().syncExec(query); return result[0]; }
From source file:org.python.pydev.navigator.actions.copied.CopyFilesAndFoldersOperation.java
License:Open Source License
/** * Returns whether moving all of the given source resources to the given * destination container could be done without causing name collisions. * * @param destination// ww w. j a v a 2 s . c o m * the destination container * @param sourceResources * the list of resources * @return <code>true</code> if there would be no name collisions, and * <code>false</code> if there would */ private IResource[] validateNoNameCollisions(IContainer destination, IResource[] sourceResources) { List<IResource> copyItems = new ArrayList<IResource>(); IWorkspaceRoot workspaceRoot = destination.getWorkspace().getRoot(); int overwrite = IDialogConstants.NO_ID; // Check to see if we would be overwriting a parent folder. // Cancel entire copy operation if we do. for (int i = 0; i < sourceResources.length; i++) { final IResource sourceResource = sourceResources[i]; final IPath destinationPath = destination.getFullPath().append(sourceResource.getName()); final IPath sourcePath = sourceResource.getFullPath(); IResource newResource = workspaceRoot.findMember(destinationPath); if (newResource != null && destinationPath.isPrefixOf(sourcePath)) { displayError(NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteProblem, destinationPath, sourcePath)); canceled = true; return null; } } // Check for overwrite conflicts for (int i = 0; i < sourceResources.length; i++) { final IResource source = sourceResources[i]; final IPath destinationPath = destination.getFullPath().append(source.getName()); IResource newResource = workspaceRoot.findMember(destinationPath); if (newResource != null) { if (overwrite != IDialogConstants.YES_TO_ALL_ID || (newResource.getType() == IResource.FOLDER && homogenousResources(source, destination) == false)) { overwrite = checkOverwrite(source, newResource); } if (overwrite == IDialogConstants.YES_ID || overwrite == IDialogConstants.YES_TO_ALL_ID) { copyItems.add(source); } else if (overwrite == IDialogConstants.CANCEL_ID) { canceled = true; return null; } } else { copyItems.add(source); } } return copyItems.toArray(new IResource[copyItems.size()]); }
From source file:org.roussev.http4e.httpclient.ui.dialog.example.DumbUser.java
License:Apache License
/** * Creates the buttons/*from w w w.j ava 2 s .c om*/ * * @param parent the parent composite */ protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); createButton(parent, I_DUNNO_ID, I_DUNNO_LABEL, false); }
From source file:org.rssowl.ui.internal.actions.AggregateFolderAction.java
License:Open Source License
public void run(IAction action) { if (!fSelection.isEmpty() && fSelection instanceof IStructuredSelection) { Object firstElem = ((IStructuredSelection) fSelection).getFirstElement(); /* Aggregate News of Folder */ if (firstElem instanceof IFolder) { IPreferenceScope preferences = Owl.getPreferenceService().getGlobalScope(); boolean aggregateAsSearch = preferences.getBoolean(DefaultPreferences.AGGREGATE_NEWS_AS_SEARCH); boolean askUserForAggregationOption = !preferences .getBoolean(DefaultPreferences.REMEMBER_AGGREGATE_NEWS_OPTION); /* Ask user for Aggregation Mode if required */ if (askUserForAggregationOption) { AggregateNewsDialog dialog = new AggregateNewsDialog(fTargetPart.getSite().getShell(), ((IFolder) firstElem).getName()); int res = dialog.open(); /* Check for Cancellation */ if (res == IDialogConstants.CANCEL_ID) return; aggregateAsSearch = (res == IDialogConstants.YES_ID); }//from w w w . j a v a 2 s. co m /* Create Search on Folder */ if (aggregateAsSearch) createAndOpenSearch((IFolder) firstElem); /* Otherwise directly aggregate */ else aggregateFolder((IFolder) firstElem); } } }
From source file:org.rssowl.ui.internal.dialogs.AggregateNewsDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { switch (buttonId) { case IDialogConstants.YES_ID: fPreferences.putBoolean(DefaultPreferences.REMEMBER_AGGREGATE_NEWS_OPTION, fRememberDecisionCheck.getSelection()); if (fRememberDecisionCheck.getSelection()) fPreferences.putBoolean(DefaultPreferences.AGGREGATE_NEWS_AS_SEARCH, true); setReturnCode(buttonId);//from w w w. j a va 2s . c o m close(); break; case IDialogConstants.NO_ID: fPreferences.putBoolean(DefaultPreferences.REMEMBER_AGGREGATE_NEWS_OPTION, fRememberDecisionCheck.getSelection()); if (fRememberDecisionCheck.getSelection()) fPreferences.putBoolean(DefaultPreferences.AGGREGATE_NEWS_AS_SEARCH, false); setReturnCode(buttonId); close(); break; } super.buttonPressed(buttonId); }
From source file:org.rssowl.ui.internal.dialogs.AggregateNewsDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); getButton(IDialogConstants.YES_ID).setFocus(); }