1.2. Contextual action
Prev | 1. action | Next

### 1.2. Contextual action

Action which is contextual, that is, the action actually taken (delegated to a command or to an actual, non-contextual, action) depends of the configuration associated to the active document. This kind of action is specified using the `context` child element.

In a `context` child element:

Element `configuration`

  Specifies what to do for a document associated to a configuration having a name equal to the value of attribute `name`.

  Example: this `configuration` element

            <configuration name="Simplified DocBook">
              <command name="docb.convertToPS"
                       parameter='pdf |pdf "/book toc /article toc" 1' />
            </configuration>

  specifies what to do for a document associated to a configuration called "`Simplified DocBook`" (see Section 3, “configuration” in XMLmind XML Editor - Configuration and Deployment).

Element `default`

  Specifies what to do for a document

  - which has no associated configuration;

  - or which has a configuration, but this configuration is not referenced in one of its `configuration` siblings.

  Example: this `default` element:

            <default>
              <class>com.xmlmind.xmleditapp.kit.part.PrintAction</class>
            </default>

  specifies what to do for a document not having a configuration or having a configuration different from "`XHTML` Strict", "`XHTML Transitional`", "`DocBook`" or "`DocBook v5+`".

The `configuration` element and the `default` element have the same content model. Their child element, `class` or `command`, specifies the action actually taken:

Element `class`

  Specifies a Java™ class derived from `com.xmlmind.xmleditapp.kit.AppAction`.

Element `command`

  Specifies a command which can be a generic one (e.g. command `convert`) or a configuration specific one (e.g. command `xhtml.preview`).

The `editingContextSensitive` attribute of the context child element specifies whether the contextual action is editing context sensitive, that is, is enabled or disabled depending on the editing context (Which node is selected? Is some text selected? Etc). The majority of contextual actions are expected to be editing context insensitive. That's why the default value of this attribute is `false`.

Example:

    <action name="printAction" label="_Print..."
              icon="xxe-gui:app/icons/printAction.gif"
              accelerator="mod P">
        <context editingContextSensitive="false">
          <configuration name="XHTML Strict">
            <command name="xhtml.convertToPS" parameter='pdf |pdf' />
          </configuration>

          <configuration name="XHTML Transitional">
            <command name="xhtml.convertToPS" parameter='pdf |pdf' />
          </configuration>

          <configuration name="DocBook v5+">
            <command name="db5.convertToPS"
                     parameter='pdf |pdf "/book toc /article toc" 1' />
          </configuration>

          <configuration name="DocBook">
            <command name="docb.convertToPS"
                     parameter='pdf |pdf "/book toc /article toc" 1' />
          </configuration>

          <default>
            <class>com.xmlmind.xmleditapp.kit.part.PrintAction</class>
          </default>
        </context>
      </action>

Prev | Up | Next
1.1. Action which is a wrapper around a command | Home | 2. command