bibliothek.gui.dock.action
Class ActionPopup

java.lang.Object
  extended by javax.swing.event.MouseInputAdapter
      extended by bibliothek.gui.dock.action.ActionPopup
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener, MouseInputListener
Direct Known Subclasses:
DefaultStackDockComponent.Tab

public abstract class ActionPopup
extends MouseInputAdapter

A mouse-listener that may be added to any component. When the popup-trigger is pressed, a popupmenu will appear. This menu shows a list of DockActions.

Author:
Benjamin Sigg

Constructor Summary
ActionPopup(boolean suppressable)
          Constructs a new ActionPopup
 
Method Summary
protected abstract  DockActionSource getActions()
          Gets the actions, that will be displayed
protected abstract  Dockable getDockable()
          Gets the Dockable to which the actions are linked.
protected  ActionPopupMenuFactory getFactory()
          Gets the factory which should be used for creating new popup menus.
protected  Point getPopupLocation(Component owner, Point location)
          Tells the exact location where the popup should appear.
protected abstract  Object getSource()
          Gets the source object, the object which is responsible for showing the current menu.
protected abstract  boolean isEnabled()
          Tells, whether a popup can be displayed, or not.
 boolean isMenuOpen()
          Tells whether this ActionPopup currently shows a menu.
 boolean isSuppressable()
          Whether this ActionPopup can be suppressed or not.
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 boolean popup(Component owner, int x, int y)
          Pops up this menu.
protected  void popup(MouseEvent e)
          Shows the popup of this ActionPopup.
 void setSuppressable(boolean suppressable)
          Sets whether to ask the ActionPopupSuppressor if this menu is allowed to popup or not.
 
Methods inherited from class javax.swing.event.MouseInputAdapter
mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionPopup

public ActionPopup(boolean suppressable)
Constructs a new ActionPopup

Parameters:
suppressable - whether to check the ActionPopupSuppressor before popping up, or not. The suppressor can tell the popup, that it should not be made visible.
Method Detail

isSuppressable

public boolean isSuppressable()
Whether this ActionPopup can be suppressed or not.

Returns:
true if this can be suppressed

setSuppressable

public void setSuppressable(boolean suppressable)
Sets whether to ask the ActionPopupSuppressor if this menu is allowed to popup or not.

Parameters:
suppressable - true if the suppressor is allowed to suppress this popup

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseInputAdapter

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseInputAdapter

isEnabled

protected abstract boolean isEnabled()
Tells, whether a popup can be displayed, or not.

Returns:
true if a popup can be displayed, false otherwise.

getDockable

protected abstract Dockable getDockable()
Gets the Dockable to which the actions are linked.

Returns:
The Dockable

getActions

protected abstract DockActionSource getActions()
Gets the actions, that will be displayed

Returns:
The actions

getSource

protected abstract Object getSource()
Gets the source object, the object which is responsible for showing the current menu.

Returns:
the source object, may be null

popup

protected void popup(MouseEvent e)
Shows the popup of this ActionPopup. This method is normally invoked by the mousePressed or the mouseReleased-method

Parameters:
e - The MouseEvent that triggers the popup. The event must not consumed

getPopupLocation

protected Point getPopupLocation(Component owner,
                                 Point location)
Tells the exact location where the popup should appear.

Parameters:
owner - the component which triggered a mouse event
location - where the user clicked onto owner
Returns:
where to open the menu or null to cancel the operation

getFactory

protected ActionPopupMenuFactory getFactory()
Gets the factory which should be used for creating new popup menus.

Returns:
the factory, not null

popup

public boolean popup(Component owner,
                     int x,
                     int y)
Pops up this menu.

Parameters:
owner - the owner of the menu
x - x-coordinate
y - y-coordinate
Returns:
true if the menu is shown

isMenuOpen

public boolean isMenuOpen()
Tells whether this ActionPopup currently shows a menu.

Returns:
true if a menu is visible, false otherwise