Using the Extended Editing Framework with Sirius

Authors Goulwen Le Fur

  1. Using the Extended Editing Framework with Sirius
    1. EEF Properties views and wizards generation
      1. Initializing and setting up EEF models
      2. Generating EEF code
    2. Setting up plugin.xml file
      1. Declaring AdapterFactories and PropertiesEditionPartProviders
      2. Declaring properties sheets
    3. Testing properties view
    4. Optional tasks (tabs optimization)
      1. Moving EEF property sheet tabs on top
      2. Multiple tabs
      3. Programmatically hide and show EEF property sheet tabs
      4. Hide Sirius built-in property sheet sections (and the corresponding tabs)
    5. Opening EEF wizard on a double click

The purpose of this Quickstart is to present how to integrate EEF properties views and wizards with a Sirius diagram representation.

EEF Properties views and wizards generation

The tutorial EEF : First generation describes the process to generate EEF properties views and wizards. Here is the main steps.

Initializing and setting up EEF models

Initialize EEF generation models with the action EEF > Initialize EEF models in the contextual menu of your genmodel file.

The created files use a simple strategy to define EEF properties. You can change theses settings to improve the logic of your properties.
If you plan to use EEF properties only in a designer (for diagrams, tables, ... but not on the EMF treeviewer), you can configure the Sirius contributor ID for the EEF views. Open the generated EEFGen model, under the root element Model, select the Gen Edition Context and set the value org.eclipse.sirius.diagram.ui to the Descriptors contributorID properties.

In order to optimize EEF performance with Sirius, change the root class of the generated EEF components to a dedicated Sirius aware components. This can be done by defining the value of the Leaf Components Super Class to org.eclipse.sirius.eef.components.SiriusAwarePropertiesEditingComponent.

Another interesting properties can be changed in this model, the generation directory. Default initialization set this value to the folder src-gen of the plug-in containing the EEF models.

Generating EEF code

Before lauching code generation, make sure the directory pointed by this value is in the build path of the plug-in.

Add a dependency to EEF runtime org.eclipse.emf.eef.runtime to the plug-in where you will generate the code.

Setting up plugin.xml file

EEF generates the java code needed for properties views and wizards. It generates also an sample plugin.xml file with the extension points you have to declare.

Declaring AdapterFactories and PropertiesEditionPartProviders

First part of the generated plugin.xml file ( <!-- EEF Extensions --> ) declare AdapterFactory and PropertiesEditionPartProvider needed by the EEF runtime. Copy this settings without any changes to the plugin.xml file of your plug-in.

Declaring properties sheets

Second part of the generated plugin.xml file ( <!-- Tabbed properties views extension -->) has extensions for tabbed properties sheets.

There is two options at this moment :


  <extension
         point="org.eclipse.ui.views.properties.tabbed.propertySections">
      <propertySections
            contributorId="org.eclipse.sirius.diagram.ui">
         <propertySection
               class="org.eclipse.emf.samples.conference.parts.forms.ConferencePropertiesEditionPartForm"
               filter="org.eclipse.emf.samples.conference.providers.ConferencePropertiesEditionProvider$EditionFilter"
               id="org.eclipse.emf.samples.conference.section.Conference"
               tab="Base">
         </propertySection>
						...
      </propertySections>
   </extension>

Note: this configuration can also be cloned to be used with Sirius tables and trees (by using the following property contributor ids
org.eclipse.sirius.table.ui.EditorID and org.eclipse.sirius.tree.ui.EditorID).

A propertySection must be declared for each tab generated in the org.eclipse.ui.views.properties.tabbed.propertyTabs extension.

Note: if you have not set Descriptors Contributor ID in the .eefgen model and you override the org.eclipse.sirius.diagram.ui, org.eclipse.sirius.table.ui.EditorID or org.eclipse.sirius.tree.ui.EditorID contributorId, do not forget to remove the use of org.eclipse.emf.eef.runtime.ui.utils.EEFLabelProvider as labelProvider. Otherwise you will get a Sirius type name as title of the properties view instead of the type name of the semantic model element.

Testing properties view

After this settings, the generated properties views must be available from a Sirius diagram. You can run an eclipse application to test it.

Optional tasks (tabs optimization)

Moving EEF property sheet tabs on top

By default, the EEF property sheets tab appear at last in the properties tabs.

It is possible to move them to make them appear at the top of the tab list :

To do this, you have to modify the org.eclipse.ui.views.properties.tabbed.propertyTabs section by changing the property category of your tabs. Instead of using the ones that have been created in the current plugin.xml (through the org.eclipse.ui.views.properties.tabbed.propertyContributor extension point), it is possible to use the ones defined by Sirius :

(please refer to the plugin.xml file of org.eclipse.sirius.diagram.ui for a complete list).

Example :

   <extension
         point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
      <propertyTabs
            contributorId="org.eclipse.sirius.diagram.ui">
         <propertyTab
               label="Base"
               category="semantic &amp; extension"
               id="Base">
         </propertyTab>
      </propertyTabs>
   </extension>

It is also possible to use the afterTab property to manage precisely the position of the EEF tabs (to put a tab before the first tab, use the value top).

Example :

   <extension
         point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
      <propertyTabs
            contributorId="org.eclipse.sirius.diagram.ui">
         <propertyTab
               afterTab="top"
               label="Base"
               category="semantic"
               id="Base">
         </propertyTab>
      </propertyTabs>
   </extension>

Multiple tabs

Several conditions have to be met in order to get several tabs for a given semantic EClass :

  1. First of all, one view must exist in the View Repository of the fs.components file for each tab that has to be shown for the given semantic EClass
  2. The Properties Edition Component associated to the semantic Eclass must reference these views
  3. In the plugin.xml file :
    1. One propertyTab XML node must exist for each expected tab ( org.eclipse.ui.views.properties.tabbed.propertyTabs extension point). The id must match the view names in the EEF components file.
    2. One propertySection XML node must exist for each expected tab( org.eclipse.ui.views.properties.tabbed.propertySections extension point), the tab attribute referencing the tabs defined in the propertyTabs section.

To illustrate it, let’s imagine that we have a semantic model that describes a filesystem in which we want to get two tabs ( File Basic and File Advanced) for the semantic File EClass.

Let’s consider that we also have an components file containing (at least) :

  1. A view named File Basic
  2. A view named File Advanced
  3. A Properties Edition Component binded to the semantic File Eclass and referencing both File Basic and File Advanced views

In the plugin.xml file, the tabs declaration should appear like this (notice that in this sample we use Sirius categories in order to make our tabs appear at first as described in the previous paragraph, which is not mandatory) :

<extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
   <propertyTabs contributorId="org.eclipse.sirius.diagram.ui">
      <!-- 
          Other declarations : Base, ... 
        -->
      <propertyTab
            label="File Advanced"
            category="semantic &amp; extension"
            id="File Advanced">
      </propertyTab>
      <propertyTab
            label="File Basic"
            category="semantic &amp; extension"
            id="File Basic">
      </propertyTab>
   </propertyTabs>
</extension>

And the property sections declaration should appear like this :

<extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
   <propertySections contributorId="org.eclipse.sirius.diagram.ui">
      <!-- 
          Other declarations : Base, ... 
        -->
      <propertySection
            class="org.eclipse.emf.eef.runtime.ui.properties.sections.PropertiesEditionSection"
            filter="org.eclipse.emf.eef.runtime.ui.properties.sections.PropertiesEditionSection"
            id="fileAdvanced"
            tab="File Advanced">
      </propertySection>
      <propertySection
            class="org.eclipse.emf.eef.runtime.ui.properties.sections.PropertiesEditionSection"
            filter="org.eclipse.emf.eef.runtime.ui.properties.sections.PropertiesEditionSection"
            id="fileBasic"
            tab="File Basic">
      </propertySection>
   </propertySections>
</extension>

Here is the result :

Programmatically hide and show EEF property sheet tabs

It is possible to hide and show EEF tabbed property sheet tabs by providing a filter to the property sections ( org.eclipse.jface.viewers.IFilter).

The most simple way to do this is to create a class that extends org.eclipse.emf.eef.runtime.ui.properties.sections.PropertiesEditionSection (this class brings a utility method ( resolveSemanticObject)) that helps to retrieve the semantic object that is targeted by a Sirius UI part).

Example #1 (based on a test of the semantic object) :

public class SemanticBasedPropertySectionFilter extends PropertiesEditionSection {

    @Override
    public boolean select(Object toTest) {
        EObject semanticObject = resolveSemanticObject(toTest);
        if (semanticObject instanceof MySemanticEClass) {
            boolean mustBeShown = true;
            // Code here the conditional tests...
            return mustBeShown;
        }
        return false;
    }

}

Example #2 (based on a test of the Sirius diagram identifier) :

public class SiriusIdBasedPropertySectionFilter extends IFilter {

    @Override
    public boolean select(Object toTest) {
        EditPart editPart = (EditPart) toTest;
        View view = (View) editPart.getModel();
        Diagram diagram = view.getDiagram();
        EObject element = diagram.getElement();
        String diagramId = ((DDiagram) element).getDescription().getName();
        return "<my diagram id>".equals(diagId);
    }

}

The filter has to be referenced from the plugin.xml file in the filter attribute of the corresponding propertySection :

<propertySection
       class="org.eclipse.emf.eef.runtime.ui.properties.sections.PropertiesEditionSection"
       filter="org.mypackage.MyPropertySectionFilter"
       id="fileBasic"
       tab="File Basic">
</propertySection>

Hide Sirius built-in property sheet sections (and the corresponding tabs)

The current plugin ( org.eclipse.sirius.eef.adapters) provides an extension mechanism that allows one to hide several Sirius built-in sections (and the corresponding tabs).

To be used, as a pre-requisite, a property section contributor must be defined (org.eclipse.ui.views.properties.tabbed.propertyContributor extension point) with the following section descriptor provider ( org.eclipse.sirius.eef.section.SiriusFilteringSectionDescriptor):

<extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
   <propertyContributor 
      contributorId="org.eclipse.sirius.table.ui.EditorID"
      sectionDescriptorProvider="org.eclipse.sirius.eef.section.SiriusFilteringSectionDescriptor">
    ...
   </propertyContributor>
</extension>

At this point, it is possible to declare which section have to be hidden for which contributor id. The following example shows how to hide the Semantic section from the Sirius diagrams property sheet and the Core and Semantic sections from the Sirius table property sheet :

<extension
      point="org.eclipse.sirius.eef.adapters.sectionFilters">
   <propertyContributorFilters
         contributorId="org.eclipse.sirius.diagram.ui">
      <sectionFilter
            id="property.section.semantic">
      </sectionFilter>
   </propertyContributorFilters>
   <propertyContributorFilters
         contributorId="org.eclipse.sirius.table.ui.EditorID">
      <sectionFilter
            id="org.eclipse.sirius.table.ui.section.core">
      </sectionFilter>
      <sectionFilter
            id="org.eclipse.sirius.table.ui.section.semantic">
      </sectionFilter>
   </propertyContributorFilters>
</extension>

Opening EEF wizard on a double click

An external java call is available to open a EEF Wizard editing the current selected element. This action can be used for the double click. In a tool section, create a Double Click Descriptor and name it Open EEF Wizard. The operation of this element is only an External Java Call. Name it Open EEF Wizard Action and define the id org.eclipse.sirius.eef.actions.openPropertiesWizard.

Finally, make a reference to this descriptor from each mapping you want to have a EEF Wizard on double click.

A double click on the selected mapping must open a EEF Wizard