How to deal with org.eclipse.emf.common.command.Command ? [message #146026] |
Thu, 09 August 2007 12:41  |
Eclipse User |
|
|
|
Originally posted by: sducas.sdmda.com
Hello
I would like to turn an org.eclipse.emf.common.command.Command instance
into an ICommand so I can pass it to my GEF commandStack with
ICommandProxy ?
What is the real way to deal with those
org.eclipse.emf.common.command.Command instance in a GMF context (at
least a TranscationnalEditingDomain)
THANKS
|
|
|
|
|
Re: How to deal with org.eclipse.emf.common.command.Command ? [message #147032 is a reply to message #146754] |
Fri, 17 August 2007 11:25  |
Eclipse User |
|
|
|
Originally posted by: sducas.sdmda.com
I finnaly wrote my own Bridge Class:
package --------------;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.gef.commands.Command;
public class IUndoableOperationToGefCommandBridge extends Command {
private static final NullProgressMonitor NULL_PROGRESS_MONITOR = new
NullProgressMonitor();
private IUndoableOperation operation;
public IUndoableOperationToGefCommandBridge(IUndoableOperation operation) {
super(operation.getLabel());
this.operation = operation;
}
@Override
public boolean canExecute() {
return operation.canExecute();
}
@Override
public boolean canUndo() {
return operation.canUndo();
}
@Override
public Command chain(Command command) {
return super.chain(command);
}
@Override
public void dispose() {
operation.dispose();
}
@Override
public void execute() {
try {
operation.execute(NULL_PROGRESS_MONITOR,null);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
@Override
public String getDebugLabel() {
return super.getDebugLabel();
}
@Override
public String getLabel() {
return super.getLabel();
}
@Override
public void redo() {
try {
operation.redo(NULL_PROGRESS_MONITOR,null);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
@Override
public void setDebugLabel(String label) {
super.setDebugLabel(label);
}
@Override
public void setLabel(String label) {
super.setLabel(label);
}
@Override
public void undo() {
try {
operation.undo(NULL_PROGRESS_MONITOR,null);
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Stéphane DUCAS a écrit :
> Ok thanks for the tip..
>
> I'll post the complete code fragment from EMF Command to my GEF command
> stack when I've done it..
>
>
> Christian W. Damus a écrit :
>> Hi, Stéphane,
>>
>> You can use the EMFCommandOperation to wrap an EMF Command object in an
>> IUndoableOperation, for execution on the operation history. I'm not sure
>> whether GMF provides such a wrapper implementing the ICommand API, though
>> ...
>>
>> HTH,
>>
>> Christian
>>
>>
>> Stéphane DUCAS wrote:
>>
>>> Hello
>>>
>>> I would like to turn an org.eclipse.emf.common.command.Command instance
>>> into an ICommand so I can pass it to my GEF commandStack with
>>> ICommandProxy ?
>>>
>>> What is the real way to deal with those
>>> org.eclipse.emf.common.command.Command instance in a GMF context (at
>>> least a TranscationnalEditingDomain)
>>>
>>> THANKS
|
|
|
Powered by
FUDForum. Page generated in 0.03238 seconds