Building Cheat Sheets in Eclipse
Pages: 1, 2, 3, 4

Step 2: Create a Cheat Sheet XML File

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 <b></b> and <br />.

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.

Step 3: Define the Cheat Sheet Properties

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.

Step 3.1 Add the cheat sheet extension to your project

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).

Figure 5
Figure 5. Create a new extension (click the image for a full-size screen shot)

You will be asked to confirm that you want to add this extension point as a plug-in dependency. Click Yes to confirm.

Step 3.2. Add a category for your cheat sheets

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
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.

Figure 7
Figure 7. Extension element details (click the image for a full-size screen shot)

Make note of the id because you will need to specify that ID string in the definitions of your cheat sheets.

Step 3.3. Add your cheat sheet to the category (once for every cheat sheet)

To add a cheat sheet, right-click on the Cheat Sheet extension on the Extensions tab, and choose New > Cheat Sheet.

Figure 8
Figure 8. New cheat sheet (click the image for a full-size screen shot)

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.

Pages: 1, 2, 3, 4

Next Page ยป