Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Simple collapsefeature
Simple collapsefeature [message #889810] Tue, 19 June 2012 13:55 Go to next message
Patrick Rütz is currently offline Patrick Rütz
Messages: 11
Registered: June 2012
Junior Member
Hi,

i try to implement a simple collapsefeature, by resizing the eclass. Now my Problem, I can´t uncollapse the eclass to the origin size. Because of I can´t save the origin size in a variable. I think there is build eveytime I use it a now feature by the featureprovider. That means I can´t store the height and width in variables. Knows somebody a way to retore the origin size?

Thanks a lot

Greetings Patrick
Re: Simple collapsefeature [message #889860 is a reply to message #889810] Tue, 19 June 2012 22:23 Go to previous messageGo to next message
Aljoscha Hark is currently offline Aljoscha Hark
Messages: 24
Registered: March 2012
Junior Member
hi,

i think you could easily achieve this by using "User-Defined Properties" as described in [1].

in your case before collapsing the compartment, you would save the current values, e.g.

PictogramElement pe = ...; // compartment
int width = pe.getGraphicsAlgorithm().getWidth();
int height = pe.getGraphicsAlgorithm().getHeight();

Graphiti.getPeService().setPropertyValue(pe, "initial_width", String.valueOf(width));
Graphiti.getPeService().setPropertyValue(pe, "initial_height", String.valueOf(height));


during re-expanding you can access those values by

PictogramElement pe = ...; // compartment
int width = 0;
String widthValue = Graphiti.getPeService().getPropertyValue(pe, "initial_width");
if(widthValue != null) {
	width = Integer.parseInt(widthValue);
}
int height = 0;
String heightValue = Graphiti.getPeService().getPropertyValue(pe, "initial_height");
if(heightValue != null) {
	height= Integer.parseInt(heightValue );
}

pe.getGraphicsAlgorithm().setWidth(width);
pe.getGraphicsAlgorithm().setHeight(height);


greetings,
aljoscha

[1] (add http) help.eclipse.org/indigo/topic/org.eclipse.graphiti.doc/resources/docu/gfw/user-defined-properties.htm
Re: Simple collapsefeature [message #889977 is a reply to message #889860] Wed, 20 June 2012 09:05 Go to previous messageGo to next message
Patrick Rütz is currently offline Patrick Rütz
Messages: 11
Registered: June 2012
Junior Member
Thanks that works very fine, now i have a second problem. If I had a transition to an eclass in a eclass which I want to collapse, the transition don´t follow the collapsed eclass, so it is only at the point where the eclass was before. How could i change that?

Thanks
Re: Simple collapsefeature [message #891775 is a reply to message #889810] Mon, 25 June 2012 16:57 Go to previous messageGo to next message
Patrick Rütz is currently offline Patrick Rütz
Messages: 11
Registered: June 2012
Junior Member
Ok finally got it. There is still a little Problem. How could i store a map? In the setProperty function, are only strings allowed. Is it possible to store the content of a map, to use it by using the collapsefunction a second time?

Thanks a lot

Patrick
Re: Simple collapsefeature [message #891859 is a reply to message #891775] Tue, 26 June 2012 06:43 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1590
Registered: July 2009
Location: Walldorf, Germany
Senior Member
The properties stored this way need to be strings because they need to be
persisted as such. You will need to serialize the map or add separate
properties for the entries in the map (of course the latter is only feasable
if there are not many entries).

Michael
Re: Simple collapsefeature [message #891932 is a reply to message #889810] Tue, 26 June 2012 11:52 Go to previous messageGo to next message
Miriam Baran is currently offline Miriam Baran
Messages: 16
Registered: May 2012
Junior Member
Hi,
trying to do a collapse Feature too right now, this post was great help, but the properties don't seem to persist. When I close my diagram with collapsed shapes, they have forgotten they are already collapsed (I use properties to know if a shape is collapsed to disable collapsing collapsed shapes) the next I open the Editor. Is this normal? Is this a problem that has been fixed with the 0.9 version(I am working with 0.8.2)?
Miriam
Re: Simple collapsefeature [message #891978 is a reply to message #891932] Tue, 26 June 2012 14:12 Go to previous messageGo to next message
Patrick Rütz is currently offline Patrick Rütz
Messages: 11
Registered: June 2012
Junior Member
HI Miriam, i have the same Problem. I tried to store connections und anchors in a hashmap. I used the putPropertyfunction. I think normally the map have to be stored like the Stringproperties. But they didn´t. If i execute the feature again the Property with the map is null. Is somebody there who could help us?

Thanks a lot...
Re: Simple collapsefeature [message #892243 is a reply to message #891978] Wed, 27 June 2012 09:28 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1590
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi, not sure what puPropertyfunction you mean?

You should use getProperties().add(...) or addAll(...) on the pictogram
element (e.g. ContainerShape) you want to store properties for. Properties
should be persisted just like any other pictogram element object in the
Graphiti model.

Michael
Re: Simple collapsefeature [message #892248 is a reply to message #889810] Wed, 27 June 2012 09:45 Go to previous messageGo to next message
Miriam Baran is currently offline Miriam Baran
Messages: 16
Registered: May 2012
Junior Member
Hi Michael,
I use the setPropertyValue function of PeService. It works fine, as long as my diagram stays open, but when I close it, and open it again, the properties seem to be lost.

Graphiti.getPeService().setPropertyValue(pe, "initial_width", String.valueOf(width));
Graphiti.getPeService().setPropertyValue(pe, "initial_height", String.valueOf(height));
Graphiti.getPeService().setPropertyValue(pe, "isCollapsed", "true");
Re: Simple collapsefeature [message #892257 is a reply to message #892248] Wed, 27 June 2012 10:05 Go to previous messageGo to next message
Aljoscha Hark is currently offline Aljoscha Hark
Messages: 24
Registered: March 2012
Junior Member
hi,

i dont think the problem is located at the graphiti framework. you could look at your ~.xyz_diagram diagram file with the "Sample Reflective Ecore Model Editor" or any text editor searching for those properties. as i understood your situation, they should be there and the problem that the compartment does not open/"the properties seem to be lost" has to be located elsewhere (you should provide more information about your PE hierarchy and the process of the collapse/expand features and its modifications to the PEs).

greetings,
aljoscha
Re: Simple collapsefeature [message #892293 is a reply to message #892257] Wed, 27 June 2012 11:55 Go to previous messageGo to next message
Patrick Rütz is currently offline Patrick Rütz
Messages: 11
Registered: June 2012
Junior Member
Finally i got it. @Mariam, maybe it´s better if you use a static boolean variable instead of the properties. Good Luck

Patrick
Re: Simple collapsefeature [message #892442 is a reply to message #889810] Thu, 28 June 2012 04:46 Go to previous message
Miriam Baran is currently offline Miriam Baran
Messages: 16
Registered: May 2012
Junior Member
I could find my problem too. Thank you Aljoscha, looking at my diagram in Text-editor really helped me debugging.
Previous Topic:Graphiti Editor in a custom Editor
Next Topic:Overriding the DiagramEditor class
Goto Forum:
  


Current Time: Sat Aug 30 16:39:18 EDT 2014

Powered by FUDForum. Page generated in 0.02167 seconds