Index: /applications/editors/josm/plugins/utilsplugin2/build.xml
===================================================================
--- /applications/editors/josm/plugins/utilsplugin2/build.xml	(revision 26643)
+++ /applications/editors/josm/plugins/utilsplugin2/build.xml	(revision 26644)
@@ -30,5 +30,5 @@
 <project name="utilsplugin2" default="dist" basedir=".">
     <!-- enter the SVN commit message -->
-    <property name="commit.message" value="Utilsplugin2: configuring custom URLs"/>
+    <property name="commit.message" value="Utilsplugin2: select all inside (testing)"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
     <property name="plugin.main.version" value="4395"/>
Index: /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/ChooseURLAction.java
===================================================================
--- /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/ChooseURLAction.java	(revision 26644)
+++ /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/ChooseURLAction.java	(revision 26644)
@@ -0,0 +1,96 @@
+package utilsplugin2;
+
+import java.awt.GridBagLayout;
+import java.awt.event.ItemEvent;
+import java.util.List;
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.tools.GBC;
+import org.openstreetmap.josm.Main;
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemListener;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import org.openstreetmap.josm.actions.JosmAction;
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+public class ChooseURLAction extends JosmAction {
+
+    public ChooseURLAction() {
+        super(tr("Select custom URL"), "selecturl", tr("Select custom URL"),null,true,true);
+         putValue("toolbar", "action/selectURL");
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+       showConfigDialog();
+    }
+
+    @Override
+    protected void updateEnabledState() {
+        if (getCurrentDataSet() == null) {
+            setEnabled(false);
+        } else {
+            setEnabled(true);
+        }
+    }
+        
+    public static void showConfigDialog() {
+        JPanel all = new JPanel();
+        GridBagLayout layout = new GridBagLayout();
+        all.setLayout(layout);
+        
+        List<String> items = (List<String>) Main.pref.getCollection("utilsplugin2.urlHistory");
+        int n=items.size()/2 , idxToSelect=-1;
+        final String names[] =new String[n];
+        final String vals[] =new String[n];
+        String addr = Main.pref.get("utilsplugin2.customurl");
+        for (int i=0;i<n;i++) {
+            names[i]=items.get(i*2);
+            vals[i]=items.get(i*2+1);
+            if (vals[i].equals(addr)) idxToSelect=i; 
+        }
+        final JLabel label1=new JLabel(tr("Please select one of custom URLs (configured in Preferences)"));
+        final JComboBox combo1=new JComboBox(names);
+        final JTextField editField=new JTextField();
+        final JCheckBox check1=new JCheckBox(tr("Ask every time"));
+        
+        
+        combo1.addItemListener(new ItemListener() {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
+                int idx=combo1.getSelectedIndex();
+                if (idx>=0) editField.setText(vals[idx]);
+            }
+        });
+        combo1.setSelectedIndex(idxToSelect);
+        check1.setSelected(Main.pref.getBoolean("utilsplugin2.askurl",false));
+        
+        editField.setEditable(false);
+        
+        all.add(label1,GBC.eop().fill(GBC.HORIZONTAL).insets(15,5,15,0));
+        all.add(combo1,GBC.eop().fill(GBC.HORIZONTAL).insets(5,5,0,0));
+        all.add(editField,GBC.eop().fill(GBC.HORIZONTAL).insets(5,5,0,0));
+        all.add(check1,GBC.eop().fill(GBC.HORIZONTAL).insets(5,5,0,0));
+        
+        ExtendedDialog dialog = new ExtendedDialog(Main.parent,
+                tr("Configure custom URL"),
+                new String[] {tr("OK"),tr("Cancel"),}
+        );
+        dialog.setContent(all, false);
+        dialog.setButtonIcons(new String[] {"ok.png","cancel.png",});
+        dialog.setDefaultButton(1);
+        dialog.showDialog();
+        
+        int idx = combo1.getSelectedIndex();
+        if (dialog.getValue() ==1 && idx>=0) {
+           Main.pref.put("utilsplugin2.customurl", vals[idx]);
+           Main.pref.put("utilsplugin2.askurl", check1.isSelected());
+        }
+    }
+
+    
+    
+}
Index: /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java
===================================================================
--- /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java	(revision 26643)
+++ /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java	(revision 26644)
@@ -30,4 +30,5 @@
     JMenuItem intWays;
     JMenuItem intWaysR;
+    JMenuItem allInside;
     JMenuItem undoSelection;
     JMenuItem extractPoint;
@@ -73,4 +74,5 @@
         intWays = MainMenu.add(selectionMenu, new IntersectedWaysAction());
         intWaysR = MainMenu.add(selectionMenu, new IntersectedWaysRecursiveAction());
+        allInside = MainMenu.add(selectionMenu, new SelectAllInsideAction());
         selModifiedNodes = MainMenu.add(selectionMenu, new SelectModNodesAction());
         selModifiedWays = MainMenu.add(selectionMenu, new SelectModWaysAction());
@@ -110,4 +112,5 @@
         undoSelection.setEnabled(enabled);
         selectURL.setEnabled(enabled);
+        allInside.setEnabled(enabled);
     }
     @Override
Index: /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysAction.java
===================================================================
--- /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysAction.java	(revision 26643)
+++ /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysAction.java	(revision 26644)
@@ -30,8 +30,4 @@
 
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
-        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
-        Set<Way> activeWays = new HashSet<Way>();
-
         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
 
Index: /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysRecursiveAction.java
===================================================================
--- /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysRecursiveAction.java	(revision 26643)
+++ /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysRecursiveAction.java	(revision 26644)
@@ -32,7 +32,5 @@
     public void actionPerformed(ActionEvent e) {
         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
-        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
-        Set<Way> activeWays = new HashSet<Way>();
-
+        
         Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
 
Index: /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java
===================================================================
--- /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java	(revision 26643)
+++ /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java	(revision 26644)
@@ -9,4 +9,6 @@
 import javax.swing.JOptionPane;
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.BBox;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -263,4 +265,32 @@
     }
 
-
+    
+
+    static void addAllInsideWay(DataSet data, Way way, Set<Way> newWays, Set<Node> newNodes) {
+        if (!way.isClosed()) return;
+        BBox box = way.getBBox();
+        List<Node> polyNodes = way.getNodes();
+        List<Node> searchNodes = data.searchNodes(box);
+        Set<Node> newestNodes = new HashSet<Node>();
+        Set<Way> newestWays = new HashSet<Way>();
+        for (Node n : searchNodes) {
+            if (Geometry.nodeInsidePolygon(n, polyNodes)) {
+                newestNodes.add(n);
+            }
+        }
+        
+        List<Way> searchWays = data.searchWays(box);
+        for (Way w : searchWays) {
+            if (newestNodes.containsAll(w.getNodes())) {
+                newestWays.add(w);
+            }
+        }
+        for (Way w : newestWays) {
+            newestNodes.removeAll(w.getNodes());
+            // do not select nodes of already selected ways
+        }
+        
+        newNodes.addAll(newestNodes);
+        newWays.addAll(newestWays);
+    }
 }
Index: /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java
===================================================================
--- /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java	(revision 26644)
+++ /applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java	(revision 26644)
@@ -0,0 +1,75 @@
+// License: GPL. Copyright 2011 by Alexei Kasatkin
+package utilsplugin2.selection;
+
+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.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
+ */
+public class SelectAllInsideAction extends JosmAction {
+
+    public SelectAllInsideAction() {
+        super(tr("All inside [testing]"), "selinside", tr("Select all inside selected polygons"),
+                Shortcut.registerShortcut("tools:selinside", tr("Tool: {0}","All inside"),
+                KeyEvent.VK_I, Shortcut.GROUP_EDIT ,KeyEvent.ALT_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK), true);
+        putValue("help", ht("/Action/SelectAllInside"));
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
+        Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
+        Set<Way> activeWays = new HashSet<Way>();
+
+        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
+
+        // select ways attached to already selected ways
+        if (!selectedWays.isEmpty()) {
+            Set<Way> newWays = new HashSet<Way>();
+            Set<Node> newNodes = new HashSet<Node>();
+            for (Way w: selectedWays) {
+                NodeWayUtils.addAllInsideWay(getCurrentDataSet(),w,newWays,newNodes);
+            }
+            getCurrentDataSet().addSelected(newWays);
+            getCurrentDataSet().addSelected(newNodes);
+            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());
+    }
+
+
+}
