Search in sources :

Example 31 with MTreeNode

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

the class VTreeTransferHandler method exportDone.

protected void exportDone(JComponent c, Transferable t, int action) {
    if (action == MOVE) {
        JTree tree = (JTree) c;
        MTreeNode node = null;
        try {
            node = (MTreeNode) t.getTransferData(TransferableTreeNode.TREE_NODE_FLAVOR);
        } catch (Exception e) {
        // ignore
        }
        if (node != null)
            ((DefaultTreeModel) tree.getModel()).removeNodeFromParent(node);
    }
}
Also used : MTreeNode(org.compiere.model.MTreeNode) JTree(javax.swing.JTree)

Example 32 with MTreeNode

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

the class VTreePanel method keyPressed.

//	getDividerLocation
/**
	 *  Enter Key
	 *  @param e event
	 */
protected void keyPressed(KeyEvent e) {
    //CHANGED - document search
    if (e.getSource() == treeSearch && treeSearch.getText() != null && treeSearch.getText().length() > 0 && treeSearch.getText().substring(0, 1).equals(PREFIX_DOCUMENT_SEARCH)) {
        setBusy(true);
        DocumentSearch search = new DocumentSearch();
        if (search.openDocumentsByDocumentNo(treeSearch.getText().substring(1)))
            treeSearch.setText(null);
        setBusy(false);
        return;
    }
    //  *** Tree ***
    if (e.getSource() instanceof JTree || //	InputEvent.CTRL_MASK
    (e.getSource() == treeSearch && e.getModifiers() != 0)) {
        TreePath tp = tree.getSelectionPath();
        if (tp == null)
            ADialog.beep();
        else {
            MTreeNode tn = (MTreeNode) tp.getLastPathComponent();
            setSelectedNode(tn);
        }
    } else //  *** treeSearch ***
    if (e.getSource() == treeSearch) {
        String search = treeSearch.getText();
        boolean found = false;
        //  at the end - try from top
        if (m_nodeEn != null && !m_nodeEn.hasMoreElements())
            m_search = "";
        //  this is the first time
        if (!search.equals(m_search)) {
            //  get enumeration of all nodes
            m_nodeEn = m_root.preorderEnumeration();
            m_search = search;
        }
        //  search the nodes
        while (!found && m_nodeEn != null && m_nodeEn.hasMoreElements()) {
            MTreeNode nd = (MTreeNode) m_nodeEn.nextElement();
            //	compare in upper case
            if (nd.toString().toUpperCase().indexOf(search.toUpperCase()) != -1) {
                found = true;
                TreePath treePath = new TreePath(nd.getPath());
                tree.setSelectionPath(treePath);
                //	expand it
                tree.makeVisible(treePath);
                tree.scrollPathToVisible(treePath);
            }
        }
        if (!found)
            ADialog.beep();
    }
//  treeSearch
}
Also used : MTreeNode(org.compiere.model.MTreeNode) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) DocumentSearch(de.schaeffer.compiere.tools.DocumentSearch)

Example 33 with MTreeNode

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

the class MReportTree method getWhereClause.

//	getTreeType
/**
	 * 	Get Where Clause
	 *	@param ID start node
	 *	@return ColumnName = 1 or ( ColumnName = 1 OR ColumnName = 2 OR ColumnName = 3)
	 */
public String getWhereClause(int ID) {
    log.fine("(" + m_ElementType + ") ID=" + ID);
    String ColumnName = MAcctSchemaElement.getColumnName(m_ElementType);
    //
    MTreeNode node = m_tree.getRoot().findNode(ID);
    log.finest("Root=" + node);
    //
    StringBuffer result = null;
    if (node != null && node.isSummary()) {
        Enumeration<MTreeNode> en = node.preorderEnumeration();
        StringBuffer sb = new StringBuffer();
        while (en.hasMoreElements()) {
            MTreeNode nn = en.nextElement();
            if (!nn.isSummary()) {
                if (sb.length() > 0) {
                    sb.append(" OR ");
                }
                sb.append(ColumnName);
                sb.append('=');
                sb.append(nn.getNode_ID());
                log.finest("- " + nn);
            } else
                log.finest("- skipped parent (" + nn + ")");
        }
        result = new StringBuffer(" ( ");
        result.append(sb);
        result.append(" ) ");
    } else
        //	not found or not summary 
        result = new StringBuffer(ColumnName).append("=").append(ID);
    //
    log.finest(result.toString());
    return result.toString();
}
Also used : MTreeNode(org.compiere.model.MTreeNode)

Example 34 with MTreeNode

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

the class WMenu method createPage.

//  doPost
/**
	 * 	Create Menu Page
	 *	@param request request 
	 *	@param wsc context
	 *	@param AD_Role_ID role
	 *	@return document
	 */
private MobileDoc createPage(HttpServletRequest request, MobileSessionCtx wsc, int AD_Role_ID, int AD_User_ID, int AD_Client_ID, int AD_Org_ID) {
    String windowTitle = Msg.getMsg(wsc.ctx, "Menu");
    MobileDoc doc = MobileDoc.createWindow(windowTitle);
    head head = doc.getHead();
    //  Specific Menu Script/Stylesheet
    head.addElement(new link(MobileEnv.getBaseDirectory("/css/menu.css"), link.REL_STYLESHEET, link.TYPE_CSS));
    //	Body
    body body = doc.getBody();
    div div = new div();
    div.setClass("toolbar");
    h1 header = new h1();
    header.setID("pageTitle");
    div.addElement(header);
    a anchor = new a();
    anchor.setID("backButton");
    anchor.setClass("button");
    div.addElement(anchor);
    anchor = new a();
    anchor.setClass("button");
    anchor.setHref(request.getRequestURI() + "?Exit=true");
    anchor.setTarget("_self");
    anchor.addElement("Logout");
    div.addElement(anchor);
    //  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(wsc.ctx, AD_Tree_ID, false, false, null);
    //	Trim tree
    MTreeNode root = tree.getRoot();
    Enumeration en = root.preorderEnumeration();
    tree.trimTree();
    //	Print tree
    StringBuffer buf = new StringBuffer();
    StringBuffer buffav = new StringBuffer();
    en = root.breadthFirstEnumeration();
    int lastNodeId = 0;
    //  start first level
    buf.append("<ul id=\"main\" selected=\"true\" title=\"Menu\">\n");
    while (en.hasMoreElements()) {
        MTreeNode nd = (MTreeNode) en.nextElement();
        //  Level
        //	0 == root
        int level = nd.getLevel();
        if (level == 0)
            continue;
        //
        MTreeNode parent = (MTreeNode) nd.getParent();
        if (parent != null && parent.getNode_ID() != lastNodeId) {
            buf.append("</ul>\n<ul id=\"" + parent.getNode_ID() + "\" title=\"" + parent.getName() + "\">\n");
            lastNodeId = parent.getNode_ID();
        }
        //	Print Node
        buf.append(printNode(nd, wsc.ctx));
        //Modified by Rob Klein 4/29/07
        if (nd.isOnBar())
            buffav.append(printNode(nd, wsc.ctx));
    }
    //  finish
    buf.append("</ul>\n");
    //Modified by Rob Klein 4/29/07
    //  Set Favorites		
    buf.append("<ul><li class=\"menuSummary\" id=\"218\" onClick=\"changeMenu(event);\">Favorites<ul style=\"display:none\">\n");
    buf.append(buffav);
    buf.append("</ul></li></ul>\n");
    body.addElement(buf.toString());
    body.addElement(div);
    return doc;
}
Also used : org.apache.ecs.xhtml.a(org.apache.ecs.xhtml.a) MTreeNode(org.compiere.model.MTreeNode) Enumeration(java.util.Enumeration) org.apache.ecs.xhtml.link(org.apache.ecs.xhtml.link) org.apache.ecs.xhtml.h1(org.apache.ecs.xhtml.h1) org.apache.ecs.xhtml.body(org.apache.ecs.xhtml.body) MTree(org.compiere.model.MTree) org.apache.ecs.xhtml.head(org.apache.ecs.xhtml.head) org.apache.ecs.xhtml.div(org.apache.ecs.xhtml.div)

Example 35 with MTreeNode

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

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