|
|
|
|
Re: update on nested GA [message #810114 is a reply to message #809761] |
Wed, 29 February 2012 18:06 |
Josef Pohl Messages: 82 Registered: January 2012 |
Member |
|
|
Hi Michael,
Sorry, I guess the code was a little out of context. It represent the code in the update method of my UpdateStrategyFeature class.
I thought, and please correct me if I am wrong, that I was deleting the GA by setting poly = null, poly being the GA associated with the shape.
The hierarchy is like this:
ContainerShape
|
|--> GA (parallelogram)
|
|--> Shape
|--> GA (diamond) (link(shape, businessObject))
| ...other Shapes
This is the error that I am getting:
!MESSAGE The following resources could not be saved:
URI: platform:/resource/egsc_test3/src/diagrams/Test26.diagram, cause:
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The object 'org.eclipse.graphiti.mm.pictograms.impl.PictogramLinkImpl@19ebfd1' is not contained in a resource.
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveImpl.java:307)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:271)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:333)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1423)
...
I get it on a save after an update. Not during the update itself.
I updated the code to try to remove the link. (See below. I have gone through several iterations on this. This is the latest version.)
I have noted that if I remove the line
from the add feature, where shape is the PE for the diamond I am trying to remove and addedClass is the BO, then everything works OK. No error on the save.
So, in reference to the code below, is there another way I should be deleting the GA?
Is there another way to access and delete that link explicitly?
Thanks as always for all your help,
Joe
public boolean update(IUpdateContext context) {
String description = null;
int shapeToRemove = -1;
PictogramElement pE = context.getPictogramElement();
Object bo = getBusinessObjectForPictogramElement(pE);
boolean tbdBO = false;
if(bo instanceof Strategy) {
Strategy strategy = (Strategy) bo;
description = strategy.getDescription();
}
int index = 0;
if(pE instanceof ContainerShape) {
ContainerShape cs = (ContainerShape) pE;
for(Shape shape : cs.getChildren()) {
if(shape.getGraphicsAlgorithm() instanceof MultiText && needsTextUpdate){
MultiText text = (MultiText) shape.getGraphicsAlgorithm();
text.setValue(description);
needsTextUpdate = false;
return true;
}
else if (shape.getGraphicsAlgorithm() instanceof Polygon){
Polygon poly = (Polygon) shape.getGraphicsAlgorithm();
if(needsDiamondRemoved){
if(Graphiti.getPeService().
getPropertyValue(shape, "shape-type").
equals("diamond")){
shapeToRemove = index;
PictogramLink l = shape.getLink();
shape.setLink(null);
l = null;
//shape.setGraphicsAlgorithm(null);
poly = null;
//Graphiti.getPeService().deletePictogramElement(pge);
needsDiamondRemoved = false;
}
}
}
index +=1;
}
if(shapeToRemove > -1){
Shape s = cs.getChildren().get(shapeToRemove);
cs.getChildren().remove(shapeToRemove);
//PictogramLink l = s.getLink();
//s.setLink(null);
//l = null;
s = null;
return true;
}
}
return false;
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04182 seconds