Changeset 2936 in josm


Ignore:
Timestamp:
2010-02-04T21:04:02+01:00 (12 years ago)
Author:
jttt
Message:

Fixed #4408 confict manager: do not have to solve tag- and element-conficts when deleting

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/history/History.java

    r2845 r2936  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm.history;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    53
    64import java.text.MessageFormat;
     
    3937    private ArrayList<HistoryOsmPrimitive> versions;
    4038    /** the object id */
    41     private long id;
    42     private OsmPrimitiveType type;
     39    private final long id;
     40    private final OsmPrimitiveType type;
    4341
    4442    /**
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java

    r2871 r2936  
    5454    }
    5555
    56     protected void fireHistoryUpdated(SimplePrimitiveId id) {
     56    protected void fireHistoryUpdated(PrimitiveId id) {
    5757        for (HistoryDataSetListener l : listeners) {
    5858            l.historyUpdated(this, id);
     
    9494     */
    9595    public void put(HistoryOsmPrimitive primitive) {
    96         SimplePrimitiveId id = new SimplePrimitiveId(primitive.getId(), primitive.getType());
     96        PrimitiveId id = new SimplePrimitiveId(primitive.getId(), primitive.getType());
    9797        if (data.get(id) == null) {
    9898            data.put(id, new ArrayList<HistoryOsmPrimitive>());
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java

    r2846 r2936  
    99import java.beans.PropertyChangeListener;
    1010import java.util.ArrayList;
    11 import java.util.logging.Logger;
     11import java.util.List;
    1212
    1313import javax.swing.ImageIcon;
     
    6767    static public final String THEIR_PRIMITIVE_PROP = ConflictResolver.class.getName() + ".theirPrimitive";
    6868
    69     private static final Logger logger = Logger.getLogger(ConflictResolver.class.getName());
     69    //private static final Logger logger = Logger.getLogger(ConflictResolver.class.getName());
    7070
    7171    private JTabbedPane tabbedPane = null;
     
    7474    private RelationMemberMerger relationMemberMerger;
    7575    private PropertiesMerger propertiesMerger;
     76    private final List<IConflictResolver> conflictResolvers = new ArrayList<IConflictResolver>();
    7677    private OsmPrimitive my;
    7778    private OsmPrimitive their;
     
    119120        setLayout(new BorderLayout());
    120121        add(tabbedPane, BorderLayout.CENTER);
     122
     123        conflictResolvers.add(propertiesMerger);
     124        conflictResolvers.add(tagMerger);
     125        conflictResolvers.add(nodeListMerger);
     126        conflictResolvers.add(relationMemberMerger);
    121127    }
    122128
     
    174180        } else if (evt.getPropertyName().equals(ListMergeModel.FROZEN_PROP)) {
    175181            boolean frozen = (Boolean)evt.getNewValue();
    176             if (frozen && evt.getSource() == nodeListMerger.getModel()) {
    177                 tabbedPane.setTitleAt(2, tr("Nodes(resolved)"));
    178                 tabbedPane.setToolTipTextAt(2, tr("Merged node list frozen. No pending conflicts in the node list of this way"));
    179                 tabbedPane.setIconAt(2, mergeComplete);
    180             } else {
    181                 tabbedPane.setTitleAt(2, tr("Nodes(with conflicts)"));
    182                 tabbedPane.setToolTipTextAt(2,tr("Pending conflicts in the node list of this way"));
    183                 tabbedPane.setIconAt(2, mergeIncomplete);
    184             }
    185             if (frozen && evt.getSource() == relationMemberMerger.getModel()) {
    186                 tabbedPane.setTitleAt(3, tr("Members(resolved)"));
    187                 tabbedPane.setToolTipTextAt(3, tr("Merged member list frozen. No pending conflicts in the member list of this relation"));
    188                 tabbedPane.setIconAt(3, mergeComplete);
    189             } else {
    190                 tabbedPane.setTitleAt(3, tr("Members(with conflicts)"));
    191                 tabbedPane.setToolTipTextAt(3, tr("Pending conflicts in the member list of this relation"));
    192                 tabbedPane.setIconAt(3, mergeIncomplete);
     182            if (evt.getSource() == nodeListMerger.getModel() && my instanceof Way) {
     183                if (frozen) {
     184                    tabbedPane.setTitleAt(2, tr("Nodes(resolved)"));
     185                    tabbedPane.setToolTipTextAt(2, tr("Merged node list frozen. No pending conflicts in the node list of this way"));
     186                    tabbedPane.setIconAt(2, mergeComplete);
     187                } else {
     188                    tabbedPane.setTitleAt(2, tr("Nodes(with conflicts)"));
     189                    tabbedPane.setToolTipTextAt(2,tr("Pending conflicts in the node list of this way"));
     190                    tabbedPane.setIconAt(2, mergeIncomplete);
     191                }
     192            } else if (evt.getSource() == relationMemberMerger.getModel() && my instanceof Relation) {
     193                if (frozen) {
     194                    tabbedPane.setTitleAt(3, tr("Members(resolved)"));
     195                    tabbedPane.setToolTipTextAt(3, tr("Merged member list frozen. No pending conflicts in the member list of this relation"));
     196                    tabbedPane.setIconAt(3, mergeComplete);
     197                } else {
     198                    tabbedPane.setTitleAt(3, tr("Members(with conflicts)"));
     199                    tabbedPane.setToolTipTextAt(3, tr("Pending conflicts in the member list of this relation"));
     200                    tabbedPane.setIconAt(3, mergeIncomplete);
     201                }
    193202            }
    194203            updateResolvedCompletely();
     
    205214            }
    206215            updateResolvedCompletely();
     216        } else if (PropertiesMergeModel.DELETE_PRIMITIVE_PROP.equals(evt.getPropertyName())) {
     217            for (IConflictResolver resolver: conflictResolvers) {
     218                resolver.deletePrimitive((Boolean) evt.getNewValue());
     219            }
    207220        }
    208221    }
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java

    r2881 r2936  
    117117    }
    118118
    119     protected ArrayList<T> getMergedEntries() {
     119    protected List<T> getMergedEntries() {
    120120        return entries.get(MERGED_ENTRIES);
    121121    }
    122122
    123     protected ArrayList<T> getMyEntries() {
     123    protected List<T> getMyEntries() {
    124124        return entries.get(MY_ENTRIES);
    125125    }
    126126
    127     protected ArrayList<T> getTheirEntries() {
     127    protected List<T> getTheirEntries() {
    128128        return entries.get(THEIR_ENTRIES);
    129129    }
     
    230230    protected void copyToTop(ListRole role, int []rows) {
    231231        copy(role, rows, 0);
    232         fireModelDataChanged();
    233232        mergedEntriesSelectionModel.setSelectionInterval(0, rows.length -1);
    234233    }
     
    267266    public void copyToEnd(ListRole source, int [] rows) {
    268267        copy(source, rows, getMergedEntriesSize());
    269         fireModelDataChanged();
    270268        mergedEntriesSelectionModel.setSelectionInterval(getMergedEntriesSize()-rows.length, getMergedEntriesSize() -1);
    271269
     
    292290    public void copyTheirToEnd(int [] rows) {
    293291        copyToEnd(THEIR_ENTRIES, rows);
     292    }
     293
     294    public void clearMerged() {
     295        getMergedEntries().clear();
     296        fireModelDataChanged();
    294297    }
    295298
     
    304307        }
    305308        getMergedEntries().addAll(position, newItems);
     309        fireModelDataChanged();
    306310    }
    307311
     
    318322    protected void copyBeforeCurrent(ListRole source, int [] rows, int current) {
    319323        copy(source, rows, current);
    320         fireModelDataChanged();
    321324        mergedEntriesSelectionModel.setSelectionInterval(current, current + rows.length-1);
    322325    }
     
    360363    protected void copyAfterCurrent(ListRole source, int [] rows, int current) {
    361364        copy(source, rows, current + 1);
    362         fireModelDataChanged();
    363365        mergedEntriesSelectionModel.setSelectionInterval(current+1, current + rows.length-1);
    364366        notifyObservers();
     
    404406            // can't move up
    405407            return;
    406         ArrayList<T> mergedEntries = getMergedEntries();
     408        List<T> mergedEntries = getMergedEntries();
    407409        for (int row: rows) {
    408410            T n = mergedEntries.get(row);
     
    427429        if (rows == null || rows.length == 0)
    428430            return;
    429         ArrayList<T> mergedEntries = getMergedEntries();
     431        List<T> mergedEntries = getMergedEntries();
    430432        if (rows[rows.length -1] == mergedEntries.size() -1)
    431433            // can't move down
     
    455457            return;
    456458
    457         ArrayList<T> mergedEntries = getMergedEntries();
     459        List<T> mergedEntries = getMergedEntries();
    458460
    459461        for (int i = rows.length-1; i>=0;i--) {
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java

    r2512 r2936  
    11package org.openstreetmap.josm.gui.conflict.pair.nodes;
    2 
    3 import java.util.logging.Logger;
    42
    53import javax.swing.JScrollPane;
     
    86import org.openstreetmap.josm.data.osm.Node;
    97import org.openstreetmap.josm.data.osm.Way;
     8import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver;
    109import org.openstreetmap.josm.gui.conflict.pair.ListMerger;
    1110
     
    1413 *
    1514 */
    16 public class NodeListMerger extends ListMerger<Node> {
    17     private static final Logger logger = Logger.getLogger(NodeListMerger.class.getName());
     15public class NodeListMerger extends ListMerger<Node> implements IConflictResolver {
     16    //private static final Logger logger = Logger.getLogger(NodeListMerger.class.getName());
    1817
    1918    public NodeListMerger() {
     
    6665        ((NodeListMergeModel)model).populate(my, their);
    6766    }
     67
     68    public void deletePrimitive(boolean deleted) {
     69        if (deleted) {
     70            model.setFrozen(true);
     71            model.clearMerged();
     72        } else {
     73            model.setFrozen(false);
     74        }
     75    }
    6876}
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java

    r2846 r2936  
    5353
    5454    static public final String RESOLVED_COMPLETELY_PROP = PropertiesMergeModel.class.getName() + ".resolvedCompletely";
     55    static public final String DELETE_PRIMITIVE_PROP = PropertiesMergeModel.class.getName() + ".deletePrimitive";
    5556
    5657    private OsmPrimitive my;
     
    287288    }
    288289
     290    private boolean getMergedDeletedState(MergeDecisionType decision) {
     291        switch (decision) {
     292        case KEEP_MINE:
     293            return myDeletedState;
     294        case KEEP_THEIR:
     295            return theirDeletedState;
     296        default:
     297            return false;
     298        }
     299    }
     300
    289301    /**
    290302     * decides the conflict between two deleted states
     
    295307    public void decideDeletedStateConflict(MergeDecisionType decision) throws IllegalArgumentException{
    296308        CheckParameterUtil.ensureParameterNotNull(decision, "decision");
     309
     310        boolean oldMergedDeletedState = getMergedDeletedState(this.deletedMergeDecision);
     311        boolean newMergedDeletedState = getMergedDeletedState(decision);
     312
    297313        this.deletedMergeDecision = decision;
    298314        setChanged();
    299315        notifyObservers();
    300316        fireCompletelyResolved();
     317
     318        if (oldMergedDeletedState != newMergedDeletedState) {
     319            support.firePropertyChange(DELETE_PRIMITIVE_PROP, oldMergedDeletedState, newMergedDeletedState);
     320        }
    301321    }
    302322
     
    478498                        dependent.size(), dependent.size(), way.getId())
    479499                        + "</html>",
    480                 tr("Undelete additional nodes?"),
    481                 JOptionPane.YES_NO_OPTION,
    482                 JOptionPane.QUESTION_MESSAGE,
    483                 null,
    484                 options,
    485                 options[0]
     500                        tr("Undelete additional nodes?"),
     501                        JOptionPane.YES_NO_OPTION,
     502                        JOptionPane.QUESTION_MESSAGE,
     503                        null,
     504                        options,
     505                        options[0]
    486506        );
    487507
     
    512532                        dependent.size(), dependent.size(), r.getId())
    513533                        + "</html>",
    514                 tr("Undelete dependent primitives?"),
    515                 JOptionPane.YES_NO_OPTION,
    516                 JOptionPane.QUESTION_MESSAGE,
    517                 null,
    518                 options,
    519                 options[0]
     534                        tr("Undelete dependent primitives?"),
     535                        JOptionPane.YES_NO_OPTION,
     536                        JOptionPane.QUESTION_MESSAGE,
     537                        null,
     538                        options,
     539                        options[0]
    520540        );
    521541
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java

    r2612 r2936  
    2222
    2323import org.openstreetmap.josm.data.coor.LatLon;
     24import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver;
    2425import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
    2526import org.openstreetmap.josm.tools.ImageProvider;
     
    3031 *
    3132 */
    32 public class PropertiesMerger extends JPanel implements Observer {
     33public class PropertiesMerger extends JPanel implements Observer, IConflictResolver {
    3334    private static DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000000");
    3435
     
    650651        }
    651652    }
     653
     654    public void deletePrimitive(boolean deleted) {
     655        // Do nothing
     656    }
    652657}
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java

    r2512 r2936  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.conflict.pair.relation;
    3 
    4 import java.util.logging.Logger;
    53
    64import javax.swing.JScrollPane;
     
    97import org.openstreetmap.josm.data.osm.Relation;
    108import org.openstreetmap.josm.data.osm.RelationMember;
     9import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver;
    1110import org.openstreetmap.josm.gui.conflict.pair.ListMerger;
    1211
     
    1413 * A UI component for resolving conflicts in the member lists of two {@see Relation}
    1514 */
    16 public class RelationMemberMerger extends ListMerger<RelationMember> {
    17     private static final Logger logger = Logger.getLogger(RelationMemberMerger.class.getName());
     15public class RelationMemberMerger extends ListMerger<RelationMember> implements IConflictResolver {
     16    //private static final Logger logger = Logger.getLogger(RelationMemberMerger.class.getName());
    1817
    1918    @Override
     
    6261        super(new RelationMemberListMergeModel());
    6362    }
     63
     64    public void deletePrimitive(boolean deleted) {
     65        if (deleted) {
     66            model.clearMerged();
     67            model.setFrozen(true);
     68        } else {
     69            model.setFrozen(false);
     70        }
     71    }
    6472}
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModel.java

    r2512 r2936  
    77import java.util.HashSet;
    88import java.util.Set;
    9 import java.util.logging.Logger;
    109
    1110import javax.swing.table.DefaultTableModel;
     
    2928 */
    3029public class TagMergeModel extends DefaultTableModel {
    31     private static final Logger logger = Logger.getLogger(TagMergeModel.class.getName());
     30    //private static final Logger logger = Logger.getLogger(TagMergeModel.class.getName());
    3231
    3332    static public final String PROP_NUM_UNDECIDED_TAGS = TagMergeModel.class.getName() + ".numUndecidedTags";
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java

    r2846 r2936  
    2626import javax.swing.event.ListSelectionListener;
    2727
     28import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver;
    2829import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
    2930import org.openstreetmap.josm.tools.ImageProvider;
     
    3233 *
    3334 */
    34 public class TagMerger extends JPanel {
     35public class TagMerger extends JPanel implements IConflictResolver {
    3536
    3637    private JTable mineTable;
     
    393394        }
    394395    }
     396
     397    public void deletePrimitive(boolean deleted) {
     398        // Use my entries, as it doesn't really matter
     399        MergeDecisionType decision = deleted?MergeDecisionType.KEEP_MINE:MergeDecisionType.UNDECIDED;
     400        for (int i=0; i<model.getRowCount(); i++) {
     401            model.decide(i, decision);
     402        }
     403    }
    395404}
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialog.java

    r2512 r2936  
    109109
    110110    public void historyUpdated(HistoryDataSet source, PrimitiveId primitiveId) {
    111         if (primitiveId == null) {
     111        if (primitiveId == null || primitiveId.equals(browser.getHistory().getPrimitmiveId())) {
    112112            browser.populate(source.getHistory(browser.getHistory().getPrimitmiveId()));
    113         } else if (primitiveId.equals(browser.getHistory().getPrimitmiveId())) {
    114             browser.populate(source.getHistory(primitiveId));
    115113        }
    116114    }
  • trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java

    r2512 r2936  
    3737public class OsmHistoryReader {
    3838
    39     private InputStream in;
    40     private HistoryDataSet data;
     39    private final InputStream in;
     40    private final HistoryDataSet data;
    4141
    4242    private class Parser extends DefaultHandler {
     
    131131                throwException(tr("Missing mandatory attribute ''{0}''.", name));
    132132            }
    133             if (v.equals("true")) return true;
    134             if (v.equals("false")) return false;
     133            if ("true".equals(v)) return true;
     134            if ("false".equals(v)) return false;
    135135            throwException(tr("Illegal value for mandatory attribute ''{0}'' of type boolean. Got ''{1}''.", name, v));
    136136            // not reached
     
    231231    public OsmHistoryReader(InputStream source) {
    232232        this.in = source;
    233         data = new HistoryDataSet();
     233        this.data = new HistoryDataSet();
    234234    }
    235235
Note: See TracChangeset for help on using the changeset viewer.