This function is called from Editor to add items to the
given menu based on config. The config is a sequence of
the following nodes and attributes.
@ChildNodes:
add - Adds a new menu item. See below for attributes.
separator - Adds a separator. No attributes.
condition - Adds a custom condition. Name attribute.
The add-node may have a child node that defines a function to be invoked
before the action is executed (or instead of an action to be executed).
@Attributes:
as - Resource key for the label (needs entry in property file).
action - Name of the action to execute in enclosing editor.
icon - Optional icon (relative/absolute URL).
iconCls - Optional CSS class for the icon.
if - Optional name of condition that must be true (see below).
enabled-if - Optional name of condition that specifies if the menu item
should be enabled.
name - Name of custom condition. Only for condition nodes.
@Conditions:
nocell - No cell under the mouse.
ncells - More than one cell selected.
notRoot - Drilling position is other than home.
cell - Cell under the mouse.
notEmpty - Exactly one cell with children under mouse.
expandable - Exactly one expandable cell under mouse.
collapsable - Exactly one collapsable cell under mouse.
validRoot - Exactly one cell which is a possible root under mouse.
swimlane - Exactly one cell which is a swimlane under mouse.
@Example:
To add a new item for a given action to the popupmenu:
<EditorPopupMenu as="popupHandler">
<add as="delete" action="delete" icon="images/delete.gif" if="cell"/>
</EditorPopupMenu>
To add a new item for a custom function:
<EditorPopupMenu as="popupHandler">
<add as="action1"><![CDATA[
function (editor, cell, evt)
{
editor.execute('action1', cell, 'myArg');
}
]]></add>
</EditorPopupMenu>
The above example invokes action1 with an additional third argument via
the editor instance. The third argument is passed to the function that
defines action1. If the add-node has no action-attribute, then only the
function defined in the text content is executed, otherwise first the
function and then the action defined in the action-attribute is
executed. The function in the text content has 3 arguments, namely the
Editor instance, the Cell instance under the mouse, and the
native mouse event.
Custom Conditions:
To add a new condition for popupmenu items:
<condition name="condition1"><![CDATA[
function (editor, cell, evt)
{
return cell != null;
}
]]></condition>
The new condition can then be used in any item as follows:
<add as="action1" action="action1" icon="action1.gif" if="condition1"/>
The order in which the items and conditions appear is not significant as
all conditions are evaluated before any items are created.