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>cacheprivate OsmDataLayerlayerthis selection table model only displays selected primitives in this layer
-
Constructor Summary
Constructors Constructor Description SelectionTableModel(OsmDataLayer layer)Creates a newSelectionTableModelfor a given layer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactiveOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)Called whenever the active or edit layer changed.intgetColumnCount()OsmPrimitivegetPrimitive(int row)Replies the primitive at rowrowin this modelintgetRowCount()java.util.List<OsmPrimitive>getSelection()Returns the selected primitives.java.lang.ObjectgetValueAt(int rowIndex, int columnIndex)voidlayerAdded(LayerManager.LayerAddEvent e)Notifies this listener that a layer has been added.voidlayerOrderChanged(LayerManager.LayerOrderChangeEvent e)Notifies this listener that the order of layers was changed.voidlayerRemoving(LayerManager.LayerRemoveEvent e)Notifies this listener that a layer was just removed.protected voidpopulateSelectedPrimitives(OsmDataLayer layer)populates the model with the primitives currently selected inlayervoidregister()Registers listeners (selection change and layer change).private voidselectionChanged(java.util.Collection<? extends OsmPrimitive> newSelection)voidselectionChanged(DataSelectionListener.SelectionChangeEvent event)Called whenever the selection is changed.voidunregister()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 newSelectionTableModelfor 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:
getColumnCountin interfacejavax.swing.table.TableModel
-
getRowCount
public int getRowCount()
- Specified by:
getRowCountin interfacejavax.swing.table.TableModel
-
getValueAt
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
- Specified by:
getValueAtin interfacejavax.swing.table.TableModel
-
activeOrEditLayerChanged
public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Description copied from interface:MainLayerManager.ActiveLayerChangeListenerCalled 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:
activeOrEditLayerChangedin interfaceMainLayerManager.ActiveLayerChangeListener- Parameters:
e- The change event.
-
layerAdded
public void layerAdded(LayerManager.LayerAddEvent e)
Description copied from interface:LayerManager.LayerChangeListenerNotifies 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:
layerAddedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The new added layer event
-
layerRemoving
public void layerRemoving(LayerManager.LayerRemoveEvent e)
Description copied from interface:LayerManager.LayerChangeListenerNotifies 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:
layerRemovingin interfaceLayerManager.LayerChangeListener- Parameters:
e- The layer to be removed (as event)
-
layerOrderChanged
public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Description copied from interface:LayerManager.LayerChangeListenerNotifies 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:
layerOrderChangedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The order change event.
-
selectionChanged
public void selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Description copied from interface:DataSelectionListenerCalled 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:
selectionChangedin 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 rowrowin this model- Parameters:
row- the row- Returns:
- the primitive at row
rowin this model - Throws:
java.lang.ArrayIndexOutOfBoundsException- if index is invalid
-
-