Class AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>
java.lang.Object
org.openstreetmap.josm.gui.util.ChangeNotifier
org.openstreetmap.josm.gui.conflict.pair.AbstractListMergeModel<T,C>
- Type Parameters:
T- the type of the list entriesC- the type of conflict resolution command
- Direct Known Subclasses:
NodeListMergeModel,RelationMemberListMergeModel
public abstract class AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>
extends ChangeNotifier
ListMergeModel is a model for interactively comparing and merging two list of entries
of type T. It maintains three lists of entries of type T:
- the list of my entries
- the list of their entries
- the list of merged entries
TableModels and three ListSelectionModels:
- the table model and the list selection for for a
JTablewhich shows my entries. SeegetMyTableModel()andgetMySelectionModel() - dito for their entries and merged entries
PropertyChangeListeners can register for property value changes of
FROZEN_PROP.
ListMergeModel is an abstract class. Three methods have to be implemented by subclasses:
cloneEntryForMergedList(T)- clones an entry of type TisEqualEntry(T, T)- checks whether two entries are equalssetValueAt(DefaultTableModel, Object, int, int)- handles values edited in a JTable, dispatched fromTableModel.setValueAt(Object, int, int)
AbstractListMerger.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA model forComparePairTypewith the enums added as options.protected classThis is the selection model to be used in aJTablewhich displays an entry list managed byAbstractListMergeModel.classThis an adapter between aJTableand one of the three entry lists in the roleListRolemanaged by theAbstractListMergeModel. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AbstractListMergeModel<T,C>.ComparePairListModel static final StringThe property name to listen for frozen changes.private booleanprivate final Set<PropertyChangeListener>private static final intprotected AbstractListMergeModel<T,C>.EntriesSelectionModel protected AbstractListMergeModel<T,C>.EntriesTableModel private Map<PrimitiveId,PrimitiveId> private DataSetprotected AbstractListMergeModel<T,C>.EntriesSelectionModel protected AbstractListMergeModel<T,C>.EntriesTableModel protected AbstractListMergeModel<T,C>.EntriesSelectionModel protected AbstractListMergeModel<T,C>.EntriesTableModel -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a newListMergeModel. -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidalertCopyFailedForDeletedPrimitives(List<PrimitiveId> deletedIds) protected voidprotected voidabstract CbuildResolveCommand(Conflict<? extends OsmPrimitive> conflict) Builds the command to resolve conflicts in the list.protected voidvoidClear the merged list.protected abstract TcloneEntryForMergedList(T entry) Creates a clone of an entry of type T suitable to be included in the list of merged entriesprivate voidprotected voidcopyAfterCurrent(ListRole source, int[] rows, int current) Copies the nodes given by indices in rows from the list of nodessourceto the list of merged nodes.voidCopies over all values from the given side to the merged table..protected voidcopyBeforeCurrent(ListRole source, int[] rows, int current) Copies the nodes given by indices in rows from the list of nodessourceto the list of merged nodes.voidcopyMyAfterCurrent(int[] rows, int current) Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes.voidcopyMyBeforeCurrent(int[] rows, int current) Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes.voidcopyMyToEnd(int... rows) Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes.voidcopyMyToTop(int... rows) Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes.voidcopyTheirAfterCurrent(int[] rows, int current) Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes.voidcopyTheirBeforeCurrent(int[] rows, int current) Copies the nodes given by indices in rows from the list of their nodes to the list of merged nodes.voidcopyTheirToEnd(int... rows) Copies the nodes given by indices in rows from the list of their nodes to the list of merged nodes.voidcopyTheirToTop(int... rows) Copies the nodes given by indices in rows from the list of their nodes to the list of merged nodes.voidCopies the nodes given by indices in rows from the list of nodes in source to the list of merged nodes.protected voidprotected voidfireFrozenChanged(boolean oldValue, boolean newValue) protected voidintintgetMyPrimitive(T entry) Replies primitive from my dataset referenced by entryfinal OsmPrimitivegetMyPrimitiveById(PrimitiveId entry) intprotected final voidinitPopulate(OsmPrimitive my, OsmPrimitive their, Map<PrimitiveId, PrimitiveId> mergedMap) abstract booleanisEqualEntry(T e1, T e2) checks whether two entries are equal.final booleanisFrozen()Check if the model is frozen.voidmoveDownMerged(int... rows) Moves the nodes given by indices in rows down by one position in the list of merged nodes.voidmoveUpMerged(int... rows) Moves the nodes given by indices in rows up by one position in the list of merged nodes.protected booleanReplies true if the list of my entries and the list of their entries are equalvoidremoveMerged(int... rows) Removes the nodes given by indices in rows from the list of merged nodes.voidfinal voidsetFrozen(boolean isFrozen) Sets the frozen status for this model.protected abstract voidsetValueAt(DefaultTableModel model, Object value, int row, int col) Handles method dispatches fromTableModel.setValueAt(Object, int, int).Methods inherited from class org.openstreetmap.josm.gui.util.ChangeNotifier
addChangeListener, fireStateChanged, removeChangeListener
-
Field Details
-
FROZEN_PROP
The property name to listen for frozen changes.- See Also:
-
MAX_DELETED_PRIMITIVE_IN_DIALOG
- See Also:
-
entries
-
myEntriesTableModel
protected AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>.EntriesTableModel myEntriesTableModel -
theirEntriesTableModel
protected AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>.EntriesTableModel theirEntriesTableModel -
mergedEntriesTableModel
protected AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>.EntriesTableModel mergedEntriesTableModel -
myEntriesSelectionModel
protected AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>.EntriesSelectionModel myEntriesSelectionModel -
theirEntriesSelectionModel
protected AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>.EntriesSelectionModel theirEntriesSelectionModel -
mergedEntriesSelectionModel
protected AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>.EntriesSelectionModel mergedEntriesSelectionModel -
listeners
-
isFrozen
-
comparePairListModel
private final AbstractListMergeModel<T extends PrimitiveId,C extends ConflictResolveCommand>.ComparePairListModel comparePairListModel -
myDataset
-
mergedMap
-
-
Constructor Details
-
AbstractListMergeModel
protected AbstractListMergeModel()Constructs a newListMergeModel.
-
-
Method Details
-
cloneEntryForMergedList
Creates a clone of an entry of type T suitable to be included in the list of merged entries- Parameters:
entry- the entry- Returns:
- the cloned entry
-
isEqualEntry
checks whether two entries are equal. This is not necessarily the same as e1.equals(e2).- Parameters:
e1- the first entrye2- the second entry- Returns:
- true, if the entries are equal, false otherwise.
-
setValueAt
Handles method dispatches fromTableModel.setValueAt(Object, int, int).- Parameters:
model- the table modelvalue- the value to be setrow- the row indexcol- the column index- See Also:
-
getMyPrimitive
Replies primitive from my dataset referenced by entry- Parameters:
entry- entry- Returns:
- Primitive from my dataset referenced by entry
-
getMyPrimitiveById
-
buildMyEntriesTableModel
-
buildTheirEntriesTableModel
-
buildMergedEntriesTableModel
-
getMergedEntries
-
getMyEntries
-
getTheirEntries
-
getMyEntriesSize
-
getMergedEntriesSize
-
getTheirEntriesSize
-
addPropertyChangeListener
-
removePropertyChangeListener
-
fireFrozenChanged
-
setFrozen
Sets the frozen status for this model.- Parameters:
isFrozen-trueif it should be frozen.
-
isFrozen
Check if the model is frozen.- Returns:
- The current frozen state.
-
getMyTableModel
-
getTheirTableModel
-
getMergedTableModel
-
getMySelectionModel
-
getTheirSelectionModel
-
getMergedSelectionModel
-
fireModelDataChanged
-
copyToTop
-
copyMyToTop
Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes. Inserts the nodes at the top of the list of merged nodes.- Parameters:
rows- the indices
-
copyTheirToTop
Copies the nodes given by indices in rows from the list of their nodes to the list of merged nodes. Inserts the nodes at the top of the list of merged nodes.- Parameters:
rows- the indices
-
copyToEnd
Copies the nodes given by indices in rows from the list of nodes in source to the list of merged nodes. Inserts the nodes at the end of the list of merged nodes.- Parameters:
source- the list of nodes to copy fromrows- the indices
-
copyMyToEnd
Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes. Inserts the nodes at the end of the list of merged nodes.- Parameters:
rows- the indices
-
copyTheirToEnd
Copies the nodes given by indices in rows from the list of their nodes to the list of merged nodes. Inserts the nodes at the end of the list of merged nodes.- Parameters:
rows- the indices
-
clearMerged
Clear the merged list. -
initPopulate
protected final void initPopulate(OsmPrimitive my, OsmPrimitive their, Map<PrimitiveId, PrimitiveId> mergedMap) -
alertCopyFailedForDeletedPrimitives
-
copy
-
copyAll
Copies over all values from the given side to the merged table..- Parameters:
source- The source side to copy from.
-
copyBeforeCurrent
Copies the nodes given by indices in rows from the list of nodessourceto the list of merged nodes. Inserts the nodes before row given by current.- Parameters:
source- the list of nodes to copy fromrows- the indicescurrent- the row index before which the nodes are inserted- Throws:
IllegalArgumentException- if current < 0 or >= #nodes in list of merged nodes
-
copyMyBeforeCurrent
Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes. Inserts the nodes before row given by current.- Parameters:
rows- the indicescurrent- the row index before which the nodes are inserted- Throws:
IllegalArgumentException- if current < 0 or >= #nodes in list of merged nodes
-
copyTheirBeforeCurrent
Copies the nodes given by indices in rows from the list of their nodes to the list of merged nodes. Inserts the nodes before row given by current.- Parameters:
rows- the indicescurrent- the row index before which the nodes are inserted- Throws:
IllegalArgumentException- if current < 0 or >= #nodes in list of merged nodes
-
copyAfterCurrent
Copies the nodes given by indices in rows from the list of nodessourceto the list of merged nodes. Inserts the nodes after the row given by current.- Parameters:
source- the list of nodes to copy fromrows- the indicescurrent- the row index after which the nodes are inserted- Throws:
IllegalArgumentException- if current < 0 or >= #nodes in list of merged nodes
-
copyMyAfterCurrent
Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes. Inserts the nodes after the row given by current.- Parameters:
rows- the indicescurrent- the row index after which the nodes are inserted- Throws:
IllegalArgumentException- if current < 0 or >= #nodes in list of merged nodes
-
copyTheirAfterCurrent
Copies the nodes given by indices in rows from the list of my nodes to the list of merged nodes. Inserts the nodes after the row given by current.- Parameters:
rows- the indicescurrent- the row index after which the nodes are inserted- Throws:
IllegalArgumentException- if current < 0 or >= #nodes in list of merged nodes
-
moveUpMerged
Moves the nodes given by indices in rows up by one position in the list of merged nodes.- Parameters:
rows- the indices
-
moveDownMerged
Moves the nodes given by indices in rows down by one position in the list of merged nodes.- Parameters:
rows- the indices
-
removeMerged
Removes the nodes given by indices in rows from the list of merged nodes.- Parameters:
rows- the indices
-
myAndTheirEntriesEqual
Replies true if the list of my entries and the list of their entries are equal- Returns:
- true, if the lists are equal; false otherwise
-
getComparePairListModel
-
buildResolveCommand
Builds the command to resolve conflicts in the list.- Parameters:
conflict- the conflict data set- Returns:
- the command
- Throws:
IllegalStateException- if the merge is not yet frozen
-