Package docking.widgets.table
Class RowObjectSelectionManager<T>
- java.lang.Object
-
- javax.swing.DefaultListSelectionModel
-
- docking.widgets.table.RowObjectSelectionManager<T>
-
- All Implemented Interfaces:
SelectionManager
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.event.TableModelListener
,javax.swing.ListSelectionModel
public class RowObjectSelectionManager<T> extends javax.swing.DefaultListSelectionModel implements SelectionManager
A class to track and restore selections made in a table. We use this in the docking environment primarily due to the heavy usage of filtering for most tables. As tables are filtered, the contents change (and then change back when the filter is removed). It is nice to be able to filter a table, select an item of interest, and then unfilter the table to see that item in more context.Notes on usage:
- Some table models are sensitive to the order in which
TableModel#tableChanged()
is called. These models should either not use this SelectionManger, or need to change their code to be more robust. As an example, theDefaultSortedTableModel
updates its indexes in odd ways. Further, there is a chance that the state of its indexing is incorrect when tableChanged is called. So, that model has to account for the fact that it may get called by this class when it is in a bad state.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RowObjectSelectionManager(javax.swing.JTable table, RowObjectTableModel<T> model)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSelectionManagerListener(SelectionManagerListener listener)
void
clearSavedSelection()
void
clearSelection()
void
dispose()
protected void
fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
void
removeSelectionManagerListener(SelectionManagerListener listener)
void
setLogger(org.apache.logging.log4j.Logger logger)
Sets the logger used by this class.void
tableChanged(javax.swing.event.TableModelEvent e)
protected java.util.List<T>
translateRowsToValues(int[] viewRows)
-
Methods inherited from class javax.swing.DefaultListSelectionModel
addListSelectionListener, addSelectionInterval, clone, fireValueChanged, fireValueChanged, getAnchorSelectionIndex, getLeadSelectionIndex, getListeners, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getSelectionMode, getValueIsAdjusting, insertIndexInterval, isLeadAnchorNotificationEnabled, isSelectedIndex, isSelectionEmpty, moveLeadSelectionIndex, removeIndexInterval, removeListSelectionListener, removeSelectionInterval, setAnchorSelectionIndex, setLeadAnchorNotificationEnabled, setLeadSelectionIndex, setSelectionInterval, setSelectionMode, setValueIsAdjusting, toString
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.swing.ListSelectionModel
addListSelectionListener, addSelectionInterval, getAnchorSelectionIndex, getLeadSelectionIndex, getMaxSelectionIndex, getMinSelectionIndex, getSelectedIndices, getSelectedItemsCount, getSelectionMode, getValueIsAdjusting, insertIndexInterval, isSelectedIndex, isSelectionEmpty, removeIndexInterval, removeListSelectionListener, removeSelectionInterval, setAnchorSelectionIndex, setLeadSelectionIndex, setSelectionInterval, setSelectionMode, setValueIsAdjusting
-
-
-
-
Constructor Detail
-
RowObjectSelectionManager
public RowObjectSelectionManager(javax.swing.JTable table, RowObjectTableModel<T> model)
-
-
Method Detail
-
setLogger
public void setLogger(org.apache.logging.log4j.Logger logger)
Sets the logger used by this class. Useful for debugging individual table issues.- Specified by:
setLogger
in interfaceSelectionManager
- Parameters:
logger
- The logger to be used by this manager, which has tracing embedded in its code.
-
addSelectionManagerListener
public void addSelectionManagerListener(SelectionManagerListener listener)
- Specified by:
addSelectionManagerListener
in interfaceSelectionManager
-
removeSelectionManagerListener
public void removeSelectionManagerListener(SelectionManagerListener listener)
- Specified by:
removeSelectionManagerListener
in interfaceSelectionManager
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceSelectionManager
-
clearSavedSelection
public void clearSavedSelection()
- Specified by:
clearSavedSelection
in interfaceSelectionManager
-
clearSelection
public void clearSelection()
- Specified by:
clearSelection
in interfacejavax.swing.ListSelectionModel
- Overrides:
clearSelection
in classjavax.swing.DefaultListSelectionModel
-
fireValueChanged
protected void fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
- Overrides:
fireValueChanged
in classjavax.swing.DefaultListSelectionModel
-
translateRowsToValues
protected java.util.List<T> translateRowsToValues(int[] viewRows)
-
tableChanged
public void tableChanged(javax.swing.event.TableModelEvent e)
- Specified by:
tableChanged
in interfacejavax.swing.event.TableModelListener
-
-