Home » Eclipse Projects » Rich Client Platform (RCP) » How to add views from other plugins to perspective
|How to add views from other plugins to perspective [message #517466]
||Sun, 28 February 2010 12:21
Originally posted by: fxulusoy.yahoo.com|
My question is actually related with RAP, but the problem is also
related with RCP. Therefore, I am writing it here again.
I want to let other plugins add views to my perspective. I have defined
a new extension point in my core plugin and used this extension point in
my 2nd (extension) plugin. But eclipse doesn't see the view and I am
getting the exception:
org.eclipse.ui.PartInitException: Could not create view: ...
I can add views from the 2nd plugin by using
org.eclipse.ui.perspectiveExtension extension point. In this case,
eclipse adds all views which are defined under this extension point
automatically. But that's not want I want.
My usecase is like this: I want to add a view to my perspective
according to some user defined arguments.
And, if somebody wants to add new view, he should use my extension point
and create his view in his plugin. Then, he can run his view with a
BTW, I have only one view in my perspective.
I am guessing that I somehow need to "extend" the extension point from
org.eclipse.ui.views. So, Eclipse is able to recognize my extension
point as an ui.views extension point. Then it would be able to find the
How can I solve this problem or is there another way to do that?
|Re: How to add views from other plugins to perspective [message #517499 is a reply to message #517484]
||Sun, 28 February 2010 20:02
Originally posted by: fxulusoy.yahoo.com|
My comments are below.
Paul Webster wrote:
> I'm not sure I follow, but I don't think you can "extend" either
> org.eclipse.ui.views or org.eclipse.ui.perspectiveExtensions (except by
> virtue of the fact it's open source and you could re-write the workbench
> ... with unlimited time :-)
This is not feasible in my case :) This takes definitely much time.
> Which part are you having problems with? org.eclipse.ui.views defines a
> view correctly, so that it can be created.
This is right. My core plugin needs to track the views which are created
for it. If a new plugin creates new view using ui.views, how does my
core know that? Therefore, extension plugins should use my extension
point from my core plugin. Then, core plugin can track the extension
plugins and their views.
> Show View will show a view that can be created, and a perspective
> factory or perspectiveExtensions allows the view to be placed in a
> perspective. Once a perspective has been instantiated, the perspective
> factory or new perspectiveExtensions won't help you.
> if users define their views using org.eclipse.ui.views, you could then
> use showView to show the view when necessary.
I want to define views in another plugin and show them according to some
dynamic changes, this makes the life difficult. Look at my comments
below. I hope, they makes the problem more clear.
> Do they need help defining their view (that you could provide with a
> base class)? Or is there view little more than some parameters
> describing how your concrete class should show some data?
Yes, they need help. As you said, I am providing an abstract base class
which extends from ViewPart class. I have defined an extension point on
this abstract base class. (My core plugin contains some more abstract
classes to help users of my plugin to be able to add new views easily.)
In my 2nd plugin I am using my abstract base class as an extension while
I am creating my view. I don't use extension point of ui.views for my
concrete view, I use my own extension point in the 2nd plugin. Then,
Eclipse is not able to see my view's ID in my core plugin. Because, the
extension for my view is not type of ui.views. This is the problem.
There is one stupid solution which I didn't like. If I define two
extension for my concrete view in the 2nd plugin, then Eclipse can see
my view. I mean, I am using two extension points. One of them is
ui.views and other one is my extension point. I think, this look not
good. Because, my view looks extension of two things. I think, there
should be nice way to do that.
Thanks for your reply.
|Re: How to add views from other plugins to perspective [message #518261 is a reply to message #517499]
||Wed, 03 March 2010 15:40
| Paul Webster
Registered: July 2009
Fatih Ulusoy wrote:|
> This is right. My core plugin needs to track the views which are created
> for it. If a new plugin creates new view using ui.views, how does my
> core know that? Therefore, extension plugins should use my extension
> point from my core plugin. Then, core plugin can track the extension
> plugins and their views.
Without using org.eclipse.ui.views it's unlikely that you would ever be
able to instantiate a view correctly.
4 options that come to mind:
1) the one you mentioned. To use your view, consumers provide an
org.eclipse.ui.views extension and your com.example.extra.info
extension. When you create you schema, you can make your viewId
attribute an "identifier" so that users of your extension point can
easily link it to a defined o.e.ui.view. In the schema file it ends up
looking like: org.eclipse.ui.views/view/@id
The disadvantage is 2 extensions. The advantage is you have all of the
declarative information you need.
2) Since you provide the base class, have the view register itself with
your plugin on creation:
As consumer views are created, you'll know it and can get information.
The down side is the view must be instantiated before you can find out
3) use IExecutableExtension parameters on views created in
<parameter name="extra.info.one" value="who"/>
<parameter name="extra.info.two" value="what"/>
These strings get passed in a map in setInitializationData(*) when the
view is created. You could also scan the org.eclipse.ui.views extension
point and extract the parameters yourself. The downside is that you
won't get tooling support, users will have to enter the XML manually.
4) use your extension to create the org.eclipse.ui.views entries on the
fly. This will only work in an RCP app, as you need the "null token".
You will have to do the research to figure out how to get the entry into
the IExtensionRegistry, and it's not pretty. See
IContributor, boolean, String, ResourceBundle, Object)
Current Time: Fri Jul 01 19:01:58 GMT 2016
Powered by FUDForum
. Page generated in 0.04229 seconds