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 thechildrenFeature 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 inAbstractEmfPage.feature, a child in the childrenFeature of
its parent. The buttons are disabled while there is no container.-
Field Summary
Fields inherited from class com.amalgamasimulation.desktop.appelements.pages.AbstractEmfPage
container, elements, feature, part, properties -
Constructor Summary
ConstructorsConstructorDescriptionEmfTreePage(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. -
Method Summary
Modifier and TypeMethodDescriptionaddColumns(Consumer<EMFTree<V>> columns) Adds columns after the ones already set.addObservableFeatures(org.eclipse.emf.ecore.EStructuralFeature... observableFeatures) Adds node features whose change updates the node.addObservablePath(org.eclipse.emf.ecore.EStructuralFeature... path) Adds a path of references; a change at its end updates the node.protected voidSets 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.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.protected ObjectSelects the first root of the tree.voidsetSelection(Object selection) Applies a scheduled update of the tree, then selects the object asAbstractEmfPage.setSelection(Object)does.toolBar()Returns the builder of the toolbar of this page; itsend()returns the page.voidUpdates the enabled state of the toolbar buttons.Methods inherited from class com.amalgamasimulation.desktop.appelements.pages.AbstractEmfPage
checkControlsNotCreated, createControls, getCommandFactory, getTreeElementType, getViewer, isShownFor, onReset, onShowMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amalgamasimulation.desktop.appelements.parts.IPartPage
getPartLabel
-
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 intype- tree element type the page is shown forcontainerSupplier- returns the container; called each time the page is shownfeature- feature of the container that holds all nodeschildrenFeature- reference to the children; it must have an opposite referencecolumns- adds the columns to the treeproperties- settings from the builder
-
-
Method Details
-
addColumns
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
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; itsend()returns the page. Call it before the controls are created.- Returns:
- the toolbar builder
-
createViewer
Creates the toolbar, if it has buttons, and the tree with the style, check boxes and row header set in the builder.- Specified by:
createViewerin classAbstractEmfPage<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-columnGridLayout- 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:
configureViewerin classAbstractEmfPage<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 theenabledcondition of a button depends on a state outside the model. Does nothing before the controls are created. -
setSelection
Applies a scheduled update of the tree, then selects the object asAbstractEmfPage.setSelection(Object)does.- Specified by:
setSelectionin interfaceIPartPage<T extends AbstractTreeElementType>- Overrides:
setSelectionin classAbstractEmfPage<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 benull
-
selectFirstRow
Selects the first root of the tree.- Specified by:
selectFirstRowin classAbstractEmfPage<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
nullif the tree is empty
-