Index: /trunk/src/org/openstreetmap/josm/actions/OsmPrimitiveAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/OsmPrimitiveAction.java	(revision 5821)
+++ /trunk/src/org/openstreetmap/josm/actions/OsmPrimitiveAction.java	(revision 5821)
@@ -0,0 +1,21 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import java.util.Collection;
+
+import javax.swing.Action;
+
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+
+/**
+ * Interface used to enable/disable all primitive-related actions, even those registered by plugins.
+ * @since 5821
+ */
+public interface OsmPrimitiveAction extends Action {
+
+    /**
+     * Specifies the working set of primitives.
+     * @param primitives The new working set of primitives. Can be null or empty
+     */
+    public abstract void setPrimitives(Collection<? extends OsmPrimitive> primitives);
+}
Index: /trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java	(revision 5820)
+++ /trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java	(revision 5821)
@@ -7,5 +7,8 @@
 import javax.swing.AbstractAction;
 
+import org.openstreetmap.josm.actions.OsmPrimitiveAction;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.tools.SubclassFilteredCollection;
 
 /**
@@ -14,17 +17,22 @@
  * @since 5793
  */
-public abstract class AbstractRelationAction extends AbstractAction {
+public abstract class AbstractRelationAction extends AbstractAction implements OsmPrimitiveAction {
     protected Collection<Relation> relations = Collections.<Relation>emptySet();
 
-    /**
-     * Specifies the working set of relations.
-     * @param relations The new working set of relations. Can be null or empty
+    protected static final Collection<Relation> getRelations(Collection<? extends OsmPrimitive> primitives) {
+        if (primitives == null || primitives.isEmpty()) {
+            return Collections.<Relation>emptySet();
+        } else {
+            return new SubclassFilteredCollection<OsmPrimitive, Relation>(
+                    primitives, OsmPrimitive.relationPredicate);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.openstreetmap.josm.actions.relation.RelationAction#setPrimitives
      */
-    public void setRelations(Collection<Relation> relations) {
-        if (relations==null) {
-            this.relations = Collections.<Relation>emptySet();
-        } else {
-            this.relations = relations;
-        }
+    @Override
+    public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
+        this.relations = getRelations(primitives);
         updateEnabledState();
     }
Index: /trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java	(revision 5820)
+++ /trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java	(revision 5821)
@@ -6,12 +6,17 @@
 
 import java.awt.event.ActionEvent;
+import java.util.Collection;
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.Predicate;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
  * The action for downloading members of relations
-
+ * @since 5793
  */
 public class DownloadMembersAction extends AbstractRelationAction {
@@ -32,3 +37,13 @@
         Main.worker.submit(new DownloadRelationTask(relations, Main.map.mapView.getEditLayer()));
     }
+
+    @Override
+    public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
+        // selected non-new relations
+        this.relations = Utils.filter(getRelations(primitives), new Predicate<Relation>(){
+            @Override public boolean evaluate(Relation r) {
+                return !r.isNew();
+            }});
+        updateEnabledState();
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java	(revision 5820)
+++ /trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java	(revision 5821)
@@ -14,4 +14,6 @@
 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.Predicate;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -51,3 +53,13 @@
                 Main.map.mapView.getEditLayer()));
     }
+
+    @Override
+    public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
+        // selected relations with incomplete members
+        this.relations = Utils.filter(getRelations(primitives), new Predicate<Relation>(){
+            @Override public boolean evaluate(Relation r) {
+                return !r.isNew() && r.hasIncompleteMembers();
+            }});
+        updateEnabledState();
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java	(revision 5820)
+++ /trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java	(revision 5821)
@@ -17,4 +17,8 @@
  */
 public class DuplicateRelationAction extends AbstractRelationAction {
+    
+    /**
+     * Constructs a new {@code DuplicateRelationAction}. 
+     */
     public DuplicateRelationAction() {
         putValue(SHORT_DESCRIPTION, tr("Create a copy of this relation and open it in another editor window"));
Index: /trunk/src/org/openstreetmap/josm/gui/PopupMenuHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/PopupMenuHandler.java	(revision 5821)
+++ /trunk/src/org/openstreetmap/josm/gui/PopupMenuHandler.java	(revision 5821)
@@ -0,0 +1,125 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.swing.Action;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.MenuElement;
+import javax.swing.event.PopupMenuListener;
+
+import org.openstreetmap.josm.actions.OsmPrimitiveAction;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+
+/**
+ * Handler to ease management of actions in different popup menus.
+ * @since 5821
+ */
+public class PopupMenuHandler {
+
+    // Set of enabled osm primitives actions
+    private final Set<OsmPrimitiveAction> primitiveActions = new HashSet<OsmPrimitiveAction>();
+    // Managed menu
+    private final JPopupMenu menu;
+    
+    /**
+     * Constructs a new {@code RelationActionMenuHandler} for the specified popup menu.
+     * 
+     * @param menu The menu to be managed
+     */
+    public PopupMenuHandler(JPopupMenu menu) {
+        this.menu = menu;
+    }
+
+    /**
+     * Appends a new separator at the end of the menu.
+     * @see JPopupMenu#addSeparator
+     */
+    public void addSeparator() {
+        menu.addSeparator();
+    }
+
+    /**
+     * Appends a new menu item to the end of the menu which dispatches the specified <code>Action</code> object.
+     * 
+     * @param a the <code>Action</code> to add to the menu
+     * @return the new menu item
+     * @see JPopupMenu#add(Action)
+     */
+    public JMenuItem addAction(Action a) {
+        if (a != null) {
+            if (a instanceof OsmPrimitiveAction) {
+                primitiveActions.add((OsmPrimitiveAction) a);
+            }
+            return menu.add(a);
+        }
+        return null;
+    }
+
+    /**
+     * Removes the menu item which dispatches the specified <code>Action</code> object.
+     * 
+     * @param a the <code>Action</code> to remove from the menu
+     * @see JPopupMenu#remove(int)
+     */
+    public void removeAction(Action a) {
+        if (a != null) {
+            if (a instanceof OsmPrimitiveAction) {
+                primitiveActions.remove(a);
+            }
+            MenuElement[] elements = menu.getSubElements();
+            for (int i=0; i<elements.length; i++) {
+                if (elements[i] instanceof JMenuItem) {
+                    if (((JMenuItem) elements[i]).getAction() == a) {
+                        menu.remove(i);
+                        return;
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     *  Adds a <code>PopupMenu</code> listener.
+     *
+     *  @param l the <code>PopupMenuListener</code> to add
+     *  @see JPopupMenu#addPopupMenuListener
+     */
+    public void addListener(PopupMenuListener l) {
+        menu.addPopupMenuListener(l);
+    }
+
+    /**
+     * Removes a <code>PopupMenu</code> listener.
+     *
+     * @param l the <code>PopupMenuListener</code> to remove
+     *  @see JPopupMenu#removePopupMenuListener
+     */
+    public void removeListener(PopupMenuListener l) {
+        menu.removePopupMenuListener(l);
+    }
+    
+    /**
+     * Returns all enabled primitive actions.
+     * @return All primitive actions that have been added.
+     * @see #addAction(Action)
+     */
+    public Collection<OsmPrimitiveAction> getPrimitiveActions() {
+        return Collections.unmodifiableCollection(primitiveActions);
+    }
+    
+    /**
+     * Specifies the working set of primitives for all primitive actions.
+     * @param primitives The new working set of primitives. Can be null or empty
+     * @see OsmPrimitiveAction#setPrimitives
+     */
+    public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
+        for (OsmPrimitiveAction action : primitiveActions) {
+            action.setPrimitives(primitives);
+        }
+    }
+}
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java	(revision 5820)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java	(revision 5821)
@@ -16,5 +16,4 @@
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -22,9 +21,7 @@
 import javax.swing.AbstractAction;
 import javax.swing.AbstractListModel;
-import javax.swing.Action;
 import javax.swing.DefaultListSelectionModel;
 import javax.swing.JComponent;
 import javax.swing.JList;
-import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
@@ -39,5 +36,4 @@
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
-import javax.swing.event.PopupMenuListener;
 
 import org.openstreetmap.josm.Main;
@@ -69,4 +65,5 @@
 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
+import org.openstreetmap.josm.gui.PopupMenuHandler;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
@@ -95,6 +92,7 @@
     private final NewAction newAction;
     
-    /** the popup menu */
-    private final RelationDialogPopupMenu popupMenu;
+    /** the popup menu and its handler */
+    private final JPopupMenu popupMenu = new JPopupMenu();
+    private final PopupMenuHandler popupMenuHandler = new PopupMenuHandler(popupMenu);
 
     private final JTextField filter;
@@ -109,9 +107,9 @@
     private final DownloadMembersAction downloadMembersAction = new DownloadMembersAction();
     private final DownloadSelectedIncompleteMembersAction downloadSelectedIncompleteMembersAction = new DownloadSelectedIncompleteMembersAction();
-    private final SelectMembersAction selectMemebersAction = new SelectMembersAction(false);
+    private final SelectMembersAction selectMembersAction = new SelectMembersAction(false);
     private final SelectMembersAction addMembersToSelectionAction = new SelectMembersAction(true);
     private final SelectRelationAction selectRelationAction = new SelectRelationAction(false);
     private final SelectRelationAction addRelationToSelectionAction = new SelectRelationAction(true);
-    /** add all selected primitives to the given realtions */
+    /** add all selected primitives to the given relations */
     private final AddSelectionToRelations addSelectionToRelations = new AddSelectionToRelations();
     
@@ -154,4 +152,7 @@
             }
         });
+
+        // Setup popup menu handler
+        setupPopupMenuHandler();
         
         JPanel pane = new JPanel(new BorderLayout());
@@ -175,6 +176,4 @@
         InputMapUtils.addEnterAction(displaylist, selectRelationAction);
 
-        popupMenu = new RelationDialogPopupMenu();
-
         // Edit relation on Ctrl-Enter
         displaylist.getActionMap().put("edit", editAction);
@@ -186,20 +185,5 @@
     // inform all actions about list of relations they need
     private void updateActionsRelationLists() {
-        List<Relation> rels;
-        rels = model.getSelectedNonNewRelations();
-        downloadMembersAction.setRelations(rels);
-
-        rels = model.getSelectedRelationsWithIncompleteMembers();
-        downloadSelectedIncompleteMembersAction.setRelations(rels); 
-
-        rels = model.getSelectedRelations();
-        editAction.setRelations(rels);
-        deleteRelationsAction.setRelations(rels);
-        addSelectionToRelations.setRelations(rels);
-        selectMemebersAction.setRelations(rels);
-        addMembersToSelectionAction.setRelations(rels);
-        selectRelationAction.setRelations(rels);
-        addRelationToSelectionAction.setRelations(rels);
-        duplicateAction.setRelations(rels);
+        popupMenuHandler.setPrimitives(model.getSelectedRelations());
     }
     
@@ -509,21 +493,4 @@
             }
         }
-
-        /**
-         * Replies the list of selected relations with incomplete members
-         *
-         * @return the list of selected relations with incomplete members
-         */
-        public List<Relation> getSelectedRelationsWithIncompleteMembers() {
-            List<Relation> ret = getSelectedNonNewRelations();
-            Iterator<Relation> it = ret.iterator();
-            while(it.hasNext()) {
-                Relation r = it.next();
-                if (!r.hasIncompleteMembers()) {
-                    it.remove();
-                }
-            }
-            return ret;
-        }
         
         private void updateFilteredRelations() {
@@ -569,24 +536,4 @@
 
         /**
-         * Replies the list of selected, non-new relations. Empty list,
-         * if there are no selected, non-new relations.
-         *
-         * @return the list of selected, non-new relations.
-         */
-        public List<Relation> getSelectedNonNewRelations() {
-            ArrayList<Relation> ret = new ArrayList<Relation>();
-            for (int i=0; i<getSize();i++) {
-                if (!selectionModel.isSelectedIndex(i)) {
-                    continue;
-                }
-                if (getVisibleRelation(i).isNew()) {
-                    continue;
-                }
-                ret.add(getVisibleRelation(i));
-            }
-            return ret;
-        }
-
-        /**
          * Replies the list of selected relations. Empty list,
          * if there are no selected relations.
@@ -656,47 +603,37 @@
     }
 
-    class RelationDialogPopupMenu extends JPopupMenu {
-
-        public RelationDialogPopupMenu() {
-            // -- download members action
-            add(downloadMembersAction);
-
-            // -- download incomplete members action
-            add(downloadSelectedIncompleteMembersAction);
-
-            addSeparator();
-
-            // -- select members action
-            add(selectMemebersAction);
-            add(addMembersToSelectionAction);
-
-            // -- select action
-            add(selectRelationAction);
-            add(addRelationToSelectionAction);
-
-            addSeparator();
-
-            add(addSelectionToRelations);
-        }
-    }
-
+    private final void setupPopupMenuHandler() {
+        
+        // -- download members action
+        popupMenuHandler.addAction(downloadMembersAction);
+
+        // -- download incomplete members action
+        popupMenuHandler.addAction(downloadSelectedIncompleteMembersAction);
+
+        popupMenuHandler.addSeparator();
+
+        // -- select members action
+        popupMenuHandler.addAction(selectMembersAction);
+        popupMenuHandler.addAction(addMembersToSelectionAction);
+
+        // -- select action
+        popupMenuHandler.addAction(selectRelationAction);
+        popupMenuHandler.addAction(addRelationToSelectionAction);
+
+        popupMenuHandler.addSeparator();
+
+        popupMenuHandler.addAction(addSelectionToRelations);
+    }
+    
     /* ---------------------------------------------------------------------------------- */
-    /* Methods that can be called from plugins                                                                    */
+    /* Methods that can be called from plugins                                            */
     /* ---------------------------------------------------------------------------------- */
 
-    public void addPopupMenuSeparator() {
-        popupMenu.addSeparator();
-    }
-
-    public JMenuItem addPopupMenuAction(Action a) {
-        return popupMenu.add(a);
-    }
-
-    public void addPopupMenuListener(PopupMenuListener l) {
-        popupMenu.addPopupMenuListener(l);
-    }
-
-    public void removePopupMenuListener(PopupMenuListener l) {
-        popupMenu.addPopupMenuListener(l);
+    /**
+     * Replies the popup menu handler.
+     * @return The popup menu handler
+     */
+    public PopupMenuHandler getPopupMenuHandler() {
+        return popupMenuHandler;
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 5820)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 5821)
@@ -24,5 +24,4 @@
 import javax.swing.AbstractAction;
 import javax.swing.AbstractListModel;
-import javax.swing.Action;
 import javax.swing.DefaultListSelectionModel;
 import javax.swing.JList;
@@ -35,5 +34,4 @@
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
-import javax.swing.event.PopupMenuListener;
 
 import org.openstreetmap.josm.Main;
@@ -67,4 +65,5 @@
 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
+import org.openstreetmap.josm.gui.PopupMenuHandler;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -92,5 +91,7 @@
     private DownloadSelectedIncompleteMembersAction actDownloadSelectedIncompleteMembers;
 
-    private SelectionPopup popupMenu;
+    /** the popup menu and its handler */
+    private final ListPopupMenu popupMenu;
+    private final PopupMenuHandler popupMenuHandler;
 
     /**
@@ -148,14 +149,12 @@
         actDownloadSelectedIncompleteMembers = new DownloadSelectedIncompleteMembersAction();
 
+        popupMenu = new ListPopupMenu(lstPrimitives);
+        popupMenuHandler = setupPopupMenuHandler();
+
         lstPrimitives.addListSelectionListener(new ListSelectionListener() {
             @Override
             public void valueChanged(ListSelectionEvent e) {
                 actZoomToListSelection.valueChanged(e);
-                List<Relation> rels;
-                rels = model.getSelectedRelationsWithIncompleteMembers();
-                actDownloadSelectedIncompleteMembers.setRelations(rels); 
-                rels = OsmPrimitive.getFilteredList(model.getSelected(), Relation.class);
-                actSetRelationSelection.setRelations(rels);
-                actEditRelationSelection.setRelations(rels);
+                popupMenuHandler.setPrimitives(model.getSelected());
             }
         });
@@ -164,5 +163,4 @@
         lstPrimitives.addMouseListener(new DblClickHandler());
 
-        popupMenu = new SelectionPopup(lstPrimitives);
         InputMapUtils.addEnterAction(lstPrimitives, actZoomToListSelection);
     }
@@ -221,34 +219,22 @@
     }
 
-    /**
-     * The popup menu for the selection list
-     */
-    class SelectionPopup extends ListPopupMenu {
-        public SelectionPopup(JList list) {
-            super(list);
-            add(actZoomToJOSMSelection);
-            add(actZoomToListSelection);
-            addSeparator();
-            add(actSetRelationSelection);
-            add(actEditRelationSelection);
-            addSeparator();
-            add(actDownloadSelectedIncompleteMembers);
-        }
-    }
-
-    public void addPopupMenuSeparator() {
-        popupMenu.addSeparator();
-    }
-
-    public JMenuItem addPopupMenuAction(Action a) {
-        return popupMenu.add(a);
-    }
-
-    public void addPopupMenuListener(PopupMenuListener l) {
-        popupMenu.addPopupMenuListener(l);
-    }
-
-    public void removePopupMenuListener(PopupMenuListener l) {
-        popupMenu.addPopupMenuListener(l);
+    private final PopupMenuHandler setupPopupMenuHandler() {
+        PopupMenuHandler handler = new PopupMenuHandler(popupMenu);
+        handler.addAction(actZoomToJOSMSelection);
+        handler.addAction(actZoomToListSelection);
+        handler.addSeparator();
+        handler.addAction(actSetRelationSelection);
+        handler.addAction(actEditRelationSelection);
+        handler.addSeparator();
+        handler.addAction(actDownloadSelectedIncompleteMembers);
+        return handler;
+    }
+
+    /**
+     * Replies the popup menu handler.
+     * @return The popup menu handler
+     */
+    public PopupMenuHandler getPopupMenuHandler() {
+        return popupMenuHandler;
     }
 
@@ -596,30 +582,4 @@
             }
             setSelected(sel);
-        }
-
-        /**
-         * Replies the list of selected relations with incomplete members
-         *
-         * @return the list of selected relations with incomplete members
-         */
-        public List<Relation> getSelectedRelationsWithIncompleteMembers() {
-            List<Relation> ret = new LinkedList<Relation>();
-            for(int i=0; i<getSize(); i++) {
-                if (!selectionModel.isSelectedIndex(i)) {
-                    continue;
-                }
-                OsmPrimitive p = selection.get(i);
-                if (! (p instanceof Relation)) {
-                    continue;
-                }
-                if (p.isNew()) {
-                    continue;
-                }
-                Relation r = (Relation)p;
-                if (r.hasIncompleteMembers()) {
-                    ret.add(r);
-                }
-            }
-            return ret;
         }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 5820)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 5821)
@@ -32,8 +32,6 @@
 
 import javax.swing.AbstractAction;
-import javax.swing.Action;
 import javax.swing.JComponent;
 import javax.swing.JLabel;
-import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
@@ -44,5 +42,4 @@
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
-import javax.swing.event.PopupMenuListener;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
@@ -77,4 +74,5 @@
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.PopupMenuHandler;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
@@ -111,6 +109,8 @@
  */
 public class PropertiesDialog extends ToggleDialog implements SelectionChangedListener, MapView.EditLayerChangeListener, DataSetListenerAdapter.Listener {
-    // hook for roadsigns plugin to display a small
-    // button in the upper right corner of this dialog
+
+    /**
+     * hook for roadsigns plugin to display a small button in the upper right corner of this dialog
+     */
     public static final JPanel pluginHook = new JPanel();
 
@@ -134,6 +134,11 @@
     private final JTable membershipTable = new JTable(membershipData);
 
-    private JPopupMenu propertyMenu;
-    private JPopupMenu membershipMenu;
+    // Popup menus
+    private final JPopupMenu propertyMenu = new JPopupMenu();
+    private final JPopupMenu membershipMenu = new JPopupMenu();
+
+    // Popup menu handlers
+    private final PopupMenuHandler propertyMenuHandler = new PopupMenuHandler(propertyMenu);
+    private final PopupMenuHandler membershipMenuHandler = new PopupMenuHandler(membershipMenu);
 
     private final Map<String, Map<String, Integer>> valueCount = new TreeMap<String, Map<String, Integer>>();
@@ -202,4 +207,5 @@
     /**
      * Create a new PropertiesDialog
+     * @param mapFrame The parent map fram
      */
     public PropertiesDialog(MapFrame mapFrame) {
@@ -370,9 +376,8 @@
     private void setupMembershipMenu() {
         // setting up the membership table
-        membershipMenu = new JPopupMenu();
-        membershipMenu.add(addRelationToSelectionAction);
-        membershipMenu.add(selectRelationAction);
-        membershipMenu.add(addMembersToSelectionAction);
-        membershipMenu.add(downloadSelectedIncompleteMembersAction);
+        membershipMenuHandler.addAction(addRelationToSelectionAction);
+        membershipMenuHandler.addAction(selectRelationAction);
+        membershipMenuHandler.addAction(addMembersToSelectionAction);
+        membershipMenuHandler.addAction(downloadSelectedIncompleteMembersAction);
         membershipMenu.addSeparator();
         membershipMenu.add(helpAction);
@@ -389,13 +394,10 @@
                     idx = new int[]{row};
                 }
-                List<Relation> rels =  new ArrayList<Relation>(10);
+                List<Relation> rels = new ArrayList<Relation>();
                 for (int i: idx) {
                     Relation r = (Relation) (membershipData.getValueAt(i, 0));
                     rels.add(r);
                 }
-                selectRelationAction.setRelations(rels);
-                addRelationToSelectionAction.setRelations(rels);
-                addMembersToSelectionAction.setRelations(rels);
-                downloadSelectedIncompleteMembersAction.setRelations(rels);
+                membershipMenuHandler.setPrimitives(rels);
                 membershipMenu.show(membershipTable, p.x, p.y-3);
             }
@@ -407,5 +409,4 @@
      */
     private void setupPropertiesMenu() {
-        propertyMenu = new JPopupMenu();
         propertyMenu.add(pasteValueAction);
         propertyMenu.add(copyValueAction);
@@ -695,18 +696,11 @@
 
     // <editor-fold defaultstate="collapsed" desc="Methods that are called by plugins to extend fuctionalty ">
-    public void addPropertyPopupMenuSeparator() {
-        propertyMenu.addSeparator();
-    }
-
-    public JMenuItem addPropertyPopupMenuAction(Action a) {
-        return propertyMenu.add(a);
-    }
-
-    public void addPropertyPopupMenuListener(PopupMenuListener l) {
-        propertyMenu.addPopupMenuListener(l);
-    }
-
-    public void removePropertyPopupMenuListener(PopupMenuListener l) {
-        propertyMenu.addPopupMenuListener(l);
+    
+    /**
+     * Replies the property popup menu handler.
+     * @return The property popup menu handler
+     */
+    public PopupMenuHandler getPropertyPopupMenuHandler() {
+        return propertyMenuHandler;
     }
 
@@ -721,18 +715,10 @@
     }
 
-    public void addMembershipPopupMenuSeparator() {
-        membershipMenu.addSeparator();
-    }
-
-    public JMenuItem addMembershipPopupMenuAction(Action a) {
-        return membershipMenu.add(a);
-    }
-
-    public void addMembershipPopupMenuListener(PopupMenuListener l) {
-        membershipMenu.addPopupMenuListener(l);
-    }
-
-    public void removeMembershipPopupMenuListener(PopupMenuListener l) {
-        membershipMenu.addPopupMenuListener(l);
+    /**
+     * Replies the membership popup menu handler.
+     * @return The membership popup menu handler
+     */
+    public PopupMenuHandler getMembershipPopupMenuHandler() {
+        return membershipMenuHandler;
     }
 
