4f37f42ecfdfd3a4a98ccfbd93e0e8c46b1dcaa1
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ui / JavaUI.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.ui;
12
13 import net.sourceforge.phpdt.core.IBufferFactory;
14 import net.sourceforge.phpdt.core.IJavaElement;
15 import net.sourceforge.phpdt.core.IWorkingCopy;
16 import net.sourceforge.phpdt.core.JavaCore;
17 import net.sourceforge.phpdt.core.JavaModelException;
18 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
19 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
20
21 import org.eclipse.ui.IEditorPart;
22 import org.eclipse.ui.ISharedImages;
23 import org.eclipse.ui.PartInitException;
24 import org.eclipse.ui.internal.SharedImages;
25 import org.eclipse.ui.texteditor.IDocumentProvider;
26
27 /**
28  * Central access point for the Java UI plug-in (id
29  * <code>"net.sourceforge.phpdt.ui"</code>). This class provides static
30  * methods for:
31  * <ul>
32  * <li> creating various kinds of selection dialogs to present a collection of
33  * Java elements to the user and let them make a selection.</li>
34  * <li> opening a Java editor on a compilation unit.</li>
35  * </ul>
36  * <p>
37  * This class provides static methods and fields only; it is not intended to be
38  * instantiated or subclassed by clients.
39  * </p>
40  */
41 public final class JavaUI {
42
43         private static ISharedImages fgSharedImages = null;
44
45         private JavaUI() {
46                 // prevent instantiation of JavaUI.
47         }
48
49         /**
50          * The id of the Java plugin (value <code>"net.sourceforge.phpdt.ui"</code>).
51          */
52         // public static final String ID_PLUGIN= "net.sourceforge.phpdt.ui";
53         // //$NON-NLS-1$
54         /**
55          * The id of the Java perspective (value
56          * <code>"net.sourceforge.phpdt.ui.JavaPerspective"</code>).
57          */
58         // public static final String ID_PERSPECTIVE=
59         // "net.sourceforge.phpdt.ui.JavaPerspective"; //$NON-NLS-1$
60         /**
61          * The id of the Java hierarchy perspective (value
62          * <code>"net.sourceforge.phpdt.ui.JavaHierarchyPerspective"</code>).
63          */
64         // public static final String ID_HIERARCHYPERSPECTIVE=
65         // "net.sourceforge.phpdt.ui.JavaHierarchyPerspective"; //$NON-NLS-1$
66         /**
67          * The id of the Java action set (value
68          * <code>"net.sourceforge.phpdt.ui.JavaActionSet"</code>).
69          */
70         // public static final String ID_ACTION_SET=
71         // "net.sourceforge.phpdt.ui.JavaActionSet"; //$NON-NLS-1$
72         /**
73          * The id of the Java Element Creation action set (value
74          * <code>"net.sourceforge.phpdt.ui.JavaElementCreationActionSet"</code>).
75          * 
76          * @since 2.0
77          */
78         // public static final String ID_ELEMENT_CREATION_ACTION_SET=
79         // "net.sourceforge.phpdt.ui.JavaElementCreationActionSet"; //$NON-NLS-1$
80         /**
81          * The id of the Java Coding action set (value
82          * <code>"net.sourceforge.phpdt.ui.CodingActionSet"</code>).
83          * 
84          * @since 2.0
85          */
86         // public static final String ID_CODING_ACTION_SET=
87         // "net.sourceforge.phpdt.ui.CodingActionSet"; //$NON-NLS-1$
88         /**
89          * The id of the Java action set for open actions (value
90          * <code>"net.sourceforge.phpdt.ui.A_OpenActionSet"</code>).
91          * 
92          * @since 2.0
93          */
94         // public static final String ID_OPEN_ACTION_SET=
95         // "net.sourceforge.phpdt.ui.A_OpenActionSet"; //$NON-NLS-1$
96         /**
97          * The id of the Java Search action set (value
98          * <code>net.sourceforge.phpdt.ui.SearchActionSet"</code>).
99          * 
100          * @since 2.0
101          */
102         // public static final String ID_SEARCH_ACTION_SET=
103         // "net.sourceforge.phpdt.ui.SearchActionSet"; //$NON-NLS-1$
104         /**
105          * The editor part id of the editor that presents Java compilation units
106          * (value <code>"net.sourceforge.phpdt.ui.CompilationUnitEditor"</code>).
107          */
108         // public static final String ID_CU_EDITOR=
109         // "net.sourceforge.phpdt.ui.PHPUnitEditor"; //$NON-NLS-1$
110         /**
111          * The editor part id of the editor that presents Java binary class files
112          * (value <code>"net.sourceforge.phpdt.ui.ClassFileEditor"</code>).
113          */
114         // public static final String ID_CF_EDITOR=
115         // "net.sourceforge.phpdt.ui.ClassFileEditor"; //$NON-NLS-1$
116         /**
117          * The editor part id of the code snippet editor (value
118          * <code>"net.sourceforge.phpdt.ui.SnippetEditor"</code>).
119          */
120         // public static final String ID_SNIPPET_EDITOR=
121         // "net.sourceforge.phpdt.ui.SnippetEditor"; //$NON-NLS-1$
122         /**
123          * The view part id of the Packages view (value
124          * <code>"net.sourceforge.phpdt.ui.PackageExplorer"</code>).
125          * <p>
126          * When this id is used to access a view part with
127          * <code>IWorkbenchPage.findView</code> or <code>showView</code>, the
128          * returned <code>IViewPart</code> can be safely cast to an
129          * <code>IPackagesViewPart</code>.
130          * </p>
131          * 
132          * @see IPackagesViewPart
133          * @see org.eclipse.ui.IWorkbenchPage#findView(java.lang.String)
134          * @see org.eclipse.ui.IWorkbenchPage#showView(java.lang.String)
135          */
136         public static final String ID_PACKAGES = "net.sourceforge.phpdt.ui.PackageExplorer"; //$NON-NLS-1$
137
138         /**
139          * The view part id of the type hierarchy part. (value
140          * <code>"net.sourceforge.phpdt.ui.TypeHierarchy"</code>).
141          * <p>
142          * When this id is used to access a view part with
143          * <code>IWorkbenchPage.findView</code> or <code>showView</code>, the
144          * returned <code>IViewPart</code> can be safely cast to an
145          * <code>ITypeHierarchyViewPart</code>.
146          * </p>
147          * 
148          * @see ITypeHierarchyViewPart
149          * @see org.eclipse.ui.IWorkbenchPage#findView(java.lang.String)
150          * @see org.eclipse.ui.IWorkbenchPage#showView(java.lang.String)
151          */
152         public static final String ID_TYPE_HIERARCHY = "net.sourceforge.phpdt.ui.TypeHierarchy"; //$NON-NLS-1$
153
154         /**
155          * The id of the Java Browsing Perspective (value
156          * <code>"net.sourceforge.phpdt.ui.JavaBrowsingPerspective"</code>).
157          * 
158          * @since 2.0
159          */
160         // public static String ID_BROWSING_PERSPECTIVE=
161         // "net.sourceforge.phpdt.ui.JavaBrowsingPerspective"; //$NON-NLS-1$
162         /**
163          * The view part id of the Java Browsing Projects view (value
164          * <code>"net.sourceforge.phpdt.ui.ProjectsView"</code>).
165          * 
166          * @since 2.0
167          */
168         // public static String ID_PROJECTS_VIEW=
169         // "net.sourceforge.phpdt.ui.ProjectsView"; //$NON-NLS-1$
170         /**
171          * The view part id of the Java Browsing Packages view (value
172          * <code>"net.sourceforge.phpdt.ui.PackagesView"</code>).
173          * 
174          * @since 2.0
175          */
176         // public static String ID_PACKAGES_VIEW=
177         // "net.sourceforge.phpdt.ui.PackagesView"; //$NON-NLS-1$
178         /**
179          * The view part id of the Java Browsing Types view (value
180          * <code>"net.sourceforge.phpdt.ui.TypesView"</code>).
181          * 
182          * @since 2.0
183          */
184         // public static String ID_TYPES_VIEW= "net.sourceforge.phpdt.ui.TypesView";
185         // //$NON-NLS-1$
186         /**
187          * The view part id of the Java Browsing Members view (value
188          * <code>"net.sourceforge.phpdt.ui.MembersView"</code>).
189          * 
190          * @since 2.0
191          */
192         // public static String ID_MEMBERS_VIEW=
193         // "net.sourceforge.phpdt.ui.MembersView"; //$NON-NLS-1$
194         /**
195          * The class org.eclipse.debug.core.model.IProcess allows attaching String
196          * properties to processes. The Java UI contributes a property page for
197          * IProcess that will show the contents of the property with this key. The
198          * intent of this property is to show the command line a process was
199          * launched with.
200          * 
201          * @deprecated
202          */
203         // public final static String ATTR_CMDLINE=
204         // "net.sourceforge.phpdt.ui.launcher.cmdLine"; //$NON-NLS-1$
205         /**
206          * Returns the shared images for the Java UI.
207          * 
208          * @return the shared images manager
209          */
210         public static ISharedImages getSharedImages() {
211                 if (fgSharedImages == null)
212                         fgSharedImages = new SharedImages();
213
214                 return fgSharedImages;
215         }
216
217         /**
218          * Creates a selection dialog that lists all packages of the given Java
219          * project. The caller is responsible for opening the dialog with
220          * <code>Window.open</code>, and subsequently extracting the selected
221          * package (of type <code>IPackageFragment</code>) via
222          * <code>SelectionDialog.getResult</code>.
223          * 
224          * @param parent
225          *            the parent shell of the dialog to be created
226          * @param project
227          *            the Java project
228          * @param style
229          *            flags defining the style of the dialog; the valid flags are:
230          *            <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>,
231          *            indicating that packages from binary package fragment roots
232          *            should be included in addition to those from source package
233          *            fragment roots;
234          *            <code>IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS</code>,
235          *            indicating that packages from required projects should be
236          *            included as well.
237          * @param filter
238          *            the initial pattern to filter the set of packages. For example
239          *            "com" shows all packages starting with "com". The meta
240          *            character '?' representing any character and '*' representing
241          *            any string are supported. Clients can pass an empty string if
242          *            no filtering is required.
243          * @return a new selection dialog
244          * @exception JavaModelException
245          *                if the selection dialog could not be opened
246          * 
247          * @since 2.0
248          */
249         // public static SelectionDialog createPackageDialog(Shell parent,
250         // IJavaProject project, int style, String filter) throws JavaModelException
251         // {
252         // Assert.isTrue((style | IJavaElementSearchConstants.CONSIDER_BINARIES |
253         // IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) ==
254         // (IJavaElementSearchConstants.CONSIDER_BINARIES |
255         // IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS));
256         //
257         // IPackageFragmentRoot[] roots= null;
258         // if ((style & IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) !=
259         // 0) {
260         // roots= project.getAllPackageFragmentRoots();
261         // } else {
262         // roots= project.getPackageFragmentRoots();
263         // }
264         //              
265         // List consideredRoots= null;
266         // if ((style & IJavaElementSearchConstants.CONSIDER_BINARIES) != 0) {
267         // consideredRoots= Arrays.asList(roots);
268         // } else {
269         // consideredRoots= new ArrayList(roots.length);
270         // for (int i= 0; i < roots.length; i++) {
271         // IPackageFragmentRoot root= roots[i];
272         // if (root.getKind() != IPackageFragmentRoot.K_BINARY)
273         // consideredRoots.add(root);
274         //                                      
275         // }
276         // }
277         //              
278         // int flags= JavaElementLabelProvider.SHOW_DEFAULT;
279         // if (consideredRoots.size() > 1)
280         // flags= flags | JavaElementLabelProvider.SHOW_ROOT;
281         //
282         // List packages= new ArrayList();
283         // Iterator iter= consideredRoots.iterator();
284         // while(iter.hasNext()) {
285         // IPackageFragmentRoot root= (IPackageFragmentRoot)iter.next();
286         // packages.addAll(Arrays.asList(root.getChildren()));
287         // }
288         // ElementListSelectionDialog dialog= new ElementListSelectionDialog(parent,
289         // new JavaElementLabelProvider(flags));
290         // dialog.setIgnoreCase(false);
291         // dialog.setElements(packages.toArray()); // XXX inefficient
292         // dialog.setFilter(filter);
293         // return dialog;
294         // }
295         /**
296          * Creates a selection dialog that lists all packages of the given Java
297          * project. The caller is responsible for opening the dialog with
298          * <code>Window.open</code>, and subsequently extracting the selected
299          * package (of type <code>IPackageFragment</code>) via
300          * <code>SelectionDialog.getResult</code>.
301          * 
302          * @param parent
303          *            the parent shell of the dialog to be created
304          * @param project
305          *            the Java project
306          * @param style
307          *            flags defining the style of the dialog; the valid flags are:
308          *            <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>,
309          *            indicating that packages from binary package fragment roots
310          *            should be included in addition to those from source package
311          *            fragment roots;
312          *            <code>IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS</code>,
313          *            indicating that packages from required projects should be
314          *            included as well.
315          * @return a new selection dialog
316          * @exception JavaModelException
317          *                if the selection dialog could not be opened
318          */
319         // public static SelectionDialog createPackageDialog(Shell parent,
320         // IJavaProject project, int style) throws JavaModelException {
321         // return createPackageDialog(parent, project, style, ""); //$NON-NLS-1$
322         // }
323         /**
324          * Creates a selection dialog that lists all packages under the given
325          * package fragment root. The caller is responsible for opening the dialog
326          * with <code>Window.open</code>, and subsequently extracting the
327          * selected package (of type <code>IPackageFragment</code>) via
328          * <code>SelectionDialog.getResult</code>.
329          * 
330          * @param parent
331          *            the parent shell of the dialog to be created
332          * @param root
333          *            the package fragment root
334          * @param filter
335          *            the initial pattern to filter the set of packages. For example
336          *            "com" shows all packages starting with "com". The meta
337          *            character '?' representing any character and '*' representing
338          *            any string are supported. Clients can pass an empty string if
339          *            no filtering is required.
340          * @return a new selection dialog
341          * @exception JavaModelException
342          *                if the selection dialog could not be opened
343          * 
344          * @since 2.0
345          */
346         // public static SelectionDialog createPackageDialog(Shell parent,
347         // IPackageFragmentRoot root, String filter) throws JavaModelException {
348         // ElementListSelectionDialog dialog= new ElementListSelectionDialog(parent,
349         // new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT));
350         // dialog.setIgnoreCase(false);
351         // dialog.setElements(root.getChildren());
352         // dialog.setFilter(filter);
353         // return dialog;
354         // }
355         /**
356          * Creates a selection dialog that lists all packages under the given
357          * package fragment root. The caller is responsible for opening the dialog
358          * with <code>Window.open</code>, and subsequently extracting the
359          * selected package (of type <code>IPackageFragment</code>) via
360          * <code>SelectionDialog.getResult</code>.
361          * 
362          * @param parent
363          *            the parent shell of the dialog to be created
364          * @param root
365          *            the package fragment root
366          * @return a new selection dialog
367          * @exception JavaModelException
368          *                if the selection dialog could not be opened
369          */
370         // public static SelectionDialog createPackageDialog(Shell parent,
371         // IPackageFragmentRoot root) throws JavaModelException {
372         // return createPackageDialog(parent, root, ""); //$NON-NLS-1$
373         // }
374         /**
375          * Creates a selection dialog that lists all types in the given scope. The
376          * caller is responsible for opening the dialog with
377          * <code>Window.open</code>, and subsequently extracting the selected
378          * type(s) (of type <code>IType</code>) via
379          * <code>SelectionDialog.getResult</code>.
380          * 
381          * @param parent
382          *            the parent shell of the dialog to be created
383          * @param context
384          *            the runnable context used to show progress when the dialog is
385          *            being populated
386          * @param scope
387          *            the scope that limits which types are included
388          * @param style
389          *            flags defining the style of the dialog; the only valid values
390          *            are <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
391          *            <code>CONSIDER_INTERFACES</code>, or their bitwise OR
392          *            (equivalent to <code>CONSIDER_TYPES</code>)
393          * @param multipleSelection
394          *            <code>true</code> if multiple selection is allowed
395          * @param filter
396          *            the initial pattern to filter the set of types. For example
397          *            "Abstract" shows all types starting with "abstract". The meta
398          *            character '?' representing any character and '*' representing
399          *            any string are supported. Clients can pass an empty string if
400          *            no filtering is required.
401          * @exception JavaModelException
402          *                if the selection dialog could not be opened
403          * 
404          * @since 2.0
405          */
406         // public static SelectionDialog createTypeDialog(Shell parent,
407         // IRunnableContext context, IJavaSearchScope scope, int style, boolean
408         // multipleSelection, String filter) throws JavaModelException {
409         // int elementKinds= 0;
410         // if (style == IJavaElementSearchConstants.CONSIDER_TYPES) {
411         // elementKinds= IJavaSearchConstants.TYPE;
412         // } else if (style == IJavaElementSearchConstants.CONSIDER_INTERFACES) {
413         // elementKinds= IJavaSearchConstants.INTERFACE;
414         // } else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES) {
415         // elementKinds= IJavaSearchConstants.CLASS;
416         // } else {
417         // Assert.isTrue(false, "illegal style"); //$NON-NLS-1$
418         // }
419         // if (multipleSelection) {
420         // MultiTypeSelectionDialog dialog= new MultiTypeSelectionDialog(parent,
421         // context, elementKinds, scope);
422         // dialog.setMessage(JavaUIMessages.getString("JavaUI.defaultDialogMessage"));
423         // //$NON-NLS-1$
424         // dialog.setFilter(filter);
425         // return dialog;
426         // } else {
427         // TypeSelectionDialog dialog= new TypeSelectionDialog(parent, context,
428         // elementKinds, scope);
429         // dialog.setMessage(JavaUIMessages.getString("JavaUI.defaultDialogMessage"));
430         // //$NON-NLS-1$
431         // dialog.setFilter(filter);
432         // return dialog;
433         // }
434         // }
435         /**
436          * Creates a selection dialog that lists all types in the given scope. The
437          * caller is responsible for opening the dialog with
438          * <code>Window.open</code>, and subsequently extracting the selected
439          * type(s) (of type <code>IType</code>) via
440          * <code>SelectionDialog.getResult</code>.
441          * 
442          * @param parent
443          *            the parent shell of the dialog to be created
444          * @param context
445          *            the runnable context used to show progress when the dialog is
446          *            being populated
447          * @param scope
448          *            the scope that limits which types are included
449          * @param style
450          *            flags defining the style of the dialog; the only valid values
451          *            are <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
452          *            <code>CONSIDER_INTERFACES</code>, or their bitwise OR
453          *            (equivalent to <code>CONSIDER_TYPES</code>)
454          * @param multipleSelection
455          *            <code>true</code> if multiple selection is allowed
456          * @return a new selection dialog
457          * @exception JavaModelException
458          *                if the selection dialog could not be opened
459          */
460         // public static SelectionDialog createTypeDialog(Shell parent,
461         // IRunnableContext context, IJavaSearchScope scope, int style, boolean
462         // multipleSelection) throws JavaModelException {
463         // return createTypeDialog(parent, context, scope, style, multipleSelection,
464         // "");//$NON-NLS-1$
465         // }
466         /**
467          * Creates a selection dialog that lists all types in the given scope
468          * containing a standard <code>main</code> method. The caller is
469          * responsible for opening the dialog with <code>Window.open</code>, and
470          * subsequently extracting the selected type(s) (of type <code>IType</code>)
471          * via <code>SelectionDialog.getResult</code>.
472          * 
473          * @param parent
474          *            the parent shell of the dialog to be created
475          * @param context
476          *            the runnable context used to show progress when the dialog is
477          *            being populated
478          * @param scope
479          *            the scope that limits which types are included
480          * @param style
481          *            flags defining the style of the dialog; the only valid values
482          *            are <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>,
483          *            <code>CONSIDER_EXTERNAL_JARS</code>, or their bitwise OR,
484          *            or <code>0</code>
485          * @param multipleSelection
486          *            <code>true</code> if multiple selection is allowed
487          * @param filter
488          *            the initial pattern to filter the set of types containg a main
489          *            method. For example "App" shows all types starting with "app".
490          *            The meta character '?' representing any character and '*'
491          *            representing any string are supported. Clients can pass an
492          *            empty string if no filtering is required.
493          * @return a new selection dialog
494          * 
495          * @since 2.0
496          */
497         // public static SelectionDialog createMainTypeDialog(Shell parent,
498         // IRunnableContext context, IJavaSearchScope scope, int style, boolean
499         // multipleSelection, String filter) {
500         // if (multipleSelection) {
501         // MultiMainTypeSelectionDialog dialog= new
502         // MultiMainTypeSelectionDialog(parent, context, scope, style);
503         // dialog.setFilter(filter);
504         // return dialog;
505         // } else {
506         // MainTypeSelectionDialog dialog= new MainTypeSelectionDialog(parent,
507         // context, scope, style);
508         // dialog.setFilter(filter);
509         // return dialog;
510         // }
511         // }
512         /**
513          * Creates a selection dialog that lists all types in the given scope
514          * containing a standard <code>main</code> method. The caller is
515          * responsible for opening the dialog with <code>Window.open</code>, and
516          * subsequently extracting the selected type(s) (of type <code>IType</code>)
517          * via <code>SelectionDialog.getResult</code>.
518          * 
519          * @param parent
520          *            the parent shell of the dialog to be created
521          * @param context
522          *            the runnable context used to show progress when the dialog is
523          *            being populated
524          * @param scope
525          *            the scope that limits which types are included
526          * @param style
527          *            flags defining the style of the dialog; the only valid values
528          *            are <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>,
529          *            <code>CONSIDER_EXTERNAL_JARS</code>, or their bitwise OR,
530          *            or <code>0</code>
531          * @param multipleSelection
532          *            <code>true</code> if multiple selection is allowed
533          * @return a new selection dialog
534          */
535         // public static SelectionDialog createMainTypeDialog(Shell parent,
536         // IRunnableContext context, IJavaSearchScope scope, int style, boolean
537         // multipleSelection) {
538         // return createMainTypeDialog(parent, context, scope, style,
539         // multipleSelection, "");//$NON-NLS-1$
540         // }
541         /**
542          * Creates a selection dialog that lists all types in the given project. The
543          * caller is responsible for opening the dialog with
544          * <code>Window.open</code>, and subsequently extracting the selected
545          * type(s) (of type <code>IType</code>) via
546          * <code>SelectionDialog.getResult</code>.
547          * 
548          * @param parent
549          *            the parent shell of the dialog to be created
550          * @param context
551          *            the runnable context used to show progress when the dialog is
552          *            being populated
553          * @param project
554          *            the Java project
555          * @param style
556          *            flags defining the style of the dialog; the only valid values
557          *            are <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
558          *            <code>CONSIDER_INTERFACES</code>, or their bitwise OR
559          *            (equivalent to <code>CONSIDER_TYPES</code>)
560          * @param multipleSelection
561          *            <code>true</code> if multiple selection is allowed
562          * @return a new selection dialog
563          * @exception JavaModelException
564          *                if the selection dialog could not be opened
565          */
566         // public static SelectionDialog createTypeDialog(Shell parent,
567         // IRunnableContext context, IProject project, int style, boolean
568         // multipleSelection) throws JavaModelException {
569         // IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new
570         // IJavaProject[] { JavaCore.create(project) });
571         // return createTypeDialog(parent, context, scope, style,
572         // multipleSelection);
573         // }
574         /**
575          * Opens a Java editor on the given Java element. The element can be a
576          * compilation unit or class file. If there already is an open Java editor
577          * for the given element, it is returned.
578          * 
579          * @param element
580          *            the input element; either a compilation unit (<code>ICompilationUnit</code>)
581          *            or a class file (</code>IClassFile</code>)
582          * @return the editor, or </code>null</code> if wrong element type or
583          *         opening failed
584          * @exception PartInitException
585          *                if the editor could not be initialized
586          * @exception JavaModelException
587          *                if this element does not exist or if an exception occurs
588          *                while accessing its underlying resource
589          */
590         public static IEditorPart openInEditor(IJavaElement element)
591                         throws JavaModelException, PartInitException {
592                 return EditorUtility.openInEditor(element);
593         }
594
595         /**
596          * Reveals the source range of the given source reference element in the
597          * given editor. No checking is done if the editor displays a compilation
598          * unit or class file that contains the given source reference. The editor
599          * simply reveals the source range denoted by the given source reference.
600          * 
601          * @param part
602          *            the editor displaying the compilation unit or class file
603          * @param element
604          *            the source reference element defining the source range to be
605          *            revealed
606          * 
607          * @deprecated use <code>revealInEditor(IEditorPart, IJavaElement)</code>
608          *             instead
609          */
610         // public static void revealInEditor(IEditorPart part, ISourceReference
611         // element) {
612         // if (element instanceof IJavaElement)
613         // revealInEditor(part, (IJavaElement) element);
614         // }
615         /**
616          * Reveals the given java element in the given editor. If the element is not
617          * an instance of <code>ISourceReference</code> this method result in a
618          * NOP. If it is a source reference no checking is done if the editor
619          * displays a compilation unit or class file that contains the source
620          * reference element. The editor simply reveals the source range denoted by
621          * the given element.
622          * 
623          * @param part
624          *            the editor displaying a compilation unit or class file
625          * @param element
626          *            the element to be revealed
627          * 
628          * @since 2.0
629          */
630         // public static void revealInEditor(IEditorPart part, IJavaElement element)
631         // {
632         // EditorUtility.revealInEditor(part, element);
633         // }
634         /**
635          * Returns the working copy manager for the Java UI plug-in.
636          * 
637          * @return the working copy manager for the Java UI plug-in
638          */
639         public static IWorkingCopyManager getWorkingCopyManager() {
640                 return PHPeclipsePlugin.getDefault().getWorkingCopyManager();
641         }
642
643         /**
644          * Answers the shared working copies currently registered for the Java
645          * plug-in. Note that the returned array can include working copies that are
646          * not on the class path of a Java project.
647          * 
648          * @return the list of shared working copies
649          * 
650          * @see net.sourceforge.phpdt.core.JavaCore#getSharedWorkingCopies(net.sourceforge.phpdt.core.IBufferFactory)
651          * @since 2.0
652          */
653         public static IWorkingCopy[] getSharedWorkingCopies() {
654                 return JavaCore.getSharedWorkingCopies(getBufferFactory());
655         }
656
657         /**
658          * Answers the shared working copies that are on the class path of a Java
659          * project currently registered for the Java plug-in.
660          * 
661          * 
662          * @return the list of shared working copies
663          * 
664          * @see #getSharedWorkingCopies()
665          * @since 2.1
666          */
667         // public static IWorkingCopy[] getSharedWorkingCopiesOnClasspath() {
668         // IWorkingCopy[] wcs= getSharedWorkingCopies();
669         // List result= new ArrayList(wcs.length);
670         // for (int i = 0; i < wcs.length; i++) {
671         // IWorkingCopy wc= wcs[i];
672         // if (wc instanceof IJavaElement) {
673         // IJavaElement je= (IJavaElement)wc;
674         // if (je.getJavaProject().isOnClasspath(je)) {
675         // result.add(wc);
676         // }
677         // }
678         // }
679         // return (IWorkingCopy[])result.toArray(new IWorkingCopy[result.size()]);
680         // }
681         /**
682          * Returns the BufferFactory for the Java UI plug-in.
683          * 
684          * @return the BufferFactory for the Java UI plug-in
685          * 
686          * @see net.sourceforge.phpdt.core.IBufferFactory
687          * @since 2.0
688          * @deprecated {@link IBufferFactory} has been replaced by
689          *             {@link net.sourceforge.phpdt.core.WorkingCopyOwner}. The
690          *             Java UI plug-in uses the <i>primary working copy owner</i>
691          *             that can be accessed with <code>null</code> in API's that
692          *             require an owner
693          */
694         public static IBufferFactory getBufferFactory() {
695                 return PHPeclipsePlugin.getDefault().getBufferFactory();
696         }
697
698         /**
699          * Returns the DocumentProvider used for Java compilation units.
700          * 
701          * @return the DocumentProvider for Java compilation units.
702          * 
703          * @see IDocumentProvider
704          * @since 2.0
705          */
706         public static IDocumentProvider getDocumentProvider() {
707                 return PHPeclipsePlugin.getDefault()
708                                 .getCompilationUnitDocumentProvider();
709         }
710
711         /**
712          * Sets the Javadoc location for an archive with the given path.
713          * 
714          * @param archivePath
715          *            the path of the library; this can be an workspace path or an
716          *            external path in case of an external library.
717          * @param url
718          *            The Javadoc location to set. This location should contain
719          *            index.html and a file 'package-list'. <code>null</code>
720          *            clears the current documentation location.
721          * 
722          * @since 2.0
723          */
724         // public static void setLibraryJavadocLocation(IPath archivePath, URL url)
725         // {
726         // JavaDocLocations.setLibraryJavadocLocation(archivePath, url);
727         // }
728         /**
729          * Returns the Javadoc location for an archive or <code>null</code> if no
730          * location is available.
731          * 
732          * @param archivePath
733          *            the path of the library. This can be an workspace path or an
734          *            external path in case of an external library.
735          * 
736          * @since 2.0
737          */
738         // public static URL getLibraryJavadocLocation(IPath archivePath) {
739         // return JavaDocLocations.getLibraryJavadocLocation(archivePath);
740         // }
741         /**
742          * Sets the Javadoc location for a Java project. This location is used for
743          * all types located in the project's source folders.
744          * 
745          * @param project
746          *            the project
747          * @param url
748          *            The Javadoc location to set. This location should contain
749          *            index.html and a file 'package-list'. <code>null</code>
750          *            clears the current documentation location.
751          * 
752          * @since 2.1
753          */
754         // public static void setProjectJavadocLocation(IJavaProject project, URL
755         // url) {
756         // JavaDocLocations.setProjectJavadocLocation(project, url);
757         // }
758         /**
759          * Returns the Javadoc location for a Java project or <code>null</code> if
760          * no location is available. This location is used for all types located in
761          * the project's source folders.
762          * 
763          * @param project
764          *            the project
765          * 
766          * @since 2.1
767          */
768         // public static URL getProjectJavadocLocation(IJavaProject project) {
769         // return JavaDocLocations.getProjectJavadocLocation(project);
770         // }
771         /**
772          * Returns the Javadoc base URL for an element. The base location contains
773          * the index file. This location doesn't have to exist. Returns
774          * <code>null</code> if no javadoc location has been attached to the
775          * element's library or project. Example of a returned URL is <i>http://www.
776          * junit. org/junit/javadoc</i>.
777          * 
778          * @param The
779          *            element for which the doc URL is requested.
780          * 
781          * @since 2.0
782          */
783         // public static URL getJavadocBaseLocation(IJavaElement element) throws
784         // JavaModelException {
785         // return JavaDocLocations.getJavadocBaseLocation(element);
786         // }
787         /**
788          * Returns the Javadoc URL for an element. Example of a returned URL is
789          * <i>http://www.junit.org/junit/javadoc/junit/extensions/TestSetup.html</i>.
790          * This returned location doesn't have to exist. Returns <code>null</code>
791          * if no javadoc location has been attached to the element's library or
792          * project.
793          * 
794          * @param The
795          *            element for which the doc URL is requested.
796          * @param includeAnchor
797          *            If set, the URL contains an anchor for member references:
798          *            <i>http://www.junit.org/junit/javadoc/junit/extensions/TestSetup.html#run(junit.framework.TestResult)</i>.
799          *            Note that this involves type resolving and is a more expensive
800          *            call than without anchor.
801          * 
802          * @since 2.0
803          */
804         // public static URL getJavadocLocation(IJavaElement element, boolean
805         // includeAnchor) throws JavaModelException {
806         // return JavaDocLocations.getJavadocLocation(element, includeAnchor);
807         // }
808 }