Search in sources :

Example 6 with DefaultTreeNode

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

the class WTreeMaintenance method action_treeDelete.

//	action_treeAdd
/**
	 * 	Action: Delete Node from Tree
	 * 	@param item item
	 */
private void action_treeDelete(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)
            model.removeNode(stn);
        //
        deleteNode(item);
    }
}
Also used : SimpleTreeModel(org.adempiere.webui.component.SimpleTreeModel) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode)

Example 7 with DefaultTreeNode

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

the class ADTreeOnDropListener method moveNode.

/**
	 *	Move TreeNode
	 *	@param	movingNode	The node to be moved
	 *	@param	toNode		The target node
	 */
private void moveNode(DefaultTreeNode movingNode, DefaultTreeNode toNode) {
    log.info(movingNode.toString() + " to " + toNode.toString());
    if (movingNode == toNode)
        return;
    MTreeNode toMNode = (MTreeNode) toNode.getData();
    DefaultTreeNode newParent;
    int index;
    if (//	drop on a child node
    !toMNode.isSummary()) {
        moveNode(movingNode, toNode, false);
    } else //	drop on a summary node
    {
        //prompt user to select insert after or drop into the summary node
        int[] path = treeModel.getPath(toNode);
        Treeitem toItem = tree.renderItemByPath(path);
        tree.setSelectedItem(toItem);
        Events.sendEvent(tree, new Event(Events.ON_SELECT, tree));
        MenuListener listener = new MenuListener(movingNode, toNode);
        //TODO: translation
        Menupopup popup = new Menupopup();
        Menuitem menuItem = new Menuitem("Insert After");
        menuItem.setValue("InsertAfter");
        menuItem.setParent(popup);
        menuItem.addEventListener(Events.ON_CLICK, listener);
        menuItem = new Menuitem("Move Into");
        menuItem.setValue("MoveInto");
        menuItem.setParent(popup);
        menuItem.addEventListener(Events.ON_CLICK, listener);
        popup.setPage(tree.getPage());
        popup.open(toItem.getTreerow());
    }
}
Also used : MTreeNode(org.compiere.model.MTreeNode) Treeitem(org.zkoss.zul.Treeitem) Menupopup(org.zkoss.zul.Menupopup) Menuitem(org.zkoss.zul.Menuitem) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) Event(org.zkoss.zk.ui.event.Event) DropEvent(org.zkoss.zk.ui.event.DropEvent)

Example 8 with DefaultTreeNode

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

Example 9 with DefaultTreeNode

use of org.zkoss.zul.DefaultTreeNode 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 10 with DefaultTreeNode

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

the class WTreeBOM method parent.

public DefaultTreeNode parent(MPPProductBOMLine bomline) {
    MProduct M_Product = MProduct.get(getCtx(), bomline.getM_Product_ID());
    MPPProductBOM bomproduct = new MPPProductBOM(getCtx(), bomline.getPP_Product_BOM_ID(), null);
    DefaultTreeNode parent = new DefaultTreeNode(productSummary(M_Product, false), new ArrayList());
    Vector<Object> line = new Vector<Object>(17);
    //  0 Select
    line.add(new Boolean(false));
    //  1 IsActive
    line.add(new Boolean(true));
    // 2 Line                
    line.add(new Integer(bomline.getLine()));
    //  3 ValidDrom
    line.add((Timestamp) bomline.getValidFrom());
    //  4 ValidTo
    line.add((Timestamp) bomline.getValidTo());
    KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(), M_Product.getName());
    //  5 M_Product_ID
    line.add(pp);
    KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(), bomline.getC_UOM().getUOMSymbol());
    //  6 C_UOM_ID
    line.add(uom);
    //  7 IsQtyPorcentage
    line.add(new Boolean(bomline.isQtyPercentage()));
    //  8 BatchPercent
    line.add((BigDecimal) bomline.getQtyBatch());
    //  9 QtyBOM
    line.add((BigDecimal) ((bomline.getQtyBOM() != null) ? bomline.getQtyBOM() : new BigDecimal(0)));
    //  10 IsCritical                  
    line.add(new Boolean(bomline.isCritical()));
    // 11 LTOffSet
    line.add((Integer) bomline.getLeadTimeOffset());
    // 12 Assay
    line.add((BigDecimal) bomline.getAssay());
    // 13 Scrap
    line.add((BigDecimal) (bomline.getScrap()));
    // 14 IssueMethod
    line.add((String) bomline.getIssueMethod());
    // 15 BackflushGroup
    line.add((String) bomline.getBackflushGroup());
    // 16 Forecast
    line.add((BigDecimal) bomline.getForecast());
    dataBOM.add(line);
    for (MPPProductBOM bom : MPPProductBOM.getProductBOMs((MProduct) bomproduct.getM_Product())) {
        MProduct component = MProduct.get(getCtx(), bom.getM_Product_ID());
        return component(component);
    }
    return parent;
}
Also used : MProduct(org.compiere.model.MProduct) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) ArrayList(java.util.ArrayList) KeyNamePair(org.compiere.util.KeyNamePair) MPPProductBOM(org.eevolution.model.MPPProductBOM) Vector(java.util.Vector) BigDecimal(java.math.BigDecimal)

Aggregations

DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)15 MTreeNode (org.compiere.model.MTreeNode)8 Treeitem (org.zkoss.zul.Treeitem)8 ArrayList (java.util.ArrayList)6 SimpleTreeModel (org.adempiere.webui.component.SimpleTreeModel)6 MProduct (org.compiere.model.MProduct)3 Vector (java.util.Vector)2 SimpleListModel (org.adempiere.webui.component.SimpleListModel)2 KeyNamePair (org.compiere.util.KeyNamePair)2 MPPProductBOM (org.eevolution.model.MPPProductBOM)2 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)2 DropEvent (org.zkoss.zk.ui.event.DropEvent)2 Event (org.zkoss.zk.ui.event.Event)2 Treecol (org.zkoss.zul.Treecol)2 Treecols (org.zkoss.zul.Treecols)2 BigDecimal (java.math.BigDecimal)1 DocumentSearch (org.adempiere.webui.util.DocumentSearch)1 TreeItemAction (org.adempiere.webui.util.TreeItemAction)1 TreeNodeAction (org.adempiere.webui.util.TreeNodeAction)1 Trx (org.compiere.util.Trx)1