Class SelectionTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.openstreetmap.josm.gui.dialogs.relation.SelectionTableModel
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.table.TableModel
,DataSelectionListener
,LayerManager.LayerChangeListener
,MainLayerManager.ActiveLayerChangeListener
public class SelectionTableModel extends javax.swing.table.AbstractTableModel implements DataSelectionListener, MainLayerManager.ActiveLayerChangeListener, LayerManager.LayerChangeListener
This table shows the primitives that are currently selected in the main OSM view.- Since:
- 1790
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.osm.DataSelectionListener
DataSelectionListener.AbstractSelectionEvent, DataSelectionListener.SelectionAddEvent, DataSelectionListener.SelectionChangeEvent, DataSelectionListener.SelectionRemoveEvent, DataSelectionListener.SelectionReplaceEvent, DataSelectionListener.SelectionToggleEvent
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<OsmPrimitive>
cache
private OsmDataLayer
layer
this selection table model only displays selected primitives in this layer
-
Constructor Summary
Constructors Constructor Description SelectionTableModel(OsmDataLayer layer)
Creates a newSelectionTableModel
for a given layer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Called whenever the active or edit layer changed.int
getColumnCount()
OsmPrimitive
getPrimitive(int row)
Replies the primitive at rowrow
in this modelint
getRowCount()
java.util.List<OsmPrimitive>
getSelection()
Returns the selected primitives.java.lang.Object
getValueAt(int rowIndex, int columnIndex)
void
layerAdded(LayerManager.LayerAddEvent e)
Notifies this listener that a layer has been added.void
layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Notifies this listener that the order of layers was changed.void
layerRemoving(LayerManager.LayerRemoveEvent e)
Notifies this listener that a layer was just removed.protected void
populateSelectedPrimitives(OsmDataLayer layer)
populates the model with the primitives currently selected inlayer
void
register()
Registers listeners (selection change and layer change).private void
selectionChanged(java.util.Collection<? extends OsmPrimitive> newSelection)
void
selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Called whenever the selection is changed.void
unregister()
Unregisters listeners (selection change and layer change).-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
-
-
-
Field Detail
-
layer
private final transient OsmDataLayer layer
this selection table model only displays selected primitives in this layer
-
cache
private final transient java.util.List<OsmPrimitive> cache
-
-
Constructor Detail
-
SelectionTableModel
public SelectionTableModel(OsmDataLayer layer)
Creates a newSelectionTableModel
for a given layer- Parameters:
layer
- the data layer. Must not be null.- Throws:
java.lang.IllegalArgumentException
- if layer is null
-
-
Method Detail
-
register
public void register()
Registers listeners (selection change and layer change).
-
unregister
public void unregister()
Unregisters listeners (selection change and layer change).
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
-
getRowCount
public int getRowCount()
- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
-
getValueAt
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
-
activeOrEditLayerChanged
public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Description copied from interface:MainLayerManager.ActiveLayerChangeListener
Called whenever the active or edit layer changed.You can be sure that this layer is still contained in this set.
Listeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
- Specified by:
activeOrEditLayerChanged
in interfaceMainLayerManager.ActiveLayerChangeListener
- Parameters:
e
- The change event.
-
layerAdded
public void layerAdded(LayerManager.LayerAddEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that a layer has been added.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerAdded
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The new added layer event
-
layerRemoving
public void layerRemoving(LayerManager.LayerRemoveEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that a layer was just removed.Listeners are called in the EDT thread after the layer was removed. Use
LayerManager.LayerRemoveEvent.scheduleRemoval(Collection)
to remove more layers. You should not do blocking or long-running tasks in this method.- Specified by:
layerRemoving
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The layer to be removed (as event)
-
layerOrderChanged
public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that the order of layers was changed.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerOrderChanged
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The order change event.
-
selectionChanged
public void selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Description copied from interface:DataSelectionListener
Called whenever the selection is changed. You get notified about the new selection, the elements that were added and removed and the layer that triggered the event.- Specified by:
selectionChanged
in interfaceDataSelectionListener
- Parameters:
event
- The selection change event.- See Also:
DataSelectionListener.SelectionChangeEvent
-
selectionChanged
private void selectionChanged(java.util.Collection<? extends OsmPrimitive> newSelection)
-
getSelection
public java.util.List<OsmPrimitive> getSelection()
Returns the selected primitives.- Returns:
- the selected primitives
-
populateSelectedPrimitives
protected void populateSelectedPrimitives(OsmDataLayer layer)
populates the model with the primitives currently selected inlayer
- Parameters:
layer
- the data layer
-
getPrimitive
public OsmPrimitive getPrimitive(int row)
Replies the primitive at rowrow
in this model- Parameters:
row
- the row- Returns:
- the primitive at row
row
in this model - Throws:
java.lang.ArrayIndexOutOfBoundsException
- if index is invalid
-
-