Ignore:
Timestamp:
2009-06-06T16:25:25+02:00 (11 years ago)
Author:
Gubaer
Message:

added row numbers and synchronized scrolling in conflict resolution dialog
fixed bugs in conflict resolution

Location:
trunk/src/org/openstreetmap/josm/command
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/TagConflictResolveCommand.java

    r1622 r1642  
    2525 */
    2626public class TagConflictResolveCommand extends Command {
    27    
     27
    2828    /** my primitive (in the local dataset). merge decisions are applied to this
    2929     *  primitive
    3030     */
    31     private OsmPrimitive my;
    32     /** their primitive (in the server dataset) */ 
    33     private OsmPrimitive their;
    34    
     31    private final OsmPrimitive my;
     32    /** their primitive (in the server dataset) */
     33    private final OsmPrimitive their;
     34
    3535    /** the list of merge decisions, represented as {@see TagMergeItem}s */
    36     private List<TagMergeItem> mergeItems;
    37    
     36    private final List<TagMergeItem> mergeItems;
     37
    3838    /**
    3939     * replies the number of decided conflicts
    4040     *
    41      * @return the number of decided conflicts 
     41     * @return the number of decided conflicts
    4242     */
    4343    public int getNumDecidedConflicts() {
     
    4545        for (TagMergeItem item: mergeItems) {
    4646            if (!item.getMergeDecision().equals(MergeDecisionType.UNDECIDED)) {
    47                 n++; 
     47                n++;
    4848            }
    4949        }
    5050        return n;
    5151    }
    52    
     52
    5353    /**
    5454     * replies a (localized) display name for the type of an OSM primitive
     
    6363        return "";
    6464    }
    65    
     65
    6666    /**
    67      * constructor 
     67     * constructor
    6868     *
    6969     * @param my  my primitive
    70      * @param their  their primitive 
     70     * @param their  their primitive
    7171     * @param mergeItems the list of merge decisions, represented as {@see TagMergeItem}s
    7272     */
     
    7676        this.mergeItems = mergeItems;
    7777    }
    78    
    79    
     78
     79
    8080    @Override
    81     public MutableTreeNode description() {               
     81    public MutableTreeNode description() {
    8282        return new DefaultMutableTreeNode(
    83           new JLabel(
    84              tr("Resolve {0} tag conflicts in {1} {2}",getNumDecidedConflicts(), getPrimitiveTypeAsString(my), my.id),
    85              ImageProvider.get("data", "object"),
    86              JLabel.HORIZONTAL
    87           )
    88        );
     83                new JLabel(
     84                        tr("Resolve {0} tag conflicts in {1} {2}",getNumDecidedConflicts(), getPrimitiveTypeAsString(my), my.id),
     85                        ImageProvider.get("data", "object"),
     86                        JLabel.HORIZONTAL
     87                )
     88        );
    8989    }
    9090
     
    9595        //
    9696        super.executeCommand();
    97        
     97
    9898        // apply the merge decisions to OSM primitive 'my'
    9999        //
    100100        for (TagMergeItem item: mergeItems) {
    101             item.applyToMyPrimitive(my);
     101            if (! item.getMergeDecision().equals(MergeDecisionType.UNDECIDED)) {
     102                item.applyToMyPrimitive(my);
     103            }
    102104        }
    103105        return true;
     
    115117        //
    116118        super.undoCommand();
    117        
     119
    118120        // restore a conflict if necessary
    119121        //
     
    123125    }
    124126
    125    
     127
    126128}
  • trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java

    r1622 r1642  
    2424public class VersionConflictResolveCommand extends Command {
    2525
    26     private OsmPrimitive my;
    27     private OsmPrimitive their;
    28    
     26    private final OsmPrimitive my;
     27    private final OsmPrimitive their;
     28
    2929    /**
    30      * constructor 
    31      * @param my  my primitive (i.e. the primitive from the local dataset) 
    32      * @param their their primitive (i.e. the primitive from the server) 
     30     * constructor
     31     * @param my  my primitive (i.e. the primitive from the local dataset)
     32     * @param their their primitive (i.e. the primitive from the server)
    3333     */
    3434    public VersionConflictResolveCommand(OsmPrimitive my, OsmPrimitive their) {
    35       this.my = my;
    36       this.their = their;
     35        this.my = my;
     36        this.their = their;
    3737    }
    38    
     38
    3939    //FIXME copied from TagConflictResolveCommand -> refactor
    4040    /**
     
    5050        return "";
    5151    }
    52    
     52
    5353    @Override
    5454    public MutableTreeNode description() {
    5555        return new DefaultMutableTreeNode(
    56             new JLabel(
    57                tr("Resolve version conflicts for {0} {1}",getPrimitiveTypeAsString(my), my.id),
    58                ImageProvider.get("data", "object"),
    59                JLabel.HORIZONTAL
    60             )
    61          );
     56                new JLabel(
     57                        tr("Resolve version conflicts for {0} {1}",getPrimitiveTypeAsString(my), my.id),
     58                        ImageProvider.get("data", "object"),
     59                        JLabel.HORIZONTAL
     60                )
     61        );
    6262    }
    6363
     
    6666        super.executeCommand();
    6767        my.version = Math.max(my.version, their.version);
    68         Main.map.conflictDialog.conflicts.remove(my);
     68        Main.map.conflictDialog.removeConflictForPrimitive(my);
    6969        return true;
    7070    }
     
    7979    public void undoCommand() {
    8080        super.undoCommand();
    81        
     81
    8282        // restore a conflict if necessary
    8383        //
    8484        if (!Main.map.conflictDialog.conflicts.containsKey(my)) {
    85             Main.map.conflictDialog.conflicts.put(my,their);
     85            Main.map.conflictDialog.addConflict(my, their);
    8686        }
    8787    }
    8888
    89    
     89
    9090}
Note: See TracChangeset for help on using the changeset viewer.