List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_ID
int NO_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_ID.
Click Source Link
From source file:org.eclipse.rcptt.ui.actions.edit.Q7CopyFilesAndFoldersOperation.java
License:Open Source License
/** * Check if the user wishes to overwrite the supplied resource or all * resources.// w w w . j a v a 2s.co 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() { @SuppressWarnings("restriction") 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( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteMergeQuestion, destination.getFullPath().makeRelative()); } else { if (destination.isLinked()) { message = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeLinkQuestion, destination.getFullPath().makeRelative()); } else { message = NLS.bind( org.eclipse.ui.internal.ide.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[] { org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getLocationText(destination), org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils .getDateStringValue(destination), org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getLocationText(source), org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getDateStringValue(source) }; message = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteWithDetailsQuestion, bindings); } MessageDialog dialog = new MessageDialog(messageShell, org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceExists, null, message, MessageDialog.QUESTION, labels, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; 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.eclipse.rcptt.ui.actions.edit.Q7CopyFilesAndFoldersOperation.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. * //w w w . j a v a 2s . c o m * @param destination * 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 */ @SuppressWarnings({ "restriction", "rawtypes", "unchecked" }) private IResource[] validateNoNameCollisions(IContainer destination, IResource[] sourceResources) { List copyItems = new ArrayList(); 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( org.eclipse.ui.internal.ide.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 (IResource[]) copyItems.toArray(new IResource[copyItems.size()]); }
From source file:org.eclipse.remote.internal.jsch.ui.JSchUserAuthenticator.java
License:Open Source License
@Override public int prompt(final int promptType, final String title, final String message, final int[] promptResponses, final int defaultResponseIndex) { final Display display = getDisplay(); final int[] retval = new int[1]; final String[] buttons = new String[promptResponses.length]; for (int i = 0; i < promptResponses.length; i++) { int prompt = promptResponses[i]; switch (prompt) { case IDialogConstants.OK_ID: buttons[i] = IDialogConstants.OK_LABEL; break; case IDialogConstants.CANCEL_ID: buttons[i] = IDialogConstants.CANCEL_LABEL; break; case IDialogConstants.NO_ID: buttons[i] = IDialogConstants.NO_LABEL; break; case IDialogConstants.YES_ID: buttons[i] = IDialogConstants.YES_LABEL; break; }/*from w w w.ja v a 2s . c o m*/ } display.syncExec(new Runnable() { @Override public void run() { final MessageDialog dialog = new MessageDialog(display.getActiveShell(), title, null /* title image */, message, promptType, buttons, defaultResponseIndex); retval[0] = dialog.open(); } }); return promptResponses[retval[0]]; }
From source file:org.eclipse.sirius.common.ui.tools.api.dialog.SiriusMessageDialogWithToggle.java
License:Open Source License
/** * Attempt to find a standard JFace button id that matches the specified * button label. If no match can be found, use the default id provided. * //from w w w . j a va 2 s . c om * Overridden to investigate the provided buttons. * * @param buttonLabel * the button label whose id is sought * @param defaultId * the id to use for the button if there is no standard id * @return the id for the specified button label */ // CHECKSTYLE:OFF private int mapButtonLabelToButtonID(String buttonLabel, int defaultId) { // CHECKSTYLE:OON // Not pretty but does the job... if (IDialogConstants.OK_LABEL.equals(buttonLabel)) { return IDialogConstants.OK_ID; } if (IDialogConstants.YES_LABEL.equals(buttonLabel)) { return IDialogConstants.YES_ID; } if (IDialogConstants.NO_LABEL.equals(buttonLabel)) { return IDialogConstants.NO_ID; } if (IDialogConstants.CANCEL_LABEL.equals(buttonLabel)) { return IDialogConstants.CANCEL_ID; } if (IDialogConstants.YES_TO_ALL_LABEL.equals(buttonLabel)) { return IDialogConstants.YES_TO_ALL_ID; } if (IDialogConstants.SKIP_LABEL.equals(buttonLabel)) { return IDialogConstants.SKIP_ID; } if (IDialogConstants.STOP_LABEL.equals(buttonLabel)) { return IDialogConstants.STOP_ID; } if (IDialogConstants.ABORT_LABEL.equals(buttonLabel)) { return IDialogConstants.ABORT_ID; } if (IDialogConstants.RETRY_LABEL.equals(buttonLabel)) { return IDialogConstants.RETRY_ID; } if (IDialogConstants.IGNORE_LABEL.equals(buttonLabel)) { return IDialogConstants.IGNORE_ID; } if (IDialogConstants.PROCEED_LABEL.equals(buttonLabel)) { return IDialogConstants.PROCEED_ID; } if (IDialogConstants.OPEN_LABEL.equals(buttonLabel)) { return IDialogConstants.OPEN_ID; } if (IDialogConstants.CLOSE_LABEL.equals(buttonLabel)) { return IDialogConstants.CLOSE_ID; } if (IDialogConstants.BACK_LABEL.equals(buttonLabel)) { return IDialogConstants.BACK_ID; } if (IDialogConstants.NEXT_LABEL.equals(buttonLabel)) { return IDialogConstants.NEXT_ID; } if (IDialogConstants.FINISH_LABEL.equals(buttonLabel)) { return IDialogConstants.FINISH_ID; } if (IDialogConstants.HELP_LABEL.equals(buttonLabel)) { return IDialogConstants.HELP_ID; } if (IDialogConstants.NO_TO_ALL_LABEL.equals(buttonLabel)) { return IDialogConstants.NO_TO_ALL_ID; } if (IDialogConstants.SHOW_DETAILS_LABEL.equals(buttonLabel)) { return IDialogConstants.DETAILS_ID; } if (IDialogConstants.HIDE_DETAILS_LABEL.equals(buttonLabel)) { return IDialogConstants.DETAILS_ID; } for (String providedButton : buttonsMap.keySet()) { if (providedButton.equals(buttonLabel)) { return buttonsMap.get(providedButton); } } // No XXX_LABEL in IDialogConstants for these. Unlikely // they would be used in a message dialog though. // public int SELECT_ALL_ID = 18; // public int DESELECT_ALL_ID = 19; // public int SELECT_TYPES_ID = 20; return defaultId; }
From source file:org.eclipse.sirius.common.ui.tools.api.util.SWTUtil.java
License:Open Source License
/** * Show a dialog to ask the user to save or not the content of the Session. * The window's return codes can be ISaveablePart2.CANCEL, * ISaveablePart2.YES or ISaveablePart2.NO. * //from w w w . j ava 2s. c o m * @param label * the name of the element to save or any other label * @param canCancel * <code>true</code> if the save can be cancel, * <code>false</code> otherwise * @param stillOpenElsewhere * <code>true</code> the object to save is open elsewhere, * <code>false</code> otherwise * @return the return code */ private static int showStandardSaveDialog(final String label, final boolean canCancel, boolean stillOpenElsewhere) { // Step 1: getting the save buttons Map<String, Integer> buttons = Maps.newLinkedHashMap(); buttons.put(IDialogConstants.YES_LABEL, IDialogConstants.YES_ID); buttons.put(IDialogConstants.NO_LABEL, IDialogConstants.NO_ID); // Step 2 :opening window int temporaryResult = openSaveDialog(label, canCancel, buttons, stillOpenElsewhere); return temporaryResult; }
From source file:org.eclipse.sirius.common.ui.tools.api.util.SWTUtil.java
License:Open Source License
/** * @see org.eclipse.internal.SaveablesList#promptForSaving(List, * org.eclipse.jface.window.IShellProvider, * org.eclipse.jface.operation.IRunnableContext, boolean, boolean) *//*w w w .j ava2 s . c o m*/ private static int openSaveDialog(String label, final boolean canCancel, Map<String, Integer> buttons, boolean stillOpenElsewhere) { int choice = ISaveablePart2.YES; // Get user preference for still open beahvior IPreferenceStore platformUIPrefStore = PlatformUI.getPreferenceStore(); boolean dontPrompt = stillOpenElsewhere && !platformUIPrefStore.getBoolean(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN); if (dontPrompt) { choice = ISaveablePart2.NO; } else { final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null && buttons != null) { final MessageDialog dialog = createSaveDialog(label, canCancel, buttons, stillOpenElsewhere, window); choice = dialog.open(); // User has pressed "Escape" or has closed the dialog if (choice == SWT.DEFAULT) { choice = IDialogConstants.CANCEL_ID; } // React to the use preference choice. // map value of choice back to ISaveablePart2 values switch (choice) { case IDialogConstants.YES_ID: choice = ISaveablePart2.YES; break; case IDialogConstants.NO_ID: choice = ISaveablePart2.NO; break; case IDialogConstants.CANCEL_ID: choice = ISaveablePart2.CANCEL; break; default: break; } if (stillOpenElsewhere) { MessageDialogWithToggle dialogWithToggle = (MessageDialogWithToggle) dialog; if (choice != ISaveablePart2.CANCEL && dialogWithToggle.getToggleState()) { // change the rpeference platformUIPrefStore.setValue(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN, false); } } } } return choice; }
From source file:org.eclipse.team.internal.ccvs.ui.actions.CommitAction.java
License:Open Source License
public static boolean isIncludeChangeSets(final Shell shell, final String message) { if (CVSUIPlugin.getPlugin().getChangeSetManager().getSets().length == 0) return false; final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); final String option = store.getString(ICVSUIConstants.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT); if (option.equals(MessageDialogWithToggle.ALWAYS)) return true; // no, always switch if (option.equals(MessageDialogWithToggle.NEVER)) return false; // no, never switch // Ask the user whether to switch final int[] result = new int[] { 0 }; Utils.syncExec(new Runnable() { public void run() { final MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(shell, CVSUIMessages.CommitAction_1, message, CVSUIMessages.ShowAnnotationOperation_4, false /* toggle state */, store, ICVSUIConstants.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT); result[0] = m.getReturnCode(); }//from ww w . jav a2 s . c o m }, shell); switch (result[0]) { // yes case IDialogConstants.YES_ID: case IDialogConstants.OK_ID: return true; // no case IDialogConstants.NO_ID: return false; } return false; }
From source file:org.eclipse.team.internal.ccvs.ui.actions.ShowAnnotationAction.java
License:Open Source License
/** * Fetch the revision number of a CVS resource and perform a ShowAnnotationOperation * in the background./*w w w . ja va2 s. c o m*/ * * @param cvsResource The CVS resource (must not be null) * * @throws InvocationTargetException * @throws InterruptedException */ public void execute(final ICVSResource cvsResource) throws InvocationTargetException, InterruptedException { final String revision = getRevision(cvsResource); if (revision == null) return; boolean binary = isBinary(cvsResource); if (binary) { final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); final String option = store.getString(ICVSUIConstants.PREF_ANNOTATE_PROMPTFORBINARY); if (option.equals(MessageDialogWithToggle.PROMPT)) { final MessageDialogWithToggle dialog = (MessageDialogWithToggle.openYesNoQuestion(getShell(), CVSUIMessages.ShowAnnotationAction_2, NLS.bind(CVSUIMessages.ShowAnnotationAction_3, new String[] { cvsResource.getName() }), CVSUIMessages.ShowAnnotationOperation_4, false, store, ICVSUIConstants.PREF_ANNOTATE_PROMPTFORBINARY)); final int result = dialog.getReturnCode(); switch (result) { case IDialogConstants.NO_ID: return; } } else if (option.equals(MessageDialogWithToggle.NEVER)) return; } new ShowAnnotationOperation(getTargetPart(), cvsResource, revision, binary).run(); }
From source file:org.eclipse.team.internal.ccvs.ui.AddToVersionControlDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); super.createButtonsForButtonBar(parent); }
From source file:org.eclipse.team.internal.ccvs.ui.AddToVersionControlDialog.java
License:Open Source License
protected void buttonPressed(int id) { // hijack yes and no buttons to set the correct return // codes.//from w w w . ja v a 2s . c o m if (id == IDialogConstants.YES_ID || id == IDialogConstants.NO_ID) { setReturnCode(id); close(); } else { super.buttonPressed(id); } }