com.ibm.jdg2e.resources.extensions.builder
Class ReadmeBuilder

java.lang.Object
  extended byorg.eclipse.core.internal.events.InternalBuilder
      extended byorg.eclipse.core.resources.IncrementalProjectBuilder
          extended bycom.ibm.jdg2e.resources.extensions.builder.ReadmeBuilder
All Implemented Interfaces:
org.eclipse.core.runtime.IExecutableExtension

public class ReadmeBuilder
extends org.eclipse.core.resources.IncrementalProjectBuilder

Builder for .readme files. Creates and HTML stub file for each readme file in a project's readme folder to demonstrate the structure of a builder and how an IResourceDelta can be processed to find changes of interest to a builder.

The builder will proecess files in the current project, and register its intent to process files in any referenced project. This means that even though the builder is not associated to a project, the fact that a project with this builder has a project reference means that the target project will also be processed.

Source includes trace logic that can be enabled or disabled based on the setting of the traceEnabled field. The trace logic uses System.out.println() statements to create trace entries. If you want to visualize the flow of build processing, un-comment these statements before starting a test cycle.

See Also:
IncrementalProjectBuilder, IResourceDelta

Field Summary
 
Fields inherited from class org.eclipse.core.resources.IncrementalProjectBuilder
AUTO_BUILD, CLEAN_BUILD, FULL_BUILD, INCREMENTAL_BUILD
 
Constructor Summary
ReadmeBuilder()
          The required public no-argument constructor.
 
Method Summary
protected  org.eclipse.core.resources.IProject[] build(int kind, java.util.Map args, org.eclipse.core.runtime.IProgressMonitor monitor)
          The build method implementation required for any incremental builder.
 void checkBuildType(int kind)
          Prints builder kind trace messages to the console
protected  void clean(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void processDelta(org.eclipse.core.resources.IResourceDelta delta)
          The IResourceDelta passed is processed by a IResourceDeltaVisitor when the delta contains information about changes in the readme folder.
 void processDelta4ReferencedProjects(org.eclipse.core.resources.IProject[] refedProjects)
          Attempts to process readme changes in another project where the builder is not registered.
 void processFull(org.eclipse.core.resources.IProject iProject)
          Performs a FULL_BUILD by visiting all nodes in the resource tree under readme folder for the specified project.
 void processFull4ReferencedProjects(org.eclipse.core.resources.IProject[] refedProjects)
          Performs a full builds on any referenced projects.
 void setInitializationData(org.eclipse.core.runtime.IConfigurationElement config, java.lang.String propertyName, java.lang.Object data)
          Finds builder parameters defined in the plugin.xml.
protected  void startupOnInitialize()
          This method allows a builder to get ready.
 org.eclipse.core.resources.IProject[] watchReferecedProjects()
          Returns an array of projects that are of interest for the next build.
 
Methods inherited from class org.eclipse.core.resources.IncrementalProjectBuilder
forgetLastBuiltState, getDelta, getProject, hasBeenBuilt, isInterrupted, needRebuild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadmeBuilder

public ReadmeBuilder()
The required public no-argument constructor.

Method Detail

build

protected org.eclipse.core.resources.IProject[] build(int kind,
                                                      java.util.Map args,
                                                      org.eclipse.core.runtime.IProgressMonitor monitor)
                                               throws org.eclipse.core.runtime.CoreException
The build method implementation required for any incremental builder. This demonstration of build processing reacts to a FULL_BUILD,AUTO_BUILD, or INCREMENTAL_BUILD build request. The processing logic to "build" the .readme files is kept in the ReadmeVisitor class and is used for all build types.

Throws:
org.eclipse.core.runtime.CoreException
See Also:
InternalBuilder.build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)

checkBuildType

public void checkBuildType(int kind)
Prints builder kind trace messages to the console

Parameters:
kind -

clean

protected void clean(org.eclipse.core.runtime.IProgressMonitor monitor)
              throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

processDelta

public void processDelta(org.eclipse.core.resources.IResourceDelta delta)
                  throws org.eclipse.core.runtime.CoreException
The IResourceDelta passed is processed by a IResourceDeltaVisitor when the delta contains information about changes in the readme folder. A null delta exists when the project is created.

Multiple visit invocation statements are included for the different resource visitors provided in this resource programming demonstration package. You may wish to invoke other visitors to further explore the IResourceDelta.

Parameters:
delta -
Throws:
org.eclipse.core.runtime.CoreException
See Also:
IResourceDelta

processDelta4ReferencedProjects

public void processDelta4ReferencedProjects(org.eclipse.core.resources.IProject[] refedProjects)
                                     throws org.eclipse.core.runtime.CoreException
Attempts to process readme changes in another project where the builder is not registered. Other projects are those referenced by the current project.

Parameters:
refedProjects -
Throws:
org.eclipse.core.runtime.CoreException

processFull

public void processFull(org.eclipse.core.resources.IProject iProject)
Performs a FULL_BUILD by visiting all nodes in the resource tree under readme folder for the specified project. The readme folder must exist. Either an IResourceProxyVisitor or IResourceVisitor can be used, both are created but only one is invoked.

By example you can see it does not take much more work to use an IResourceProxyVisitor and the visitor will run faster.

The ReadmeVisitor logic is used to actually process the .readme files found in the project tree.

Parameters:
iProject -

processFull4ReferencedProjects

public void processFull4ReferencedProjects(org.eclipse.core.resources.IProject[] refedProjects)
Performs a full builds on any referenced projects.

Parameters:
refedProjects -

setInitializationData

public void setInitializationData(org.eclipse.core.runtime.IConfigurationElement config,
                                  java.lang.String propertyName,
                                  java.lang.Object data)
                           throws org.eclipse.core.runtime.CoreException
Finds builder parameters defined in the plugin.xml. Parameters are printed to the console if the System.out.println() statements are uncommented.

Throws:
org.eclipse.core.runtime.CoreException
See Also:
IExecutableExtension.setInitializationData(IConfigurationElement, String, Object)

startupOnInitialize

protected void startupOnInitialize()
This method allows a builder to get ready. Called early in the build cycle.

See Also:
InternalBuilder.startupOnInitialize()

watchReferecedProjects

public org.eclipse.core.resources.IProject[] watchReferecedProjects()
Returns an array of projects that are of interest for the next build. If this array is returned by the build method, the build can get a delta for these projects during the next build cycle. The projects returned are those referenced by the current project, if none are referenced a null is returned.

Returns:
array of interesting projects