Package org.eclipse.jdt.ui
Class StandardJavaElementContentProvider
java.lang.Object
org.eclipse.jdt.ui.StandardJavaElementContentProvider
- All Implemented Interfaces:
IWorkingCopyProvider
,org.eclipse.jface.viewers.IContentProvider
,org.eclipse.jface.viewers.IStructuredContentProvider
,org.eclipse.jface.viewers.ITreeContentProvider
- Direct Known Subclasses:
JavaElementContentProvider
public class StandardJavaElementContentProvider
extends Object
implements org.eclipse.jface.viewers.ITreeContentProvider, IWorkingCopyProvider
A base content provider for Java elements. It provides access to the
Java element hierarchy without listening to changes in the Java model.
If updating the presentation on Java model change is required than
clients have to subclass, listen to Java model changes and have to update
the UI using corresponding methods provided by the JFace viewers or their
own UI presentation.
The following Java element hierarchy is surfaced by this content provider:
Java model (IJavaModel
) Java project (IJavaProject
) package fragment root (IPackageFragmentRoot
) package fragment (IPackageFragment
) compilation unit (ICompilationUnit
) binary class file (IClassFile
)
Note that when the entire Java project is declared to be package fragment root, the corresponding package fragment root element that normally appears between the Java project and the package fragments is automatically filtered out.
- Since:
- 2.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
protected static final Object[]
-
Constructor Summary
ConstructorDescriptionCreates a new content provider.StandardJavaElementContentProvider
(boolean provideMembers) Creates a newStandardJavaElementContentProvider
.StandardJavaElementContentProvider
(boolean provideMembers, boolean provideWorkingCopy) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected static Object[]
concatenate
(Object[] a1, Object[] a2) Utility method to concatenate two arrays.void
dispose()
protected boolean
Note: This method is for internal use only.Object[]
getChildren
(Object element) Object[]
getElements
(Object parent) protected Object[]
getFolderContent
(org.eclipse.core.resources.IFolder folder) Evaluates all children of a givenIFolder
.protected Object[]
Evaluates all Java projects of a givenIJavaModel
.protected Object[]
getPackageContent
(IPackageFragment fragment) Evaluates all children of a givenIPackageFragment
.protected Object[]
Evaluates all children of a givenIPackageFragmentRoot
.protected Object[]
getPackageFragmentRoots
(IJavaProject project) Evaluates all children of a givenIJavaProject
.boolean
Returns whether members are provided when asking for a compilation units or class file for its children.boolean
Deprecated.Since 3.0 compilation unit children are always provided as working copies.boolean
hasChildren
(Object element) void
inputChanged
(org.eclipse.jface.viewers.Viewer viewer, Object oldInput, Object newInput) protected Object
internalGetParent
(Object element) Note: This method is for internal use only.protected boolean
Tests if the a Java element delta contains a class path changeprotected boolean
isPackageFragmentEmpty
(IJavaElement element) Tests if the given element is a empty package fragment.protected boolean
Tests if the package fragment root is located on the project.boolean
Returnstrue
if the content provider returns working copy elements; otherwisefalse
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.void
setProvideWorkingCopy
(boolean b) Deprecated.Since 3.0 compilation unit children are always provided from the working copy.protected Object
Note: This method is for internal use only.
-
Field Details
-
NO_CHILDREN
-
fProvideMembers
protected boolean fProvideMembers -
fProvideWorkingCopy
protected boolean fProvideWorkingCopy
-
-
Constructor Details
-
StandardJavaElementContentProvider
public StandardJavaElementContentProvider()Creates a new content provider. The content provider does not provide members of compilation units or class files. -
StandardJavaElementContentProvider
@Deprecated public StandardJavaElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) Deprecated.UseStandardJavaElementContentProvider(boolean)
instead. Since 3.0 compilation unit children are always provided as working copies. The Java Model does not support the 'original' mode anymore.- Parameters:
provideMembers
- iftrue
members below compilation unitsprovideWorkingCopy
- iftrue
working copies are provided
-
StandardJavaElementContentProvider
public StandardJavaElementContentProvider(boolean provideMembers) Creates a newStandardJavaElementContentProvider
.- Parameters:
provideMembers
- iftrue
members below compilation units and class files are provided.
-
-
Method Details
-
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; otherwisefalse
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
- iftrue
then members are provided. Iffalse
compilation units and class files are the leaves provided by this content provider.
-
getProvideWorkingCopy
Deprecated.Since 3.0 compilation unit children are always provided as working copies. The Java model does not support the 'original' mode anymore.- Returns:
- returns
true
if working copies are provided
-
setProvideWorkingCopy
Deprecated.Since 3.0 compilation unit children are always provided from the working copy. The Java model offers a unified world and does not support the 'original' mode anymore.- Parameters:
b
- specifies if working copies should be provided
-
providesWorkingCopies
public boolean providesWorkingCopies()Description copied from interface:IWorkingCopyProvider
Returnstrue
if the content provider returns working copy elements; otherwisefalse
is returned.- Specified by:
providesWorkingCopies
in interfaceIWorkingCopyProvider
- Returns:
- whether working copy elements are provided.
-
getElements
- Specified by:
getElements
in interfaceorg.eclipse.jface.viewers.IStructuredContentProvider
- Specified by:
getElements
in interfaceorg.eclipse.jface.viewers.ITreeContentProvider
-
inputChanged
- Specified by:
inputChanged
in interfaceorg.eclipse.jface.viewers.IContentProvider
-
dispose
public void dispose()- Specified by:
dispose
in interfaceorg.eclipse.jface.viewers.IContentProvider
-
getChildren
- Specified by:
getChildren
in interfaceorg.eclipse.jface.viewers.ITreeContentProvider
-
hasChildren
- Specified by:
hasChildren
in interfaceorg.eclipse.jface.viewers.ITreeContentProvider
-
getParent
- Specified by:
getParent
in interfaceorg.eclipse.jface.viewers.ITreeContentProvider
-
getPackageFragmentRootContent
protected Object[] getPackageFragmentRootContent(IPackageFragmentRoot root) throws JavaModelException Evaluates all children of a givenIPackageFragmentRoot
. Clients can override this method.- Parameters:
root
- The root to evaluate the children for.- Returns:
- The children of the root
- Throws:
JavaModelException
- if the package fragment root does not exist or if an exception occurs while accessing its corresponding resource- Since:
- 3.3
-
getPackageFragmentRoots
Evaluates all children of a givenIJavaProject
. Clients can override this method.- Parameters:
project
- The Java 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:
JavaModelException
- if the Java project does not exist or if an exception occurs while accessing its corresponding resource
-
getJavaProjects
Evaluates all Java projects of a givenIJavaModel
. Clients can override this method.- Parameters:
jm
- the Java model- Returns:
- the projects
- Throws:
JavaModelException
- thrown if accessing the model failed
-
getPackageContent
Evaluates all children of a givenIPackageFragment
. Clients can override this method.- Parameters:
fragment
- The fragment to evaluate the children for.- Returns:
- The children of the given package fragment.
- Throws:
JavaModelException
- if the package fragment does not exist or if an exception occurs while accessing its corresponding resource- Since:
- 3.3
-
getFolderContent
protected Object[] getFolderContent(org.eclipse.core.resources.IFolder folder) throws org.eclipse.core.runtime.CoreException Evaluates all children of a givenIFolder
. Clients can override this method.- Parameters:
folder
- The folder to evaluate the children for.- Returns:
- The children of the given folder.
- Throws:
org.eclipse.core.runtime.CoreException
- if the folder does not exist.- Since:
- 3.3
-
isClassPathChange
Tests if the a Java element delta contains a class path change- Parameters:
delta
- the Java element delta- Returns:
- returns
true
if the delta contains a class path change
-
skipProjectPackageFragmentRoot
Note: This method is for internal use only. Clients should not call this method.- Parameters:
root
- the package fragment root- Returns:
- returns the element representing the root.
- Restriction:
- This method is not intended to be referenced by clients.
-
isPackageFragmentEmpty
Tests if the given element is a empty package fragment.- Parameters:
element
- the element to test- Returns:
- returns
true
if the package fragment is empty - Throws:
JavaModelException
- thrown if accessing the element failed
-
isProjectPackageFragmentRoot
Tests if the package fragment root is located on the project.- Parameters:
root
- the package fragment root- Returns:
- returns
true
if the package fragment root is the located on the project
-
exists
Note: This method is for internal use only. Clients should not call this method.- Parameters:
element
- the element to test- Returns:
- returns
true
if the element exists - Restriction:
- This method is not intended to be referenced by clients.
-
internalGetParent
Note: This method is for internal use only. Clients should not call this method.- Parameters:
element
- the element- Returns:
- the parent of the element
- Restriction:
- This method is not intended to be referenced by clients.
-
concatenate
Utility method to concatenate two arrays.- Parameters:
a1
- the first arraya2
- the second array- Returns:
- the concatenated array
-
StandardJavaElementContentProvider(boolean)
instead.