Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Update/refresh automatically feature
Update/refresh automatically feature [message #1090494] Tue, 20 August 2013 08:03 Go to next message
Andrej K is currently offline Andrej KFriend
Messages: 26
Registered: March 2013
Location: germany
Junior Member

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)

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:

[Updated on: Tue, 20 August 2013 08:52]

Report message to a moderator

Re: Update/refresh automatically feature [message #1092932 is a reply to message #1090494] Fri, 23 August 2013 10:47 Go to previous message
Felix Velasco is currently offline Felix VelascoFriend
Messages: 43
Registered: July 2009
You need a write transaction to modify the model.
Try substituting this:

for this:
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(diagram);
ted.getCommandStack().execute(new RecordingCommand(editingDomain) {

			protected void doExecute() {
Previous Topic:DiagramEditor refresh behaviour
Next Topic:rolling back model changes
Goto Forum:

Current Time: Sun Nov 29 18:03:25 GMT 2015

Powered by FUDForum. Page generated in 0.02356 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software