Search in sources :

Example 1 with ADMenuItem

use of pl.x3E.adInterface.ADMenuItem in project adempiere by adempiere.

the class ADServiceImpl method printNode.

private ADMenuItem printNode(MTreeNode node, Properties ctx, ADMenuItemList itl) {
    ADMenuItem i = itl.addNewItem();
    i.setName(node.getName());
    i.setDescription(node.getDescription());
    i.setADMenuID(node.getNode_ID());
    String type = "";
    if (node.isWindow())
        type = "Window";
    else if (node.isForm())
        type = "Form";
    else if (node.isReport())
        type = "Report";
    else if (node.isProcess())
        type = "Process";
    else if (node.isSummary())
        type = "Summary";
    else if (node.isTask())
        type = "Task";
    else if (node.isWorkbench())
        type = "Workbench";
    else if (node.isWorkFlow())
        type = "Workbench";
    i.setType(type);
    return i;
}
Also used : ADMenuItem(pl.x3E.adInterface.ADMenuItem)

Example 2 with ADMenuItem

use of pl.x3E.adInterface.ADMenuItem in project adempiere by adempiere.

the class ADServiceImpl method getADMenu.

public ADMenuDocument getADMenu(int AD_Role_ID) throws XFireFault {
    authenticate(webServiceName, "getADMenu");
    ADMenuDocument res = ADMenuDocument.Factory.newInstance();
    ADMenuItem menu = res.addNewADMenu();
    menu.setName("Menu");
    menu.setType("Summary");
    AD_Role_ID = Integer.parseInt(m_cs.getM_ctx().getProperty("#AD_Role_ID"));
    //  Load Menu Structure     ----------------------
    int AD_Tree_ID = DB.getSQLValue(null, "SELECT COALESCE(r.AD_Tree_Menu_ID, ci.AD_Tree_Menu_ID)" + "FROM AD_ClientInfo ci" + " INNER JOIN AD_Role r ON (ci.AD_Client_ID=r.AD_Client_ID) " + "WHERE AD_Role_ID=?", AD_Role_ID);
    if (AD_Tree_ID <= 0)
        //	Menu
        AD_Tree_ID = 10;
    //log.fine("doPost - AD_Tree_ID=" + AD_Tree_ID + " - " + Env.getAD_Language(wsc.ctx));
    // Language set in WLogin
    MTree tree = new MTree(m_cs.getM_ctx(), AD_Tree_ID, false, false, null);
    //	Trim tree
    MTreeNode root = tree.getRoot();
    Enumeration en = root.preorderEnumeration();
    // menu.addNewItems();
    ADMenuItemList itl = null;
    //, it_last = null;
    ADMenuItem it = menu;
    Stack stack = new Stack();
    while (en.hasMoreElements()) {
        MTreeNode nd = (MTreeNode) en.nextElement();
        if (nd.isTask() || nd.isWorkbench() || nd.isWorkFlow() || //	Reset Cache - kills the server
        nd.getNode_ID() == 383) {
            MTreeNode parent = (MTreeNode) nd.getParent();
            parent.remove(nd);
        }
    }
    tree.trimTree();
    //	Print tree
    StringBuffer buf = new StringBuffer();
    StringBuffer barbuf = new StringBuffer();
    en = root.preorderEnumeration();
    int oldLevel = 0;
    while (en.hasMoreElements()) {
        MTreeNode nd = (MTreeNode) en.nextElement();
        //  Level
        //	0 == root
        int level = nd.getLevel();
        if (level == 0)
            continue;
        //
        while (oldLevel < level) {
            if (itl != null)
                stack.push(itl);
            itl = it.addNewItems();
            oldLevel++;
        }
        while (oldLevel > level) {
            oldLevel--;
            itl = (ADMenuItemList) stack.pop();
        }
        //	Print Node
        ADMenuItem it_last = printNode(nd, m_cs.getM_ctx(), itl);
        if (nd.isSummary())
            it = it_last;
    //if(nd.isOnBar() && !nd.isSummary())
    //barbuf.append(printNode(nd, m_cs.getM_ctx() ));
    }
    return res;
}
Also used : MTreeNode(org.compiere.model.MTreeNode) ADMenuItemList(pl.x3E.adInterface.ADMenuItemList) Enumeration(java.util.Enumeration) ADMenuDocument(pl.x3E.adInterface.ADMenuDocument) ADMenuItem(pl.x3E.adInterface.ADMenuItem) MTree(org.compiere.model.MTree) Stack(java.util.Stack)

Aggregations

ADMenuItem (pl.x3E.adInterface.ADMenuItem)2 Enumeration (java.util.Enumeration)1 Stack (java.util.Stack)1 MTree (org.compiere.model.MTree)1 MTreeNode (org.compiere.model.MTreeNode)1 ADMenuDocument (pl.x3E.adInterface.ADMenuDocument)1 ADMenuItemList (pl.x3E.adInterface.ADMenuItemList)1