net.refractions.udig.ui
Class FeatureTableControl

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

public class FeatureTableControl
extends java.lang.Object

A TreeViewer control for viewing a table of SimpleFeature attributes.

The object is used by using a FeatureCollection. In this case the control hangs on to a reference to the FeatureCollection and populates the table entries directory from it. This method results in a single page containing all features.

If the FeatureCollection implements the IAdaptable interface and adapts to ICellModifier then the table is editable. The ICellModifier is used to modify the features. The Column properties passed to the ICellModifier are the attribute name of the attribute being modified.

If the FeatureCollection implements the IAdaptable interface and adapts to CellEditor[] then the cell editors will be used to edit the cells. This is optional for editing. By default a TextCellEditor is used for editing most cells, and an AttributeValidator is used to validate the new values. The first column is for the fid column and will not be used since FIDS are assigned by the datastore and can not be modified. The number of Items the array (this is the same for the cell editor validators and cell editor listeners) must be either the number of attributes in the feature type or the number of attributes + 1 (one for the FID column). If the number of editors it Attributes+1 then the first element in the array will not be used as it is assumed to be a placeholder for the fid column.

If the FeatureCollection implements the IAdaptable interface and adapts to ICellEditorValidator[] then the validators will be used to validate the cells.

If the FeatureCollection implements the IAdaptable interface and adapts to ICellEditorListener[] then the listeners will be added to the CellEditors.

Since:
0.3
Author:
jdeolive, jeichar

Field Summary
static java.lang.String[] ALL
          Indicates that all attribute types will be searched by the select method
static java.lang.String CACHING_WARNING
          Key for indicating whether the warning should be displayed.
static java.lang.Object ERROR_COLUMN_PROPERTY
           
static java.lang.String FEATURE_ID_COLUMN_PROPERTY
           
static java.lang.Object LOADING
           
 
Constructor Summary
FeatureTableControl()
          Construct FeatureTableControl.
FeatureTableControl( monitorProvider)
          Construct FeatureTableControl.
FeatureTableControl( monitorProvider, Composite parent,  features)
          Construct a FeatureTableControl.
FeatureTableControl(Composite parent,  features)
          Construct a FeatureTableControl.
 
Method Summary
 void addLoadingListener(IFeatureTableLoadingListener listener)
           
 void addSelectionChangedListener(ISelectionChangedListener listener)
           
 void assertInternallyConsistent()
          Checks all the lists, caches, content providers, etc...
 void clear()
          Don't display nothing :-)
 void createTableControl(Composite parent)
          Creates the table control.
protected  void createTableViewer(Composite parent)
          Creates the table control itself.
  deleteSelection()
          Removes the selected features (the features selected by the owning FeatureTableControl).
 void dispose()
           
 Control getControl()
          Returns the control representing the table control.
  getFeatures()
          Contents of the current page of features
 int getPageSize()
          Returns the number of features viewed in the table per page.
 ISelection getSelection()
          Returns a selection with a single Id indicating the features selected
 int getSelectionCount()
           
 TableViewer getViewer()
           
 void message(java.lang.String text)
          Displays a message.
 void message(java.lang.String text, Color background, Color foreground)
          Displays a message.
protected  void notifyLoadingListeners(net.refractions.udig.ui.LoadingEvent event)
           
 void promoteSelection()
          Sorts the table so that the selection is at the top of the table.
 void remove(IFeatureTableLoadingListener listener)
           
 void removeSelectionChangedListener(ISelectionChangedListener listener)
           
 void select(java.util.Set<FeatureId> selection)
           
 void select(java.lang.String cql, boolean selectAll)
           
 void select(java.lang.String text, java.lang.String[] attributes, boolean selectAll)
          select the features found that has the text.
 void setFeatures( features)
          Set up for a single page of content
 void setFocus()
          Does nothing.
 void setMenuManager(MenuManager contextMenu)
          Sets the context Menu used by the table view.
 void setPageSize(int resPerPage)
          Sets the number of features viewed in the table per page.
 void setSelection(ISelection newSelection)
          Useable selections are: selection of features, FIDS and Filters/Queries that adapt to a FeatureSource
 void setSelection(StructuredSelection selection, boolean reveal)
           
 void setSelectionColor( selectionColor)
           
 boolean showWarning(Display display)
          show the warning about loading features into memory.
 void sort(java.util.Comparator<SimpleFeature> comparator, int dir, TableColumn sortColumn)
          Sorts the features in the tableView.
 void update()
          Updates the table control with the current set of features.
 void update( features2)
          Updates the features that have the same feature ID to match the new feature or adds the features if they are not part of the current collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FEATURE_ID_COLUMN_PROPERTY

public static final java.lang.String FEATURE_ID_COLUMN_PROPERTY
See Also:
Constant Field Values

ERROR_COLUMN_PROPERTY

public static final java.lang.Object ERROR_COLUMN_PROPERTY

LOADING

public static final java.lang.Object LOADING

CACHING_WARNING

public static final java.lang.String CACHING_WARNING
Key for indicating whether the warning should be displayed. false if the warning is displayed

See Also:
Constant Field Values

ALL

public static final java.lang.String[] ALL
Indicates that all attribute types will be searched by the select method

See Also:
select(String, String[], boolean)
Constructor Detail

FeatureTableControl

public FeatureTableControl()
Construct FeatureTableControl.

Must call setFeatures before use.


FeatureTableControl

public FeatureTableControl(Composite parent,
                            features)
Construct a FeatureTableControl.

Parameters:
monitorProvider - a provider that will provider progress monitors for displaying loading information.
fReader - The FeatureReader that returns the actual features.
resPerPage - Results per page to be shown in the table.

FeatureTableControl

public FeatureTableControl( monitorProvider)
Construct FeatureTableControl.

Must call setFeatures before use.

Parameters:
monitorProvider - a provider that will provider progress monitors for displaying loading information.

FeatureTableControl

public FeatureTableControl( monitorProvider,
                           Composite parent,
                            features)
Construct a FeatureTableControl.

Parameters:
monitorProvider - a provider that will provider progress monitors for displaying loading information.
fReader - The FeatureReader that returns the actual features.
resPerPage - Results per page to be shown in the table.
Method Detail

setPageSize

public void setPageSize(int resPerPage)
Sets the number of features viewed in the table per page.

Parameters:
resPerPage - positive integer.

getPageSize

public int getPageSize()
Returns the number of features viewed in the table per page.

Returns:
positive integer.

getControl

public Control getControl()
Returns the control representing the table control.

Returns:
The internal table viewer control.

dispose

public void dispose()

createTableControl

public void createTableControl(Composite parent)
Creates the table control.

Parameters:
parent - The to be parent of the control.

showWarning

public boolean showWarning(Display display)
show the warning about loading features into memory.


update

public void update()
Updates the table control with the current set of features.

This method will ensure that the column information gets updated


createTableViewer

protected void createTableViewer(Composite parent)
Creates the table control itself.

Parameters:
parent -

setFocus

public void setFocus()
Does nothing.

See Also:
org.eclipse.ui.IWorkbenchPart#setFocus()

getFeatures

public  getFeatures()
Contents of the current page of features

Returns:

setFeatures

public void setFeatures( features)
Set up for a single page of content


clear

public void clear()
Don't display nothing :-)


message

public void message(java.lang.String text,
                    Color background,
                    Color foreground)
Displays a message. If text == null or "" then the message is hidden and tableViewer is shown again.

Parameters:
text - message to display
background - color of the background of the text widget. If null the default color is used
foreground - color of the foreground of the text widget. If null the default color is used

message

public void message(java.lang.String text)
Displays a message. If text == null or "" then the message is hidden and tableViewer is shown again.

Parameters:
text - message to display

getSelection

public ISelection getSelection()
Returns a selection with a single Id indicating the features selected


addSelectionChangedListener

public void addSelectionChangedListener(ISelectionChangedListener listener)

removeSelectionChangedListener

public void removeSelectionChangedListener(ISelectionChangedListener listener)

setSelection

public void setSelection(ISelection newSelection)
Useable selections are: selection of features, FIDS and Filters/Queries that adapt to a FeatureSource


promoteSelection

public void promoteSelection()
Sorts the table so that the selection is at the top of the table. It does not last. The next selection will not be at the top.


sort

public void sort(java.util.Comparator<SimpleFeature> comparator,
                 int dir,
                 TableColumn sortColumn)
Sorts the features in the tableView.

Parameters:
comparator - comparator to use for the sorting.
dir - the direction to set the column SWT.UP or SWT.DOWN. If SWT.UP then the table item with index 0 is at the top of the table otherwise it is at the bottom of the table.
sortColumn - the column that is being sorted

getViewer

public TableViewer getViewer()

setSelection

public void setSelection(StructuredSelection selection,
                         boolean reveal)

getSelectionCount

public int getSelectionCount()

select

public void select(java.util.Set<FeatureId> selection)

select

public void select(java.lang.String cql,
                   boolean selectAll)
            throws CQLException
Throws:
CQLException

select

public void select(java.lang.String text,
                   java.lang.String[] attributes,
                   boolean selectAll)
            throws java.util.regex.PatternSyntaxException
select the features found that has the text. Only the attributes indicated are searched. If ALL is selected then all attributes will be searched

Parameters:
text - text to search for it will first be assumed that it is a reg ex expression
attributes - the attributes to search. See ALL
selectAll - if true all matched features will be selected otherwise just the first feature
Throws:
java.util.regex.PatternSyntaxException

addLoadingListener

public void addLoadingListener(IFeatureTableLoadingListener listener)

remove

public void remove(IFeatureTableLoadingListener listener)

notifyLoadingListeners

protected void notifyLoadingListeners(net.refractions.udig.ui.LoadingEvent event)

update

public void update( features2)
Updates the features that have the same feature ID to match the new feature or adds the features if they are not part of the current collection.

Parameters:
features2 - the feature collection that contains the modified or new features.

assertInternallyConsistent

public void assertInternallyConsistent()
Checks all the lists, caches, content providers, etc... are consistent with each other. This is an expensive method so should be called with care. A test is a good example.


deleteSelection

public  deleteSelection()
Removes the selected features (the features selected by the owning FeatureTableControl).

Returns:
returns a collection of the deleted features
See Also:
setSelection(ISelection), setSelection(StructuredSelection, boolean)

setMenuManager

public void setMenuManager(MenuManager contextMenu)
Sets the context Menu used by the table view. Not menu is used for the message box.

Parameters:
contextMenu - menu manager used for creating the menu.

setSelectionColor

public void setSelectionColor( selectionColor)