Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsAdding a listener to a diagram after opening it in an edtor
https://www.eclipse.org/forums/index.php/mv/msg/17595/56403/#msg_56403
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]]>2006-09-27T13:42:14-00:00Re: Adding a listener to a diagram after opening it in an edtor
https://www.eclipse.org/forums/index.php/mv/msg/17595/56871/#msg_56871
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]]>Alexander Shatalin2006-09-28T09:12:51-00:00Re: Adding a listener to a diagram after opening it in an edtor
https://www.eclipse.org/forums/index.php/mv/msg/17595/56922/#msg_56922
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
>
>]]>2006-09-28T10:42:51-00:00Re: Adding a listener to a diagram after opening it in an edtor
https://www.eclipse.org/forums/index.php/mv/msg/17595/56947/#msg_56947
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]]>Alexander Shatalin2006-09-28T11:04:42-00:00Re: Adding a listener to a diagram after opening it in an edtor
https://www.eclipse.org/forums/index.php/mv/msg/17595/57675/#msg_57675
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
>
>]]>Cherie Revells2006-09-29T20:02:59-00:00Re: Adding a listener to a diagram after opening it in an edtor
https://www.eclipse.org/forums/index.php/mv/msg/17595/58359/#msg_58359
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
>>
>>]]>Mohammed Mostafa2006-10-02T14:02:15-00:00