In the
first part of this multi part tutorial i have shown you how to create the structure of the plugin and how to import and add an icon to the build configuration of your plugin. In the second part i will show you which dependency and extension you have to add to get your icon in the Masthead.
Open your plugin.xml with a double click. Go to the "Dependencies" tab and select "Add" to add a dependency.
Search for "com.ibm.rcp.ui" and select it to add it to your dependencies. You can only use functionality from the target platform for which you have created a dependency. Dependencies are a very powerful concept of the eclipse platform.
Next go to the "Extensions" tab in the plugin.xml and click "Add" to add your extension to the "ShortcutButtonSet" extension point in the "com.ibm.rcp.ui" plugin. Extension points and extensions are the mechanism which allows eclipse plugins to add functionality to existing plugins without the need to change them. If you want to know more you can find detailed information's about this topic in a very nice
tutorial from
Lars Vogel.Search for the "ShortcutButtonSet" extension point and select finish to add it to your plugin.xml
The shortcutButtonSet extension point have many values which can customize the functionality of your custom button.
Id: The unique id of your extension.
Name: The name of your extension.
Handler: This is the java class which will be called when a user clicks your icon in the masthead. We will create this class in the next step.
Image: Select the image you have imported to the plugin in the first part of the tutorial.
Show: If you select true, your icon will be visible by default in the Masthead and the user can hide it with a context action, otherwise the icon will be invisible and the user have to activate the icon in the view menu.
ContextMenuItemLabel: Label of the context action to hide the icon in the masthead.
ViewMenuItemLabel: Label of this extension in the view-> Show Shortcut Buttons menu.
Tooltip: The tooltip which should be shown when the user put the mouse over the icon.
Order: With this value you can control the position of your icon in the Masthead.
targetPersonalities: This controls in which personality of Expeditor your icon should be visible. Normally this should be always "com.ibm.rcp.platform.personality"
To create the java class which manges clicks on your icon click on the "handler*:" Label. Change the Package name to the java package in your plugin and give the Handler a name. Click "Finish" to edit your newly created class.
The class is pretty simple and have only an open method in which you check if your icon id has been clicked and if yes do what ever your action should do. In our example we want to open the ToDo Frameset of the mail database.
public class ShortcutSetHandler implements IShortcutSetHandler {
/**
* This method will be called, when the user clicks on your
* ShortcutButtonSet Icon. arg1 contains the id of the clicked icon. So one
* Handler class can manage several different Icons.
*/
@Override
public void open(int arg0, String arg1) {
// When ToDoShortcut is clicked open the Todo Framset
if ("petter.eclipse.ToDoShortCut".equals(arg1)) {
Program.launch("Notes:///0000000000000E00/ToDoFS?OpenFrameset");
}
}
}
Save the code and the plugin.xlm and start the notes client from eclipse. Be sure that your newly created plugin is selected in the launch configuration.
After Notes has been started you should see your new Action in the masthead.
If you want do add more actions to the masthead you can create one plugin for every action, or you can add additional actions to this plugin. In one of my next blog posts i will show you how to create feature, an update site and a widget for this plugin so that you can deploy your extensions to the masthead to your notes clients.
If you have problems with this tutorial, feel free to ask your questions in the comment section.