Authoring a command link
To include command links in your documentation, you must first declare the
use of the supporting JavaScript code. The live help JavaScript is located in the org.eclipse.help
plug-in. You refer to it using the help system's
crossplug-in referencing technique. This script reference should be placed in the HEAD section of your HTML:
<script type="text/javascript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js">
</script>
Now in the body of your documentation you may invoke the executeCommand function.
Here is an example:
<a href='javascript:executeCommand("org.eclipse.ui.help.aboutAction")'>
Open the About dialog</a>
The parameter for the executeCommand function is a serialized
ParameterizedCommand.
See the
ParameterizedCommand.serialize() method for full details on this format.
The example above shows the bare minimum required to embed a command in an HTML link.
The Eclipse documentation supplements this with two extra pieces of information.
First a class attribute is specified to allow for tuning the look of the link
via CSS. Second, an image tag is included before the link text. The image serves
to distinguish command links from ordinary links to other HTML pages. Supplementing
our initial example with these two extra features will look like this:
<a class="command-link" href='javascript:executeCommand("org.eclipse.ui.help.aboutAction")'>
<img src="PLUGINS_ROOT/org.eclipse.help/command_link.png">
Open the About dialog</a>
In the examples above, the About dialog command does not require any parameters, so the
serialization is merely its command id: org.eclipse.ui.help.aboutAction.
Below is another example showing a command with a parameter. Note the command id is
followed by the parameter id and value in parentheses:
<a href='javascript:executeCommand(
"org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.preferencePages.Views)")'>
Show a preference page</a>
Another example demonstrates that multiple parameters are possible. They are comma
separated and the order of the parameters is not important.
<a href='javascript:executeCommand(
"org.eclipse.ui.dialogs.openMessageDialog(imageType=3,buttonLabel2=Maybe,title=Opinion Poll,message=Do you like command links?,buttonLabel0=Yes,defaultIndex=0,buttonLabel1=No)")'>
Open a message dialog</a>