|Adding a listener to a diagram after opening it in an edtor [message #56403]
||Wed, 27 September 2006 13:42
Originally posted by: daniel-p.gmx.de|
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
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?
|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
| Mohammed Mostafa
Registered: July 2009
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
> 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.
> 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
Powered by FUDForum
. Page generated in 0.03115 seconds