public interface DynamicMenuListener
extends java.util.EventListener
| Modifier and Type | Method and Description |
|---|---|
javax.swing.JComponent[] |
gatherDynamicActions(Context context)
Called just before the dynamic menu is added to the main menu bar.
|
javax.swing.JComponent[] gatherDynamicActions(Context context)
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));
context - the current view context.