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));