Lines 13-19
Link Here
|
13 |
import java.net.URL; |
13 |
import java.net.URL; |
14 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
15 |
import java.util.Arrays; |
15 |
import java.util.Arrays; |
16 |
import java.util.Iterator; |
|
|
17 |
import java.util.List; |
16 |
import java.util.List; |
18 |
|
17 |
|
19 |
import org.eclipse.core.runtime.IPath; |
18 |
import org.eclipse.core.runtime.IPath; |
Lines 28-34
Link Here
|
28 |
|
27 |
|
29 |
import org.eclipse.ui.IEditorPart; |
28 |
import org.eclipse.ui.IEditorPart; |
30 |
import org.eclipse.ui.PartInitException; |
29 |
import org.eclipse.ui.PartInitException; |
31 |
import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
|
|
32 |
import org.eclipse.ui.dialogs.SelectionDialog; |
30 |
import org.eclipse.ui.dialogs.SelectionDialog; |
33 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
31 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
34 |
|
32 |
|
Lines 53-60
Link Here
|
53 |
import org.eclipse.jdt.internal.ui.SharedImages; |
51 |
import org.eclipse.jdt.internal.ui.SharedImages; |
54 |
import org.eclipse.jdt.internal.ui.dialogs.MainTypeSelectionDialog; |
52 |
import org.eclipse.jdt.internal.ui.dialogs.MainTypeSelectionDialog; |
55 |
import org.eclipse.jdt.internal.ui.dialogs.MultiMainTypeSelectionDialog; |
53 |
import org.eclipse.jdt.internal.ui.dialogs.MultiMainTypeSelectionDialog; |
|
|
54 |
import org.eclipse.jdt.internal.ui.dialogs.PackageSelectionDialog; |
56 |
import org.eclipse.jdt.internal.ui.dialogs.TypeSelectionDialog2; |
55 |
import org.eclipse.jdt.internal.ui.dialogs.TypeSelectionDialog2; |
57 |
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; |
56 |
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; |
|
|
57 |
import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext; |
58 |
|
58 |
|
59 |
/** |
59 |
/** |
60 |
* Central access point for the Java UI plug-in (id <code>"org.eclipse.jdt.ui"</code>). |
60 |
* Central access point for the Java UI plug-in (id <code>"org.eclipse.jdt.ui"</code>). |
Lines 318-339
Link Here
|
318 |
} |
318 |
} |
319 |
} |
319 |
} |
320 |
|
320 |
|
321 |
int flags= JavaElementLabelProvider.SHOW_DEFAULT; |
321 |
IJavaSearchScope searchScope= SearchEngine.createJavaSearchScope((IJavaElement[])consideredRoots.toArray(new IJavaElement[consideredRoots.size()])); |
322 |
if (consideredRoots.size() > 1) |
322 |
BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext(); |
323 |
flags= flags | JavaElementLabelProvider.SHOW_ROOT; |
323 |
if (style == 0 || style == IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) { |
324 |
|
324 |
return createPackageDialog(parent, context, searchScope, false, true, filter); |
325 |
List packages= new ArrayList(); |
325 |
} else { |
326 |
Iterator iter= consideredRoots.iterator(); |
326 |
return createPackageDialog(parent, context, searchScope, false, false, filter); |
327 |
while(iter.hasNext()) { |
327 |
} |
328 |
IPackageFragmentRoot root= (IPackageFragmentRoot)iter.next(); |
328 |
} |
329 |
packages.addAll(Arrays.asList(root.getChildren())); |
329 |
|
330 |
} |
330 |
/** |
331 |
ElementListSelectionDialog dialog= new ElementListSelectionDialog(parent, new JavaElementLabelProvider(flags)); |
331 |
* Creates a selection dialog that lists all packages of the given Java search scope. |
332 |
dialog.setIgnoreCase(false); |
332 |
* The caller is responsible for opening the dialog with <code>Window.open</code>, |
333 |
dialog.setElements(packages.toArray()); // XXX inefficient |
333 |
* and subsequently extracting the selected package (of type |
|
|
334 |
* <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>. |
335 |
* |
336 |
* @param parent the parent shell of the dialog to be created |
337 |
* @param context the runnable context to run the search in |
338 |
* @param scope the scope defining the available packages. |
339 |
* @param multipleSelection true if multiple selection is allowed |
340 |
* @param removeDuplicates true if only one package is shown per package name |
341 |
* @param filter the initial pattern to filter the set of packages. For example "com" shows |
342 |
* all packages starting with "com". The meta character '?' representing any character and |
343 |
* '*' representing any string are supported. Clients can pass an empty string if no filtering |
344 |
* is required. |
345 |
* @return a new selection dialog |
346 |
* |
347 |
* @since 3.2 |
348 |
*/ |
349 |
public static SelectionDialog createPackageDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope, |
350 |
boolean multipleSelection, boolean removeDuplicates, String filter) { |
351 |
|
352 |
int flag= removeDuplicates?PackageSelectionDialog.F_REMOVE_DUPLICATES:0; |
353 |
PackageSelectionDialog dialog= new PackageSelectionDialog(parent, context, flag, scope); |
334 |
dialog.setFilter(filter); |
354 |
dialog.setFilter(filter); |
|
|
355 |
dialog.setIgnoreCase(false); |
356 |
dialog.setMultipleSelection(multipleSelection); |
335 |
return dialog; |
357 |
return dialog; |
336 |
} |
358 |
} |
|
|
359 |
|
360 |
/** |
361 |
* Creates a selection dialog that lists all packages of the given Java search scope. |
362 |
* The caller is responsible for opening the dialog with <code>Window.open</code>, |
363 |
* and subsequently extracting the selected package (of type |
364 |
* <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>. |
365 |
* |
366 |
* @param parent the parent shell of the dialog to be created |
367 |
* @param context the runnable context to run the search in |
368 |
* @param scope the scope defining the available packages. |
369 |
*/ |
370 |
public SelectionDialog createPackageDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope) { |
371 |
return createPackageDialog(parent, context, scope, false, true, ""); //$NON-NLS-1$ |
372 |
} |
337 |
|
373 |
|
338 |
/** |
374 |
/** |
339 |
* Creates a selection dialog that lists all packages of the given Java project. |
375 |
* Creates a selection dialog that lists all packages of the given Java project. |
Lines 375-385
Link Here
|
375 |
* @since 2.0 |
411 |
* @since 2.0 |
376 |
*/ |
412 |
*/ |
377 |
public static SelectionDialog createPackageDialog(Shell parent, IPackageFragmentRoot root, String filter) throws JavaModelException { |
413 |
public static SelectionDialog createPackageDialog(Shell parent, IPackageFragmentRoot root, String filter) throws JavaModelException { |
378 |
ElementListSelectionDialog dialog= new ElementListSelectionDialog(parent, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT)); |
414 |
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] {root}); |
379 |
dialog.setIgnoreCase(false); |
415 |
BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext(); |
380 |
dialog.setElements(root.getChildren()); |
416 |
return createPackageDialog(parent, context, scope, false, true, filter); |
381 |
dialog.setFilter(filter); |
|
|
382 |
return dialog; |
383 |
} |
417 |
} |
384 |
|
418 |
|
385 |
/** |
419 |
/** |