Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to execute a gmf CopyCommand
How to execute a gmf CopyCommand [message #661407] Thu, 24 March 2011 14:34 Go to next message
Matthias Kloppenborg is currently offline Matthias KloppenborgFriend
Messages: 17
Registered: April 2010
Junior Member
Hello everybody,

i want to execute a copy command programmatically with the following code.

CopyCommand copy = new CopyCommand(domain, "Copy",
diagramWorkbenchPart.getDiagram(), views);

CompositeCommand command = new CompositeCommand("",
Arrays.asList(copy)); IWorkbenchPart wbPart = page.getActivePart();
ActionManager manager = (ActionManager) wbPart
.getAdapter(ActionManager.class);
try {
manager.getOperationHistory().execute(command,
new NullProgressMonitor(),
null);
} catch (ExecutionException e) {
e.printStackTrace();
}

After this i should be able to execute a paste command with the Ctrl + V
in the Editor, but it seems that the CopyCommand doesn't work.

Can somebody please give me a hint what i am doing wrong?

Greetings

Matthias
Re: How to execute a gmf CopyCommand [message #661462 is a reply to message #661407] Thu, 24 March 2011 18:02 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
I know of a bug, in ClipboardSupport. There is a workaround, I am not
sure your problem is related but you could have a look:
It broke in 2.2.2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=306500

How to fix: (Let the internal clip-factory have a higher prio, medium).

<extension

point="org.eclipse.gmf.runtime.emf.clipboard.core.clipboardSupport ">
<factory
class=" org.eclipse.gmf.runtime.notation.providers.internal.copypast e.ClipboardSupportFactory "
nsURI="http://www.eclipse.org/gmf/runtime/1.0.2/notation"
priority="medium">
</factory>


On 24-03-11 07:34, Matthias Kloppenborg wrote:
> Hello everybody,
>
> i want to execute a copy command programmatically with the following code.
>
> CopyCommand copy = new CopyCommand(domain, "Copy",
> diagramWorkbenchPart.getDiagram(), views);
>
> CompositeCommand command = new CompositeCommand("",
> Arrays.asList(copy)); IWorkbenchPart wbPart = page.getActivePart();
> ActionManager manager = (ActionManager) wbPart
> .getAdapter(ActionManager.class);
> try {
> manager.getOperationHistory().execute(command,
> new NullProgressMonitor(),
> null);
> } catch (ExecutionException e) {
> e.printStackTrace();
> }
>
> After this i should be able to execute a paste command with the Ctrl + V
> in the Editor, but it seems that the CopyCommand doesn't work.
>
> Can somebody please give me a hint what i am doing wrong?
>
> Greetings
>
> Matthias
>
>
>
>
Re: How to execute a gmf CopyCommand [message #661542 is a reply to message #661462] Fri, 25 March 2011 08:14 Go to previous message
Matthias Kloppenborg is currently offline Matthias KloppenborgFriend
Messages: 17
Registered: April 2010
Junior Member
I changed the priority, but this did not help. Anyway, thanks for your
suggestion.

Am 24.03.2011 19:02, schrieb Christophe Bouhier:
> I know of a bug, in ClipboardSupport. There is a workaround, I am not
> sure your problem is related but you could have a look:
> It broke in 2.2.2
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=306500
>
> How to fix: (Let the internal clip-factory have a higher prio, medium).
>
> <extension
>
> point="org.eclipse.gmf.runtime.emf.clipboard.core.clipboardSupport ">
> <factory
> class=" org.eclipse.gmf.runtime.notation.providers.internal.copypast e.ClipboardSupportFactory "
>
> nsURI="http://www.eclipse.org/gmf/runtime/1.0.2/notation"
> priority="medium">
> </factory>
>
>
> On 24-03-11 07:34, Matthias Kloppenborg wrote:
>> Hello everybody,
>>
>> i want to execute a copy command programmatically with the following
>> code.
>>
>> CopyCommand copy = new CopyCommand(domain, "Copy",
>> diagramWorkbenchPart.getDiagram(), views);
>>
>> CompositeCommand command = new CompositeCommand("",
>> Arrays.asList(copy)); IWorkbenchPart wbPart = page.getActivePart();
>> ActionManager manager = (ActionManager) wbPart
>> .getAdapter(ActionManager.class);
>> try {
>> manager.getOperationHistory().execute(command,
>> new NullProgressMonitor(),
>> null);
>> } catch (ExecutionException e) {
>> e.printStackTrace();
>> }
>>
>> After this i should be able to execute a paste command with the Ctrl + V
>> in the Editor, but it seems that the CopyCommand doesn't work.
>>
>> Can somebody please give me a hint what i am doing wrong?
>>
>> Greetings
>>
>> Matthias
>>
>>
>>
>>
>
Previous Topic:Problem with GMF editor embedded in SharedHeaderFormEditor.
Next Topic: shared editor domain across several diagram editors
Goto Forum:
  


Current Time: Thu Apr 25 23:52:51 GMT 2024

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

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

Back to the top