Search in sources :

Example 16 with Treeitem

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

the class TreeSearchPanel method select.

private void select(Treeitem selectedItem) {
    Treeitem parent = selectedItem.getParentItem();
    while (parent != null) {
        if (!parent.isOpen())
            parent.setOpen(true);
        parent = parent.getParentItem();
    }
    selectedItem.getTree().setSelectedItem(selectedItem);
}
Also used : Treeitem(org.zkoss.zul.Treeitem)

Example 17 with Treeitem

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

the class WDeleteEntity method loadView.

/**
	 * Load View
	 * @param clientId
	 * @param tableId
	 */
private void loadView() {
    //	
    DeleteEntitiesModel data = new DeleteEntitiesModel(getClientId(), getTableId());
    //	
    tree.clear();
    if ((tree.getChildren()).size() > 1) {
        @SuppressWarnings("rawtypes") List treePreviousChild = tree.getChildren();
        tree.removeChild((Treechildren) treePreviousChild.get(1));
    }
    //	
    Treechildren rootTreeChild = new Treechildren();
    Treeitem rootTreeItem = new Treeitem();
    rootTreeItem.setValue(data);
    rootTreeItem.setLabel(data.toString());
    Treechildren rootTreeItemChild = new Treechildren();
    createNodes(data, rootTreeItemChild);
    rootTreeItem.appendChild(rootTreeItemChild);
    rootTreeChild.appendChild(rootTreeItem);
    tree.appendChild(rootTreeChild);
}
Also used : Treeitem(org.zkoss.zul.Treeitem) DeleteEntitiesModel(org.adempiere.util.DeleteEntitiesModel) Treechildren(org.zkoss.zul.Treechildren) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with Treeitem

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

the class TreeUtils method traverse.

/**
	 * Traverse treechildren and execution action on Treeitem
	 * @param treechildren
	 * @param action
	 */
public static void traverse(Treechildren treechildren, TreeItemAction action) {
    List<?> list = treechildren.getChildren();
    for (int index = 0; index < list.size(); index++) {
        Object o = list.get(index);
        if (o instanceof Treechildren) {
            Treechildren treechild = (Treechildren) o;
            traverse(treechild, action);
        } else if (o instanceof Treeitem) {
            Treeitem treeitem = (Treeitem) o;
            action.run(treeitem);
            List<?> treeitemChildren = treeitem.getChildren();
            for (int childIndex = 0; childIndex < treeitemChildren.size(); childIndex++) {
                Object child = treeitemChildren.get(childIndex);
                if (child instanceof Treechildren) {
                    Treechildren treechild = (Treechildren) child;
                    traverse(treechild, action);
                }
            }
        }
    }
}
Also used : Treeitem(org.zkoss.zul.Treeitem) Treechildren(org.zkoss.zul.Treechildren) List(java.util.List)

Example 19 with Treeitem

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

the class WTreeMaintenance method action_treeAdd.

//	propertyChange
/**
	 * 	Action: Add Node to Tree
	 * 	@param item item
	 */
private void action_treeAdd(ListItem item) {
    log.info("Item=" + item);
    if (item != null) {
        SimpleTreeModel model = (SimpleTreeModel) (TreeModel<?>) centerTree.getModel();
        DefaultTreeNode stn = model.find(model.getRoot(), item.id);
        if (stn != null) {
            MTreeNode tNode = (MTreeNode) stn.getData();
            tNode.setName(item.name);
            tNode.setAllowsChildren(item.isSummary);
            tNode.setImageIndicator(item.imageIndicator);
            model.nodeUpdated(stn);
            Treeitem ti = centerTree.renderItemByPath(model.getPath(stn));
            ti.setTooltiptext(item.description);
        } else {
            stn = new DefaultTreeNode(new MTreeNode(item.id, 0, item.name, item.description, 0, item.isSummary, item.imageIndicator, false, null), new ArrayList<Object>());
            model.addNode(stn);
        }
        //	May cause Error if in tree
        addNode(item);
    }
}
Also used : MTreeNode(org.compiere.model.MTreeNode) Treeitem(org.zkoss.zul.Treeitem) SimpleTreeModel(org.adempiere.webui.component.SimpleTreeModel) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) ArrayList(java.util.ArrayList)

Example 20 with Treeitem

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

the class ADTreeOnDropListener method onEvent.

/**
	 * @param event
	 */
public void onEvent(Event event) throws Exception {
    if (event instanceof DropEvent) {
        DropEvent de = (DropEvent) event;
        log.fine("Source=" + de.getDragged() + " Target=" + de.getTarget());
        if (de.getDragged() != de.getTarget()) {
            Treeitem src = (Treeitem) ((Treerow) de.getDragged()).getParent();
            Treeitem target = (Treeitem) ((Treerow) de.getTarget()).getParent();
            moveNode((DefaultTreeNode) src.getValue(), (DefaultTreeNode) target.getValue());
        }
    }
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) Treeitem(org.zkoss.zul.Treeitem)

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