...
The last section of this tutorial is about text labels in the graphical editor. We will use such labels for displaying state names and transition specifications. The steps required for these tasks are given only coarsely here, since you should now be able to find out yourself about the details using the Graphiti documentation.
- Add a
Text
element to states in theStateAddFeature
in order to display the name of each state. - Create a new class
StateDirectEditingFeature
extendingAbstractDirectEditingFeature
and register it by overridinggetDirectEditingFeature
in theTuringFeatureProvider
. This new feature is responsible for connecting the edited text with the name attribute of states with the in-diagram text editing box, i.e. retrieving the current text from the attribute and updating it after the user has entered a new value. - Create a new class
StateUpdateFeature
extendingAbstractUpdateFeature
and register it by overridinggetUpdateFeature
in theTuringFeatureProvider
. This new feature is responsible for updating the displayed text when the corresponding attribute in the domain model is changed outside the Graphiti editor. For example you could open the Turing Machine model with the Sample Reflective Ecore Model Editor in order to modify attributes. You can activate automatic updates of the diagram by extendingisAutoUpdateAtRuntime
(resp.Startup
/Reset
) in theTuringDiagramTypeProvider
and returningtrue
. The update feature can be invoked explicitly in other features by calling the superclass methodupdatePictogramElement
. - Create a new class
StateLayoutFeature
extendingAbstractLayoutFeature
and register it by overridinggetLayoutFeature
in theTuringFeatureProvider
. This new feature is responsible for updating the position and size of graphics algorithms of a state when the state is resized in the graphical editor or when the displayed text for the state name is updated. The layout feature can be invoked explicitly in other features by calling the superclass methodlayoutPictogramElement
.