In order to describe how to use MDE Rich Text widget, the official example Component Sample of Kitalpha is used. The example is available under the GIT repository of Kitalpha or by importing the example in the workspace via the Kitalpha Example.
This full implementation of the integration of the MDE Rich Text is available in the example. Another use case alos provided in the example is the contribution to the Activity Explorer by Documentation page which embed an instance of the MDE Rich Text Widget.
The meta-model of component sample is:

The aim of the exercise is to fill the description feature with the Rich Text using the MDE Rich Text Widget
The steps above is only for contributing with a new Tab to property tab. This section intends to show how to display and configure the MDE Rich Text Widget in this Tab
NB: The code source here are commented with #{number} pattern. The pattern indicates the step.
Create object attribute:
public class ComponentSampleDescription extends AbstractSection {
/**
* #0: declaration of the widget
*/
private MDERichtextWidget richtextWidget; //Widget declaration
//...
}
Override org.polarsys.kitalpha.vp.componentsample.ui.ComponentSampleDescription#createControls(Composite, TabbedPropertySheetPage) method and put the implementation:
super.createControls(parent, aTabbedPropertySheetPage);
parent.setLayout(new GridLayout(1, true));
parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
/**
* #1: Create a factory
* #2: Create a minimal Rich Text Widget
*/
richtextWidget = (new MDERichTextFactory()).createMinimalRichTextWidget(parent);
/**
* #3: Set strategy of saving in the model.
*/
richtextWidget.setSaveStrategy(new SaveStrategy() {
@Override
public void save(String editorText, EObject owner, EStructuralFeature feature) {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(owner);
Command set = SetCommand.create(ted, owner, feature, editorText);
CommandStack stack = ted.getCommandStack();
stack.execute(set);
}
});
Once the widget is created. Know, it must be binded to the current selection and description feature. Override org.polarsys.kitalpha.vp.componentsample.ui.ComponentSampleDescription#setInput(IWorkbenchPart, ISelection) method and enter the following source
super.setInput(part, selection);
EObject owner = null;
//Find the real object behind the selection
if (selection instanceof TreeSelection) {
owner = (EObject) ((TreeSelection) selection).getFirstElement();
}
/**
* #4: Bind the widget with the owner of description feature
*/
richtextWidget.bind(owner, ComponentSamplePackage.Literals.COMPONENT_ELEMENT__DESCRIPTION);
By this way, every changing of selection to Component Sample element, we rebind the the widget to the right element.
The aim of the filter is to restrect the activation of the tab to Component element.
Implements org.polarsys.kitalpha.vp.componentsample.ui.filters.ComponentSampleDescriptionFilter#select(Object) method which check if the object is a ComponentElement one.
public boolean select(Object toTest) {
return toTest instanceof ComponentElement;
}

To summary, the steps to use MDE Rich Text Widget are: