Adding cheat sheet to the help menu:
- Add org.eclipse.ui.cheatSheets as dependency for the plugin.
- Add org.eclipse.ui.actionSets extension point
- Under this add a new action set for cheat sheets and give it the id org.eclipse.ui.cheatsheets.actionSet
- Create an action under the action set and give it the id org.eclipse.ui.cheatsheets.actions.CheatSheetHelpMenuAction. Give it a menubarpath (id of the help menu\path), label and style.
Creating Cheat Sheet:
- Add org.eclipse.ui.cheatsheets.cheatSheetContent extension point.
- Go to File->New->Other->User Assistance->Cheat Sheet
- Select the folder where you want to create the cheat sheet, type in the file name and choose whether you want to create a simple or composite cheat sheet. We will create a simple cheat sheet in this article.
- When the editor comes up, it would just have Title and Introduction. Replace the defaults with your own title and introduction.
- Click on Register Cheat Sheet in the top right to register the cheat sheet before adding contents to it.
- In Register cheat sheet dialog, set the category (Optional - but highly recommended so that they are grouped properly in the "Cheat Sheet Selection" dialog) and enter description. This basically adds your cheat sheet under the cheatSheetContent in plugin.xml.
- After this you can add how many number of steps you want and each step can have many sub-steps under it.
- Apart from the instructions, we can also add links to the help content by using Help section in the cheat sheet editor.
- One of the main advantages in cheat sheet is user can either do the step manually and click on "Click when complete" or click on "Click to perform" to automatically perform the action. Click to perform can either be achieved by adding an action or by adding a command to the step.
- To add the command click on Command->Browse in cheat sheet editor and select the appropriate command. If required, enter the parameter to that command.
- We can also add an action to a step, but that is not currently supported by the cheat sheet editor. We can go directly to the xml and add the action though. An example of an action looks like this below: <action
Here we specify the action class and the plugin id it lives in. Required = "false" attribute displays the "Click when complete" link. If required is true, then it means user has to use the click to perform and so click when complete will not be displayed.
Some of the advanced options are not available via the cheat sheet editor. We can add them directly to the XML since cheat sheet is persisted in XML anyway. Click on the source tab in cheat sheet editor to open the XML.
- In the XML, each step is represented by an item and each sub-step is represented by a sub-item.
- If a particular step involves bringing up a modal dialog, you can add dialog=true attribute in the item element in XML and that will make sure to bring the cheat sheet view along with the dialog so that cheat sheet view can be operated while in a modal dialog.
- We already saw action above. An item can also have perform-when, onCompletion, conditional-subitem and repeated-subitem elements. You can guess what they are used for from the name. Sample XML for some of these are shown below:
<item ...>The above code picks the sub-step based on the value of variable v1.
<subitem when="x" label="Proceed to x" />
<subitem when="y" label="Proceed to y" />
<subitem label="Sub step">
<action when="a" class="com.xyz.action1"
<action when="b" class="com.xyz.action2"
The above code picks the action for the sub-step based on
the value of variable v1.
We saw how to add cheat sheet to the menu and contribute
cheat sheet content. We also saw how to add the content
directly through the editor or using the XML. I hope this
article helps you to create cheat sheets in your
- Building Commercial-Quality Plug-ins by Eric Clayberg and Dan Rubel.
- All the articles on cheat sheets in my delicious bookmarks:http://delicious.com/search?context=userposts&p=cheat%20sheet&lc=1&u=rajak27