Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » dynamic loading of views
dynamic loading of views [message #47551] Tue, 18 September 2007 11:34 Go to next message
Eclipse UserFriend
Originally posted by: s5824917.inf.tu-dresden.de

hey there,

Imagine there are people creating different kind of views. Each view has
certain functionalities. So in the end there are a couple of views that do
different things or the same things in a different way.

Then there are other people writing applications who just specify the
functionalities of these views they want to use. These people will use a
framework I am about to write, which will do the job of selecting the right
view for their case.
(Example: Person P wants to display two views, the first view has to fulfill
functionality A and the second has to fulfill functionality B. That
requirement is passed to my framework, which then checks all available
packages that use extension point "com.example.view". It checks the
functionality attribute of each package found and gets lets say 2 packages
that fulfill functionality A and one that fulfills functionality B. An
algorithm in the framework then selects a single view to use for
functionality A. Once the views are found they need to be mapped for use in
the application.)

I found a nice tutorial which kind of explains how to do that with normal
eclipse at
http://www.eclipsezone.com/eclipse/forums/t97608.rhtml

Now I wonder if it is also possible with RAP to check for certain packages
at runtime and then load a view from that package based on a few attributes
of that view?




Example how to get all packages that use "com.example.pizza" (not possible
like that in RAP !?):

StringBuffer buffer = new StringBuffer();
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] extensions =
reg.getConfigurationElementsFor("com.example.pizza");
Re: dynamic loading of views [message #47947 is a reply to message #47551] Wed, 19 September 2007 10:36 Go to previous messageGo to next message
Benjamin Muskalla is currently offline Benjamin MuskallaFriend
Messages: 237
Registered: July 2009
Senior Member
Hi Stefan,

I'm a little but confused with your naming. With package you mean
"Extensions" right? So let's say you have an extension point called
"com.example.pizza" and now want to read out all extensions for this
extension point.

In this area there are now differences between RAP and RCP as the
extension point mechanism is provided by the core (which is the same for
both).

What did you do? Did you create an extension point schema? Did you
register it in the plugin.xml of the plugin it is contained? Did you
create an extension for that extension point?

Then you can read all extension in a way like this:

IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint( "com.example.pizza");
IConfigurationElement[] elements = point.getConfigurationElements();
for( int i = 0; i < elements.length; i++ ) {
String someAttr = elements[ i ].getAttribute( "someAttr" );
}

Greets
Benny

Stefan Lindner wrote:
> hey there,
>
> Imagine there are people creating different kind of views. Each view has
> certain functionalities. So in the end there are a couple of views that do
> different things or the same things in a different way.
>
> Then there are other people writing applications who just specify the
> functionalities of these views they want to use. These people will use a
> framework I am about to write, which will do the job of selecting the right
> view for their case.
> (Example: Person P wants to display two views, the first view has to fulfill
> functionality A and the second has to fulfill functionality B. That
> requirement is passed to my framework, which then checks all available
> packages that use extension point "com.example.view". It checks the
> functionality attribute of each package found and gets lets say 2 packages
> that fulfill functionality A and one that fulfills functionality B. An
> algorithm in the framework then selects a single view to use for
> functionality A. Once the views are found they need to be mapped for use in
> the application.)
>
> I found a nice tutorial which kind of explains how to do that with normal
> eclipse at
> http://www.eclipsezone.com/eclipse/forums/t97608.rhtml
>
> Now I wonder if it is also possible with RAP to check for certain packages
> at runtime and then load a view from that package based on a few attributes
> of that view?
>
>
>
>
> Example how to get all packages that use "com.example.pizza" (not possible
> like that in RAP !?):
>
> StringBuffer buffer = new StringBuffer();
> IExtensionRegistry reg = Platform.getExtensionRegistry();
> IConfigurationElement[] extensions =
> reg.getConfigurationElementsFor("com.example.pizza");
>
>
Re: dynamic loading of views [message #49842 is a reply to message #47947] Wed, 26 September 2007 17:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: s5824917.inf.tu-dresden.de

Hey Benjamin,
I forgot to thank you for all the responses, but I'll try to explain it all
over again and more detailed this time...

Meanwhile I have 4 bundles:
(com.myapp)
The first consists of the application itself. (Workbench, Advisors,
Perspective). It does not contain a view yet, but requires another bundle
called com.slf.
Extensions: org.eclipse.rap.entrypoint, org.eclipse.ui.perspectives
Require Bundle: com.slf, org.eclipse.rap.ui

(com.slf)
The second consists of a ViewManager.java and a self-made StandardView.java
Extension Points: com.slf
Schema: com.slf.exsd ==> which adds a new element "myview"
with attributes "purpose" and "class"
Export-Package: com.slf;version="1.0.0", com.slf.manager;version="1.0.0"

(com.slf.viewone)
The third consists of a view SampleViewOne.java.
Extensions: com.slf
Require Bundle: org.eclipse.rap.ui, com.slf
<plugin>
<extension
point="com.slf">
<myview purpose="picture" class="com.slf.viewone.SampleViewOne"/>
</extension>
</plugin>

(com.slf.viewtwo)
The fourth also consists just of a view SampleViewTwo.java.
Extensions: com.slf
Require Bundle: org.eclipse.rap.ui, com.slf
<plugin>
<extension
point="com.slf">
<myview purpose="picture" class="com.slf.viewone.SampleViewOne"/>
</extension>
</plugin>

Now its supposed to work as follows. In the perspective of the application I
call the ViewManager vm and use the vm.getView("purpose") function.
This function will look for all extensions com.slf and read its elements. If
there are extensions and the purpose-attribute equals
the parameter that was given with the function call, the function will
return the String of the class attribute (which is the view to be
loaded). Then that string is used to add the view to the perspective -
topLeft.addView( returnedString );
If nothing was returned then the StandardView is used.

Thats the goal, but its not working. There are no errors, the
folder(IFolderLayout topLeft = layout.createFolder(...) gets created, I can
minimize
and maximize it, but no view gets shown inside.Inside the folder there is a
button, or rather a tiny bit of a button, but its enough to hover
over it with your mouse. The tooltip says "Menu", maybe thats a hint on
whats going wrong. If you click it the application crashes.

I know that normally you declare Extensions for views in the application
with org.eclipse.ui.views. But using that its already set into stone which
views are available to the application. My goal is to make it possible to
add views afterwards, that can be used by the application without
touching the application at all.
That requires to add some meta-information to views, so they can be properly
selected automatically, for example:
- the job they have to fulfill (is it for viewing, selecting or editing
something).
- viewing or selecting single or multiple items etc.
- the datatypes supported (*.*, jpg, mp3...)
- the minimum size the view requires

Is that possible? or am I working too much against the concepts?
And yes, I am pretty new to this still :)




> "Benjamin Muskalla" <bmuskalla@innoopract.com> schrieb im Newsbeitrag
> news:fcqu8s$h2c$1@build.eclipse.org...
> Hi Stefan,
>
> I'm a little but confused with your naming. With package you mean
> "Extensions" right? So let's say you have an extension point called
> "com.example.pizza" and now want to read out all extensions for this
> extension point.
>
> In this area there are now differences between RAP and RCP as the
> extension point mechanism is provided by the core (which is the same for
> both).
>
> What did you do? Did you create an extension point schema? Did you
> register it in the plugin.xml of the plugin it is contained? Did you
> create an extension for that extension point?
>
> Then you can read all extension in a way like this:
>
> IExtensionRegistry registry = Platform.getExtensionRegistry();
> IExtensionPoint point = registry.getExtensionPoint( "com.example.pizza");
> IConfigurationElement[] elements = point.getConfigurationElements();
> for( int i = 0; i < elements.length; i++ ) {
> String someAttr = elements[ i ].getAttribute( "someAttr" );
> }
>
> Greets
> Benny
>
> Stefan Lindner wrote:
>> hey there,
>>
>> Imagine there are people creating different kind of views. Each view has
>> certain functionalities. So in the end there are a couple of views that
>> do different things or the same things in a different way.
>>
>> Then there are other people writing applications who just specify the
>> functionalities of these views they want to use. These people will use a
>> framework I am about to write, which will do the job of selecting the
>> right view for their case.
>> (Example: Person P wants to display two views, the first view has to
>> fulfill functionality A and the second has to fulfill functionality B.
>> That requirement is passed to my framework, which then checks all
>> available packages that use extension point "com.example.view". It checks
>> the functionality attribute of each package found and gets lets say 2
>> packages that fulfill functionality A and one that fulfills functionality
>> B. An algorithm in the framework then selects a single view to use for
>> functionality A. Once the views are found they need to be mapped for use
>> in the application.)
>>
>> I found a nice tutorial which kind of explains how to do that with normal
>> eclipse at
>> http://www.eclipsezone.com/eclipse/forums/t97608.rhtml
>>
>> Now I wonder if it is also possible with RAP to check for certain
>> packages at runtime and then load a view from that package based on a few
>> attributes of that view?
>>
>>
>>
>>
>> Example how to get all packages that use "com.example.pizza" (not
>> possible like that in RAP !?):
>>
>> StringBuffer buffer = new StringBuffer();
>> IExtensionRegistry reg = Platform.getExtensionRegistry();
>> IConfigurationElement[] extensions =
>> reg.getConfigurationElementsFor("com.example.pizza");
>>
Re: dynamic loading of views [message #49968 is a reply to message #49842] Thu, 27 September 2007 08:50 Go to previous message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

I am not pretty sure that I understood everything correctly that you want to
do. But It seems to me that you may not need different Viewparts to reach
your goal. I think that a combination of PageBookView, PartActivation and
the Adapter framework should do the trick.

As an example you may look at the eclipse RCP outline view (which is also
available in RAP). Depending on the activated Editor type different
'outlines' fitting the needs of the active editor are displayed. The outline
ViewPart implementation uses a PageBookView to do so. A page book view can
be seen as a tabfolder without tabs for selection. So the Outline is
listening to PartActivation listeners. You can get those by using

getSite().getPage().addPartListener( new IPartListener() {
public void partActivated( final IWorkbenchPart part ) {
}
[...]
}

in createPartControl of your ViewPart. If a part gets activated the
partActivated(IWorkbenchpart) method is called by the workbench framework.
To simplify things a little bit we asume that Outline checks whether the
part is of type editor and if so it askes via

Object outlineAdapter = part.getAdapter( IContentOutlinePage.class );

whether the editor supports a outline or not. If so it is displayed in the
page book view.

The usage of those mechanism in eclipse RCP is widely spread, so you may
have a look into the workbench code to get familiar with it. As you said
that you are new to those concepts, you may also have a look at the articles
on eclipse.org, personally I still like how the stuff is explained in
Contributing to Eclipse by Erich Gamma and Kent Beck (although some things
are a little bit outdated by now) and last but not least the RCP book by
Jeff McAffer and Jean-Michel Lemieux is very good. And the nice thing is
that these concepts work in RAP too. So we don't have to spend too much time
on writing such stuff :-)

Hopefully that fits your needs and helps!

Ciao
Frank


"Stefan Lindner" <s5824917@inf.tu-dresden.de> schrieb im Newsbeitrag
news:fde5hs$pri$1@build.eclipse.org...
> Hey Benjamin,
> I forgot to thank you for all the responses, but I'll try to explain it
> all over again and more detailed this time...
>
> Meanwhile I have 4 bundles:
> (com.myapp)
> The first consists of the application itself. (Workbench, Advisors,
> Perspective). It does not contain a view yet, but requires another bundle
> called com.slf.
> Extensions: org.eclipse.rap.entrypoint, org.eclipse.ui.perspectives
> Require Bundle: com.slf, org.eclipse.rap.ui
>
> (com.slf)
> The second consists of a ViewManager.java and a self-made
> StandardView.java
> Extension Points: com.slf
> Schema: com.slf.exsd ==> which adds a new element "myview"
> with attributes "purpose" and "class"
> Export-Package: com.slf;version="1.0.0",
> com.slf.manager;version="1.0.0"
>
> (com.slf.viewone)
> The third consists of a view SampleViewOne.java.
> Extensions: com.slf
> Require Bundle: org.eclipse.rap.ui, com.slf
> <plugin>
> <extension
> point="com.slf">
> <myview purpose="picture" class="com.slf.viewone.SampleViewOne"/>
> </extension>
> </plugin>
>
> (com.slf.viewtwo)
> The fourth also consists just of a view SampleViewTwo.java.
> Extensions: com.slf
> Require Bundle: org.eclipse.rap.ui, com.slf
> <plugin>
> <extension
> point="com.slf">
> <myview purpose="picture" class="com.slf.viewone.SampleViewOne"/>
> </extension>
> </plugin>
>
> Now its supposed to work as follows. In the perspective of the application
> I call the ViewManager vm and use the vm.getView("purpose") function.
> This function will look for all extensions com.slf and read its elements.
> If there are extensions and the purpose-attribute equals
> the parameter that was given with the function call, the function will
> return the String of the class attribute (which is the view to be
> loaded). Then that string is used to add the view to the perspective -
> topLeft.addView( returnedString );
> If nothing was returned then the StandardView is used.
>
> Thats the goal, but its not working. There are no errors, the
> folder(IFolderLayout topLeft = layout.createFolder(...) gets created, I
> can minimize
> and maximize it, but no view gets shown inside.Inside the folder there is
> a button, or rather a tiny bit of a button, but its enough to hover
> over it with your mouse. The tooltip says "Menu", maybe thats a hint on
> whats going wrong. If you click it the application crashes.
>
> I know that normally you declare Extensions for views in the application
> with org.eclipse.ui.views. But using that its already set into stone which
> views are available to the application. My goal is to make it possible to
> add views afterwards, that can be used by the application without
> touching the application at all.
> That requires to add some meta-information to views, so they can be
> properly selected automatically, for example:
> - the job they have to fulfill (is it for viewing, selecting or editing
> something).
> - viewing or selecting single or multiple items etc.
> - the datatypes supported (*.*, jpg, mp3...)
> - the minimum size the view requires
>
> Is that possible? or am I working too much against the concepts?
> And yes, I am pretty new to this still :)
>
>
>
>
>> "Benjamin Muskalla" <bmuskalla@innoopract.com> schrieb im Newsbeitrag
>> news:fcqu8s$h2c$1@build.eclipse.org...
>> Hi Stefan,
>>
>> I'm a little but confused with your naming. With package you mean
>> "Extensions" right? So let's say you have an extension point called
>> "com.example.pizza" and now want to read out all extensions for this
>> extension point.
>>
>> In this area there are now differences between RAP and RCP as the
>> extension point mechanism is provided by the core (which is the same for
>> both).
>>
>> What did you do? Did you create an extension point schema? Did you
>> register it in the plugin.xml of the plugin it is contained? Did you
>> create an extension for that extension point?
>>
>> Then you can read all extension in a way like this:
>>
>> IExtensionRegistry registry = Platform.getExtensionRegistry();
>> IExtensionPoint point = registry.getExtensionPoint( "com.example.pizza");
>> IConfigurationElement[] elements = point.getConfigurationElements();
>> for( int i = 0; i < elements.length; i++ ) {
>> String someAttr = elements[ i ].getAttribute( "someAttr" );
>> }
>>
>> Greets
>> Benny
>>
>> Stefan Lindner wrote:
>>> hey there,
>>>
>>> Imagine there are people creating different kind of views. Each view has
>>> certain functionalities. So in the end there are a couple of views that
>>> do different things or the same things in a different way.
>>>
>>> Then there are other people writing applications who just specify the
>>> functionalities of these views they want to use. These people will use a
>>> framework I am about to write, which will do the job of selecting the
>>> right view for their case.
>>> (Example: Person P wants to display two views, the first view has to
>>> fulfill functionality A and the second has to fulfill functionality B.
>>> That requirement is passed to my framework, which then checks all
>>> available packages that use extension point "com.example.view". It
>>> checks the functionality attribute of each package found and gets lets
>>> say 2 packages that fulfill functionality A and one that fulfills
>>> functionality B. An algorithm in the framework then selects a single
>>> view to use for functionality A. Once the views are found they need to
>>> be mapped for use in the application.)
>>>
>>> I found a nice tutorial which kind of explains how to do that with
>>> normal eclipse at
>>> http://www.eclipsezone.com/eclipse/forums/t97608.rhtml
>>>
>>> Now I wonder if it is also possible with RAP to check for certain
>>> packages at runtime and then load a view from that package based on a
>>> few attributes of that view?
>>>
>>>
>>>
>>>
>>> Example how to get all packages that use "com.example.pizza" (not
>>> possible like that in RAP !?):
>>>
>>> StringBuffer buffer = new StringBuffer();
>>> IExtensionRegistry reg = Platform.getExtensionRegistry();
>>> IConfigurationElement[] extensions =
>>> reg.getConfigurationElementsFor("com.example.pizza");
>>>
>
Previous Topic:FormEditor
Next Topic:GWT vs RAP and some random ideas [Importance: Low]
Goto Forum:
  


Current Time: Thu Apr 18 08:07:00 GMT 2024

Powered by FUDForum. Page generated in 0.02589 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top