Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

oracle.ide.controller
Class ContextMenu

java.lang.Object
  extended by oracle.ide.controller.MenuManager
      extended by oracle.ide.controller.ContextMenu

public final class ContextMenu
extends MenuManager

Use ContextMenu to add menu items to context (right click) menus.

Thread Safety: instances of this class are not thread safe. They must be used only from the AWT Event Dispatch Thread. However, ContextMenuListeners can be safely added or removed while events are being dispatched.

Since:
9.0.2

Constructor Summary
ContextMenu()
           
ContextMenu(MnemonicSolver solver)
          Creates an instance of ContextMenu that will automatically resolve mnemonic conflicts.
 
Method Summary
 void add(java.awt.Component child)
          Appends a component into the MenuManager's GUI.
 void add(java.awt.Component child, float sectionId)
          Add the specified child to the end of this context menu.
 void add(java.awt.Component child, float sectionId, boolean fixed)
          Add the specified child to the end of this context menu.
 void addContextMenuListener(ContextMenuListener l)
          Adds a context menu listener.
 void addContextMenuListener(ContextMenuListener l, java.lang.Class cls)
          Adds a ContextMenuListener that is called when the type of the data represented by the current Context is assignable to a variable whose type is of the specified Class.
 void addMenuFilter(MenuFilter menuFilter)
          This implementation adds a menu filter only to the context menu.
 void addSeparator()
          Adds a Menu separator to the context menu.
 boolean fireDefaultAction(Context context)
          Invoke this method to fire the deault action associated with this context menu.
 Context getContext()
          Gets the current context.
 java.util.List<Pair<java.lang.Class,ContextMenuListener>> getContextMenuListeners()
          Returns a list of ContextMenuListener registered with this ContextMenu.
 java.awt.Container getGUI(boolean create)
          Creates the actual popup menu.
 int getMenuCount()
          Returns the number of elements in the menu.
 MnemonicSolver getMnemonicSolver()
          Get the menu item mnemonic solver.
 void prepareShow(Context context)
           
protected  void registerFilterContainerListener(javax.swing.JMenu menu)
           
 void removeAll()
          Removes all menu items from the popup menu.
 void removeContextMenuListener(ContextMenuListener l)
          Removes a context menu listener.
 void removeMenuFilter(MenuFilter menuFilter)
          This implementation removes a menu filter only from the context menu.
 void show(Context context)
          Shows the popup menu.
static Element unwrapDecoratedElement(Element elem)
          Returns the undecorated Element, when the ElementAttributes.DECORATES_DATA_ELEMENT attribute is set.
 
Methods inherited from class oracle.ide.controller.MenuManager
add, add, applyGlobalFilter, applyGlobalFilterImpl, clearGlobalFilter, clearGlobalFilterImpl, createMenu, createMenu, createMenu, createMenu, createMenu, createMenuItem, createMenuItem, createSubMenu, createSubMenu, createSubMenu, getChildById, getId, getIndexOfChild, getIndexOfCommandId, getJMenu, getKeyboardMnemonic, getMenuId, isMenuComponentAccepted, isMenuComponentAccepted, lookupMenuSection, putJMenu, remove, remove, removeMenuManagerMenuListener, setMenuId, setWeight, sortContainer, sortSectionByName, storeMenuSection, unregisterFilterContainerListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextMenu

public ContextMenu()

ContextMenu

public ContextMenu(MnemonicSolver solver)
Creates an instance of ContextMenu that will automatically resolve mnemonic conflicts.

Parameters:
solver - an instance of the MnemonicSolver class. This instance will be used to resolve mnemonic conflicts between context menu items.
Method Detail

add

public void add(java.awt.Component child)
Description copied from class: MenuManager
Appends a component into the MenuManager's GUI.

Overrides:
add in class MenuManager
Parameters:
child - the child to add.

add

public void add(java.awt.Component child,
                float sectionId)
Add the specified child to the end of this context menu.

Overrides:
add in class MenuManager
Parameters:
child - menu item to add.
sectionId - floating point number used to group commands by section. Each section is automatically surrounded with JSeparators.

add

public void add(java.awt.Component child,
                float sectionId,
                boolean fixed)
Add the specified child to the end of this context menu.

Parameters:
child - menu item to add.
sectionId - floating point number used to group commands by section. Each section is automatically surrounded with JSeparators.
fixed - indicates that the mnemonics used by the specified child should be respected by any active MnemonicSolver.

addContextMenuListener

public void addContextMenuListener(ContextMenuListener l)
Adds a context menu listener. Context menu listeners listen for notification of when the menu is about to become visible or invisible.

Parameters:
l - the context menu listener.

addContextMenuListener

public void addContextMenuListener(ContextMenuListener l,
                                   java.lang.Class cls)
Adds a ContextMenuListener that is called when the type of the data represented by the current Context is assignable to a variable whose type is of the specified Class.

Parameters:
l - the ContextMenuListener to add.
cls - if non-null, the ContextMenuListener will only be notified if the current Context's data object type is assignable to a variable whose type is of the specified Class.

removeContextMenuListener

public void removeContextMenuListener(ContextMenuListener l)
Removes a context menu listener. Context menu listeners listen for notification of when the menu is about to become visible or invisible.

Parameters:
l - the context menu listener.

getContextMenuListeners

public java.util.List<Pair<java.lang.Class,ContextMenuListener>> getContextMenuListeners()
Returns a list of ContextMenuListener registered with this ContextMenu.

Returns:
an immutable list of ContextMenuListeners, each ContextMenuListener will only be notified if the current Context's data object type is assignable to a variable whose type is of the specified Class.

getGUI

public java.awt.Container getGUI(boolean create)
Creates the actual popup menu. Callers should store the returned value for use when calling the show method.

Specified by:
getGUI in class MenuManager
Parameters:
create - force a creation of the GUI if it does not yet exist.
Returns:
the newly create popup menu.

getMenuCount

public int getMenuCount()
Returns the number of elements in the menu.


removeAll

public void removeAll()
Removes all menu items from the popup menu.


show

public final void show(Context context)
Shows the popup menu.

Parameters:
context - the current context. context cannot be null and the context's event object must be a MouseEvent.
Throws:
java.lang.NullPointerException - if context is null.

prepareShow

public final void prepareShow(Context context)

getContext

public final Context getContext()
Gets the current context.

Returns:
The current context from where this menu was poppped-up. This method will return null on a ContextMenu instance which has popped down.

addSeparator

public void addSeparator()
Adds a Menu separator to the context menu.


fireDefaultAction

public boolean fireDefaultAction(Context context)
Invoke this method to fire the deault action associated with this context menu. This is the action triggered when the user double clicks on the object from where the context menu is popped-up.

Parameters:
context - The current context.

getMnemonicSolver

public MnemonicSolver getMnemonicSolver()
Get the menu item mnemonic solver. This object can be used to make sure that the context menu does not have any conflicting mnemonics. Returns null if none available.


unwrapDecoratedElement

public static Element unwrapDecoratedElement(Element elem)
Returns the undecorated Element, when the ElementAttributes.DECORATES_DATA_ELEMENT attribute is set.


addMenuFilter

public final void addMenuFilter(MenuFilter menuFilter)
This implementation adds a menu filter only to the context menu. If you want to add a menu filter to all menus, use Ide.getMenubar().addMenuFilter().

Overrides:
addMenuFilter in class MenuManager
Parameters:
menuFilter - a menu filter to add for the context menu. Must not be null.
Since:
11.0

removeMenuFilter

public final void removeMenuFilter(MenuFilter menuFilter)
This implementation removes a menu filter only from the context menu.

Overrides:
removeMenuFilter in class MenuManager
Parameters:
menuFilter - a menu filter to remove.
Since:
11.0

registerFilterContainerListener

protected void registerFilterContainerListener(javax.swing.JMenu menu)
Overrides:
registerFilterContainerListener in class MenuManager

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

Copyright © 1997, 2013, Oracle. All rights reserved.