Ignore:
Timestamp:
2011-10-23T19:41:25+02:00 (13 years ago)
Author:
bastiK
Message:

applied #6853 - In draw mode, select the way to be extended immediately (patch by olejorgenb)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r4327 r4539  
    5353import org.openstreetmap.josm.tools.Pair;
    5454import org.openstreetmap.josm.tools.Shortcut;
     55import org.openstreetmap.josm.tools.Utils;
    5556
    5657/**
    57  *
     58 * Mapmode to add nodes, create and extend ways.
    5859 */
    5960public class DrawAction extends MapMode implements MapViewPaintable, SelectionChangedListener, AWTEventListener {
     
    9899        updateStatusLine();
    99100        if ((!drawHelperLine || wayIsFinished) && !drawTargetHighlight) return;
     101        // update selection to reflect which way being modified
     102        if (currentBaseNode != null && getCurrentDataSet().getSelected().isEmpty() == false) {
     103            Way continueFrom = getWayForNode(currentBaseNode);
     104            if (alt && continueFrom != null) {
     105                getCurrentDataSet().beginUpdate(); // to prevent the selection listener to screw around with the state
     106                getCurrentDataSet().addSelected(currentBaseNode);
     107                getCurrentDataSet().clearSelection(continueFrom);
     108                getCurrentDataSet().endUpdate();
     109            } else if (!alt && continueFrom != null) {
     110                getCurrentDataSet().addSelected(continueFrom);
     111            }
     112        }
    100113        Main.map.mapView.repaint();
    101114    }
     
    294307                // (this is just a convenience option so that people don't
    295308                // have to switch modes)
    296                 newSelection.clear();
    297                 newSelection.add(n);
     309
    298310                getCurrentDataSet().setSelected(n);
     311                // If we extend/continue an existing way, select it already now to make it obvious
     312                Way continueFrom = getWayForNode(n);
     313                if (continueFrom != null) {
     314                    getCurrentDataSet().addSelected(continueFrom);
     315                }
     316
    299317                // The user explicitly selected a node, so let him continue drawing
    300318                wayIsFinished = false;
     
    718736    public Way getWayForNode(Node n) {
    719737        Way way = null;
    720         for (Way w : OsmPrimitive.getFilteredList(n.getReferrers(), Way.class)) {
     738        for (Way w : Utils.filteredCollection(n.getReferrers(), Way.class)) {
    721739            if (!w.isUsable() || w.getNodesCount() < 1) {
    722740                continue;
Note: See TracChangeset for help on using the changeset viewer.