Search in sources :

Example 21 with MTreeNode

use of org.compiere.model.MTreeNode in project adempiere by adempiere.

the class ASPGenerateLevel method doIt.

//	prepare
/**
	 * 	Process
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("ASP_Status=" + p_ASP_Status + ", AD_Menu_ID=" + p_AD_Menu_ID + ", IsGenerateFields=" + p_IsGenerateFields);
    MClientInfo clientInfo = MClientInfo.get(getCtx(), getAD_Client_ID(), get_TrxName());
    int AD_Tree_ID = clientInfo.getAD_Tree_Menu_ID();
    //	Yamel Senih [ 9223372036854775807 ]
    //	Change Constructor
    MTree thisTree = new MTree(getCtx(), AD_Tree_ID, true, true, true, null, get_TrxName());
    //	End Yamel Senih
    MTreeNode node;
    if (p_AD_Menu_ID > 0)
        node = thisTree.getRoot().findNode(p_AD_Menu_ID);
    else
        node = thisTree.getRoot();
    // Navigate the menu and add every non-summary node
    if (node != null && node.isSummary()) {
        Enumeration<?> en = node.preorderEnumeration();
        while (en.hasMoreElements()) {
            MTreeNode nn = (MTreeNode) en.nextElement();
            if (!nn.isSummary())
                addNodeToLevel(nn);
        }
    }
    if (noWindows > 0)
        addLog("Window " + noWindows);
    if (noTabs > 0)
        addLog("Tab " + noTabs);
    if (noFields > 0)
        addLog("Field " + noFields);
    if (noProcesses > 0)
        addLog("Process " + noProcesses);
    if (noParameters > 0)
        addLog("Process Parameter " + noParameters);
    if (noForms > 0)
        addLog("Form " + noForms);
    if (noBrowses > 0)
        addLog("noBrowses " + noBrowses);
    if (noTasks > 0)
        addLog("Task " + noTasks);
    if (noWorkflows > 0)
        addLog("Workflow " + noWorkflows);
    return "@OK@";
}
Also used : MTreeNode(org.compiere.model.MTreeNode) MClientInfo(org.compiere.model.MClientInfo) MTree(org.compiere.model.MTree)

Example 22 with MTreeNode

use of org.compiere.model.MTreeNode 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)

Example 23 with MTreeNode

use of org.compiere.model.MTreeNode in project adempiere by adempiere.

the class TreeXML method generateTree.

public void generateTree(MWebProject m_project, MTree thisTree) {
    MTreeNode root = thisTree.getRoot();
    xmlTree.append(appendNode(root));
}
Also used : MTreeNode(org.compiere.model.MTreeNode)

Example 24 with MTreeNode

use of org.compiere.model.MTreeNode in project adempiere by adempiere.

the class SimpleTreeModel method createFrom.

//	End Yamel Senih
/**
	 * 
	 * @param root
	 * @return SimpleTreeModel
	 */
public static SimpleTreeModel createFrom(MTreeNode root) {
    SimpleTreeModel model = null;
    Enumeration<?> nodeEnum = root.children();
    DefaultTreeNode<Object> stRoot = new DefaultTreeNode<Object>(root, nodeEnum.hasMoreElements() ? new ArrayList<TreeNode<Object>>() : null);
    while (nodeEnum.hasMoreElements()) {
        MTreeNode childNode = (MTreeNode) nodeEnum.nextElement();
        DefaultTreeNode<Object> stNode = childNode.getChildCount() > 0 ? new DefaultTreeNode<Object>(childNode, new ArrayList<TreeNode<Object>>()) : new DefaultTreeNode<Object>(childNode);
        stRoot.getChildren().add(stNode);
        if (childNode.getChildCount() > 0) {
            populate(stNode, childNode);
        }
    }
    model = new SimpleTreeModel(stRoot);
    return model;
}
Also used : MTreeNode(org.compiere.model.MTreeNode) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) ArrayList(java.util.ArrayList)

Example 25 with MTreeNode

use of org.compiere.model.MTreeNode in project adempiere by adempiere.

the class SimpleTreeModel method initADTree.

/**
	 * @param tree
	 * @param AD_Tree_ID
	 * @param windowNo
	 * @param editable
	 * @param whereClause
	 * @param trxName
	 * @return SimpleTreeModel
	 */
public static SimpleTreeModel initADTree(Tree tree, int AD_Tree_ID, int windowNo, boolean editable, String whereClause, String trxName) {
    //	Change to where clause
    MTree vTree = new MTree(Env.getCtx(), AD_Tree_ID, editable, true, false, whereClause, trxName);
    MTreeNode root = vTree.getRoot();
    SimpleTreeModel treeModel = SimpleTreeModel.createFrom(root);
    treeModel.setItemDraggable(true);
    treeModel.addOnDropEventListener(new ADTreeOnDropListener(tree, treeModel, vTree, windowNo));
    Treecols treeCols = new Treecols();
    tree.appendChild(treeCols);
    Treecol treeCol = new Treecol();
    treeCols.appendChild(treeCol);
    tree.setPageSize(-1);
    try {
        tree.setItemRenderer(treeModel);
        tree.setModel(treeModel);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Failed to setup tree");
    }
    return treeModel;
}
Also used : Treecol(org.zkoss.zul.Treecol) MTreeNode(org.compiere.model.MTreeNode) Treecols(org.zkoss.zul.Treecols) MTree(org.compiere.model.MTree)

Aggregations

MTreeNode (org.compiere.model.MTreeNode)38 MTree (org.compiere.model.MTree)9 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)8 Treeitem (org.zkoss.zul.Treeitem)7 JTree (javax.swing.JTree)5 ArrayList (java.util.ArrayList)4 Enumeration (java.util.Enumeration)4 TreePath (javax.swing.tree.TreePath)4 MContainer (org.compiere.model.MContainer)3 BorderLayout (java.awt.BorderLayout)2 JButton (javax.swing.JButton)2 JToolBar (javax.swing.JToolBar)2 AdempiereTaskPaneUI (org.adempiere.plaf.AdempiereTaskPaneUI)2 SimpleTreeModel (org.adempiere.webui.component.SimpleTreeModel)2 org.apache.ecs.xhtml.a (org.apache.ecs.xhtml.a)2 org.apache.ecs.xhtml.body (org.apache.ecs.xhtml.body)2 org.apache.ecs.xhtml.head (org.apache.ecs.xhtml.head)2 org.apache.ecs.xhtml.link (org.apache.ecs.xhtml.link)2 MCStage (org.compiere.model.MCStage)2 JXTaskPane (org.jdesktop.swingx.JXTaskPane)2