Components

This section describes the components that are provided to be used out-of-the-box, that are the foundations for all parts built upon EMF Parsley. Afetr a brief description, for each component we present a set of customizations, just to give an idea of how it works. You can refer to Customizations Section for a complete list.

Components and viewers have to be created using the factories we provide (e.g., for viewers we provide ViewerFactory (src)); such factories provide specific create methods that require all the needed parameters. These factories must be injected.

Form Component

The Form Component can be used to rapresent an EObject (src) in a form, like in the image above.

EMF Parsley provides a factory that can be used to create such a component, like in the code below. Here you can see that a form can be configured in 2 lines, the constructor phase and the build&fill phase.

@Inject FormFactory formFactory;

(...)

formComposite = formFactory.createFormDetailComposite(parent, SWT.NONE);
formComposite.init(eObject);

Most of the job is done by the second line of code, which gets the list of EStructuralFeature (src) defined for the EClass (src) (that is the type of the object to represent) and builds a row for each of them. Each row is composed by a caption which defaults to the name of the feature and a control to access the data.

All these aspects can be customized in many ways, for example you can customize the feature list, the captions and the controls.

Feature List Customization

The list of features displayed on the form can be customized via the Feature Provider that returns the list of the features (in a given order).

Caption Customization

The captions of the features shown in the form can be customizzed via the Form Feature Caption Provider.

Control Customization

The Controls in the form can be customized via the Form Control Factory.

Proposal Provider

Depending on the feature types, some fields can have predefined values (e.g. combo). You can provide the exact proposal list via the Proposal Provider

Tree Component

The Tree Component provides a tree rapresentation of data that can be fed with an EResource, a Resource URI, and a simple EObject. This component uses the EMF Meta-Model information to display objects in the tree.

EMF Parsley provides a factory that can be used to create such a component, like in the code below. Here you can see that can be configured only in 2 lines, the constructor phase and the build&fill phase.

@Inject ViewerFactory viewerFactory;

(...)

treeViewer = new TreeViewer(parent);
viewerFactory.initialize(treeViewer, element);

The Tree Componentcan be customized in several way via the standard EMF Edit facilities or with the EMF Parsley codeinjection based mechanism. If you are familiar with Jface APIs, you can easily use the basic class with some facilties to define the specific implementation. See the corrisponding sections for more details.

Content Provider

An IContentProvider is used in Jface to retrieve the list of elements and children to be showed in the tree viewer. The Viewer Content Provider is the EMF Parsley implementation of that interface, and by default uses the containment mechanisms to provide children as in EMF Edit framework, but it can be customized as weel.

LabelProvider

The Viewer Label Provider is the implementation of an ILabelProvider interface and is responsible to provide the text and image rapresentation for each EObject visualized.

Adding Menu

The contextual menu can be added to the viewer via an injected ViewerContextMenuHelper (src), as explained in the Menu section. The Menu Builder allows to fully customize the menus.

Tree Form Component

The Tree Form Component contains a section TreeComponent that provides a tree rapresentation of data that can be fed with an EResource, a Resource URI, and a simple EObject. This component uses the EMF Meta-Model information to display objects in the tree. The component also combines a section FormComponent detail that display the current selected object.

EMF Parsley provides a factory to create such a component.

@Inject TreeFormFactory treeFormFactory;

(...)

treeFormComposite = treeFormFactory.createTreeFormComposite(parent, SWT.BORDER);
treeFormComposite.update(application);

Since Tree Form Component is a combination of Tree Component and Form Component, all their customizations are avaible for it.

Table Component

The Table Component can rapresent data in a grid, once you have specified the type of objects to represent. It uses metamodel information to build columns as needed, and a TableViewerContentProvider (src) to retrieve the contents of the specified type (see also section TableViewerContentProvider).

@Inject ViewerFactory viewerFactory;

(...)

tableViewer = viewerFactory.createTableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION, eClass);

The class TableViewerColumnBuilder (src) has the responsibility to build the columns of the Table, by using the Features Provider to get the list of features and the Feature Caption Provider for the column headers. The class TableColumnLabelProvider (src) can be used to specify an implementation of ILabelProvider for each cell in the table.

Feature List Customization

The list fo features displayed on the table can be customized via the Table Feature Provider. This list of features will be used for building the columns of the table.

Caption Customization

The headers of the table can be customizzed via the Caption Provider.

Column width Customization

All columns have the same size by default, but they can be customizzed via the Configurator for instance in the DSL, like in the example below.

bindings{
    value List<Integer> TableColumnWeights -> #[10,20,30,40]
}

Adding Menu

The contextual menu can be added to the viewer via an injected ViewerContextMenuHelper (src), as explained in the Menu section. The Menu Builder allows to fully customize the menus.