[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Unhandled event loop exception (problem with read-only transaction context)

Vlad,

it looks like a straightforward solution, however it leads to a very similar problem:
the ICommandProxy can only wrap org.eclipse.gmf.runtime.common.core.command, not the EMF command (org.eclipse.emf.common.command.Command).


Am I missing something obvious here?

--Jirka

You cannot do that unfortunately. The GraphicalEditPart.getCommand() wraps
the calls to the edit policies into a read only transaction so you can
read the model. That transaction doesn't allow you to modify the
model. Wrap your SetCommand into an ICommandProxy and return it from the
edit policy.

vlad

On Wed, 21 Feb 2007 10:28:15 +0100, Jiri Semecky wrote:

I'm trying to set the model attribute when an editpart is double-clicked.
The scenario follows:

1. in en EditPart I install an OpenEditPolicy
2. in getOpenCommand execute EMF command and return null for the GEF command

installEditPolicy(EditPolicyRoles.OPEN_ROLE, new OpenEditPolicy() {
   protected Command getOpenCommand(Request request) {
      getEditingDomain().getCommandStack().execute(
         SetCommand.create(
	     getEditingDomain(),
              ((Node)getModel()).getElement(),
              XXXPackage.eINSTANCE.getYYYType_ZZZ(),
              "new_src_value" ) );
      return null;
   }
};

3. I get "Unhandled event loop exception:"
java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context


What is the problem?
Could the EMF command (org.eclipse.emf.common.command.Command) be somehow encapsulated into a GEF command (org.eclipse.gef.commands.Command)


Thanks for any hint,
--Jirka