Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Best way to listen to eclipse Notification(EMF Notification Observer)
Best way to listen to eclipse Notification [message #1115593] Tue, 24 September 2013 05:58 Go to next message
Jürgen  Krey is currently offline Jürgen Krey
Messages: 4
Registered: July 2009
Location: Cologne
Junior Member
I'd like to observe org.eclipse.emf.common.notify.Notification's in my (business domain) plugin, ie. I have to listen to
objects of type org.eclipse.emf.common.notify.impl.NotificationImpl.

What is the best way/technique to implement / register an appropriate
org.eclipse.emf.common.notify.Adapter?
Do I need an org.eclipse.emf.common.notify.AdapterFactory?

I don't want tight coupling by adding technical imports in the corresponding classes...

Can anyone provide links or code templates?

best regards
Juergen

Re: Best way to listen to eclipse Notification [message #1115664 is a reply to message #1115593] Tue, 24 September 2013 08:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25948
Registered: July 2009
Senior Member
Jürgen,

Comments below.


On 24/09/2013 1:50 PM, Jürgen rey wrote:
> I'd like to observe org.eclipse.emf.common.notify.Notification's in my
> (business domain) plugin,
For what purpose?
> ie. I have to listen to
> objects of type org.eclipse.emf.common.notify.impl.NotificationImpl.
What will you do with the notifications when you receive them?
>
> What is the best way/technique to implement / register an appropriate
> org.eclipse.emf.common.notify.Adapter?
That depends on what your purpose, which isn't clear.
> Do I need an org.eclipse.emf.common.notify.AdapterFactory?
Not necessarily, but you might want one.
>
> I don't want tight coupling by adding technical imports in the
> corresponding classes...
I'm not sure what "technical imports" are...
>
> Can anyone provide links or code templates?
It's impossible to point you in a direction if it's not clear what
you're trying to achieve...
>
> best regards Juergen
>
>
Re: Best way to listen to eclipse Notification [message #1117620 is a reply to message #1115664] Thu, 26 September 2013 12:35 Go to previous messageGo to next message
Jürgen  Krey is currently offline Jürgen Krey
Messages: 4
Registered: July 2009
Location: Cologne
Junior Member
Ok, here are more details, which make it easier to understand my feature.
I created a special collapsable/expandable panel with its own renderer.
A user toggles the state (by clicking an small triangle), which upon a NotificationImpl event is fired.

In order to save the states of multiple panels between user session, I'd like
to listen to the notification and hash them in my preferences module/class.

My goal is to de-couple the panel class from the preferences class by means of
sending Notifications containing the panelID and its boolean state...

Hope this makes my scenario clearer and concrete?!

best regards Juergen
Re: Best way to listen to eclipse Notification [message #1117637 is a reply to message #1117620] Thu, 26 September 2013 12:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25948
Registered: July 2009
Senior Member
Jürgen,

Comments below.

On 26/09/2013 6:35 PM, Jürgen rey wrote:
> Ok, here are more details, which make it easier to understand my feature.
> I created a special collapsable/expandable panel with its own renderer.
> A user toggles the state (by clicking an small triangle), which upon a
> NotificationImpl event is fired.
What you described sounds like UI elements so you're binding those to a
model, and then you want to listen to the model change...
>
> In order to save the states of multiple panels between user session,
> I'd like to listen to the notification and hash them in my preferences
> module/class.
You want to do such state saving every time the user changes something?
>
> My goal is to de-couple the panel class from the preferences class by
> means of
> sending Notifications containing the panelID and its boolean state...
Is this panel part of a modal dialog? Or part of an editor or a view?
>
> Hope this makes my scenario clearer and concrete?!
Wherever it is that you create your model to store the state of the
preferences you read would be the place where you can add a listener
(and adapter) to the model so that you can save the preference when the
model changes.
>
> best regards Juergen
Re: Best way to listen to eclipse Notification [message #1118236 is a reply to message #1117637] Fri, 27 September 2013 03:40 Go to previous messageGo to next message
Jürgen  Krey is currently offline Jürgen Krey
Messages: 4
Registered: July 2009
Location: Cologne
Junior Member
Hi Ed,

yes, I want to listen to model state changes for a UI element!

... and yes: the state change should immediately propagated to a preferences store, where all kinds of prefs are collected at first. (the preference manager is responsible for further handling)

The panel is normally part of an editor or a view, it is currently NOT part of any modal dialog, but it could be in the future. (which implications does this have?)

It would be very nice, if my preference manager only had imports
of the Notification(Impl) class. This way I wouldn't have any dependencies to
custom (presentation) model classes!

Can I do this via extension points, which establish corresponding adapters?
In Java code or per xml declarations?

Sorry for these detailed questions, but I didn't find appropriate documentations or eclipse recipes for (Notification) handling.

best regards





Re: Best way to listen to eclipse Notification [message #1118273 is a reply to message #1118236] Fri, 27 September 2013 04:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25948
Registered: July 2009
Senior Member
Jürgen,

Comments below.

On 27/09/2013 9:40 AM, Jürgen rey wrote:
> Hi Ed,
>
> yes, I want to listen to model state changes for a UI element!
Is the UI element an EMF model?
>
> .. and yes: the state change should immediately propagated to a
> preferences store, where all kinds of prefs are collected at first.
> (the preference manager is responsible for further handling)
>
> The panel is normally part of an editor or a view, it is currently NOT
> part of any modal dialog, but it could be in the future. (which
> implications does this have?)
It's a question of how often you want such things saved. If the user
doesn't save the editor, do they still want this preference state to be
saved?
>
> It would be very nice, if my preference manager only had imports of
> the Notification(Impl) class. This way I wouldn't have any
> dependencies to custom (presentation) model classes!
But it sounds like the preference manager is also responsible for
reading the state and making it available via the state of a model...
>
> Can I do this via extension points, which establish corresponding
> adapters?
It's not so clear exactly what you're doing. There is no EMF extension
point for adding adapters. There's an extension point contributing an
item provider adapter factory for your package, but it sounds unrelated
to what you're describing.
> In Java code or per xml declarations?
>
> Sorry for these detailed questions, but I didn't find appropriate
> documentations or eclipse recipes for (Notification) handling.
I'm not sure if you aren't confusing EMF's notification with other
flavors of notification provided by Eclipse.
>
> best regards
>
>
>
>
>
>
Re: Best way to listen to eclipse Notification [message #1118296 is a reply to message #1117620] Fri, 27 September 2013 05:04 Go to previous message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
On 26-09-13 18:35, Jürgen rey wrote:
> A user toggles the state (by clicking an small triangle), which upon a
> NotificationImpl event is fired.

This sounds like an e4 workbench model, which fires with UI interaction.
What would be the relation between the state of the workbench (Saved as
workbench.xmi in the workspace) and an adaptation to the Preference
Store, if your Panel is based on the e4 programming model?

BTW, with e3, you can bind your UI state with an EMF model, but this EMF
model would need to be defined first.

See this: http://www.vogella.com/articles/EclipseDataBindingEMF/article.html

The way I do it in NetXStudio is by simply writing SWT/JFace UI state to
an IMemento, but that's not very "modern" .


Cheers / Christophe
Previous Topic:Visible or Invisible Properties When model changed
Next Topic:[Texo] Support overidding xtend2 templates.
Goto Forum:
  


Current Time: Fri Aug 01 01:51:29 EDT 2014

Powered by FUDForum. Page generated in 0.11964 seconds