Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


The Layout View empowers users to directly modify the layout configuration for the currently viewed diagram. This power, however, comes with a price. Tool developers implementing a IDiagramLayoutManager additionally have to provide an implementation of IMutableLayoutConfig that loads and saves layout option values in a way that they can be stored persistently with the respective diagram. Good examples of such configurators are GmfLayoutConfig and GraphitiLayoutConfig for GMF and Graphiti diagrams, respectively. The GMF implementation stores option values as styles in the GMF Notation model, while the Graphiti implementation stores the values as properties in the Graphiti Pictogram model. If you are developing an editor based on GMF or Graphiti, simply reuse these implementations and you're fine. Otherwise, read this section to learn how to implement a suitable configurator.

Step 1: Implement a Mutable Layout Configurator

A mutable layout configurator is one that can not only read option values, but also write them. Most interface methods are rather self-explanatory, therefore we will consider only the getContextValue(IProperty, LayoutContext) method here. This method receives a LayoutContext and should return a value that corresponds to the given property, if possible, and null otherwise. The starting point is usually the current value of LayoutContext.DIAGRAM_PART in the given context, called the diagram part, which refers to the currently selected diagram element in the viewer (the abstract syntax element). From this the method should extract more information considering the following other context properties:

  • LayoutContext.DOMAIN_MODEL – The domain model element linked to the current diagram part.
  • LayoutContext.CONTAINER_DIAGRAM_PART – The diagram part that corresponds to the graph or subgraph that contains the current diagram part. This is called the container. If The current diagram part is already the top-level element of the diagram, then there is no container and null should be returned.
  • LayoutContext.CONTAINER_DOMAIN_MODEL – The domain model element linked to the container.
  • LayoutContext.OPT_TARGETS – A set containing the kind of graph element that corresponds to the current diagram part, referenced with the enumeration LayoutOptionData.Target. If the diagram part is a node, for example, the set should contain the value NODES. If the node is also a container for a subgraph, the set should additionally contain the value PARENTS.
  • DefaultLayoutConfig.HAS_PORTS – If the current diagram part is a node, the returned value for this property should be true or false depending on whether the node has any ports or not. Ports are explicit connection points for edges; they occur frequently in data flow diagrams.
  • DefaultLayoutConfig.CONTENT_HINT – If the diagram contains an annotation about which layout algorithm to use for the content of the current diagram part, the returned value for this property should be the identifier of that algorithm. This is the same kind of annotation that is accessed through getOptionValue(), i.e. a value set by the user with the Layout View.
  • DefaultLayoutConfig.CONTAINER_HINT – The same as for CONTENT_HINT, but referring to the container.

Step 2: Add the Configurator to the Layout Mapping


  • EclipseLayoutConfig.EDITING_DOMAIN – If your diagram editor needs an EMF editing domain in order to modify annotations of layout options, then such an editing domain should be returned for this property.

An instance of your self-made configurator to the list of configurators of the created LayoutMapping. This makes sure that the options configured in the layout view are actually applied in the layout process.

Step 3: Implement the Adapter Factory Pattern

IDiagramLayoutManager is a subinterface of IAdapterFactory, an interface provided by Eclipse. As such, your diagram layout manager must implement getAdapter(Object, Class).


should be returned by the getDiagramConfig() method of your diagram layout manager.