public static final class LayerListDialog.LayerListModel extends javax.swing.table.AbstractTableModel implements LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener, java.beans.PropertyChangeListener
TableModel and it provides a ListSelectionModel. It expects
to be configured with a DefaultListSelectionModel. The selection model is used
to update the selection state of views depending on messages sent to the model.
The model manages a list of LayerListDialog.LayerListModelListener which are mainly notified if
the model requires views to make a specific list entry visible.
It also listens to PropertyChangeEvents of every Layer it manages, in particular to
the properties Layer.VISIBLE_PROP and Layer.NAME_PROP.| Modifier and Type | Field and Description |
|---|---|
private LayerListDialog.LayerList |
layerList |
private MainLayerManager |
layerManager |
private java.util.concurrent.CopyOnWriteArrayList<LayerListDialog.LayerListModelListener> |
listeners |
private javax.swing.DefaultListSelectionModel |
selectionModel
manages list selection state
|
| Constructor and Description |
|---|
LayerListModel(MainLayerManager layerManager,
javax.swing.DefaultListSelectionModel selectionModel)
constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Called whenever the active or edit layer changed.
|
void |
addLayerListModelListener(LayerListDialog.LayerListModelListener listener)
Adds a listener to this model
|
boolean |
canMoveDown()
Replies true if the currently selected layers can move down by one position
|
boolean |
canMoveUp()
Replies true if the currently selected layers can move up by one position
|
protected void |
ensureActiveSelected()
Ensures that at least one layer is selected in the layer dialog
|
protected void |
ensureSelectedIsVisible()
Make sure the first of the selected layers is visible in the views of this model.
|
protected void |
fireMakeVisible(int index,
Layer layer)
Fires a make visible event to listeners
|
protected void |
fireRefresh()
Fires a refresh event to listeners of this model
|
protected Layer |
getActiveLayer()
Replies the active layer.
|
int |
getColumnCount() |
Layer |
getFirstLayer()
Replies the first layer.
|
Layer |
getLayer(int index)
Replies the layer at position
index |
MainLayerManager |
getLayerManager()
The layer manager this model is for.
|
java.util.List<Layer> |
getLayers()
Replies the list of layers currently managed by
MapView. |
protected NativeScaleLayer |
getNativeScaleLayer()
Deprecated.
Deprecated since it is unused in JOSM and does not really belong here. Can be removed soon (August 2016).
You can directly query MapView.
|
java.util.List<Layer> |
getPossibleMergeTargets(Layer source)
Replies a list of layers which are possible merge targets for
source |
int |
getRowCount() |
java.util.List<Layer> |
getSelectedLayers()
Replies the list of currently selected layers.
|
java.util.List<java.lang.Integer> |
getSelectedRows()
Replies a the list of indices of the selected rows.
|
java.lang.Object |
getValueAt(int row,
int col) |
boolean |
isCellEditable(int row,
int col) |
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 is about to be removed.
|
void |
moveDown()
Move down the currently selected layers by one position
|
void |
moveUp()
Move up the currently selected layers by one position
|
private void |
onAddLayer(Layer layer)
Invoked when a layer managed by
MapView is added |
private void |
onRemoveLayer(Layer layer)
Invoked if a layer managed by
MapView is removed |
void |
populate()
Populates the model with the current layers managed by
MapView. |
void |
propertyChange(java.beans.PropertyChangeEvent evt) |
void |
removeLayerListModelListener(LayerListDialog.LayerListModelListener listener)
removes a listener from this model
|
(package private) void |
setLayerList(LayerListDialog.LayerList layerList) |
void |
setSelectedLayer(Layer layer)
Marks
layer as selected layer. |
void |
setValueAt(java.lang.Object value,
int row,
int col) |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, removeTableModelListenerprivate final javax.swing.DefaultListSelectionModel selectionModel
private final java.util.concurrent.CopyOnWriteArrayList<LayerListDialog.LayerListModelListener> listeners
private LayerListDialog.LayerList layerList
private final MainLayerManager layerManager
LayerListModel(MainLayerManager layerManager, javax.swing.DefaultListSelectionModel selectionModel)
layerManager - The layer manager to use for the list.selectionModel - the list selection modelvoid setLayerList(LayerListDialog.LayerList layerList)
public MainLayerManager getLayerManager()
public void addLayerListModelListener(LayerListDialog.LayerListModelListener listener)
listener - the listenerpublic void removeLayerListModelListener(LayerListDialog.LayerListModelListener listener)
listener - the listenerprotected void fireMakeVisible(int index, Layer layer)
index - the index of the row to make visiblelayer - the layer at this indexLayerListDialog.LayerListModelListener.makeVisible(int, Layer)protected void fireRefresh()
public void setSelectedLayer(Layer layer)
layer as selected layer. Ignored, if layer is null.layer - the layer.public java.util.List<Layer> getSelectedLayers()
public java.util.List<java.lang.Integer> getSelectedRows()
private void onRemoveLayer(Layer layer)
MapView is removedlayer - the layer which is removedprivate void onAddLayer(Layer layer)
MapView is addedlayer - the layerpublic Layer getFirstLayer()
public Layer getLayer(int index)
indexindex - the indexindex. Null,
if index is out of range.public boolean canMoveUp()
public void moveUp()
public boolean canMoveDown()
public void moveDown()
protected void ensureSelectedIsVisible()
public java.util.List<Layer> getPossibleMergeTargets(Layer source)
sourcesource - the source layersource. Never null, but can be empty.public java.util.List<Layer> getLayers()
MapView.
Never null, but can be empty.MapView.
Never null, but can be empty.protected void ensureActiveSelected()
protected Layer getActiveLayer()
@Deprecated protected NativeScaleLayer getNativeScaleLayer()
public int getRowCount()
getRowCount in interface javax.swing.table.TableModelpublic int getColumnCount()
getColumnCount in interface javax.swing.table.TableModelpublic java.lang.Object getValueAt(int row, int col)
getValueAt in interface javax.swing.table.TableModelpublic boolean isCellEditable(int row, int col)
isCellEditable in interface javax.swing.table.TableModelisCellEditable in class javax.swing.table.AbstractTableModelpublic void setValueAt(java.lang.Object value, int row, int col)
setValueAt in interface javax.swing.table.TableModelsetValueAt in class javax.swing.table.AbstractTableModelpublic void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
MainLayerManager.ActiveLayerChangeListenerYou 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.
activeOrEditLayerChanged in interface MainLayerManager.ActiveLayerChangeListenere - The change event.public void layerAdded(LayerManager.LayerAddEvent e)
LayerManager.LayerChangeListenerListeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
layerAdded in interface LayerManager.LayerChangeListenere - The new added layer eventpublic void layerRemoving(LayerManager.LayerRemoveEvent e)
LayerManager.LayerChangeListenerListeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
layerRemoving in interface LayerManager.LayerChangeListenere - The layer to be removed (as event)public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
LayerManager.LayerChangeListenerListeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
layerOrderChanged in interface LayerManager.LayerChangeListenere - The order change event.public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListener