Modify

Opened 12 years ago

Closed 12 years ago

#9403 closed enhancement (wontfix)

[Patch] Relation members sorting in conflict editor

Reported by: josm@… Owned by: team
Priority: normal Milestone:
Component: Core Version: tested
Keywords: conflict, relation Cc:

Description

Relation conflict editor could list all the relations in some defined order, so only changes in membership will be affected. This would help a lot in resolving conflicts

Proposed simple patch:

Index: src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java
===================================================================
--- src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java	(revision 6453)
+++ src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java	(working copy)
@@ -3,6 +3,8 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 
@@ -67,12 +69,24 @@
     public void populate(Relation my, Relation their, Map<PrimitiveId, PrimitiveId> mergedMap) {
         initPopulate(my, their, mergedMap);
 
+        final Comparator<RelationMember> relationMemberComparator = new Comparator<RelationMember>() {
+            @Override
+            public int compare(RelationMember o1, RelationMember o2) {
+                return Long.compare(o1.getUniqueId(), o2.getUniqueId());
+            }
+
+        };
+
         for (RelationMember n : my.getMembers()) {
             getMyEntries().add(n);
         }
+        Collections.sort(getMyEntries(), relationMemberComparator);
+
         for (RelationMember n : their.getMembers()) {
             getTheirEntries().add(n);
         }
+        Collections.sort(getTheirEntries(), relationMemberComparator);
+
         if (myAndTheirEntriesEqual()) {
             for (RelationMember m : getMyEntries()) {
                 getMergedEntries().add(cloneEntryForMergedList(m));

Attachments (1)

RelationMemberListMergeModel.java.patch (1.6 KB ) - added by josm@… 12 years ago.
RelationMemberListMergeModel.java.patch

Download all attachments as: .zip

Change History (6)

comment:1 by skyper, 12 years ago

Order is important but you are right that the colouring is misleading, if you have only one extra member one one side.

comment:2 by Don-vip, 12 years ago

Summary: Relations conflict editor[Patch] Relations conflict editor

comment:3 by Don-vip, 12 years ago

Keywords: java7 added
Owner: changed from team to josm@…
Status: newneedinfo

Your patch does not compile with Java 6. Please supply a new one, because we won't switch to Java 7 before May at best.

The method Long.compare(long,long) has been introduced in Java 7.

by josm@…, 12 years ago

RelationMemberListMergeModel.java.patch

comment:4 by josm@…, 12 years ago

Owner: changed from josm@… to team
Status: needinfonew

Attached updated patch. Though I'm concerened with Don comment - I haven't meet relations, where order is important, but I'm not an advanced user and I put confidence in JOSM sorting for proper ordering in relation.

On the other hand, I digged a bit into colouring algorithms and as I understand, the colours should provide already information, whether object is on list or not (but this is not explicit). So I'm not sure, whether this patch should be at all commited.

comment:5 by Don-vip, 12 years ago

Keywords: java7 removed
Resolution: wontfix
Status: newclosed
Summary: [Patch] Relations conflict editor[Patch] Relation members sorting in conflict editor
Type: defectenhancement

Sorry I should have looked at patch first. Yes, order of members is important, we cannot mess with it like this.

However I do agree the display in conflict editor is misleading. It looks like the "diff" code is pretty naive in conflict dialog regarding to the code existing in history dialog, which is much more efficient.

Colors are simple enough: red items are deleted on their side while orange/brown items are modified. The problem is that the conflict dialog thinks items are modified when they are not.

Please create another enhancement ticket for improving the display (reusing history code in some way would be the better approach). If you manage to get a working patch we'll probably take it with great pleasure :)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.