Controller (UI component composition) can be extended and their extensions easily incorporated by the xml file.
\\ ===== Example: Extend a specific 'CComboController' for property 'rating' ===== We want to create a new CComboController which manages background colors: **light blue** if value is 'R', **Red** if value is 'NC 17', default otherwise.\\ In Eclipse IDE, open file $projectDirectory/resources/xml/include/detail/FilmDI.xml. ===== Specify a new controller for Rating field ===== {{:tutorial:select_rating_controller_class.png?350 | Specify a new controller for Rating field}} - open file $projectDirectory/resources/xml/include/detail/FilmDI.xml with AXML editor. - Select field Select CCombo rating field. - Select Life cycle elements shelf in the outline page. - Click on controllerClassName hypelink. A new wizard window is opened for the creation of a new class. \\ ===== Create the new controller class ===== {{:tutorial:create_rating_controller.png?350 | Create the new controller class}} A new Java Class wizard is starting with a default values for source folder, package and superclass. - Specify class name as RatingCComboController. - Click on Finish button. - Select Life cycle elements shelf in the outline page. - Click on controllerClassName hypelink. A new Java editor window is open for RatingCComboController Java class. - Copy following code inside editor. - Save RatingCComboController Java class editor. - Save FilmDI.axml AXML editor. package org.mycompany.myproject.gencode.custom; import org.adichatz.engine.controller.IContainerController; import org.adichatz.engine.controller.field.CComboController; import org.adichatz.engine.core.ControllerCore; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; public class RatingCComboController extends CComboController { public RatingCComboController(String id, IContainerController parentController, ControllerCore genCode) { super(id, parentController, genCode); } @Override public void createControl() { super.createControl(); getCCombo().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setRatingBackGroundColor(); } }); } @Override public void setValue(Object value) { super.setValue(value); setRatingBackGroundColor(); } private void setRatingBackGroundColor() { String value = getCCombo().getText(); // Use 'setCssBackground' rather than 'getControl().setBackground' to be compliant with css process. // Otherwise when changing css theme current color is lost. if ("NC-17".equals(value)) setCssBackground("#adichatz-common", "error-foreground-color"); else if ("R".equals(value)) setCssBackground("#adichatz-common", "title-background"); else setCssBackground(null, null); } } \\ \\ Save changes in new **RatingCComboController.java** file then in **FilmDI.axml** file.\\ \\ In your application, open a new editor for the detail of a Film, background color of rating CComboController changes following value of the property.\\
**You do not need to close and reopen application to see changes at runtime.**