Index: /applications/editors/josm/plugins/tag2link/build.xml
===================================================================
--- /applications/editors/josm/plugins/tag2link/build.xml	(revision 26921)
+++ /applications/editors/josm/plugins/tag2link/build.xml	(revision 26922)
@@ -32,5 +32,5 @@
     <property name="commit.message" value="Commit message"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
-    <property name="plugin.main.version" value="4487"/>
+    <property name="plugin.main.version" value="4536"/>
     <!-- should not be necessary to change the following properties -->
     <property name="josm" location="../../core/dist/josm-custom.jar"/>
@@ -99,6 +99,5 @@
                 <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.tag2link.Tag2LinkPlugin"/>
                 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
-                <attribute name="Plugin-Description" value="TODO"/>
-                <attribute name="fr_Plugin-Description" value="TODO"/>
+                <attribute name="Plugin-Description" value="Launch browser to a Web resource about a selected object having known tags, such as Wikipedia"/>
                 <attribute name="Plugin-Early" value="false"/>
                 <attribute name="Plugin-Icon" value="images/tag2linkv2_24x24.png"/>
Index: /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPlugin.java
===================================================================
--- /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPlugin.java	(revision 26921)
+++ /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPlugin.java	(revision 26922)
@@ -28,7 +28,7 @@
  * Main class of tag2links plugin.
  * @author Don-vip
- * @version 1.0
+ * @version 0.1
  * History:
- * 1.0 ??-Oct-2011 first version
+ * 0.1 22-Oct-2011 first working prototype
  */
 public class Tag2LinkPlugin extends Plugin {
Index: /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPreferenceSetting.java
===================================================================
--- /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPreferenceSetting.java	(revision 26921)
+++ /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPreferenceSetting.java	(revision 26922)
@@ -16,8 +16,4 @@
 package org.openstreetmap.josm.plugins.tag2link;
 
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import javax.swing.JPanel;
-
 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
@@ -27,6 +23,6 @@
     @Override
     public void addGui(PreferenceTabbedPane gui) {
-        JPanel p = gui.createPreferenceTab(ICON_48, tr("Tag2Link Preferences"),
-                tr("Tag2Link Preferences"), false);
+        /*JPanel p = gui.createPreferenceTab(ICON_48, tr("Tag2Link Preferences"),
+                tr("Tag2Link Preferences"), false);*/
         // TODO
     }
Index: /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkRuleChecker.java
===================================================================
--- /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkRuleChecker.java	(revision 26921)
+++ /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkRuleChecker.java	(revision 26922)
@@ -24,4 +24,5 @@
 
 import org.openstreetmap.josm.data.osm.IPrimitive;
+import org.openstreetmap.josm.data.osm.Tag;
 import org.openstreetmap.josm.plugins.tag2link.data.Link;
 import org.openstreetmap.josm.plugins.tag2link.data.Rule;
@@ -53,52 +54,67 @@
     }
     
+    private static Collection<Link> processEval(EvalResult eval, Rule rule, Source source) {
+    	Collection<Link> result = new ArrayList<Link>();
+        if (eval.matches()) {
+            for (Link link : rule.links) {
+            	Link copy = new Link(link);
+            	copy.name = copy.name.replaceAll("%name%", source.name);
+				Matcher m = Pattern.compile("%([^%]*)%").matcher(copy.url);
+				while (m.find()) {
+					String arg = m.group(1);
+					String val = findValue(arg, eval.matchingTags);
+					if (val == null && arg.contains(":")) {
+						String[] vars = arg.split(":");
+						for (int i = 0; val == null && i < vars.length-1; i++) {
+							val = findValue(vars[i], eval.matchingTags);
+						}
+						if (val == null) {
+							// Default value
+							val = vars[vars.length-1];
+						}
+					}
+					if (val != null) {
+						try {
+							// Special hack for Wikipedia that prevents spaces being replaced by "+" characters, but by "_"
+							if (copy.url.contains("wikipedia.")) {
+								val = val.replaceAll(" ", "_");
+							}
+							// Encode param to be included in the URL, except if it is the URL itself !
+							if (!m.group().equals(copy.url)) {
+								val = URLEncoder.encode(val, UTF8_ENCODING);
+							}
+							// Finally replace parameter
+							copy.url = copy.url.replaceFirst(m.group(), val);
+						} catch (UnsupportedEncodingException e) {
+							e.printStackTrace();
+						}
+					} else {
+						System.err.println("Invalid argument: "+arg);
+					}
+				}
+            	result.add(copy);
+            }
+        }
+        return result;
+    }
+    
     public static Collection<Link> getLinks(IPrimitive p) {
         Collection<Link> result = new ArrayList<Link>();
         for (Source source : sources) {
             for (Rule rule : source.rules) {
-                EvalResult eval = rule.evaluates(p);
-                if (eval.matches()) {
-                    for (Link link : rule.links) {
-                    	Link copy = new Link(link);
-                    	copy.name = copy.name.replaceAll("%name%", source.name);
-						Matcher m = Pattern.compile("%([^%]*)%").matcher(copy.url);
-						while (m.find()) {
-							String arg = m.group(1);
-							String val = findValue(arg, eval.matchingTags);
-							if (val == null && arg.contains(":")) {
-								String[] vars = arg.split(":");
-								for (int i = 0; val == null && i < vars.length-1; i++) {
-									val = findValue(vars[i], eval.matchingTags);
-								}
-								if (val == null) {
-									// Default value
-									val = vars[vars.length-1];
-								}
-							}
-							if (val != null) {
-								try {
-									// Special hack for Wikipedia that prevents spaces being replaced by "+" characters, but by "_"
-									if (copy.url.contains("wikipedia.")) {
-										val = val.replaceAll(" ", "_");
-									}
-									// Encode param to be included in the URL, except if it is the URL itself !
-									if (!m.group().equals(copy.url)) {
-										val = URLEncoder.encode(val, UTF8_ENCODING);
-									}
-									// Finally replace parameter
-									copy.url = copy.url.replaceFirst(m.group(), val);
-								} catch (UnsupportedEncodingException e) {
-									e.printStackTrace();
-								}
-							} else {
-								System.err.println("Invalid argument: "+arg);
-							}
-						}
-                    	result.add(copy);
-                    }
-                }
+                result.addAll(processEval(rule.evaluates(p), rule, source));
             }
         }
         return result;
     }
+
+	public static Collection<Link> getLinks(Tag tag) {
+		Collection<Link> result = new ArrayList<Link>();
+        for (Source source : sources) {
+            for (Rule rule : source.rules) {
+                result.addAll(processEval(rule.evaluates(tag), rule, source));
+            }
+        }
+		return result;
+	}
 }
Index: /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Rule.java
===================================================================
--- /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Rule.java	(revision 26921)
+++ /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Rule.java	(revision 26922)
@@ -8,4 +8,5 @@
 
 import org.openstreetmap.josm.data.osm.IPrimitive;
+import org.openstreetmap.josm.data.osm.Tag;
 
 public class Rule {
@@ -47,7 +48,6 @@
     }
     
-    public EvalResult evaluates(IPrimitive p) {
+    public EvalResult evaluates(Map<String, String> tags) {
         EvalResult result = new EvalResult();
-        Map<String, String> tags = p.getKeys();
         for (Condition c : conditions) {
             for (String key : tags.keySet()) {
@@ -73,4 +73,15 @@
         }
         return result;
+
     }
+    
+    public EvalResult evaluates(IPrimitive p) {
+    	return evaluates(p.getKeys());
+    }
+
+	public EvalResult evaluates(Tag tag) {
+		Map<String, String> map = new HashMap<String, String>();
+		map.put(tag.getKey(), tag.getValue());
+		return evaluates(map);
+	}
 }
Index: /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/listeners/MembershipPopupListener.java
===================================================================
--- /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/listeners/MembershipPopupListener.java	(revision 26921)
+++ /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/listeners/MembershipPopupListener.java	(revision 26922)
@@ -27,5 +27,5 @@
     @Override
     protected IPrimitive getFirstSelectedPrimitive() {
-        return frame.propertiesDialog.getSelectedMembershipRelations().iterator().next();
+        return frame.propertiesDialog.getSelectedMembershipRelation();
     }
 }
Index: /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/listeners/PropertyPopupListener.java
===================================================================
--- /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/listeners/PropertyPopupListener.java	(revision 26921)
+++ /applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/listeners/PropertyPopupListener.java	(revision 26922)
@@ -16,7 +16,11 @@
 package org.openstreetmap.josm.plugins.tag2link.listeners;
 
+import javax.swing.JPopupMenu;
 import javax.swing.event.PopupMenuEvent;
 
+import org.openstreetmap.josm.data.osm.Tag;
 import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.plugins.tag2link.Tag2LinkRuleChecker;
+import org.openstreetmap.josm.plugins.tag2link.data.Link;
 
 public class PropertyPopupListener extends AbstractPopupListener {
@@ -24,12 +28,15 @@
     public PropertyPopupListener(MapFrame frame) {
         super(frame);
-        // TODO Auto-generated constructor stub
     }
 
     @Override
     public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
-        // TODO Auto-generated method stub
-
+        Tag tag = frame.propertiesDialog.getSelectedProperty();
+        if (tag != null) {
+            JPopupMenu popup = (JPopupMenu) e.getSource();
+            for (Link link : Tag2LinkRuleChecker.getLinks(tag)) {
+                addLink(popup, link);
+            }
+        }
     }
-
 }
