net.refractions.udig.ui
Class FeatureTypeEditor

java.lang.Object
  extended by net.refractions.udig.ui.FeatureTypeEditor

public class FeatureTypeEditor
extends java.lang.Object

A composite editor based on a JFace TreeViewer for creating and editing feature types.

Since:
1.1.0
Author:
jones

Nested Class Summary
 class FeatureTypeEditor.AttributeCellModifier
           
static class FeatureTypeEditor.FeatureTypeContentProvider
          A Tree Content Provider that serves up attributeTypes from a FeatureType as a parent.
static class FeatureTypeEditor.FeatureTypeLabelProvider
          Label provider for labelling AttributeTypes
 
Constructor Summary
FeatureTypeEditor()
           
 
Method Summary
 void builderChanged()
          Updates the viewer so it matches the state of the builder.
 MenuManager createContextMenu()
          Creates a ContextMenu (the menu is created using the Table's composite as a parent) and returns the contextMenu.
 FeatureTypeBuilder createDefaultFeatureType()
          Creates a default FeatureTypeBuilder.
 void createFeatureTypeNameText(Composite parent, java.lang.Object layoutData)
          Creates a Text input object that for modify the feature type name.
 void createTable(Composite parent, java.lang.Object layoutData)
          Create the table control and set the input.
 void createTable(Composite parent, java.lang.Object layoutData, FeatureType type)
          Create the table control and set the input.
 void createTable(Composite parent, java.lang.Object layoutData, FeatureTypeBuilder builder, boolean editable)
          Create the table control and set the input.
 Control getControl()
          Returns the control that is the FeatureTypeEditor
 IAction getCreateAttributeAction()
          Returns an action that will add a new attribute to the FeatureType.
 IAction getDeleteAction()
          Returns an action that will delete the selected attributes from the FeatureType.
 FeatureType getFeatureType()
          Retrieves the new FeatureType.
 FeatureTypeBuilder getFeatureTypeBuilder()
          Returns the FeatureTypeBuilder that is used for editing the feature type.
 java.util.List<LegalAttributeTypes> getLegalTypes()
           
 void setDefaultCRS(CoordinateReferenceSystem crs)
           
 void setEditable(boolean editable)
          Sets whether the table is editable or just a viewer.
 void setFeatureType(FeatureType type)
          Sets the FeatureType being edited.
 void setFeatureTypeBuilder(FeatureTypeBuilder newBuilder)
          Sets the FeatureTypeBuilder used for creating the feature type.
 void setGlobalActions(IActionBars actionBars)
          Sets the Global actions that apply.
 void setLegalTypes(java.util.List<LegalAttributeTypes> legalTypes)
          Declares what types are permitted as attributes.
 Text testingGetNameText()
           
static java.util.List<LegalAttributeTypes> testingGetTYPES()
          PUBLIC ONLY so tests can verify the correct behaviour.
 TreeViewer testingGetViewer()
          PUBLIC ONLY so tests can verify the correct behaviour.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeatureTypeEditor

public FeatureTypeEditor()
Method Detail

createTable

public void createTable(Composite parent,
                        java.lang.Object layoutData)
Create the table control and set the input.

Parameters:
parent - the composite that will be used as the TreeViewer's parent.
layoutData - the layout data to use to layout the editor. If null GridData(Fill_Both)

createTable

public void createTable(Composite parent,
                        java.lang.Object layoutData,
                        FeatureType type)
Create the table control and set the input.

Parameters:
parent - the composite that will be used as the TreeViewer's parent.
layoutData - the layout data to use to layout the editor. If null GridData(Fill_Both)

createTable

public void createTable(Composite parent,
                        java.lang.Object layoutData,
                        FeatureTypeBuilder builder,
                        boolean editable)
Create the table control and set the input.

Parameters:
parent - the composite that will be used as the TreeViewer's parent.
layoutData - the layout data to use to layout the editor. If null GridData(Fill_Both)

setLegalTypes

public void setLegalTypes(java.util.List<LegalAttributeTypes> legalTypes)
Declares what types are permitted as attributes. For example Shapefiles do not permit Geometry as a legal type.

Parameters:
legalTypes - the List of legal types in the order they will be displayed.

getLegalTypes

public java.util.List<LegalAttributeTypes> getLegalTypes()
Returns:
Returns the list of types that this editor will allow the use to select

setEditable

public void setEditable(boolean editable)
Sets whether the table is editable or just a viewer.

Parameters:
editable - if true then the table can be edited

createContextMenu

public MenuManager createContextMenu()
Creates a ContextMenu (the menu is created using the Table's composite as a parent) and returns the contextMenu.

It is recommended that the MenuManager be registered with an IWorkbenchPartSite

Returns:
a MenuManager for the contextMenu.

setGlobalActions

public void setGlobalActions(IActionBars actionBars)
Sets the Global actions that apply. IE sets the delete global action.

Parameters:
actionBars -

setFeatureType

public void setFeatureType(FeatureType type)
Sets the FeatureType being edited. If type is null then a new featureType is created. Must be called in the display thread.

Parameters:
type - then new FeatureType to be edited, or null to create a new type.

setFeatureTypeBuilder

public final void setFeatureTypeBuilder(FeatureTypeBuilder newBuilder)
Sets the FeatureTypeBuilder used for creating the feature type.

Parameters:
builder -

createDefaultFeatureType

public FeatureTypeBuilder createDefaultFeatureType()
Creates a default FeatureTypeBuilder. The default builder has a geometry attribute and a name attribute. The geometry attribute is a linestring.

Returns:
a default FeatureTypeBuilder.

setDefaultCRS

public void setDefaultCRS(CoordinateReferenceSystem crs)

getCreateAttributeAction

public IAction getCreateAttributeAction()
Returns an action that will add a new attribute to the FeatureType.

Returns:
an action that will add a new attribute to the FeatureType.

getDeleteAction

public IAction getDeleteAction()
Returns an action that will delete the selected attributes from the FeatureType.

Returns:
an action that will delete the selected attributes from the FeatureType.

createFeatureTypeNameText

public void createFeatureTypeNameText(Composite parent,
                                      java.lang.Object layoutData)
Creates a Text input object that for modify the feature type name.

Parameters:
parent - the parent of the text object

getFeatureType

public FeatureType getFeatureType()
                           throws SchemaException
Retrieves the new FeatureType. Must be called in the display thread. May return null.

Returns:
the new FeatureType.
Throws:
SchemaException

getFeatureTypeBuilder

public FeatureTypeBuilder getFeatureTypeBuilder()
Returns the FeatureTypeBuilder that is used for editing the feature type.

Returns:
the FeatureTypeBuilder that is used for editing the feature type.

getControl

public Control getControl()
Returns the control that is the FeatureTypeEditor

Returns:
the control that is the FeatureTypeEditor

testingGetViewer

public TreeViewer testingGetViewer()
PUBLIC ONLY so tests can verify the correct behaviour.


testingGetTYPES

public static java.util.List<LegalAttributeTypes> testingGetTYPES()
PUBLIC ONLY so tests can verify the correct behaviour.


testingGetNameText

public Text testingGetNameText()

builderChanged

public void builderChanged()
Updates the viewer so it matches the state of the builder.