DESY ACOP Beans Home

com.cosylab.gui.components.util
Class PopupManager

java.lang.Object
  extended by com.cosylab.gui.components.util.PopupManager

public class PopupManager
extends java.lang.Object

PopupManager helps simple GUI widget to handle popup menu in transparent and extensible way.

Version:
$id$
Author:
Igor Kriznar

Constructor Summary
PopupManager(javax.swing.JComponent owner)
          Constructs a new PopupManager which belongs to the given component.
PopupManager(javax.swing.JComponent owner, boolean auto)
          Creates manager, which can automatically show a popup menu.
 
Method Summary
 int actionCount()
          Returns the number of actions.
 void addAction(javax.swing.Action a)
          Adds action to this manager.
 void addActions(javax.swing.Action[] a)
          Adds action to this manager.
 boolean containsAction(javax.swing.Action a)
          Checks in the manager contains the specified action.
 boolean containsActionForName(java.lang.String name)
          Checks if the manager containes action with the specified name.
 int firstIndexOf(javax.swing.Action a)
          Returns the first index of the action in the manager.
 int firstIndexOfName(java.lang.String name)
          Returns the first index of the action with the given name.
 javax.swing.Action getAction(int index)
          Returns the action at the given index.
 javax.swing.Action[] getActions()
          Returns an array of all action in the manager.
 javax.swing.JPopupMenu getJPopupMenu()
          Returns popup menu constructed from actions registered at the manager.
 com.cosylab.gui.components.util.PopupManager.MouseHook getMouseHook()
           
 javax.swing.JComponent getOwner()
          Returns owner of this manager.
 boolean isEnabled()
          Returns true if popup manager is enabled and shows popup menu.
 void removeAction(javax.swing.Action a)
          Removes the specified action from the manager.
 javax.swing.Action removeAction(int index)
          Removes the action under the index.
 void removeActions(javax.swing.Action[] a)
          Removes the specified actions from the manager
 javax.swing.Action[] removeAllActions()
          Removes all actions from the manager.
 void setEnabled(boolean b)
          Enambes or disables popup manager.
 void showPopup(java.awt.Component c, int x, int y)
          Shows popup menu at given location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PopupManager

public PopupManager(javax.swing.JComponent owner)
Constructs a new PopupManager which belongs to the given component.


PopupManager

public PopupManager(javax.swing.JComponent owner,
                    boolean auto)
Creates manager, which can automatically show a popup menu.

Parameters:
owner - owner, for which manager manages popup menu
auto - true if menu popups automatically
Method Detail

getOwner

public javax.swing.JComponent getOwner()
Returns owner of this manager. Usually it it GUI widgets which uses this manager to manage popup menu.

Returns:
owner of this manager

addAction

public void addAction(javax.swing.Action a)
Adds action to this manager. If action added is null, action is translateed to manu separator.

Parameters:
a - action to be added, if null, action is translateed to manu separator.

addActions

public void addActions(javax.swing.Action[] a)
Adds action to this manager. If action added is null, action is translateed to manu separator.

Parameters:
a - action to be added, if null, action is translateed to manu separator.

containsAction

public boolean containsAction(javax.swing.Action a)
Checks in the manager contains the specified action.

Parameters:
a -
Returns:
true if action exists

containsActionForName

public boolean containsActionForName(java.lang.String name)
Checks if the manager containes action with the specified name.

Parameters:
name - the name of the action
Returns:
true if action exists

firstIndexOf

public int firstIndexOf(javax.swing.Action a)
Returns the first index of the action in the manager.

Parameters:
a -
Returns:
index of action

firstIndexOfName

public int firstIndexOfName(java.lang.String name)
Returns the first index of the action with the given name.

Parameters:
name - the name of the action
Returns:
index of the action

getAction

public javax.swing.Action getAction(int index)
Returns the action at the given index.

Parameters:
index - index of action
Returns:
the action

removeAction

public void removeAction(javax.swing.Action a)
Removes the specified action from the manager.

Parameters:
a - the action to be removed

removeAction

public javax.swing.Action removeAction(int index)
Removes the action under the index.

Parameters:
index - index at which the action should be removed
Returns:
the removed action

removeActions

public void removeActions(javax.swing.Action[] a)
Removes the specified actions from the manager

Parameters:
a - actions to be removed

removeAllActions

public javax.swing.Action[] removeAllActions()
Removes all actions from the manager.

Returns:
removed actions

actionCount

public int actionCount()
Returns the number of actions.

Returns:

getActions

public javax.swing.Action[] getActions()
Returns an array of all action in the manager.

Returns:

getJPopupMenu

public javax.swing.JPopupMenu getJPopupMenu()
Returns popup menu constructed from actions registered at the manager.

Returns:
popup menu

showPopup

public void showPopup(java.awt.Component c,
                      int x,
                      int y)
Shows popup menu at given location.

Parameters:
x -
y -
c -

getMouseHook

public com.cosylab.gui.components.util.PopupManager.MouseHook getMouseHook()

isEnabled

public boolean isEnabled()
Returns true if popup manager is enabled and shows popup menu.

Returns:

setEnabled

public void setEnabled(boolean b)
Enambes or disables popup manager.

Parameters:
b -


Copyright © 2010. All Rights Reserved.