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 List/Detail editor with a query of all customers of USA with new features.
Use modified query as shown in complete query page.

Add following XML lines where your want the new item to appear:

        <item label="List/Detail customers of USA" image="#IMG(adi://org.adichatz.engine/./IMG_QUERY.png)" id="customerUSAQUERY">
                <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(adichatzNavigator,customerQueryEditorToolTipText)"/>
                <param id="RESOURCE_BUNDLE" value="adi://myproject/./customer"/>
                <param xsi:type="listDetailContentProviderType" adiResourceURI="adi://myproject/model.customer/CustomerQUERY" id="CONTENT_PROVIDER" preferenceURI="queryPreference://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"/>
                <tabular refreshAtStart="true" background="SWT.COLOR_TITLE_BACKGROUND_GRADIENT" id="tableInclude:table"/>
                <sashForm id="ListDetailSashForm" orientation="SWT.HORIZONTAL" weights="3,1"/>
                <section id="detailInclude:detailSection">
                        <listener listenerTypes="BEFORE_SYNCHRONIZE" id="beforeSynchronize">
                            <code>reinitLayout(controller, true);</code>
                <composite id="detailInclude:fieldsComposite">
                    <layout layoutConstraints="wrap 4" columnConstraints="[align right]10[grow,fill]25[align right]10[grow,fill]"/>
                <action id="masterDetailTBM:changeOrientationAction">
                        <listener listenerTypes="PRE_RUN" id="preRun">
                            <code>reinitLayout(controller, false);</code>
                <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:detailSection");
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]"));
        sectionController.getComposite().setLayout(new MigLayout("wrap 2", "[fill, align right]10[fill,grow]"));

The query 'adi://myproject/model.customer/CustomerQUERY' must contains all needed jointures (as address,…) as shown in page complete query.

Lines 7-14: Defines query preferences:

  • Line 7: use a specific content provider (listDetailContentProviderType), built for List/Detail architecture.
  • Line 8: Status bar is 'Navigator' (see below): User can navigates page per page. Table renderer choice is 'Binding' (org.adichatz.engine.renderer.BindingTableRenderer<T>): Modified records use bold font, Erroneous rows are displayed in red foreground color.
  • Line 9: Pagination start to first element (position 0) and fetch 20 rows per page.
  • Line 10: a parameter for the country of the customer is defined. Paramter is added to the query. Value is 44 on property country
  • Line 12: A filter on only 'active' customer is enabled: Filter is applied on UI result and not on server side as parameters.

Lines 22-28: Defines new behavior on ui components:

  • Line 23: launch automatically query ending life cycle of the grid and set background color.
  • Line 24: SashForm orientation is horizontal (meand divided vertically).
  • Lines 27-29: Listener for page layout reinitialization when section controller receives entity (section control is created just after this moment, it is null as long as no row is selected in the grid).
  • Lines 37-39: Listener for page layout reinitialization after selecting action 'changeOrientationAction'.
  • Lines 42-57: the reinit layout code: When editor is vertically split, detail section contains 2 columns, when editor is horizontally split, detail section contains 4 columns.

renders the new layout:
 Customer List/Detail (customized)

tutorial/add_navigator_item.txt · Last modified: 2015/10/05 17:52 (external edit)