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