Differences
This shows you the differences between two versions of the page.
tutorial:add_navigator_item [2020/04/29 11:12] |
tutorial:add_navigator_item [2020/04/29 11:12] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Navigator items can easily be added. Behavior of editor and other parts can directly be changed from the navigator. | ||
+ | |||
+ | In this example, an item is added which provides a way to launch an <wrap adicode>List/Detail</wrap> editor with a query of all customers of USA with new features.\\ | ||
+ | Use modified query as shown in [[complete_query#changed_query|complete query]] page. | ||
+ | \\ | ||
+ | |||
+ | **Add following XML lines where your want the new item to appear:**\\ | ||
+ | <sxh xml; first-line: 1; highlight: [8,11, 16,17,21,26, 31]; title: excerpt from 'GroupListNavigatorContentGENERATED.axml.axml' file (new version).> | ||
+ | <item label="List/Detail customers of USA" image="#IMG(adi://org.adichatz.engine/./IMG_QUERY.png)" id="customerUSAQUERY"> | ||
+ | <params> | ||
+ | <param value="adi://myproject/./country" id="MESSAGE_BUNDLE"/> | ||
+ | <param id="ICON_URI" value="platform:/plugin/org.adichatz.engine/resources/icons/IMG_QUERY.png"/> | ||
+ | <param id="TITLE" value="List/Detail customers of USA"/> | ||
+ | <param id="TOOL_TIP_TEXT" value="#MSG(adichatzGroupNavigator,customerQueryEditorToolTipText)"/> | ||
+ | <param id="RESOURCE_BUNDLE" value="adi://myproject/./customer"/> | ||
+ | <param xsi:type="listDetailContentProviderType" adiResourceURI="adi://myproject/model.customer/CustomerQUERY" id="CONTENT_PROVIDER" preferenceURI="preferenceName://usa"/> | ||
+ | <param id="ADI_RESOURCE_URI" value="adi://org.adichatz.jpa/query/ListDetailQueryForm"/> | ||
+ | <param id="TABLE_RESOURCE_URI" value="adi://myproject/model.customer/CustomerTI"/> | ||
+ | <param id="DETAIL_RESOURCE_URI" value="adi://myproject/model.customer/CustomerDI"/> | ||
+ | <param id="DUPLICATE_EDITOR" value="true"/> | ||
+ | <param id="ADD_EDITOR_TOOLBAR" value="true"/> | ||
+ | </params> | ||
+ | <customizations> | ||
+ | <tabular refreshAtStart="true" background="#COLOR(SWT.COLOR_TITLE_BACKGROUND_GRADIENT)" id="tableInclude:table"/> | ||
+ | <sashForm id="ListDetailSashForm" orientation="SWT.HORIZONTAL" weights="3,1"/> | ||
+ | <section id="detailInclude:detailContainer"> | ||
+ | <listeners> | ||
+ | <listener listenerTypes="BEFORE_SYNCHRONIZE" id="beforeSynchronize"> | ||
+ | <code>reinitLayout(controller, true);</code> | ||
+ | </listener> | ||
+ | </listeners> | ||
+ | </section> | ||
+ | <composite id="detailInclude:fieldsComposite"> | ||
+ | <layout layoutConstraints="wrap 4" columnConstraints="[align right]10[grow,fill]25[align right]10[grow,fill]"/> | ||
+ | </composite> | ||
+ | <action id="masterDetailTBM:changeOrientationAction"> | ||
+ | <listeners> | ||
+ | <listener listenerTypes="PRE_RUN" id="preRun"> | ||
+ | <code>reinitLayout(controller, false);</code> | ||
+ | </listener> | ||
+ | </listeners> | ||
+ | </action> | ||
+ | <additionalCode>import org.adichatz.engine.controller.collection.SashFormController | ||
+ | import org.adichatz.engine.controller.AWidgetController | ||
+ | import org.eclipse.swt.SWT | ||
+ | import org.adichatz.engine.controller.collection.SectionController | ||
+ | import net.miginfocom.swt.MigLayout | ||
+ | private void reinitLayout(AWidgetController controller, boolean inverse) { | ||
+ | SashFormController sashFormController = (SashFormController) controller.getRootCore().getFromRegister("ListDetailSashForm"); | ||
+ | SectionController sectionController = (SectionController) controller.getRootCore().getFromRegister("detailInclude:detailContainer"); | ||
+ | if (null != sectionController.getControl()) { | ||
+ | boolean horizontal = SWT.HORIZONTAL == sashFormController.getControl().getOrientation(); | ||
+ | horizontal = inverse ? !horizontal : horizontal; | ||
+ | if (horizontal) | ||
+ | sectionController.getComposite().setLayout(new MigLayout("wrap 4", "[fill, align right]10[fill,grow]25[align right]10[fill,grow]")); | ||
+ | else | ||
+ | sectionController.getComposite().setLayout(new MigLayout("wrap 2", "[fill, align right]10[fill,grow]")); | ||
+ | }}</additionalCode> | ||
+ | </customizations> | ||
+ | </item> | ||
+ | </sxh> | ||
+ | <WRAP indic><wrap adititle>Remark</wrap>:\\ | ||
+ | The query '<wrap adicode><nowiki>adi://myproject/model.customer/CustomerQUERY</nowiki></wrap>' must contains all needed jointures (as address, address.city...) as shown in page [[complete_query#changed_query|complete query]]. | ||
+ | \\ \\ | ||
+ | <wrap adititle>Explanations</wrap>:\\ | ||
+ | Lines 3-13: Lists needed parameters for launching the List/Detail part: | ||
+ | * Line 8: use a specific content provider (<wrap adicode>listDetailContentProviderType</wrap>), built for **List/Detail** architecture and use a variation of <wrap adicode>customerQUERY</wrap> using **USA** preference (see [[complete_query#changed_query|complete query]]). | ||
+ | * Line 11: a parameter must define the URI for detail part. | ||
+ | \\ | ||
+ | Lines 16-50: Defines new behavior on ui components: | ||
+ | * Line 16: launch automatically query ending life cycle of the grid and set background color. | ||
+ | * Line 17: SashForm orientation is horizontal (means divided vertically). | ||
+ | * Lines 20-22: Listener for page layout reinitialization when <wrap adicode>section controller</wrap> receives entity (<wrap adicode>section control</wrap> is created just after this moment, it is null as long as no row is selected in the grid). | ||
+ | * Line 26: Defines a new layout used by Detail part | ||
+ | * Lines 30-32: Listener for page layout reinitialization after selecting <wrap adicode>action</wrap> 'changeOrientationAction'. | ||
+ | * Lines 35-50: the reinit layout code: When editor is vertically split, detail section contains 2 columns, when editor is horizontally split, detail section contains 4 columns. | ||
+ | | ||
+ | </WRAP> | ||
+ | ** renders the new layout:**\\ | ||
+ | {{tutorial:customer_list_detail.png?600 | Customer List/Detail (customized)}} | ||