|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Undoing direct editing leads to multiple undos [message #1384720 is a reply to message #1384688] |
Fri, 30 May 2014 17:19 |
Al B Messages: 130 Registered: July 2009 |
Senior Member |
|
|
Hi Michael,
I can see that the problem is when a feature is created. For some reason the emf command stack only records the last created feature. For instance, if I drop two elements from the palette onto the diagram editor, then the command stack only shows the last one in the history list (see attached CreateTwice.png file). However, if I drop 2 elements and then I delete the last one, then you can see the two command operations listed in the stack (see CreateTwiceDeleteOne.png).
The problem seems to happen only with the create operation bacause if I execute 2 deletes, then the stack shows the 2 delete operations plus the last create operation. I expect it to show 2 delete operations plus 2 create operations though.
It's definitely strange since the code to create the feature is quite simple (see below) so I'm not sure where the emf command stack is being overridden with the last create operation.
public class CreateGoalFeature extends AbstractCreateNodeFeature {
public static final String NAME = "Goal";
public static final String DESCRIPTION = "Create Goal";
public CreateGoalFeature(IFeatureProvider fp) {
super(fp, NAME, DESCRIPTION);
}
@Override
public Object[] create(ICreateContext context) {
Goal goal = XxegsnFactory.eINSTANCE.createGoal();
goal.setIdentifier(getUniqueId(IIdentifierConstants.GOAL));
getDiagram().eResource().getContents().add(goal);
addGraphicalRepresentation(context, goal);
return new Object[] { goal };
}
@Override
public String getCreateImageId() {
return IImageConstants.GOAL;
}
}
|
|
|
Re: Undoing direct editing leads to multiple undos [message #1384897 is a reply to message #1384720] |
Mon, 02 June 2014 21:15 |
Al B Messages: 130 Registered: July 2009 |
Senior Member |
|
|
Hi, Michael, Laurent,
I think I found out the problem. It's actually caused by the call to updatePictogramElement(containerShape); which is being called from the overridden AbstractAddShapeFeature::add() method as shown below. If I comment out the call to updatePictogramElement(), then undo works properly, but the shape doesn't look right. Any suggestions? Can updatePictogramElement() be called form add()?
@Override
public PictogramElement add(IAddContext context) {
Diagram diagram = (Diagram) context.getTargetContainer();
Goal goal = (Goal) context.getNewObject();
IPeCreateService peCreateService = getPeCreateService();
IGaService gaService = getGaService();
// Container-shape
ContainerShape containerShape = peCreateService.createContainerShape(diagram, true);
peCreateService.createChopboxAnchor(containerShape);
link(containerShape, goal);
// Outer-rectangle
Rectangle outerRectangle = gaService.createInvisibleRectangle(containerShape);
gaService.setLocationAndSize(outerRectangle, context.getX(), context.getY(), context.getWidth(), context.getHeight());
// Inner-rectangle
Rectangle innerRectangle = gaService.createRectangle(outerRectangle);
innerRectangle.setStyle(getStyle(IModelConstants.Goal));
addIdentifier(containerShape);
addDescription(containerShape);
updatePictogramElement(containerShape);
layoutPictogramElement(containerShape);
activateDirectEdit(containerShape, IDiagramConstants.description);
return containerShape;
}
|
|
|
Powered by
FUDForum. Page generated in 0.09760 seconds