public class TagEditorModel extends javax.swing.table.AbstractTableModel
Modifier and Type | Class and Description |
---|---|
(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
|
static java.lang.String |
PROP_DIRTY |
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) |
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
|
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) |
TagModel |
get(int idx) |
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.Map<java.lang.String,java.lang.String> |
getTags() |
java.util.Map<java.lang.String,java.lang.String> |
getTags(boolean keepEmpty) |
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) |
void |
removeProperyChangeListener(java.beans.PropertyChangeListener listener) |
protected void |
setDirty(boolean newValue) |
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 javax.swing.DefaultListSelectionModel rowSelectionModel
private javax.swing.DefaultListSelectionModel colSelectionModel
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)
public javax.swing.DefaultListSelectionModel getRowSelectionModel()
public javax.swing.DefaultListSelectionModel getColumnSelectionModel()
public void removeProperyChangeListener(java.beans.PropertyChangeListener listener)
protected 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 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 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)
public java.util.Map<java.lang.String,java.lang.String> getTags()
public java.util.Map<java.lang.String,java.lang.String> getTags(boolean keepEmpty)
public 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()