org.jdesktop.swingx.decorator
Class DefaultSelectionMapper

java.lang.Object
  extended by org.jdesktop.swingx.decorator.DefaultSelectionMapper
All Implemented Interfaces:
SelectionMapper

public class DefaultSelectionMapper
extends Object
implements SelectionMapper

Responsible for keeping track of selection in model coordinates.

updates view selection on pipeline change. updates model selection on view selection change.


Field Summary
protected  DefaultListSelectionModel modelSelection
          selection in model coordinates.
 
Constructor Summary
DefaultSelectionMapper(FilterPipeline pipeline, ListSelectionModel selection)
          PRE: selection != null;
 
Method Summary
 void clearModelSelection()
           
 ListSelectionModel getViewSelectionModel()
          
 void insertIndexInterval(int start, int length, boolean before)
          Adjust the model by adding the specified rows.
 boolean isEnabled()
          
protected  void mapTowardsView()
          Populate view selection from model selection.
 void removeIndexInterval(int start, int end)
          Adjust the model by removing the specified rows.
 void setEnabled(boolean enabled)
          Toggle whether selection mapping is active.
 void setFilters(FilterPipeline pipeline)
          Install the new filter pipeline and map the newly filtered data towards the view.
 void setViewSelectionModel(ListSelectionModel viewSelectionModel)
          sets the view selection model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modelSelection

protected final DefaultListSelectionModel modelSelection
selection in model coordinates.

Constructor Detail

DefaultSelectionMapper

public DefaultSelectionMapper(FilterPipeline pipeline,
                              ListSelectionModel selection)
PRE: selection != null;

Parameters:
pipeline -
selection -
Method Detail

setViewSelectionModel

public void setViewSelectionModel(ListSelectionModel viewSelectionModel)
sets the view selection model. Must not be null.

Specified by:
setViewSelectionModel in interface SelectionMapper
Parameters:
viewSelectionModel - holding selected indices in view coordinates

getViewSelectionModel

public ListSelectionModel getViewSelectionModel()

Specified by:
getViewSelectionModel in interface SelectionMapper
Returns:
view selection model

setFilters

public void setFilters(FilterPipeline pipeline)
Description copied from interface: SelectionMapper
Install the new filter pipeline and map the newly filtered data towards the view.

Specified by:
setFilters in interface SelectionMapper

mapTowardsView

protected void mapTowardsView()
Populate view selection from model selection. This is used to keep the view's logical selection in sync whenever the model changes due to filtering or sorting.


setEnabled

public void setEnabled(boolean enabled)
Toggle whether selection mapping is active. If mapping is active, user actions to select rows in the view will be recorded in model coordinates. When the model changes due to filtering, the view selection will be updated to maintain the logical selection.

Specified by:
setEnabled in interface SelectionMapper

isEnabled

public boolean isEnabled()

Specified by:
isEnabled in interface SelectionMapper
Returns:
true if selection mapping is active.

clearModelSelection

public void clearModelSelection()
Specified by:
clearModelSelection in interface SelectionMapper

insertIndexInterval

public void insertIndexInterval(int start,
                                int length,
                                boolean before)
Description copied from interface: SelectionMapper
Adjust the model by adding the specified rows.

Specified by:
insertIndexInterval in interface SelectionMapper

removeIndexInterval

public void removeIndexInterval(int start,
                                int end)
Description copied from interface: SelectionMapper
Adjust the model by removing the specified rows.

Specified by:
removeIndexInterval in interface SelectionMapper