In my Graphiti project I use shape properties to trace some elements which have no business objects linked to them.
In my add feature I have the following code.
...and in my feature provider I do the selection in order to return some customized features.
if (!pictogramElement.getProperties().isEmpty() && pictogramElement.getProperties().get(0).getValue() == "activationrectangle") {
return new LayoutActivationRectangleFeature(this);
}
This seemed to work well: when i try to resize my activation rectangle the right LayoutFeature is returned and I have my custom behaviour.
But (the problem) I noticed that this does not work when I open my diagram for later edits. It looks like shape properties are lost after I close the diagram file.
Why? How can I manage to return the right features if I cant count on properties?
Albert Hofkamp wrote on Mon, 30 September 2013 05:37
Testing string equality with object identity seems a bit dangerous to me, does changing == to .equals solve your problem?
You're absolutely right. My fault, I was sure that there was an overloading of the == operator for String objects but it isn't so. That's why it worked only inside a session... i was checking for equality of the references.