|
|
|
Re: UML 2 Plugin [message #477508 is a reply to message #477504] |
Wed, 11 June 2008 17:51 |
Tim Myer Messages: 81 Registered: July 2009 |
Member |
|
|
Hi Iris,
It seems to me the problem boils down to this: some plug-in needs to
start when the Workbench starts and to observe the Workbench so that,
whenever a new editor for a UML Model is opened, an observer can be
added to the CommandStack or ResultSet (and removed when the editor is
closed). The way I might approach the problem would be this:
Perhaps your plug-in could start up when the Workbench starts by using
the org.eclipse.ui.startup extension point.
You can add an IPartListener to listen for editors being opened and
closed using
PlatformUI#getWorkbench#getActiveWorkbenchWindow#getActivePa ge#addPartListener
When an IWorkbenchPart opens, you can check that it is an IEditorPart,
that its IEditorInput is a UML file, and that it is an
IEditingDomainProvider (the standard uml2 UMLEditor is an
IEditingDomainProvider). Once you know this, you can get the
EditingDomain and add the CommandStack or Resource Set observers.
The solution seems a bit hacky to me, and of course it leaves out a
bunch of edge cases, but it decouples the editors from your observers,
and it might give you an idea of a direction. I would be very
interested to hear a better solution if you have one.
Let me know if this works for what you need!
-----Tim------
Iris wrote:
> Hi,
>
> Thank you so much for your answer! That helps a lot. The question for me
> is now if I create an eclipse plugin, how do I get the editing domain
> from the currently opened uml model in the editor?
>
> Thanks a lot!
>
|
|
|
|
|
|
|
Re: UML 2 Plugin [message #626698 is a reply to message #477504] |
Wed, 11 June 2008 17:51 |
Tim Myer Messages: 81 Registered: July 2009 |
Member |
|
|
Hi Iris,
It seems to me the problem boils down to this: some plug-in needs to
start when the Workbench starts and to observe the Workbench so that,
whenever a new editor for a UML Model is opened, an observer can be
added to the CommandStack or ResultSet (and removed when the editor is
closed). The way I might approach the problem would be this:
Perhaps your plug-in could start up when the Workbench starts by using
the org.eclipse.ui.startup extension point.
You can add an IPartListener to listen for editors being opened and
closed using
PlatformUI#getWorkbench#getActiveWorkbenchWindow#getActivePa ge#addPartListener
When an IWorkbenchPart opens, you can check that it is an IEditorPart,
that its IEditorInput is a UML file, and that it is an
IEditingDomainProvider (the standard uml2 UMLEditor is an
IEditingDomainProvider). Once you know this, you can get the
EditingDomain and add the CommandStack or Resource Set observers.
The solution seems a bit hacky to me, and of course it leaves out a
bunch of edge cases, but it decouples the editors from your observers,
and it might give you an idea of a direction. I would be very
interested to hear a better solution if you have one.
Let me know if this works for what you need!
-----Tim------
Iris wrote:
> Hi,
>
> Thank you so much for your answer! That helps a lot. The question for me
> is now if I create an eclipse plugin, how do I get the editing domain
> from the currently opened uml model in the editor?
>
> Thanks a lot!
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04843 seconds