Index: applications/editors/josm/plugins/utilsplugin2/build.xml
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/build.xml	(revision 25190)
+++ applications/editors/josm/plugins/utilsplugin2/build.xml	(revision 25814)
@@ -31,5 +31,5 @@
 
     <!-- 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" />
@@ -254,3 +254,8 @@
     <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>
Index: applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/AdjacentNodesAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/AdjacentNodesAction.java	(revision 25814)
+++ applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/AdjacentNodesAction.java	(revision 25814)
@@ -0,0 +1,115 @@
+// License: GPL. Copyright 2011 by Alexei Kasatkin and others
+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.Set;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.*;
+
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ *    Extends current selection
+ */
+class AdjacentNodesAction extends JosmAction {
+
+    public static final boolean treeMode = false;
+
+    public AdjacentNodesAction() {
+        super(tr("Adjacent nodes"), "adjnodes", tr("Select adjacent nodes"),
+                Shortcut.registerShortcut("tools:adjnodes", tr("Tool: {0}","Adjacent nodes"),
+                KeyEvent.VK_E, Shortcut.GROUP_EDIT), true);
+        putValue("help", ht("/Action/AdjacentNodes"));
+    }
+
+    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 (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;
+        }
+
+        // selecting nodes of selected ways
+        if(selectedNodes.isEmpty()) {
+            HashSet<Node> newNodes = new HashSet<Node>();
+            NodeWayUtils.addNodesConnectedToWays(selectedWays, newNodes);
+            activeWays.clear();
+            getCurrentDataSet().setSelected(newNodes);
+            return;
+        }
+
+        if (activeWays.isEmpty()) {
+                NodeWayUtils.addWaysConnectedToNodes(selectedNodes, activeWays);
+        }
+
+        Set<Node> newNodes = new HashSet <Node>();
+        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: applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/AdjacentWaysAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/AdjacentWaysAction.java	(revision 25814)
+++ applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/AdjacentWaysAction.java	(revision 25814)
@@ -0,0 +1,74 @@
+// License: GPL. Copyright 2011 by Alexei Kasatkin
+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.LinkedHashSet;
+import java.util.Set;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.*;
+
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ *    Extends current selection
+ */
+class AdjacentWaysAction extends JosmAction {
+
+    public static final boolean treeMode = false;
+
+    public AdjacentWaysAction() {
+        super(tr("Adjacent ways"), "adjways",
+                tr("Adjacent ways will be selected. Nodes wiil be deselected."),
+                Shortcut.registerShortcut("tools:adjways", tr("Tool: {0}","Adjacent ways"),
+                KeyEvent.VK_E, Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true);
+        putValue("help", ht("/Action/AdjacentWays"));
+    }
+
+    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);
+
+        // select ways attached to already selected ways
+        Set<Way> newWays = new LinkedHashSet<Way>();
+        newWays.addAll(selectedWays);
+        for (Way w : selectedWays){
+            NodeWayUtils.addWaysConnectedToWay(w, newWays);
+        }
+
+        // selecting ways attached to selected nodes
+        if(!selectedNodes.isEmpty()) {
+            NodeWayUtils.addWaysConnectedToNodes(selectedNodes, newWays);
+        }
+
+//        System.out.printf("%d ways added to selection\n",newWays.size()-selectedWays.size());
+        getCurrentDataSet().setSelected(newWays);
+    }
+
+    @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: applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/ConnectedWaysAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/ConnectedWaysAction.java	(revision 25814)
+++ applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/ConnectedWaysAction.java	(revision 25814)
@@ -0,0 +1,69 @@
+// License: GPL. Copyright 2011 by Alexei Kasatkin
+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.LinkedHashSet;
+import java.util.Set;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.*;
+
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ *    Extends current selection by selecting nodes on all touched ways
+ */
+class ConnectedWaysAction extends JosmAction {
+
+    public ConnectedWaysAction() {
+        super(tr("All connected ways"), "adjwaysall", tr("Select all connected ways"),
+                Shortcut.registerShortcut("tools:adjwaysall", tr("Tool: {0}","All connected ways"),
+                KeyEvent.VK_E, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), true);
+        putValue("help", ht("/Action/SelectConnectedWays"));
+    }
+
+    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);
+
+        Set<Way> newWays = new LinkedHashSet<Way>();
+
+        // selecting ways attached to selected nodes
+        if(!selectedNodes.isEmpty()) {
+            NodeWayUtils.addWaysConnectedToNodes(selectedNodes, newWays);
+        }
+
+        // select ways attached to already selected ways
+        newWays.addAll(selectedWays);
+        NodeWayUtils.addWaysConnectedToWaysRecursively(selectedWays, newWays);
+        
+//        System.out.printf("%d ways added to selection\n",newWays.size()-selectedWays.size());
+        getCurrentDataSet().setSelected(newWays);
+
+    }
+
+    @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: applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/IntersectedWaysAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/IntersectedWaysAction.java	(revision 25814)
+++ applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/IntersectedWaysAction.java	(revision 25814)
@@ -0,0 +1,73 @@
+// License: GPL. Copyright 2011 by Alexei Kasatkin
+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.LinkedHashSet;
+import java.util.Set;
+import javax.swing.JOptionPane;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.*;
+
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ *    Extends current selection by selecting nodes on all touched ways
+ */
+class IntersectedWaysAction extends JosmAction {
+
+    public IntersectedWaysAction() {
+        super(tr("Intersecting ways"), "intway", tr("Select intersecting ways"),
+                Shortcut.registerShortcut("tools:intway", tr("Tool: {0}","Intersecting ways"),
+                KeyEvent.VK_I, Shortcut.GROUP_EDIT), true);
+        putValue("help", ht("/Action/SelectIntersectingWays"));
+    }
+
+    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);
+
+        // select ways attached to already selected ways
+        if (!selectedWays.isEmpty()) {
+            Set<Way> newWays = new LinkedHashSet<Way>();
+            NodeWayUtils.addWaysIntersectingWays(
+                    getCurrentDataSet().getWays(),
+                    selectedWays, newWays);
+            getCurrentDataSet().addSelected(newWays);
+            return;
+        } else {
+             JOptionPane.showMessageDialog(Main.parent,
+               tr("Please select some ways to find connected and intersecting ways!"),
+               tr("Warning"), JOptionPane.WARNING_MESSAGE);
+        }
+
+    }
+
+    @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: applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/IntersectedWaysRecursiveAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/IntersectedWaysRecursiveAction.java	(revision 25814)
+++ applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/IntersectedWaysRecursiveAction.java	(revision 25814)
@@ -0,0 +1,74 @@
+// License: GPL. Copyright 2011 by Alexei Kasatkin ond others
+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.LinkedHashSet;
+import java.util.Set;
+import javax.swing.JOptionPane;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.*;
+
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ *    Extends current selection by selecting nodes on all touched ways
+ */
+class IntersectedWaysRecursiveAction extends JosmAction {
+    
+    public IntersectedWaysRecursiveAction() {
+        super(tr("All intersecting ways"), "intwayall", tr("Select all intersecting ways"),
+                Shortcut.registerShortcut("tools:intwayall", tr("Tool: {0}","All intersecting ways"),
+                KeyEvent.VK_I, Shortcut.GROUP_MENU), true);
+        putValue("help", ht("/Action/SelectAllIntersectingWays"));
+
+    }
+
+    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 (!selectedWays.isEmpty()) {
+            Set<Way> newWays = new LinkedHashSet<Way>();
+            NodeWayUtils.addWaysIntersectingWaysRecursively(
+                    getCurrentDataSet().getWays(),
+                    selectedWays, newWays);
+            getCurrentDataSet().addSelected(newWays);
+            return;
+        } else {
+             JOptionPane.showMessageDialog(Main.parent,
+               tr("Please select some ways to find all connected and intersecting ways!"),
+               tr("Warning"), JOptionPane.WARNING_MESSAGE);
+        }
+
+    }
+
+
+    @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: applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/NodeWayUtils.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/NodeWayUtils.java	(revision 25814)
+++ applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/NodeWayUtils.java	(revision 25814)
@@ -0,0 +1,224 @@
+// License: GPL. Copyright 2011 by Alexei Kasatkin
+package utilsplugin2;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import javax.swing.JOptionPane;
+import org.openstreetmap.josm.Main;
+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;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+
+/**
+ * Class with some useful functions that are reused in extend selection actions
+ *
+ */
+public final class NodeWayUtils {
+
+    static final int maxLevel = Main.pref.getInteger("selection.maxrecursion", 5);
+    static final int maxWays = Main.pref.getInteger("selection.maxfoundways", 2000);
+    static final int maxWays1 = Main.pref.getInteger("selection.maxfoundwaysrec", 200);
+
+    /**
+     * 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 int addWaysConnectedToWay(Way w, Set<Way> ways) {
+         int s = ways.size();
+        List<Node> nodes = w.getNodes();
+        for (Node n: nodes) {
+            ways.addAll(OsmPrimitive.getFilteredList(n.getReferrers(), Way.class));
+        }
+        return ways.size() - s;
+    }
+
+    /**
+     * 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 int addWaysConnectedToNode(Node n, Set<Way> ways) {
+        int s = ways.size();
+        ways.addAll(OsmPrimitive.getFilteredList(n.getReferrers(), Way.class));
+        return ways.size() - s;
+    }
+
+    /**
+     * 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 int addWaysIntersectingWay(Collection<Way> ways, Way w, Set<Way> newWays,Set<Way> excludeWays) {
+        List<Pair<Node, Node>> nodePairs = w.getNodePairs(false);
+        int count=0;
+        for (Way anyway: ways) {
+            if (anyway == w) continue;
+            if (newWays.contains(anyway) || excludeWays.contains(anyway) ) continue;
+
+            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);
+                            count++;
+                            break loop;
+                    }
+                }
+            }
+        }
+        return count;
+    }
+
+
+        static int addWaysIntersectingWay(Collection<Way> ways, Way w, Set<Way> newWays) {
+        List<Pair<Node, Node>> nodePairs = w.getNodePairs(false);
+        int count=0;
+        for (Way anyway: ways) {
+            if (anyway == w) continue;
+            if (newWays.contains(anyway)) continue;
+            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);
+                            count++;
+                            break loop;
+                    }
+                }
+            }
+        }
+        return count;
+    }
+
+    /**
+     * 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 int addWaysIntersectingWays(Collection<Way> allWays, Collection<Way> initWays, Set<Way> newWays) {
+        int count=0;
+        for (Way w : initWays){
+            count+=addWaysIntersectingWay(allWays, w, newWays);
+        }
+        return count;
+    }
+
+    static int addWaysConnectedToNodes(Set<Node> selectedNodes, Set<Way> newWays) {
+        int s = newWays.size();
+        for (Node node: selectedNodes) {
+            addWaysConnectedToNode(node, newWays);
+        }
+        return newWays.size() - s;
+    }
+
+    static int addNodesConnectedToWays(Set<Way> initWays, Set<Node> newNodes) {
+        int s = newNodes.size();
+        for (Way w: initWays) {
+                newNodes.addAll(w.getNodes());
+        }
+        return newNodes.size()-s;
+    }
+
+    static void addWaysIntersectingWaysRecursively
+            (Collection<Way> allWays, Collection<Way> initWays, Set<Way> newWays)
+    {
+            Set<Way> foundWays = new LinkedHashSet<Way>();
+            foundWays.addAll(initWays);
+            newWays.addAll(initWays);
+            Set<Way> newFoundWays = new LinkedHashSet<Way>();
+
+            int level=0,c;
+            do {
+                 c=0;
+                 newFoundWays = new LinkedHashSet<Way>();
+                 for (Way w : foundWays){
+                      c+=addWaysIntersectingWay(allWays, w, newFoundWays,newWays);
+                 }
+                 foundWays = newFoundWays;
+                 newWays.addAll(newFoundWays);
+                 level++;
+//                 System.out.printf("%d: %d ways added to selection intersectiong\n",level,c);
+                 if (c>maxWays1) {
+                       JOptionPane.showMessageDialog(Main.parent,
+                                tr("Too many ways are added: {0}!",c),
+                                        tr("Warning"),
+                                        JOptionPane.WARNING_MESSAGE);
+                       return;
+                 }
+            } while ( c >0 && level < maxLevel );
+            return;
+    }
+
+ static void addWaysConnectedToWaysRecursively
+            (Collection<Way> initWays, Set<Way> newWays)
+    {
+            int level=0,c;
+            newWays.addAll(initWays);
+            do {
+                 c=0;
+                 Set<Way> foundWays = new LinkedHashSet<Way>();
+                 foundWays.addAll(newWays);
+                 for (Way w : foundWays){
+                      c+=addWaysConnectedToWay(w, newWays);
+                 }
+                 level++;
+//                 System.out.printf("%d: %d ways added to selection\n",level,c);
+                 if (c>maxWays) {
+                       JOptionPane.showMessageDialog(Main.parent,
+                                tr("Too many ways are added: {0}!",c),
+                                        tr("Warning"),
+                                        JOptionPane.WARNING_MESSAGE);
+                       return;
+                 }
+            } while ( c >0 && level < maxLevel );
+            return;
+    }
+
+
+
+}
Index: applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java	(revision 25190)
+++ applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java	(revision 25814)
@@ -2,4 +2,6 @@
 package utilsplugin2;
 
+import java.awt.event.KeyEvent;
+import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 
@@ -9,4 +11,5 @@
 import org.openstreetmap.josm.plugins.Plugin;
 import org.openstreetmap.josm.plugins.PluginInformation;
+import static org.openstreetmap.josm.tools.I18n.marktr;
 
 public class UtilsPlugin2 extends Plugin {
@@ -15,4 +18,9 @@
     JMenuItem splitObject;
     JMenuItem selectWayNodes;
+    JMenuItem adjNodes;
+    JMenuItem adjWays;
+    JMenuItem adjWaysAll;
+    JMenuItem intWays;
+    JMenuItem intWaysR;
 
     public UtilsPlugin2(PluginInformation info) {
@@ -22,5 +30,13 @@
         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());
+        Main.main.menu.toolsMenu.addSeparator();
+        JMenu m1 = Main.main.menu.addMenu(marktr("Selection"), KeyEvent.VK_S, Main.main.menu.defaultMenuPos, "help");
+
+        selectWayNodes = MainMenu.add(m1, new SelectWayNodesAction());
+        adjNodes = MainMenu.add(m1, new AdjacentNodesAction());
+        adjWays = MainMenu.add(m1, new AdjacentWaysAction());
+        adjWaysAll = MainMenu.add(m1, new ConnectedWaysAction());
+        intWays = MainMenu.add(m1, new IntersectedWaysAction());
+        intWaysR = MainMenu.add(m1, new IntersectedWaysRecursiveAction());
     }
 
@@ -28,8 +44,14 @@
     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
         boolean enabled = newFrame != null;
+        enabled = false;
         unglueRelation.setEnabled(enabled);
         addIntersections.setEnabled(enabled);
         splitObject.setEnabled(enabled);
         selectWayNodes.setEnabled(enabled);
+        adjNodes.setEnabled(enabled);
+        adjWays.setEnabled(enabled);
+        adjWaysAll.setEnabled(enabled);
+        intWays.setEnabled(enabled);
+        intWaysR.setEnabled(enabled);
     }
 }
