[Transaction] Command is not executed [message #62858] |
Mon, 27 November 2006 10:47  |
Eclipse User |
|
|
|
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 #62875 is a reply to message #62869] |
Tue, 28 November 2006 10:02  |
Eclipse User |
|
|
|
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 10:53  |
Eclipse User |
|
|
|
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 10:02  |
Eclipse User |
|
|
|
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
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03414 seconds