List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_LABEL
String NO_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.
Click Source Link
From source file:ext.org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.AddFolderToBuildpathAction.java
License:Open Source License
/** * {@inheritDoc}/*from w w w .j a v a 2s . c o m*/ */ @Override public void run() { try { final IJavaProject project; Object object = getSelectedElements().get(0); if (object instanceof IJavaProject) { project = (IJavaProject) object; } else if (object instanceof IPackageFragment) { project = ((IPackageFragment) object).getJavaProject(); } else { IFolder folder = (IFolder) object; project = JavaCore.create(folder.getProject()); if (project == null) return; } final Shell shell = getShell(); final boolean removeProjectFromClasspath; IPath outputLocation = project.getOutputLocation(); final IPath defaultOutputLocation = outputLocation.makeRelative(); final IPath newDefaultOutputLocation; final boolean removeOldClassFiles; IPath projPath = project.getProject().getFullPath(); if (!(getSelectedElements().size() == 1 && getSelectedElements().get(0) instanceof IJavaProject) && //if only the project should be added, then the query does not need to be executed (outputLocation.equals(projPath) || defaultOutputLocation.segmentCount() == 1)) { final OutputFolderQuery outputFolderQuery = ClasspathModifierQueries.getDefaultFolderQuery(shell, defaultOutputLocation); if (outputFolderQuery.doQuery(true, ClasspathModifier.getValidator(getSelectedElements(), project), project)) { newDefaultOutputLocation = outputFolderQuery.getOutputLocation(); removeProjectFromClasspath = outputFolderQuery.removeProjectFromClasspath(); if (BuildPathsBlock.hasClassfiles(project.getProject()) && outputLocation.equals(projPath)) { String title = NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_title; String message = Messages.format( NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_description, BasicElementLabels.getPathLabel(projPath, false)); MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int answer = dialog.open(); if (answer == 0) { removeOldClassFiles = true; } else if (answer == 1) { removeOldClassFiles = false; } else { return; } } else { removeOldClassFiles = false; } } else { return; } } else { removeProjectFromClasspath = false; removeOldClassFiles = false; newDefaultOutputLocation = defaultOutputLocation; } try { final IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { List<IJavaElement> result = addToClasspath(getSelectedElements(), project, newDefaultOutputLocation.makeAbsolute(), removeProjectFromClasspath, removeOldClassFiles, monitor); selectAndReveal(new StructuredSelection(result)); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; fContext.run(false, false, runnable); } catch (final InvocationTargetException e) { if (e.getCause() instanceof CoreException) { showExceptionDialog((CoreException) e.getCause(), NewWizardMessages.AddSourceFolderToBuildpathAction_ErrorTitle); } else { JavaPlugin.log(e); } } catch (final InterruptedException e) { } } catch (CoreException e) { showExceptionDialog(e, NewWizardMessages.AddSourceFolderToBuildpathAction_ErrorTitle); } }
From source file:ext.org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.RemoveLinkedFolderDialog.java
License:Open Source License
/** * Creates a new remove linked folder dialog. * * @param shell the parent shell to use// w w w. java 2s .c o m * @param folder the linked folder to remove */ RemoveLinkedFolderDialog(final Shell shell, final IFolder folder) { super(shell, NewWizardMessages.ClasspathModifierQueries_confirm_remove_linked_folder_label, null, Messages.format(NewWizardMessages.ClasspathModifierQueries_confirm_remove_linked_folder_message, new Object[] { BasicElementLabels.getPathLabel(folder.getFullPath(), false) }), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // yes is the default Assert.isTrue(folder.isLinked()); }
From source file:ext.org.eclipse.jdt.internal.ui.wizards.buildpaths.VariableBlock.java
License:Open Source License
public boolean performOk() { ArrayList<String> removedVariables = new ArrayList<String>(); ArrayList<String> changedVariables = new ArrayList<String>(); removedVariables.addAll(Arrays.asList(JavaCore.getClasspathVariableNames())); // remove all unchanged List<CPVariableElement> changedElements = fVariablesList.getElements(); for (int i = changedElements.size() - 1; i >= 0; i--) { CPVariableElement curr = changedElements.get(i); if (curr.isReadOnly()) { changedElements.remove(curr); } else {/*from ww w . j a va2 s. c o m*/ IPath path = curr.getPath(); IPath prevPath = JavaCore.getClasspathVariable(curr.getName()); if (prevPath != null && prevPath.equals(path)) { changedElements.remove(curr); } else { changedVariables.add(curr.getName()); } } removedVariables.remove(curr.getName()); } int steps = changedElements.size() + removedVariables.size(); if (steps > 0) { boolean needsBuild = false; if (fAskToBuild && doesChangeRequireFullBuild(removedVariables, changedVariables)) { String title = NewWizardMessages.VariableBlock_needsbuild_title; String message = NewWizardMessages.VariableBlock_needsbuild_message; MessageDialog buildDialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = buildDialog.open(); if (res != 0 && res != 1) { return false; } needsBuild = (res == 0); } final VariableBlockRunnable runnable = new VariableBlockRunnable(removedVariables, changedElements); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { PlatformUI.getWorkbench().getProgressService().runInUI(dialog, runnable, ResourcesPlugin.getWorkspace().getRoot()); } catch (InvocationTargetException e) { ExceptionHandler.handle(new InvocationTargetException(new NullPointerException()), getShell(), NewWizardMessages.VariableBlock_variableSettingError_titel, NewWizardMessages.VariableBlock_variableSettingError_message); return false; } catch (InterruptedException e) { return false; } if (needsBuild) { CoreUtility.getBuildJob(null).schedule(); } } return true; }
From source file:fr.inria.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.ImportTracePackageWizardPage.java
License:Open Source License
private boolean checkForOverwrite() { TracePackageElement[] traceElements = (TracePackageElement[]) getElementViewer().getInput(); List<TracePackageTraceElement> noImportTraces = new ArrayList<>(); boolean noToAll = false; for (TracePackageElement packageElement : traceElements) { TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement; if (!AbstractTracePackageOperation.isFilesChecked(traceElement)) { continue; }/*w w w . ja va 2s . c o m*/ if (noToAll) { noImportTraces.add(traceElement); continue; } if (traceExists(traceElement)) { int returnCode = promptForOverwrite(traceElement.getDestinationElementPath()); // The return code is an index to a button in the dialog but the // 'X' button in the window corner is not considered a button // therefore it returns -1 and unfortunately, there is no // constant for that. if (returnCode < 0) { return false; } final String[] response = new String[] { IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.YES_LABEL }; if (response[returnCode].equals(IDialogConstants.YES_TO_ALL_LABEL)) { break; } else if (response[returnCode].equals(IDialogConstants.NO_TO_ALL_LABEL)) { noToAll = true; noImportTraces.add(traceElement); } else if (response[returnCode].equals(IDialogConstants.NO_LABEL)) { noImportTraces.add(traceElement); } } } // Unselect the traces that the user decided not to import for (TracePackageTraceElement t : noImportTraces) { for (TracePackageElement e : t.getChildren()) { if (e instanceof TracePackageFilesElement) { ((TracePackageFilesElement) e).setChecked(false); } } } return true; }
From source file:fr.inria.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.ImportTracePackageWizardPage.java
License:Open Source License
private int promptForOverwrite(String traceName) { final MessageDialog dialog = new MessageDialog(getContainer().getShell(), null, null, MessageFormat.format(Messages.ImportTracePackageWizardPage_AlreadyExists, traceName), MessageDialog.QUESTION, new String[] { IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.YES_LABEL, }, 3) {// w w w . jav a 2 s . com @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; return dialog.open(); }
From source file:gov.nasa.ensemble.common.ui.operations.EnsembleFileSystemExportOperation.java
License:Open Source License
protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getShellForMessageDialog(), "Question", (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { @Override//ww w.j a v a 2s . c om protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; // ensure yes is the default return dialog.open() == 0; }
From source file:gov.nasa.ensemble.common.ui.wizard.AbstractEnsembleProjectExportWizardPage.java
License:Open Source License
@Override public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString;/*from w w w . j a v a 2 s .c o m*/ //Break the message up if there is a file name and a directory //and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { // PATH_TO_FILE already exists. Would you like to overwrite it? //messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path); IPath location = folder.getLocation(); File file = null; if (location == null) { file = new File(pathString); } else { file = location.toFile(); } messageString = getDialogQuestionText(file); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); String osString = path.toOSString(); Date date = new Date(new File(osString).lastModified()); messageString += System.getProperty("line.separator") + System.getProperty("line.separator") + "'" + path.lastSegment() + "' was last modified on: " + date; } final MessageDialog dialog = new MessageDialog(getShellForMessageDialog(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; //run in syncExec because callback is from an operation, //which is probably not running in the UI thread. WidgetUtils.runInDisplayThread(getShell(), new Runnable() { @Override public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:gov.nasa.ensemble.common.ui.wizard.AbstractEnsembleProjectExportWizardPage.java
License:Open Source License
/** * This override is provided to provide an appropriate shell vs the standard * approach of just using the container. *//*w w w .ja v a2s.co m*/ @Override protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getShellForMessageDialog(), IDEWorkbenchMessages.Question, (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; // ensure yes is the default return dialog.open() == 0; }
From source file:gov.nasa.ensemble.common.ui.wizard.DefaultOverwriteQueryImpl.java
License:Open Source License
@Override public String queryOverwrite(String pathString) { if (alwaysOverwrite) { return ALL; }//from w w w .j ava 2 s .com final String returnCode[] = { CANCEL }; final String msg = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteQuestion, pathString); final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; shell.getDisplay().syncExec(new Runnable() { @Override public void run() { MessageDialog dialog = new MessageDialog(shell, IDEWorkbenchMessages.CopyFilesAndFoldersOperation_question, null, msg, MessageDialog.QUESTION, options, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; dialog.open(); int returnVal = dialog.getReturnCode(); String[] returnCodes = { YES, ALL, NO, CANCEL }; returnCode[0] = returnVal == -1 ? CANCEL : returnCodes[returnVal]; } }); if (returnCode[0] == ALL) { alwaysOverwrite = true; } else if (returnCode[0] == CANCEL) { canceled = true; } return returnCode[0]; }
From source file:gov.nasa.ensemble.core.plan.editor.lifecycle.WizardPlanExportPage.java
License:Open Source License
/** * Displays a Yes/No question to the user with the specified message and returns * the user's response.//from w w w .java 2 s. c o m * * @param message the question to ask * @return <code>true</code> for Yes, and <code>false</code> for No */ protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getContainer().getShell(), "Question", (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // ensure yes is the default return dialog.open() == 0; }