<!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. 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 Project wizard, type the project name | |
"com.example.german". 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 "com.example.xyz" 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 "org.eclipse.ui.actionSets" 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>In the Extension Element Details section, change the <b>label</b> property to | |
"Deutsche Aktionsmenge."</li> | |
<li>In the All Extensions section, right-click on the new action set 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 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>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 "DeutscheBeispielAktion". Press <b>Finish</b>.</li> | |
<li>When the Java editor with the new class opens, find the "run" method and | |
add the following: | |
<p style="color:#4444CC; position:relative; left:40px;"><code>System.out.println("Hallo, PDE welt!"); | |
</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 "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> | |
</body> | |
</html> |