Index: src/utilsplugin2/UtilsPlugin2.java
===================================================================
--- src/utilsplugin2/UtilsPlugin2.java	(revision 25797)
+++ src/utilsplugin2/UtilsPlugin2.java	(working copy)
@@ -14,6 +14,8 @@
     JMenuItem addIntersections;
     JMenuItem splitObject;
     JMenuItem selectWayNodes;
+    JMenuItem extendSelection;
+    JMenuItem extendSelectionR;
 
     public UtilsPlugin2(PluginInformation info) {
         super(info);
@@ -22,6 +24,8 @@
         addIntersections = MainMenu.add(Main.main.menu.toolsMenu, new AddIntersectionsAction());
         splitObject = MainMenu.add(Main.main.menu.toolsMenu, new SplitObjectAction());
         selectWayNodes = MainMenu.add(Main.main.menu.toolsMenu, new SelectWayNodesAction());
+        extendSelection = MainMenu.add(Main.main.menu.toolsMenu, new ExtendSelectionAction());
+        extendSelectionR = MainMenu.add(Main.main.menu.toolsMenu, new RecursiveExtendSelectionAction());
     }
 
     @Override
@@ -31,5 +35,7 @@
         addIntersections.setEnabled(enabled);
         splitObject.setEnabled(enabled);
         selectWayNodes.setEnabled(enabled);
+        extendSelection.setEnabled(enabled);
+        extendSelectionR.setEnabled(enabled);
     }
 }
Index: src/utilsplugin2/RecursiveExtendSelectionAction.java
===================================================================
--- src/utilsplugin2/RecursiveExtendSelectionAction.java	(revision 0)
+++ src/utilsplugin2/RecursiveExtendSelectionAction.java	(revision 0)
@@ -0,0 +1,99 @@
+package utilsplugin2;
+
+import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.swing.JOptionPane;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.SelectionChangedListener;
+import org.openstreetmap.josm.data.osm.*;
+
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ *    Extends current selection by selecting nodes on all touched ways
+ */
+class RecursiveExtendSelectionAction extends JosmAction {
+
+    public RecursiveExtendSelectionAction() {
+        super(tr("Extends selection recursively"), "rextendselection", tr("Extends current selection recursively."),
+                Shortcut.registerShortcut("tools:rextendselection", tr("Tool: {0}","Extends selection recursively"),
+                KeyEvent.VK_E, Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true);
+        putValue("help", ht("/Action/RExtendSelection"));
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
+        Set<Way> activeWays = new LinkedHashSet<Way>();
+
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
+
+        if (selectedNodes.isEmpty() && selectedWays.isEmpty()) return;
+
+        // if no nodes are selected,
+        // select ways attached to already selected ways
+        if (selectedNodes.isEmpty() && !selectedWays.isEmpty()) {
+            Set<Way> newWays = new LinkedHashSet<Way>();
+
+            NodeWayUtils.addWaysIntersectingWays(getCurrentDataSet().getWays(), selectedWays, newWays);
+            
+            newWays.removeAll(selectedWays);
+            System.out.printf("%d ways added to selection\n",newWays.size());
+            getCurrentDataSet().addSelected(newWays);
+            return;
+        }
+
+
+        if (! selectedWays.isEmpty()) activeWays = selectedWays;
+        
+        Set<Node> newNodes = new HashSet <Node>();
+
+
+        if ( activeWays.isEmpty()) {
+            NodeWayUtils.addWaysConnectedToNodes(selectedNodes, activeWays);
+        }
+
+        for (Node node: selectedNodes) {
+            NodeWayUtils.addNodesConnectedToWays(activeWays,newNodes);
+        }
+        
+        // select only newly found nodes
+         newNodes.removeAll(selectedNodes);
+         System.out.printf("Found %d new nodes\n",newNodes.size());
+         
+         getCurrentDataSet().addSelected(newNodes);
+
+         newNodes = null;
+
+    }
+
+    @Override
+    protected void updateEnabledState() {
+        if (getCurrentDataSet() == null) {
+            setEnabled(false);
+        } else {
+            updateEnabledState(getCurrentDataSet().getSelected());
+        }
+    }
+
+    @Override
+    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
+        if (selection == null) {
+            setEnabled(false);
+            return;
+        }
+        setEnabled(!selection.isEmpty());
+    }
+
+
+}
Index: src/utilsplugin2/NodeWayUtils.java
===================================================================
--- src/utilsplugin2/NodeWayUtils.java	(revision 0)
+++ src/utilsplugin2/NodeWayUtils.java	(revision 0)
@@ -0,0 +1,122 @@
+// License: GPL. Copyright 2011 by Alexei Kasatkin
+package utilsplugin2;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.tools.Geometry;
+import org.openstreetmap.josm.tools.Pair;
+
+/**
+ * Class with some useful functions that are reused in extend selection actions
+ *
+ */
+public final class NodeWayUtils {
+
+    /**
+     * Find the neighbours of node n on the way w and put them in given collection
+     * @param w way on which the search goes
+     * @param n node to find its neighbours
+     * @param nodes collection to place the nodes we found
+     */
+    static void addNeighbours(Way w, Node n, Collection<Node> nodes) {
+        List<Node> nodeList = w.getNodes();
+        
+        int idx = nodeList.indexOf(n);
+        if (idx == -1) return;
+
+        // add previous element
+        if (idx > 0) {
+            nodes.add(nodeList.get(idx - 1));
+        }
+        // add next element
+        if (idx < nodeList.size() - 1) {
+            nodes.add(nodeList.get(idx + 1));
+        }
+        if (w.isClosed()) {
+            // cyclic neighbours detection
+            if (idx == 0) {
+                nodes.add(nodeList.get(nodeList.size() - 2));
+            }
+            if (idx == nodeList.size() - 1) {
+                nodes.add(nodeList.get(1));
+            }
+        }
+     }
+
+    /**
+     * Adds all ways attached to way to specified collection
+     * @param w way to find attached ways
+     * @param ways  collection to place the ways we found
+     */
+    static void addWaysConnectedToWay(Way w, Collection<Way> ways) {
+        List<Node> nodes = w.getNodes();
+        for (Node n: nodes) {
+            ways.addAll(OsmPrimitive.getFilteredList(n.getReferrers(), Way.class));
+        }
+    }
+
+    /**
+     * Adds all ways attached to node to specified collection
+     * @param n Node to find attached ways
+     * @param ways  collection to place the ways we found
+     */
+    static void addWaysConnectedToNode(Node n, Collection<Way> ways) {
+        ways.addAll(OsmPrimitive.getFilteredList(n.getReferrers(), Way.class));
+    }
+
+
+
+    /**
+     * Adds all ways intersecting one way to specified set
+     * @param ways collection of ways to search
+     * @param w way to check intersections
+     * @param newWays set to place the ways we found
+     */
+    static void addWaysIntersectingWay(Collection<Way> ways, Way w, Set<Way> newWays) {
+        List<Pair<Node, Node>> nodePairs = w.getNodePairs(false);
+            for (Way anyway: ways) {
+            List<Pair<Node, Node>> nodePairs2 = anyway.getNodePairs(false);
+            loop: for (Pair<Node,Node> p1 : nodePairs) {
+                for (Pair<Node,Node> p2 : nodePairs2) {
+                    if (null!=Geometry.getSegmentSegmentIntersection(
+                            p1.a.getEastNorth(),p1.b.getEastNorth(),
+                            p2.a.getEastNorth(),p2.b.getEastNorth())) {
+                        newWays.add(anyway);
+                        break loop;
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Adds all ways from allWays intersecting initWays way to specified set newWays
+     * @param allWays collection of ways to search
+     * @param initWays ways to check intersections
+     * @param newWays set to place the ways we found
+     */
+    static void addWaysIntersectingWays(Collection<Way> allWays, Collection<Way> initWays, Set<Way> newWays) {
+        for (Way w : initWays){
+            addWaysIntersectingWay(allWays, w, newWays);
+        }
+    }
+
+    static void addWaysConnectedToNodes(Set<Node> selectedNodes, Set<Way> newWays) {
+        for (Node node: selectedNodes) {
+            addWaysConnectedToNode(node, newWays);
+        }
+    }
+
+    static void addNodesConnectedToWays(Set<Way> initWays, Set<Node> newNodes) {
+        for (Way w: initWays) {
+                newNodes.addAll(w.getNodes());
+        }
+    }
+
+
+
+}
Index: src/utilsplugin2/ExtendSelectionAction.java
===================================================================
--- src/utilsplugin2/ExtendSelectionAction.java	(revision 0)
+++ src/utilsplugin2/ExtendSelectionAction.java	(revision 0)
@@ -0,0 +1,130 @@
+package utilsplugin2;
+
+import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.swing.JOptionPane;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.SelectionChangedListener;
+import org.openstreetmap.josm.data.osm.*;
+
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ *    Extends current selection
+ */
+class ExtendSelectionAction extends JosmAction {
+
+    public static final boolean treeMode = false;
+
+    public ExtendSelectionAction() {
+        super(tr("Extends selection"), "extendselection", tr("Extends current selections."),
+                Shortcut.registerShortcut("tools:extendselection", tr("Tool: {0}","Extends selection"),
+                KeyEvent.VK_E, Shortcut.GROUP_EDIT), true);
+        putValue("help", ht("/Action/ExtendSelection"));
+    }
+
+    private  Set<Way> activeWays = new LinkedHashSet<Way>();
+
+    public void actionPerformed(ActionEvent e) {
+        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
+
+
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
+        
+        
+        // if no nodes and no ways are selected, do nothing
+        if (selectedNodes.isEmpty() && selectedWays.isEmpty()) return;
+
+        // if no nodes are selected,
+        // select ways attached to already selected ways
+        if (selectedNodes.isEmpty() && !selectedWays.isEmpty()) {
+            Set<Way> newWays = new LinkedHashSet<Way>();
+
+
+            for (Way w : selectedWays){
+                NodeWayUtils.addWaysConnectedToWay(w, newWays);
+            }
+            newWays.removeAll(selectedWays);
+            System.out.printf("%d ways added to selection\n",newWays.size());
+            getCurrentDataSet().addSelected(newWays);
+            return;
+        }
+
+
+
+        if (selectedWays.isEmpty()) {
+            // if one node is selected, used ways connected to it to extend selecteons
+            // activeWays are remembered for next extend action (!!!)
+
+            // FIXME: some strange behaviour is possible if user delete some of these way
+            // how to clear activeWays during such user actions? Do not know
+            if (selectedNodes.size() == 1) {
+                activeWays.clear();
+                System.out.println("Cleared active ways");
+            }
+        } else {
+            // use only ways that were selected for adding nodes
+            activeWays = selectedWays;
+        }
+
+        Set<Node> newNodes = new HashSet <Node>();
+
+        if (treeMode || activeWays.isEmpty()) {
+                NodeWayUtils.addWaysConnectedToNodes(selectedNodes, activeWays);
+            }
+
+        for (Node node: selectedNodes) {
+            for (Way w: activeWays) {
+                NodeWayUtils.addNeighbours(w, node, newNodes);
+            }
+        }
+        
+        // select only newly found nodes
+         newNodes.removeAll(selectedNodes);
+
+         System.out.printf("Found %d new nodes\n",newNodes.size());
+         
+         // enable branching on next call of this function
+         // if no new nodes were found, next search will include all touched ways
+         if (newNodes.isEmpty()) {
+             activeWays.clear();
+             System.out.println("No more points found, activeways cleared");
+         }
+
+         getCurrentDataSet().addSelected(newNodes);
+         newNodes = null;
+
+    }
+
+    @Override
+    protected void updateEnabledState() {
+        if (getCurrentDataSet() == null) {
+            setEnabled(false);
+        } else {
+            updateEnabledState(getCurrentDataSet().getSelected());
+        }
+    }
+
+    @Override
+    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
+        if (selection == null) {
+            setEnabled(false);
+            return;
+        }
+        setEnabled(!selection.isEmpty());
+    }
+
+
+
+}
Index: build.xml
===================================================================
--- build.xml	(revision 25797)
+++ build.xml	(working copy)
@@ -30,7 +30,7 @@
 <project name="utilsplugin2" default="dist" basedir=".">
 
     <!-- enter the SVN commit message -->
-    <property name="commit.message" value="fix" />
+    <property name="commit.message" value="extend selection" />
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
     <property name="plugin.main.version" value="3835" />
 
@@ -39,7 +39,7 @@
       ************************************************
       ** should not be necessary to change the following properties
      -->
-    <property name="josm"                   location="../../core/dist/josm-custom.jar"/>
+    <property name="josm"                   location="../../dist/josm-custom.jar"/>
     <property name="plugin.build.dir"       value="build"/>
     <property name="plugin.src.dir"         value="src"/>
     <!-- this is the directory where the plugin jar is copied to -->
@@ -168,7 +168,7 @@
             <env key="LANG" value="C"/>
             <arg value="info"/>
             <arg value="--xml"/>
-            <arg value="../../core"/>
+            <arg value="../../"/>
         </exec>
         <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
         <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
@@ -253,4 +253,9 @@
 
     <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
     </target>
+    <target name="runjosm" depends="install">
+        <java jar="${josm}" >
+            <arg line="../../data_nodist/neubrandenburg.osm"/>
+        </java>
+    </target>
 </project>
