1 /*******************************************************************************
2 * Copyright (c) 2000, 2012 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.ui.wizards;
15 import java.util.ArrayList;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.widgets.DirectoryDialog;
19 import org.eclipse.swt.widgets.FileDialog;
20 import org.eclipse.swt.widgets.Shell;
22 import org.eclipse.core.runtime.IPath;
23 import org.eclipse.core.runtime.Path;
25 import org.eclipse.core.resources.IContainer;
26 import org.eclipse.core.resources.IFile;
27 import org.eclipse.core.resources.IFolder;
28 import org.eclipse.core.resources.IProject;
29 import org.eclipse.core.resources.IResource;
30 import org.eclipse.core.resources.IWorkspaceRoot;
31 import org.eclipse.core.resources.ResourcesPlugin;
33 import org.eclipse.jface.window.Window;
35 import org.eclipse.ui.model.WorkbenchContentProvider;
36 import org.eclipse.ui.model.WorkbenchLabelProvider;
37 import org.eclipse.ui.views.navigator.ResourceComparator;
39 import org.eclipse.jdt.core.IClasspathEntry;
40 import org.eclipse.jdt.core.IJavaProject;
42 import org.eclipse.jdt.ui.JavaUI;
44 import org.eclipse.jdt.internal.ui.IUIConstants;
45 import org.eclipse.jdt.internal.ui.JavaPlugin;
46 import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
47 import org.eclipse.jdt.internal.ui.viewsupport.FilteredElementTreeSelectionDialog;
48 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
49 import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator;
50 import org.eclipse.jdt.internal.ui.wizards.TypedViewerFilter;
51 import org.eclipse.jdt.internal.ui.wizards.buildpaths.ArchiveFileFilter;
52 import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
53 import org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerWizard;
54 import org.eclipse.jdt.internal.ui.wizards.buildpaths.EditVariableEntryDialog;
55 import org.eclipse.jdt.internal.ui.wizards.buildpaths.JavadocLocationDialog;
56 import org.eclipse.jdt.internal.ui.wizards.buildpaths.MultipleFolderSelectionDialog;
57 import org.eclipse.jdt.internal.ui.wizards.buildpaths.NewVariableEntryDialog;
58 import org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentDialog;
61 * Class that gives access to dialogs used by the Java build path page to configure classpath entries
62 * and properties of classpath entries.
63 * Static methods are provided to show dialogs for:
65 * <li> configuration of source attachments</li>
66 * <li> configuration of Javadoc locations</li>
67 * <li> configuration and selection of classpath variable entries</li>
68 * <li> configuration and selection of classpath container entries</li>
69 * <li> configuration and selection of JAR and external JAR entries</li>
70 * <li> selection of class and source folders</li>
73 * This class is not intended to be instantiated or subclassed by clients.
77 * @noinstantiate This class is not intended to be instantiated by clients.
79 public final class BuildPathDialogAccess {
81 private BuildPathDialogAccess() {
86 * Shows the UI for configuring source attachments, with editing of source attachment encoding
87 * disabled. <code>null</code> is returned if the user cancels the dialog. The dialog does not
90 * @param shell The parent shell for the dialog
91 * @param initialEntry The entry to edit. The kind of the classpath entry must be either
92 * <code>IClasspathEntry.CPE_LIBRARY</code> or
93 * <code>IClasspathEntry.CPE_VARIABLE</code>.
94 * @return Returns the resulting classpath entry containing a potentially modified source
95 * attachment path, source attachment root and source attachment encoding. The resulting
96 * entry can be used to replace the original entry on the classpath. Note that the
97 * dialog does not make any changes on the passed entry nor on the classpath that
100 public static IClasspathEntry configureSourceAttachment(Shell shell, IClasspathEntry initialEntry) {
101 return configureSourceAttachment(shell, initialEntry, false);
105 * Shows the UI for configuring source attachments. The source attachment encoding can be edited
106 * depending on the parameter <code>canEditEncoding</code>. <code>null</code> is returned if the
107 * user cancels the dialog. The dialog does not apply any changes.
109 * @param shell The parent shell for the dialog
110 * @param initialEntry The entry to edit. The kind of the classpath entry must be either
111 * <code>IClasspathEntry.CPE_LIBRARY</code> or
112 * <code>IClasspathEntry.CPE_VARIABLE</code>.
113 * @param canEditEncoding whether the source attachment encoding can be edited
114 * @return Returns the resulting classpath entry containing a potentially modified source
115 * attachment path, source attachment root and source attachment encoding. The resulting
116 * entry can be used to replace the original entry on the classpath. Note that the
117 * dialog does not make any changes on the passed entry nor on the classpath that
121 public static IClasspathEntry configureSourceAttachment(Shell shell, IClasspathEntry initialEntry, boolean canEditEncoding) {
122 if (initialEntry == null) {
123 throw new IllegalArgumentException();
125 int entryKind= initialEntry.getEntryKind();
126 if (entryKind != IClasspathEntry.CPE_LIBRARY && entryKind != IClasspathEntry.CPE_VARIABLE) {
127 throw new IllegalArgumentException();
130 SourceAttachmentDialog dialog= new SourceAttachmentDialog(shell, initialEntry, canEditEncoding);
131 if (dialog.open() == Window.OK) {
132 return dialog.getResult();
138 * Shows the UI for configuring a javadoc location. <code>null</code> is returned
139 * if the user cancels the dialog. If OK is pressed, an array of length 1 containing the configured URL is
140 * returned. Note that the configured URL can be <code>null</code> when the user
141 * wishes to have no URL location specified. The dialog does not apply any changes.
142 * Use {@link org.eclipse.jdt.ui.JavaUI} to access and configure
145 * @param shell The parent shell for the dialog.
146 * @param libraryName Name of of the library to which configured javadoc location belongs.
147 * @param initialURL The initial URL or <code>null</code>.
148 * @return Returns an array of size 1 that contains the resulting javadoc location or
149 * <code>null</code> if the dialog has been canceled. Note that the configured URL can be <code>null</code> when the user
150 * wishes to have no URL location specified.
152 public static URL[] configureJavadocLocation(Shell shell, String libraryName, URL initialURL) {
153 if (libraryName == null) {
154 throw new IllegalArgumentException();
157 JavadocLocationDialog dialog= new JavadocLocationDialog(shell, libraryName, initialURL);
158 if (dialog.open() == Window.OK) {
159 return new URL[] { dialog.getResult() };
165 * Shows the UI for configuring a javadoc location attribute of the classpath entry. <code>null</code> is returned
166 * if the user cancels the dialog. The dialog does not apply any changes.
168 * @param shell The parent shell for the dialog.
169 * @param initialEntry The entry to edit. The kind of the classpath entry must be either
170 * <code>IClasspathEntry.CPE_LIBRARY</code> or <code>IClasspathEntry.CPE_VARIABLE</code>.
171 * @return Returns the resulting classpath entry containing a potentially modified javadoc location attribute
172 * The resulting entry can be used to replace the original entry on the classpath.
173 * Note that the dialog does not make any changes on the passed entry nor on the classpath that
178 public static IClasspathEntry configureJavadocLocation(Shell shell, IClasspathEntry initialEntry) {
179 if (initialEntry == null) {
180 throw new IllegalArgumentException();
182 int entryKind= initialEntry.getEntryKind();
183 if (entryKind != IClasspathEntry.CPE_LIBRARY && entryKind != IClasspathEntry.CPE_VARIABLE) {
184 throw new IllegalArgumentException();
187 URL location= JavaUI.getLibraryJavadocLocation(initialEntry);
188 JavadocLocationDialog dialog= new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location);
189 if (dialog.open() == Window.OK) {
190 CPListElement element= CPListElement.createFromExisting(initialEntry, null);
191 URL res= dialog.getResult();
192 element.setAttribute(CPListElement.JAVADOC, res != null ? res.toExternalForm() : null);
193 return element.getClasspathEntry();
199 * Shows the UI for configuring a variable classpath entry. See {@link IClasspathEntry#CPE_VARIABLE} for
200 * details about variable classpath entries.
201 * The dialog returns the configured classpath entry path or <code>null</code> if the dialog has
202 * been canceled. The dialog does not apply any changes.
204 * @param shell The parent shell for the dialog.
205 * @param initialEntryPath The initial variable classpath variable path or <code>null</code> to use
207 * @param existingPaths An array of paths that are already on the classpath and therefore should not be
209 * @return Returns the configures classpath entry path or <code>null</code> if the dialog has
212 public static IPath configureVariableEntry(Shell shell, IPath initialEntryPath, IPath[] existingPaths) {
213 if (existingPaths == null) {
214 throw new IllegalArgumentException();
217 EditVariableEntryDialog dialog= new EditVariableEntryDialog(shell, initialEntryPath, existingPaths);
218 if (dialog.open() == Window.OK) {
219 return dialog.getPath();
225 * Shows the UI for selecting new variable classpath entries. See {@link IClasspathEntry#CPE_VARIABLE} for
226 * details about variable classpath entries.
227 * The dialog returns an array of the selected variable entries or <code>null</code> if the dialog has
228 * been canceled. The dialog does not apply any changes.
230 * @param shell The parent shell for the dialog.
231 * @param existingPaths An array of paths that are already on the classpath and therefore should not be
233 * @return Returns an non empty array of the selected variable entries or <code>null</code> if the dialog has
236 public static IPath[] chooseVariableEntries(Shell shell, IPath[] existingPaths) {
237 if (existingPaths == null) {
238 throw new IllegalArgumentException();
240 NewVariableEntryDialog dialog= new NewVariableEntryDialog(shell);
241 if (dialog.open() == Window.OK) {
242 return dialog.getResult();
248 * Shows the UI to configure a classpath container classpath entry. See {@link IClasspathEntry#CPE_CONTAINER} for
249 * details about container classpath entries.
250 * The dialog returns the configured classpath entry or <code>null</code> if the dialog has
251 * been canceled. The dialog does not apply any changes.
253 * @param shell The parent shell for the dialog.
254 * @param initialEntry The initial classpath container entry.
255 * @param project The project the entry belongs to. The project does not have to exist and can also be <code>null</code>.
256 * @param currentClasspath The class path entries currently selected to be set as the projects classpath. This can also
257 * include the entry to be edited. The dialog uses these entries as information only (e.g. to avoid duplicate entries); The user still can make changes after the
258 * the classpath container dialog has been closed. See {@link IClasspathContainerPageExtension} for
260 * @return Returns the configured classpath container entry or <code>null</code> if the dialog has
261 * been canceled by the user.
263 public static IClasspathEntry configureContainerEntry(Shell shell, IClasspathEntry initialEntry, IJavaProject project, IClasspathEntry[] currentClasspath) {
264 if (initialEntry == null || currentClasspath == null) {
265 throw new IllegalArgumentException();
268 ClasspathContainerWizard wizard= new ClasspathContainerWizard(initialEntry, project, currentClasspath);
269 if (ClasspathContainerWizard.openWizard(shell, wizard) == Window.OK) {
270 IClasspathEntry[] created= wizard.getNewEntries();
271 if (created != null && created.length == 1) {
279 * Shows the UI to choose new classpath container classpath entries. See {@link IClasspathEntry#CPE_CONTAINER} for
280 * details about container classpath entries.
281 * The dialog returns the selected classpath entries or <code>null</code> if the dialog has
282 * been canceled. The dialog does not apply any changes.
284 * @param shell The parent shell for the dialog.
285 * @param project The project the entry belongs to. The project does not have to exist and
286 * can also be <code>null</code>.
287 * @param currentClasspath The class path entries currently selected to be set as the projects classpath. This can also
288 * include the entry to be edited. The dialog uses these entries as information only; The user still can make changes after the
289 * the classpath container dialog has been closed. See {@link IClasspathContainerPageExtension} for
291 * @return Returns the selected classpath container entries or <code>null</code> if the dialog has
292 * been canceled by the user.
294 public static IClasspathEntry[] chooseContainerEntries(Shell shell, IJavaProject project, IClasspathEntry[] currentClasspath) {
295 if (currentClasspath == null) {
296 throw new IllegalArgumentException();
299 ClasspathContainerWizard wizard= new ClasspathContainerWizard((IClasspathEntry) null, project, currentClasspath);
300 if (ClasspathContainerWizard.openWizard(shell, wizard) == Window.OK) {
301 return wizard.getNewEntries();
308 * Shows the UI to configure a JAR or ZIP archive located in the workspace.
309 * The dialog returns the configured classpath entry path or <code>null</code> if the dialog has
310 * been canceled. The dialog does not apply any changes.
312 * @param shell The parent shell for the dialog.
313 * @param initialEntry The path of the initial archive entry
314 * @param usedEntries An array of paths that are already on the classpath and therefore should not be
316 * @return Returns the configured JAR path or <code>null</code> if the dialog has
317 * been canceled by the user.
319 public static IPath configureJAREntry(Shell shell, IPath initialEntry, IPath[] usedEntries) {
320 if (initialEntry == null || usedEntries == null) {
321 throw new IllegalArgumentException();
324 Class<?>[] acceptedClasses= new Class[] { IFile.class };
325 TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
327 ArrayList<IResource> usedJars= new ArrayList<IResource>(usedEntries.length);
328 IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
329 for (int i= 0; i < usedEntries.length; i++) {
330 IPath curr= usedEntries[i];
331 if (!curr.equals(initialEntry)) {
332 IResource resource= root.findMember(usedEntries[i]);
333 if (resource instanceof IFile) {
334 usedJars.add(resource);
339 IResource existing= root.findMember(initialEntry);
341 FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
342 dialog.setValidator(validator);
343 dialog.setTitle(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_title);
344 dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_description);
345 dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING);
346 dialog.addFilter(new ArchiveFileFilter(usedJars, true, true));
347 dialog.setInput(root);
348 dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
349 dialog.setInitialSelection(existing);
351 if (dialog.open() == Window.OK) {
352 IResource element= (IResource) dialog.getFirstResult();
353 return element.getFullPath();
359 * Shows the UI to select new JAR or ZIP archive entries located in the workspace.
360 * The dialog returns the selected entries or <code>null</code> if the dialog has
361 * been canceled. The dialog does not apply any changes.
363 * @param shell The parent shell for the dialog.
364 * @param initialSelection The path of the element (container or archive) to initially select or <code>null</code> to not select an entry.
365 * @param usedEntries An array of paths that are already on the classpath and therefore should not be
367 * @return Returns the new JAR paths or <code>null</code> if the dialog has
368 * been canceled by the user.
370 public static IPath[] chooseJAREntries(Shell shell, IPath initialSelection, IPath[] usedEntries) {
371 if (usedEntries == null) {
372 throw new IllegalArgumentException();
375 Class<?>[] acceptedClasses= new Class[] { IFile.class };
376 TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
377 ArrayList<IResource> usedJars= new ArrayList<IResource>(usedEntries.length);
378 IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
379 for (int i= 0; i < usedEntries.length; i++) {
380 IResource resource= root.findMember(usedEntries[i]);
381 if (resource instanceof IFile) {
382 usedJars.add(resource);
385 IResource focus= initialSelection != null ? root.findMember(initialSelection) : null;
387 FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
388 dialog.setHelpAvailable(false);
389 dialog.setValidator(validator);
390 dialog.setTitle(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_title);
391 dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_description);
392 dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING);
393 dialog.addFilter(new ArchiveFileFilter(usedJars, true, true));
394 dialog.setInput(root);
395 dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
396 dialog.setInitialSelection(focus);
398 if (dialog.open() == Window.OK) {
399 Object[] elements= dialog.getResult();
400 IPath[] res= new IPath[elements.length];
401 for (int i= 0; i < res.length; i++) {
402 IResource elem= (IResource)elements[i];
403 res[i]= elem.getFullPath();
411 * Shows the UI to configure an external JAR or ZIP archive.
412 * The dialog returns the configured or <code>null</code> if the dialog has
413 * been canceled. The dialog does not apply any changes.
415 * @param shell The parent shell for the dialog.
416 * @param initialEntry The path of the initial archive entry.
417 * @return Returns the configured external JAR path or <code>null</code> if the dialog has
418 * been canceled by the user.
420 public static IPath configureExternalJAREntry(Shell shell, IPath initialEntry) {
421 if (initialEntry == null) {
422 throw new IllegalArgumentException();
425 String lastUsedPath= initialEntry.removeLastSegments(1).toOSString();
427 FileDialog dialog= new FileDialog(shell, SWT.SINGLE);
428 dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtJARArchiveDialog_edit_title);
429 dialog.setFilterExtensions(ArchiveFileFilter.JAR_ZIP_FILTER_EXTENSIONS);
430 dialog.setFilterPath(lastUsedPath);
431 dialog.setFileName(initialEntry.lastSegment());
433 String res= dialog.open();
437 JavaPlugin.getDefault().getDialogSettings().put(IUIConstants.DIALOGSTORE_LASTEXTJAR, dialog.getFilterPath());
439 return Path.fromOSString(res).makeAbsolute();
443 * Shows the UI to select new external JAR or ZIP archive entries.
444 * The dialog returns the selected entry paths or <code>null</code> if the dialog has
445 * been canceled. The dialog does not apply any changes.
447 * @param shell The parent shell for the dialog.
448 * @return Returns the new external JAR paths or <code>null</code> if the dialog has
449 * been canceled by the user.
451 public static IPath[] chooseExternalJAREntries(Shell shell) {
452 String lastUsedPath= JavaPlugin.getDefault().getDialogSettings().get(IUIConstants.DIALOGSTORE_LASTEXTJAR);
453 if (lastUsedPath == null) {
454 lastUsedPath= ""; //$NON-NLS-1$
456 FileDialog dialog= new FileDialog(shell, SWT.MULTI);
457 dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtJARArchiveDialog_new_title);
458 dialog.setFilterExtensions(ArchiveFileFilter.ALL_ARCHIVES_FILTER_EXTENSIONS);
459 dialog.setFilterPath(lastUsedPath);
461 String res= dialog.open();
465 String[] fileNames= dialog.getFileNames();
466 int nChosen= fileNames.length;
468 IPath filterPath= Path.fromOSString(dialog.getFilterPath());
469 IPath[] elems= new IPath[nChosen];
470 for (int i= 0; i < nChosen; i++) {
471 elems[i]= filterPath.append(fileNames[i]).makeAbsolute();
473 JavaPlugin.getDefault().getDialogSettings().put(IUIConstants.DIALOGSTORE_LASTEXTJAR, dialog.getFilterPath());
479 * Shows the UI to select new external class folder entries.
480 * The dialog returns the selected entry paths or <code>null</code> if the dialog has
481 * been canceled. The dialog does not apply any changes.
483 * @param shell The parent shell for the dialog.
484 * @return Returns the new external class folder path or <code>null</code> if the dialog has
485 * been canceled by the user.
489 public static IPath[] chooseExternalClassFolderEntries(Shell shell) {
490 String lastUsedPath= JavaPlugin.getDefault().getDialogSettings().get(IUIConstants.DIALOGSTORE_LASTEXTJARFOLDER);
491 if (lastUsedPath == null) {
492 lastUsedPath= ""; //$NON-NLS-1$
494 DirectoryDialog dialog= new DirectoryDialog(shell, SWT.MULTI);
495 dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_new_title);
496 dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_new_description);
497 dialog.setFilterPath(lastUsedPath);
499 String res= dialog.open();
504 File file= new File(res);
505 if (file.isDirectory())
506 return new IPath[] { new Path(file.getAbsolutePath()) };
512 * Shows the UI to configure an external class folder.
513 * The dialog returns the configured or <code>null</code> if the dialog has
514 * been canceled. The dialog does not apply any changes.
516 * @param shell The parent shell for the dialog.
517 * @param initialEntry The path of the initial archive entry.
518 * @return Returns the configured external class folder path or <code>null</code> if the dialog has
519 * been canceled by the user.
523 public static IPath configureExternalClassFolderEntries(Shell shell, IPath initialEntry) {
524 DirectoryDialog dialog= new DirectoryDialog(shell, SWT.SINGLE);
525 dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_edit_title);
526 dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_edit_description);
527 dialog.setFilterPath(initialEntry.toString());
529 String res= dialog.open();
534 File file= new File(res);
535 if (file.isDirectory())
536 return new Path(file.getAbsolutePath());
542 * Shows the UI to select new class folders.
543 * The dialog returns the selected class folder entry paths or <code>null</code> if the dialog has
544 * been canceled. The dialog does not apply any changes.
546 * @param shell The parent shell for the dialog.
547 * @param initialSelection The path of the element to initially select or <code>null</code>.
548 * @param usedEntries An array of paths that are already on the classpath and therefore should not be
550 * @return Returns the configured class folder paths or <code>null</code> if the dialog has
551 * been canceled by the user.
553 public static IPath[] chooseClassFolderEntries(Shell shell, IPath initialSelection, IPath[] usedEntries) {
554 if (usedEntries == null) {
555 throw new IllegalArgumentException();
557 String title= NewWizardMessages.BuildPathDialogAccess_ExistingClassFolderDialog_new_title;
558 String message= NewWizardMessages.BuildPathDialogAccess_ExistingClassFolderDialog_new_description;
559 return internalChooseFolderEntry(shell, initialSelection, usedEntries, title, message);
563 * Shows the UI to select new source folders.
564 * The dialog returns the selected classpath entry paths or <code>null</code> if the dialog has
565 * been canceled. The dialog does not apply any changes.
567 * @param shell The parent shell for the dialog.
568 * @param initialSelection The path of the element to initially select or <code>null</code>
569 * @param usedEntries An array of paths that are already on the classpath and therefore should not be
571 * @return Returns the configured class folder entry paths or <code>null</code> if the dialog has
572 * been canceled by the user.
574 public static IPath[] chooseSourceFolderEntries(Shell shell, IPath initialSelection, IPath[] usedEntries) {
575 if (usedEntries == null) {
576 throw new IllegalArgumentException();
578 String title= NewWizardMessages.BuildPathDialogAccess_ExistingSourceFolderDialog_new_title;
579 String message= NewWizardMessages.BuildPathDialogAccess_ExistingSourceFolderDialog_new_description;
580 return internalChooseFolderEntry(shell, initialSelection, usedEntries, title, message);
584 private static IPath[] internalChooseFolderEntry(Shell shell, IPath initialSelection, IPath[] usedEntries, String title, String message) {
585 Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
587 ArrayList<IResource> usedContainers= new ArrayList<IResource>(usedEntries.length);
588 IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
589 for (int i= 0; i < usedEntries.length; i++) {
590 IResource resource= root.findMember(usedEntries[i]);
591 if (resource instanceof IContainer) {
592 usedContainers.add(resource);
596 IResource focus= initialSelection != null ? root.findMember(initialSelection) : null;
597 Object[] used= usedContainers.toArray();
599 MultipleFolderSelectionDialog dialog= new MultipleFolderSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
600 dialog.setExisting(used);
601 dialog.setTitle(title);
602 dialog.setMessage(message);
603 dialog.setHelpAvailable(false);
604 dialog.addFilter(new TypedViewerFilter(acceptedClasses, used));
605 dialog.setInput(root);
606 dialog.setInitialFocus(focus);
608 if (dialog.open() == Window.OK) {
609 Object[] elements= dialog.getResult();
610 IPath[] res= new IPath[elements.length];
611 for (int i= 0; i < res.length; i++) {
612 IResource elem= (IResource) elements[i];
613 res[i]= elem.getFullPath();