Adichatz generates brute Entity Editors to display detail parts of an Entity and the list of its related objects (dependencies). For example the Entity Editor for a Film class is described by an XML file called 'FilmEditorGENERATED.axml' or 'FilmDIGENERATED.axml' (see generated file).

For example, open file $projectDirectory/resources/xml/model/film/FilmDIGENERATED.xml.

Following XML elements:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<includeTree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance" coreClassName="org.adichatz.engine.core.ASectionCore" entityURI="adi:/entityURI="adi://myproject/model.film/FilmMM" xsi:noNamespaceSchemaLocation="http://www.adichatz.org/xsd/v0.9.1/generator/includeTree.xsd">
    <section text="#MSG(film, detailContainerText)" id="detailContainer">
        <layout layoutConstraints="wrap 4" columnConstraints="[fill, align right]10[fill,grow]25[align right]10[fill,grow]"/>
        <include adiResourceURI="getToolBarURI((String) #PARAM(TOOL_BAR_TYPE))" id="detailToolbarMenu">
            <params>
                <param value="#CONTROLLER(detailContainer)" id="CONTROLLER"/>
                <param optional="true" value="#PARAM(TOOL_BAR_TYPE)" id="TOOL_BAR_TYPE"/>
            </params>
        </include>
        <formattedText editPattern="######" format="Short" property="filmId" enabled="false" id="filmId"/>
        <refText property="languageByLanguageId" mandatory="true" style="SWT.BORDER | AdiSWT.FIND_BUTTON | AdiSWT.EDITOR_BUTTON" id="languageByLanguageId">
            <convertModelToTarget>return null==value ? "" : #FV().name;</convertModelToTarget>
        </refText>
        <refText property="languageByOriginalLanguageId" style="SWT.BORDER | AdiSWT.FIND_BUTTON | AdiSWT.EDITOR_BUTTON | AdiSWT.DELETE_BUTTON" id="languageByOriginalLanguageId">
            <convertModelToTarget>return null==value ? "" : #FV().name;</convertModelToTarget>
        </refText>
        <text textLimit="255" property="title" mandatory="true" id="title"/>
        <text textLimit="65535" property="description" id="description"/>
        <formattedText editPattern="####" format="Integer" property="releaseYear" id="releaseYear">
            <validators>
                <validator key="invalidYear" errorMessage="#MSG(film, invalid.year.value, #FV())">
                    <errorWhen>return #FV() &lt; 1900 ||  #FV() &gt; 2155;</errorWhen>
                </validator>
            </validators>
        </formattedText>
        <checkBox property="active" mandatory="true" style="SWT.CHECK" id="active"/>
        <formattedText format="Byte" property="rentalDuration" mandatory="true" id="rentalDuration"/>
        <formattedText editPattern="##.##" format="Double" property="rentalRate" mandatory="true" id="rentalRate">
            <convertModelToTarget>return null == value ? null : ((java.math.BigDecimal) value).doubleValue();</convertModelToTarget>
            <convertTargetToModel>return null == value ? null : new java.math.BigDecimal((Double) value);</convertTargetToModel>
        </formattedText>
        <formattedText editPattern="######" format="Short" property="length" id="length"/>
        <formattedText editPattern="###.##" format="Double" property="replacementCost" mandatory="true" id="replacementCost">
            <convertModelToTarget>return null == value ? null : ((java.math.BigDecimal) value).doubleValue();</convertModelToTarget>
            <convertTargetToModel>return null == value ? null : new java.math.BigDecimal((Double) value);</convertTargetToModel>
        </formattedText>
        <text textLimit="5" property="rating" id="rating"/>
        <multiChoice popupToolbar="true" multiChoiceType="String" values="Trailers,Commentaries,Deleted Scenes,Behind the Scenes" property="specialFeatures" id="specialFeatures"/>
        <text textLimit="255" property="imageUrl" id="imageUrl"/>
        <dateText property="lastUpdate" enabled="false" style="SWT.BORDER | SWT.TIME" id="lastUpdate"/>
    </section>
</includeTree>

renders the following layout:
 Film detail (brute)


Change XML elements

  • Copy FilmDIGENERATED.axml file to FilmDI.axml which will become the reference for generated code.
  • Replace above XML lines with the following ones:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<includeTree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance" coreClassName="org.adichatz.engine.core.ASectionCore" entityURI="adi:/entityURI="adi://myproject/model.film/FilmMM" xsi:noNamespaceSchemaLocation="http://www.adichatz.org/xsd/v0.9.1/generator/includeTree.xsd">
    <section text="#MSG(film, detailContainerText)" style="Section.TWISTIE | Section.TITLE_BAR | Section.EXPANDED" id="detailContainer">
        <layout layoutConstraints="wrap 4" columnConstraints="[fill, align right]10[fill,grow]25[align right]10[fill,grow]"/>
        <include adiResourceURI="getToolBarURI((String) #PARAM(TOOL_BAR_TYPE))" id="detailToolbarMenu">
            <params>
                <param value="#CONTROLLER(detailContainer)" id="CONTROLLER"/>
                <param optional="true" value="#PARAM(TOOL_BAR_TYPE)" id="TOOL_BAR_TYPE"/>
            </params>
        </include>
        <formattedText editPattern="######" format="Short" property="filmId" enabled="false" id="filmId"/>
        <text textLimit="255" property="title" mandatory="true" id="title"/>
        <text layoutData="span 3" textLimit="255" property="description" id="description"/>
        <composite layoutData="newline, grow, push, span 4" id="bottomComposite">
            <layout layoutConstraints="wrap 2" columnConstraints="[fill, grow][fill, grow]" rowConstraints="[fill, grow, al top]"/>
            <imageViewer imageType="Url" fitCanvas="true" toolBarStyle="AdiSWT.DELETE_BUTTON | AdiSWT.EXPANDABLE | AdiSWT.EDITABLE" noLabel="true" layoutData="hmax 300" property="imageUrl" id="imageUrl"/>
            <composite id="fieldComposite">
                <layout layoutConstraints="wrap 2" columnConstraints="[align right]10[fill,grow]"/>
                <refText property="languageByOriginalLanguageId" style="SWT.BORDER | AdiSWT.FIND_BUTTON | AdiSWT.EDITOR_BUTTON | AdiSWT.DELETE_BUTTON" id="languageByOriginalLanguageId">
                    <convertModelToTarget>return null==value ? &quot;&quot; : #FV().name;</convertModelToTarget>
                </refText>
                <refText property="languageByLanguageId" mandatory="true" style="SWT.BORDER | AdiSWT.EDITOR_BUTTON | AdiSWT.FIND_BUTTON" id="languageByLanguageId">
                    <convertModelToTarget>return null==value ? &quot;&quot; : #FV().name;</convertModelToTarget>
                </refText>
                <ccombo values="G, PG, PG-13, R, NC-17" style="SWT.READ_ONLY | SWT.BORDER" property="rating" id="rating"/>
                <checkBox text="#MSG(film,active)" property="active" noLabel="true" style="SWT.CHECK" id="active"/>
                <composite id="activeComposite">
                    <layout layoutConstraints="wrap 1, ins 0, hidemode 3" columnConstraints="[fill, grow]"/>
                    <pgroup text="#MSG(film,active)" id="activeGroup" dirtyManagement="false">
                        <dynamicClause listenedFieldId="active">
                            <conditionCode>#BEAN().isActive()</conditionCode>
                            <postCode>#CONTROLLER(detailContainer).reflowControllers();</postCode>
                        </dynamicClause>
                        <layout layoutConstraints="wrap 2" columnConstraints="[align right]10[fill,grow]"/>
                        <formattedText editPattern="######" format="Short" property="rentalDuration" mandatory="true" id="rentalDuration"/>
                        <numericText pattern="##.##" property="rentalRate" mandatory="true" style="SWT.BORDER | SWT.RIGHT" id="rentalRate"/>
                        <numericText pattern="###.##" property="replacementCost" mandatory="true" style="SWT.BORDER | SWT.RIGHT" id="replacementCost"/>
                    </pgroup>
                </composite>
                <formattedText editPattern="######" format="Short" property="length" id="length"/>
				<multiChoice popupToolbar="true" multiChoiceType="String" values="Trailers,Commentaries,Deleted Scenes,Behind the Scenes" property="specialFeatures" id="specialFeatures"/>
                <dateText property="lastUpdate" enabled="false" style="SWT.BORDER | SWT.TIME" id="lastUpdate"/>
            </composite>
        </composite>
    </section>
</includeTree>
renders the new layout:
 Film detail (improved)

Remarks:

Lines 15:A text controller is trplced by an ImageViewer controller which displays an image for an URL.
Lines 29-32:show how to create a dynamic block. 'forRentGroup' pgroup is created only when field forRent is set to true.


If you are using pagila postgresql datababase rather than sakila mysql, two changes must be done:
replace line 25 by following lines.

<ccombo property="rating" id="rating">
    <labelProvider>
        <textCode>return ((#MODELPACKAGE().MpaaRatingEnum) element).getValue();</textCode>
    </labelProvider>
    <initValues>return java.util.Arrays.asList(#MODELPACKAGE().MpaaRatingEnum.values());</initValues>
</ccombo>

replace line 41 (line 46 after previous change) by following lines.

<multiChoice popupToolbar="true" multiChoiceType="Array" values="Trailers,Commentaries,Deleted Scenes,Behind the Scenes" property="specialFeatures" id="specialFeatures">
    <convertTargetToModel>return java.util.Arrays.copyOf((Object[]) value, ((Object[]) value).length, String[].class);</convertTargetToModel>
</multiChoice>

See page Improve Film Detail (pagila).


Same method can be used for FilmDescription.