## org.eclipse.jet.taglib.workspace
Class WorkspaceContextExtender

    java.lang.Object
      org.eclipse.jet.AbstractContextExtender
          org.eclipse.jet.taglib.workspace.WorkspaceContextExtender

    public class WorkspaceContextExtender

extends AbstractContextExtender

An extension to the JET2Context for collecting workspace actions (file writes etc) and performing them at the end of a JET2 transformation.

Field Summary
`static java.lang.String` `VAR_RAW_LOCATION` Name of the context variable referencing the raw location of the resource.
`static java.lang.String` `VAR_RESOURCE_FILE_EXTENSION` Name of the context variable referencing the file extension of the resource.
`static java.lang.String` `VAR_RESOURCE_FILE_NAME` Name of the context variable referencing file name (with extension removed) of the resource.
`static java.lang.String` `VAR_RESOURCE_FULL_PATH` Name of the context variable referencing the full path of the resource.
`static java.lang.String` `VAR_RESOURCE_LOCATION` Name of the context variable referencing the location of the resource.
`static java.lang.String` `VAR_RESOURCE_NAME` Name of the context variable referencing the name of the resource.
`static java.lang.String` `VAR_RESOURCE_PARENT_FULL_PATH` Name of the context variable referencing the full path of the resource's parent.
`static java.lang.String` `VAR_RESOURCE_PARENT_LOCATION` Name of the context variable referencing the location of the resource's parent.
`static java.lang.String` `VAR_RESOURCE_PARENT_NAME` Name of the context variable referencing the name of the resource's parent.
`static java.lang.String` `VAR_RESOURCE_PARENT_PROJECT_RELATIVE_PATH` Name of the context variable referencing the project relative path of the resource's parent.
`static java.lang.String` `VAR_RESOURCE_PARENT_RAW_LOCATION` Name of the context variable referencing the raw location of the resource's parent.
`static java.lang.String` `VAR_RESOURCE_PROJECT_NAME` Name of the context variable referencing the name of the project containing the resource.
`static java.lang.String` `VAR_RESOURCE_PROJECT_RELATIVE_PATH` Name of the context variable referencing the project relative path of the resource.
`static java.lang.String` `VAR_RESOURCE_TYPE` Name of the context variable referencing the type of the resource.

Constructor Summary
`WorkspaceContextExtender(JET2Context context)` Create a workspace context extender on the passed context.

Method Summary
`void` `addAction(IWorkspaceAction action)` Add a new action to be executed when the JET2 transform commits.
`void` `addFinalAction(IWorkspaceAction action)` Add a new action to be executed after all actions added view `addAction(IWorkspaceAction)` are executed when the JET2 transform commits.
`protected java.lang.Object` `createExtendedData(JET2Context context)` Called by the AbstractContextExtender constructor if the extender's data has not yet been created in the context.
`boolean` `existsContainer()` Test whether the container stack has an entry for resolving relative paths.
`org.eclipse.core.resources.IContainer` `getContainer()` Get the top most container from the default containers stack without doing a pop.
`static WorkspaceContextExtender` `getInstance(JET2Context context)` Return the workspace context extender for the given JET context.
`static void` `loadResourceAsSource(JET2Context context, org.eclipse.core.resources.IResource resource, java.lang.String resourceLoaderId, java.lang.String resourceType)` Load the passed IResource, and set it as the source of the passed JET2Context.
`void` `popContainer()` Remove the top-most container on the default containers stack.
`void` `pushContainer(org.eclipse.core.resources.IContainer container)` Push a default container onto the stack of default containers.

Methods inherited from class org.eclipse.jet.AbstractContextExtender
`getContext, getExtendedData`

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

Field Detail

### VAR_RESOURCE_PARENT_PROJECT_RELATIVE_PATH

    public static final java.lang.String VAR_RESOURCE_PARENT_PROJECT_RELATIVE_PATH

  Name of the context variable referencing the project relative path of the resource's parent.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getParent()`, `IResource.getProject()`, Constant Field Values

### VAR_RESOURCE_PARENT_FULL_PATH

    public static final java.lang.String VAR_RESOURCE_PARENT_FULL_PATH

  Name of the context variable referencing the full path of the resource's parent.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getParent()`, `IResource.getFullPath()`, Constant Field Values

### VAR_RESOURCE_PARENT_RAW_LOCATION

    public static final java.lang.String VAR_RESOURCE_PARENT_RAW_LOCATION

  Name of the context variable referencing the raw location of the resource's parent.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getParent()`, `IResource.getRawLocation()`, Constant Field Values

### VAR_RESOURCE_PARENT_LOCATION

    public static final java.lang.String VAR_RESOURCE_PARENT_LOCATION

  Name of the context variable referencing the location of the resource's parent.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getParent()`, `IResource.getLocation()`, Constant Field Values

### VAR_RESOURCE_PARENT_NAME

    public static final java.lang.String VAR_RESOURCE_PARENT_NAME

  Name of the context variable referencing the name of the resource's parent.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getParent()`, Constant Field Values

### VAR_RESOURCE_FILE_NAME

    public static final java.lang.String VAR_RESOURCE_FILE_NAME

  Name of the context variable referencing file name (with extension removed) of the resource.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getName()`, `IResource.getFileExtension()`, Constant Field Values

### VAR_RESOURCE_FILE_EXTENSION

    public static final java.lang.String VAR_RESOURCE_FILE_EXTENSION

  Name of the context variable referencing the file extension of the resource.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getFileExtension()`, Constant Field Values

### VAR_RESOURCE_PROJECT_RELATIVE_PATH

    public static final java.lang.String VAR_RESOURCE_PROJECT_RELATIVE_PATH

  Name of the context variable referencing the project relative path of the resource.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getProjectRelativePath()`, Constant Field Values

### VAR_RESOURCE_FULL_PATH

    public static final java.lang.String VAR_RESOURCE_FULL_PATH

  Name of the context variable referencing the full path of the resource.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getFullPath()`, Constant Field Values

### VAR_RESOURCE_PROJECT_NAME

    public static final java.lang.String VAR_RESOURCE_PROJECT_NAME

  Name of the context variable referencing the name of the project containing the resource.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getProject()`, Constant Field Values

### VAR_RAW_LOCATION

    public static final java.lang.String VAR_RAW_LOCATION

  Name of the context variable referencing the raw location of the resource.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getRawLocation()`, Constant Field Values

### VAR_RESOURCE_LOCATION

    public static final java.lang.String VAR_RESOURCE_LOCATION

  Name of the context variable referencing the location of the resource.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getLocation()`, Constant Field Values

### VAR_RESOURCE_TYPE

    public static final java.lang.String VAR_RESOURCE_TYPE

  Name of the context variable referencing the type of the resource. The value of the context variable will be one of 'file', 'folder' or 'project'.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getType()`, Constant Field Values

### VAR_RESOURCE_NAME

    public static final java.lang.String VAR_RESOURCE_NAME

  Name of the context variable referencing the name of the resource.

  See Also:
    `loadResourceAsSource(JET2Context, IResource, String, String)`, `IResource.getName()`, Constant Field Values

Constructor Detail

### WorkspaceContextExtender

    public WorkspaceContextExtender(JET2Context context)

  Create a workspace context extender on the passed context.

  Parameters:
    `context` - a JET2Context. Cannot be `null`.

Method Detail

### createExtendedData

    protected java.lang.Object createExtendedData(JET2Context context)

  Description copied from class: `AbstractContextExtender`
  Called by the AbstractContextExtender constructor if the extender's data has not yet been created in the context.

  Specified by:
    `createExtendedData` in class `AbstractContextExtender`
  Parameters:
    `context` - the context in which the data will be created.
  Returns:
    the extension data object.

### addAction

    public void addAction(IWorkspaceAction action)

  Add a new action to be executed when the JET2 transform commits.

  Parameters:
    `action` - the action to execute

### addFinalAction

    public void addFinalAction(IWorkspaceAction action)

  Add a new action to be executed after all actions added view `addAction(IWorkspaceAction)` are executed when the JET2 transform commits. Final actions behave identically to other actions, except that the occur after all 'normal' actions. In particular, final actions: <bl>
  - participate in the team environment validateEdit phase.
  - are performed within the same Eclipse workspace operation as other actions.
  </bl>

  Parameters:
    `action` - the action to execute

### pushContainer

    public void pushContainer(org.eclipse.core.resources.IContainer container)

  Push a default container onto the stack of default containers.

  Parameters:
    `container` -

### popContainer

    public void popContainer()
                      throws JET2TagException

  Remove the top-most container on the default containers stack.

  Throws:
    `JET2TagException` - if the container stack is empty.

### existsContainer

    public boolean existsContainer()

  Test whether the container stack has an entry for resolving relative paths.

  Returns:
    `true` if the container stack is not empty, `false` otherwise.

### getContainer

    public org.eclipse.core.resources.IContainer getContainer()
                                                       throws JET2TagException

  Get the top most container from the default containers stack without doing a pop.

  Returns:
    the default container
  Throws:
    `JET2TagException` - if the container stack is empty.

### getInstance

    public static WorkspaceContextExtender getInstance(JET2Context context)

  Return the workspace context extender for the given JET context.

  Parameters:
    `context` - the JET context.
  Returns:
    the Workspace Context extender

### loadResourceAsSource

    public static void loadResourceAsSource(JET2Context context,
                                            org.eclipse.core.resources.IResource resource,
                                            java.lang.String resourceLoaderId,
                                            java.lang.String resourceType)
                                     throws CoreJETException,
                                            java.io.IOException

  Load the passed IResource, and set it as the source of the passed JET2Context. This method delegates to `TransformContextExtender.loadModel(URL, String, String)` and then sets a number of context variables describing the loaded resource. Finally, the root of the loaded resource is set as the context source by invoking `JET2Context.setSource(Object)`.

  The following context variables are set for all resources: <bl>

  - org.eclipse.jet.resource.name - the name of the resource. See `VAR_RESOURCE_NAME`.
  - org.eclipse.jet.resource.type - the type of the resource. See `VAR_RESOURCE_TYPE`.
  - org.eclipse.jet.resource.location - the location of the resource. See `VAR_RESOURCE_LOCATION`.
  - org.eclipse.jet.resource.rawLocation - the raw location of the resource. See `VAR_RAW_LOCATION`.
  - org.eclipse.jet.resource.project.name - the project name of the resource. See `VAR_RESOURCE_PROJECT_NAME`.
  - org.eclipse.jet.resource.fullPath - the full path of the resource. See `VAR_RESOURCE_FULL_PATH`.
  - org.eclipse.jet.resource.projectRelativePath - the project relative path of the resource. See `VAR_RESOURCE_PROJECT_RELATIVE_PATH`.
  - org.eclipse.jet.resource.fileExtension - the file extension of the resource. See `VAR_RESOURCE_FILE_EXTENSION`.
  - org.eclipse.jet.resource.fileName - the file name (without extension) of the resource. See `VAR_RESOURCE_FILE_NAME`.
  </bl>

  The following variables are set for resources of type file and folder only: <bl>

  - org.eclipse.jet.resource.parent.name - the name of the resource's parent. See `VAR_RESOURCE_NAME`.
  - org.eclipse.jet.resource.parent.location - the location of the resource's parent. See `VAR_RESOURCE_LOCATION`.
  - org.eclipse.jet.resource.parent.rawLocation - the raw location of the resource's parent. See `VAR_RAW_LOCATION`.
  - org.eclipse.jet.resource.parent.fullPath - the full path of the resource's parent. See `VAR_RESOURCE_FULL_PATH`.
  - org.eclipse.jet.resource.parent.projectRelativePath - the project relative path of the resource's parent. See `VAR_RESOURCE_PROJECT_RELATIVE_PATH`.
  </bl>

  In general, the names of the properties correspond to getX() functions of `IResource`.

  Parameters:
    `context` - the JET2Context into which the loaded model will be set as source.
    `resource` - the resource to load
    `resourceLoaderId` - the id of the model loader to use, or `null`.
    `resourceType` - the type of the resource, or `null`.
  Throws:
    `CoreJETException` - if the resource cannot be loaded
    `java.io.IOException` - if the loader fails to load the resource.
  See Also:
    `IResource.getName()`, `IResource.getType()`, `IResource.getLocation()`, `IResource.getRawLocation()`, `IResource.getProject()`, `IResource.getFullPath()`, `IResource.getProjectRelativePath()`, `IResource.getFileExtension()`, `IResource.getParent()`

Copyright 2006 IBM Corporation and others. All Rights Reserved.