Search in sources :

Example 6 with SimpleTreeModel

use of org.adempiere.webui.component.SimpleTreeModel in project adempiere by adempiere.

the class ADTabPanel method deleteNode.

private void deleteNode(int recordId) {
    if (recordId <= 0)
        return;
    SimpleTreeModel model = (SimpleTreeModel) treePanel.getTree().getModel();
    if (treePanel.getTree().getSelectedItem() != null) {
        SimpleTreeNode treeNode = (SimpleTreeNode) treePanel.getTree().getSelectedItem().getValue();
        MTreeNode data = (MTreeNode) treeNode.getData();
        if (data.getNode_ID() == recordId) {
            model.removeNode(treeNode);
            return;
        }
    }
    SimpleTreeNode treeNode = model.find(null, recordId);
    if (treeNode != null) {
        model.removeNode(treeNode);
    }
}
Also used : SimpleTreeModel(org.adempiere.webui.component.SimpleTreeModel)

Example 7 with SimpleTreeModel

use of org.adempiere.webui.component.SimpleTreeModel 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 8 with SimpleTreeModel

use of org.adempiere.webui.component.SimpleTreeModel in project adempiere by adempiere.

the class WTreeBOM method action_loadBOM.

private void action_loadBOM() {
    int M_Product_ID = getM_Product_ID();
    if (M_Product_ID == 0)
        return;
    MProduct product = MProduct.get(getCtx(), M_Product_ID);
    DefaultTreeNode parent = new DefaultTreeNode(productSummary(product, false), new ArrayList());
    dataBOM.clear();
    if (isImplosion()) {
        try {
            m_tree.setModel(null);
        } catch (Exception e) {
        }
        if (m_tree.getTreecols() != null)
            m_tree.getTreecols().detach();
        if (m_tree.getTreefoot() != null)
            m_tree.getTreefoot().detach();
        if (m_tree.getTreechildren() != null)
            m_tree.getTreechildren().detach();
        for (MPPProductBOMLine bomline : MPPProductBOMLine.getByProduct(product)) {
            parent.getChildren().add(parent(bomline));
        }
        Treecols treeCols = new Treecols();
        m_tree.appendChild(treeCols);
        Treecol treeCol = new Treecol();
        treeCols.appendChild(treeCol);
        SimpleTreeModel model = new SimpleTreeModel(parent);
        m_tree.setPageSize(-1);
        m_tree.setTreeitemRenderer(model);
        m_tree.setModel(model);
    } else {
        try {
            m_tree.setModel(null);
        } catch (Exception e) {
        }
        if (m_tree.getTreecols() != null)
            m_tree.getTreecols().detach();
        if (m_tree.getTreefoot() != null)
            m_tree.getTreefoot().detach();
        if (m_tree.getTreechildren() != null)
            m_tree.getTreechildren().detach();
        for (MPPProductBOM bom : MPPProductBOM.getProductBOMs(product)) {
            parent.getChildren().add(parent(bom));
        }
        Treecols treeCols = new Treecols();
        m_tree.appendChild(treeCols);
        Treecol treeCol = new Treecol();
        treeCols.appendChild(treeCol);
        SimpleTreeModel model = new SimpleTreeModel(parent);
        m_tree.setPageSize(-1);
        m_tree.setTreeitemRenderer(model);
        m_tree.setModel(model);
    }
    m_tree.addEventListener(Events.ON_SELECTION, this);
    loadTableBOM();
}
Also used : Treecol(org.zkoss.zul.Treecol) Treecols(org.zkoss.zul.Treecols) MProduct(org.compiere.model.MProduct) SimpleTreeModel(org.adempiere.webui.component.SimpleTreeModel) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) ArrayList(java.util.ArrayList) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) MPPProductBOM(org.eevolution.model.MPPProductBOM)

Example 9 with SimpleTreeModel

use of org.adempiere.webui.component.SimpleTreeModel in project adempiere by adempiere.

the class WCRPDetail method getTree.

private Tree getTree() {
    Tree tree = new Tree();
    List<String> nodes = model.getDataset().getColumnKeys();
    DefaultTreeNode root = new DefaultTreeNode(getResource(resource.getValue()).getName(), new ArrayList());
    for (String node : nodes) {
        root.getChildren().add(new DefaultTreeNode(node, new ArrayList()));
    }
    Treecols treeCols = new Treecols();
    tree.appendChild(treeCols);
    Treecol treeCol = new Treecol();
    treeCols.appendChild(treeCol);
    SimpleTreeModel model = new SimpleTreeModel(root);
    tree.setPageSize(-1);
    tree.setTreeitemRenderer(model);
    tree.setModel(model);
    return tree;
}
Also used : Treecol(org.zkoss.zul.Treecol) Treecols(org.zkoss.zul.Treecols) SimpleTreeModel(org.adempiere.webui.component.SimpleTreeModel) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) ArrayList(java.util.ArrayList) Tree(org.zkoss.zul.Tree)

Aggregations

SimpleTreeModel (org.adempiere.webui.component.SimpleTreeModel)9 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)6 ArrayList (java.util.ArrayList)3 Treeitem (org.zkoss.zul.Treeitem)3 MTreeNode (org.compiere.model.MTreeNode)2 Treecol (org.zkoss.zul.Treecol)2 Treecols (org.zkoss.zul.Treecols)2 SimpleListModel (org.adempiere.webui.component.SimpleListModel)1 MProduct (org.compiere.model.MProduct)1 MPPProductBOM (org.eevolution.model.MPPProductBOM)1 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)1 Tree (org.zkoss.zul.Tree)1