JavaScript Development Tools
Release 3.2

org.eclipse.wst.jsdt.ui
Class StandardJavaScriptElementContentProvider

java.lang.Object
  extended by org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider
All Implemented Interfaces:
IWorkingCopyProvider

public class StandardJavaScriptElementContentProvider
extends Object
implements IWorkingCopyProvider

A base content provider for JavaScriptelements. It provides access to the JavaScriptelement hierarchy without listening to changes in the JavaScriptmodel. If updating the presentation on JavaScript model change is required than clients have to subclass, listen to JavaScript model changes and have to update the UI using corresponding methods provided by the JFace viewers or their own UI presentation.

The following JavaScript element hierarchy is surfaced by this content provider:

JavaScript model (IJavaScriptModel)
   JavaScript project (IJavaScriptProject)
      package fragment root (IPackageFragmentRoot)
         package fragment (IPackageFragment)
            compilation unit (IJavaScriptUnit)
            binary class file (IClassFile)
 

Note that when the entire JavaScript project is declared to be package fragment root, the corresponding package fragment root element that normally appears between the JavaScript project and the package fragments is automatically filtered out.


Field Summary
protected  boolean fProvideMembers
           
protected  boolean fProvideWorkingCopy
           
protected static Object[] NO_CHILDREN
           
 
Constructor Summary
StandardJavaScriptElementContentProvider()
          Creates a new content provider.
StandardJavaScriptElementContentProvider(boolean provideMembers)
          Creates a new StandardJavaScriptElementContentProvider.
 
Method Summary
protected static Object[] concatenate(Object[] a1, Object[] a2)
          Note: This method is for internal use only.
 void dispose()
           
protected  boolean exists(Object element)
          Note: This method is for internal use only.
protected  IJavaScriptElement[] filter(IJavaScriptElement[] children)
           
 Object[] getChildren(Object element)
           
 Object[] getElements(Object parent)
           
protected  Object[] getFolderContent(IFolder folder)
          Evaluates all children of a given IFolder.
protected  Object[] getJavaProjects(IJavaScriptModel jm)
          Note: This method is for internal use only.
protected  Object[] getPackageContent(IPackageFragment fragment)
          Evaluates all children of a given IPackageFragment.
protected  Object[] getPackageFragmentRootContent(IPackageFragmentRoot root)
          Evaluates all children of a given IPackageFragmentRoot.
protected  Object[] getPackageFragmentRoots(IJavaScriptProject project)
          Evaluates all children of a given IJavaScriptProject.
 Object getParent(Object element)
           
 boolean getProvideMembers()
          Returns whether members are provided when asking for a compilation units or class file for its children.
 boolean getProvideWorkingCopy()
          Deprecated. Since 3.0 compilation unit children are always provided as working copies. The JavaScript model does not support the 'original' mode anymore.
 boolean hasChildren(Object element)
           
 void inputChanged(Viewer viewer, Object oldInput, Object newInput)
           
protected  Object internalGetParent(Object element)
          Note: This method is for internal use only.
protected  boolean isClassPathChange(IJavaScriptElementDelta delta)
          Note: This method is for internal use only.
protected  boolean isPackageFragmentEmpty(IJavaScriptElement element)
          Note: This method is for internal use only.
protected  boolean isProjectPackageFragmentRoot(IPackageFragmentRoot root)
          Note: This method is for internal use only.
protected  boolean matches(IJavaScriptElement element)
           
 boolean providesWorkingCopies()
          Returns true if the content provider returns working copy elements; otherwise false is returned.
 void setProvideMembers(boolean b)
          Sets whether the content provider is supposed to return members when asking a compilation unit or class file for its children.
protected  Object skipProjectPackageFragmentRoot(IPackageFragmentRoot root)
          Note: This method is for internal use only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_CHILDREN

protected static final Object[] NO_CHILDREN

fProvideMembers

protected boolean fProvideMembers

fProvideWorkingCopy

protected boolean fProvideWorkingCopy
Constructor Detail

StandardJavaScriptElementContentProvider

public StandardJavaScriptElementContentProvider()
Creates a new content provider. The content provider does not provide members of compilation units or class files.


StandardJavaScriptElementContentProvider

public StandardJavaScriptElementContentProvider(boolean provideMembers)
Creates a new StandardJavaScriptElementContentProvider.

Parameters:
provideMembers - if true members below compilation units and class files are provided.
Method Detail

getProvideMembers

public boolean getProvideMembers()
Returns whether members are provided when asking for a compilation units or class file for its children.

Returns:
true if the content provider provides members; otherwise false is returned

setProvideMembers

public void setProvideMembers(boolean b)
Sets whether the content provider is supposed to return members when asking a compilation unit or class file for its children.

Parameters:
b - if true then members are provided. If false compilation units and class files are the leaves provided by this content provider.

getProvideWorkingCopy

public boolean getProvideWorkingCopy()
Deprecated. Since 3.0 compilation unit children are always provided as working copies. The JavaScript model does not support the 'original' mode anymore.


providesWorkingCopies

public boolean providesWorkingCopies()
Description copied from interface: IWorkingCopyProvider
Returns true if the content provider returns working copy elements; otherwise false is returned.

Specified by:
providesWorkingCopies in interface IWorkingCopyProvider
Returns:
whether working copy elements are provided.

getElements

public Object[] getElements(Object parent)

inputChanged

public void inputChanged(Viewer viewer,
                         Object oldInput,
                         Object newInput)

dispose

public void dispose()

getChildren

public Object[] getChildren(Object element)

matches

protected boolean matches(IJavaScriptElement element)

filter

protected IJavaScriptElement[] filter(IJavaScriptElement[] children)

hasChildren

public boolean hasChildren(Object element)

getParent

public Object getParent(Object element)

getPackageFragmentRootContent

protected Object[] getPackageFragmentRootContent(IPackageFragmentRoot root)
                                          throws JavaScriptModelException
Evaluates all children of a given IPackageFragmentRoot. Clients can override this method.

Parameters:
root - The root to evaluate the children for.
Returns:
The children of the root
Throws:
JavaScriptModelException - if the package fragment root does not exist or if an exception occurs while accessing its corresponding resource

getPackageFragmentRoots

protected Object[] getPackageFragmentRoots(IJavaScriptProject project)
                                    throws JavaScriptModelException
Evaluates all children of a given IJavaScriptProject. Clients can override this method.

Parameters:
project - The JavaScript project to evaluate the children for.
Returns:
The children of the project. Typically these are package fragment roots but can also be other elements.
Throws:
JavaScriptModelException - if the JavaScript project does not exist or if an exception occurs while accessing its corresponding resource

getJavaProjects

protected Object[] getJavaProjects(IJavaScriptModel jm)
                            throws JavaScriptModelException
Note: This method is for internal use only. Clients should not call this method.

Throws:
JavaScriptModelException

getPackageContent

protected Object[] getPackageContent(IPackageFragment fragment)
                              throws JavaScriptModelException
Evaluates all children of a given IPackageFragment. Clients can override this method.

Parameters:
fragment - The fragment to evaluate the children for.
Returns:
The children of the given package fragment.
Throws:
JavaScriptModelException - if the package fragment does not exist or if an exception occurs while accessing its corresponding resource

getFolderContent

protected Object[] getFolderContent(IFolder folder)
                             throws CoreException
Evaluates all children of a given IFolder. Clients can override this method.

Parameters:
folder - The folder to evaluate the children for.
Returns:
The children of the given package fragment.
Throws:
CoreException - if the folder does not exist.

isClassPathChange

protected boolean isClassPathChange(IJavaScriptElementDelta delta)
Note: This method is for internal use only. Clients should not call this method.


skipProjectPackageFragmentRoot

protected Object skipProjectPackageFragmentRoot(IPackageFragmentRoot root)
Note: This method is for internal use only. Clients should not call this method.


isPackageFragmentEmpty

protected boolean isPackageFragmentEmpty(IJavaScriptElement element)
                                  throws JavaScriptModelException
Note: This method is for internal use only. Clients should not call this method.

Throws:
JavaScriptModelException

isProjectPackageFragmentRoot

protected boolean isProjectPackageFragmentRoot(IPackageFragmentRoot root)
Note: This method is for internal use only. Clients should not call this method.


exists

protected boolean exists(Object element)
Note: This method is for internal use only. Clients should not call this method.


internalGetParent

protected Object internalGetParent(Object element)
Note: This method is for internal use only. Clients should not call this method.


concatenate

protected static Object[] concatenate(Object[] a1,
                                      Object[] a2)
Note: This method is for internal use only. Clients should not call this method.


JavaScript Development Tools
Release 3.2

Copyright (c) IBM Corp. and others 2000, 2010. All Rights Reserved.