Search in sources :

Example 1 with JXTaskPane

use of org.jdesktop.swingx.JXTaskPane in project adempiere by adempiere.

the class VTreePanel method initTree.

/**
	 *  Tree initialization.
	 * 	May be called several times
	 *	@param	AD_Tree_ID	tree to load
	 *  @return true if loaded ok
	 */
public boolean initTree(int AD_Tree_ID, String whereClause) {
    log.config("AD_Tree_ID=" + AD_Tree_ID);
    //
    m_AD_Tree_ID = AD_Tree_ID;
    //	Yamel Senih [ 9223372036854775807 ]
    //	Add Where Clause
    //  Get Tree
    //		MTree vTree = new MTree (Env.getCtx(), AD_Tree_ID, m_editable, true, null);
    MTree vTree = new MTree(Env.getCtx(), AD_Tree_ID, m_editable, true, null);
    //	End Yamel Senih
    m_root = vTree.getRoot();
    // translate name of menu.
    m_root.setName(Msg.getMsg(Env.getCtx(), vTree.getName()));
    // m_root.setName(Msg.getMsg(Env.getCtx(), "Menu") ); // @Trifon; this is the hardcoded way.
    log.config("root=" + m_root);
    m_nodeTableName = vTree.getNodeTableName();
    treeModel = new AdempiereTreeModel(m_root, true);
    treeModel.setMTree(vTree);
    tree.setModel(treeModel);
    //  Shortcut Bar
    if (m_hasBar) {
        for (JToolBar jt : toolbar) jt.removeAll();
        toolbarMap = new HashMap<Integer, JToolBar>();
        Enumeration<?> enTop = m_root.children();
        JToolBar jt = null;
        Map<JToolBar, String> titleMap = new HashMap<JToolBar, String>();
        while (enTop.hasMoreElements()) {
            MTreeNode ndTop = (MTreeNode) enTop.nextElement();
            Enumeration<?> en = ndTop.preorderEnumeration();
            boolean labelDrawn = false;
            while (en.hasMoreElements()) {
                MTreeNode nd = (MTreeNode) en.nextElement();
                if (nd.isOnBar()) {
                    if (!labelDrawn) {
                        jt = new JToolBar(JToolBar.VERTICAL);
                        titleMap.put(jt, ndTop.toString().trim());
                        labelDrawn = true;
                        toolbarMap.put(ndTop.getNode_ID(), jt);
                    }
                    addToBar(nd, jt, false);
                }
            }
            if (jt != null)
                toolbar.add(jt);
            jt = null;
        }
        //jbInit();
        for (JToolBar jt2 : toolbar) {
            jt2.setOpaque(false);
            //jt2.setLayout(new GridBagLayout());
            jt2.setFloatable(false);
            jt2.setRollover(true);
            jt2.setBorder(BorderFactory.createEmptyBorder());
            JXTaskPane barPart = new JXTaskPane();
            //Begin - [FR 1953769]
            barPart.setUI(new AdempiereTaskPaneUI());
            barPart.getContentPane().setBackground(AdempierePLAF.getFormBackground());
            //End - [FR 1953769]
            barPart.setAnimated(true);
            barPart.setLayout(new BorderLayout());
            barPart.add(jt2, BorderLayout.NORTH);
            barPart.setTitle(titleMap.get(jt2));
            bar.add(barPart);
            //Begin - [FR 1953769]
            bar.setBackground(AdempierePLAF.getFormBackground());
        //End - [FR 1953769]
        }
    }
    return true;
}
Also used : MTreeNode(org.compiere.model.MTreeNode) AdempiereTaskPaneUI(org.adempiere.plaf.AdempiereTaskPaneUI) HashMap(java.util.HashMap) JToolBar(javax.swing.JToolBar) MTree(org.compiere.model.MTree) BorderLayout(java.awt.BorderLayout) JXTaskPane(org.jdesktop.swingx.JXTaskPane)

Example 2 with JXTaskPane

use of org.jdesktop.swingx.JXTaskPane in project adempiere by adempiere.

the class VTreePanel method getParentToolBar.

//  barAdd
/**
	 * Returns the top level parent JToolBar for the given MTreenode. If the parent is not on 
	 * the CPanel yet a new one is created and added.
	 * @param nd
	 * @return top level parent JToolBar for the given MTreenode
	 */
private JToolBar getParentToolBar(MTreeNode nd) {
    int topParentId = getTopParentId(nd);
    JToolBar parent = toolbarMap.get(topParentId);
    if (parent == null) {
        Enumeration<?> enTop = m_root.children();
        while (enTop.hasMoreElements()) {
            MTreeNode ndTop = (MTreeNode) enTop.nextElement();
            if (ndTop.getNode_ID() == topParentId) {
                log.fine("add new category: " + ndTop);
                parent = new JToolBar(JToolBar.VERTICAL);
                toolbarMap.put(ndTop.getNode_ID(), parent);
                toolbar.add(parent);
                parent.setOpaque(false);
                parent.setFloatable(false);
                parent.setRollover(true);
                parent.setBorder(BorderFactory.createEmptyBorder());
                JXTaskPane barPart = new JXTaskPane();
                //Begin - [FR 1953769]
                barPart.setUI(new AdempiereTaskPaneUI());
                barPart.getContentPane().setBackground(AdempierePLAF.getFormBackground());
                //End - [FR 1953769]
                barPart.setTitle(ndTop.toString().trim());
                barPart.setAnimated(true);
                barPart.setLayout(new BorderLayout());
                barPart.add(parent, BorderLayout.NORTH);
                bar.add(barPart);
                return parent;
            }
        }
    } else {
        log.fine("parent found: " + parent);
    }
    return parent;
}
Also used : MTreeNode(org.compiere.model.MTreeNode) AdempiereTaskPaneUI(org.adempiere.plaf.AdempiereTaskPaneUI) BorderLayout(java.awt.BorderLayout) JToolBar(javax.swing.JToolBar) JXTaskPane(org.jdesktop.swingx.JXTaskPane)

Aggregations

BorderLayout (java.awt.BorderLayout)2 JToolBar (javax.swing.JToolBar)2 AdempiereTaskPaneUI (org.adempiere.plaf.AdempiereTaskPaneUI)2 MTreeNode (org.compiere.model.MTreeNode)2 JXTaskPane (org.jdesktop.swingx.JXTaskPane)2 HashMap (java.util.HashMap)1 MTree (org.compiere.model.MTree)1