Search in sources :

Example 6 with Treeitem

use of org.zkoss.zul.Treeitem in project adempiere by adempiere.

the class WDeleteEntity method createNodes.

//  dynInit
/**
	 * Create Nodes
	 * @param root
	 */
private void createNodes(DeleteEntitiesModel currentNode, Treechildren root) {
    //	Load from parent
    loadChilds(currentNode, root);
    @SuppressWarnings("unchecked") Collection<Treeitem> collItemChild = (Collection<Treeitem>) root.getItems();
    Iterator<Treeitem> it = collItemChild.iterator();
    //	
    while (it.hasNext()) {
        Treeitem node = (Treeitem) it.next();
        Treeitem rootOfNode = node.getParentItem();
        if (rootOfNode != null && rootOfNode.getParentItem() != null && rootOfNode.getParentItem().equals(node)) {
            log.log(Level.WARNING, "Loop detected, escaping.");
            break;
        } else if (((DeleteEntitiesModel) node.getValue()).isMandatoryLink()) {
            DeleteEntitiesModel itemTableData = (DeleteEntitiesModel) node.getValue();
            Treechildren nodeChild = new Treechildren();
            createNodes(itemTableData, nodeChild);
            //	
            if (nodeChild.getItemCount() != 0) {
                node.appendChild(nodeChild);
            }
        }
    }
}
Also used : Treeitem(org.zkoss.zul.Treeitem) DeleteEntitiesModel(org.adempiere.util.DeleteEntitiesModel) Treechildren(org.zkoss.zul.Treechildren) Collection(java.util.Collection)

Example 7 with Treeitem

use of org.zkoss.zul.Treeitem in project adempiere by adempiere.

the class WDeleteEntity method addToNode.

@Override
public void addToNode(DeleteEntitiesModel data, Object rootNode) {
    Treeitem treeitem = new Treeitem();
    ((Treechildren) rootNode).appendChild(treeitem);
    treeitem.setLabel(data.toString());
    treeitem.setValue(data);
}
Also used : Treeitem(org.zkoss.zul.Treeitem) Treechildren(org.zkoss.zul.Treechildren)

Example 8 with Treeitem

use of org.zkoss.zul.Treeitem in project adempiere by adempiere.

the class DPFavourites method onEvent.

public void onEvent(Event event) {
    Component comp = event.getTarget();
    String eventName = event.getName();
    if (eventName.equals(Events.ON_CLICK)) {
        if (comp instanceof Button) {
            Button btn = (Button) comp;
            int menuId = 0;
            try {
                menuId = Integer.valueOf(btn.getName());
            } catch (NumberFormatException e) {
            }
            if (menuId > 0)
                SessionManager.getAppDesktop().onMenuSelected(menuId);
        }
    } else // Elaine 2008/07/24
    if (eventName.equals(Events.ON_DROP)) {
        DropEvent de = (DropEvent) event;
        Component dragged = de.getDragged();
        if (comp instanceof Panelchildren) {
            if (dragged instanceof Treerow) {
                Treerow treerow = (Treerow) dragged;
                Treeitem treeitem = (Treeitem) treerow.getParent();
                addItem(treeitem);
            }
        } else if (comp instanceof Image) {
            if (dragged instanceof Button) {
                Button btn = (Button) dragged;
                removeLink(btn);
            }
        }
    }
//
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) Treeitem(org.zkoss.zul.Treeitem) Button(org.adempiere.webui.component.Button) Panelchildren(org.zkoss.zul.Panelchildren) Component(org.zkoss.zk.ui.Component) Image(org.zkoss.zul.Image) Treerow(org.zkoss.zul.Treerow)

Example 9 with Treeitem

use of org.zkoss.zul.Treeitem 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)

Example 10 with Treeitem

use of org.zkoss.zul.Treeitem in project adempiere by adempiere.

the class TreeSearchPanel method refreshSearchList.

private void refreshSearchList() {
    treeNodeItemMap.clear();
    if (tree.getModel() == null) {
        TreeUtils.traverse(tree, new TreeItemAction() {

            public void run(Treeitem treeItem) {
                addTreeItem(treeItem);
            }
        });
    } else {
        TreeUtils.traverse(tree.getModel(), new TreeNodeAction() {

            public void run(DefaultTreeNode<?> treeNode) {
                addTreeItem(treeNode);
            }
        });
    }
    treeValues = new String[treeNodeItemMap.size()];
    treeDescription = new String[treeNodeItemMap.size()];
    int i = -1;
    for (Object value : treeNodeItemMap.values()) {
        i++;
        if (value instanceof Treeitem) {
            Treeitem treeItem = (Treeitem) value;
            treeValues[i] = treeItem.getLabel();
            treeDescription[i] = treeItem.getTooltiptext();
        } else if (value instanceof DefaultTreeNode) {
            DefaultTreeNode<?> sNode = (DefaultTreeNode<?>) value;
            MTreeNode mNode = (MTreeNode) sNode.getData();
            treeValues[i] = mNode.getName();
            treeDescription[i] = mNode.getDescription();
        }
    }
    cmbSearch.setDescription(treeDescription);
    cmbSearch.setDict(treeValues);
}
Also used : MTreeNode(org.compiere.model.MTreeNode) TreeItemAction(org.adempiere.webui.util.TreeItemAction) Treeitem(org.zkoss.zul.Treeitem) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) TreeNodeAction(org.adempiere.webui.util.TreeNodeAction)

Aggregations

Treeitem (org.zkoss.zul.Treeitem)22 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)8 MTreeNode (org.compiere.model.MTreeNode)7 Treechildren (org.zkoss.zul.Treechildren)7 DeleteEntitiesModel (org.adempiere.util.DeleteEntitiesModel)5 DropEvent (org.zkoss.zk.ui.event.DropEvent)5 Treerow (org.zkoss.zul.Treerow)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 SimpleTreeModel (org.adempiere.webui.component.SimpleTreeModel)3 Component (org.zkoss.zk.ui.Component)3 SQLException (java.sql.SQLException)2 Collection (java.util.Collection)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 SimpleListModel (org.adempiere.webui.component.SimpleListModel)2 Event (org.zkoss.zk.ui.event.Event)2 IOException (java.io.IOException)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 HashSet (java.util.HashSet)1