Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Custom Actions
Custom Actions [message #72572] Wed, 01 November 2006 07:52 Go to next message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

Hello,

is there any documentation on custom actions? I tried to modify the tutorial
example for my own editor, but always there are execution exceptions.

Honestly I'm not even sure which of all these eclipse,emf,gef,gmf and jface
actions and commands to use, and which are compatible with each other. It
wouldbe great if you could give me some advice.

First what I'm basically trying to do: I have a customization plugin for my
diagram editor as discribed in the tutorial with some actions for (a)
creating new Nodes (like in the example, but in sub-compartments) and (b)
creating and initializing some non-graphical elements.

If I really stick to the example it works: Creating a new Node and a
Connection on the Canvas.

But when I try this in a Sub-Compartment (when the node's parent being
passed to the CreateViewAndOptionallyElementCommand constructor is a
XXXCompartmentEditPart) it doesn't work. The Connection is created (judging
from the source node's outgoing feature), but not the node (resulting in
quite fatal errors when saving the diagram). There is no exception listed
in the problem log, and no undo available.

Another problem is there with a very simple Action I wrote for testing. The
Action extends the same class (IObjectActionDelegate) and tries to execute
a simple gef-Command with execute doing nothing more than setting a string
attribute. When I try to execute this command in the same way like in the
tutorial I get following Exception:

org.eclipse.core.commands.ExecutionException: While executing the operation,
an exception occurred
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:517)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:205)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:168)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:155)
at XXXX.custom.actions.InitMessageAction.run(InitMessageAction. java:27)
....
Caused by: java.lang.IllegalStateException: Cannot modify resource set
without a write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:291)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:253)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:235)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:191)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
at bpmn.impl.ConnectingObjectImpl.setName(ConnectingObjectImpl. java:94)
at
XXXX.custom.actions.InitMessageAction$InitMessageCommand.exe cute(InitMessageAction.java:50)
....

I read about this, but since I do use a commandbeing executed by a command
stack I really don't know what's the problem. I also tried

editingDomain.getCommandStack().execute(SetCommand.create(ed itingDomain,
selectedElement, feature , newValue));

which results in a NullPointerException (and would not be very applicable
for the use I have in mind).

Can you tell me what I'm doing wrong?

tobias
Re: Custom Actions [message #72605 is a reply to message #72572] Wed, 01 November 2006 08:17 Go to previous messageGo to next message
Eclipse UserFriend
On Wed, 2006-11-01 at 13:52 +0100, tobias wrote:
> Hello,
>
> is there any documentation on custom actions? I tried to modify the tutorial
> example for my own editor, but always there are execution exceptions.
>
> Honestly I'm not even sure which of all these eclipse,emf,gef,gmf and jface
> actions and commands to use, and which are compatible with each other. It
> wouldbe great if you could give me some advice.
>
> First what I'm basically trying to do: I have a customization plugin for my
> diagram editor as discribed in the tutorial with some actions for (a)
> creating new Nodes (like in the example, but in sub-compartments) and (b)
> creating and initializing some non-graphical elements.

Maybe this page will be helpful for you:
http://wiki.eclipse.org/index.php/GMF_Tips

Regards,
Seweryn Niemiec
--
Szczecin University of Technology
Academic Center of Computer Science
Re: Custom Actions [message #72734 is a reply to message #72572] Wed, 01 November 2006 11:09 Go to previous message
Eclipse UserFriend
Hi Tobias,

You need a transactional command to edit the model in a write
transaction. In GMF, there are two kinds of transactional commands:
AbstractTransactionalCommand and CompositeTransactionalCommand. GEF
commands are not transactional commands. However, the ICommandProxy in
GMF is a GEF command that delegates to an ICommand, which may be
transactional.

Unfortunately the programmer's guide for GMF commands is out of date
(see https://bugs.eclipse.org/bugs/show_bug.cgi?id=150426) but there is
additional information in the design docs attached to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=113708 and
https://bugs.eclipse.org/bugs/show_bug.cgi?id=112826 that might be
useful to you.

In your test action, try creating a new AbstractTransactionalCommand
whose #doExecuteWithResult sets the string attribute. You can then
execute this command through the Eclipse operation history
(OperationHistoryFactory.getOperationHistory().execute). As a side
note, GMF's DiagramCommandStack just delegates the execution of GEF
commands to the Eclipse operation history.

You can also look at the logic example's
CreateLogicElementActionDelegate, which is used by contributions to the
Eclipse popupMenus extension point to add circuits and half-adders to
the logic diagram. These actions are discussed in the tutorial:
http://help.eclipse.org/help31/topic/org.eclipse.gmf.doc/tut orials/common/Extensible%20Type%20Registry/extensibleTypeReg istryTutorial.html

Hope that helps,
Linda


tobias wrote:
> Hello,
>
> is there any documentation on custom actions? I tried to modify the tutorial
> example for my own editor, but always there are execution exceptions.
>
> Honestly I'm not even sure which of all these eclipse,emf,gef,gmf and jface
> actions and commands to use, and which are compatible with each other. It
> wouldbe great if you could give me some advice.
>
> First what I'm basically trying to do: I have a customization plugin for my
> diagram editor as discribed in the tutorial with some actions for (a)
> creating new Nodes (like in the example, but in sub-compartments) and (b)
> creating and initializing some non-graphical elements.
>
> If I really stick to the example it works: Creating a new Node and a
> Connection on the Canvas.
>
> But when I try this in a Sub-Compartment (when the node's parent being
> passed to the CreateViewAndOptionallyElementCommand constructor is a
> XXXCompartmentEditPart) it doesn't work. The Connection is created (judging
> from the source node's outgoing feature), but not the node (resulting in
> quite fatal errors when saving the diagram). There is no exception listed
> in the problem log, and no undo available.
>
> Another problem is there with a very simple Action I wrote for testing. The
> Action extends the same class (IObjectActionDelegate) and tries to execute
> a simple gef-Command with execute doing nothing more than setting a string
> attribute. When I try to execute this command in the same way like in the
> tutorial I get following Exception:
>
> org.eclipse.core.commands.ExecutionException: While executing the operation,
> an exception occurred
> at
> org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:517)
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:205)
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:168)
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:155)
> at XXXX.custom.actions.InitMessageAction.run(InitMessageAction. java:27)
> ...
> Caused by: java.lang.IllegalStateException: Cannot modify resource set
> without a write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:291)
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:253)
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:235)
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:191)
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
> at bpmn.impl.ConnectingObjectImpl.setName(ConnectingObjectImpl. java:94)
> at
> XXXX.custom.actions.InitMessageAction$InitMessageCommand.exe cute(InitMessageAction.java:50)
> ...
>
> I read about this, but since I do use a commandbeing executed by a command
> stack I really don't know what's the problem. I also tried
>
> editingDomain.getCommandStack().execute(SetCommand.create(ed itingDomain,
> selectedElement, feature , newValue));
>
> which results in a NullPointerException (and would not be very applicable
> for the use I have in mind).
>
> Can you tell me what I'm doing wrong?
>
> tobias
Previous Topic:Gmf rcp lite ...resize/move problem
Next Topic:corrupt icons
Goto Forum:
  


Current Time: Mon May 05 02:10:05 EDT 2025

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

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

Back to the top