Skip to content

GemTreeNode

Combine multiple tree nodes to a tree. A tree displays hierarchical data. It provides a visual representation of parent-child relationships, allowing users to navigate and interact with a hierarchical dataset.

Usage Example

/* (c) https://github.com/MontiCore/monticore */
package example_arrange;

import Domain.Person;

import mc.fenix.arrange.GemTreeNode;
import mc.fenix.basic.GemText;
import mc.fenix.input.GemCheckBoxInput;
import mc.fenix.arrange.GemColumn;
import common.ExamplePage;

page GemTreeNodeExample(List<Person> persons) {
  @ExamplePage(
    component = @GemColumn(components = [
      @GemTreeNode(children = [
        @iterate(Person p : persons) {
          @GemTreeNode(
            content = @GemText(value = p.name),
            children = [
              @iterate(Person f : p.friends) {
                @GemTreeNode(
                  content = @GemText(value = f.name),
                  children = [
                    @iterate(Person ff : f.friends) {
                      @GemCheckBoxInput(
                        labelText = ff.name + " is employed",
                        checked = ff.employed
                      );
                    }
                  ]
                );
              }
            ],
            onClick = sayHello(p.name)
          );
        }
      ])
    ]),
    basePath = "example_arrange",
    componentName = "GemTreeNodeExample"
  );
}
GemTreeNodeExample

GUI Model

component GemTreeNode(
  boolean isExpanded = false,
  GUIViewElement content,
  List<GUIViewElement> children,
  Event<Void> onClick,
  Event<boolean> onToggle
)
Name Type Description Default value
isExpanded boolean Whether subtree of this node is expanded false
content GUIViewElement Content of this node. If not set, the node is expected to be the root of the tree.
children List<GUIViewElement> Tree nodes. Each node defines a root of a subtree and its children. Normally set to a list of GemTreeNode. If not set or empty, the node is expected to be a leaf of the tree.
onClick Event<Void> Callback that is executed when the node is clicked.
onToggle Event<boolean> Callback that is executed when the expand/collapse icon is clicked. Returns true if the subtree is expanded, otherwise false.