Eclipse plugin and RCP development notes
This page contains my Eclipse plugin and RCP development notes. I am not developing Eclipse plugin often enough to stay current so this should help me to get re-started with Eclipse plugin development.
I use Diigo to store my links about Eclipse here.
Eclipse Plugins
For Eclipse plugin development I strongly recommend the book Eclipse Plug-ins (third edition), get the book or at least install the examples and use them for development! You can download/install the examples from the update site and Open the QualityEclipse Book Samples View and load the appropriate chapter project. Additional code examples can be found here.
Learn form mistakes here is Top 10.
Check the official Plugins Development documentation, FAQ and the API Reference. Use Plug-In Spy by selecting en Eclipse window (view, editor,…) ore resource (file, project) and pressing Alt-Shift F1. The popup window will display information about the contributing plug-in and much more; click on the links to learn more! Since Eclipse 3.5 Plug-In Spy can be used to explore menus by pressing Alt-Shift-F2, see second part of this excellent blog.
Check following tutorials:
- Eclipse Plugin Development – Tutorial for Eclipse 3.5 (Galileo)
- Plug-in Development 101: The Fundamentals
- Eclipse Plugin Development Tutorial website
- Understanding how Eclipse plug-ins work with OSGi
- Introduction to Eclipse Plugin Architecture
- Recommended Eclipse reading list
- Creating an Eclipse View (old, but still useful)
- Contributing a Little Help (old, but still useful)
- Eclipse Extension Points and Extensions – Tutorial
- Eclipse Commands – Tutorial
- Getting Started with Equinox and OSGi
- Eclipse Articles
- SWT
- SWT Documentation
- Understanding SWT layouts
- SWT and JFace part1, part2, part3, part4
- The JFace of Eclipse
- Viewing HTML pages with SWT Browser widget
- How to use the JFace Tree Viewer
- Building tables made easy
- Eclipse Forms
You will need some Eclipse compliant icons for plugin development, here are some:
To leverage Eclipse SDK and use plugins/tools already available in Eclipse, you need to know extension point, here is the documentation.
To learn how to use JFace Views you can use Eclipse JFace TableViewer – Tutorial . To learn how to use wizards, check Creating JFace Wizards.
To learn how to use Eclipse Preferences and Preference Pages you can use Eclipse Preference.
Good background information on internationalizing plug-ins can be found in the Eclipse Foundation’s articles “How to Internationalize your Eclipse Plug-In“, “How to Test Your Internationalized Eclipse Plug-In” or here.
Pay attention to plugin activation. Eclipse plugins are by default lazily initialized (only when needed), see check “Activate this plugin when one of its classes is loaded” on plugin editor Overview page. You plugin activator, usually subclass of AbstractUIPlugin start() method is only called when the plugin is activated, so if you store static reference to plugin like:
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
public static PluginActivator getDefault() {
return plugin;
}
getDefault() method can return null if referenced before the plugin is activated (for example from your perspective that is restored form workspace instead of created from the perspective factory).
Eclipse plugins menus are implemented using Actions (older) or Commands, check following links:
Four good articles by Prakash G.R.:
- Commands Part 1: Actions Vs Commands
- Commands Part 2: Selection and Enablement of IHandlers
- Commands Part 3: Parameters for Commands
- Commands Part 4: Misc items …
- Commands Part 5: Authentication in RCP applications
- Commands Part 6: Toggle & Radio menu contributions.
and the standard set of references:
Credit for links to How to Eclipse Commands blog.
Eclipse Menu Contributions are documented here. If you use Commands you will probably have to use custom property testers to set command visibility visibleWhen and/or handler active state activeWhen and enabled state enabledWhen. To learn more check great screencast from Robert Konigsberg. You will need to declare command handlers, the class org.eclipse.ui.handlers.HandlerUtil provides several convenience methods useful from within the handler execute() method.
Note. Eclipse Search menu (org.eclipse.search.menu) doesn’t support Command contributions, so you cannot use org.eclipse.ui.menus extension point to make Search menu contribution. You have to use action sets and org.eclipse.ui.actionSets extension point and use menubarPath org.eclipse.search.menu/dialogGroup (for example) for your action.
If you wish to contribute to already existing Eclipse menus, you will have to make menu contributions. Check Eclipse Plugins Exposed page 1, page 2.
If you need to take a look at Eclipse source, here is Eclipse CVS Howto. I highly recommend to put the repository :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse into Eclipse CVS perspective, and use the repository (directly without downloading the source code projects) to explore Eclipse source code.
Extension points and Extensions
Adding an extension point (publish extension) and load (consume) the extensions defined by the extension is a fairly involved and not very well documented procedure.
Old way to load extensions was static and usually happened only while your plugin was being loaded. New approach uses IExtensionChangeHandler to load or remove the extension during the lifetime of your plugin. See the article OSGi, Dynamics and Eclipse « EclipseSource Blog for excellent explanation how to dynamically add/load or remove extensions based on your extension point.
Tips, Tricks and Howto
Following notes contain small code howto snippets useful for Eclipse plugin development :
- To get all projects in workbench:
IProject[] projects = ResourcePlugin.getWorkspace().getRoot().getProjects();
- To get Eclipse installation configuration location:
Location loc = Platform.getConfigurationLocation();
- If you need to create and write into console view, check “How do I write to the console from a plug-in“? Here is some code:
public static MessageConsole findConsole(String name) {
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
for (int i = 0; i < existing.length; i++)
if (name.equals(existing[i].getName()))
return (MessageConsole) existing[i];
//no console found, so create a new one
MessageConsole myConsole = new MessageConsole(name, null);
conMan.addConsoles(new IConsole[]{myConsole});
return myConsole;<br /> }
public static void writeToConsole(String message) {
MessageConsole myConsole = findConsole(CONSOLE_NAME);
MessageConsoleStream out = myConsole.newMessageStream();
out.println(message);
// Make console visible
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IConsoleView view = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
view.display(myConsole);
} catch (Exception e) {
Log.logError("Unable to display Console View", e);
}
}
- If you need to listen to resource changes check the article Responding to resource changes in the Eclipse workspace.
- To learn about Project Builders and Natures, read article Project Builders and Natures, and check Eclipse Builder and Nature Documentation.
- If you need to handle selection, check Use the Selection Service
Eclipse RCP
To get started with Eclipse RCP development you should install Eclipse RCP delta pack to support multiple platforms, here are some useful links:
- Using deltapack in Eclipse 3.5
- Installing deltapack for Eclipse
- Creating an Eclipse RCP 3.5 target platform
- DZone Refcard – Programming Eclipse RCP
Note, do not unzip deltapack directly into Eclipse install, use Eclipse/Preferences/PDE Development as described in Using deltapack in Eclipse 3.5.
Review the older but still very useful Eclipse RCP tutorial from Ed Brunette:
Another useful RCP tutorials:
- Eclipse RCP – Tutorial with Eclipse 3.5 (Galileo)
- Plug-in development 101, Part 2: Introducing Rich-Client Applications
- Building RCP application
- Rich clients with the SWT and JFace
- SWT and JFace part1, part2, part3, part4
- Spring OSGi + Eclipse RCP
And check the official Eclipse RCP web site RCP FAQ.
If you need to create a welcome page for your RCP application read “Get to know Eclipse User Assistance.”
Debugging and testing Plugin or RCP
You can run or debug the plugin or RCP application from the Overview tab of the plugin or RCP. It will create a launch configuration if it doesn’t exist. If you need to start from scratch, you can reset the workspace before the launch. To do that, check Clear workspace (on Main tab). Optionally, you can check “Clear the configuration area before launching” in Configuration tab.
Make sure you have -consoleLog as a Program Argument in your launch configuration. You may also want to take a look at these runtime tools.
Building plugins, features
Automated build of plugins and features without Eclipse IDE is challenge task. Check bottom of this blog and P2 Publisher (new in Eclipse 3.5).
Adding Update Support
There is a great tutorial Adding Self-Update to an RCP Application at Eclipse Wiki. You can also check EclipseSource Equinox p2 website and Eclipse p2 website.

4 Comments »
Leave a comment
-
Recent
- Explanation how to dynamically load or remove extensions based on extension point
- Eclipse 3.5 Treasures
- How I lost and found Mylyn with Eclipse 3.4 and how Yoxos saved me
- Working with the Eclipse FileSystem …
- EclipseZone – SWT: The Newly Available DateTime …
- Why I Converted to SWT
- Eclipse Plugins I use to extend Eclipse IDE functionality
- Introduction: Eclipse Test and Performance Tools Platform
- Eclipse project information management
- EclipseZone – Remove Clutter by Compressing Package Names
- NEW: Metrics plugin 1.3.6 for eclipse 3.1
- Code review plugin
-
Links
-
Archives
- July 2009 (2)
- July 2008 (1)
- November 2006 (2)
- September 2006 (1)
- March 2006 (1)
- February 2006 (1)
- November 2005 (1)
- August 2005 (1)
- July 2005 (1)
- February 2005 (1)
- January 2005 (2)
- December 2004 (7)
-
Categories
-
RSS
Entries RSS
Comments RSS
[...] the delta pack is slightly different, and is described by Andrew Niefer (via Lubos’s excellent list of Eclipse plugin and RCP development [...]
Pingback by Installing the RCP Delta Pack for Eclipse « Eclipse, Java and more | July 9, 2009 |
Thanks for the link to my delta pack post, which I’ve updated to link to Andrew Niefer’s “Using deltapack in Eclipse 3.5″ post.
This is a great list of resources; thanks very much!
Thanks. Nice collection of articles.
Thanks, Lars,
you deserve credit for quite a few of them, you have created quite a few very useful tutorials! I use them a lot to refresh my knowledge of Eclipse plugin/RCP development! Great job!