## Example: Writing a German fragment for XYZ Plug-in

The PDE wizards and editors that manipulate plug-ins and fragments are nearly the same. However, you must be aware of some important differences.

We start by creating a new fragment project.

On the first page of the New Fragment Project wizard, type the project name "com.example.german". Accept the default values and press Next. The "Fragment Content" page has three additional fields from the plug-in creation wizard: parent plug-in id, parent plug-in version, and version match rule.

Since we are writing a fragment for a specific plug-in, we can use the Browse button to select "com.example.xyz" in the plug-in selection dialog. Using the dialog, we could have also chosen any external plug-in.

Once the project is created, it opens the fragment manifest editor.

It is almost identical to plug-in manifest editor with the following exceptions:

1. 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 parent plug-in. Instead, the parent plug-in id and version fields are shown.
2. A drop-down combo box labelled "Match Rule" allows for precise definition of the plug-in reference (perfect, compatible, equivalent etc.).

We will add a similar action set as in the plug-in example, but this time in German.

1. Go to the Extensions page in the fragment manifest editor. Press Add to launch the Extension wizard.
2. Select "org.eclipse.ui.actionSets" from the list of extension points. Press Finish.
3. Select the new action set. Select New->actionSet from the popup menu.
4. In the Extension Element Details section, change the label property to "Deutsche Aktionsmenge."
5. In the All Extensions section, right-click on the new action set and select New->menu from the popup.
6. Change the label property of the menu to "Beispiel Menu" and the id property to "beispielMenu."
7. Select the menu element again and choose New->separator from the popup menu. Change its name to "beispielGruppe" and save it.
8. Create a new "action" element (similar to step 6). Set the label property to "Beispiel Aktion." Set the menubarPath to "beispielMenu/beispielGruppe."
9. Click on the class 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 Finish.
10. When the Java editor with the new class opens, find the "run" method and add the following:

    `System.out.println("Hallo, PDE welt!");`

11. Save and close the Java editor and fragment manifest editor.

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 Window->Customize Perspective...->Other 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.