Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » TransactionalEditing Domain problem
TransactionalEditing Domain problem [message #716397] Wed, 17 August 2011 09:48 Go to next message
Murthy Bhat is currently offline Murthy Bhat
Messages: 159
Registered: July 2009
Senior Member
Hello,

I have a Graphiti based diagram editor which allows for editing my domain model graphically. Now, I have a case where i have to manually modify the domain model just before save. But when i try to run a "RecordingCommand" I get the error saying "Cannot activate read/write transaction in read-only transaction context". Any idea where am I going wrong ? Is it the command ?


Regards,
Murthy
Re: TransactionalEditing Domain problem [message #716410 is a reply to message #716397] Wed, 17 August 2011 10:37 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim Kaiser
Messages: 118
Registered: July 2009
Senior Member
Hi Murthy,

how do you execute the command?
At which point exactly (when) do you execute the command (callstack)?

Possibly there is a read-only transaction open already
within whih you cannot nest a write-transaction...

Best, Tim
Re: TransactionalEditing Domain problem [message #716419 is a reply to message #716410] Wed, 17 August 2011 11:19 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy Bhat
Messages: 159
Registered: July 2009
Senior Member
Hi Tim,

Thanks.

I am executing this command in the doSave() method of my own ResourceFactory. I need some changes to be done to the domain model before its persisted onto the file. So I set my values using the record command. Something like this :



 @Override
      public void doSave(OutputStream outputStream, Map< ? , ? > options)
            throws IOException
{
      MyModel myModel=...;
      TransactionalEditingDomain editingDomain = getEditingDomain(resourceSet);

      final CommandStack commandStack = editingDomain.getCommandStack();
      commandStack.execute(new RecordingCommand(editingDomain)
      {
         @Override
         protected void doExecute()
         {
              //My custom Changes
              myModel.setCustomName("");
          
            }
         }
      });

   super.save(outputStream, options);
}
   



Thanks,
Murthy
Re: TransactionalEditing Domain problem [message #716426 is a reply to message #716419] Wed, 17 August 2011 11:32 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim Kaiser
Messages: 118
Registered: July 2009
Senior Member
The command looks good.
How is your doSave method interwoven with the Graphiti framework?
Re: TransactionalEditing Domain problem [message #716501 is a reply to message #716426] Wed, 17 August 2011 15:05 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy Bhat
Messages: 159
Registered: July 2009
Senior Member
My resourceset contains as contents (GraphitiDiagramModel+MyModel) which are linked to each other. I was wondering if modifying the resourceset (modify its contents) is affecting the emf transaction due to its graphiti connection?


Thanks,
Murthy
Re: TransactionalEditing Domain problem [message #716742 is a reply to message #716501] Thu, 18 August 2011 09:46 Go to previous message
Murthy Bhat is currently offline Murthy Bhat
Messages: 159
Registered: July 2009
Senior Member
Hi Tim,

Thanks for the suggestion. I guess I had another read-only transaction open already over which i was trying to run another transaction. By moving my model modification to a much earlier state i was able to resolve my problem.

Regards,
Murthy
Previous Topic:Using user defined shapes in Graphiti
Next Topic:Adding Shapes Programmatically
Goto Forum:
  


Current Time: Fri Oct 31 06:26:39 GMT 2014

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

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