Configure the Insert Section Action for a Framework
(Section16.gif) for
the menu item and
(Section20.gif) for the toolbar, are already available. Although you
could use the same icon size for both the menu and toolbar, usually the icons from the
toolbars are larger than the ones found in the menus. These files should be placed in the
frameworks/sdf directory.Figure: Action Dialog Box
- Set the ID field to insert_section. This is a unique action identifier.
- Set the Name field to Insert Section. This will be the action's name, displayed as a tooltip when the action is placed in the toolbar, or as the menu item name.
- Set the Menu access key to i. On Windows, the menu items can be accessed using ALT+letter keys combination, when the menu is visible. The letter is visually represented by underlining the first letter from the menu item name having the same value.
- Set the Description field to Insert a section at cursor position.
-
Set the Large icon (20x20) field to
${frameworks}/sdf/Section20.gif. A good practice is to store the image files inside the framework directory and use editor variable ${framework} to make the image relative to the framework location.If the images are bundled in a jar archive together with some Java operations implementation, for instance, it might be convenient for you to reference the images not by the file name, but by their relative path location in the class-path.If the image file Section20.gif is located in the images directory inside the jar archive, you can reference it by using /images/Section20.gif. The jar file must be added into the Classpath list.
-
Set the Small icon (16x16) field to
${frameworks}/sdf/Section16.gif. -
Click the text field next to Shortcut key and set it to Ctrl (Meta on Mac
OS)+Shift+S. This will be the key combination to trigger the action using the
keyboard only.
The shortcut is enabled only by adding the action to the main menu of Author mode, which contains all the actions that the author will have in a menu for the current document type.
-
At this time the action has no functionality added to it. Next you must define how this
action operates. An action can have multiple operation modes. The first action mode
enabled by the evaluation of its associated XPath expression will be executed when the
action is triggered by the user. The Xpath expression needs to be version 2.0 and its
scope must be only element and attribute nodes of the edited document. Otherwise, the
expression will not return a match and will not trigger the action. If the expression is
left empty, the action will be enabled anywhere in the scope of the root element. For this
example we'll suppose you want allow the action to add a section only if the current
element is either a
book,articleor anothersection.-
Set the XPath expression field to:
local-name()='section' or local-name()='book' or local-name()='article' - Set the invoke operation field to InsertFragmentOperation built-in operation, designed to insert an XML fragment at cursor position. This belongs to a set of built-in operations, a complete list of which can be found in the Author Default Operations section. This set can be expanded with your own Java operation implementations.
-
Configure the arguments section as follows:
<section xmlns= "http://www.oxygenxml.com/sample/documentation"> <title/> </section>
insertLocation - leave it empty. This means the location will be at the cursor position.
insertPosition - select "Inside".
-
Set the XPath expression field to: