Package ptolemy.vergil.tree
Class PTreeMenuCreator
- java.lang.Object
-
- java.awt.event.MouseAdapter
-
- ptolemy.vergil.tree.PTreeMenuCreator
-
- All Implemented Interfaces:
java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.awt.event.MouseWheelListener
,java.util.EventListener
public class PTreeMenuCreator extends java.awt.event.MouseAdapter
A mouse listener that creates context menus for a PTree using menu item factories. When asked to create a context menu, This class determines the ptolemy object associated with the point in the tree that was clicked on. Then it passes the ptolemy object to each menu item factory that it contains to add the menu items. Lastly, it pops up the resulting menu.- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- Author:
- Steve Neuendorffer
- Pt.AcceptedRating:
- Red (johnr)
- Pt.ProposedRating:
- Red (eal)
-
-
Constructor Summary
Constructors Constructor Description PTreeMenuCreator()
Create a new menu factory that contains no menu item factories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMenuItemFactory(MenuItemFactory factory)
Add a menu item factory to this creator.void
clear()
Remove all MenuItemFactories from the factory list.java.util.List
menuItemFactoryList()
Return the list of menu item factories.void
mousePressed(java.awt.event.MouseEvent e)
Create an instance of the menu associated with this factory.void
mouseReleased(java.awt.event.MouseEvent e)
Create an instance of the menu associated with this factory.void
removeMenuItemFactory(MenuItemFactory factory)
Remove the given menu item factory from the factory list.
-
-
-
Method Detail
-
addMenuItemFactory
public void addMenuItemFactory(MenuItemFactory factory)
Add a menu item factory to this creator.- Parameters:
factory
- The menu item factory to add.
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
Create an instance of the menu associated with this factory.- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
- Overrides:
mousePressed
in classjava.awt.event.MouseAdapter
- Parameters:
e
- The mouse event. If the mouse event is a popup event, then menu is created and shown.
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
Create an instance of the menu associated with this factory.- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
- Overrides:
mouseReleased
in classjava.awt.event.MouseAdapter
- Parameters:
e
- The mouse event. If the mouse event is a popup event, then menu is created and shown.
-
menuItemFactoryList
public java.util.List menuItemFactoryList()
Return the list of menu item factories.- Returns:
- An unmodifiable list.
-
removeMenuItemFactory
public void removeMenuItemFactory(MenuItemFactory factory)
Remove the given menu item factory from the factory list.- Parameters:
factory
- The factory to be removed.
-
clear
public void clear()
Remove all MenuItemFactories from the factory list.
-
-