| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <html> |
| <head> |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| <script type="text/javascript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"></script> |
| <title>Authoring a command link</title> |
| </head> |
| <body> |
| |
| <h2>Authoring a command link</h2> |
| |
| <P> |
| 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 <b>org.eclipse.help</b> |
| plug-in. You refer to it using the help system's <a href="ua_help_content_files.htm#help_plugin_files_xref">cross |
| plug-in referencing</a> technique. This script reference should be placed in the <b>HEAD</b> section of your HTML: |
| </P> |
| |
| <pre ><script type="text/javascript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> |
| </script></pre> |
| |
| <P> |
| Now in the body of your documentation you may invoke the <b>executeCommand</b> function. |
| Here is an example: |
| </P> |
| |
| <pre><a href='javascript:executeCommand("org.eclipse.ui.help.aboutAction")'> |
| Open the About dialog</a></pre> |
| |
| <P> |
| The parameter for the <b>executeCommand</b> function is a serialized |
| <a href="../reference/api/org/eclipse/core/commands/ParameterizedCommand.html"> |
| <b>ParameterizedCommand</b></a>. |
| See the |
| <a href="../reference/api/org/eclipse/core/commands/ParameterizedCommand.html#serialize()"> |
| <b>ParameterizedCommand.serialize()</b></a> method for full details on this format. |
| </P> |
| |
| <P> |
| 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 <tt>class</tt> 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: |
| </P> |
| |
| <pre><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></pre> |
| |
| <P> |
| In the examples above, the About dialog command does not require any parameters, so the |
| serialization is merely its command id: <tt>org.eclipse.ui.help.aboutAction</tt>. |
| Below is another example showing a command with a parameter. Note the command id is |
| followed by the parameter id and value in parentheses: |
| </P> |
| |
| <pre><a href='javascript:executeCommand( |
| "org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.preferencePages.Views)")'> |
| Show a preference page</a></pre> |
| |
| <P> |
| Another example demonstrates that multiple parameters are possible. They are comma |
| separated and the order of the parameters is not important. |
| </P> |
| |
| <pre><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></pre> |
| |
| </body> |
| </html> |