Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » How can I combine nested feature calls in one command
How can I combine nested feature calls in one command [message #972030] Mon, 05 November 2012 09:49 Go to next message
Raghava Rao is currently offline Raghava RaoFriend
Messages: 64
Registered: July 2009
Member
Hello All,

I am executing nested feature calls in one feature.
In command stack those will be different commands. On Undo and Redo every feature call will appear as separate command.

I want to combine all in one command.Is there any way to do this?

I want to avoid update command in commandstack, i want to combine update command with previous executed command.Can I do this in Graphiti?

Advance thanks for your reply.

Thanks,
Raghav

Re: How can I combine nested feature calls in one command [message #973173 is a reply to message #972030] Tue, 06 November 2012 05:58 Go to previous messageGo to next message
Raghava Rao is currently offline Raghava RaoFriend
Messages: 64
Registered: July 2009
Member
Hello,

I do not want to include Update,Layout commands for Undo/Redo. I want to incude the same in previously executed operation.

Thanks,
Raghav
Re: How can I combine nested feature calls in one command [message #981557 is a reply to message #973173] Mon, 12 November 2012 14:12 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Raghav,

you can simply trigger an update or layout at the end of another operation
by calling updatePictogramElement or layoutPictogramElement in
AbstractFeature (which should be a super class of your fetaure).

Michael
Re: How can I combine nested feature calls in one command [message #985380 is a reply to message #981557] Thu, 15 November 2012 10:55 Go to previous messageGo to next message
Raghava Rao is currently offline Raghava RaoFriend
Messages: 64
Registered: July 2009
Member
Hello Michael,

Thanks for your response.

I am using same methods to trigger the update for pictogram element.

Suppose i am doing direct edit using direct editing feature,after domain model updation, updatePictogramElement method is executed to update the shape.

For executing the updatefeature new GenericFeatureCommandWithContext will be created and executed in the command stack as per DiagramEditor code.

So on first undo updatefeature will be executed and on second undo direct editing.

As per requirement i do not want to give any update action in menu/undo/redo.

I want to combine the update with previous command (feature),if i do not do so undo/redo on update will show model and pictogram data inconsistency.

please suggest me how can i proceed to resolve the same.

Thanks,
Raghav
Re: How can I combine nested feature calls in one command [message #985799 is a reply to message #985380] Fri, 16 November 2012 08:38 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Raghav,

sorry, I'm not sure if I got your scenario right...

You will only need to wrap the calls into GenericFeatureCommandWithContext
in case you trigger the feature not from within the execution of another
feature. In case you want to trigger from within a feature (e.g. direct
editing) you should simply call the methods directly. This will cause the
update to happen within the same transactional EMF change and add only one
entry to the command stack so there is only one undo added.

Michael
Re: How can I combine nested feature calls in one command [message #986195 is a reply to message #985799] Mon, 19 November 2012 12:18 Go to previous messageGo to next message
Raghava Rao is currently offline Raghava RaoFriend
Messages: 64
Registered: July 2009
Member
Hello Michael,

Thanks for your reply.

you reply answered my question.I am directly calling respective features execute methods with in a the feature.Now I am able to see the command stack with main feature.

But this undo/redo is not working properly.

Looks like Undo/ redo operations are also getting executed in the Command Stack.

If I create three shapes E, C ,F in order.

On First Undo it should remove F

On Second Undo It should remove C

On Third Undo It should remove E

I think this should be behaviour for undo.But last undo operation also exected in Command stack.

Is this a bug in graphiti?

One more question regarding Update command..
if Editor and Properties view are using same transcational editing domain.so all the command will be executed in one command stack.
Any Model change will lead to update command in Editor.
So In command stack last command will be Update command.On undo shape will not have updated model data,so red font will be displayed to respective Shape.
How can I avoid this? How can avoid adding Update command to command stack.
please suggest me.

Thanks,
Raghav

[Updated on: Mon, 19 November 2012 12:18]

Report message to a moderator

Re: How can I combine nested feature calls in one command [message #986733 is a reply to message #986195] Wed, 21 November 2012 13:33 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Raghav,

we recently fixed (for Kepler M2/M3) some bugs that affected the command
stack behavior and may cause a behavior like the one you described. Mostly
the error was caused when a command didn't really change the model. For
details you may check Bugzillas
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389379 and
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391506 .

To avoid the extra update command after changes triggered from the
properties view you can try to add a call to the update feature to the
command in which you set the new property value in the property view.

Michael
Re: How can I combine nested feature calls in one command [message #986864 is a reply to message #986733] Thu, 22 November 2012 07:15 Go to previous messageGo to next message
Raghava Rao is currently offline Raghava RaoFriend
Messages: 64
Registered: July 2009
Member
Hello Michael,

Thanks for your reply.

Regarding Update command..

As we are doing Graphical Editor and Properties view in different plugins, we do not have dependency between them. so we can not call UpdateFeature directly from Properties view.

a.I tried to wrapper GenericFeatureCommandWithContext
b.I implemented my own command by extending org.eclipse.gef.commands.Command.

In both cases canUndo() i made to false.Still undo is getting called for Update Command.Looks like GFCommandStack does not consider canUndo.

c.I tried with Emf Recording Command.Looks like it will clear previous undo stack.

Undo on UpdateFeature will make the graphical editor red font ( as mismatch between diagram and domain model),It may confuse the user.
We are not providing Update Action either in Context Pad or Context Menu.



Can you please suggest on the same?

Thanks,
Raghav
Re: How can I combine nested feature calls in one command [message #986950 is a reply to message #986864] Thu, 22 November 2012 13:51 Go to previous messageGo to next message
Aljoscha Hark is currently offline Aljoscha HarkFriend
Messages: 24
Registered: March 2012
Junior Member
Hello,

regarding to the independence of the property sheet page:

When you are implementing the properties as tabbed properties and its sections are implemented in a similar way as described in the Graphiti tutorial (extending GFPropertySection), you would have the ability to access the active IDiagramEditor, IDiagramTypeProvider and therefore the IFeatureProvider to do a updateIfPossibleAndNeeded(IUpdateContext) after the model change.

To be more concrete:
- we have a simple class representation (a white rectangle with a black border and a text showing the name).
- we change the name of a selected class in the (tabbed) property sheet.
- the UpdateFeature for that element will update the visible name.

during/after the change in the properties, the GFPropertySection (say, ClassNameSection) executes an IFeature on the IDiagramEditor with an appropriate IContext. The IFeature wraps the model change [EObject.eSet(EStructuralFeature)] and calls IFeatureProvider.updateIfPossibleAndNeeded(IUpdateContext) with appropriate data.

I think (hope!) this would wrap all changes to the model and the visual representation (including the update) into one command. I did not try that by myself right now...

When it works it would be glad when you report back. I think the 'wrapping way' would be helpful in some of my cases, too.

Greetings,
Aljoscha
Re: How can I combine nested feature calls in one command [message #1457223 is a reply to message #986950] Fri, 31 October 2014 05:24 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Hello,
I also have problems with executing features and having multiple commands instead of one. This is my scenario: I want to add a shape, a connection and do a layout afterwards. All in one operation.

This is basically what I do:

Within the execution of an add feature for a shape
- retrieve and execute an addConnectionFeature
- call layoutPictogramElement (which in turn retrieves a layoutFeature which is executed. )


If I understand this here correct, I should be able to call features from within features with all ending up in the same command. I debugged the code but I cannot find where collecting the different operations into one really happens. Can someone point me to the right direction please?

Quote:

You will only need to wrap the calls into GenericFeatureCommandWithContext
in case you trigger the feature not from within the execution of another
feature. In case you want to trigger from within a feature (e.g. direct
editing) you should simply call the methods directly. This will cause the
update to happen within the same transactional EMF change and add only one
entry to the command stack so there is only one undo added.


Help would be appreciated
Regards
Thorsten
Re: How can I combine nested feature calls in one command [message #1457543 is a reply to message #1457223] Fri, 31 October 2014 12:39 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Thorsten,

actually, all features (also the ones that are called from within another
feature) will be wrapped in GEF and EMF commands. While executing the EMF
command on the EMF workspace command stack, a check for an existing outer
transaction is done. In case there is no outer transaction, the command es
executed within a new transaction, in case one exists, the command is simply
executed within the current one.

You can have a look at GFWorkspaceCommandStackImpl.execute for details.

Michael
Re: How can I combine nested feature calls in one command [message #1457658 is a reply to message #1457543] Fri, 31 October 2014 15:14 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Michael,
thank you very much for the pointer. As I said. I debuged the code but I did not find the GFWorkspaceCommandStackImpl because we are using an existing ResourceSet and EditingDomain with other project resources. We only use a simple WorkspaceCommandStackImpl. If I use the GFWorkspaceCommandStackImpl then everything works like a charme. Is there anything you could tell me that speaks against using the GFWorkspaceCommandStackImpl for our whole ProjectResourceSet in general?

Regards,
Thorsten
Re: How can I combine nested feature calls in one command [message #1463376 is a reply to message #1457658] Thu, 06 November 2014 14:01 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Thorsten,

inside Graphiti editors (and MultiPageEditors containing a Graphiti editor)
you should definitely use GFWorkspaceCommandStackImpl. Not sure what your
ProjectResourceSet covers, but using it outside a Graphiti editor appears
kind of strange to me as it is very much suited to work for Graphiti.

Michael
Previous Topic:Highlighting Connection of ConnectionDecorator
Next Topic:Filled attribute always true?
Goto Forum:
  


Current Time: Sun Dec 21 04:47:46 GMT 2014

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

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