Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Adding a listener to a diagram after opening it in an edtor
Adding a listener to a diagram after opening it in an edtor [message #56403] Wed, 27 September 2006 13:42 Go to next message
Eclipse User
Originally posted by: daniel-p.gmx.de

Hi everybody,

I need to add a listener to a digram after I opened it programmatically. I
first create a FileInput which I then pass to the IEditorPart
IDE.openEditor method.
I tried adding a listener to the underlying domain model before calling
IDE.openEditor, but as I expected this does not work.

Does anybody know how to accomplish that task?

Thanks,

Dan
Re: Adding a listener to a diagram after opening it in an edtor [message #56871 is a reply to message #56403] Thu, 28 September 2006 09:12 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Daniel,

Please take a loot on generated ???EditPart class for your diagram. (this
class extends DiagramEditPart). You can override addNotationalListeners()
method in this class and attach your listener to the Diagram instance there.

-----------------
Alex Shatalin
Re: Adding a listener to a diagram after opening it in an edtor [message #56922 is a reply to message #56871] Thu, 28 September 2006 10:42 Go to previous messageGo to next message
Eclipse User
Originally posted by: daniel-p.gmx.de

Sorry, that does not work in my case, since I have to add the listener
from inside another plug-in and set up the listener with some generic
information.

Dan


On Thu, 28 Sep 2006 11:12:51 +0200, Alex Shatalin <vano@borland.com> wrote:

> Hello Daniel,
>
> Please take a loot on generated ???EditPart class for your diagram.
> (this class extends DiagramEditPart). You can override
> addNotationalListeners() method in this class and attach your listener
> to the Diagram instance there.
>
> -----------------
> Alex Shatalin
>
>
Re: Adding a listener to a diagram after opening it in an edtor [message #56947 is a reply to message #56922] Thu, 28 September 2006 11:04 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Daniel,

Then take a look on generated ???ViewProvider class. This class return ???ViewFactory.class
from getDiagramViewClass(). You can:
- create your own ViewProvider and register it with higher priority then
generated one
- implement only getDiagramViewClass in this provider and return custom factory
class from there.
- custom factory class could subclass generated factory class and attach
desired listener by overriding createDiagram() method.

-----------------
Alex Shatalin
Re: Adding a listener to a diagram after opening it in an edtor [message #57675 is a reply to message #56947] Fri, 29 September 2006 20:02 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie Revells
Messages: 299
Registered: July 2009
Senior Member
Daniel,

Depending on what you want to do, it might make more sense to install an
editpolicy on your diagram editpart and add the listener in here.
Search the GMF docs for info on the editpolicy service to learn how to
install an editpolicy from another plugin.

Regards,
Cherie

Alex Shatalin wrote:
> Hello Daniel,
>
> Then take a look on generated ???ViewProvider class. This class return
> ???ViewFactory.class from getDiagramViewClass(). You can:
> - create your own ViewProvider and register it with higher priority then
> generated one
> - implement only getDiagramViewClass in this provider and return custom
> factory class from there.
> - custom factory class could subclass generated factory class and attach
> desired listener by overriding createDiagram() method.
>
> -----------------
> Alex Shatalin
>
>
Re: Adding a listener to a diagram after opening it in an edtor [message #58359 is a reply to message #57675] Mon, 02 October 2006 14:02 Go to previous message
Mohammed Mostafa is currently offline Mohammed Mostafa
Messages: 143
Registered: July 2009
Senior Member
Daniel :

I don not think View Factories are the way to go here; since view
factories will be invoked only during view creation; which means if your
diagram view is serialized in the resource, the next time you open it no
view factory will be called to create the diagram.
Now , regarding adding listeners, when you say you open the diagram
programatically do you mean you just opened the resource or did you
render the diagram on the screen ?
If you just loaded the resource, then Edit parts or edit policies
will not help since they exist only if the diagram is rendered, an you
might need a resource listener instead which you should install after
you load the resource
If you rendered the diagram then your diagram edit part is already
listening to the diagram, you can modify it to add listeners as you
like, check addSemanticListeners, or you can create a speciallied edit
policy that does the listening and install it on your edit part


> Daniel,
>
> Depending on what you want to do, it might make more sense to install an
> editpolicy on your diagram editpart and add the listener in here. Search
> the GMF docs for info on the editpolicy service to learn how to install
> an editpolicy from another plugin.
>
> Regards,
> Cherie
>
> Alex Shatalin wrote:
>> Hello Daniel,
>>
>> Then take a look on generated ???ViewProvider class. This class return
>> ???ViewFactory.class from getDiagramViewClass(). You can:
>> - create your own ViewProvider and register it with higher priority
>> then generated one
>> - implement only getDiagramViewClass in this provider and return
>> custom factory class from there.
>> - custom factory class could subclass generated factory class and
>> attach desired listener by overriding createDiagram() method.
>>
>> -----------------
>> Alex Shatalin
>>
>>
Previous Topic:Bug in Ecore Editor, assotiation between Eclass and EEnum
Next Topic:Specify what to use as Link containers
Goto Forum:
  


Current Time: Thu Oct 23 08:01:17 GMT 2014

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

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