|
Re: CompoundCommand.appendAndExecute question [message #1714625 is a reply to message #1714456] |
Sat, 14 November 2015 07:26 |
Ed Merks Messages: 33133 Registered: July 2009 |
Senior Member |
|
|
Celine,
On 13/11/2015 4:25 PM, Celine Bensoussan wrote:
> Hi,
>
> I have an issue understanding how appendAndExecute() works.
> It seems that if I appendAndExecute a RemoveCommand it will be
> successfully execute once, and then it will be executed again when
> performing the compoundCommand.execute() where it will fail. Should it
> know during the execute that this command has already been executed
> and should not be executed again ?
The Javadoc shows it being using during the execute() of command.
>
> private CompoundCommand deleteFeatureSelection(AssociationEnd
> associationEnd, EditingDomain editingDomain) {
> CompoundCommand compoundCommand = new CompoundCommand();
> //When this is just an append, it works nicely but I need it to
> be executed before createFeatureSelection
> compoundCommand.appendAndExecute(RemoveCommand.create(editingDomain,
> associationEnd.getFeatureSelection()));
> return compoundCommand;
> }
This isn't using a command stack. This isn't how it should be used.
>
>
>
> public void doSomething(AssociationEnd associationEnd) {
> EditingDomain editingDomain =
> EMFEditUtil.getEditingDomain(associationEnd);
> CompoundCommand compoundCommand = new CompoundCommand();
>
> compoundCommand.append(deleteFeatureSelection(associationEnd,
> editingDomain));
> //This createFeatureSelection needs all command from
> deleteFeatureSelection to have been executed
> compoundCommand.append(createFeatureSelection(associationEnd,
> editingDomain));
>
> compoundCommand.execute();
> }
This also isn't using a command stack. Is the problem you're trying to
solve that the createFeatureSelection command isn't enabled (canExecute
is false) unless the deleteFeatureSelection is already executed? Is the
containment reference to it single valued such that a SetCommand can
simply replace the old with the new?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02265 seconds