Differences
This shows you the differences between two versions of the page.
get_started:improve_part [2020/04/21 11:13] |
get_started:improve_part [2020/04/21 11:13] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP indic> | ||
+ | **Adichatz** generates XML file using **Scenarios** and from the XML files use **Generators** which produce **Java** classes. \\ | ||
+ | The result (editors, navigators, entities...) is rather a draft but by changing manually Adichatz XML file, developers can easily improve layouts and behaviors. | ||
+ | </WRAP> | ||
+ | ==== Original XML File ==== | ||
+ | <sxh xml; first-line: 1; title: 'FilmDIGENERATED.axml' file.> | ||
+ | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
+ | <includeTree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" coreClassName="org.adichatz.engine.core.ASectionCore" 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="Integer" property="filmId" enabled="false" id="filmId"/> | ||
+ | <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> | ||
+ | <refText property="languageByLanguageId" mandatory="true" style="SWT.BORDER | AdiSWT.FIND_BUTTON | AdiSWT.EDITOR_BUTTON" id="languageByLanguageId"> | ||
+ | <convertModelToTarget>return null==value ? "" : #FV().name;</convertModelToTarget> | ||
+ | </refText> | ||
+ | <text textLimit="255" property="title" mandatory="true" id="title"/> | ||
+ | <text textLimit="255" 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() < 1900 || #FV() > 2155;</errorWhen> | ||
+ | </validator> | ||
+ | </validators> | ||
+ | </formattedText> | ||
+ | <checkBox property="active" mandatory="true" style="SWT.CHECK" id="active"/> | ||
+ | <formattedText editPattern="#####" format="Short" 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> | ||
+ | <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> | ||
+ | <text textLimit="255" property="imageUrl" id="imageUrl"/> | ||
+ | <dateText property="lastUpdate" enabled="false" style="SWT.BORDER | SWT.TIME" id="lastUpdate"/> | ||
+ | <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> | ||
+ | </section> | ||
+ | </includeTree> | ||
+ | </sxh> | ||
+ | ==== Original layout ==== | ||
+ | <columns 100% l 550px middle> | ||
+ | {{ tutorial:film_detail_generated.jpg?550 | Film detail (brute)}} | ||
+ | <newcolumn left> | ||
+ | <WRAP adihi> | ||
+ | Using Adichatz XML file editor, it is very easy to change completely the behavior: | ||
+ | </WRAP> | ||
+ | </columns> | ||
+ | ==== Improved XML File ==== | ||
+ | <sxh xml; first-line: 1; title: improved 'FilmDI.axml' file.> | ||
+ | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
+ | <includeTree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" coreClassName="org.adichatz.engine.core.ASectionCore" 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"/> | ||
+ | <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 ? "" : #FV().name;</convertModelToTarget> | ||
+ | </refText> | ||
+ | <refText property="languageByLanguageId" mandatory="true" style="SWT.BORDER | AdiSWT.EDITOR_BUTTON | AdiSWT.FIND_BUTTON" id="languageByLanguageId"> | ||
+ | <convertModelToTarget>return null==value ? "" : #FV().name;</convertModelToTarget> | ||
+ | </refText> | ||
+ | <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> | ||
+ | <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="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> | ||
+ | <dateText property="lastUpdate" enabled="false" style="SWT.BORDER | SWT.TIME" id="lastUpdate"/> | ||
+ | </composite> | ||
+ | </composite> | ||
+ | </section> | ||
+ | </includeTree> | ||
+ | </sxh> | ||
+ | ==== Improved layout ==== | ||
+ | <columns 100% l 550px middle> | ||
+ | {{{{tutorial:entity_editor:1_detail.jpg ?550 | Film detail (improved)}} | ||
+ | <newcolumn left> | ||
+ | <WRAP adihi>The differences are: | ||
+ | * A better layout. | ||
+ | * an Image field rather a Text field containing an URL. | ||
+ | * Combo field replace a text field. | ||
+ | * A dynamic block for the rent issue. | ||
+ | |||
+ | So in a few minutes you can completely change the behavior of generated editors. That only a small part of what you can do. | ||
+ | For example, Three other staways are available: | ||
+ | * add [[features:create_listener|listeners]]. | ||
+ | * extends [[features:extend_controller|controllers]]. | ||
+ | * add [[features:validation_process|Validation process]]. | ||
+ | </WRAP> | ||
+ | </columns> | ||