Changeset 2712 in josm


Ignore:
Timestamp:
2009-12-30T21:28:16+01:00 (15 years ago)
Author:
mjulius
Message:

fixes #4252 - Handling relations of way combining unintuitive
For both the combining of ways and merging of nodes the default is now to keep the relation membership for the first way/node in the list and to remove the other members of the same relation.

Location:
trunk/src/org/openstreetmap/josm/gui/conflict/tags
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java

    r2626 r2712  
    1515import java.beans.PropertyChangeEvent;
    1616import java.beans.PropertyChangeListener;
     17import java.util.HashSet;
    1718import java.util.LinkedList;
    1819import java.util.List;
     20import java.util.Set;
    1921
    2022import javax.swing.AbstractAction;
     
    3133import org.openstreetmap.josm.data.osm.Node;
    3234import org.openstreetmap.josm.data.osm.OsmPrimitive;
     35import org.openstreetmap.josm.data.osm.Relation;
    3336import org.openstreetmap.josm.data.osm.TagCollection;
    3437import org.openstreetmap.josm.data.osm.Way;
     
    130133        }
    131134        if (targetPrimitive instanceof Way) {
    132             setTitle(
    133                     tr(
    134                             "Conflicts when combining ways - combined way is ''{0}''",
    135                             targetPrimitive.getDisplayName(DefaultNameFormatter.getInstance())
    136                     )
    137             );
     135            setTitle(tr("Conflicts when combining ways - combined way is ''{0}''", targetPrimitive
     136                    .getDisplayName(DefaultNameFormatter.getInstance())));
    138137            helpAction.setHelpTopic(ht("/Action/CombineWay#ResolvingConflicts"));
    139138            getRootPane().putClientProperty("help", ht("/Action/CombineWay#ResolvingConflicts"));
    140139        } else if (targetPrimitive instanceof Node) {
    141             setTitle(
    142                     tr(
    143                             "Conflicts when merging nodes - target node is ''{0}''",
    144                             targetPrimitive.getDisplayName(DefaultNameFormatter.getInstance())
    145                     )
    146             );
     140            setTitle(tr("Conflicts when merging nodes - target node is ''{0}''", targetPrimitive
     141                    .getDisplayName(DefaultNameFormatter.getInstance())));
    147142            helpAction.setHelpTopic(ht("/Action/MergeNodes#ResolvingConflicts"));
    148143            getRootPane().putClientProperty("help", ht("/Action/MergeNodes#ResolvingConflicts"));
     
    195190
    196191    public CombinePrimitiveResolverDialog(Component owner) {
    197         super(JOptionPane.getFrameForComponent(owner),true /* modal */);
     192        super(JOptionPane.getFrameForComponent(owner), true /* modal */);
    198193        build();
    199194    }
     
    227222        List<Command> cmds = new LinkedList<Command>();
    228223
    229         if (getTagConflictResolverModel().getNumDecisions() >0) {
     224        if (getTagConflictResolverModel().getNumDecisions() > 0) {
    230225            TagCollection tc = getTagConflictResolverModel().getResolution();
    231226            cmds.addAll(buildTagChangeCommand(targetPrimitive, tc));
     
    235230        }
    236231
    237         if (getRelationMemberConflictResolverModel().getNumDecisions() >0) {
     232        if (getRelationMemberConflictResolverModel().getNumDecisions() > 0) {
    238233            cmds.addAll(getRelationMemberConflictResolverModel().buildResolutionCommands(targetPrimitive));
    239234        }
    240235
    241         Command cmd = pnlRelationMemberConflictResolver.buildTagApplyCommands(
    242                 getRelationMemberConflictResolverModel().getModifiedRelations(targetPrimitive)
    243         );
     236        Command cmd = pnlRelationMemberConflictResolver.buildTagApplyCommands(getRelationMemberConflictResolverModel()
     237                .getModifiedRelations(targetPrimitive));
    244238        if (cmd != null) {
    245239            cmds.add(cmd);
     
    250244    protected void prepareDefaultTagDecisions() {
    251245        TagConflictResolverModel model = getTagConflictResolverModel();
    252         for (int i =0; i< model.getRowCount(); i++) {
     246        for (int i = 0; i < model.getRowCount(); i++) {
    253247            MultiValueResolutionDecision decision = model.getDecision(i);
    254248            List<String> values = decision.getValues();
     
    265259    protected void prepareDefaultRelationDecisions() {
    266260        RelationMemberConflictResolverModel model = getRelationMemberConflictResolverModel();
    267         for (int i=0; i < model.getNumDecisions(); i++) {
    268             model.getDecision(i).decide(RelationMemberConflictDecisionType.KEEP);
     261        Set<Relation> relations = new HashSet<Relation>();
     262        for (int i = 0; i < model.getNumDecisions(); i++) {
     263            RelationMemberConflictDecision decision = model.getDecision(i);
     264            if (!relations.contains(decision.getRelation())) {
     265                decision.decide(RelationMemberConflictDecisionType.KEEP);
     266                relations.add(decision.getRelation());
     267            } else {
     268                decision.decide(RelationMemberConflictDecisionType.REMOVE);
     269            }
    269270        }
    270271        model.refresh();
     
    298299            //
    299300            getContentPane().add(pnlRelationMemberConflictResolver, BorderLayout.CENTER);
    300         } else if (tagModel.getNumDecisions() >0) {
     301        } else if (tagModel.getNumDecisions() > 0) {
    301302            // tag conflicts only
    302303            //
     
    310311        int numTagDecisions = getTagConflictResolverModel().getNumDecisions();
    311312        int numRelationDecisions = getRelationMemberConflictResolverModel().getNumDecisions();
    312         if (numTagDecisions > 0 &&  numRelationDecisions > 0) {
     313        if (numTagDecisions > 0 && numRelationDecisions > 0) {
    313314            spTagConflictTypes.setDividerLocation(0.5);
    314315        }
     
    328329        if (visible) {
    329330            prepareGUIBeforeConflictResolutionStarts();
    330             new WindowGeometry(
    331                     getClass().getName()  + ".geometry",
    332                     WindowGeometry.centerInWindow(
    333                             Main.parent,
    334                             new Dimension(600,400)
    335                     )
    336             ).applySafe(this);
     331            new WindowGeometry(getClass().getName() + ".geometry", WindowGeometry.centerInWindow(Main.parent,
     332                    new Dimension(600, 400))).applySafe(this);
    337333            setCancelled(false);
    338334            btnApply.requestFocusInWindow();
     
    372368
    373369        protected void updateEnabledState() {
    374             setEnabled(
    375                     pnlTagConflictResolver.getModel().getNumConflicts() == 0
    376                     && pnlRelationMemberConflictResolver.getModel().getNumConflicts() == 0
    377             );
     370            setEnabled(pnlTagConflictResolver.getModel().getNumConflicts() == 0
     371                    && pnlRelationMemberConflictResolver.getModel().getNumConflicts() == 0);
    378372        }
    379373
     
    393387            int numTagDecisions = getTagConflictResolverModel().getNumDecisions();
    394388            int numRelationDecisions = getRelationMemberConflictResolverModel().getNumDecisions();
    395             if (numTagDecisions > 0 &&  numRelationDecisions > 0) {
     389            if (numTagDecisions > 0 && numRelationDecisions > 0) {
    396390                spTagConflictTypes.setDividerLocation(0.5);
    397391            }
     
    404398        public AutoAdjustingSplitPane(int newOrientation) {
    405399            super(newOrientation);
    406             addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,this);
     400            addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, this);
    407401            addHierarchyBoundsListener(this);
    408402        }
    409403
    410404        public void ancestorResized(HierarchyEvent e) {
    411             setDividerLocation((int)(dividerLocation * getHeight()));
     405            setDividerLocation((int) (dividerLocation * getHeight()));
    412406        }
    413407
     
    418412        public void propertyChange(PropertyChangeEvent evt) {
    419413            if (evt.getPropertyName().equals(JSplitPane.DIVIDER_LOCATION_PROPERTY)) {
    420                 int newVal = (Integer)evt.getNewValue();
     414                int newVal = (Integer) evt.getNewValue();
    421415                if (getHeight() != 0) {
    422                     dividerLocation = (double)newVal / (double)getHeight();
     416                    dividerLocation = (double) newVal / (double) getHeight();
    423417                }
    424418            }
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java

    r2512 r2712  
    121121
    122122    public void initForWayCombining() {
    123        lblHeader.setText(tr("<html>The combined ways are members in one ore more relations. "
    124                 + "Please decide whether your want to <strong>keep</strong> these memberships "
     123        lblHeader.setText(tr("<html>The combined ways are members in one ore more relations. "
     124                + "Please decide whether you want to <strong>keep</strong> these memberships "
    125125                + "for the combined way or whether you want to <strong>remove</strong> them.<br>"
    126                 + "The default is to <strong>keep</strong> them: the combined way will take the place of the original way in the membership."
    127                         + "</html>"));
    128        invalidate();
     126                + "The default is to <strong>keep</strong> the first way and <strong>remove</strong> "
     127                + "the other ways that are members of the same relation: the combined way will "
     128                + "take the place of the original way in the membership."
     129                + "</html>"));
     130        invalidate();
    129131    }
    130132
    131133    public void initForNodeMerging() {
    132134        lblHeader.setText(tr("<html>The merged nodes are members in one ore more relations. "
    133                  + "Please decide whether your want to <strong>keep</strong> these memberships "
    134                  + "for the target node or whether you want to <strong>remove</strong> them.<br>"
    135                  + "The default is to <strong>keep</strong> them: the target node will take the place of the original node in the membership."
    136                          + "</html>"));
     135                + "Please decide whether you want to <strong>keep</strong> these memberships "
     136                + "for the target node or whether you want to <strong>remove</strong> them.<br>"
     137                + "The default is to <strong>keep</strong> the first node and <strong>remove</strong> "
     138                + "the other nodes that are members of the same relation: the target node will "
     139                + "take the place of the original node in the membership."
     140                + "</html>"));
    137141        invalidate();
    138      }
     142    }
    139143
    140144    class ApplyRoleAction extends AbstractAction {
     
    183187        AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithMemberRoles(acList);
    184188        tfRole.setAutoCompletionList(acList);
    185         AutoCompletingTextField editor = (AutoCompletingTextField) tblResolver.getColumnModel().getColumn(2)
    186                 .getCellEditor();
     189        AutoCompletingTextField editor = (AutoCompletingTextField) tblResolver.getColumnModel().getColumn(2).getCellEditor();
    187190        if (editor != null) {
    188191            editor.setAutoCompletionList(acList);
Note: See TracChangeset for help on using the changeset viewer.