Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Transaction] Command is not executed
[Transaction] Command is not executed [message #62858] Mon, 27 November 2006 15:47 Go to next message
Eclipse UserFriend
Originally posted by: wah.zurich.ibm.com

Hi,

I would like to add a constraint to a UML class. However, I have not
found a tutorial on the transaction API, so I've done some
trial-and-error. Sadly, I stopped with an error.

Here's my code. The problem is that the execute() method is never invoked.

Any help appreciated!

Michael

--

TransactionalEditingDomain editDomain =
TransactionUtil.getEditingDomain(targetClass);

editDomain.getCommandStack().execute(new
org.eclipse.emf.common.command.AbstractCommand() {

public void execute() {
targetClass.getOwnedRules().add(constraint);
}

public void redo() {
// TODO
}
});

editDomain.getCommandStack().flush();
Re: [Transaction] Command is not executed - solved [message #62869 is a reply to message #62858] Mon, 27 November 2006 15:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wah.zurich.ibm.com

I just replaced AbstractCommand with RecordingCommand, and now it's working!

One more question: Is is necessary at all to invoke flush() on the
command stack?


Michael Wahler wrote:
> Hi,
>
> I would like to add a constraint to a UML class. However, I have not
> found a tutorial on the transaction API, so I've done some
> trial-and-error. Sadly, I stopped with an error.
>
> Here's my code. The problem is that the execute() method is never invoked.
>
> Any help appreciated!
>
> Michael
>
Re: [Transaction] Command is not executed - solved [message #62875 is a reply to message #62869] Tue, 28 November 2006 15:02 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hello, Michael,

You didn't actually need to use the RecordingCommand. What you forgot to do
in your AbstractCommand was to override the default implementation of
prepare() to return something other than false (i.e., true). Unless you do
that, the command will not be executable, and the command stack will refuse
to execute it. The RecordingCommand overrides prepare() to return true by
default, because it assumes that subclasses won't have anything to prepare.

You shouldn't need to flush the command stack unless you actually don't want
any of its history to be undoable.

Cheers,

Christian


Michael Wahler wrote:

> I just replaced AbstractCommand with RecordingCommand, and now it's
> working!
>
> One more question: Is is necessary at all to invoke flush() on the
> command stack?
>
>
> Michael Wahler wrote:
>> Hi,
>>
>> I would like to add a constraint to a UML class. However, I have not
>> found a tutorial on the transaction API, so I've done some
>> trial-and-error. Sadly, I stopped with an error.
>>
>> Here's my code. The problem is that the execute() method is never
>> invoked.
>>
>> Any help appreciated!
>>
>> Michael
>>
Re: [Transaction] Command is not executed - solved [message #596242 is a reply to message #62858] Mon, 27 November 2006 15:53 Go to previous message
Michael Wahler is currently offline Michael WahlerFriend
Messages: 14
Registered: July 2009
Junior Member
I just replaced AbstractCommand with RecordingCommand, and now it's working!

One more question: Is is necessary at all to invoke flush() on the
command stack?


Michael Wahler wrote:
> Hi,
>
> I would like to add a constraint to a UML class. However, I have not
> found a tutorial on the transaction API, so I've done some
> trial-and-error. Sadly, I stopped with an error.
>
> Here's my code. The problem is that the execute() method is never invoked.
>
> Any help appreciated!
>
> Michael
>
Re: [Transaction] Command is not executed - solved [message #596251 is a reply to message #62869] Tue, 28 November 2006 15:02 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hello, Michael,

You didn't actually need to use the RecordingCommand. What you forgot to do
in your AbstractCommand was to override the default implementation of
prepare() to return something other than false (i.e., true). Unless you do
that, the command will not be executable, and the command stack will refuse
to execute it. The RecordingCommand overrides prepare() to return true by
default, because it assumes that subclasses won't have anything to prepare.

You shouldn't need to flush the command stack unless you actually don't want
any of its history to be undoable.

Cheers,

Christian


Michael Wahler wrote:

> I just replaced AbstractCommand with RecordingCommand, and now it's
> working!
>
> One more question: Is is necessary at all to invoke flush() on the
> command stack?
>
>
> Michael Wahler wrote:
>> Hi,
>>
>> I would like to add a constraint to a UML class. However, I have not
>> found a tutorial on the transaction API, so I've done some
>> trial-and-error. Sadly, I stopped with an error.
>>
>> Here's my code. The problem is that the execute() method is never
>> invoked.
>>
>> Any help appreciated!
>>
>> Michael
>>
Previous Topic:[Transaction] Command is not executed
Next Topic:Can Validation handle inter-model constraints?
Goto Forum:
  


Current Time: Thu Feb 25 22:48:58 GMT 2021

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

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

Back to the top