November 25, 2014
Hot Topics:

A First Look at Eclipse Plug-In Programming

  • February 23, 2004
  • By Koray Guclu
  • Send Email »
  • More Articles »
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>
  <import plugin="org.eclipse.core.resources"/>

  <import plugin="org.eclipse.ui"/>
   </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 Packageplug-in id
org.eclipse.jface[.*],
org.eclipse.swt[.*],
org.eclipse.ui[.*]
org.eclipse.ui
org.eclipse.core.resourcesorg.eclipse.core.resources
org.eclipse.core.bootorg.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
<extension point="org.eclipse.ui.actionSets">
    <actionSet
      id="de.korayguclu.eclipse.actionSet"
      label="Sample Action Set"
      visible="true">
      <menu id="sampleMenu"
            label="Sample &amp;Menu">
        <separator name="sampleGroup"/>
      </menu>
      <action
        id="de.korayguclu.eclipse.actions.SampleAction">
        class="de.korayguclu.eclipse.actions.SampleAction"
        menubarPath="sampleMenu/sampleGroup"
        toolbarPath="sampleGroup"
       label="&amp;Sample Action"
        icon="icons/sample.gif"
        tooltip="Hello, Eclipse world">
     </action>
   </actionSet>
   </extension>
<extension point="org.eclipse.ui.perspectiveExtensions">
    <perspectiveExtension
      targetID="org.eclipse.ui.resourcePerspective">
    <actionSet id="de.korayguclu.eclipse.actionSet"/>
    </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


Koray Güclü

He is working as a freelance author and software architect. He is currently finishing his book on Software Architectures and Design Patterns. His main interest areas are Software Architectures, Data Warehouses, and Database Modeling.

www.korayguclu.de

Resources

Credits

I would like to thank to Steve Gaiser for his valuable efforts in reviewing this text.

Links

Books





Page 5 of 5



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel