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 04:49 Go to next message
Raghava Rao is currently offline Raghava Rao
Messages: 62
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 00:58 Go to previous messageGo to next message
Raghava Rao is currently offline Raghava Rao
Messages: 62
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 09:12 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
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 05:55 Go to previous messageGo to next message
Raghava Rao is currently offline Raghava Rao
Messages: 62
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 03:38 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
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 07:18 Go to previous messageGo to next message
Raghava Rao is currently offline Raghava Rao
Messages: 62
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 07: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 08:33 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
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 02:15 Go to previous messageGo to next message
Raghava Rao is currently offline Raghava Rao
Messages: 62
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 08:51 Go to previous message
Aljoscha Hark is currently offline Aljoscha Hark
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
Previous Topic:Can I change context pad location for a shape
Next Topic:GraphitiConnectionEditPart causes problem
Goto Forum:
  


Current Time: Wed Jul 30 17:23:01 EDT 2014

Powered by FUDForum. Page generated in 0.01802 seconds