Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Sphinx/tutorials"

(Customizing Tree Views)
Line 5: Line 5:
 
The EMF Edit framework and its code generator allow creating easily editors and tree views from EMF models. However, the structure that we want displaying into tree view may be often different to the EMF model structure. The EMF Edit framework provides also mechanisms allowing customizing editors and tree views.  
 
The EMF Edit framework and its code generator allow creating easily editors and tree views from EMF models. However, the structure that we want displaying into tree view may be often different to the EMF model structure. The EMF Edit framework provides also mechanisms allowing customizing editors and tree views.  
  
In the following sections, we’ll describe how to easily customize tree views in order to display customized tree view structure. There are several kings of tree view customization. For instance, we may want displaying object references as children, adding non-model elements or suppressing model objects in tree views. We’ll use an extract of the Hummingbird meta-model to illustrate these kinds of tree views customization, as shown in following image:<br>  
+
In the following sections, we’ll describe how to easily customize tree views in order to display customized tree view structure. There are several kings of tree view customization. For instance, we may want displaying object references as children, adding non-model elements or suppressing model objects in tree views. We’ll use an extract of the Hummingbird meta-model to illustrate these kinds of tree views customization, as shown in Figure 1:<br>  
  
[[Image:HummingbirdMetaModel20.jpg|An extract of the Hummingbird meta-model 2.0]]<br>
+
[[Image:HummingbirdMetaModel20.jpg|An extract of the Hummingbird meta-model 2.0]]<br>  
  
'''&nbsp;&nbsp;&nbsp; Figure 1: An extract of the Hummingbird meta-model 2.0.'''<br>
+
'''&nbsp;&nbsp;&nbsp; Figure 1: An extract of the Hummingbird meta-model 2.0.'''<br>  
  
 
==== Displaying References as Children  ====
 
==== Displaying References as Children  ====
  
This section describes how displaying references as children into tree views. For example, we’ll display source port and target component (of a Connection object) as children of objects of Connection type. Realizing this kind of view customization is quite simple. The following figure illustrates this kind of tree view customization:<br>
+
This section describes how displaying references as children into tree views. For example, we’ll display source port and target component (of a Connection object) as children of objects of Connection type. Realizing this kind of view customization is quite simple. The following figure illustrates this kind of tree view customization:<br>  
 
+
[[Image:ReferenceAsChildren.jpg|An example displaying references as children]]<br>
+
  
 +
[[Image:ReferenceAsChildren.jpg|An example displaying references as children]] <br>
 
'''&nbsp;&nbsp; Figure 2: An example displaying references as children.'''<br>
 
'''&nbsp;&nbsp; Figure 2: An example displaying references as children.'''<br>
 +
 +
We must initially override the getChildren (Object object) method of the appropriate item provider (e.g., ConnectionItemProvider. We decide creating an extended class of ConnectionItemProvider named ExtendedConnectionItemProvider) like this:
 +
 +
    @Override
 +
    public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
 +
        super.getChildrenFeatures(object);
 +
        childrenFeatures.add(InstanceModel20Package.Literals.CONNECTION__SOURCE_PORT);
 +
        childrenFeatures.add(InstanceModel20Package.Literals.CONNECTION__TARGET_COMPONENT);
 +
        return childrenFeatures;
 +
    }
  
 
==== Adding Transient Nodes  ====
 
==== Adding Transient Nodes  ====

Revision as of 04:35, 22 July 2011

Model Editing Enhancements

Customizing Tree Views

The EMF Edit framework and its code generator allow creating easily editors and tree views from EMF models. However, the structure that we want displaying into tree view may be often different to the EMF model structure. The EMF Edit framework provides also mechanisms allowing customizing editors and tree views.

In the following sections, we’ll describe how to easily customize tree views in order to display customized tree view structure. There are several kings of tree view customization. For instance, we may want displaying object references as children, adding non-model elements or suppressing model objects in tree views. We’ll use an extract of the Hummingbird meta-model to illustrate these kinds of tree views customization, as shown in Figure 1:

An extract of the Hummingbird meta-model 2.0

    Figure 1: An extract of the Hummingbird meta-model 2.0.

Displaying References as Children

This section describes how displaying references as children into tree views. For example, we’ll display source port and target component (of a Connection object) as children of objects of Connection type. Realizing this kind of view customization is quite simple. The following figure illustrates this kind of tree view customization:

An example displaying references as children
   Figure 2: An example displaying references as children.

We must initially override the getChildren (Object object) method of the appropriate item provider (e.g., ConnectionItemProvider. We decide creating an extended class of ConnectionItemProvider named ExtendedConnectionItemProvider) like this:

   @Override
   public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
       super.getChildrenFeatures(object);
       childrenFeatures.add(InstanceModel20Package.Literals.CONNECTION__SOURCE_PORT);
       childrenFeatures.add(InstanceModel20Package.Literals.CONNECTION__TARGET_COMPONENT);
       return childrenFeatures;
   }

Adding Transient Nodes

Adding Transient Nodes

Suppressing Model Objects in views

Customizing Object Property Sheet

Back to the top