Class FilterTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.openstreetmap.josm.gui.dialogs.FilterTableModel
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.table.TableModel
,ReorderableModel<Filter>
,SortableModel<Filter>
,ReorderableTableModel<Filter>
,SortableTableModel<Filter>
public class FilterTableModel extends javax.swing.table.AbstractTableModel implements SortableTableModel<Filter>
The model that is used for the table in theFilterDialog
.- Since:
- 2125
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
COL_ENABLED
The filter enabled columnstatic int
COL_HIDING
The column indicating if the filter is hiding.static int
COL_INVERTED
The column to invert the filterstatic int
COL_TEXT
The column that displays the filter textprivate OSDLabel
lblOSD
A helper fordrawOSDText(Graphics2D)
(package private) FilterModel
model
The filter model(package private) javax.swing.ListSelectionModel
selectionModel
The selection model
-
Constructor Summary
Constructors Constructor Description FilterTableModel(javax.swing.ListSelectionModel listSelectionModel)
Constructs a newFilterTableModel
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFilter(Filter filter)
Adds a new filter to the filter list.void
addFilters(Filter... filters)
Adds a new filter to the filter list.boolean
doMove(int delta, int... selectedRows)
Performs the move operation, without any check nor selection handling.void
drawOSDText(java.awt.Graphics2D g)
Draws a text on the map display that indicates that filters are active.void
executeFilters()
Runs the filters on the current edit data set, if any.void
executeFilters(boolean force)
Runs the filters on the current edit data set, if any.void
executeFilters(java.util.Collection<? extends OsmPrimitive> primitives)
Runs the filter on a list of primitives that are part of the edit data set, if any.void
executeFilters(java.util.Collection<? extends OsmPrimitive> primitives, boolean force)
Runs the filter on a list of primitives that are part of the edit data set, if any.java.lang.Class<?>
getColumnClass(int column)
int
getColumnCount()
java.lang.String
getColumnName(int column)
java.util.List<Filter>
getFilters()
Returns the list of filters.int
getRowCount()
Returns the number of rows in the list/table.javax.swing.ListSelectionModel
getSelectionModel()
Returns the selection model.Filter
getValue(int rowIndex)
Get object value at given index.java.lang.Object
getValueAt(int row, int column)
boolean
isCellEditable(int row, int column)
boolean
isCellEnabled(int row, int column)
Determines if a cell is enabled.private void
loadPrefs()
boolean
move(int delta, int... selectedRows)
Move selected rows by any number of positions, if possible.void
removeFilter(int rowIndex)
Removes the filter that is displayed in the given rowvoid
removeFilters(int... rowIndexes)
Removes the filters that is displayed in the given rowsvoid
reverse()
Reverse the items order.private void
savePrefs()
Filter
setValue(int rowIndex, Filter filter)
Set object value at given index.void
setValueAt(java.lang.Object aValue, int row, int column)
void
sort()
Sort the items.private void
updateFilters()
private void
updateMap()
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.ReorderableModel
canMove, canMoveDown, canMoveUp
-
Methods inherited from interface org.openstreetmap.josm.gui.util.ReorderableTableModel
canMove, canMoveDown, canMoveDown, canMoveUp, canMoveUp, getSelectedIndices, moveDown, moveDown, moveUp, moveUp, selectedIndices
-
-
-
-
Field Detail
-
COL_ENABLED
public static final int COL_ENABLED
The filter enabled column- See Also:
- Constant Field Values
-
COL_HIDING
public static final int COL_HIDING
The column indicating if the filter is hiding.- See Also:
- Constant Field Values
-
COL_TEXT
public static final int COL_TEXT
The column that displays the filter text- See Also:
- Constant Field Values
-
COL_INVERTED
public static final int COL_INVERTED
The column to invert the filter- See Also:
- Constant Field Values
-
model
final FilterModel model
The filter model
-
selectionModel
final javax.swing.ListSelectionModel selectionModel
The selection model
-
lblOSD
private final OSDLabel lblOSD
A helper fordrawOSDText(Graphics2D)
-
-
Constructor Detail
-
FilterTableModel
public FilterTableModel(javax.swing.ListSelectionModel listSelectionModel)
Constructs a newFilterTableModel
.- Parameters:
listSelectionModel
- selection model
-
-
Method Detail
-
updateFilters
private void updateFilters()
-
executeFilters
public void executeFilters()
Runs the filters on the current edit data set, if any. Does nothing if no filter is enabled.
-
executeFilters
public void executeFilters(java.util.Collection<? extends OsmPrimitive> primitives)
Runs the filter on a list of primitives that are part of the edit data set, if any. Does nothing if no filter is enabled.- Parameters:
primitives
- The primitives
-
executeFilters
public void executeFilters(boolean force)
Runs the filters on the current edit data set, if any.- Parameters:
force
- force execution of filters even if no filter is enabled. Useful to reset state after change of filters- Since:
- 14206
-
executeFilters
public void executeFilters(java.util.Collection<? extends OsmPrimitive> primitives, boolean force)
Runs the filter on a list of primitives that are part of the edit data set, if any.- Parameters:
force
- force execution of filters even if no filter is enabled. Useful to reset state after change of filtersprimitives
- The primitives- Since:
- 14206
-
updateMap
private void updateMap()
-
loadPrefs
private void loadPrefs()
-
savePrefs
private void savePrefs()
-
addFilter
public void addFilter(Filter filter)
Adds a new filter to the filter list.- Parameters:
filter
- The new filter- See Also:
for bulk addition
-
addFilters
public void addFilters(Filter... filters)
Adds a new filter to the filter list.- Parameters:
filters
- The new filter- Since:
- 18556
-
doMove
public boolean doMove(int delta, int... selectedRows)
Description copied from interface:ReorderableModel
Performs the move operation, without any check nor selection handling.- Specified by:
doMove
in interfaceReorderableModel<Filter>
- Parameters:
delta
- negative or positive deltaselectedRows
- rows to move- Returns:
true
if rows have been moved
-
move
public boolean move(int delta, int... selectedRows)
Description copied from interface:ReorderableTableModel
Move selected rows by any number of positions, if possible.- Specified by:
move
in interfaceReorderableTableModel<Filter>
- Parameters:
delta
- negative or positive deltaselectedRows
- rows to move- Returns:
true
if the move was performed- See Also:
ReorderableTableModel.canMove(int)
-
removeFilter
public void removeFilter(int rowIndex)
Removes the filter that is displayed in the given row- Parameters:
rowIndex
- The index of the filter to remove- See Also:
removeFilters(int...)
-
removeFilters
public void removeFilters(int... rowIndexes)
Removes the filters that is displayed in the given rows- Parameters:
rowIndexes
- The indexes of the filters to remove- Since:
- 18556
-
setValue
public Filter setValue(int rowIndex, Filter filter)
Description copied from interface:ReorderableModel
Set object value at given index.- Specified by:
setValue
in interfaceReorderableModel<Filter>
- Parameters:
rowIndex
- indexfilter
- new value- Returns:
- the value previously at the specified position
-
getValue
public Filter getValue(int rowIndex)
Description copied from interface:ReorderableModel
Get object value at given index.- Specified by:
getValue
in interfaceReorderableModel<Filter>
- Parameters:
rowIndex
- index- Returns:
- object value at given index
-
getSelectionModel
public javax.swing.ListSelectionModel getSelectionModel()
Description copied from interface:ReorderableTableModel
Returns the selection model.- Specified by:
getSelectionModel
in interfaceReorderableTableModel<Filter>
- Returns:
- the selection model (never null)
- See Also:
JList.getSelectionModel()
,JTable.getSelectionModel()
-
getRowCount
public int getRowCount()
Description copied from interface:ReorderableTableModel
Returns the number of rows in the list/table.- Specified by:
getRowCount
in interfaceReorderableTableModel<Filter>
- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
- Returns:
- the number of rows in the list/table
- See Also:
ListModel.getSize()
,TableModel.getRowCount()
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
-
getColumnName
public java.lang.String getColumnName(int column)
- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.AbstractTableModel
-
getColumnClass
public java.lang.Class<?> getColumnClass(int column)
- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classjavax.swing.table.AbstractTableModel
-
isCellEnabled
public boolean isCellEnabled(int row, int column)
Determines if a cell is enabled.- Parameters:
row
- row indexcolumn
- column index- Returns:
true
if the cell at (row, column) is enabled
-
isCellEditable
public boolean isCellEditable(int row, int column)
- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in classjavax.swing.table.AbstractTableModel
-
setValueAt
public void setValueAt(java.lang.Object aValue, int row, int column)
- Specified by:
setValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
setValueAt
in classjavax.swing.table.AbstractTableModel
-
getValueAt
public java.lang.Object getValueAt(int row, int column)
- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
-
drawOSDText
public void drawOSDText(java.awt.Graphics2D g)
Draws a text on the map display that indicates that filters are active.- Parameters:
g
- The graphics to draw that text on.
-
getFilters
public java.util.List<Filter> getFilters()
Returns the list of filters.- Returns:
- the list of filters
-
sort
public void sort()
Description copied from interface:SortableModel
Sort the items.- Specified by:
sort
in interfaceSortableModel<Filter>
-
reverse
public void reverse()
Description copied from interface:SortableModel
Reverse the items order.- Specified by:
reverse
in interfaceSortableModel<Filter>
-
-