Eclipse

Building Cheat Sheets in Eclipse

_침묵_ 2006. 9. 15. 19:45

출처 :http://dev2dev.bea.com/pub/a/2006/08/eclipse-cheat-sheets.html

 

Published ondev2dev(http://dev2dev.bea.com/)
 http://dev2dev.bea.com/pub/a/2006/08/eclipse-cheat-sheets.html
 See thisif you're having trouble printing code examples

Building Cheat Sheets in Eclipse

byHarriett HardmanandSteve Hanson
08/23/2006

Abstract

Eclipse provides a built-in mechanism for displaying mini-tutorials calledcheat sheets. Cheat sheets are quick-and-dirty instructions for how to perform multi-step processes in Eclipse, displayed on the side of the workbench where you can quickly and easily step through them.

This tutorial demonstrates how to construct cheat sheets for Eclipse. As a result, they'll also run on BEA Workshop Studio and BEA Workshop for WebLogic—and any other Eclipse ecosystem, perhaps complementing your existing tools and plug-ins. The sample download provides three ready-to-use cheat sheets, including a cheat sheet for how to build your own cheat sheets.

Introduction

Eclipse provides native support for a nifty little feature, cheat sheets, which provide quick instructions for standard but detailed tasks. To display the available cheat sheets in your Eclipse installation, clickHelp > Cheat SheetsorWindow > Show View > Other > Cheat Sheets > Cheat Sheets > OK.

Cheat sheets appear as a view on the right side of the workbench, making it easy to simultaneously read and execute the cheat sheet instructions. Here's an example:

사용자 삽입 이미지

Figure 1. Cheat sheet view

Cheat sheets are intended to guide you through a process, so as you complete each step of the cheat sheet, you click on the icon at the bottom of the step and the next step opens automatically. The?icon allows you to open a help page that relates to that step of the cheat sheet.

You can use cheat sheets provided by others or you can create your own. Cheat sheets are an ideal way to let everyone on the team know how to do standard yet infrequent operations like accessing in-house APIs or connecting to legacy applications. The things that you have written down as a set of steps on a sticky note are candidates for making a cheat sheet. Cheat sheets are stored in JAR files that you can easily share with others.

As you may expect, Eclipse also provides simple tools for assembling cheat sheets as plug-in and dropping the resulting JAR file into your current installation. In a nutshell, you can create as many cheat sheets (each in their own XML file) as you want within a plug-in project, and then export them as a JAR and drop them into your localeclipse/plug-insfolder.

You can create cheat sheets in any instance of Eclipse that has plug-in development features enabled, such as BEA Workshop for WebLogic 9.2.

Writing Your Own Cheat Sheet

This tutorial guides you through making a cheat sheet in Eclipse, from start to finish. In summary, you have to execute the following steps:

  • Set up a project for creating your cheat sheet files.
  • Create an XML file that contains the cheat sheet text.
  • Define the cheat sheet properties.
  • Export the cheat sheet into a JAR file.
  • Copy the JAR file to the Eclipse folder.
  • Access your cheat sheet.

The steps are all pretty simple. Open up your Eclipse and let's begin.

Step 1: Set Up a Project for Creating Your Cheat Sheet Files

To begin, choose File > New > Project and from the New Project wizard, expand Plug-In Development, and choose Plug-in Project, as shown in Figure 2. When using BEA Workshop for WebLogic 9.2, you must click the Show All Wizards option to see these project types.

사용자 삽입 이미지

Figure 2. Create a plug-in project

On the next dialog, specify the project name. Be sure to uncheck the Create a Java project option, as shown in Figure 3. For more complex cheat sheets that invoke Java actions, you may have to enable this option. For simple text-only cheat sheets that do nothing more complex than launch a wizard, you don't need to create a Java project.

사용자 삽입 이미지

Figure 3. New plug-in project

On the next dialog, fill in the provider field with your name or company name (see Figure 4). Click Finish to create the project.

사용자 삽입 이미지

Figure 4. Plug-in content

You'll also be prompted to switch to Plug-in Development perspective, and you should click Yes to do that.

At this point you will have created an empty cheat sheet project. You are now in a position to start filling in the content.

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

A new category will appear, and you can customize the settings. Be sure to specify the categorynamevalue because that will be the name that will appear in Eclipse describing the category.

사용자 삽입 이미지

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

Step 4: Export the Cheat Sheet JAR File

To use your cheat sheet, you must export it as a JAR and copy the JAR to the Eclipse plug-ins directory where it will be found next time Eclipse is started.

Before exporting, be sure all of your cheat sheet XML files are included in the build by clicking on the Build tab and making sure the Binary Build section has all your XML files checked. Be sure everything is selected except.projectandbuild.propertiesas these are related to the Eclipse plug-in project structure, not to the cheat sheet content.

Also, select File > Save All to be sure all your files and settings are saved.

To create the cheat sheet JAR file, from the Overview tab, click on the Export Wizard link. All you need to do is specify the directory where the JAR file should be located and click on the Package plug-ins as individual JAR archives option. Click Finish to do the export, as shown in Figure 9.

사용자 삽입 이미지

Figure 9. Export the JAR

Step 5: Copy the JAR File into Your Eclipse Plug-Ins Folder

For Eclipse users, copy the JAR file into the ECLIPSE_HOME/plugins folder.

For BEA Workshop for WebLogic 9.2, drop the JAR files into WORKSHOP_HOME/workshop92/workshop4WP/eclipse/plugins.

For Workshop Studio, the JAR files go into STUDIO_HOME/Workshop/eclipse/plugins.

Now restart Eclipse so that the cheat sheet JAR file will be found.

Step 6: Access the Cheat Sheet

Click Help > Cheat Sheets to display the Cheat Sheets view.

If the Help > Cheat Sheets command is not available, click Window > Show View > Other, and choose Cheat Sheets > Cheat Sheets. Click OK. You can now open your cheat sheets by clicking on the pull-down menu at the top of the Cheat Sheet view and choosing Launch Other. Your cheat sheet category will appear in the list of groups, and you can expand your category and choose your cheat sheet.

Download

To get you started we've also provided downloadable JARs with a couple of sample cheat sheets plus our favorite: How to Make a Cheat Sheet cheat sheet:

Summary

This tutorial provides the basic steps for creating a cheat sheet. In truth, there's not a lot more to say. Cheat sheets don't provide extensive formatting options, since they're just intended to guide you through a series of steps. The one point that we didn't discuss is how to have a cheat sheet launch a wizard (for example, to create a new project) or some other action in Eclipse. We'll publish more on this later if there's enough interest.

References

Harriett Hardmanis a senior technical writer working for BEA on the Workshop documentation team.

Steve Hansonis a senior technical writer for BEA Systems on the Workshop documentation team.


Return todev2dev.