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, Andrea Antonello (www.hydrologis.com)

Nested Class Summary
 class FeatureTypeEditor.AttributeCellModifier
           
static class FeatureTypeEditor.FeatureTypeContentProvider
          A Tree Content Provider that serves up attributeTypes from a SimpleFeatureType as a parent.
static class FeatureTypeEditor.FeatureTypeLabelProvider
          Label provider for labeling AttributeTypes.
 
Constructor Summary
FeatureTypeEditor()
           
 
Method Summary
 void builderChanged()
          Updates the viewer so it matches the state of the builder.
 SimpleFeatureTypeBuilder builderFromFeatureType(SimpleFeatureType ft)
           
 MenuManager createContextMenu()
          Creates a ContextMenu (the menu is created using the Table's composite as a parent) and returns the contextMenu.
 SimpleFeatureType createDefaultFeatureType()
          Creates a default FeatureType.
 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, SimpleFeatureType type)
          Create the table control and set the input.
 void createTable(Composite parent, java.lang.Object layoutData, SimpleFeatureType featureType, 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 SimpleFeatureType.
 IAction getDeleteAction()
          Returns an action that will delete the selected attributes from the SimpleFeatureType.
 SimpleFeatureType getFeatureType()
          Retrieves the new SimpleFeatureType.
 SimpleFeatureTypeBuilder 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 setErrorMessage(java.lang.String errorMessage)
           
 void setFeatureType(SimpleFeatureType type)
          Sets the SimpleFeatureType being edited.
 void setFeatureTypeBuilder(SimpleFeatureTypeBuilder newBuilder)
          Deprecated. with the new SimpleFeatureTypeBuilder this is no more possible, therefore deprecating.
 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,
                        SimpleFeatureType 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,
                        SimpleFeatureType featureType,
                        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).
featureType - the FeatureType to use to populate the table.
editable - the editable flag of the table

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

builderFromFeatureType

public SimpleFeatureTypeBuilder builderFromFeatureType(SimpleFeatureType ft)

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(SimpleFeatureType type)
Sets the SimpleFeatureType being edited.

If type is null then a new featureType is created. Must be called in the display thread.

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

setFeatureTypeBuilder

public final void setFeatureTypeBuilder(SimpleFeatureTypeBuilder newBuilder)
Deprecated. with the new SimpleFeatureTypeBuilder this is no more possible, therefore deprecating.

Sets the FeatureTypeBuilder used for creating the feature type.

Parameters:
builder -

createDefaultFeatureType

public SimpleFeatureType createDefaultFeatureType()
Creates a default FeatureType.

The default type has a Geometry attribute and a name attribute. The geometry attribute is a LineString.

Returns:
a default FeatureType.

setDefaultCRS

public void setDefaultCRS(CoordinateReferenceSystem crs)

getCreateAttributeAction

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

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

getDeleteAction

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

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

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 SimpleFeatureType getFeatureType()
Retrieves the new SimpleFeatureType. Must be called in the display thread. May return null.

Returns:
the new SimpleFeatureType.

getFeatureTypeBuilder

public SimpleFeatureTypeBuilder 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.


setErrorMessage

public void setErrorMessage(java.lang.String errorMessage)