Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Hook save operation / override class editor
Hook save operation / override class editor [message #889856] Wed, 20 June 2012 00:43 Go to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 126
Registered: September 2011
Senior Member
Hi,

I want to synchronize the UML models I create with Papyrus with an ECore-Model, e.g. every UML2::Class corresponds to an Ecore::EClass etc.

For that purpose I have overriden e.g. the ClassEditPart and installed an EditPolicy that does the synchronization. That is working and I am ok with this.

But there are three things missing:
(1) I have to hold a reference to the dirty Ecore model instance somewhere.
(2) I need to have access to the Ecore model instance from the Command that does the synchronization
(3) I have to save the dirty Ecore model to hard disk, when a save operation in Papyrus is called.

Right at the moment, every time the synchronization Command is called, I save the changes directly to the file. But then the UML file and the Ecore file become inconsistent and I do not want that.

for (1 and 3) I wanted to override org.eclipse.papyrus.uml.diagram.clazz.UmlClassDiagramForMultiEditor and add a field for storing the reference to the Ecore model. And I wanted to override the doSave method, so that the reference can be stored to harddisk.
But I think that approach is no good idea, because I do not know whether and how it is possible to integrate the inherited editor in Papyrus.

for (3) I have seen the org.eclipse.papyrus.infra.core.lifecycleevents.SaveAndDirtyService extension point, but I do not know if that helps me.


For any hints on points 1-3 or completely other approaches I would be thankful.
Re: Hook save operation / override class editor [message #889892 is a reply to message #889856] Wed, 20 June 2012 07:41 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 511
Registered: February 2011
Senior Member
Hello,


The right solution might be to open your Ecore Editor as a Papyrus nested editor (Just like any other Papyrus Diagram). One editor, one save command, and you should be fine Smile

I'm not sure whether this is documented somewhere, but there are at least two examples of this case in Papyrus:


- Integration of a Nested text-editor for UML Comments: org.eclipse.papyrus.example.uml.comment.editor.newresource + org.eclipse.papyrus.example.text.instance (See trunk/incoming/ on the Papyrus SVN Repository)
- Integration of an EMF Tree Editor for EMF Models: org.eclipse.papyrus.uml.diagram.emftree


The first example is probably better, as it creates a new resource to persist its contents, while the second one relies on the already existing di/notation/uml files.


Regards,
Camille


Camille Letavernier
Papyrus developer
Re: Hook save operation / override class editor [message #890060 is a reply to message #889892] Wed, 20 June 2012 21:15 Go to previous messageGo to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 126
Registered: September 2011
Senior Member
Hi Camille,

thank you for your interesting suggestion. I will take a look into the editos you mentioned.

I've read the extension point documentation of Papyrus before and then I saw this nestedEditor extension point, but I assumed that a nestedEditor can contribute to the uml model, but not to another model. That's why I did not take a closer look at it.



I think the editor have to be opened the whole time, right? Which means, is it visible to the user? I would be ok with this, but I would prefer a synchronization that hidden from the user and happens in the background. Because the user could close the editor and the synchronization stops.

I need the synchronized Ecore-File as an input for another 3rd party Eclipse plugin. Later on, that plugin and Papyrus shall be integrated seamless, which means that the user should not notice the synchronization.


Best regards,
Simon
Re: Hook save operation / override class editor [message #890120 is a reply to message #890060] Thu, 21 June 2012 08:09 Go to previous message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 511
Registered: February 2011
Senior Member
Hello Simon,

Actually, just like Papyrus diagrams, the editor does not need to be opened all the time (Nor to be opened at all). The editor won't be opened at all, unless you explicitly add a handler somewhere to open it.

It may be that you won't even need a nested editor, but simply a new Papyrus IModel (org.eclipse.papyrus.infra.core.model). I've always used this extension with a nested editor, because it often makes sense to add an editor for a new resource, but this isn't required.


Regards,
Camille


Camille Letavernier
Papyrus developer
Previous Topic:Apply OCL Constraints
Next Topic:Class diagram appearance
Goto Forum:
  


Current Time: Fri Dec 19 23:45:14 GMT 2014

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

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