Package org.openstreetmap.josm.gui
Class PopupMenuHandler
- java.lang.Object
-
- org.openstreetmap.josm.gui.PopupMenuHandler
-
public class PopupMenuHandler extends java.lang.Object
Handler to ease management of actions in different popup menus.- Since:
- 5821
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JPopupMenu
menu
private java.util.Set<IPrimitiveAction>
primitiveActions
-
Constructor Summary
Constructors Constructor Description PopupMenuHandler(javax.swing.JPopupMenu menu)
Constructs a newRelationActionMenuHandler
for the specified popup menu.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.swing.JMenuItem
addAction(javax.swing.Action a)
Appends a new menu item to the end of the menu which dispatches the specifiedAction
object.void
addListener(javax.swing.event.PopupMenuListener l)
Adds aPopupMenu
listener.void
addSeparator()
Appends a new separator at the end of the menu.java.util.Collection<IPrimitiveAction>
getPrimitiveActions()
Returns all enabled primitive actions.void
removeAction(javax.swing.Action a)
Removes the menu item which dispatches the specifiedAction
object.void
removeListener(javax.swing.event.PopupMenuListener l)
Removes aPopupMenu
listener.void
setPrimitives(java.util.Collection<? extends IPrimitive> primitives)
Specifies the working set of primitives for all primitive actions.
-
-
-
Field Detail
-
primitiveActions
private final java.util.Set<IPrimitiveAction> primitiveActions
-
menu
private final javax.swing.JPopupMenu menu
-
-
Constructor Detail
-
PopupMenuHandler
public PopupMenuHandler(javax.swing.JPopupMenu menu)
Constructs a newRelationActionMenuHandler
for the specified popup menu.- Parameters:
menu
- The menu to be managed
-
-
Method Detail
-
addSeparator
public void addSeparator()
Appends a new separator at the end of the menu.- See Also:
JPopupMenu.addSeparator()
-
addAction
public javax.swing.JMenuItem addAction(javax.swing.Action a)
Appends a new menu item to the end of the menu which dispatches the specifiedAction
object.- Parameters:
a
- theAction
to add to the menu- Returns:
- the new menu item
- See Also:
JPopupMenu.add(Action)
-
removeAction
public void removeAction(javax.swing.Action a)
Removes the menu item which dispatches the specifiedAction
object.- Parameters:
a
- theAction
to remove from the menu- See Also:
JPopupMenu.remove(int)
-
addListener
public void addListener(javax.swing.event.PopupMenuListener l)
Adds aPopupMenu
listener.- Parameters:
l
- thePopupMenuListener
to add- See Also:
JPopupMenu.addPopupMenuListener(javax.swing.event.PopupMenuListener)
-
removeListener
public void removeListener(javax.swing.event.PopupMenuListener l)
Removes aPopupMenu
listener.- Parameters:
l
- thePopupMenuListener
to remove- See Also:
JPopupMenu.removePopupMenuListener(javax.swing.event.PopupMenuListener)
-
getPrimitiveActions
public java.util.Collection<IPrimitiveAction> getPrimitiveActions()
Returns all enabled primitive actions.- Returns:
- All primitive actions that have been added.
- Since:
- 13957 (signature)
- See Also:
addAction(Action)
-
setPrimitives
public void setPrimitives(java.util.Collection<? extends IPrimitive> primitives)
Specifies the working set of primitives for all primitive actions.- Parameters:
primitives
- The new working set of primitives. Can be null or empty- Since:
- 13957 (signature)
- See Also:
IPrimitiveAction.setPrimitives(java.util.Collection<? extends org.openstreetmap.josm.data.osm.IPrimitive>)
-
-