Class RelationMemberConflictResolverModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- javax.swing.table.DefaultTableModel
-
- org.openstreetmap.josm.gui.conflict.tags.RelationMemberConflictResolverModel
-
- All Implemented Interfaces:
Serializable
,TableModel
public class RelationMemberConflictResolverModel extends DefaultTableModel
This model manages a list of conflicting relation members. It can be used asTableModel
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<RelationMemberConflictDecision>
decisions
the list of conflict decisionsstatic String
NUM_CONFLICTS_PROP
the property name for the number conflicts managed by this modelprivate int
numConflicts
the number of conflictsprotected Collection<? extends OsmPrimitive>
primitives
the collection of primitives for which we manage conflictsprotected Collection<Relation>
relations
the collection of relations for which we manage conflictsprivate PropertyChangeSupport
support
-
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description RelationMemberConflictResolverModel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(PropertyChangeListener l)
void
applyRole(String role)
Apply a role to all member managed by this model.List<Command>
buildResolutionCommands(OsmPrimitive newPrimitive)
Builds a collection of commands executing the decisions made in this model.protected Command
buildResolveCommand(Relation relation, OsmPrimitive newPrimitive)
RelationMemberConflictDecision
getDecision(int row)
Replies the decision at positionrow
protected RelationMemberConflictDecision
getDecision(Relation relation, int pos)
Set<Relation>
getModifiedRelations(OsmPrimitive newPrimitive)
Replies the set of relations which have to be modified according to the decisions managed by this model.int
getNumConflicts()
Replies the current number of conflictsint
getNumDecisions()
Replies the number of decisions managed by this modelprotected String
getProperty()
int
getRowCount()
Object
getValueAt(int row, int column)
protected boolean
isChanged(Relation relation, OsmPrimitive newPrimitive)
(package private) static boolean
isCollectionOfConsecutiveNumbers(Collection<Integer> numbers)
boolean
isResolvedCompletely()
Replies true if eachMultiValueResolutionDecision
is decided.void
populate(Collection<Relation> relations, Collection<? extends OsmPrimitive> memberPrimitives)
Populates the model with the relation members belonging to one of the relations inrelations
and referring to one of the primitives inmemberPrimitives
.(package private) void
populate(Collection<Relation> relations, Collection<? extends OsmPrimitive> memberPrimitives, boolean fireEvent)
Populates the model with the relation members belonging to one of the relations inrelations
and referring to one of the primitives inmemberPrimitives
.void
populate(Collection<RelationToChildReference> references)
Populates the model with the relation members represented as a collection ofRelationToChildReference
s.protected void
populate(Relation relation, OsmPrimitive primitive)
Populates the model with the members of the relationrelation
referring toprimitive
.void
prepareDefaultRelationDecisions()
Prepare the default decisions for the current model.(package private) void
prepareDefaultRelationDecisions(boolean fireEvent)
Prepare the default decisions for the current model.void
refresh()
Refreshes the model state.(package private) void
refresh(boolean fireEvent)
Refreshes the model state.void
removePropertyChangeListener(PropertyChangeListener l)
void
setValueAt(Object value, int row, int column)
protected void
updateNumConflicts()
Updates the current number of conflicts from list of decisions and emits a property change event if necessary.-
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getColumnName, getDataVector, insertRow, insertRow, isCellEditable, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
-
-
-
-
Field Detail
-
NUM_CONFLICTS_PROP
public static final String NUM_CONFLICTS_PROP
the property name for the number conflicts managed by this model
-
decisions
protected final transient List<RelationMemberConflictDecision> decisions
the list of conflict decisions
-
relations
protected transient Collection<Relation> relations
the collection of relations for which we manage conflicts
-
primitives
protected transient Collection<? extends OsmPrimitive> primitives
the collection of primitives for which we manage conflicts
-
numConflicts
private int numConflicts
the number of conflicts
-
support
private final PropertyChangeSupport support
-
-
Constructor Detail
-
RelationMemberConflictResolverModel
public RelationMemberConflictResolverModel()
-
-
Method Detail
-
isResolvedCompletely
public boolean isResolvedCompletely()
Replies true if eachMultiValueResolutionDecision
is decided.- Returns:
- true if each
MultiValueResolutionDecision
is decided; false otherwise
-
getNumConflicts
public int getNumConflicts()
Replies the current number of conflicts- Returns:
- the current number of conflicts
-
updateNumConflicts
protected void updateNumConflicts()
Updates the current number of conflicts from list of decisions and emits a property change event if necessary.
-
getProperty
protected String getProperty()
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l)
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l)
-
getRowCount
public int getRowCount()
- Specified by:
getRowCount
in interfaceTableModel
- Overrides:
getRowCount
in classDefaultTableModel
-
getValueAt
public Object getValueAt(int row, int column)
- Specified by:
getValueAt
in interfaceTableModel
- Overrides:
getValueAt
in classDefaultTableModel
-
setValueAt
public void setValueAt(Object value, int row, int column)
- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classDefaultTableModel
-
populate
protected void populate(Relation relation, OsmPrimitive primitive)
Populates the model with the members of the relationrelation
referring toprimitive
.- Parameters:
relation
- the parent relationprimitive
- the child primitive
-
populate
public void populate(Collection<Relation> relations, Collection<? extends OsmPrimitive> memberPrimitives)
Populates the model with the relation members belonging to one of the relations inrelations
and referring to one of the primitives inmemberPrimitives
.- Parameters:
relations
- the parent relations. Empty list assumed if null.memberPrimitives
- the child primitives. Empty list assumed if null.
-
populate
void populate(Collection<Relation> relations, Collection<? extends OsmPrimitive> memberPrimitives, boolean fireEvent)
Populates the model with the relation members belonging to one of the relations inrelations
and referring to one of the primitives inmemberPrimitives
.- Parameters:
relations
- the parent relations. Empty list assumed if null.memberPrimitives
- the child primitives. Empty list assumed if null.fireEvent
-true
to callfireTableDataChanged
(can be a slow operation)- Since:
- 11626
-
populate
public void populate(Collection<RelationToChildReference> references)
Populates the model with the relation members represented as a collection ofRelationToChildReference
s.- Parameters:
references
- the references. Empty list assumed if null.
-
prepareDefaultRelationDecisions
public void prepareDefaultRelationDecisions()
Prepare the default decisions for the current model. Keep/delete decisions are made if every member has the same role and the members are in consecutive order within the relation. For multiple occurrences those conditions are tested stepwise for each occurrence.
-
prepareDefaultRelationDecisions
void prepareDefaultRelationDecisions(boolean fireEvent)
Prepare the default decisions for the current model. Keep/delete decisions are made if every member has the same role and the members are in consecutive order within the relation. For multiple occurrences those conditions are tested stepwise for each occurrence.- Parameters:
fireEvent
-true
to callfireTableDataChanged
(can be a slow operation)- Since:
- 11626
-
isCollectionOfConsecutiveNumbers
static boolean isCollectionOfConsecutiveNumbers(Collection<Integer> numbers)
-
getDecision
public RelationMemberConflictDecision getDecision(int row)
Replies the decision at positionrow
- Parameters:
row
- position- Returns:
- the decision at position
row
-
getNumDecisions
public int getNumDecisions()
Replies the number of decisions managed by this model- Returns:
- the number of decisions managed by this model
-
refresh
public void refresh()
Refreshes the model state. Invoke this method to trigger necessary change events after an update of the model data.
-
refresh
void refresh(boolean fireEvent)
Refreshes the model state. Invoke this method to trigger necessary change events after an update of the model data.- Parameters:
fireEvent
-true
to callfireTableDataChanged
(can be a slow operation)- Since:
- 11626
-
applyRole
public void applyRole(String role)
Apply a role to all member managed by this model.- Parameters:
role
- the role. Empty string assumed if null.
-
getDecision
protected RelationMemberConflictDecision getDecision(Relation relation, int pos)
-
buildResolveCommand
protected Command buildResolveCommand(Relation relation, OsmPrimitive newPrimitive)
-
buildResolutionCommands
public List<Command> buildResolutionCommands(OsmPrimitive newPrimitive)
Builds a collection of commands executing the decisions made in this model.- Parameters:
newPrimitive
- the primitive which members shall refer to- Returns:
- a list of commands
-
isChanged
protected boolean isChanged(Relation relation, OsmPrimitive newPrimitive)
-
getModifiedRelations
public Set<Relation> getModifiedRelations(OsmPrimitive newPrimitive)
Replies the set of relations which have to be modified according to the decisions managed by this model.- Parameters:
newPrimitive
- the primitive which members shall refer to- Returns:
- the set of relations which have to be modified according to the decisions managed by this model
-
-