Undo [message #892984] |
Mon, 02 July 2012 04:32  |
Eclipse User |
|
|
|
Hi,
I am having trouble with undo: It doesn't work correctly on Connections. If I create a new Connection in the diagram and undo that step, the Connection will be deleted from .diagram file as expected, but it will stay in the view (until I close and open it again). Could someone explain me how the undo works, to help me debug (I did not override it)? Can this be due to the update feature?
|
|
|
|
|
|
Re: Undo [message #894092 is a reply to message #893940] |
Fri, 06 July 2012 11:22   |
Eclipse User |
|
|
|
here my add Methode of the a connection (there are different ones, but one will do, as it is always the same problem).
/**
* {@inheritDoc}
*/
@Override
public PictogramElement add(IAddContext context) {
IAddConnectionContext addConContext = (IAddConnectionContext) context;
// TODO: Domain object
Rule addedDomainObject = (Rule) context.getNewObject();
ISprayStyle style = new RuleStyle();
ISprayConnection connection = new SimpleArrowShape(getFeatureProvider());
Connection result = (Connection) connection.getConnection(getDiagram(), style, addConContext.getSourceAnchor(), addConContext.getTargetAnchor());
// create link and wire it
peService.setPropertyValue(result, PROPERTY_MODEL_TYPE, CorePackage.Literals.RULE.getName());
link(result, addedDomainObject);
for (ConnectionDecorator conDecorator : result.getConnectionDecorators()) {
link(conDecorator, addedDomainObject);
}
setDoneChanges(true);
updatePictogramElement(result);
/*
* My add:
* add false connections to enable collapse/expand
*/
CustomContext ccontext = new CustomContext();
PictogramElement[] pea = new PictogramElement[2];
pea[0] = addConContext.getSourceAnchor().getParent();
pea[1] = addConContext.getTargetAnchor().getParent();
ccontext.setPictogramElements(pea);
ccontext.putProperty("type", "rule");
ICustomFeature[] cfs = getFeatureProvider().getCustomFeatures(ccontext);
for(ICustomFeature cf : cfs){
if(cf instanceof MyCreateFalseConnectionsFeature){
if(cf.canExecute(ccontext)){
cf.execute(ccontext);
}
}
}
return result;
}
and here is how the connection is created (getConnection Method of DottedArrowShape)
@Override
public Connection getConnection(final Diagram diagram, final ISprayStyle sprayStyle, final Anchor startAnchor, final Anchor endAnchor) {
final Connection newConnection = peCreateService.createFreeFormConnection(diagram);
newConnection.setStart(startAnchor);
newConnection.setEnd(endAnchor);
final Polyline polyline = gaService.createPolyline(newConnection);
polyline.setStyle(sprayStyle.getStyle(diagram));
// Define general layout of connection
polyline.setLineStyle(LineStyle.DASH);
// Set the Placings of the connection
{
ConnectionDecorator decorator = peCreateService.createConnectionDecorator(newConnection, false, 1.0, true);
List<Point> pointList = new ArrayList<Point>();
pointList.add(gaService.createPoint(-10, 10, 0, 0));
pointList.add(gaService.createPoint(0, 0, 0, 0));
pointList.add(gaService.createPoint(-10, -10, 0, 0));
Polyline element = gaService.createPolyline(decorator, pointList);
ISprayStyle style = sprayStyle;
element.setStyle(style.getStyle(diagram));
}
return newConnection;
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05675 seconds