Chapter 10.  UI improvements

You can customize your user interface like shown below. For more samples please refer to the Logo tutorial (chapter 9 : UI Improvement).

10.1.  Customize the generated EMF editor

Generated code can be modified for customization. An EMF editor for FSM models is ever deployed into Eclipse Kermeta. Retrieve the plugin code source with File -> Import -> Plug-in Development -> Plug-ins and Fragments and click two times on Next. Then choose the following plugins :

Import EMF and Topcased FSM Editor deployed plugins

Figure 10.1.  Import EMF and Topcased FSM Editor deployed plugins


The plugin .model, .edit and .editor correspond to the fsm EMF editor whereas the .graphicalEditor represents the Topcased editor.

[Tip] Add custom code

To keep your customized code for each generation you need to add

 
         /**
	       * 
	       * @generated NOT
	       */
         

just before the name of the method you want to customize.

10.1.1.  Change the editor's icons

To change an icon you need only to replace the icon from fr.triskell.kermeta.samples.fsm.edit/icons/full/obj16 to another with the same name and the same extension. It is the case on this deployed plugin. The following image presents this plugin, the .gif images have been changed from the initial EMF generation.

Customize icons

Figure 10.2.  Customize icons


Respectively the icons FSM.gif, State.gif and Transition.gif look like this :

FSM icon

Figure 10.3.  FSM icon


State icon

Figure 10.4.  State icon


Transition icon

Figure 10.5.  Transition icon


[Note]Note

Like GMF use EMF icons for the palette you can customize the palette icons by this way.

You will see the change when you will use the generated editor like in the following section.

10.1.2.  Change text presentation

The following method comes from FSMItemProvider in the package fr.triskell.kermeta.samples.fsm.provider in the project fr.irisa.triskell.kermeta.samples.fsm.model.edit. It permits to disply thr initial state or if it is missing or if the final state is missing.

        /**
	 * This returns the label text for the adapted class.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public String getText(Object object) {
		
		String initialState = " [an initial state is required]";
		if(object instanceof FSM && ((FSM) object).getInitialState()!=null) {
			initialState = " [initial state = " + ((FSM) object).getInitialState().getName() + "]";
		}
		String finalState = " - [at least one final state is required]";
		if(object instanceof FSM && ((FSM) object).getFinalState().size()>0) {
			finalState = "";
		}
		return getString("_UI_FSM_type") + initialState + finalState;
	}
         

.