Update/refresh automatically feature [message #1090494] |
Tue, 20 August 2013 08:03 |
Andrej K Messages: 26 Registered: March 2013 Location: germany |
Junior Member |
|
|
Hello!
i have an Graphiti editor as RCP. The mean application provide the information to my graphiti editor and "say" what he need to show.
I can load, place and connect elements automatically. Now i need functionality which can refresh/update the shown information in elements which are already placed. (like color, size of elements inside, text...)
I can find and read information of element which i exactly want to update/refresh, but if i want to change him, i get this error:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
Here how i try to do this:
I have an method in the RCP where i call the graphiti feature to update the exact (elementIdInsideEditor) element:
public static void updateXXX(...) {
Diagram diagram = ((MyEditor) myEditor).getDiagramTypeProvider().getDiagram();
EList<Shape> diagramChildren= diagram.getChildren();
PictogramElement pe = diagramChildren.get(elementIdInsideEditor).getGraphicsAlgorithm().getPictogramElement();
UpdateContext updateContext = new UpdateContext(pe);
updateContext.putProperty(... , ...);
IUpdateFeature iUpdateFeature = ((MyEditor) myEditor)
.getDiagramTypeProvider()
.getFeatureProvider()
.getUpdateFeature(updateContext);
if(iUpdateFeature.canUpdate(updateContext))
iUpdateFeature.update(updateContext);
}
I get from "canUpdate" true and can call my "update feature", there i can reed the informations of my PictogrammElement(pe) but if i want to change something, i get the error
public boolean update(IUpdateContext context) {
PictogramElement pe = context.getPictogramElement();
Object bo = getBusinessObjectForPictogramElement(pe);
if (bo instanceof SketchElement) {//wenn es ein sketchelement ist
SketchElement sElement = (SketchElement)bo;
if(pe instanceof ContainerShape){
ContainerShape cs = (ContainerShape) pe;
for (Shape shape : cs.getChildren()) {
if(shape.getGraphicsAlgorithm() instanceof Rectangle){
Rectangle rect = (Rectangle)shape.getGraphicsAlgorithm();
rect.setBackground(manageColor(myColor)); //!!
rect.setX(10); //!!
}
}
}
}
return true;
}
setBackground or setX doesn't work
I'm wondering why it is not possible, the code is similar for automatically place, connect or drag and drop from an independent Tree-view
can somebody give me a hint why it doesn't work?
Regards Andrej
-------
Topic can be closed...
how it always happens, you try a long time, ask somebody and directly after this you found a solution
here is a hint:
http://stackoverflow.com/questions/17592810/automatic-update-of-graphiti-diagrams-in-case-of-changes-in-the-datamodel
[Updated on: Tue, 20 August 2013 08:52] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.01908 seconds