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