org.eclipse.wst.jsdt.ui

## Class StandardJavaScriptElementContentProvider

- java.lang.Object
- - org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider

All Implemented Interfaces:
  IWorkingCopyProvider

    public class StandardJavaScriptElementContentProvider
    extends java.lang.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

Fields
`protected boolean` `fProvideMembers`
`protected boolean` `fProvideWorkingCopy`
`protected static java.lang.Object[]` `NO_CHILDREN`

### Constructor Summary

Constructors
Constructor and Description
`StandardJavaScriptElementContentProvider()` Creates a new content provider.
`StandardJavaScriptElementContentProvider(boolean provideMembers)` Creates a new `StandardJavaScriptElementContentProvider`.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`protected static java.lang.Object[]` `concatenate(java.lang.Object[] a1, java.lang.Object[] a2)` Note: This method is for internal use only.
`void` `dispose()`
`protected boolean` `exists(java.lang.Object element)` Note: This method is for internal use only.
`protected IJavaScriptElement[]` `filter(IJavaScriptElement[] children)`
`java.lang.Object[]` `getChildren(java.lang.Object element)`
`java.lang.Object[]` `getElements(java.lang.Object parent)`
`protected java.lang.Object[]` `getFolderContent(IFolder folder)` Evaluates all children of a given `IFolder`.
`protected java.lang.Object[]` `getJavaProjects(IJavaScriptModel jm)` Note: This method is for internal use only.
`protected java.lang.Object[]` `getPackageContent(IPackageFragment fragment)` Evaluates all children of a given `IPackageFragment`.
`protected java.lang.Object[]` `getPackageFragmentRootContent(IPackageFragmentRoot root)` Evaluates all children of a given `IPackageFragmentRoot`.
`protected java.lang.Object[]` `getPackageFragmentRoots(IJavaScriptProject project)` Evaluates all children of a given `IJavaScriptProject`.
`java.lang.Object` `getParent(java.lang.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(java.lang.Object element)`
`void` `inputChanged(Viewer viewer, java.lang.Object oldInput, java.lang.Object newInput)`
`protected java.lang.Object` `internalGetParent(java.lang.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 java.lang.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 java.lang.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 java.lang.Object[] getElements(java.lang.Object parent)

#### inputChanged

    public void inputChanged(Viewer viewer,
                             java.lang.Object oldInput,
                             java.lang.Object newInput)

#### dispose

    public void dispose()

#### getChildren

    public java.lang.Object[] getChildren(java.lang.Object element)

#### matches

    protected boolean matches(IJavaScriptElement element)

#### filter

    protected IJavaScriptElement[] filter(IJavaScriptElement[] children)

#### hasChildren

    public boolean hasChildren(java.lang.Object element)

#### getParent

    public java.lang.Object getParent(java.lang.Object element)

#### getPackageFragmentRootContent

    protected java.lang.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 java.lang.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 java.lang.Object[] getJavaProjects(IJavaScriptModel jm)
                                          throws JavaScriptModelException

Note: This method is for internal use only. Clients should not call this method.

Throws:
  `JavaScriptModelException`

#### getPackageContent

    protected java.lang.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 java.lang.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 java.lang.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(java.lang.Object element)

Note: This method is for internal use only. Clients should not call this method.

#### internalGetParent

    protected java.lang.Object internalGetParent(java.lang.Object element)

Note: This method is for internal use only. Clients should not call this method.

#### concatenate

    protected static java.lang.Object[] concatenate(java.lang.Object[] a1,
                                                    java.lang.Object[] a2)

Note: This method is for internal use only. Clients should not call this method.