blob: da84a256fa57d161ca68862915686a367eec02e8 [file] [log] [blame]
<!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.&nbsp; However, you must be aware of some important differences.</p>
<p>We start by creating a new fragment project.&nbsp;&nbsp;</p>
<p>On the first page of the New Fragment Wizard, type the project name &quot;<b>com.example.german</b>.&quot;&nbsp;
Press <b>Next</b> and accept the default values of the second page.&nbsp; (Press
<b>Next</b> again.)&nbsp; On the &quot;Fragment Code Generators&quot; page,
choose the radio button for creating a fragment from a template and select the
&quot;Default Fragment Generator&quot; wizard.&nbsp; After pressing <b>Next</b>,
you should see the &quot;Simple Fragment Content&quot; 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
&quot;XYZ Plugin&quot; from the &quot;Workspace Plug-ins&quot; 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 &quot;class&quot; attribute is gone.&nbsp;
Fragments do not have a plug-in class since they follow the life cycle of
their target plug-in.&nbsp; 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&nbsp; the Extensions page in the fragment manifest editor.
Press <b>Add</b> to launch the Extension wizard.</li>
<li>Select &quot;Generic Wizards&quot; and &quot;Schema-based extension&quot;.
Press <b>Next</b>.</li>
<li> Select &quot;Actions Sets&quot; from the list of extension
points. Press <b>Finish</b>.</li>
<li>Select the new action set. Select <b>New-&gt;actionSet</b> from the popup
menu.</li>
<li>Move to the property sheet and change the <b>label</b> property to
&quot;Deutsche Aktionsmenge.&quot;</li>
<li>Move to the &quot;Extension Element Children&quot; section and select <b>New-&gt;menu</b>
from the popup.</li>
<li>Change the <b>label</b> property of the menu to &quot;Beispiel Menu&quot;
and the <b>id</b> property to &quot;beispielMenu.&quot;</li>
<li>Select the menu element again and choose <b>New-&gt;separator</b> from
the popup menu. Change its name in properties to &quot;beispielGruppe&quot;
and save it.</li>
<li>Create a new &quot;action&quot; element (similar to step 6). Set the <b> label</b>
property to &quot;Beispiel Aktion.&quot; Set the <b> menubarPath</b> to &quot;beispielMenu/beispielGruppe.&quot;</li>
<li>Select the <b>class</b> property for editing and bring up the cell editor
dialog. Select the &quot;Generate a new class&quot; radio button.</li>
<li>Browse for the class container and select the &quot;GERMAN Fragment&quot;
folder in the &quot;com.example.german&quot; project.</li>
<li>Change the class name to &quot;DeutscheBeispielAktion&quot;. Press <b>Finish</b>.</li>
<li>When the Java editor with the new class opens, find the &quot;run&quot; method and
add the following:</li>
</ol>
<font color='#4444CC'><pre> System.out.println(&quot;Hallo, PDE welt!&quot;);
</pre></font>
<p>Save and close the Java editor and fragment manifest editor.</p>
<p align="left">When you run the fragment using the &quot;Run&quot; tool bar
button, the run-time platform instance should have the &quot;Deutsche Aktionsmenge&quot;
action set available.&nbsp; (Use <b>Window-&gt;Customize Perspective...-&gt;Other</b> to
get to the list of action sets). When you activate the action set, the &quot;Beispiel
Menu&quot; menu should
appear on the tool bar. When you select its menu item, you should see
&quot;Hallo, PDE welt!&quot; 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>&nbsp;<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>