Each cheat sheet that you create must have its own XML file containing the text of the cheat sheet. The cheat structure is very simple: an
<intro> block followed by multiple
<item> blocks, one for every step in the cheat sheet. The formatting options are limited to
The sample below provides a two-step cheat sheet:
<?xml version="1.0" encoding="UTF-8"?> <cheatsheet title="Demo Cheat Sheet"> <intro > <description> This cheat sheet is a demo. </description> </intro> <item title="Hello, world!" > <description> This is the <b>first</b> step in this cheat sheet. <br /> </description> </item> <item title="Hello, world again!" > <description> This is the <b>second</b> step in this cheat sheet. <br /> </description> </item> </cheatsheet>
Create an XML file in your Eclipse plug-in project and copy the cheat sheet text into it. The XML file can be located anywhere, but it's easiest to put it in the project root folder.
Now that you have a cheat sheet XML file, you must add the Eclipse cheat sheet extension to your project, since it's not a required plug-in and therefore is not installed by default. Then you must create a grouping for your cheat sheets and insert your cheat sheet into the group. When you access the cheat sheet, you will see your grouping/category name and when you click to expand it, you will see all your cheat sheets (or just one cheat sheet as in the case of this tutorial).
From the Plug-In Development perspective, the main view provides a set of tabs for setting plug-in properties and options.
The Eclipse functionality (extension) for supporting cheat sheets isn't checked for by default. Before you can create a cheat sheet, you have to specify that the cheat sheet has a dependency on that extension. To add the cheat sheet extension to your project, click on the Extensions tab at the bottom of the view. Click Add.
Then from the New Extension dialog, be sure that the Show only extension points from the required plug-ins option is disabled. Click on org.eclipse.ui.cheatsheets.cheatSheetContent, and click Finish (see Figure 5).
You will be asked to confirm that you want to add this extension point as a plug-in dependency. Click Yes to confirm.
All the cheat sheets that you create will be grouped together into a category (top-level grouping). To create the category, from the Extensions tab, right-click on the Cheat Sheet extension, and choose New > category, as shown here.
Figure 6. New category
A new category will appear, and you can customize the settings. Be sure to specify the category name value because that will be the name that will appear in Eclipse describing the category.
Make note of the id because you will need to specify that ID string in the definitions of your cheat sheets.
To add a cheat sheet, right-click on the Cheat Sheet extension on the Extensions tab, and choose New > Cheat Sheet.
Be sure to specify the name of your cheat sheet, the category ID of your category, and the name of the XML file that contains the cheat sheet content.
Repeat this step for each cheat sheet that you wish to add to the category.
At this point, you've created the content for your cheat sheet and you've done the virtual plumbing to make a cheat sheet visible in Eclipse.