Class EmfTreePage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject>

java.lang.Object
com.amalgamasimulation.desktop.appelements.pages.AbstractEmfPage<T,V,EMFTree<V>,TreePageProperties<V>>
com.amalgamasimulation.desktop.appelements.pages.EmfTreePage<T,V>
All Implemented Interfaces:
IPartPage<T>

public class EmfTreePage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject> extends AbstractEmfPage<T,V,EMFTree<V>,TreePageProperties<V>>
Page with an EMFTree built from the flat list AbstractEmfPage.feature of the container. All nodes are in this list. Nodes without a parent are the roots, and the children come from the childrenFeature. The childrenFeature must have an opposite reference: the page finds the parent through it, and the builder checks this. The page is usually built with Pages.emfTree.

Updates

When the list changes, or the childrenFeature or its opposite changes in any node, the page schedules one update for the next UI cycle: it collects the roots again and refreshes the whole tree, keeping expanded nodes and the selection. Methods that read the tree, such as the selection and the toolbar buttons, apply a scheduled update first. Fields of the nodes are updated for observableFeatures and observablePath, and only in visible nodes.

Toolbar

Create adds an element to the container, remove deletes the selected nodes, and up and down move a node among its siblings: a root in AbstractEmfPage.feature, a child in the childrenFeature of its parent. The buttons are disabled while there is no container.
  • Constructor Details

    • EmfTreePage

      public EmfTreePage(AbstractPagesPart<T,?> part, T type, Supplier<org.eclipse.emf.ecore.EObject> containerSupplier, org.eclipse.emf.ecore.EStructuralFeature feature, org.eclipse.emf.ecore.EReference childrenFeature, Consumer<EMFTree<V>> columns, TreePageProperties<V> properties)
      Creates a page. Usually the builder calls it.
      Parameters:
      part - part the page is registered in
      type - tree element type the page is shown for
      containerSupplier - returns the container; called each time the page is shown
      feature - feature of the container that holds all nodes
      childrenFeature - reference to the children; it must have an opposite reference
      columns - adds the columns to the tree
      properties - settings from the builder
  • Method Details

    • addColumns

      public EmfTreePage<T,V> addColumns(Consumer<EMFTree<V>> columns)
      Adds columns after the ones already set. A subclass of the part uses it to extend a page created by the base part. Call it before the controls are created.
      Parameters:
      columns - adds the columns to the tree
      Returns:
      this page
    • addObservableFeatures

      public EmfTreePage<T,V> addObservableFeatures(org.eclipse.emf.ecore.EStructuralFeature... observableFeatures)
      Adds node features whose change updates the node. Call it before the controls are created.
      Parameters:
      observableFeatures - features of the node
      Returns:
      this page
    • addObservablePath

      public EmfTreePage<T,V> addObservablePath(org.eclipse.emf.ecore.EStructuralFeature... path)
      Adds a path of references; a change at its end updates the node. An empty path is not added. Call it before the controls are created.
      Parameters:
      path - features from the node to the observed one
      Returns:
      this page
    • toolBar

      Returns the builder of the toolbar of this page; its end() returns the page. Call it before the controls are created.
      Returns:
      the toolbar builder
    • createViewer

      protected EMFTree<V> createViewer(org.eclipse.swt.widgets.Composite parent)
      Creates the toolbar, if it has buttons, and the tree with the style, check boxes and row header set in the builder.
      Specified by:
      createViewer in class AbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject,EMFTree<V extends org.eclipse.emf.ecore.EObject>,TreePageProperties<V extends org.eclipse.emf.ecore.EObject>>
      Parameters:
      parent - parent with a one-column GridLayout
      Returns:
      the tree
    • configureViewer

      protected void configureViewer()
      Sets the columns, field updates, double click and toolbar, listens to the list and to the parent and children references, and builds the tree for the first time.
      Specified by:
      configureViewer in class AbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject,EMFTree<V extends org.eclipse.emf.ecore.EObject>,TreePageProperties<V extends org.eclipse.emf.ecore.EObject>>
    • updateEnabled

      public void updateEnabled()
      Updates the enabled state of the toolbar buttons. Call it when the enabled condition of a button depends on a state outside the model. Does nothing before the controls are created.
    • setSelection

      public void setSelection(Object selection)
      Applies a scheduled update of the tree, then selects the object as AbstractEmfPage.setSelection(Object) does.
      Specified by:
      setSelection in interface IPartPage<T extends AbstractTreeElementType>
      Overrides:
      setSelection in class AbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject,EMFTree<V extends org.eclipse.emf.ecore.EObject>,TreePageProperties<V extends org.eclipse.emf.ecore.EObject>>
      Parameters:
      selection - object to select, may be null
    • selectFirstRow

      protected Object selectFirstRow()
      Selects the first root of the tree.
      Specified by:
      selectFirstRow in class AbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject,EMFTree<V extends org.eclipse.emf.ecore.EObject>,TreePageProperties<V extends org.eclipse.emf.ecore.EObject>>
      Returns:
      the selected object, or null if the tree is empty