Expansion of diagram by adding compartments

Table of Contents

Requirements

- Add Graphical Elements (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_010): 
The system shall be able to add new graphical elements in new diagrams or existing diagrams
- Add Graphical Compartments (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_011): 
The developper can add new compartments from a existed graphical element.
- Add new nodes (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_012): 
A developper can add new nodes in the diagram that no exist in the existed diagram or add element by reusing existed shape.
- Add new child label  (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_013): 
A developper can add new child labels ( element that can be contained in a list compartment) in the diagram that no exist in the existed diagram or add element by reusing existed child label.
- Add new border item (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_014): 
A developper can add new border items ( element that can be installed around the shape) in the diagram that no exist in the existed diagram or add element by reusing existed border item.
- Add new links  (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_015): 
A developper can add new links in the diagram that no exist in the existed diagram or add element by reuse existed links.
- Reuse representations from diagram (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_016): 
It must be able to reuse rperesentations from existed diagrams
- Drop of new Elements (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_020): 
New Elements can be dropped from the model explorer.
- Assistant (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_030): 
The new element must be created by using assistant mechanism
- Creation from the palette (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_040): 
Elements can be created fom the palette
- Non impact on parent diagrams (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_050): 
the inheridted diagram must not impact parent diagram by addin the new compartments.
- ExpransionModel (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_060): 
The expansion of diagram has to be a model and be interpreted
- The model has to be well-built (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_061): 
When the model is done, the ystem has to ensure that it can be correctly interpreted.
- Expanded diagrams viewed with original editor (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_070): 
The original diagram must be view in original diagram, exteernal element must have a predefined shape.
It cannot be implemented for the version Mars
- CSS driven (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_080): 
The added element must be driven by CSS
- View point relation (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_090): 
The new specialization editor must benefit of all specializations.
- Loading at runtime (id=org.eclipse.papyrus.infra.gmfdiag.expansion.Req_0100): 
An expansion model must be able to load during runtime, not only with extension point.
It allow to be tested by Junit Tests.

Use Cases

UseCaseDiagram

UseCaseDiagram


Diagram Expansion

CommentDiagram

CommentDiagram


Create an expansion model

  - traces to ExpransionModel
The developper can model the expansion of diagram.

How to
In order to be able to edit this kind of model, the developper has to download the code of this editor. 

To do that, click on menu File--> new-->Other
Choose "Example EMF models creation wizards" and select Expansion Model.
Then select as root Object a diagram expansion.

Create

Create a new expansion model step 2


Create

Create a new expansion model step 1


I has to be included inside plug-ins and fill the extension point: "org.eclipse.papyrus.infra.gmfdiag.common.diagramExpansion".

Note: If the model is not valid, the framework does not take in account your model expansion.
--> so valid it, and see your log error.

In order to add an expansion for a diagram, the developper has to wonder "Which diagram must be expanded?

To specify it the advanced user has to create a UseContext. The diagram type is the reference to your diagram, class diagram, composite diagram or your view point?

Set

Set a UseContext


Reuse a representation

  - traces to Reuse representations from diagram
It must be able to reuse reperesentations from existed diagrams
How to
Reuse representation of existing diagram implies knowledge of each representation. A representation is composed by three concepts:

- the model (in our case this is the notation model or more see serailization of the diagram)
- the controler (in the context of GEF, it is named "EditPart"
- and the view ( the java Darw2d figure)

First indicate the visual ID that you want to overload (this id can be found in the code or in the gmfgen files)
So if you want to change the serialization of the new representation change the view factory
If you want to associate a new controler to the model notation change the editpart.
In order to have more detailled information see the MVC of GEF.

The name in this element is never used programmtically. It is used as an information.

Resuse

Resuse class representation form class diagram


Add a graphical representation

  - traces to Add Graphical Elements

Add compartments

  - traces to Add Graphical Compartments
A developper can add compartments inside a node. It can be XYlayout or list or other type of compartments.

Add new nodes

  - traces to Add new nodes
A developper can add new nodes in the diagram that no exist in the existed diagram or  add element by reusing existed shape.

Add new child label

  - traces to Add new child label 
 A developper can add new child labels ( element that can be contained in a list compartment) in the diagram that no exist in the existed diagram or  add element by reusing existed child label.

Add new border item

  - traces to Add new border item
A developper can add new border items ( element that can be installed around the  shape) in the diagram that no exist in the existed diagram or  add element by reusing existed border item.

Add new link

  - traces to Add new links 
A developper can add new links in the diagram that no exist in the existed diagram or  add element by reuse existed links.

Design

The code is dispatched in several packages.

The infra.gmf.common contains the essential of the code.
One part has been generated from the UML model to design the structure of representation.
The second part has been coded manuaaly in order to interpret instances of models.

expansionmodel

NewEcoreUMLClassDiagram

NewEcoreUMLClassDiagram


Class Representation

  - specializes AbstractRepresentation
A representation is en element that is displyed on a diagram it is attached to a controler (see editpart) and to a notation structure( build bt the viewFactory)

Class InducedRepresentation

  - specializes AbstractRepresentation
An Induced Representation is a representation that is automatically created by its parent representation (compartment, label of a shape, label of link, label or border item)

Class GraphicalElementLibrary

Class UseContext

The use context is the point used to extend a diagram, it indicate for wich diagram all representation will be added or extended.

Class DiagramExpansion

This the root element model that can contain Use context or libraries. 

An Id is associated in order to allow debbugging in the case of model is bad build.

Class GMFT_BasedRepresentation

  - specializes Representation
A GMF_BasedRepresentation is  reuse of an element generated by GMFT, for example well would to add compartments for class. we need to references class  of class diagram. this element is used o this.

Class RepresentationKind

This Element is a library of Type of representation, for display as label, border item, classifier...

Class AbstractRepresentation

This is an abstract representation used to display  shape or reused shape in diagram.

Package org.eclipse.papyrus.infra.gmfdiag.common

Package Expansion

View

View Providers


This design contains classes to interpret model of expansion and create graphical elements from the palette.

Creation

Creation of InducedRepresentations


This design contains classes to interpret model of expansion and create induced representation ( compartments, labels...).
Class ChildrenListRepresentation
This class is a structure that is adapted for the code of provider not to describe compartments as the model

it satisfy #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_060
Class CreateInducedRepresentationViewCommand
  - specializes RecordingCommand
Command to create the compartment displaying shapes for an element

see #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_011
Class DiagramExpansionSingleton
This factory is used to give an instance of the diagram expansion 
Class DiagramExpansionsRegistry
This class is used to load all extension point call org.eclipse.papyrus.infra.gmfdiag.diagramexpansion

It gives the set of all Diagram expansion that has to be used
#Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_060
Class ExpandEditPartProvider
  - specializes AbstractEditPartProvider
This class is a generic EditpartProvider that is enable to associate controler to new notation element by reading an expansion model

See Requirement #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_010
Class ExpandViewProvider
  - specializes CustomAbstractViewProvider

- realizes IViewProvider
This class is a generic ViewProvider that is enable to create notation element by reading an expansion model

See Requirement #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_010
#Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_040

Class IdentityGraphicalElementType
  - realizes IGraphicalTypeRegistry
This class is used to know all graphical type that can be added in the diagram.

By default it accepts all. This is the ExpandViewProvider that verify the job
#Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_010
Class InducedRepresentationCreationEditPolicy
  - specializes GraphicalEditPolicy
This edit policy can be apply only on {@link IPapyrusEditPart} in order to  access to primary figure. the primary figure has to be a {@link IPapyrusNodeUMLElementFigure}.

It creates the compartment displaying shapes for an element by reading the expansion model
see #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_011
Class InducedRepresentationPolicyProvider
  - specializes AbstractProvider

- realizes IEditPolicyProvider
Edit policy provider to install InducedRepresentationPolicy in charge to create compartments displaying shapes for an element by reading the expansion model

see #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_011

Package expansionmodel

Class UseContext
Class AbstractRepresentation
Class DiagramExpansion

Package providers

Class CustomAbstractViewProvider
Interface IGraphicalTypeRegistry

Package service

Package shape
Class NotificationManager

Tests

Test

Test expansion model


The code coverage  for:

- org.eclipse.papyrus.infra.gmfdiag.common.expansion is equals to 90,1 %.
- ExpansionElementDropStrategy.java 87,0 %

The function is coverage at 64%

TestCase T001-Load ExpansionModel

TestCase T002-Add a compartment

The goal of this test is to know if a compartment can be added on existed node.

TestCase T003-Add Child Label

The goal of this test is to know if a child label can be added inside compartments.

TestCase T006-Add Compartment with Kind

The goal of this test is to know if a compartment can be added on existed node by using library of compartments.

TestCase T004-Add Border Item

The goal of this test is to know if a border item can be added on existed node.

TestCase T005-Add link

The goal of this test is to know if a link can be added inside a diagram.

TestCase T006-Drop of Elements

TestCase T007-AssistantUsage

The goal of this test case is to ensure that the  assistant can be used with the an expansion of model. It contains on test based on node.

It remains to add a test based on links.

Requirements Coverage

RequirementsCoverageTable
IdSatisfied byVerified by
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_010
Add a graphical representation
T002-Add a compartment,
T003-Add Child Label,
T006-Add Compartment with Kind,
T005-Add link,
T004-Add Border Item
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_011
Add compartments
T002-Add a compartment,
T006-Add Compartment with Kind
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_012
Add new nodes
T004-Add Border Item
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_013
Add new child label
T003-Add Child Label
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_014
Add new border item
T004-Add Border Item
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_015
Add new link
T005-Add link
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_016
Reuse a representation
T003-Add Child Label,
T002-Add a compartment,
T006-Add Compartment with Kind,
T004-Add Border Item
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_020
T006-Drop of Elements
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_030
T007-AssistantUsage
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_040
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_050
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_060
Create an expansion model
T001-Load ExpansionModel,
T002-Add a compartment,
T006-Add Compartment with Kind,
T005-Add link,
T004-Add Border Item,
T003-Add Child Label
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_061
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_070
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_080
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_090
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_0100
T001-Load ExpansionModel
Unsatisfied requirements (9 out of 17) : 
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_020, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_030, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_040, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_050, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_061, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_070, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_080, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_090, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_0100
Unverified requirements (6 out of 17) : 
org.eclipse.papyrus.infra.gmfdiag.expansion.Req_040, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_050, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_061, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_070, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_080, org.eclipse.papyrus.infra.gmfdiag.expansion.Req_090