Package org.jdesktop.swingx.decorator
Class DefaultSelectionMapper
- java.lang.Object
-
- org.jdesktop.swingx.decorator.DefaultSelectionMapper
-
- All Implemented Interfaces:
SelectionMapper
public class DefaultSelectionMapper extends java.lang.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
Fields Modifier and Type Field Description protected javax.swing.DefaultListSelectionModel
modelSelection
selection in model coordinates.
-
Constructor Summary
Constructors Constructor Description DefaultSelectionMapper(FilterPipeline pipeline, javax.swing.ListSelectionModel selection)
PRE: selection != null;
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearModelSelection()
javax.swing.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(javax.swing.ListSelectionModel viewSelectionModel)
sets the view selection model.
-
-
-
Constructor Detail
-
DefaultSelectionMapper
public DefaultSelectionMapper(FilterPipeline pipeline, javax.swing.ListSelectionModel selection)
PRE: selection != null;- Parameters:
pipeline
-selection
-
-
-
Method Detail
-
setViewSelectionModel
public void setViewSelectionModel(javax.swing.ListSelectionModel viewSelectionModel)
sets the view selection model. Must not be null.- Specified by:
setViewSelectionModel
in interfaceSelectionMapper
- Parameters:
viewSelectionModel
- holding selected indices in view coordinates
-
getViewSelectionModel
public javax.swing.ListSelectionModel getViewSelectionModel()
- Specified by:
getViewSelectionModel
in interfaceSelectionMapper
- 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 interfaceSelectionMapper
-
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 interfaceSelectionMapper
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabled
in interfaceSelectionMapper
- Returns:
- true if selection mapping is active.
-
clearModelSelection
public void clearModelSelection()
- Specified by:
clearModelSelection
in interfaceSelectionMapper
-
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 interfaceSelectionMapper
-
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 interfaceSelectionMapper
-
-