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.team.internal.ccvs.ui.repo.RepositoryManager.java
License:Open Source License
/** * Prompt to add all or some of the provided resources to version control. * The value null is returned if the dialog is cancelled. * /*from w w w . jav a 2 s .c o m*/ * @param shell * @param unadded * @return IResource[] */ public IResource[] promptForResourcesToBeAdded(Shell shell, IResource[] unadded) { if (unadded == null) return new IResource[0]; if (unadded.length == 0) return unadded; final IResource[][] result = new IResource[1][0]; result[0] = null; final AddToVersionControlDialog dialog = new AddToVersionControlDialog(shell, unadded); shell.getDisplay().syncExec(new Runnable() { public void run() { int code = dialog.open(); if (code == IDialogConstants.YES_ID) { result[0] = dialog.getResourcesToAdd(); } else if (code == IDialogConstants.NO_ID) { // allow the commit to continue. result[0] = new IResource[0]; } } }); return result[0]; }
From source file:org.eclipse.team.internal.ccvs.ui.subscriber.UpdateDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { createButton(parent, YES, IDialogConstants.YES_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); super.createButtonsForButtonBar(parent); }
From source file:org.eclipse.team.internal.ccvs.ui.subscriber.UpdateDialog.java
License:Open Source License
protected void buttonPressed(int id) { // hijack yes and no buttons to set the correct return // codes./*from w ww . ja v a 2s . com*/ if (id == YES || id == IDialogConstants.NO_ID) { setReturnCode(id); filterSyncSet(); close(); } else { super.buttonPressed(id); } }
From source file:org.eclipse.team.internal.ccvs.ui.wizards.NewLocationWizard.java
License:Open Source License
private String promptForPerspectiveSwitch() { // check whether we should ask the user. final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); final String option = store.getString(ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_NEW_REPOSITORY_LOCATION); final String desiredID = CVSPerspective.ID; if (option.equals(MessageDialogWithToggle.ALWAYS)) return desiredID; // no, always switch if (option.equals(MessageDialogWithToggle.NEVER)) return null; // no, never switch // Check whether the desired perspective is already active. final IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry(); final IPerspectiveDescriptor desired = registry.findPerspectiveWithId(desiredID); final IWorkbenchPage page = CVSUIPlugin.getActivePage(); if (page != null) { final IPerspectiveDescriptor current = page.getPerspective(); if (current != null && current.getId().equals(desiredID)) { return null; // it is active, so no prompt and no switch }/*from w w w .j a v a 2s . c o m*/ } if (desired != null) { String message; ; String desc = desired.getDescription(); if (desc == null) { message = NLS.bind(CVSUIMessages.NewLocationWizard_2, new String[] { desired.getLabel() }); } else { message = NLS.bind(CVSUIMessages.NewLocationWizard_3, new String[] { desired.getLabel(), desc }); } // Ask the user whether to switch final MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(Utils.getShell(null), CVSUIMessages.NewLocationWizard_1, message, CVSUIMessages.NewLocationWizard_4, false /* toggle state */, store, ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_NEW_REPOSITORY_LOCATION); final int result = m.getReturnCode(); switch (result) { // yes case IDialogConstants.YES_ID: case IDialogConstants.OK_ID: return desiredID; // no case IDialogConstants.NO_ID: return null; } } return null; }
From source file:org.eclipse.team.internal.ui.mapping.MergeAllOperation.java
License:Open Source License
public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { new ModelMergeOperation(getPart(), ((SynchronizationContext) context).getScopeManager()) { public boolean isPreviewRequested() { return false; }/*from ww w . ja v a 2 s . co m*/ protected void initializeContext(IProgressMonitor monitor) throws CoreException { monitor.beginTask(null, 10); monitor.done(); } protected ISynchronizationContext getContext() { return context; } protected void executeMerge(IProgressMonitor monitor) throws CoreException { monitor.beginTask(null, 100); if (!hasChangesOfInterest()) { handleNoChanges(); } else if (isPreviewRequested()) { handlePreviewRequest(); } else { IStatus status = ModelMergeOperation.validateMerge(getMergeContext(), Policy.subMonitorFor(monitor, 10)); if (!status.isOK()) { if (!promptToContinue(status)) return; } status = performMerge(Policy.subMonitorFor(monitor, 90)); if (!status.isOK()) { handleMergeFailure(status); } } monitor.done(); } private IMergeContext getMergeContext() { return (IMergeContext) getContext(); } private boolean promptToContinue(final IStatus status) { final boolean[] result = new boolean[] { false }; Runnable runnable = new Runnable() { public void run() { ErrorDialog dialog = new ErrorDialog(getShell(), TeamUIMessages.ModelMergeOperation_0, TeamUIMessages.ModelMergeOperation_1, status, IStatus.ERROR | IStatus.WARNING | IStatus.INFO) { protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); createDetailsButton(parent); } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.ErrorDialog#buttonPressed(int) */ protected void buttonPressed(int id) { if (id == IDialogConstants.YES_ID) super.buttonPressed(IDialogConstants.OK_ID); else if (id == IDialogConstants.NO_ID) super.buttonPressed(IDialogConstants.CANCEL_ID); super.buttonPressed(id); } }; int code = dialog.open(); result[0] = code == 0; } }; getShell().getDisplay().syncExec(runnable); return (result[0]); } }.run(monitor); }
From source file:org.eclipse.team.internal.ui.synchronize.SynchronizeManager.java
License:Open Source License
/** * Decides what action to take when switching perspectives and showing the synchronize view. Basically there are a * set of user preferences that control how perspective switching. *//* www. j a v a 2s. c om*/ private boolean promptForPerspectiveSwitch() { // Decide if a prompt is even required IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore(); String option = store.getString(IPreferenceIds.SYNCHRONIZING_COMPLETE_PERSPECTIVE); if (option.equals(MessageDialogWithToggle.ALWAYS)) { return true; } else if (option.equals(MessageDialogWithToggle.NEVER)) { return false; } // Otherwise determine if a prompt is required IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry(); String defaultSyncPerspectiveId = store.getString(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE); IPerspectiveDescriptor perspectiveDescriptor = registry.findPerspectiveWithId(defaultSyncPerspectiveId); IWorkbenchPage page = TeamUIPlugin.getActivePage(); if (page != null) { IPerspectiveDescriptor p = page.getPerspective(); if (p != null && p.getId().equals(defaultSyncPerspectiveId)) { // currently in default perspective return false; } } if (perspectiveDescriptor != null) { String message; ; String desc = perspectiveDescriptor.getDescription(); if (desc == null) { message = NLS.bind(TeamUIMessages.SynchronizeManager_30, new String[] { perspectiveDescriptor.getLabel() }); } else { message = NLS.bind(TeamUIMessages.SynchronizeManager_32, new String[] { perspectiveDescriptor.getLabel(), desc }); } MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(Utils.getShell(null), TeamUIMessages.SynchronizeManager_27, message, TeamUIMessages.SynchronizeManager_31, false /* toggle state */, store, IPreferenceIds.SYNCHRONIZING_COMPLETE_PERSPECTIVE); int result = m.getReturnCode(); switch (result) { // yes, ok 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.svn.ui.synchronize.action.CommitActionHelper.java
License:Open Source License
/** * Ask preferences in order to determine whether to consult change sets * during commit, synchronize or not/*from w ww . jav a 2 s .c om*/ */ public static boolean isIncludeChangeSets(final String message) { if (SVNTeamPlugin.instance().getModelChangeSetManager().getSets().length == 0) return false; final IPreferenceStore store = SVNTeamUIPlugin.instance().getPreferenceStore(); String consultChangeSetsOption = SVNTeamPreferences.getConsultChangeSetsInCommit(store, SVNTeamPreferences.CONSULT_CHANGE_SETS_IN_COMMIT); if (consultChangeSetsOption.equals(SVNTeamPreferences.CONSULT_CHANGE_SETS_IN_COMMIT_ALWAYS)) { return true; } else if (consultChangeSetsOption.equals(SVNTeamPreferences.CONSULT_CHANGE_SETS_IN_COMMIT_NEVER)) { return false; } final int[] result = new int[] { 0 }; // Ask the user whether to switch UIMonitorUtility.getDisplay().syncExec(new Runnable() { public void run() { Shell shell = UIMonitorUtility.getShell(); MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(shell, SVNUIMessages.ConsultChangeSets_toggleDialog_title, message, SVNUIMessages.ConsultChangeSets_toggleDialog_toggleMessage, false /* toggle state */, store, SVNTeamPreferences.fullPromptName(SVNTeamPreferences.CONSULT_CHANGE_SETS_IN_COMMIT)); m.getReturnCode(); result[0] = m.getReturnCode(); } }); 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.ui.synchronize.ModelMergeOperation.java
License:Open Source License
/** * Method invoked when the context contains changes that failed validation * by at least one {@link IResourceMappingMerger}. * By default, the user is prompted to inform them that unmergeable changes were found * and the {@link #handlePreviewRequest()} method is invoked. * Subclasses may override.//from ww w . j a va 2 s . c o m * @param status the status returned from the mergers that reported the validation failures */ protected void handleValidationFailure(final IStatus status) { final boolean[] result = new boolean[] { false }; Runnable runnable = new Runnable() { public void run() { ErrorDialog dialog = new ErrorDialog(getShell(), TeamUIMessages.ModelMergeOperation_0, TeamUIMessages.ModelMergeOperation_1, status, IStatus.ERROR | IStatus.WARNING | IStatus.INFO) { protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); createDetailsButton(parent); } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.ErrorDialog#buttonPressed(int) */ protected void buttonPressed(int id) { if (id == IDialogConstants.YES_ID) super.buttonPressed(IDialogConstants.OK_ID); else if (id == IDialogConstants.NO_ID) super.buttonPressed(IDialogConstants.CANCEL_ID); super.buttonPressed(id); } }; int code = dialog.open(); result[0] = code == 0; } }; getShell().getDisplay().syncExec(runnable); if (result[0]) handlePreviewRequest(); }
From source file:org.eclipse.ui.actions.CopyFilesAndFoldersOperation.java
License:Open Source License
/** * Check if the user wishes to overwrite the supplied resource or all * resources./*from ww w .j a v a2s.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() { 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) { 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.ui.actions.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. * /*from w w w.j ava 2 s. c om*/ * @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 */ 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(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()]); }