Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

oracle.ide.controller
Interface DynamicMenuListener

All Superinterfaces:
java.util.EventListener

public interface DynamicMenuListener
extends java.util.EventListener

The DynamicMenuListener allows implementors to add their own menu items to the dynamic menu associated with this listener.


Method Summary
 javax.swing.JComponent[] gatherDynamicActions(Context context)
          Called just before the dynamic menu is added to the main menu bar.
 

Method Detail

gatherDynamicActions

javax.swing.JComponent[] gatherDynamicActions(Context context)
Called just before the dynamic menu is added to the main menu bar. Implementors should use the Context to determine whether or not to add commands to the menu. Implementors should add JMenuItem, JSeparator, or JMenu objects.

Example:

 
 public JComponent[] gatherDynamicActions(Context context)
 {
    if (context.getView() instanceof CodeEditor && 
        context.getDocument() instanceof JavaSourceNode)
    {
      return new JComponent[] 
      { 
        Ide.getMenubar().createMenuItem( action1 ), 
        Ide.getMenubar().createMenuItem( action2 ),
        new JSeparator(), 
        Ide.getMenubar().createMenuItem( action3 )
      };
    }
    return new JComponent[0];
 }
A note about weighting components: Weighting is used to control the order of commands in the dynamic menu. The weight is a float value that can be specific for IdeAction objects like:
  action.setMenuWeight(new Float(0.05f);
and for JMenu and JSeparator objects like:
  ((JComponent) menu).putClientProperty(IdeConstants.MENU_WEIGHT, new Float(0.5f));

Parameters:
context - the current view context.
Returns:
a list of menu items to add to the dynamic menu. Should return a zero-length array if no commands are available in the active context.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

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