A First Look at Eclipse Plug-In Programming
3.1.3. Requires tag
The requires tag defines the dependency of the plug-in. The requires tag defines the runtime dependency of the plug-in. If the tag is not correctly defined, you might be able to compile your plug-in but not run it.
Source 4. plug-in.xml, requires tag |
<requires>![]() ![]() </requires> |
The HelloWorld plug-in depends on the org.eclipse.core.resource plug-in and
depends on org.eclipse.ui plug-in. To use the import
org.eclipse.core.resources.*
statement and the org.eclipse.ui.plugin.*
in Source 2, you need to define the plug-in IDs of these APIs in the requires tag.
We define the ID of the required plug-in in the require tag. This definition enables us to use the API classes of the plug-in. Table 2 shows the list of used APIs and plug-in IDs of the HelloWorld plug-in. The API package is the package that we import in our plug-in classes. The plug-in ID is the ID that we need to define in the requires tag. The org.eclipse.core.boot and org.eclipse.core.runtime plug-ins are special plug-ins. They are automatically defined as prerequisites of every plug-in. Therefore, their API packages are always available.
Table 2. Map of used platform plug-ins | |
API Package | plug-in id |
org.eclipse.jface[.*], org.eclipse.swt[.*], org.eclipse.ui[.*] | org.eclipse.ui |
org.eclipse.core.resources | org.eclipse.core.resources |
org.eclipse.core.boot | org.eclipse.core.boot |
org.eclipse.core.runtime, org.eclipse.core.runtime.model | org.eclipse.core.runtime |
If the requires tag is not correctly set, Eclipse might show something similar to the following error message in the console view.
Console output |
Could not create action delegate for id: de.korayguclu.eclipse.actions.SampleAction Reason: Plug-in de.korayguclu.eclipse was unable to load class de.korayguclu.eclipse.actions.SampleAction. |
3.1.4. Extension tag
An extension tag is used to extend an existing functionality of the another plug-in or Eclipse platform. The HelloWorld plug-in defines two extensions to add additional functionality to the existing extension points. The first extension defines new action sets and the
second extension is used to add
the first extension to the
default (resource) perspective.
Source 5. plug-in.xml, requires tag |
![]() <actionSet id="de.korayguclu.eclipse.actionSet" label="Sample Action Set" visible="true"> <menu id="sampleMenu" label="Sample &Menu"> <separator name="sampleGroup"/> </menu> <action id="de.korayguclu.eclipse.actions.SampleAction"> class="de.korayguclu.eclipse.actions.SampleAction" menubarPath="sampleMenu/sampleGroup" toolbarPath="sampleGroup" label="&Sample Action" icon="icons/sample.gif" tooltip="Hello, Eclipse world"> </action> </actionSet> </extension> ![]() <perspectiveExtension ![]() ![]() </perspectiveExtension> </extension> |
Conclusion
Java is strong on server platforms. Eclipse will bring Java to the desktop. Being an open source project will spread the use of Eclipse quickly. It makes it easy to improve the existing code or to adapt the existing code of the Eclipse platform.
Just like enterprise Java beans, Eclipse is a good candidate to be a container for a desktop application of the plug-in developers.
Many open source tools have been successfully used in business. Linux, Apache, JBoss, and StarOffice are examples of successful open source projects.
About the Author | |
![]() |
|
Resources
Credits
I would like to thank to Steve Gaiser for his valuable efforts in reviewing this text.
Links
- Download the HelloWorldPlugin's source code.
- Eclipse uses the Common Public License: http://www.eclipse.org/legal/cpl-v10.html
- Eclipse download site: http://www.eclipse.org/downloads/
- Articles published on the Eclipse Web site: http://www.eclipse.org/arcticles/
- Java download Web site: http://java.sun.com/downloads/index.html
- Eclipse user interface guidelines: http://www.eclipse.org/articles/Article-UI-Guidelines/Index.html
- News at IBM: http://www.ibm.com/news/us/2001/11/05.html
- SWT Standard Widget Toolkit: http://www.eclipse.org/articles/Article-SWT-Design-1/SWT-Design-1.html
- Eclipse platform ready to forge its own path: http://www.eweek.com/article2/0,4149,1457153,00.asp
- SWT, Managing OS resources: http://www.eclipse.org/articles/swt-design-2/swt-design-2.html
- Swing and SWT: A Tale of Two Java GUI Libraries: http://www.developer.com/java/other/article.php/2179061
Books
- Erich Gamma, Kent Beck, (2003) Contributing to Eclipse: Principles, Patterns, and Plugins, Addison-Wesley Pub Co.
- David Gallardo, Ed Burnett, Robert McGovern (2003) Eclipse in Action: A Guide for Java Developers, Manning Publications.
- Sherry Shavor, Jim D'Anjou, Scott Fairbrother (2003) The Java Developer's Guide to Eclipse, Addison-Wesley Professional
Page 5 of 5
This article was originally published on February 23, 2004