| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" > |
| <title>Components</title> |
| |
| <link href="book.css" rel="stylesheet" type="text/css"> |
| <link href="code.css" rel="stylesheet" type="text/css"> |
| <link rel="home" href="00-Main.html" title=""> |
| </head> |
| <body> |
| <a name="Components"></a> |
| <h1>Components</h1> |
| <p> |
| This section describes the components that are provided to be used out-of-the-box, that are the foundations for all parts built upon <em>EMF Parsley</em>. |
| 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 <a href="06-Customization.html#Customizations" title="Go to "Customizations"">Customizations Section</a> for a complete list. |
| </p> |
| <p> |
| Components and viewers have to be created using the factories we provide |
| (e.g., for viewers we provide <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/parsley/viewers/ViewerFactory.html" title="View JavaDoc"><abbr title="org.eclipse.emf.parsley.viewers.ViewerFactory" >ViewerFactory</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/parsley/viewers/ViewerFactory.java" title="View Source Code" >(src)</a>); |
| such factories provide specific <em>create</em> methods that require all the needed parameters. |
| These factories must be injected. |
| </p> |
| <a name="FormComponent"></a> |
| <h2>Form Component</h2> |
| <p> |
| The <em>Form Component</em> can be used to rapresent an <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/ecore/EObject.html" title="View JavaDoc"><abbr title="org.eclipse.emf.ecore.EObject" >EObject</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EObject.java" title="View Source Code" >(src)</a> in a form, |
| like in the image above. |
| </p> |
| <p> |
| <div class="image" > |
| <img src="images/03-components-form.png" class=" " |
| /> |
| <div class="caption"> |
| </div> |
| </div> |
| </p> |
| <p> |
| <em>EMF Parsley</em> 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. |
| </p> |
| <p> |
| <div class="literallayout"> |
| <div class="incode"> |
| <p class="code"> |
| @Inject FormFactory formFactory;<br/> |
| <br/> |
| (...)<br/> |
| <br/> |
| formComposite = formFactory.createFormDetailComposite(parent, SWT.NONE);<br/> |
| formComposite.init(eObject);<br/> |
| </p> |
| </div> |
| </div> |
| </p> |
| <p> |
| Most of the job is done by the second line of code, which gets the list of <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/ecore/EStructuralFeature.html" title="View JavaDoc"><abbr title="org.eclipse.emf.ecore.EStructuralFeature" >EStructuralFeature</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EStructuralFeature.java" title="View Source Code" >(src)</a> defined |
| for the <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/ecore/EClass.html" title="View JavaDoc"><abbr title="org.eclipse.emf.ecore.EClass" >EClass</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EClass.java" title="View Source Code" >(src)</a> |
| (that is the type of the object to represent) and builds a row for each of them. Each row is composed |
| by a <em>caption</em> which defaults to the name of the feature and a <em>control</em> to access the data. |
| </p> |
| <p> |
| All these aspects can be customized in many ways, for example you can customize the feature list, the captions and the controls. |
| </p> |
| <a name="FormComponent_features"></a> |
| <h3>Feature List Customization</h3> |
| <p> |
| The <em>list of features</em> displayed on the form can be customized via the <a href="06-Customization.html#FeaturesProvider" title="Go to "Features Provider"">Feature Provider</a> |
| that returns the list of the features (in a given order). |
| </p> |
| <a name="FormComponent_captions"></a> |
| <h3>Caption Customization</h3> |
| <p> |
| The captions of the features shown in the form can be customizzed via the <a href="06-Customization.html#FormFeatureCaptionProvider" title="Go to "Form and Dialog Feature Caption Provider"">Form Feature Caption Provider</a>. |
| </p> |
| <a name="FormComponent_controls"></a> |
| <h3>Control Customization</h3> |
| <p> |
| The Controls in the form can be customized via the <a href="06-Customization.html#FormControlFactory" title="Go to "Form Control Factory"">Form Control Factory</a>. |
| </p> |
| <a name="FormComponent_proposals"></a> |
| <h3>Proposal Provider</h3> |
| <p> |
| Depending on the feature types, some fields can have predefined values (e.g. combo). |
| You can provide the exact proposal list via the <a href="06-Customization.html#ProposalProvider" title="Go to "Proposal Provider"">Proposal Provider</a> |
| </p> |
| <a name="TreeComponent"></a> |
| <h2>Tree Component</h2> |
| <p> |
| The <em>Tree Component</em> provides a tree representation 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. |
| </p> |
| <p> |
| <div class="image" > |
| <img src="images/03-components-tree.png" class=" " |
| /> |
| <div class="caption"> |
| </div> |
| </div> |
| </p> |
| <p> |
| <em>EMF Parsley</em> provides a factory that can be used to create such a component, like in the code below: |
| </p> |
| <p> |
| <div class="literallayout"> |
| <div class="incode"> |
| <p class="code"> |
| @Inject ViewerFactory viewerFactory;<br/> |
| <br/> |
| (...)<br/> |
| <br/> |
| treeViewer = <span class="keyword">new</span> TreeViewer(parent);<br/> |
| viewerFactory.initialize(treeViewer, element);<br/> |
| </p> |
| </div> |
| </div> |
| </p> |
| <p> |
| The <em>Tree Component</em>can 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. |
| </p> |
| <a name="Tree_ContentProvider"></a> |
| <h3>Content Provider</h3> |
| <p> |
| An IContentProvider is used in Jface to retrieve the list of <em>elements</em> and <em>children</em> to be showed |
| in the tree viewer. The <a href="06-Customization.html#ViewerContentProvider" title="Go to "Viewer Content Provider"">Viewer Content Provider</a> is the <em>EMF Parsley</em> 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. |
| </p> |
| <a name="Tree_LabelProvider"></a> |
| <h3>LabelProvider</h3> |
| <p> |
| The <a href="06-Customization.html#ViewerLabelProvider" title="Go to "Viewer Label Provider"">Viewer Label Provider</a> is the implementation of an ILabelProvider interface |
| and is responsible to provide the text and image representation for each EObject visualized. |
| </p> |
| <a name="Tree_MenuBuilder"></a> |
| <h3>Adding Menu</h3> |
| <p> |
| The contextual menu can be added to the viewer via an injected |
| <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/parsley/menus/ViewerContextMenuHelper.html" title="View JavaDoc"><abbr title="org.eclipse.emf.parsley.menus.ViewerContextMenuHelper" >ViewerContextMenuHelper</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/parsley/menus/ViewerContextMenuHelper.java" title="View Source Code" >(src)</a>, as explained in the <a href="06-Customization.html#ContextualMenu" title="Go to "Contextual Menu"">Menu section</a>. |
| The <a href="06-Customization.html#MenuBuilder" title="Go to "Menu Builder"">Menu Builder</a> allows to fully customize the menus. |
| </p> |
| <a name="TreeFormComponent"></a> |
| <h2>Tree Form Component</h2> |
| <p> |
| The <em>Tree Form Component</em> contains a <a href="05-Components.html#TreeComponent" title="Go to "Tree Component"" >section TreeComponent</a> that provides a tree representation 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 <a href="05-Components.html#FormComponent" title="Go to "Form Component"" >section FormComponent</a> detail that display the current selected object. |
| </p> |
| <p> |
| <div class="image" > |
| <img src="images/03-components-treeform.png" class=" " |
| /> |
| <div class="caption"> |
| </div> |
| </div> |
| </p> |
| <p> |
| <em>EMF Parsley</em> provides a factory to create such a component. |
| </p> |
| <p> |
| <div class="literallayout"> |
| <div class="incode"> |
| <p class="code"> |
| @Inject TreeFormFactory treeFormFactory;<br/> |
| <br/> |
| (...)<br/> |
| <br/> |
| treeFormComposite = treeFormFactory.createTreeFormComposite(parent, SWT.BORDER);<br/> |
| treeFormComposite.update(application);<br/> |
| </p> |
| </div> |
| </div> |
| </p> |
| <p> |
| Since <em>Tree Form Component</em> is a combination of <em>Tree Component</em> and <em>Form Component</em>, all their customizations |
| are avaible for it. |
| </p> |
| <a name="TableComponent"></a> |
| <h2>Table Component</h2> |
| <p> |
| The <em>Table Component</em> 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 |
| <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/parsley/edit/ui/provider/TableViewerContentProvider.html" title="View JavaDoc"><abbr title="org.eclipse.emf.parsley.edit.ui.provider.TableViewerContentProvider" >TableViewerContentProvider</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/parsley/edit/ui/provider/TableViewerContentProvider.java" title="View Source Code" >(src)</a> to retrieve |
| the contents of the specified type (see also <a href="06-Customization.html#TableViewerContentProvider" title="Go to "Table Viewer Content Provider"" >section TableViewerContentProvider</a>). |
| </p> |
| <p> |
| <div class="image" > |
| <img src="images/03-components-table.png" class=" " |
| /> |
| <div class="caption"> |
| </div> |
| </div> |
| </p> |
| <p> |
| <div class="literallayout"> |
| <div class="incode"> |
| <p class="code"> |
| @Inject ViewerFactory viewerFactory;<br/> |
| <br/> |
| (...)<br/> |
| <br/> |
| tableViewer = viewerFactory.createTableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION, eClass);<br/> |
| </p> |
| </div> |
| </div> |
| </p> |
| <p> |
| The class <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/parsley/viewers/TableViewerColumnBuilder.html" title="View JavaDoc"><abbr title="org.eclipse.emf.parsley.viewers.TableViewerColumnBuilder" >TableViewerColumnBuilder</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/parsley/viewers/TableViewerColumnBuilder.java" title="View Source Code" >(src)</a> has the responsibility to |
| build the columns of the Table, by using the <a href="06-Customization.html#FeaturesProvider" title="Go to "Features Provider"">Features Provider</a> to get the list |
| of features and the <a href="06-Customization.html#FeatureCaptionProvider" title="Go to "Feature Caption Provider"">Feature Caption Provider</a> for the column headers. |
| The class <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/parsley/ui/provider/TableColumnLabelProvider.html" title="View JavaDoc"><abbr title="org.eclipse.emf.parsley.ui.provider.TableColumnLabelProvider" >TableColumnLabelProvider</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/parsley/ui/provider/TableColumnLabelProvider.java" title="View Source Code" >(src)</a> can be used to specify |
| an implementation of ILabelProvider for each cell in the table. |
| </p> |
| <a name="Table_features"></a> |
| <h3>Feature List Customization</h3> |
| <p> |
| The <em>list fo features</em> displayed on the table can be customized via the <a href="06-Customization.html#TableFeaturesProvider" title="Go to "Table Features Provider"">Table Feature Provider</a>. |
| This list of features will be used for building the columns of the table. |
| </p> |
| <a name="Table_captions"></a> |
| <h3>Caption Customization</h3> |
| <p> |
| The headers of the table can be customizzed via the <a href="06-Customization.html#FeatureCaptionProvider" title="Go to "Feature Caption Provider"">Caption Provider</a>. |
| </p> |
| <a name="Table_columns_width"></a> |
| <h3>Column width Customization</h3> |
| <p> |
| All columns have the same size by default, but they can be customizzed via the <a href="06-Customization.html#Configurator" title="Go to "Configurator"">Configurator</a> |
| for instance in the DSL, like in the example below. |
| </p> |
| <p> |
| <div class="literallayout"> |
| <div class="incode"> |
| <p class="code"> |
| <span class="keyword">bindings</span>{<br/> |
| <span class="keyword">value</span> List<Integer> TableColumnWeights -> #[10,20,30,40]<br/> |
| }<br/> |
| </p> |
| </div> |
| </div> |
| </p> |
| <a name="Table_MenuBuilder"></a> |
| <h3>Adding Menu</h3> |
| <p> |
| The contextual menu can be added to the viewer via an injected |
| <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/parsley/menus/ViewerContextMenuHelper.html" title="View JavaDoc"><abbr title="org.eclipse.emf.parsley.menus.ViewerContextMenuHelper" >ViewerContextMenuHelper</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/parsley/menus/ViewerContextMenuHelper.java" title="View Source Code" >(src)</a>, as explained in the <a href="06-Customization.html#ContextualMenu" title="Go to "Contextual Menu"">Menu section</a>. |
| The <a href="06-Customization.html#MenuBuilder" title="Go to "Menu Builder"">Menu Builder</a> allows to fully customize the menus. |
| </p> |
| <a name="TreeWithColumnsComponent"></a> |
| <h2>Tree With Columns Component</h2> |
| <p> |
| The <em>Tree With Columns Component</em> provides a tree representation just like <a href="05-Components.html#TreeComponent" title="Go to "Tree Component"">Tree Component</a>, |
| but it also shows table columns representing the features of the specified <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/ecore/EClass.html" title="View JavaDoc"><abbr title="org.eclipse.emf.ecore.EClass" >EClass</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EClass.java" title="View Source Code" >(src)</a>. |
| </p> |
| <p> |
| IMPORTANT: the <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/ecore/EClass.html" title="View JavaDoc"><abbr title="org.eclipse.emf.ecore.EClass" >EClass</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EClass.java" title="View Source Code" >(src)</a> is used to retrieve the features to be shown, and |
| NOT to filter elements to be shown (as opposite to the <a href="05-Components.html#TableComponent" title="Go to "Table Component"">Table Component</a>). If a given |
| row in the tree represents an object whose class does not have the feature for a given column, then the |
| corresponding table cell for that object will be empty. |
| </p> |
| <p> |
| For example, the following screenshot shows a tree with columns representing a library; the specified |
| <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/org/eclipse/emf/ecore/EClass.html" title="View JavaDoc"><abbr title="org.eclipse.emf.ecore.EClass" >EClass</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EClass.java" title="View Source Code" >(src)</a> is the <em>Writer</em> so the columns show the features of the |
| <em>Writer</em>'s class. Some of these features, e.g., <em>address</em>, <em>firstName</em> and <em>lastName</em>, are defined |
| in the superclasses of <em>Writer</em>. The objects of class <em>Employee</em> have these features as well, while |
| they don't have features that are specific of <em>Writer</em>, e.g., <em>name</em> and <em>books</em>, thus the corresponding |
| cells for employees will be empty. |
| </p> |
| <p> |
| <div class="image" > |
| <img src="images/03-components-treecolumns.png" class=" " |
| /> |
| <div class="caption"> |
| </div> |
| </div> |
| </p> |
| <p> |
| <em>EMF Parsley</em> provides a factory that can be used to create such a component, like in the code below: |
| </p> |
| <p> |
| <div class="literallayout"> |
| <div class="incode"> |
| <p class="code"> |
| @Inject ViewerFactory viewerFactory;<br/> |
| <br/> |
| (...)<br/> |
| <br/> |
| treeViewer = createTreeViewerWithColumns(parent, getEClass(), getContents());<br/> |
| </p> |
| </div> |
| </div> |
| </p> |
| <p> |
| Since this component mixes the features of a tree and a table, the customizations are basically the |
| same shown in the subsections of <a href="05-Components.html#TreeComponent" title="Go to "Tree Component"" >section TreeComponent</a> and <a href="05-Components.html#TableComponent" title="Go to "Table Component"" >section TableComponent</a>. |
| </p> |
| </body> |
| </html> |