| Java, Eclipse and Web programming Tutorials |
Version 2.3
Copyright © 2009 - 2010 Lars Vogel
01.03.2010
| Revision History | ||
|---|---|---|
| Revision 0.1 - 0.6 | 23.05.2008 | Lars Vogel |
| Created Article | ||
| Revision 0.7 | 18.02.2009 | Lars Vogel |
| Added CVS access | ||
| Revision 0.8 | 03.05.2009 | Lars Vogel |
| Plugin Spy for menus (Eclipse 3.5) | ||
| Revision 0.9 | 29.05.2009 | Lars Vogel |
| Updated to Eclipse 3.5 | ||
| Revision 1.0 | 01.06.2009 | Lars Vogel |
| Added cvs details in table | ||
| Revision 1.1 | 06.07.2009 | Lars Vogel |
| Added cvs details in table | ||
| Revision 1.2 | 09.07.2009 | Lars Vogel |
| How to get commandsId for keybindings | ||
| Revision 1.3 | 17.07.2009 | Lars Vogel |
| Improved cvs section, adding how to access Eclipse PDE cvs repository | ||
| Revision 1.4 | 26.07.2009 | Lars Vogel |
| plugin search, new introduction | ||
| Revision 1.5 | 29.07.2009 | Lars Vogel |
| How to use Mylyn to connect to Bugzilla | ||
| Revision 1.6 | 09.08.2009 | Lars Vogel |
| Improved cvs description | ||
| Revision 1.7 | 10.11.2009 | Lars Vogel |
| Added Project Set Files for cvs access | ||
| Revision 1.8 | 17.11.2009 | Lars Vogel |
| Removed redundant plugin search capter, general rework of the Article. | ||
| Revision 1.9 | 03.01.2009 | Lars Vogel |
| Added WTP cvs repository | ||
| Revision 2.0 | 04.01.2010 | Lars Vogel |
| get the source code via git | ||
| Revision 2.1 | 06.01.2010 | Lars Vogel |
| added SWT spy | ||
| Revision 2.2 | 13.01.2010 | Lars Vogel |
| Added CVS web respository | ||
| Revision 2.3 | 01.03.2010 | Lars Vogel |
| Simplified CVS chapter | ||
Eclipse Source Code Guide
This article describes how to access the Eclipse source code, search for plugins or code, demonstrates the usage of the "Plugin Spy" and how to debug the Eclipse IDE.
This article assumes that you are already familiar with using the Eclipse IDE and is based on Eclipse 3.5 (Eclipse Galileo).
Table of Contents
Often you need to change or extend Eclipse functionality. This guide try to help getting into the Eclipse source code.
In additional to this developers are frequently advised to read existing high-quality code. Having easy access to the Eclipse sources can be extremely helpful in familiarizing yourself with the coding patterns inherent in Eclipse
Eclipse is a powerful, extensible IDE for building general purpose applications. Some of the key player in creating Eclipse are also well known for their software architecture skills. So you can learn a lot from the Eclipse code base.
The Eclipse code base can be imported directly from your installed Eclipse version or can be access via the cvs or svn version control system. The article describes both approaches.
The following describes how you can import Eclipse plugins from your Eclipse installation to review the code.
Select File -> Import. Select "Plug-ins and Fragments".

Make the following settings.

Add all plugins you would like to import and press "Finish". In my example I import only "org.eclipse.ui.intro".

You can you investigate the code of the imported plugins.
The Plugin Spy gives you easily information about the running UI. Press Alt+Shift+F1 to get information about the current running Eclipse plugin / data types / screen. This way you can get immediately access to the plugin which is currently running.

Click on the active class or the contributing plugin to get to the class or the source code of the class.
Eclipse 3.5 introduced the possibility to check which plugin contributed a menu. Press "Alt + Shift + F2" and select a menu to see who is contributing this menu.

SWT spy for Eclipse is a tool that prints out information about the widget under the cursor. Currently, this includes style, layout and parent information.
See here for more information SWT Tools .
Plugin Search allow you to search for extension points declaration and usage.
Select from the menu Search -> Search and then the tab "Plug-in Search". For example the following will search for all declaration (defining an extension) to the extension point "org.eclipse.debug.core.launchConfigurationTypes".

Eclipse allows to trace a running Eclipse and to write information to the console. This can be used to identify which command is associated with a certain keybinding.
To use this create a runtime configuration which contains the Eclipse plugins you are interested in, e.g. include "org.eclipse.ui" and press add required plugins.
In the "Run Configuration" switch to the "Tracing" tab and set "Enable Tracing". Select the "org.eclipse.ui" plugin. Flag "debug".

Scroll down and select "trace/keybindings" and "trace/keybindings.verbose".

Make sure you have the -consoleLog flag maintained as an argument.

If you start now the Eclipse IDE then everytime you use a shortcut the calling Eclipse will display a trace which contains the commandId.

In your calling Eclipse you can now use Search (text) to find the handler / action which implements this command.
You can also debug the Eclipse IDE if you want to see how certain things are done. Use for example the Plugin Spy to find the class / plugin which you would like to invest. Put a breakpoint into the coding, for example in the constructor of the class or if the class shows UI elements "createPartControl". Create a Run Configuration which includes all Eclipse IDE plugins and run it.


If you now select Run -> Debug for your runtime configuration you can start debugging the interesting point.

Eclipse projects can use cvs and svn as version control system. The majority of the project still uses cvs. Downloading the source code from a version control system is called "checkout".
To access the Eclipse CVS repositories open the "CVS Repositories" view via Window -> Show View -> Other -> CVS -> CVS Repositories
Create a repository by right clicking in the view and selecting "New" -> "Repository Location".

Copy the following string and paste it into the CVS view to create a new repository.
:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse
You can check the created properties via right-mouse click on the entry -> Properties

Now can you browse the structure and check out code. Check out will create a local copy of the selected path into your workspace.

Not all Eclipse projects are in the same path. For example here are some connection strings.
Table 1. Access to some
| Project | Description |
|---|---|
| Eclipse Main | :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse |
| Eclipse PDE CVS repository | :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse then find the folder pde |
| Eclipse Equinox CVS repository | :pserver:anonymous@dev.eclipse.org:/cvsroot/rt |
More information about cvs access can be found Eclipse cvs access

The access of Eclipse code via svn is described in Eclipse svn access . For using svn with Eclipse you need the Eclipse subversive plugin. The installation of this plugin is described in Eclipse Subversive
.Eclipse mirrors the cvs repositories into Git.
The Eclipse code is currently mainly maintained in cvs but this source code is mirrored into Git repositories.

Please see Git with Eclipse EGit - Tutorial for details on how to use the EGit plugin.
All known Eclipse bugs and feature requests are stored in a Bugzilla database Eclipse Bugs
The following explains how you could use Mylyn to work on Bugs and store your content in the bugreport.
Mylyn is a task management system and allows to store the context (source files) in a task. This way you can work on a certain task, switch to another tasks and return to the same tasks and all the files you worked on are re-opened. See the Mylyn Tutorial for installation and basic usage.
Mylyn has build in support for the Eclipse bug database. Just right click in the "Task List" view and select New -> Query

Select "Eclipse" and press Next. Select "Create query" and if you know the bug already "Create query using form".

Lets assume you want to see all bugs for Eclipse 3.6 in PDE - UI then you could maintain the following query.

If you now activate a task you can use Mylyn to work on Eclipse bugs.

Thank you for practicing with this tutorial.
Please note that I maintain this website in my private time. If you like the information I'm providing please help me by donating.For questions and discussion around this article please use the www.vogella.de Google Group. Also if you note an error in this article please post the error and if possible the correction to the Group.
I believe the following is a very good guideline for asking questions in general and also for the Google group How To Ask Questions The Smart Way.
http://www.vogella.de/code/codeeclipse.html Source Code of Examples