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 forV- type of the rowsW- type of the viewerP- 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
- A builder creates the page, and its
registeradds the page to the part. 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 throwIllegalStateException(seecheckControlsNotCreated()).onShow(AbstractTreeElementType, boolean)puts the current value of the supplier intocontainer, andelementsswitches to the list of the new container.onReset()sets the container tonull.- When the viewer is disposed,
elementsandcontainerare disposed too.
Selection
When the user selects a row, the page sendsPlatformTopics.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
FieldsModifier and TypeFieldDescriptionprotected final org.eclipse.core.databinding.observable.value.WritableValue<org.eclipse.emf.ecore.EObject> Current container:nullbefore the first show and afteronReset().protected final org.eclipse.core.databinding.observable.list.IObservableList<V> Listfeatureof the current container.protected final org.eclipse.emf.ecore.EStructuralFeatureFeature of the container that holds the rows.protected final AbstractPagesPart<T, ?> Part the page is registered in.protected final PSettings of the page from the builder. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThrowsIllegalStateExceptionif the controls are already created.protected abstract voidConfigures the created viewer: columns, updates, buttons.voidcreateControls(org.eclipse.swt.widgets.Composite parent) Creates the viewer and listens to its selection and disposal.protected abstract WcreateViewer(org.eclipse.swt.widgets.Composite parent) Creates the viewer and, if needed, the toolbar above it.protected ICommandFactoryReturns the command factory of the part.Returns the tree element type set in the builder.protected WReturns the viewer, ornullbeforecreateControls(Composite).booleanisShownFor(T type) Returnstruefor the own type of the page and for the types added withalsoShownForin the builder.voidonReset()Removes the container, and the page becomes empty.voidTakes the container from the supplier.protected abstract ObjectSelects the first row, if there is one.voidsetSelection(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, waitMethods inherited from interface com.amalgamasimulation.desktop.appelements.parts.IPartPage
getPartLabel
-
Field Details
-
part
Part the page is registered in. The page sends messages through its event broker. -
feature
protected final org.eclipse.emf.ecore.EStructuralFeature featureFeature of the container that holds the rows. -
properties
Settings of the page from the builder. -
container
protected final org.eclipse.core.databinding.observable.value.WritableValue<org.eclipse.emf.ecore.EObject> containerCurrent container:nullbefore the first show and afteronReset(). -
elements
protected final org.eclipse.core.databinding.observable.list.IObservableList<V extends org.eclipse.emf.ecore.EObject> elementsListfeatureof the current container. When the container changes, it switches to the list of the new container by itself.
-
-
Method Details
-
createViewer
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-columnGridLayout- Returns:
- the viewer
-
configureViewer
protected abstract void configureViewer()Configures the created viewer: columns, updates, buttons. Called once, right aftercreateViewer(Composite). -
selectFirstRow
Selects the first row, if there is one. Sends no messages.- Returns:
- the selected object, or
nullif there are no rows
-
getTreeElementType
Returns the tree element type set in the builder.- Specified by:
getTreeElementTypein interfaceIPartPage<T extends AbstractTreeElementType>- Returns:
- the tree element type
-
isShownFor
Returnstruefor the own type of the page and for the types added withalsoShownForin the builder.- Specified by:
isShownForin interfaceIPartPage<T extends AbstractTreeElementType>- Parameters:
type- tree element type selected in the tree- Returns:
- whether the page is shown for the type
-
getViewer
Returns the viewer, ornullbeforecreateControls(Composite).- Returns:
- the viewer
-
checkControlsNotCreated
protected void checkControlsNotCreated()ThrowsIllegalStateExceptionif 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:
createControlsin interfaceIPartPage<T extends AbstractTreeElementType>- Parameters:
parent- composite of the page
-
onShow
Takes the container from the supplier. IfupdateSelectionistrue, selects the first row and sends it withPlatformTopics.PROPERTY_SELECTION_CHANGED.- Specified by:
onShowin interfaceIPartPage<T extends AbstractTreeElementType>- Parameters:
type- shown tree element typeupdateSelection- whether to select the first row
-
onReset
public void onReset()Removes the container, and the page becomes empty.- Specified by:
onResetin interfaceIPartPage<T extends AbstractTreeElementType>
-
setSelection
Selects an object that was selected outside the page, without sending messages.nullselects the first row; an object from the list is selected and scrolled to; any other object changes nothing.- Specified by:
setSelectionin interfaceIPartPage<T extends AbstractTreeElementType>- Parameters:
selection- object to select, may benull
-
getCommandFactory
Returns the command factory of the part. The toolbar buttons use it.- Returns:
- the command factory
-