-
Hi, I have a UML diagram editor which is built similar to the example project for Java-EMF-Theia (https://github.com/eclipse-glsp/glsp-examples/tree/master/project-templates/java-emf-theia), but with a UML model as a source model. I already have packages with compartments with the freeform layout, which works just as expected. But now I want to add attributes to a compartment inside of a class node in a structured manner. Attributes are added to classes by adding a node (with a label) to a compartment of the class. The issue that I can't seem to fix is that the VBOX layouting inside of the compartment does not work. When I build the GCompartment in the gmodel factory, I use In this image, there are actually two attributes on top of each other, but I would like them to be automatically arranged vertically. Of course, I when adding a new attribute, I could just count the existing attributes of the class and set the position manually. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Hi @Ginxss, Indeed, this is exactly what the VBox layout is supposed to do; so there might be a configuration issue. Can you show the Json Graph model you use for rendering this Class and its children? I would expect the following structure:
(Properties could also be GNode with nested GLabel, I guess; it doesn't really matter in this example. The Class label may also be wrapped into its own Compartment - doesn't matter either) |
Beta Was this translation helpful? Give feedback.
-
The structure seems correct to me. On the client side, do you use the GLSP And which version of the GLSP Client are you currently using? The latest release is 1.0.0, but Layout has changed a bit in the upcoming 1.1.0 version. |
Beta Was this translation helpful? Give feedback.
-
As an update for @CamilleLetavernier and anyone curious, the VBOX container works as expected for labels and compartments, but it just does not work for nodes. This is an example where the label is put in a compartment: GNodeBuilder classBuilder = new GNodeBuilder(UmlModelTypes.CLASS)
.id(id)
.add(new GLabelBuilder(UmlModelTypes.EDITABLE_LABEL)
.id(id + "_label")
.text(cl.getName())
.build())
.add(new GCompartmentBuilder()
.id(id + "_comp")
.add(new GLabelBuilder(UmlModelTypes.EDITABLE_LABEL)
.id(id + "_attribute_label")
.text(cl.getName() + "_test")
.build())
.build())
.layout(GConstants.Layout.VBOX)
.layoutOptions(new GLayoutOptions()
.hAlign(GConstants.HAlign.CENTER)); Which leads to this result: Whereas if you put the label in a node: GNodeBuilder classBuilder = new GNodeBuilder(UmlModelTypes.CLASS)
.id(id)
.add(new GLabelBuilder(UmlModelTypes.EDITABLE_LABEL)
.id(id + "_label")
.text(cl.getName())
.build())
.add(new GNodeBuilder()
.id(id + "_attribute")
.add(new GLabelBuilder(UmlModelTypes.EDITABLE_LABEL)
.id(id + "_attribute_label")
.text(cl.getName() + "_test")
.build())
.build())
.layout(GConstants.Layout.VBOX)
.layoutOptions(new GLayoutOptions()
.hAlign(GConstants.HAlign.CENTER)); It leads to this result: So if you want layout nodes vertically until this gets fixed, the workaround is to put every node inside of another compartment, which would look like this:
|
Beta Was this translation helpful? Give feedback.
-
Hi @Ginxss , Sorry for the delay! I wanted to create a small example to see if I could reproduce the issue. I used the following structure:
The result looks like this: You can find the example model here: (Note: it is not possible to recreate this model from the Workflow example; I manually tweaked the model to test the layout. However, it should open just fine in the Workflow Example editor) Anyway: it seems that Compartments aren't required. Everything works as expected |
Beta Was this translation helpful? Give feedback.
As an update for @CamilleLetavernier and anyone curious, the VBOX container works as expected for labels and compartments, but it just does not work for nodes.
This is an example where the label is put in a compartment: