Class SelectionListDialog.SelectionListModel
- java.lang.Object
-
- javax.swing.AbstractListModel<OsmPrimitive>
-
- org.openstreetmap.josm.gui.dialogs.SelectionListDialog.SelectionListModel
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.ListModel<OsmPrimitive>
,DataSelectionListener
,DataSetListener
,MainLayerManager.ActiveLayerChangeListener
- Enclosing class:
- SelectionListDialog
static class SelectionListDialog.SelectionListModel extends javax.swing.AbstractListModel<OsmPrimitive> implements MainLayerManager.ActiveLayerChangeListener, DataSelectionListener, DataSetListener
The list model for the list of OSM primitives in the current JOSM selection.The model also maintains a history of the last
SELECTION_HISTORY_SIZE
JOSM selection.
-
-
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.LinkedList<java.util.Collection<? extends OsmPrimitive>>
history
private java.util.List<OsmPrimitive>
selection
private static int
SELECTION_HISTORY_SIZE
private javax.swing.DefaultListSelectionModel
selectionModel
-
Constructor Summary
Constructors Constructor Description SelectionListModel(javax.swing.DefaultListSelectionModel selectionModel)
Constructor
-
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.void
dataChanged(DataChangedEvent event)
Called after big changes in dataset.protected void
fireContentsChanged(java.lang.Object source, int index0, int index1)
OsmPrimitive
getElementAt(int index)
java.lang.String
getJOSMSelectionSummary()
Replies a summary of the current JOSM selectionjava.util.Collection<OsmPrimitive>
getSelected()
Replies the collection of OSM primitives currently selected in the view of this modeljava.util.List<java.util.Collection<? extends OsmPrimitive>>
getSelectionHistory()
Replies the history of JOSM selectionsint
getSize()
boolean
isSelectionEmpty()
Determines if no OSM primitives are currently selected.void
nodeMoved(NodeMovedEvent event)
A node's coordinates were modified.void
otherDatasetChange(AbstractDatasetChangedEvent event)
Minor dataset change, currently only changeset id changed is supported, but can be extended in future.void
primitivesAdded(PrimitivesAddedEvent event)
A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.void
primitivesRemoved(PrimitivesRemovedEvent event)
A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.void
relationMembersChanged(RelationMembersChangedEvent event)
A relation's members have changed.void
remember(java.util.Collection<? extends OsmPrimitive> selection)
Remembers a JOSM selection the history of JOSM selectionsvoid
selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Called whenever the selection is changed.void
setJOSMSelection(java.util.Collection<? extends OsmPrimitive> selection)
Sets the collection of currently selected OSM objectsvoid
setSelected(java.util.Collection<OsmPrimitive> sel)
Sets the OSM primitives to be selected in the view of this modelvoid
sort()
Sorts the current elements in the selectionvoid
tagsChanged(TagsChangedEvent event)
There was some change in the tag set of a primitive.void
update(java.util.Collection<? extends OsmPrimitive> toUpdate)
Triggers a refresh of the view for all primitives intoUpdate
which are currently displayed in the viewvoid
wayNodesChanged(WayNodesChangedEvent event)
A way's node list was changed.-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
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.osm.event.DataSetListener
dataChangedIndividualEvents
-
-
-
-
Field Detail
-
SELECTION_HISTORY_SIZE
private static final int SELECTION_HISTORY_SIZE
- See Also:
- Constant Field Values
-
history
private java.util.LinkedList<java.util.Collection<? extends OsmPrimitive>> history
-
selection
private final transient java.util.List<OsmPrimitive> selection
-
selectionModel
private final javax.swing.DefaultListSelectionModel selectionModel
-
-
Constructor Detail
-
SelectionListModel
SelectionListModel(javax.swing.DefaultListSelectionModel selectionModel)
Constructor- Parameters:
selectionModel
- the selection model used in the list
-
-
Method Detail
-
getJOSMSelectionSummary
public java.lang.String getJOSMSelectionSummary()
Replies a summary of the current JOSM selection- Returns:
- a summary of the current JOSM selection
-
remember
public void remember(java.util.Collection<? extends OsmPrimitive> selection)
Remembers a JOSM selection the history of JOSM selections- Parameters:
selection
- the JOSM selection. Ignored if null or empty.
-
getSelectionHistory
public java.util.List<java.util.Collection<? extends OsmPrimitive>> getSelectionHistory()
Replies the history of JOSM selections- Returns:
- history of JOSM selections
-
getElementAt
public OsmPrimitive getElementAt(int index)
- Specified by:
getElementAt
in interfacejavax.swing.ListModel<OsmPrimitive>
-
getSize
public int getSize()
- Specified by:
getSize
in interfacejavax.swing.ListModel<OsmPrimitive>
-
isSelectionEmpty
public boolean isSelectionEmpty()
Determines if no OSM primitives are currently selected.- Returns:
true
if no OSM primitives are currently selected- Since:
- 10383
-
getSelected
public java.util.Collection<OsmPrimitive> getSelected()
Replies the collection of OSM primitives currently selected in the view of this model- Returns:
- chosen elements in the view
-
setSelected
public void setSelected(java.util.Collection<OsmPrimitive> sel)
Sets the OSM primitives to be selected in the view of this model- Parameters:
sel
- the collection of primitives to select
-
fireContentsChanged
protected void fireContentsChanged(java.lang.Object source, int index0, int index1)
- Overrides:
fireContentsChanged
in classjavax.swing.AbstractListModel<OsmPrimitive>
-
setJOSMSelection
public void setJOSMSelection(java.util.Collection<? extends OsmPrimitive> selection)
Sets the collection of currently selected OSM objects- Parameters:
selection
- the collection of currently selected OSM objects
-
update
public void update(java.util.Collection<? extends OsmPrimitive> toUpdate)
Triggers a refresh of the view for all primitives intoUpdate
which are currently displayed in the view- Parameters:
toUpdate
- the collection of primitives to update
-
sort
public void sort()
Sorts the current elements in the selection
-
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.
-
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
-
dataChanged
public void dataChanged(DataChangedEvent event)
Description copied from interface:DataSetListener
Called after big changes in dataset. Usually other events are stopped using Dataset.beginUpdate() and after operation is completed (Dataset.endUpdate()),DataSetListener.dataChanged(DataChangedEvent event)
is called.- Specified by:
dataChanged
in interfaceDataSetListener
- Parameters:
event
- data change event
-
nodeMoved
public void nodeMoved(NodeMovedEvent event)
Description copied from interface:DataSetListener
A node's coordinates were modified.- Specified by:
nodeMoved
in interfaceDataSetListener
- Parameters:
event
- The event for the node that was moved.
-
otherDatasetChange
public void otherDatasetChange(AbstractDatasetChangedEvent event)
Description copied from interface:DataSetListener
Minor dataset change, currently only changeset id changed is supported, but can be extended in future.- Specified by:
otherDatasetChange
in interfaceDataSetListener
- Parameters:
event
- the event for data modification
-
relationMembersChanged
public void relationMembersChanged(RelationMembersChangedEvent event)
Description copied from interface:DataSetListener
A relation's members have changed.- Specified by:
relationMembersChanged
in interfaceDataSetListener
- Parameters:
event
- The event for the relation that was modified.
-
tagsChanged
public void tagsChanged(TagsChangedEvent event)
Description copied from interface:DataSetListener
There was some change in the tag set of a primitive. It can have been a tag addition, tag removal or change in tag value.- Specified by:
tagsChanged
in interfaceDataSetListener
- Parameters:
event
- the event for the primitive, whose tags were affected.
-
wayNodesChanged
public void wayNodesChanged(WayNodesChangedEvent event)
Description copied from interface:DataSetListener
A way's node list was changed.- Specified by:
wayNodesChanged
in interfaceDataSetListener
- Parameters:
event
- The event for the way that was modified.
-
primitivesAdded
public void primitivesAdded(PrimitivesAddedEvent event)
Description copied from interface:DataSetListener
A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.- Specified by:
primitivesAdded
in interfaceDataSetListener
- Parameters:
event
- An event for an collection of newly-visible primitives
-
primitivesRemoved
public void primitivesRemoved(PrimitivesRemovedEvent event)
Description copied from interface:DataSetListener
A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.- Specified by:
primitivesRemoved
in interfaceDataSetListener
- Parameters:
event
- An event for an collection of newly-invisible primitives
-
-