blob: cd350c3ce8c4fe519df9f00032d0660ebf277e53 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><HTML>
<HEAD>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<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 Project wizard, type the project name
&quot;com.example.german&quot;.&nbsp; Accept the default values and press <b>Next</b>.
</p>
<p>The <strong>Fragment Content</strong> page has three additional fields from
the plug-in creation wizard: host plug-in id, parent plug-in version, and version
match rule.</p>
<p>Since we are writing a fragment for a specific plug-in, we can use the <b>Browse</b>
button to select &quot;com.example.xyz&quot; in the plug-in selection dialog.
Using the dialog, we could have also chosen any external plug-in.</p>
<p align="center">
<img border="0" src="images/fragment-content.png" alt="Fragment example - sample fragment content page" ></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.png" alt="Fragment example - manifest overview"></p>
<p align="left"> As opposed to a plug-in, a fragment does no have a plug-in class
since they follow the life cycle of their host plug-in.</p>
<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 &quot;org.eclipse.ui.actionSets&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>In the Extension Element Details section, change the <b>label</b> property to
&quot;Deutsche Aktionsmenge.&quot;</li>
<li>In the All Extensions section, right-click on the new action set 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 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>Click on the <b>class</b> property hyperlink to generate a new class for your action.
Use "com.example.german/src" as your source folder and leave the package name blank (uses the default package).
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:
<p style="color:#4444CC; position:relative; left:40px;"><code>System.out.println(&quot;Hallo, PDE welt!&quot;);
</code></p>
</li>
<li>Save and close the Java editor and fragment manifest editor.</li>
</ol>
<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>
</body>
</html>