Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Serialization Questions
Serialization Questions [message #988446] Thu, 29 November 2012 22:03 Go to next message
Nick Collier is currently offline Nick CollierFriend
Messages: 20
Registered: July 2009
Junior Member
I've got a node in my diagram called Node. It has an id property of type String and an Action property of type Action. Action is an EClass in my emf model. Action is never displayed or created in the diagram proper. It is only presented to the user through a custom property sheet that is displayed when the user clicks on Node. The property sheet binds the Action's properties to some widgets. This binding seems to work fine and I can see the action's properties update in the debugger. However there are two problems.

1. Changing the action's properties doesn't result in the diagram being marked as dirty.
2. The action never gets saved when the diagram is saved.

I figure the first of these has something to do with the action being hidden from the diagram code in some way. It doesn't get created via the diagram so it doesn't get hooked into the notification system. How can I mimic that process when I create an Action programmatically?

The second I'm stumped as it looks like the underlying model does contain the action's new properties but its just not getting saved.

thanks,

Nick
Re: Serialization Questions [message #988474 is a reply to message #988446] Fri, 30 November 2012 06:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Nick,

Comments below.

On 29/11/2012 11:03 PM, Nick Collier wrote:
> I've got a node in my diagram called Node. It has an id property of
> type String and an Action property of type Action. Action is an EClass
> in my emf model. Action is never displayed or created in the diagram
> proper. It is only presented to the user through a custom property
> sheet that is displayed when the user clicks on Node. The property
> sheet binds the Action's properties to some widgets. This binding
> seems to work fine and I can see the action's properties update in the
> debugger. However there are two problems.
>
> 1. Changing the action's properties doesn't result in the diagram
> being marked as dirty.
Are you using Commands to make the changes? You must do that so that
it's undoable. Also, I'm pretty sure GMF uses the state of the command
stack to determine dirtiness.
> 2. The action never gets saved when the diagram is saved.
Are your model and your diagram saved to a single resource or two
separate resources?
> I figure the first of these has something to do with the action being
> hidden from the diagram code in some way.
No, likely it's caused by not using commands.
> It doesn't get created via the diagram so it doesn't get hooked into
> the notification system.
EObjects directly produce notifications when modified.
> How can I mimic that process when I create an Action programmatically?
Use a Command.
>
> The second I'm stumped as it looks like the underlying model does
> contain the action's new properties but its just not getting saved.
The whole action, or just not its properties. Presumably these features
are not marked transient...
>
> thanks,
>
> Nick


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Serialization Questions [message #988557 is a reply to message #988474] Fri, 30 November 2012 14:00 Go to previous messageGo to next message
Nick Collier is currently offline Nick CollierFriend
Messages: 20
Registered: July 2009
Junior Member
Ed,

Thanks for the reply. Re. your questions,

1. the model and the diagram are saved to a single resource.
2. The entire Action is not saved. The features are not marked transient.

thanks again,

Nick
Re: Serialization Questions [message #988569 is a reply to message #988557] Fri, 30 November 2012 14:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Nick,

Is the new object you created added to a containment reference for to a
resource's contents? I.e., if you set a breakpoint where you create it
and add it to your model (which presumably you do?), is its
EObject.eResource() non-null?


On 30/11/2012 3:00 PM, Nick Collier wrote:
> Ed,
>
> Thanks for the reply. Re. your questions,
> 1. the model and the diagram are saved to a single resource. 2. The
> entire Action is not saved. The features are not marked transient.
>
> thanks again,
>
> Nick


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Serialization Questions [message #989337 is a reply to message #988569] Wed, 05 December 2012 17:04 Go to previous message
Nick Collier is currently offline Nick CollierFriend
Messages: 20
Registered: July 2009
Junior Member
Ed,

Thanks again for replying. I solved this my reworking my ecore model such that the problematic entities (such as Action) are collections of attributes in other EClasses.

Nick
Previous Topic:Workaround for "Focus transfer copies values into text fields" bug?
Next Topic:Use existing model implementation
Goto Forum:
  


Current Time: Fri Apr 19 20:48:23 GMT 2024

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

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

Back to the top