Search in sources :

Example 1 with DocumentSearch

use of org.adempiere.webui.util.DocumentSearch in project adempiere by adempiere.

the class TreeSearchPanel method onEvent.

/**
     * @param event
     * @see EventListener#onEvent(Event)
     */
public void onEvent(Event event) {
    if (cmbSearch.equals(event.getTarget()) && ((event.getName().equals(Events.ON_CHANGE) || event.getName().equals(Events.ON_OK)))) {
        String value = cmbSearch.getValue();
        if (value != null && value.trim().length() > 0 && value.substring(0, 1).equals(PREFIX_DOCUMENT_SEARCH)) {
            DocumentSearch search = new DocumentSearch();
            if (search.openDocumentsByDocumentNo(value.substring(1)))
                cmbSearch.setText(null);
            return;
        }
        Object node = treeNodeItemMap.get(value);
        Treeitem treeItem = null;
        if (node == null) {
            return;
        } else if (node instanceof Treeitem) {
            treeItem = (Treeitem) node;
        } else {
            DefaultTreeNode<?> sNode = (DefaultTreeNode<?>) node;
            int[] path = tree.getModel().getPath(sNode);
            treeItem = tree.renderItemByPath(path);
            tree.setSelectedItem(treeItem);
        }
        if (treeItem != null) {
            select(treeItem);
            Clients.showBusy(Msg.getMsg(Env.getCtx(), "Loading"));
            Events.echoEvent("onPostSelect", this, null);
        }
    }
}
Also used : Treeitem(org.zkoss.zul.Treeitem) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) DocumentSearch(org.adempiere.webui.util.DocumentSearch)

Aggregations

DocumentSearch (org.adempiere.webui.util.DocumentSearch)1 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)1 Treeitem (org.zkoss.zul.Treeitem)1