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 with observableFeatures 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 the ICommandFactory of the part:
  • create adds an element to the container, with the idPattern if 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.
The buttons are disabled while there is no container.
  • 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 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 the rows
      columns - adds the columns to the table
      properties - settings from the builder
  • Method Details

    • addColumns

      public EmfTablePage<T,V> addColumns(Consumer<EMFTable<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 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

      public EmfTablePage<T,V> addObservablePath(org.eclipse.emf.ecore.EStructuralFeature... path)
      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; its end() returns the page. Call it before the controls are created.
      Returns:
      the toolbar builder
    • createViewer

      protected EMFTable<V> 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.
      Specified by:
      createViewer in class AbstractEmfPage<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-column GridLayout
      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:
      configureViewer in class AbstractEmfPage<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 the enabled condition 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. With true the table becomes empty and does not react to changes; with false it shows the list and the check boxes again. Use it while the model changes a lot at once.
      Parameters:
      updateRestricted - true to detach the table, false to attach it
    • selectFirstRow

      protected Object selectFirstRow()
      Selects the first row as the table shows it, after sorting and filtering.
      Specified by:
      selectFirstRow in class AbstractEmfPage<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 null if the table is empty