Class AbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject,W extends org.eclipse.jface.viewers.StructuredViewer,P extends AbstractPageProperties<V>>

java.lang.Object
com.amalgamasimulation.desktop.appelements.pages.AbstractEmfPage<T,V,W,P>
Type Parameters:
T - type of the tree element the page is shown for
V - type of the rows
W - type of the viewer
P - settings of the page from the builder
All Implemented Interfaces:
IPartPage<T>
Direct Known Subclasses:
EmfTablePage, EmfTreePage

public abstract class AbstractEmfPage<T extends AbstractTreeElementType,V extends org.eclipse.emf.ecore.EObject,W extends org.eclipse.jface.viewers.StructuredViewer,P extends AbstractPageProperties<V>> extends Object implements IPartPage<T>
Base page of AbstractPagesPart that shows the list feature of a container in a StructuredViewer. The container comes from a supplier, and the page reads it again each time it is shown. Subclasses are created only in this package, so the protected members are meant for them.

Life cycle

  1. A builder creates the page, and its register adds the page to the part.
  2. createControls(Composite) creates the viewer over the whole page and configures it. Until then a subclass may change the settings of the page; after that such methods throw IllegalStateException (see checkControlsNotCreated()).
  3. onShow(AbstractTreeElementType, boolean) puts the current value of the supplier into container, and elements switches to the list of the new container. onReset() sets the container to null.
  4. When the viewer is disposed, elements and container are disposed too.

Selection

When the user selects a row, the page sends PlatformTopics.PROPERTY_SELECTION_CHANGED and PlatformTopics.NAVIGATE_TO with the first selected object. A click on a check box does not send them. setSelection(Object) selects a row without these messages.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.eclipse.core.databinding.observable.value.WritableValue<org.eclipse.emf.ecore.EObject>
    Current container: null before the first show and after onReset().
    protected final org.eclipse.core.databinding.observable.list.IObservableList<V>
    List feature of the current container.
    protected final org.eclipse.emf.ecore.EStructuralFeature
    Feature of the container that holds the rows.
    protected final AbstractPagesPart<T,?>
    Part the page is registered in.
    protected final P
    Settings of the page from the builder.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Throws IllegalStateException if the controls are already created.
    protected abstract void
    Configures the created viewer: columns, updates, buttons.
    void
    createControls(org.eclipse.swt.widgets.Composite parent)
    Creates the viewer and listens to its selection and disposal.
    protected abstract W
    createViewer(org.eclipse.swt.widgets.Composite parent)
    Creates the viewer and, if needed, the toolbar above it.
    protected ICommandFactory
    Returns the command factory of the part.
    Returns the tree element type set in the builder.
    protected W
    Returns the viewer, or null before createControls(Composite).
    boolean
    isShownFor(T type)
    Returns true for the own type of the page and for the types added with alsoShownFor in the builder.
    void
    Removes the container, and the page becomes empty.
    void
    onShow(T type, boolean updateSelection)
    Takes the container from the supplier.
    protected abstract Object
    Selects the first row, if there is one.
    void
    setSelection(Object selection)
    Selects an object that was selected outside the page, without sending messages.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.amalgamasimulation.desktop.appelements.parts.IPartPage

    getPartLabel
  • Field Details

    • part

      protected final AbstractPagesPart<T extends AbstractTreeElementType,?> part
      Part the page is registered in. The page sends messages through its event broker.
    • feature

      protected final org.eclipse.emf.ecore.EStructuralFeature feature
      Feature of the container that holds the rows.
    • properties

      protected final P extends AbstractPageProperties<V> properties
      Settings of the page from the builder.
    • container

      protected final org.eclipse.core.databinding.observable.value.WritableValue<org.eclipse.emf.ecore.EObject> container
      Current container: null before the first show and after onReset().
    • elements

      protected final org.eclipse.core.databinding.observable.list.IObservableList<V extends org.eclipse.emf.ecore.EObject> elements
      List feature of the current container. When the container changes, it switches to the list of the new container by itself.
  • Method Details

    • createViewer

      protected abstract W createViewer(org.eclipse.swt.widgets.Composite parent)
      Creates the viewer and, if needed, the toolbar above it. The base class sets the layout data of the viewer.
      Parameters:
      parent - parent with a one-column GridLayout
      Returns:
      the viewer
    • configureViewer

      protected abstract void configureViewer()
      Configures the created viewer: columns, updates, buttons. Called once, right after createViewer(Composite).
    • selectFirstRow

      protected abstract Object selectFirstRow()
      Selects the first row, if there is one. Sends no messages.
      Returns:
      the selected object, or null if there are no rows
    • getTreeElementType

      public T getTreeElementType()
      Returns the tree element type set in the builder.
      Specified by:
      getTreeElementType in interface IPartPage<T extends AbstractTreeElementType>
      Returns:
      the tree element type
    • isShownFor

      public boolean isShownFor(T type)
      Returns true for the own type of the page and for the types added with alsoShownFor in the builder.
      Specified by:
      isShownFor in interface IPartPage<T extends AbstractTreeElementType>
      Parameters:
      type - tree element type selected in the tree
      Returns:
      whether the page is shown for the type
    • getViewer

      protected W getViewer()
      Returns the viewer, or null before createControls(Composite).
      Returns:
      the viewer
    • checkControlsNotCreated

      protected void checkControlsNotCreated()
      Throws IllegalStateException if the controls are already created. Call it at the start of methods that change the settings of the page.
    • createControls

      public void createControls(org.eclipse.swt.widgets.Composite parent)
      Creates the viewer and listens to its selection and disposal.
      Specified by:
      createControls in interface IPartPage<T extends AbstractTreeElementType>
      Parameters:
      parent - composite of the page
    • onShow

      public void onShow(T type, boolean updateSelection)
      Takes the container from the supplier. If updateSelection is true, selects the first row and sends it with PlatformTopics.PROPERTY_SELECTION_CHANGED.
      Specified by:
      onShow in interface IPartPage<T extends AbstractTreeElementType>
      Parameters:
      type - shown tree element type
      updateSelection - whether to select the first row
    • onReset

      public void onReset()
      Removes the container, and the page becomes empty.
      Specified by:
      onReset in interface IPartPage<T extends AbstractTreeElementType>
    • setSelection

      public void setSelection(Object selection)
      Selects an object that was selected outside the page, without sending messages. null selects the first row; an object from the list is selected and scrolled to; any other object changes nothing.
      Specified by:
      setSelection in interface IPartPage<T extends AbstractTreeElementType>
      Parameters:
      selection - object to select, may be null
    • getCommandFactory

      protected ICommandFactory getCommandFactory()
      Returns the command factory of the part. The toolbar buttons use it.
      Returns:
      the command factory