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