# com.bea.ide.control.filegen
AbstractFileGenAction Class

public abstract class AbstractFileGenAction
extends `DefaultAction`

Base class for actions that generate files from a parent file..

Hierarchy
  `Object`
  `DefaultAction`
  `AbstractFileGenAction`

All Implemented Interfaces
  `ActionListener`, `EventListener`, `IAction`, `PropertyChangeListener`

## Field Summary

`protected `URI`` | `_overrideDestUri` URI
`protected `URI`` | `_overrideSourceUri` URI
`protected static `ResourceSvc.IResourcePkg`` | `_res` strings at bottom of source file.

Fields from com.bea.ide.actions`.`DefaultAction``
``_proxy``

## Constructor Summary

AbstractFileGenAction()

## Method Summary

`public void` | `actionPerformed`(`ActionEvent` aevt) Perform the file generation, based on calculated or set parameters.
`public `URI`` | `generate`(`URI` sourceURI) Generate a child file from the given parent.
`public boolean` | `generate`(`URI` sourceURI, `URI` destURI) Generate a specific destination from the given parent.
`protected `String`` | `getClassFromURI`(`URI` path) Calculate a classname based on a filename.
`protected `String`` | `getContents`(`URI` sourceURI, `URI` destURI) Get the contents for the destination file.
`protected abstract `URI`` | `getDestURI`(`URI` sourceURI) Calculate the URI to generate.
`protected `String`` | `getPackageFromURI`(`URI` path) Calculate a package based on a filename.
`protected `URI`` | `getPopupURI`() get the URI for the workspace popup menu, if exactly one file is selected.
`protected abstract `String`` | `getPropertyName`() The name of the property in the IPropertyInfoFeature that contains the base for this generated file.
`protected `URI`` | `getSourceURI`() the URI we're acting on.
`public `String`` | `getSrc`(`Reader` in, `IFile` sourceFile) Get the source contents as a string.
`public boolean` | `isAncestor`(`URI` sourceURI, `URI` destURI) Check the getParent() hierarchy of the source URI to ensure that we're not about to create a loop.
`protected boolean` | `isError`(`URI` sourceURI, `URI` destURI) Check for and show errors related to autogeneration.
`public void` | `prepare`(`IPopupContext` pc) prepares for a popup.
`protected void` | `saveContents`(`URI` source, `URI` destination, `String` contents) Save the given contents to the destination.
`public void` | `setDestinationURI`(`URI` dest) Set the source URI explicitly.
`public void` | `setSourceURI`(`URI` source) Set the source URI explicitly.
`protected void` | `showError`(`String` error) Show an error during autogeneration.
`public static `String`` | `staticGetSrc`(`Reader` in, `IFile` sourceFile) Static version of getSrc.

Methods from `com.bea.ide.actions.`DefaultAction``
``getProxy`, `propertyChange``

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

Methods from interface `java.awt.event.`ActionListener``
`actionPerformed`

Methods from interface `com.bea.ide.actions.`IAction``
``actionPerformed`, `propertyChange``

Methods from interface `java.beans.`PropertyChangeListener``
`propertyChange`

## Field Detail

### _overrideDestUri

    protected URI _overrideDestUri

### _overrideSourceUri

    protected URI _overrideSourceUri

### _res

    protected static ResourceSvc.IResourcePkg _res

  strings at bottom of source file.

## Constructor Detail

### AbstractFileGenAction

    public AbstractFileGenAction()

## Method Detail

### actionPerformed(ActionEvent) Method

    public void actionPerformed(ActionEvent aevt)

Perform the file generation, based on calculated or set parameters.

#### Parameters

aevt
  AWT action event associated with this invocation.

### generate(URI) Method

    public URI generate(URI sourceURI)

Generate a child file from the given parent.

#### Returns

the URI of the generated file, or null if none was generated.

### generate(URI, URI) Method

    public boolean generate(URI sourceURI,
                            URI destURI)

Generate a specific destination from the given parent.

#### Parameters

sourceURI
  the parent file.

destURI
  the destination file.

#### Returns

true if the file was generated, false otherwise.

### getClassFromURI(URI) Method

    protected String getClassFromURI(URI path)

Calculate a classname based on a filename.

#### Parameters

path
  the URI to a file.

#### Returns

a best-guess classname (without package) for the file.

### getContents(URI, URI) Method

    protected String getContents(URI sourceURI,
                                 URI destURI)

Get the contents for the destination file. This is often the easiest method to override to make specific changes to the file generation.

#### Parameters

sourceURI
  the source document.

destURI
  the document being generated.

#### Returns

the contents which should be written to destURI.

### getDestURI(URI) Method

    protected abstract URI getDestURI(URI sourceURI)

Calculate the URI to generate. This will generally be found by chopping off the extension and adding a new one.

#### Parameters

sourceURI
  the URI we're acting upon.

#### Returns

The URI this action will create.

### getPackageFromURI(URI) Method

    protected String getPackageFromURI(URI path)

Calculate a package based on a filename.

#### Parameters

path
  the URI to a file. This URI must be in a project.

#### Returns

a best-guess package for the file.

### getPopupURI() Method

    protected URI getPopupURI()

get the URI for the workspace popup menu, if exactly one file is selected. Null otherwise. Not used unless a subclass calls it.

### getPropertyName() Method

    protected abstract String getPropertyName()

The name of the property in the IPropertyInfoFeature that contains the base for this generated file.

### getSourceURI() Method

    protected URI getSourceURI()

the URI we're acting on. By default, the currently displayed file, but could be overridden by a subclass to work on a popup. The easy way to override is to return getPopupURI();

#### Returns

the URI for the source file.

### getSrc(Reader, IFile) Method

    public String getSrc(Reader in,
                         IFile sourceFile)

Get the source contents as a string. This does some checking of encoding as well.

#### Parameters

in
  a Reader for the source document.

sourceFile
  the IFile of the source document

#### Returns

a String containing the contents of the source document.

### isAncestor(URI, URI) Method

    public boolean isAncestor(URI sourceURI,
                              URI destURI)

Check the getParent() hierarchy of the source URI to ensure that we're not about to create a loop.

#### Returns

true if the dest is an autogen ancestor of source.

### isError(URI, URI) Method

    protected boolean isError(URI sourceURI,
                              URI destURI)

Check for and show errors related to autogeneration. This verifies that the destination is writable, that it's not creating an autogen loop, and that the source document does not contain compilation errors.

#### Returns

true if errors prevent this action from working, false if it should continue.

### prepare(IPopupContext) Method

    public void prepare(IPopupContext pc)

prepares for a popup. Set my state to show or not on the menu based on the workspace state. We don't actually implement IPopupMenu, this just makes it trivial for subclasses to do so.

### saveContents(URI, URI, String) Method

    protected void saveContents(URI source,
                                URI destination,
                                String contents)

Save the given contents to the destination.

#### Parameters

source
  the URI of the source file.

destination
  the URI to write to.

contents
  the contents which should be written.

### setDestinationURI(URI) Method

    public void setDestinationURI(URI dest)

Set the source URI explicitly. Not all subclasses honor this.

#### Parameters

dest
  The URI that this action will create. If null, it will be calculated based on the source URI.

### setSourceURI(URI) Method

    public void setSourceURI(URI source)

Set the source URI explicitly. Not all subclasses honor this.

#### Parameters

source
  The URI that this action will use as a source when generating a file. If this is null, the source will come from the workspace tree or active document, depending on the specific subclass being used.

### showError(String) Method

    protected void showError(String error)

Show an error during autogeneration.

#### Parameters

error
  the description of the error.

### staticGetSrc(Reader, IFile) Method

    public static String staticGetSrc(Reader in,
                                      IFile sourceFile)

Static version of getSrc.