Papyrus Banner

How to customize the model explorer from profile

Model explorer gives a tree representation of the element model .

To be clear about the use of vocabulary, we suppose that :

We will explain the following cases:

Prerequisite

installation required:

for example in case of eclipse 2020-06 we choose : http://download.eclipse.org/modeling/mdt/papyrus/updates/releases/2020-06 .

Creation of the configuration file

First create a plug-in that will contain the configuration of your model explorer.

Create a file ".custom"

Choose as Customization root.

Add customization

Add the referencing extension point for the file ".custom"

In this part we need to reference our emf Facet model on the plug-in .xml .

Choose the created file ".custom" .

How to display additional children

Context

Our profile representation :

« stereotypeB » references « stereotypeC ».

In the explorer model we represent the « stereotypeC » classes as children of « stereotypeB ».

Creation of EclassCustomization

We have to customize the « stereotypeB » representation to be able to display new children .

As we extend the metaClass , we choose Class.

You have to chose Extended Facet and select « CustomizedEobject » Then we name it «CustomizationOfStereotypeB » .

Creation of an "EMF facet" operation to customize only "StereotypeB"

We are going to restrict the modification only to the classes to which we apply the stereotypeB.

Create an EMF Facet operation named « isAstereotypeB ».

Creation of Java Query

Validation with « OK ».

The Request does not exist ,so we create a Java class.

Validation with « OK ».

Result :

Then, you have to write this code :

The generated class contains the signature of the operation. You just have to fill in it.

Fill in the field «conformanceType» of «stereotypeB»

Fill in the field « Conformance Typed Element » with our EMF facet operation.

Creation of «ERefrence» to visualize the children of «stereotypeB»

Now we will specify the display of « C classes » as Child. In order to do this, we will add a reference facet.

A dialog box pop up:

Fill in :

Put type as a UML class  choose « UML metaModel » then the « Class metaclasse ».

Choose a Java request by following the wizardVous.

As a result ,You must obtain:

Also,we have to write the Java request

Let's test our customization

We have to choose the customization we have created.

Click on « Customize Model Explorer ».

Select « simpleexample ».

Put it on the « Loaded Customizations » list.

Now we can see that « stereotypeC » child of « stereotypeB ».

How to filter the children ?

Now we want no longer to see « stereotypeC » under packages, Hence filtering.

In this framework, it’s impossible to filter directly, so the solution is to create a new « Ereference » and to hide the reference that displays the elements.

How to hide children

With Papyrus we display all the composite relationships.

To display the Roles click on « toggle advanced » in model explorer. The role displaying the classes is « packagedElement ».

To hide the display of the « packagedElements » role,we have to create an « EClass Customization » on Package (see the section « creating an "EClassCustomization" »)

Here the "conformance Typed Element" field will not be filled, because we are customizing all the package representations.

We will create an operation « hide packageableElement ».

In the class below we don't display « PackagedElement ».

We select the EMF Facet operation.

Put « visibleReferences » to the « Override » field.

In application, this configuration must be priority over SimpleUML ,so we must put it before:

result --> no longer classes

Now we have to add a « Reference » where we only see the « stereotypeA » and « sterotypeB ».

Creation of a new «Eref» to see «SterotypeA» and «sterotypeB»

We want to see « stereotypeA » and « StereotypeB » as children of the package, For this we create a "FacetReference".

As we return a list:

The code must be written is as follows:

Once change applied we have the wanted result: