Akif Patel - BRMS
Akif Patel - BRMS

Reputation: 537

Inheriting Eclipse Plug-In

I have a plug-in which renders an editor to edit a specific file. I wants to create a same plug-in with few more features.

Is it possible to create my own plug-in using\inheriting existing plug-in and overriding few behaviors?

I'm well versed with creating a new plug-in from scratch. But can't figure out how to do this?

Upvotes: 0

Views: 86

Answers (2)

Didier Vojtisek
Didier Vojtisek

Reputation: 61

In general, there is no "inherit" mecanism that allows to fully inherit from a plugin.

In particular, most extensions declared in a plugin.xml don't support any mecanism similar to "inheritance".

However, in some simple case, you may be able to duplicate the declarations from the parent plugin.xml in the child plugin.xml and adapt them to point to classes that inherit from the original classes in the parent plugin. But this technique has many limitations :

  • This works for only some extension point.
  • The original plugin may not expose all the class that would need to be subclassed.
  • This may lead to subclassing or worst copying many classes from the original plugin.
  • This requires a fine understanding of each reused classes and their relation to the original plugin in order to prevent unexpected behavior. (This is quite important if the parent plugin actually works with other plugins.)

    For better result, the parent plugin need to be designed for reuse, typically providing reusable classes or even better providing dedicated extension points.

Upvotes: 0

Henry
Henry

Reputation: 17841

You cannot inherit from a plugin, even if you are the creator of both the plugin(at least in the standard meaning of the term Inheritance).

  1. You can either add all your features to the existing plugin.
  2. Or expose extensions of the first plugin and use them in the second. For this you need to modify the first plugin. You need to create extension points for that.

In any case, you can't inherit from other plugins like PDT, JDT, etc... If you think about it, that's the whole idea behind the Plugin architecture. Instead of inheritance, you can have two plugins work in harmony to satisfy the needs of the user, via Extensions and Extension Points.

Upvotes: 1

Related Questions