Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » UML 2 Plugin
UML 2 Plugin [message #477498] Tue, 10 June 2008 08:20 Go to next message
Iris Groher is currently offline Iris GroherFriend
Messages: 33
Registered: July 2009
Member
Hi,

I would like to create an Eclipse plugin that keeps track of any changes
made to a UML model. Can you give me some hints how this could be done? Do
I need to create an own editor that allows me to trace the changes?

Thank you so much!
Re: UML 2 Plugin [message #477502 is a reply to message #477498] Tue, 10 June 2008 15:53 Go to previous messageGo to next message
Tim Myer is currently offline Tim MyerFriend
Messages: 81
Registered: July 2009
Member
Hi Iris,
Perhaps one of these options would help:

1. For any UMLEditor that is opened, you could get the CommandStack
from the EditingDomain, add a CommandStackListener and record the
Commands that are executed (see UMLEditor#initializeEditingDomain).
2. For any UMLEditor that is opened, you could get the ResourceSet from
the EditingDomain and attach your own Adapter to listen for Notifications.

Does either of these meet your requirements?
----Tim----



Iris wrote:
> Hi,
>
> I would like to create an Eclipse plugin that keeps track of any changes
> made to a UML model. Can you give me some hints how this could be done?
> Do I need to create an own editor that allows me to trace the changes?
>
> Thank you so much!
>
>
Re: UML 2 Plugin [message #477504 is a reply to message #477502] Wed, 11 June 2008 10:48 Go to previous messageGo to next message
Iris Groher is currently offline Iris GroherFriend
Messages: 33
Registered: July 2009
Member
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 #477508 is a reply to message #477504] Wed, 11 June 2008 17:51 Go to previous messageGo to next message
Tim Myer is currently offline Tim MyerFriend
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 #477509 is a reply to message #477508] Thu, 12 June 2008 11:35 Go to previous messageGo to next message
Iris Groher is currently offline Iris GroherFriend
Messages: 33
Registered: July 2009
Member
Hi Tim,

Thank you very much! This helped me a lot! I can now trace all changed
made to models. the only problem that I currently have is that the method
PlatformUI.getWorkbench().getActiveWorkbenchWindow() needs to be called
from within a UI thread. Otherwise it always returns null.
How can I call it from a UI thread if my plugin does not make
contributions to the UI?

Many thanks for your help!
Re: UML 2 Plugin [message #477513 is a reply to message #477509] Thu, 12 June 2008 15:00 Go to previous message
Tim Myer is currently offline Tim MyerFriend
Messages: 81
Registered: July 2009
Member
Hi Iris,
You can call Display#syncExec or Display#asyncExec to run on the display
thread.
------Tim------

Iris wrote:
> Hi Tim,
>
> Thank you very much! This helped me a lot! I can now trace all changed
> made to models. the only problem that I currently have is that the
> method PlatformUI.getWorkbench().getActiveWorkbenchWindow() needs to be
> called from within a UI thread. Otherwise it always returns null.
> How can I call it from a UI thread if my plugin does not make
> contributions to the UI?
>
> Many thanks for your help!
Re: UML 2 Plugin [message #626692 is a reply to message #477498] Tue, 10 June 2008 15:53 Go to previous message
Tim Myer is currently offline Tim MyerFriend
Messages: 81
Registered: July 2009
Member
Hi Iris,
Perhaps one of these options would help:

1. For any UMLEditor that is opened, you could get the CommandStack
from the EditingDomain, add a CommandStackListener and record the
Commands that are executed (see UMLEditor#initializeEditingDomain).
2. For any UMLEditor that is opened, you could get the ResourceSet from
the EditingDomain and attach your own Adapter to listen for Notifications.

Does either of these meet your requirements?
----Tim----



Iris wrote:
> Hi,
>
> I would like to create an Eclipse plugin that keeps track of any changes
> made to a UML model. Can you give me some hints how this could be done?
> Do I need to create an own editor that allows me to trace the changes?
>
> Thank you so much!
>
>
Re: UML 2 Plugin [message #626694 is a reply to message #477502] Wed, 11 June 2008 10:48 Go to previous message
Iris Groher is currently offline Iris GroherFriend
Messages: 33
Registered: July 2009
Member
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 Go to previous message
Tim Myer is currently offline Tim MyerFriend
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 #626699 is a reply to message #477508] Thu, 12 June 2008 11:35 Go to previous message
Iris Groher is currently offline Iris GroherFriend
Messages: 33
Registered: July 2009
Member
Hi Tim,

Thank you very much! This helped me a lot! I can now trace all changed
made to models. the only problem that I currently have is that the method
PlatformUI.getWorkbench().getActiveWorkbenchWindow() needs to be called
from within a UI thread. Otherwise it always returns null.
How can I call it from a UI thread if my plugin does not make
contributions to the UI?

Many thanks for your help!
Re: UML 2 Plugin [message #626703 is a reply to message #477509] Thu, 12 June 2008 15:00 Go to previous message
Tim Myer is currently offline Tim MyerFriend
Messages: 81
Registered: July 2009
Member
Hi Iris,
You can call Display#syncExec or Display#asyncExec to run on the display
thread.
------Tim------

Iris wrote:
> Hi Tim,
>
> Thank you very much! This helped me a lot! I can now trace all changed
> made to models. the only problem that I currently have is that the
> method PlatformUI.getWorkbench().getActiveWorkbenchWindow() needs to be
> called from within a UI thread. Otherwise it always returns null.
> How can I call it from a UI thread if my plugin does not make
> contributions to the UI?
>
> Many thanks for your help!
Previous Topic:Loading a uml model with a profile (in an ATL transformation)
Next Topic:Sterotypes
Goto Forum:
  


Current Time: Sun Apr 05 00:59:05 GMT 2020

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

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

Back to the top