Customizing the Inspector Mode
The Inspector is a cockpit UI component that shows the details of a selected Item. It is a view-only component. To edit an item, you need to open it in the editor area. The default implementation of the inspector displays attributes and values of the selected item, as well as the coverage information.
Browser Area Configuration
The inspector component in the current implementation is integrated to the system as a part of the browser area of the Product Cockpit. The component itself is a generic component and can be easily integrated in other cockpits as well. The integration in the Product Cockpit is as follows:
- In the productcockpit-web-spring.xml file in the product perspective, the bean definition in the browser area is specified and contains a special viewURI and some other inspector parameters:
<bean id="ProductPerspective" class="de.hybris.platform.productcockpit.session.impl.ProductPerspective" scope="session" parent="BasePerspective"> ... <property name="browserArea"> <bean class="de.hybris.platform.productcockpit.session.impl.BrowserArea"> <property name="viewURI" value="/productcockpit/productBrowser.zul" /> ... <property name="inspectorRenderer" ref="coverageInspectorRenderer"/> <property name="openInspectorOnSelect" value="true"/> </bean> ...
- The view of the browser area is the productBrowser.zul file, which is as follows:
<?xml version="1.0" encoding="UTF-8"?> <?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?> <zk xmlns="http://www.zkoss.org/2005/zul" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:zk="http://www.zkoss.org/2005/zk" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd "> <div width="100%" height="100%" use="de.hybris.platform.cockpit.components.contentbrowser.BrowserContainer" action="onmouseup: comm.sendClick(#{self},null)"> <borderlayout style="background-color: transparent" sclass="infoEnabledBrowserArea"> <center border="none"> <borderlayout sclass="centerAreaContainer" width="100%" height="100%" use="de.hybris.platform.cockpit.components.contentbrowser.CenterAreaContainer"/> </center> <east collapsible="true" open="false" border="none" splittable="true" title=" " visible="true" sclass="infoAreaEast roundedCorners" width="280px" minsize="250"> <div id="infoAreaContainer" sclass="infoArea navigationarea"></div> </east> </borderlayout> </div> </zk>
The infoAreaContainer is important here because it is where the inspector is rendered. In addition to this, a special style class, the infoEnabledBrowserArea class is used here. Otherwise it is very similar to the standard viewURI browser area.
- The de.hybris.platform.productcockpit.session.impl.BrowserArea browser area class used here is a subclass of the AbstractBrowserArea of the cockpit framework. This abstract browser area, as well as all its subclasses, has the inspector mode functionality. Most of the browser area implementations are subclasses of this class.
The following methods of the AbstractBrowserArea are related to the inspector mode:
Method
Description
public void openInspector(final TypedObject item) Opens the inspector with the given item.
public void closeInspector() Closes the inspector.
public Component getInfoArea() Returns the container element for the inspector (the element with the infoAreaContainer ID).
public void updateInfoArea(final ListProvider<TypedObject> listProvider) Updates the content of the inspector according to the given list of items.
Coverage Info Action
In the cockpit there is a ready to use action, CoverageInfoAction, that displays the coverage status of the item and opens the inspector when clicked. It calls the AbstractBrowserArea.openInspector(final TypedObject item) method to open it.
Inspector Configuration
The inspector is specified as a renderer class. It is configured as a property of the browser area as shown in the following code excerpt:
... <bean class="de.hybris.platform.productcockpit.session.impl.BrowserArea"> <property name="viewURI" value="/productcockpit/productBrowser.zul" /> ... <property name="inspectorRenderer" ref="coverageInspectorRenderer"/> <property name="openInspectorOnSelect" value="true"/> </bean> ...
The inspector renderer implements the InspectorRenderer interface defined in the cockpit framework. The DefaultCoverageInspectorRenderer is the default implementation.
Default Coverage Inspector Renderer
The DefaultCoverageInspectorRenderer displays the coverage status, that is the coverage index and messages, as well as the attributes and values of the selected item. It uses the editor area configuration and displayes the attributes of all visible opened sections that have a value. You can also configure the showOnlyVisibleRows flag to display not visible attributes. Empty attributes are not shown at all.
The easiest way to configure the inspector is to configure the editor areas sections and rows accordingly.
If you want a different behavior of the inspector, you can create your own renderer by implementing the interface or extending the default interface and setting it to the browser area as a property.