Class EmfTablePage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject>
java.lang.Object
com.amalgamasimulation.desktop.appelements.pages.AbstractEmfPage<T,V,EMFTable<V>,TablePageProperties<V>>
com.amalgamasimulation.desktop.appelements.pages.EmfTablePage<T,V>
- All Implemented Interfaces:
IPartPage<T>
public class EmfTablePage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject>
extends AbstractEmfPage<T,V,EMFTable<V>,TablePageProperties<V>>
Page with an
EMFTable of the rows from the list AbstractEmfPage.feature of the container. It is
usually built with Pages.emfTable.
Updates
The table follows the list and adds, removes and moves rows by itself. Changes of the row fields are shown only for the features and paths set withobservableFeatures and
observablePath, and only in visible rows. With checkBox(checkedFeature) the check boxes
and the boolean attribute stay in sync both ways: a check box sets the attribute with a command
on the stack, and a change of the attribute updates the check box.
Toolbar
The default buttons work through theICommandFactory of the part:
- create adds an element to the container, with the
idPatternif it is set; - remove deletes the selected rows;
- copy inserts the copy after the original if the original is in
AbstractEmfPage.feature; - up and down move the row with
MoveCommand; - select from table opens an
EMFMultiSelectionDialog.
-
Field Summary
Fields inherited from class com.amalgamasimulation.desktop.appelements.pages.AbstractEmfPage
container, elements, feature, part, properties -
Constructor Summary
ConstructorsConstructorDescriptionEmfTablePage(AbstractPagesPart<T, ?> part, T type, Supplier<org.eclipse.emf.ecore.EObject> containerSupplier, org.eclipse.emf.ecore.EStructuralFeature feature, Consumer<EMFTable<V>> columns, TablePageProperties<V> properties) Creates a page. -
Method Summary
Modifier and TypeMethodDescriptionaddColumns(Consumer<EMFTable<V>> columns) Adds columns after the ones already set.addObservableFeatures(org.eclipse.emf.ecore.EStructuralFeature... observableFeatures) Adds row features whose change updates the row.addObservablePath(org.eclipse.emf.ecore.EStructuralFeature... path) Adds a path of references; a change at its end updates the row.protected voidConnects the table to the list and sets the columns, check boxes, field updates, double click and toolbar.createViewer(org.eclipse.swt.widgets.Composite parent) Creates the toolbar, if it has buttons, and the table: plain or virtual, with check boxes and a row header, as set in the builder.protected ObjectSelects the first row as the table shows it, after sorting and filtering.voidsetUpdateRestricted(boolean updateRestricted) Detaches the table from the list or attaches it back.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, onShow, setSelectionMethods 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
-
EmfTablePage
public EmfTablePage(AbstractPagesPart<T, ?> part, T type, Supplier<org.eclipse.emf.ecore.EObject> containerSupplier, org.eclipse.emf.ecore.EStructuralFeature feature, Consumer<EMFTable<V>> columns, TablePageProperties<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 the rowscolumns- adds the columns to the tableproperties- 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 table- Returns:
- this page
-
addObservableFeatures
public EmfTablePage<T,V> addObservableFeatures(org.eclipse.emf.ecore.EStructuralFeature... observableFeatures) Adds row features whose change updates the row. Call it before the controls are created.- Parameters:
observableFeatures- features of the row- Returns:
- this page
-
addObservablePath
Adds a path of references; a change at its end updates the row. An empty path is not added. Call it before the controls are created.- Parameters:
path- features from the row 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 table: plain or virtual, with check boxes and a row header, as set in the builder.- Specified by:
createViewerin classAbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject, EMFTable<V extends org.eclipse.emf.ecore.EObject>, TablePageProperties<V extends org.eclipse.emf.ecore.EObject>> - Parameters:
parent- parent with a one-columnGridLayout- Returns:
- the table
-
configureViewer
protected void configureViewer()Connects the table to the list and sets the columns, check boxes, field updates, double click and toolbar.- Specified by:
configureViewerin classAbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject, EMFTable<V extends org.eclipse.emf.ecore.EObject>, TablePageProperties<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. -
setUpdateRestricted
public void setUpdateRestricted(boolean updateRestricted) Detaches the table from the list or attaches it back. Withtruethe table becomes empty and does not react to changes; withfalseit shows the list and the check boxes again. Use it while the model changes a lot at once.- Parameters:
updateRestricted-trueto detach the table,falseto attach it
-
selectFirstRow
Selects the first row as the table shows it, after sorting and filtering.- Specified by:
selectFirstRowin classAbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject, EMFTable<V extends org.eclipse.emf.ecore.EObject>, TablePageProperties<V extends org.eclipse.emf.ecore.EObject>> - Returns:
- the selected object, or
nullif the table is empty
-