public final class LayerListDialog.LayerListModel extends javax.swing.table.AbstractTableModel implements MapView.LayerChangeListener, 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 java.util.concurrent.CopyOnWriteArrayList<LayerListDialog.LayerListModelListener> |
listeners |
private javax.swing.DefaultListSelectionModel |
selectionModel
manages list selection state
|
| Modifier | Constructor and Description |
|---|---|
private |
LayerListModel(javax.swing.DefaultListSelectionModel selectionModel)
constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
activeLayerChange(Layer oldLayer,
Layer newLayer)
Notifies this listener that the active layer has 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 |
java.util.List<Layer> |
getLayers()
Replies the list of layers currently managed by
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(Layer newLayer)
Notifies this listener that a layer has been added.
|
void |
layerRemoved(Layer oldLayer)
Notifies this listener that a layer has been removed.
|
void |
moveDown()
Move down the currently selected layers by one position
|
void |
moveUp()
Move up the currently selected layers by one position
|
protected void |
onAddLayer(Layer layer)
Invoked when a layer managed by
MapView is added |
protected 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
|
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 javax.swing.DefaultListSelectionModel selectionModel
private java.util.concurrent.CopyOnWriteArrayList<LayerListDialog.LayerListModelListener> listeners
private LayerListModel(javax.swing.DefaultListSelectionModel selectionModel)
selectionModel - the list selection modelpublic 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()
protected void onRemoveLayer(Layer layer)
MapView is removedlayer - the layer which is removedprotected 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()
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 activeLayerChange(Layer oldLayer, Layer newLayer)
MapView.LayerChangeListeneractiveLayerChange in interface MapView.LayerChangeListeneroldLayer - The previous active layernewLayer - The new activer layerpublic void layerAdded(Layer newLayer)
MapView.LayerChangeListenerlayerAdded in interface MapView.LayerChangeListenernewLayer - The new added layerpublic void layerRemoved(Layer oldLayer)
MapView.LayerChangeListenerlayerRemoved in interface MapView.LayerChangeListeneroldLayer - The old removed layerpublic void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListener