Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to deal with org.eclipse.emf.common.command.Command ?
How to deal with org.eclipse.emf.common.command.Command ? [message #146026] Thu, 09 August 2007 12:41 Go to next message
Eclipse UserFriend
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 #146152 is a reply to message #146026] Fri, 10 August 2007 08:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

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
Re: How to deal with org.eclipse.emf.common.command.Command ? [message #146754 is a reply to message #146152] Thu, 16 August 2007 12:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sducas.sdmda.com

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
>
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Shortcuts Decorations
Next Topic:Create Connection in a command
Goto Forum:
  


Current Time: Fri Apr 25 22:07:17 EDT 2025

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

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

Back to the top