Graphical Modeling Framework/Models/GMFGraph
- 1 Scenarios
- 1.1 Scalable/resizable figures
- 1.2 How can I start with CustomFigures
- 1.3 How can I use CustomLayout and what is purpose of the CustomAttribute
- 1.4 What to do with strange ClassCastException while working with (say, opening in editor, validating or generating code from) GMFGraph resource.
- 1.5 I really want some GMFGraph notions to have the same name. Is there the way to avoid that ClassCastException?
- 1.6 There's a legacy GEF figure code and I'd like to use it with GMF
- 1.7 I need a figure that is similar to UML package
- 1.8 How to create several figures at once
How can I start with CustomFigures
How can I use CustomLayout and what is purpose of the CustomAttribute
From the newsgroup thread
gmfgraph.CustomLayout is just a gate to the custom implementation of the org.eclipse.draw2d.LayoutManager class. Thus there is in fact 2 questions -- how to write draw2d Layout manager and how to plug it into the gmfgraph. This covers only the latter.
Imagine you have com.xyz.SuperLayout class in the com.xyz.misc plugin. The SuperLayout class has method setBoolParam(boolean) and public instance field int myIntParam; It also expects the instanceof superLayoutData that has setter setStringParam(String s).
To plug this into gmfgraph you need:
- Create separate ResourceGallery, set implementation bundle to "com.xyz.misc"
- Create figures structure.
- In the container node create CustomLayout, set fqn = "com.xyz.SuperLayout". Note that bundleName property of CustomLayout is deprecated and not used, it does not make sense to change it.
- In the just created Custom Layout create custom attribute, set name = boolParam (or BoolParam -- it doesnot make sense) -- the name is derived from setter name, value = (say) "false" or "42 / 2 >= 21".
- Create one more custom attribute, name = "myIntParam" (derived from field name), value = "42", isDirectAccess = true.
- In the child figure create CustomLayoutData, set fqn = "com.xyz.SuperLayutData", repeat step 4 for custom attribute "StringParam" if needed.
Note that values set at the steps 4, 5 are considered opaque and just generated into the setter call or assignment statement as is. Thus, to set the string value "MG" for custom attribute StringParam you need to set value = "MG" (with quotes).
What to do with strange ClassCastException while working with (say, opening in editor, validating or generating code from) GMFGraph resource.
The most common reason of ClassCastException like the one described in the newsgroup thread is name collision in the gmfgraph resource. GMFGraph declares the name attribute for Node's and Figure's as ID-attribute so all names used in given resource should be different.
I really want some GMFGraph notions to have the same name. Is there the way to avoid that ClassCastException?
Yes, sometimes there may be good reasons to have diffent GMFGraph notions with the same name. After all, Compartment's name is shown at the diagram, and it may be usefull to setup different compartments for different nodes to be shown with same label. Just define them in different resources.
There's a legacy GEF figure code and I'd like to use it with GMF
tbd (check for MapMode, etc)
I need a figure that is similar to UML package
There's no need to use custom figure, just use some GMFGraph magic...tbd TODO put link to newsgroup discussion If you like to have custom anchor behaviour (e.g. no link attaching to package title box), you need to hand code it (there was a posting in the newsgroup).
How to create several figures at once
I.e. when creating some element, few additional should be created as well. tbd Need to find better place for this, as it's not gmfgraph topic