Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Contributing Nodes from external plugins. Extension Points vs. Application Model
Contributing Nodes from external plugins. Extension Points vs. Application Model [message #1705126] Wed, 12 August 2015 10:29 Go to next message
Kai Pervoelz is currently offline Kai PervoelzFriend
Messages: 14
Registered: August 2015
Junior Member
I am building a prototype where a Part should support to render different layers on top of each other in a single view. At the moment the layers are added as Nodes to a StackPane in a single plugin. Now I would like to add Nodes from separate plugins.

One way would be to use Extension Points but I am wondering if there is a way to use the ApplicationModel for this.

As far as I got it right now I would need to do something like this:

- Extending the ApplicationModel by creating a new EcoreModel
- Adding a new renderer resp. customizing the PartRenderer

Is this the way to go?
Would appreciate to get suggestions, hints, links to examples or blog posts.

Kai

Re: Contributing Nodes from external plugins. Extension Points vs. Application Model [message #1705253 is a reply to message #1705126] Thu, 13 August 2015 10:28 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 12.08.15 15:21, Kai Pervoelz wrote:
> I am building a prototype where a Part should support to render
> different layers on top of each other in a single view. At the moment
> the layers are added as Nodes to a StackPane in a single plugin. Now I
> would like to add Nodes from separate plugins.
> One way would be to use Extension Points but I am wondering if there is
> a way to use the ApplicationModel for this.

I personally don't like extension points but much more prefer
OSGi-Services! With our DI-Extension [1] you can get those injected into
your part! I also suggest you do use OSGi-Annotations by installing [2].

Extending the application model is certainly also a possibility and BTW
did you know that there is MCompositePart who also you to nest MPart,
MPartStack, ... into it?

Only caveat I think the lastest stable release of the e4xmi-Editor is
not able to define this guy in the editor but I think Dirk fixed that in
the nightlies, Dirk?

> As far as I got it right now I would need to do something like this:
>
> - Extending the ApplicationModel by creating a new EcoreModel
> - Adding a new renderer resp. customizing the PartRenderer
>

Yes that's the way to go.

> Is this the way to go? Would appreciate to get suggestions, hints,
> links to examples or blog posts.

I know how to do it but I've never written a blog post about it. Beside
extending the Ecore you also need to contribute your new element to the
e4xmi-Editor who has extension points but IMHO they are not yet
providing a full-feature set of functionality (well I'm the one to blame
because I did the initial implementation of the editor :-)

To summerize:
a) maybe MCompositePart is the right thing for you?
b) if not I'd go with OSGi-Services who maybe are the right choice
anyways because they are 100% dynamic which is not true for the
model stuff where things can not be installed/uninstalled at runtime
(yet).

Tom


[1]https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Injection_of_OSGi-Services
[2]https://github.com/ecliptical/ds-annotations
Re: Contributing Nodes from external plugins. Extension Points vs. Application Model [message #1705272 is a reply to message #1705253] Thu, 13 August 2015 11:58 Go to previous messageGo to next message
Kai Pervoelz is currently offline Kai PervoelzFriend
Messages: 14
Registered: August 2015
Junior Member
Hey Tom,

thanks a lot for your hints and suggestions!
The MCompositePart seems to be the way to go for...
I will definitely check if this works for me.

Kai

Re: Contributing Nodes from external plugins. Extension Points vs. Application Model [message #1705306 is a reply to message #1705253] Thu, 13 August 2015 15:55 Go to previous messageGo to next message
Kai Pervoelz is currently offline Kai PervoelzFriend
Messages: 14
Registered: August 2015
Junior Member
Hi Tom,

I investigated MCompositePart today but unfortunately I didn't find a lot...

With the nightly build I can add CompositeParts also with the e4xmi Editor, but I am not sure if I got your idea how I can use those to solve my problem.

At the moment my layers are extending javafx.scene.layout.Pane. In the MPart I add a javafx.scene.layout.StackPane to the injected BorderPane, instantiate my layers and add them to the StackPane.

By contributing to the ID of the CompositePart I can add Parts to it from other plug-ins but how can I use those as layers for a main part. It seems that I can't define a Class URI for a MCompositePart from which I could access its children.


Kai








Re: Contributing Nodes from external plugins. Extension Points vs. Application Model [message #1705317 is a reply to message #1705306] Thu, 13 August 2015 18:11 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

To start how do you switch between the different layers in your UI?

On 13.08.15 17:55, Kai Pervoelz wrote:
> Hi Tom,
> I investigated MCompositePart today but unfortunately I didn't find a
> lot...
>
> With the nightly build I can add CompositeParts also with the e4xmi
> Editor, but I am not sure if I got your idea how I can use those to
> solve my problem.
> At the moment my layers are extending javafx.scene.layout.Pane. In the

Ok so you have a custom layout pane.

> MPart I add a javafx.scene.layout.StackPane to the injected BorderPane,
> instantiate my layers and add them to the StackPane.

Ok did you know that you can make the renderer inject a StackPane
directly? See https://wiki.eclipse.org/Efxclipse/Runtime/e4#MPart

> By contributing to the ID of the CompositePart I can add Parts to it
> from other plug-ins but how can I use those as layers for a main part.
> It seems that I can't define a Class URI for a MCompositePart from which
> I could access its children.
>

a) It is a bug in the editor that it does not allow you to specify an
URI for the contribution class!
b) I don't think you need that but you need a custom renderer for
MPartStack

No you ask why MPartStack? The reason is simple in general the
application has 2 container types:

* SashContainer ===> show all children with different ratios
* StackContainer ===> show only one child

+ MCompositePart (=sash container)
+ MPartStack(tags=[MyCustomStackRenderer]) (=stack container)
+ MPart(tags=[Container:UrlPane:%PANE_URL%])
+ MPart(tags=[Container:UrlPane:%PANE_URL%])
+ MPart(tags=[Container:UrlPane:%PANE_URL%])

%PANE_URL%=bundleclass://my.bundle/my.layout.pane.MyStack


class MyRendererFactory extends DefWorkbenchRendererFactory {
private MyStackRenderer myStackRenderer;

@Inject
public MyRendererFactory(IEclipseContext context) {
super(context);
}

public <R extends ElementRenderer<?, ?>> R getRenderer(MUIElement
modelObject) {
if( modelObject instanceof MPartStack &&
modelObject.getTags().contains("MyCustomStackRenderer") ) {
if( myStackRenderer == null ) {
myStackRenderer = make( MyStackRenderer.class );
}
return myStackRenderer;
}
}
}

class MyStackRenderer extends BaseStackRenderer<....> {

}


and in your plugin.xml where your have defined the product you add:

<property
name="rendererFactoryUri"
value="bundleclass://my.bundle/my.custom.MyRendererFactory">
</property>

To sum it up: Maybe the OSGi-Service way is the easier way to go?

Tom
Re: Contributing Nodes from external plugins. Extension Points vs. Application Model [message #1705360 is a reply to message #1705317] Fri, 14 August 2015 07:04 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
> Only caveat I think the lastest stable release of the e4xmi-Editor is
> not able to define this guy in the editor but I think Dirk fixed that in
> the nightlies, Dirk?

I haven't looked at this yet. First I need to get familiar with the editor internals. But I'm on vacation at the moment, so I'm not sure when I'm able to look at it.
Previous Topic:Need a pan-able and scroll-able JavaFX scene
Next Topic:Problems building e4 application
Goto Forum:
  


Current Time: Tue Jan 14 21:19:58 GMT 2025

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

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

Back to the top