org.openstreetmap.josm.gui.conflict.tags
Class RelationMemberConflictResolverModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by javax.swing.table.DefaultTableModel
          extended by org.openstreetmap.josm.gui.conflict.tags.RelationMemberConflictResolverModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class RelationMemberConflictResolverModel
extends javax.swing.table.DefaultTableModel

This model manages a list of conflicting relation members. It can be used as TableModel.

See Also:
Serialized Form

Field Summary
private  java.util.List<RelationMemberConflictDecision> decisions
          the list of conflict decisions
static java.lang.String NUM_CONFLICTS_PROP
          the property name for the number conflicts managed by this model
private  int numConflicts
          the number of conflicts
private  java.util.Collection<Relation> relations
          the collection of relations for which we manage conflicts
private  java.beans.PropertyChangeSupport support
           
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
RelationMemberConflictResolverModel()
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void applyRole(java.lang.String role)
          Apply a role to all member managed by this model.
 java.util.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 position row
protected  RelationMemberConflictDecision getDecision(Relation relation, int pos)
           
 java.util.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 conflicts
 int getNumDecisions()
          Replies the number of decisions managed by this model
 int getRowCount()
           
 java.lang.Object getValueAt(int row, int column)
           
protected  boolean isChanged(Relation relation, OsmPrimitive newPrimitive)
           
 void populate(java.util.Collection<Relation> relations, java.util.Collection<? extends OsmPrimitive> memberPrimitives)
          Populates the model with the relation members belonging to one of the relations in relations and referring to one of the primitives in memberPrimitives.
 void populate(java.util.Collection<RelationToChildReference> references)
          Populates the model with the relation members represented as a collection of RelationToChildReferences.
protected  void populate(Relation relation, OsmPrimitive primitive)
          Populates the model with the members of the relation relation referring to primitive.
 void refresh()
          Refreshes the model state.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void setValueAt(java.lang.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_CONFLICTS_PROP

public static final java.lang.String NUM_CONFLICTS_PROP
the property name for the number conflicts managed by this model


decisions

private java.util.List<RelationMemberConflictDecision> decisions
the list of conflict decisions


relations

private java.util.Collection<Relation> relations
the collection of relations for which we manage conflicts


numConflicts

private int numConflicts
the number of conflicts


support

private java.beans.PropertyChangeSupport support
Constructor Detail

RelationMemberConflictResolverModel

public RelationMemberConflictResolverModel()
Method Detail

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.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel
Overrides:
getRowCount in class javax.swing.table.DefaultTableModel

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Specified by:
getValueAt in interface javax.swing.table.TableModel
Overrides:
getValueAt in class javax.swing.table.DefaultTableModel

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int column)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.DefaultTableModel

populate

protected void populate(Relation relation,
                        OsmPrimitive primitive)
Populates the model with the members of the relation relation referring to primitive.

Parameters:
relation - the parent relation
primitive - the child primitive

populate

public void populate(java.util.Collection<Relation> relations,
                     java.util.Collection<? extends OsmPrimitive> memberPrimitives)
Populates the model with the relation members belonging to one of the relations in relations and referring to one of the primitives in memberPrimitives.

Parameters:
relations - the parent relations. Empty list assumed if null.
memberPrimitives - the child primitives. Empty list assumed if null.

populate

public void populate(java.util.Collection<RelationToChildReference> references)
Populates the model with the relation members represented as a collection of RelationToChildReferences.

Parameters:
references - the references. Empty list assumed if null.

getDecision

public RelationMemberConflictDecision getDecision(int row)
Replies the decision at position row

Parameters:
row -
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.


applyRole

public void applyRole(java.lang.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 java.util.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 if the decision is RelationMemberConflictDecisionType#REPLACE
Returns:
a list of commands

isChanged

protected boolean isChanged(Relation relation,
                            OsmPrimitive newPrimitive)

getModifiedRelations

public java.util.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 if the decision is RelationMemberConflictDecisionType#REPLACE
Returns:
the set of relations which have to be modified according to the decisions managed by this model


JOSM