- Click Ctrl+N to open the New wizard.
- Select Plug-in Project and click Next.
com.ibm.pltein the Project name text field and click Next.
- Answer Yes to the question "Would you like to create a rich client application?" Click Next.
- Select Hello RCP template and click Finish.
- The Open Associated Perspective dialog box may pop up. Click Yes.
Your workbench should look similar to the following:
Figure 1. Plug-in com.ibm.plte's plugin.xml in the PDE perspective
The Hello RCP template is very powerful and performs many tasks behind the scenes. The template generates a plug-in project, and adds two extension points and six Java classes. Each extension point and Java class is described below.
Table 2. Description of artifacts generated by Hello RCP template
|org.eclipse.core.runtime.applications||This extension point tells the Eclipse runtime the name of your main program and the class that implements |
Note that since the Eclipse IDE is an RCP application, it also defines this extension point. In the Eclipse IDE, the application name is org.eclipse.ui.ide.workbench, and the class is org.eclipse.ui.internal.ide.IDEApplication.
|A perspective is a set of visible views, editors, and menus that include positions and sizes. In an RCP application, you must define at least one perspective and make it the default. Perspectives are created by implementing |
|PltePlugin.java||This class is referred to as the plug-in class. An optional singleton class can be used to store global information for the plug-in. It is also a convenient place to put static utility functions used by other classes in the plug-in.|
|Application.java||Application.java is a class that acts as the RCP application's main routine. It is similar to a Java class with |
The workbench is declared and maintained as part of the RCP framework. There is only one workbench, but it can have more than one visible top-level workbench window. For example, in the Eclipse IDE, when you first start Eclipse, you will see one workbench window, but if you select Window > New Window, a second window pops up. So now there are two workbench windows, but only one workbench.
|There are three advisor classes used to configure all aspects of the workbench, such as the title, menu bars, and so on. These are the most important classes for an RCP developer to understand. You extend the base version of the class -- for example, WorkbenchAdvisor -- in the RCP application and override one or more of the methods to set whatever options you want. See product documentation for details.|
Make sure the overview page of the com.ibm.plte (plugin.xml) editor is open. Click Launch an Eclipse application from the Testing section. Your minimal Hello World RCP application should look like what is shown below.
Figure 2. Minimal RCP application
In two simple steps, you created and ran a minimal RCP application. At this point, the RCP application contains a single perspective, but no other Eclipse functions (no menus, actions, views, preference pages, Help books, etc.). You will add these functions as you continue.
Menus and actions can be added in two ways. Here, we add them to the RCP application programmatically. Later, you will add them via extension points.
Five menus are added:
- Window/Open perspective
- Window/Show view
And six actions are added:
- Window/Open perspective/Other
- Window/Show view/Other
- Help/Help contents
The actions you add here are pre-built actions normally included in the Eclipse IDE. However, the RCP provides them for your convenience. To understand how these menus and actions are defined, look at ApplicationActionBarAdvisor.java in the com.ibm.plte.help feature project. Note that using the actions framework, you can contribute your own actions. You will do this using extension points later.
Steps to take:
- Replace the com.ibm.plte plug-in's com.ibm.plte.ApplicationActionBarAdvisor.java with a file having the same name from the com.ibm.plte.help feature project.
- Ensure that you closed the RCP application you launched previously. Go back to the overview page of the com.ibm.plte (plugin.xml) editor and click Launch an Eclipse application from the Testing section. Your RCP application should have several menus.
Figure 3. RCP application with some menus
- Click Window > Open Perspective > Other. In the Select Perspective dialog box, you will see one perspective labeled Plte Perspective (default). This is the perspective you created using the Hello RCP template.
- Click Window > Show View > Other. You should see an empty Show View dialog box. This is because you have not added any views to the RCP application yet. We do this in the next section.
- Click Window > Preferences. You should see an empty Preferences dialog box. This is because you have not added any preferences to the RCP application yet. We do this in the next section.
- Click Help > About. The About dialog box will be empty, except for three buttons. The About dialog box gives information about the set of features and plug-ins installed in your RCP application. Since you have not added any features yet, the dialog box is empty.
- Click Plug-in Details. The dialog box will show the complete list of plug-ins that are part of this RCP application. We will see the 10 RCP plug-ins, plus the single plug-in we created.
- Click on com.ibm.plte plug-in in this dialog box and notice that the More Info button is disabled. More Info provides additional information about the plug-in. If you want to provide additional information about your plug-in(s), you need to add it in an about.html file. We do this in the next step.
Figure 4. Plug-ins included in the Hello World RCP application
The one action we did not execute is Help > Help Contents. This requires a number of Help plug-ins not included in the Hello World RCP application. Therefore, this action will not run until the necessary Help plug-ins have been added. We do this in the next section.
Here, you provide information about a plug-in via its about.html file:
- Move about.html from the com.ibm.plte.help feature project to the com.ibm.plte plug-in.
- Ensure that you closed the RCP application launched previously. Go back to the overview page of the com.ibm.plte (plugin.xml) editor and click Launch an Eclipse application from the Testing section.
- Click Help > About.
- Click Plug-in Details.
- Select the com.ibm.plte plug-in. The More Info button should be enabled.
- Click More Info, and about.html will open in a browser.
Figure 5. The com.ibm.plte plug-in's description