Index: applications/editors/josm/plugins/utilsplugin2/build.xml
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/build.xml	(revision 30197)
+++ applications/editors/josm/plugins/utilsplugin2/build.xml	(revision 30200)
@@ -3,5 +3,5 @@
 
     <!-- enter the SVN commit message -->
-    <property name="commit.message" value="[josm_utilsplugin2]: Use notifications instead of MessageBoxes"/>
+    <property name="commit.message" value="[josm_utilsplugin2]: move search classes to separate package, inside now finds both node and ways"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
     <property name="plugin.main.version" value="6317"/>
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/UtilsPlugin2.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/UtilsPlugin2.java	(revision 30197)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/UtilsPlugin2.java	(revision 30200)
@@ -2,8 +2,4 @@
 package org.openstreetmap.josm.plugins.utilsplugin2;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
 
 import javax.swing.JMenu;
@@ -11,14 +7,5 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.search.PushbackTokenizer;
 import org.openstreetmap.josm.actions.search.SearchCompiler;
-import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
-import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
-import org.openstreetmap.josm.actions.search.SearchCompiler.UnaryMatch;
-import org.openstreetmap.josm.actions.search.SearchCompiler.UnaryMatchFactory;
-import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Relation;
-import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.MainMenu;
 import org.openstreetmap.josm.gui.MapFrame;
@@ -42,4 +29,5 @@
 import org.openstreetmap.josm.plugins.utilsplugin2.latlon.LatLonAction;
 import org.openstreetmap.josm.plugins.utilsplugin2.replacegeometry.ReplaceGeometryAction;
+import org.openstreetmap.josm.plugins.utilsplugin2.search.UtilsUnaryMatchFactory;
 import org.openstreetmap.josm.plugins.utilsplugin2.selection.AdjacentNodesAction;
 import org.openstreetmap.josm.plugins.utilsplugin2.selection.AdjacentWaysAction;
@@ -48,5 +36,4 @@
 import org.openstreetmap.josm.plugins.utilsplugin2.selection.IntersectedWaysRecursiveAction;
 import org.openstreetmap.josm.plugins.utilsplugin2.selection.MiddleNodesAction;
-import org.openstreetmap.josm.plugins.utilsplugin2.selection.NodeWayUtils;
 import org.openstreetmap.josm.plugins.utilsplugin2.selection.SelectAllInsideAction;
 import org.openstreetmap.josm.plugins.utilsplugin2.selection.SelectBoundaryAction;
@@ -175,160 +162,5 @@
     }
     
-    public static class UtilsUnaryMatchFactory implements UnaryMatchFactory {
-        private static Collection<String> keywords = Arrays.asList("inside",
-                "intersecting", "allintersecting", "adjacent", "connected");
-        
-        @Override
-        public UnaryMatch get(String keyword, Match matchOperand, PushbackTokenizer tokenizer) throws ParseError {
-            if ("inside".equals(keyword))
-                return new InsideMatch(matchOperand);
-            else if ("adjacent".equals(keyword))
-                return new ConnectedMatch(matchOperand, false);
-            else if ("connected".equals(keyword))
-                return new ConnectedMatch(matchOperand, true);
-            else if ("intersecting".equals(keyword))
-                return new IntersectingMatch(matchOperand, false);
-            else if ("allintersecting".equals(keyword))
-                return new IntersectingMatch(matchOperand, true);
-            return null;
-        }
-
-        @Override
-        public Collection<String> getKeywords() {
-            return keywords;
-        }
-    }
-
-    /**
-     * Matches all objects contained within the match expression.
-     */
-    public static class InsideMatch extends UnaryMatch {
-        private Collection<OsmPrimitive> inside = null;
-        
-        public InsideMatch(Match match) {
-            super(match);
-        }
-        
-        /**
-         * Find all objects inside areas which match the expression
-         */
-        private void init() {
-            Collection<OsmPrimitive> matchedAreas = new HashSet<OsmPrimitive>();
-
-            // find all ways that match the expression
-            Collection<Way> ways = Main.main.getCurrentDataSet().getWays();
-            for (Way way : ways) {
-                if (match.match(way))
-                    matchedAreas.add(way);
-            }
-            
-            // find all relations that match the expression
-            Collection<Relation> rels = Main.main.getCurrentDataSet().getRelations();
-            for (Relation rel : rels) {
-                if (match.match(rel))
-                    matchedAreas.add(rel);
-            }
-            
-            inside = NodeWayUtils.selectAllInside(matchedAreas, Main.main.getCurrentDataSet());
-        }
-
-        @Override
-        public boolean match(OsmPrimitive osm) {
-            if (inside == null)
-                init(); // lazy initialization
-
-            return inside.contains(osm);
-        }
-    }
-    
-    public static class IntersectingMatch extends UnaryMatch {
-        private Collection<Way> intersecting = null;
-        boolean all;
-        
-        public IntersectingMatch(Match match, boolean all) {
-            super(match);
-            this.all=all;
-            //init(all);
-        }   
-        
-        /**
-         * Find (all) ways intersecting ways which match the expression.
-         */
-        private void init(boolean all) {
-            Collection<Way> matchedWays = new HashSet<Way>();
-            
-            // find all ways that match the expression
-            Collection<Way> allWays = Main.main.getCurrentDataSet().getWays();
-            for (Way way : allWays) {
-                if (match.match(way))
-                    matchedWays.add(way);
-            }
-            
-            Set<Way> newWays = new HashSet<Way>();
-            if (all)
-                NodeWayUtils.addWaysIntersectingWaysRecursively(allWays, matchedWays, newWays);
-            else
-                NodeWayUtils.addWaysIntersectingWays(allWays, matchedWays, newWays);
-            intersecting = newWays;
-        }
-        
-        @Override
-        public boolean match(OsmPrimitive osm) {
-            if (intersecting==null) init(all); // lazy initialization
-            if (osm instanceof Way)
-                return intersecting.contains((Way)osm);
-            return false;
-        }
-    }
-    
-    public static class ConnectedMatch extends UnaryMatch {
-        private Collection<Way> connected = null;
-        boolean all;
-        
-        public ConnectedMatch(Match match, boolean all) {
-            super(match);
-            this.all=all;
-        }   
-        
-        /**
-         * Find (all) ways intersecting ways which match the expression.
-         */
-        private void init(boolean all) {
-            Collection<Way> matchedWays = new HashSet<Way>();
-            Set<Node> matchedNodes = new HashSet<Node>();
-            
-            // find all ways that match the expression
-            Collection<Way> allWays = Main.main.getCurrentDataSet().getWays();
-            for (Way way : allWays) {
-                if (match.match(way))
-                    matchedWays.add(way);
-            }
-            
-            // find all nodes that match the expression
-            Collection<Node> allNodes = Main.main.getCurrentDataSet().getNodes();
-            for (Node node: allNodes) {
-                if (match.match(node))
-                    matchedNodes.add(node);
-            }
-            
-            Set<Way> newWays = new HashSet<Way>();
-            if (all) {
-                NodeWayUtils.addWaysConnectedToNodes(matchedNodes, newWays);
-                NodeWayUtils.addWaysConnectedToWaysRecursively(matchedWays, newWays);
-            } else {
-                NodeWayUtils.addWaysConnectedToNodes(matchedNodes, newWays);
-                NodeWayUtils.addWaysConnectedToWays(matchedWays, newWays);
-            }
-            connected = newWays;
-        }
-        
-        @Override
-        public boolean match(OsmPrimitive osm) {
-            if (connected==null) init(all); // lazy initialization
-            if (osm instanceof Way)
-                return connected.contains((Way)osm);
-            return false;
-        }
-    }   
+       
     
 }
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/NodeWayUtils.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/NodeWayUtils.java	(revision 30197)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/NodeWayUtils.java	(revision 30200)
@@ -408,8 +408,4 @@
                 newestWays.add(w);
             }
-        }
-        for (Way w : newestWays) {
-            newestNodes.removeAll(w.getNodes());
-            // do not select nodes of already selected ways
         }
         
@@ -474,4 +470,8 @@
     
     public static Collection<OsmPrimitive> selectAllInside(Collection<OsmPrimitive> selected, DataSet dataset) {
+        return selectAllInside(selected, dataset, true);
+    }
+    
+    public static Collection<OsmPrimitive> selectAllInside(Collection<OsmPrimitive> selected, DataSet dataset, boolean ignoreNodesOfFoundWays) {
         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(selected, Way.class);
         Set<Relation> selectedRels = OsmPrimitive.getFilteredSet(selected, Relation.class);
@@ -486,5 +486,5 @@
         Set<Way> newWays = new HashSet<Way>();
         Set<Node> newNodes = new HashSet<Node>();
-        // select ways attached to already selected ways
+        // select nodes and ways inside slexcted ways and multipolygons
         if (!selectedWays.isEmpty()) {
             for (Way w: selectedWays) {
@@ -496,4 +496,10 @@
                 addAllInsideMultipolygon(dataset,r,newWays,newNodes);
             }
+        }
+        if (ignoreNodesOfFoundWays) {
+            for (Way w : newWays) {
+                newNodes.removeAll(w.getNodes());
+                // do not select nodes of already selected ways
+            }            
         }
         
Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java	(revision 30197)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java	(revision 30200)
@@ -32,5 +32,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> insideSelected = NodeWayUtils.selectAllInside(getCurrentDataSet().getSelected(), getCurrentDataSet());
+        Collection<OsmPrimitive> insideSelected = NodeWayUtils.selectAllInside(getCurrentDataSet().getSelected(), getCurrentDataSet(), true);
         
         if (!insideSelected.isEmpty()) {
