public class TagEditorModel extends javax.swing.table.AbstractTableModel
TagEditorPanel
.Modifier and Type | Class and Description |
---|---|
static interface |
TagEditorModel.EndEditListener
A listener that is called whenever the cells may be updated from outside the editor and the editor should thus be commited.
|
(package private) class |
TagEditorModel.SelectionStateMemento |
Modifier and Type | Field and Description |
---|---|
private javax.swing.DefaultListSelectionModel |
colSelectionModel |
private boolean |
dirty
indicates whether the model is dirty
|
private TagEditorModel.EndEditListener |
endEditListener |
private OsmPrimitive |
primitive |
static java.lang.String |
PROP_DIRTY
The dirty property.
|
private java.beans.PropertyChangeSupport |
propChangeSupport |
private javax.swing.DefaultListSelectionModel |
rowSelectionModel |
protected java.util.List<TagModel> |
tags
the list holding the tags
|
Constructor and Description |
---|
TagEditorModel()
Creates a new tag editor model.
|
TagEditorModel(javax.swing.DefaultListSelectionModel rowSelectionModel,
javax.swing.DefaultListSelectionModel colSelectionModel)
Creates a new tag editor model.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String name,
java.lang.String value)
adds a tag given by a name/value pair to the tag editor model.
|
void |
add(TagModel tag)
adds a tag to the model
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds property change listener.
|
void |
appendNewTag()
creates a new tag and appends it to the model
|
void |
applyToPrimitive(Tagged primitive)
applies the current state of the tag editor model to a primitive
|
private java.util.Map<java.lang.String,java.lang.String> |
applyToTags(boolean keepEmpty)
applies the current state of the tag editor model to a map of tags
|
void |
clear()
removes all tags in the model
|
private void |
commitPendingEdit() |
protected Command |
createDeleteTagsCommand(java.util.Collection<OsmPrimitive> primitives) |
protected Command |
createUpdateTagCommand(java.util.Collection<OsmPrimitive> primitives,
TagModel tag) |
void |
delete(java.lang.String name)
Deletes all tags with name
name |
void |
deleteTagNames(int... tagIndices)
deletes the names of the tags given by tagIndices
|
void |
deleteTags(int... tagIndices)
deletes the tags given by tagIndices
|
void |
deleteTagValues(int... tagIndices)
deletes the values of the tags given by tagIndices
|
void |
ensureOneTag()
makes sure the model includes at least one (empty) tag
|
protected void |
fireDirtyStateChanged(boolean oldValue,
boolean newValue) |
TagEditorModel |
forPrimitive(OsmPrimitive primitive)
Makes this TagEditorModel specific to a given OSM primitive.
|
TagModel |
get(int idx)
Gets a tag row
|
TagModel |
get(java.lang.String name)
replies the tag with name
name ; null, if no such tag exists |
int |
getColumnCount() |
javax.swing.DefaultListSelectionModel |
getColumnSelectionModel()
Replies the column selection model used by this tag editor model
|
java.util.List<java.lang.String> |
getKeys()
replies the list of keys of the tags managed by this model
|
int |
getRowCount() |
javax.swing.DefaultListSelectionModel |
getRowSelectionModel()
Replies the row selection model used by this tag editor model
|
TagCollection |
getTagCollection()
Replies the tags in this tag editor model as
TagCollection . |
java.util.Collection<TaggingPresetType> |
getTaggingPresetTypes()
Returns the list of tagging presets types to consider when updating the presets list panel.
|
java.util.Map<java.lang.String,java.lang.String> |
getTags()
Returns tags, without empty ones.
|
java.util.Map<java.lang.String,java.lang.String> |
getTags(boolean keepEmpty)
Returns tags.
|
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex) |
boolean |
includesTag(java.lang.String key)
checks whether the tag model includes a tag with a given key
|
void |
initFromPrimitive(Tagged primitive)
initializes the model with the tags of an OSM primitive
|
void |
initFromTags(java.util.Map<java.lang.String,java.lang.String> tags)
Initializes the model with the tags of an OSM primitive
|
void |
initFromTags(TagCollection tags)
Initializes the model with the tags in a tag collection.
|
boolean |
isCellEditable(int row,
int col) |
boolean |
isDirty()
replies true, if this model has been updated
|
void |
prepend(TagModel tag)
Add a tag at the beginning of the table.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes property change listener.
|
protected void |
setDirty(boolean newValue) |
void |
setEndEditListener(TagEditorModel.EndEditListener endEditListener)
Sets the listener that is notified when an edit should be aborted.
|
void |
setValueAt(java.lang.Object value,
int row,
int col) |
protected void |
sort()
sorts the current tags according alphabetical order of names
|
void |
updateTagName(TagModel tag,
java.lang.String newName)
updates the name of a tag and sets the dirty state to true if
the new name is different from the old name.
|
void |
updateTags(java.util.List<Tag> tags)
Load tags from given list
|
void |
updateTagValue(TagModel tag,
java.lang.String newValue)
updates the value value of a tag and sets the dirty state to true if the
new name is different from the old name
|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, removeTableModelListener
public static final java.lang.String PROP_DIRTY
private boolean dirty
private final java.beans.PropertyChangeSupport propChangeSupport
private final javax.swing.DefaultListSelectionModel rowSelectionModel
private final javax.swing.DefaultListSelectionModel colSelectionModel
private transient OsmPrimitive primitive
private TagEditorModel.EndEditListener endEditListener
public TagEditorModel()
JTable
with this model:
TagEditorModel model = new TagEditorModel(); TagTable tbl = new TagTabel(model);
getRowSelectionModel()
,
getColumnSelectionModel()
public TagEditorModel(javax.swing.DefaultListSelectionModel rowSelectionModel, javax.swing.DefaultListSelectionModel colSelectionModel)
rowSelectionModel
- the row selection model. Must not be null.colSelectionModel
- the column selection model. Must not be null.java.lang.IllegalArgumentException
- if rowSelectionModel
is nulljava.lang.IllegalArgumentException
- if colSelectionModel
is nullpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- property change listener to addpublic javax.swing.DefaultListSelectionModel getRowSelectionModel()
public javax.swing.DefaultListSelectionModel getColumnSelectionModel()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- property change listener to removeprotected void fireDirtyStateChanged(boolean oldValue, boolean newValue)
protected void setDirty(boolean newValue)
public int getColumnCount()
public int getRowCount()
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
public void setValueAt(java.lang.Object value, int row, int col)
setValueAt
in interface javax.swing.table.TableModel
setValueAt
in class javax.swing.table.AbstractTableModel
public void clear()
public void add(TagModel tag)
tag
- the tag. Must not be null.java.lang.IllegalArgumentException
- if tag is nullpublic void prepend(TagModel tag)
tag
- The tag to addjava.lang.IllegalArgumentException
- if tag is nulladd(TagModel)
public void add(java.lang.String name, java.lang.String value)
name
yet, a new TagModel
is created
and append to this model.
If there is a tag with name name
, value
is merged to the list
of values for this tag.name
- the name; converted to "" if nullvalue
- the value; converted to "" if nullpublic TagModel get(java.lang.String name)
name
; null, if no such tag existsname
- the tag namename
; null, if no such tag existspublic TagModel get(int idx)
idx
- The index of the rowpublic boolean isCellEditable(int row, int col)
isCellEditable
in interface javax.swing.table.TableModel
isCellEditable
in class javax.swing.table.AbstractTableModel
public void deleteTagNames(int... tagIndices)
tagIndices
- a list of tag indicespublic void deleteTagValues(int... tagIndices)
tagIndices
- the lit of tag indicespublic void delete(java.lang.String name)
name
name
- the name. Ignored if null.public void deleteTags(int... tagIndices)
tagIndices
- the list of tag indicespublic void appendNewTag()
public void ensureOneTag()
public void initFromPrimitive(Tagged primitive)
primitive
- the OSM primitivepublic void initFromTags(java.util.Map<java.lang.String,java.lang.String> tags)
tags
- the tags of an OSM primitivepublic void initFromTags(TagCollection tags)
tags
is null.tags
- the tagspublic void applyToPrimitive(Tagged primitive)
primitive
- the primitiveprivate java.util.Map<java.lang.String,java.lang.String> applyToTags(boolean keepEmpty)
keepEmpty
- true
to keep empty tagspublic java.util.Map<java.lang.String,java.lang.String> getTags()
public java.util.Map<java.lang.String,java.lang.String> getTags(boolean keepEmpty)
keepEmpty
- true
to keep empty tagspublic TagCollection getTagCollection()
TagCollection
.TagCollection
public boolean includesTag(java.lang.String key)
key
- the keyprotected Command createUpdateTagCommand(java.util.Collection<OsmPrimitive> primitives, TagModel tag)
protected Command createDeleteTagsCommand(java.util.Collection<OsmPrimitive> primitives)
public java.util.List<java.lang.String> getKeys()
protected void sort()
public void updateTagName(TagModel tag, java.lang.String newName)
tag
- the tagnewName
- the new namepublic void updateTagValue(TagModel tag, java.lang.String newValue)
tag
- the tagnewValue
- the new valuepublic void updateTags(java.util.List<Tag> tags)
tags
- - the listpublic boolean isDirty()
public java.util.Collection<TaggingPresetType> getTaggingPresetTypes()
forPrimitive(org.openstreetmap.josm.data.osm.OsmPrimitive)
,
TaggingPresetType.forPrimitive(org.openstreetmap.josm.data.osm.IPrimitive)
public TagEditorModel forPrimitive(OsmPrimitive primitive)
primitive
- primitive to considerthis
public void setEndEditListener(TagEditorModel.EndEditListener endEditListener)
endEditListener
- The listener to be notified when editing should be aborted.private void commitPendingEdit()