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.rcptt.ui.actions.edit.PasteAction.java
License:Open Source License
/** * Check if the user wishes to overwrite the supplied resource or all * resources. Copied from/* ww w . ja v a 2 s .c om*/ * org.eclipse.ui.actions.CopyFilesAndFoldersOperation. * * @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 }; 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(shell, 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()]; } } }; shell.getDisplay().syncExec(query); return result[0]; }
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 ww . ja v a 2 s . c om * * @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 ww .ja va 2s.com * @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.rcptt.ui.dialogs.AddProjectReferencesDialog.java
License:Open Source License
public static boolean open(Shell parentShell, IProject project, Map<IProject, Set<IQ7NamedElement>> references) { String value = prefStore.getString(IPreferenceKeys.ADD_PROJECT_REFERENCES); if (ALWAYS.equals(value)) { addMissingReferences(project, references); return true; } else {/* w ww .j a va2 s . c om*/ if (instance != null && instance.getShell() != null && !instance.getShell().isDisposed()) { // Is still running return false; } instance = new AddProjectReferencesDialog(parentShell, project, references); return instance.open() == IDialogConstants.YES_ID; } }
From source file:org.eclipse.rcptt.ui.dialogs.AddProjectReferencesDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.YES_ID) { addMissingReferences(project, references); }/* ww w . j a v a 2s.c o m*/ if (getToggleState()) { prefStore.setValue(IPreferenceKeys.ADD_PROJECT_REFERENCES, ALWAYS); } setReturnCode(buttonId); close(); }
From source file:org.eclipse.rcptt.ui.dialogs.RemoveAllProjectReferencesDialog.java
License:Open Source License
public static boolean open(Shell parentShell, IQ7Project project, List<IQ7NamedElement> elements) { String value = prefStore.getString(IPreferenceKeys.ALL_REMOVE_PROJECT_REFERENCES); if (ALWAYS.equals(value)) { addMissingReferences(project, elements); return true; } else {//from w w w. ja v a2 s . com if (instance != null && instance.getShell() != null && !instance.getShell().isDisposed()) { // Is still running return false; } instance = new RemoveAllProjectReferencesDialog(parentShell, project, elements); return instance.open() == IDialogConstants.YES_ID; } }
From source file:org.eclipse.rcptt.ui.dialogs.RemoveAllProjectReferencesDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.YES_ID) { addMissingReferences(project, references); }/*www . java 2 s.c o m*/ if (getToggleState()) { prefStore.setValue(IPreferenceKeys.ALL_REMOVE_PROJECT_REFERENCES, ALWAYS); } setReturnCode(buttonId); close(); }
From source file:org.eclipse.rcptt.ui.dialogs.RemoveProjectReferencesDialog.java
License:Open Source License
public static boolean open(Shell parentShell, IQ7NamedElement element, List<String> references) { String value = prefStore.getString(IPreferenceKeys.REMOVE_PROJECT_REFERENCES); if (ALWAYS.equals(value)) { addMissingReferences(element, references); return true; } else {/*from ww w . jav a 2 s . c om*/ if (instance != null && instance.getShell() != null && !instance.getShell().isDisposed()) { // Is still running return false; } instance = new RemoveProjectReferencesDialog(parentShell, element, references); return instance.open() == IDialogConstants.YES_ID; } }
From source file:org.eclipse.rcptt.ui.dialogs.RemoveProjectReferencesDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.YES_ID) { addMissingReferences(element, references); }//from ww w. j a v a 2s. c om if (getToggleState()) { prefStore.setValue(IPreferenceKeys.REMOVE_PROJECT_REFERENCES, ALWAYS); } setReturnCode(buttonId); close(); }
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. j a v a2 s . 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]]; }