<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><HTML> | |
<HEAD> | |
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> | |
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> | |
<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css"> | |
<title>German fragment example</title> | |
</head> | |
<BODY BGCOLOR="#ffffff"> | |
<h2>Example: Writing a German fragment for XYZ Plug-in</h2> | |
<p>The PDE wizards and editors that manipulate plug-ins and fragments are nearly the | |
same. However, you must be aware of some important differences.</p> | |
<p>We start by creating a new fragment project. </p> | |
<p>On the first page of the New Fragment Wizard, type the project name "<b>com.example.german</b>." | |
Press <b>Next</b> and accept the default values of the second page. (Press | |
<b>Next</b> again.) On the "Fragment Code Generators" page, | |
choose the radio button for creating a fragment from a template and select the | |
"Default Fragment Generator" wizard. After pressing <b>Next</b>, | |
you should see the "Simple Fragment Content" page.</p> | |
<p>This page looks a little different from | |
the plug-in wizard since it has two additional fields: target plug-in id and | |
version. Since we are writing a fragment for a specific plug-in, we can use the <b>Browse</b> button | |
to select | |
"XYZ Plugin" from the "Workspace Plug-ins" group (we | |
could also pick any of the external plug-ins).</p> | |
<p align="center"> | |
<img border="0" src="images/fragment-content.gif" alt="Fragment example - sample fragment content page" width="500" height="500"></p> | |
<p align="left">Once the project is created, it opens the fragment manifest | |
editor.</p> | |
<p align="center"> | |
<img border="0" src="images/fragment-overview.gif" alt="Fragment example - manifest overview" width="545" height="507"></p> | |
<p align="left"> | |
It is almost identical to plug-in manifest editor with the following exceptions:</p> | |
<ol> | |
<li> | |
In the Overview page, the "class" attribute is gone. | |
Fragments do not have a plug-in class since they follow the life cycle of | |
their target plug-in. Instead, the target plug-in id and version | |
fields are shown.</li> | |
<li> | |
A drop-down combo box allows precise definition of the plug-in reference | |
(perfect, compatible, equivalent etc.).</li> | |
</ol> | |
<p align="left">We will add a similar action set as in the plug-in example, but | |
this time in German.</p> | |
<ol> | |
<li>Go to the Extensions page in the fragment manifest editor. | |
Press <b>Add</b> to launch the Extension wizard.</li> | |
<li>Select "Generic Wizards" and "Schema-based extension". | |
Press <b>Next</b>.</li> | |
<li> Select "Actions Sets" from the list of extension | |
points. Press <b>Finish</b>.</li> | |
<li>Select the new action set. Select <b>New->actionSet</b> from the popup | |
menu.</li> | |
<li>Move to the property sheet and change the <b>label</b> property to | |
"Deutsche Aktionsmenge."</li> | |
<li>Move to the "Extension Element Children" section and select <b>New->menu</b> | |
from the popup.</li> | |
<li>Change the <b>label</b> property of the menu to "Beispiel Menu" | |
and the <b>id</b> property to "beispielMenu."</li> | |
<li>Select the menu element again and choose <b>New->separator</b> from | |
the popup menu. Change its name in properties to "beispielGruppe" | |
and save it.</li> | |
<li>Create a new "action" element (similar to step 6). Set the <b> label</b> | |
property to "Beispiel Aktion." Set the <b> menubarPath</b> to "beispielMenu/beispielGruppe."</li> | |
<li>Select the <b>class</b> property for editing and bring up the cell editor | |
dialog. Select the "Generate a new class" radio button.</li> | |
<li>Browse for the class container and select the "GERMAN Fragment" | |
folder in the "com.example.german" project.</li> | |
<li>Change the class name to "DeutscheBeispielAktion". Press <b>Finish</b>.</li> | |
<li>When the Java editor with the new class opens, find the "run" method and | |
add the following:</li> | |
</ol> | |
<font color='#4444CC'><pre> System.out.println("Hallo, PDE welt!"); | |
</pre></font> | |
<p>Save and close the Java editor and fragment manifest editor.</p> | |
<p align="left">When you run the fragment using the "Run" tool bar | |
button, the run-time platform instance should have the "Deutsche Aktionsmenge" | |
action set available. (Use <b>Window->Customize Perspective...->Other</b> to | |
get to the list of action sets). When you activate the action set, the "Beispiel | |
Menu" menu should | |
appear on the tool bar. When you select its menu item, you should see | |
"Hallo, PDE welt!" in the Console. The runtime platform didn't | |
see the German fragment directly. Instead, its plug-in registry resolved | |
fragment references in such a way that the fragment's action set appeared to the | |
platform as though it came directly from the XYZ Plug-in.</p> | |
<p> <br> | |
<a href="../hglegal2003.htm"> | |
<img src = "../images/ngibmcpy2003.gif" alt="Copyright IBM Corporation and others 2000, 2003" border="0" width="324" height="14"></a> | |
</p> | |
</body> | |
</html> |