com.ibm.jdg2e.view.files.ui
Class FileContentProvider

java.lang.Object
  extended bycom.ibm.jdg2e.view.files.ui.FileContentProvider
All Implemented Interfaces:
java.util.EventListener, org.eclipse.jface.viewers.IContentProvider, org.eclipse.core.resources.IResourceChangeListener, org.eclipse.jface.viewers.IStructuredContentProvider

class FileContentProvider
extends java.lang.Object
implements org.eclipse.jface.viewers.IStructuredContentProvider, org.eclipse.core.resources.IResourceChangeListener

Obtains file resources from selected input for display in view. A dynamic approach based on Job and WorkbenchJob support, is used to both reduce UI locking and allow for an improved user dynamic. The getElements method does not actually return content, instead it starts a job that will result in the delivery of the required content to the viewer.

If the user changes the input or filtering rules all in-flight work is canceled and the new input/filter rules are used. This is possible because jobs are used for most of the processing.


Nested Class Summary
(package private)  class FileContentProvider.AddToViewer
          This job is used to deliver content to the viewer.
(package private)  class FileContentProvider.FileFinder
          Job to find input for the File Resources view.
(package private)  class FileContentProvider.FileProxyVisitor
          Visitor for File Resources view.
 
Constructor Summary
(package private) FileContentProvider()
          Constructor.
  FileContentProvider(FileView view)
           
 
Method Summary
(package private)  void cancelActiveJobs()
          Cancel any jobs that might be active.
 void dispose()
          Cancel any active jobs and clear references.
(package private)  void findFiles(java.lang.Object parent, org.eclipse.core.runtime.IProgressMonitor monitor)
          Create and run an IResourceProxyVisitor to fine files.
 java.lang.Object[] getElements(java.lang.Object parent)
          Find all IFile resources for the selected input.
 int getElementsLength()
          Provides access to the size of the elements that might be visible in the viewer.
 void inputChanged(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object oldInput, java.lang.Object newInput)
          Following the pattern of removing listener from old input and adding to new input.
 void resetTimestampRange()
          Forces viewer update of all content to reflect new rules for label provider logic that color codes recent updates based on the selected time span range.
 void resourceChanged(org.eclipse.core.resources.IResourceChangeEvent event)
          Identifies when changes have occurred and asks that the viewer refresh to show current content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileContentProvider

FileContentProvider()
Constructor.


FileContentProvider

public FileContentProvider(FileView view)
Parameters:
view - used to obtain IWorkbenchSiteProgressService reference to schedule workbench part aware jobs.
Method Detail

cancelActiveJobs

void cancelActiveJobs()
Cancel any jobs that might be active.


dispose

public void dispose()
Cancel any active jobs and clear references.

Specified by:
dispose in interface org.eclipse.jface.viewers.IContentProvider
See Also:
IContentProvider.dispose()

findFiles

void findFiles(java.lang.Object parent,
               org.eclipse.core.runtime.IProgressMonitor monitor)
Create and run an IResourceProxyVisitor to fine files.

Parameters:
parent - Input to be searched for files.
monitor - used to determine if the job has been canceled.

getElements

public java.lang.Object[] getElements(java.lang.Object parent)
Find all IFile resources for the selected input. When the input is new/unknown, this is nota a direct request in that this method actually returns an empty array. The real processing is packaged in a job that uses an IResourceProxyVisitor that walks the input resource tree to find IFile resources.

When the parent parameter represents the current input then the existing array is returned to avoid re-walking the resource tree for a simple sort request.

Specified by:
getElements in interface org.eclipse.jface.viewers.IStructuredContentProvider
See Also:
IStructuredContentProvider.getElements(java.lang.Object)

getElementsLength

public int getElementsLength()
Provides access to the size of the elements that might be visible in the viewer.

Returns:
size of the array of IFile elements.

inputChanged

public void inputChanged(org.eclipse.jface.viewers.Viewer viewer,
                         java.lang.Object oldInput,
                         java.lang.Object newInput)
Following the pattern of removing listener from old input and adding to new input. Net result is there is always a listener, which is correct. Could have just added the listener and ignored all subsequent changes since the global model is the workspace and the change listener is the same regardless of which IContainer is the input.

Specified by:
inputChanged in interface org.eclipse.jface.viewers.IContentProvider
See Also:
IContentProvider.inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)

resetTimestampRange

public void resetTimestampRange()
Forces viewer update of all content to reflect new rules for label provider logic that color codes recent updates based on the selected time span range.


resourceChanged

public void resourceChanged(org.eclipse.core.resources.IResourceChangeEvent event)
Identifies when changes have occurred and asks that the viewer refresh to show current content. This implementation of an IResourceChangeListener includes a minor optimization so that viewer refresh requests are only sent when files that are in the viewer have actually changed.

Specified by:
resourceChanged in interface org.eclipse.core.resources.IResourceChangeListener
See Also:
IResourceChangeListener.resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)