Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » modify the semantic model in the table viewer
modify the semantic model in the table viewer [message #634036] Wed, 20 October 2010 10:53 Go to next message
No real name is currently offline No real nameFriend
Messages: 18
Registered: October 2009
Location: denmark
Junior Member
Hi,

I am sorry if I am asking in the wrong newsgroup.

I have created a GMF editor, which contains some edges. The edge owns a list of variable elements. Those variables do not have views, they can be created in the semantic model, the model is saved together with the graphical models in the shared file.

I have created a table viewer window upon double-click on the edge for editing the variable list. The AdapterFactoryContentProvider is attached to the tableviewer. It works very well for displaying the variables.

Then, I would like to modify (editing, add, remove) the variables via the table viewer.

in my ICellModifier() of my viewer, in the modify() method, I did something like:
----------
TransactionalEditingDomain ed = TransactionUtil.getEditingDomain(variable);
Command command = SetCommand.create(ed, variable, CommonPackage.Literals.NAMED_COMPONENT__NAME, value.toString());
boolean isExecutable= command.canExecute();
ed.getCommandStack().execute(command );
------------
The isExecutable is always false. And the execution gives an Cannot activate read/write transaction in read-only transaction context Exception.

Please help me with this problem, Is it correct to modify the semantic model this way? How can I modify the semantic model in the table viewer.

-Wei
Re: modify the semantic model in the table viewer [message #634133 is a reply to message #634036] Wed, 20 October 2010 15:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Wei,

Comments below.

ayia wrote:
> Hi,
>
> I am sorry if I am asking in the wrong newsgroup.
>
> I have created a GMF editor, which contains some edges. The edge owns
> a list of variable elements. Those variables do not have views, they
> can be created in the semantic model, the model is saved together with
> the graphical models in the shared file.
>
> I have created a table viewer window upon double-click on the edge
> for editing the variable list. The AdapterFactoryContentProvider is
> attached to the tableviewer. It works very well for displaying the
> variables.
>
> Then, I would like to modify (editing, add, remove) the variables via
> the table viewer.
>
> in my ICellModifier() of my viewer, in the modify() method, I did
> something like: ----------
> TransactionalEditingDomain ed =
> TransactionUtil.getEditingDomain(variable);
> Command command = SetCommand.create(ed, variable,
> CommonPackage.Literals.NAMED_COMPONENT__NAME, value.toString());
> boolean isExecutable= command.canExecute();
You've traced this with the debugger to see why it's returning false?
> ed.getCommandStack().execute(command );
> ------------
> The isExecutable is always false. And the execution gives an Cannot
> activate read/write transaction in read-only transaction context
> Exception.
>
> Please help me with this problem, Is it correct to modify the semantic
> model this way? How can I modify the semantic model in the table viewer.
>
> -Wei
Re: modify the semantic model in the table viewer [message #634558 is a reply to message #634133] Fri, 22 October 2010 08:43 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 18
Registered: October 2009
Location: denmark
Junior Member
Hi Ed,

I have tried to trace it. The canExecute gives true. but during execution it throws exception.

java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.acquire(TransactionalEditingDomainImpl.java:576)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.activate(TransactionalEditingDomainImpl.java:508)
at org.eclipse.emf.transaction.impl.TransactionImpl.start(Trans actionImpl.java:204)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.cre ateTransaction(WorkspaceCommandStackImpl.java:380)
at org.eclipse.emf.workspace.EMFCommandOperation.createTransact ion(EMFCommandOperation.java:215)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:147)
at org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:511)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doE xecute(WorkspaceCommandStackImpl.java:208)
at org.eclipse.emf.transaction.impl.AbstractTransactionalComman dStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.emf.transaction.impl.AbstractTransactionalComman dStack.execute(AbstractTransactionalCommandStack.java:219)
at system.diagram.edit.parts.dialog.TableEditorComposite$3.modi fy(TableEditorComposite.java:185)

.....

I did some search in the forum, I guess the problem might be that my tabeviewer is opened in the getOpenCommand of an OpenEditPolicy, where I can not modify the semantic model. Is there some alternative ways? Thank you.

Wei
Re: modify the semantic model in the table viewer [message #634695 is a reply to message #634558] Fri, 22 October 2010 17:56 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Wei,

Perhaps you should post to the display thread to do this while you're
not in the middle of opening something.


ayia wrote:
> Hi Ed,
>
> I have tried to trace it. The canExecute gives true. but during
> execution it throws exception.
>
> java.lang.IllegalStateException: Cannot activate read/write
> transaction in read-only transaction context
> at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI
> mpl.acquire(TransactionalEditingDomainImpl.java:576)
> at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI
> mpl.activate(TransactionalEditingDomainImpl.java:508)
> at org.eclipse.emf.transaction.impl.TransactionImpl.start(Trans
> actionImpl.java:204)
> at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.cre
> ateTransaction(WorkspaceCommandStackImpl.java:380)
> at org.eclipse.emf.workspace.EMFCommandOperation.createTransact
> ion(EMFCommandOperation.java:215)
> at org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr
> actEMFOperation.java:147)
> at org.eclipse.core.commands.operations.DefaultOperationHistory
> .execute(DefaultOperationHistory.java:511)
> at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doE
> xecute(WorkspaceCommandStackImpl.java:208)
> at org.eclipse.emf.transaction.impl.AbstractTransactionalComman
> dStack.execute(AbstractTransactionalCommandStack.java:165)
> at org.eclipse.emf.transaction.impl.AbstractTransactionalComman
> dStack.execute(AbstractTransactionalCommandStack.java:219)
> at system.diagram.edit.parts.dialog.TableEditorComposite$3.modi
> fy(TableEditorComposite.java:185)
>
> ....
>
> I did some search in the forum, I guess the problem might be that my
> tabeviewer is opened in the getOpenCommand of an OpenEditPolicy, where
> I can not modify the semantic model. Is there some alternative ways?
> Thank you.
>
> Wei
Previous Topic:Read referenced resource programatically
Next Topic:Read different kinds of xml files into ecore models
Goto Forum:
  


Current Time: Sun Oct 20 02:58:51 GMT 2019

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

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

Back to the top