## org.eclipse.contribution.visualiser.jdtImpl
Class JDTContentProvider

    java.lang.Object
      org.eclipse.contribution.visualiser.jdtImpl.JDTContentProvider

All Implemented Interfaces:
  IContentProvider, org.eclipse.ui.ISelectionListener

Direct Known Subclasses:
  JDTSearchResultsContentProvider

public class JDTContentProvider
extends java.lang.Object
implements IContentProvider, org.eclipse.ui.ISelectionListener

Field Summary
`protected org.eclipse.jdt.core.IJavaElement` `currentlySelectedJE`
`protected org.eclipse.jdt.core.IJavaProject` `currentProject`

Constructor Summary
`JDTContentProvider()`

Method Summary
`void` `activate()` Called when this provider is selected.
`protected boolean` `containsUsefulStuff(org.eclipse.jdt.core.IPackageFragment fragment)` Returns true if this package fragment has Java classes in it.
`void` `deactivate()` Called when this provider is currently active and another provider is selected.
`java.util.List` `getAllGroups()` Get all groups
`java.util.List` `getAllJDTGroups(org.eclipse.jdt.core.IJavaProject JP)` Get all package fragments for the given Java project
`java.util.List` `getAllMembers()` Get all members
`java.util.List` `getAllMembers(IGroup group)` Get all members for the given group
`org.eclipse.jdt.core.IJavaProject` `getCurrentProject()` Get the current project
`JDTGroup` `getGroupForFragment(org.eclipse.jdt.core.IPackageFragment ipf)` Get a JDTGroup to represent the give IPackageFragment (Java package)
`org.eclipse.jface.resource.ImageDescriptor` `getGroupViewIcon()` Called when switching to this content provider to get the icon used in the Visualiser view for Group view.
`protected int` `getLength(org.eclipse.jdt.core.ICompilationUnit element)` Given a compilation unit, work out the number of lines in its source.
`java.util.List` `getMembersForPackage(org.eclipse.jdt.core.IPackageFragment PF)` Get all JDT members for the given IPackageFragment (Java package)
`org.eclipse.jface.resource.ImageDescriptor` `getMemberViewIcon()` Called when switching to this content provider to get the icon used in the Visualiser view for Member view.
`void` `initialise()` Initialise
`void` `lookForData()` Attempts to find some data to display by looking for selections in each of the packages view, projects view, and package explorer (in turn).
`boolean` `processMouseclick(IMember member, boolean markupWasClicked, int buttonClicked)` Process a mouse click on a member
`void` `selectionChanged(org.eclipse.ui.IWorkbenchPart iwp, org.eclipse.jface.viewers.ISelection is)` Keeps the currentResource and currentProject information up to date in this class, as this method is called whenever a user changes their selection in the workspace.
`protected void` `setCurrentProject(org.eclipse.jdt.core.IJavaProject currentProject)` Set the current project
`void` `trace(java.lang.String string)` Simple trace routine - we can turn trace on and off by commenting out the body.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### currentProject

    protected org.eclipse.jdt.core.IJavaProject currentProject

### currentlySelectedJE

    protected org.eclipse.jdt.core.IJavaElement currentlySelectedJE

Constructor Detail

### JDTContentProvider

    public JDTContentProvider()

Method Detail

### getLength

    protected int getLength(org.eclipse.jdt.core.ICompilationUnit element)

  Given a compilation unit, work out the number of lines in its source.

  Parameters:
    `element` - Compilation unit to investigate
  Returns:
    number of lines in the compilation unit

### trace

    public void trace(java.lang.String string)

  Simple trace routine - we can turn trace on and off by commenting out the body.

### selectionChanged

    public void selectionChanged(org.eclipse.ui.IWorkbenchPart iwp,
                                 org.eclipse.jface.viewers.ISelection is)

  Keeps the currentResource and currentProject information up to date in this class, as this method is called whenever a user changes their selection in the workspace.

  Specified by:
    `selectionChanged` in interface `org.eclipse.ui.ISelectionListener`

### getAllMembers

    public java.util.List getAllMembers(IGroup group)

  Get all members for the given group

  Specified by:
    `getAllMembers` in interface `IContentProvider`
  Returns:
    List of IMembers
  See Also:
    `IContentProvider.getAllMembers(org.eclipse.contribution.visualiser.interfaces.IGroup)`

### getAllMembers

    public java.util.List getAllMembers()

  Get all members

  Specified by:
    `getAllMembers` in interface `IContentProvider`
  See Also:
    `IContentProvider.getAllMembers()`

### initialise

    public void initialise()

  Initialise

  Specified by:
    `initialise` in interface `IContentProvider`
  See Also:
    `IContentProvider.initialise()`

### lookForData

    public void lookForData()

  Attempts to find some data to display by looking for selections in each of the packages view, projects view, and package explorer (in turn). The first selection found is used to refresh the visualiser. It is called by the visualiser if it receives a paint request, but hasn't been given any data. Selections are generally preserved by Eclipse across sessions, so this should result in the visualisation from a previous session being restored. This method should not be used when the provider is initialised, because that may occur before the other views have been created.

### processMouseclick

    public boolean processMouseclick(IMember member,
                                     boolean markupWasClicked,
                                     int buttonClicked)

  Process a mouse click on a member

  Specified by:
    `processMouseclick` in interface `IContentProvider`
  See Also:
    `IContentProvider.processMouseclick(IMember, boolean, int)`

### getAllGroups

    public java.util.List getAllGroups()

  Get all groups

  Specified by:
    `getAllGroups` in interface `IContentProvider`
  Returns:
    List of IGroups

### getGroupForFragment

    public JDTGroup getGroupForFragment(org.eclipse.jdt.core.IPackageFragment ipf)

  Get a JDTGroup to represent the give IPackageFragment (Java package)

  Parameters:
    `ipf` -
  Returns:
    the JDTGroup created

### getAllJDTGroups

    public java.util.List getAllJDTGroups(org.eclipse.jdt.core.IJavaProject JP)

  Get all package fragments for the given Java project

  Parameters:
    `JP` -
  Returns:
    List of JDTGroups

### getMembersForPackage

    public java.util.List getMembersForPackage(org.eclipse.jdt.core.IPackageFragment PF)

  Get all JDT members for the given IPackageFragment (Java package)

  Parameters:
    `PF` -
  Returns:
    List of JDTMembers

### containsUsefulStuff

    protected boolean containsUsefulStuff(org.eclipse.jdt.core.IPackageFragment fragment)

  Returns true if this package fragment has Java classes in it.

  Parameters:
    `fragment` -
  Returns:
    true if the package fragment contains Java classes

### getMemberViewIcon

    public org.eclipse.jface.resource.ImageDescriptor getMemberViewIcon()

  Description copied from interface: `IContentProvider`
  Called when switching to this content provider to get the icon used in the Visualiser view for Member view. If null is returned default icons are used.

  Specified by:
    `getMemberViewIcon` in interface `IContentProvider`
  Returns:
    image to be used as member view icon
  See Also:
    `IContentProvider.getMemberViewIcon()`

### getGroupViewIcon

    public org.eclipse.jface.resource.ImageDescriptor getGroupViewIcon()

  Description copied from interface: `IContentProvider`
  Called when switching to this content provider to get the icon used in the Visualiser view for Group view. If null is returned default icons are used.

  Specified by:
    `getGroupViewIcon` in interface `IContentProvider`
  Returns:
    image to be used as group view icon, or null if default is required
  See Also:
    `IContentProvider.getGroupViewIcon()`

### setCurrentProject

    protected void setCurrentProject(org.eclipse.jdt.core.IJavaProject currentProject)

  Set the current project

  Parameters:
    `currentProject` - - the current IJavaProject

### getCurrentProject

    public org.eclipse.jdt.core.IJavaProject getCurrentProject()

  Get the current project

  Returns:
    current IJavaProject

### activate

    public void activate()

  Description copied from interface: `IContentProvider`
  Called when this provider is selected.

  Specified by:
    `activate` in interface `IContentProvider`
  See Also:
    `IContentProvider.activate()`

### deactivate

    public void deactivate()

  Description copied from interface: `IContentProvider`
  Called when this provider is currently active and another provider is selected.

  Specified by:
    `deactivate` in interface `IContentProvider`
  See Also:
    `IContentProvider.deactivate()`