Part can use rich controllers provided by Adichatz as [[controllers:gmapcontroller|GMapController]]. Before using [[controllers:gmapcontroller|GMapController]], [[https://developers.google.com/maps/documentation/javascript/get-api-key | get GMap API key]] and store it in './resources/xml/AdichatzRcpConfig.xml' file as shown below. ... ... \\ \\ For example, open file $projectDirectory/resources/xml/model/address/AddressDIGENERATED.xml.\\ \\ **Following XML elements:**
\\ **renders the following layout:**\\ {{ tutorial:address_detail.png?600 | Address detail (brute) }} \\ \\ \\ **Change XML elements**: * Copy AddressDIGENERATED.axml file to AddressDI.axml which will become the reference for generated code. * Replace above XML lines with the following ones:
displayGMap(); import org.adichatz.engine.widgets.GMap; import java.lang.Runnable; private boolean doit = true; private void displayGMap() { if (doit) { doit = false; GMap gmapControl = #CONTROL(map); Address address = #BEAN(); if (null != address) { StringBuffer addresSB = new StringBuffer(); if (null != address.getAddress()) addresSB.append(address.getAddress()).append(" "); if (null != address.getAddress2()) addresSB.append(address.getAddress2()).append(" "); if (null != address.getPostalCode()) addresSB.append(address.getPostalCode()).append(" "); if (null != address.getCity()) { addresSB.append(address.getCity().getCity()).append(" "); addresSB.append(#BEAN().city.country.country); } gmapControl.setValue(addresSB.toString().trim()); } else gmapControl.setValue(null); doit = true; } } return null==value ? "" : #FV().city;
** renders the new layout:**\\ {{tutorial:address_detail_gmap.png?600 | Address detail (improved)}} \\ Remarks:\\ Lines 12-14: Method displayGMap is called at three moments of the life cycle of the controller: * AFTER_SYNCHRONIZE: After received entity is injected inside UI controllers. * AFTER_PROPERTY_CHANGE: After UI send a change to a property of the entity. * POST_REFRESH: After changes on entity are cancelled by asking to refresh property values from Database. Lines 16-41: Build an address string from property values and set the string to the GMap control. Line 55: Set a gmap controller.