Search in sources :

Example 1 with AdempiereTaskPaneUI

use of org.adempiere.plaf.AdempiereTaskPaneUI 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 AdempiereTaskPaneUI

use of org.adempiere.plaf.AdempiereTaskPaneUI 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)

Example 3 with AdempiereTaskPaneUI

use of org.adempiere.plaf.AdempiereTaskPaneUI in project adempiere by adempiere.

the class Info method jbInit.

/**
	 *	Static Init
	 *  @throws Exception
	 */
protected void jbInit() throws Exception {
    this.getContentPane().add(parameterPanel, BorderLayout.NORTH);
    this.getContentPane().add(scrollPane, BorderLayout.CENTER);
    this.getContentPane().add(southPanel, BorderLayout.SOUTH);
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    //
    AppsAction aa = new AppsAction(ConfirmPanel.A_RESET, null, "reset");
    bReset = (CButton) aa.getButton();
    bReset.setMargin(ConfirmPanel.s_insets);
    bReset.setSize(bReset.getHeight(), bReset.getHeight());
    Dimension bSize = bReset.getSize();
    bSize.height = bReset.getHeight();
    bSize.width = bReset.getHeight();
    // Make it square
    bReset.setMaximumSize(bSize);
    bReset.addActionListener(this);
    //
    buttonPanel = new CPanel(new FlowLayout(FlowLayout.LEFT));
    buttonPanel.add(bReset, FlowLayout.LEFT);
    //
    // p_criteriaGrid is filled by the subordinate class
    p_criteriaGrid.setLayout(new ALayout());
    //
    parameterPanel.setLayout(new BorderLayout());
    parameterPanel.add(buttonPanel, BorderLayout.WEST);
    parameterPanel.add(p_criteriaGrid, BorderLayout.CENTER);
    //
    // Setup the detail panel if used
    p_detailTaskPane.setVisible(false);
    p_detailTaskPane.setCollapsed(true);
    p_detailTaskPane.setLayout(new BorderLayout());
    p_detailTaskPane.setUI(new AdempiereTaskPaneUI());
    p_detailTaskPane.getContentPane().setBackground(new ColorUIResource(251, 248, 241));
    p_detailTaskPane.getContentPane().setForeground(new ColorUIResource(251, 0, 0));
    addonPanel.setLayout(new BorderLayout());
    // Allow auto resizing of the panel
    addonPanel.add(p_detailTaskPane, BorderLayout.CENTER);
    southPanel.setLayout(southLayout);
    southPanel.add(addonPanel, BorderLayout.NORTH);
    southPanel.add(confirmPanel, BorderLayout.CENTER);
    southPanel.add(statusBar, BorderLayout.SOUTH);
    scrollPane.getViewport().add(p_table, null);
    //
    confirmPanel.addActionListener(this);
    confirmPanel.getResetButton().setVisible(hasReset());
    confirmPanel.getCustomizeButton().setVisible(hasCustomize());
    confirmPanel.getHistoryButton().setVisible(hasHistory());
    confirmPanel.getZoomButton().setVisible(hasZoom());
    //  Only show the OK button if we intend to save
    confirmPanel.setOKVisible(p_saveResults);
    //
    JButton print = ConfirmPanel.createPrintButton(true);
    print.addActionListener(this);
    confirmPanel.addButton(print);
    //
    checkAutoQuery.setText(Msg.getMsg(Env.getCtx(), "AutoRefresh"));
    checkAutoQuery.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoRefresh"));
    checkAutoQuery.setName("AutoQuery");
    checkAutoQuery.setSelected(MSysConfig.getValue(SYSCONFIG_INFO_AUTO_QUERY, "Y", Env.getAD_Client_ID(Env.getCtx())).equals("Y"));
    checkAutoQuery.addActionListener(this);
    // Index 0 is OK-Cancel on the right
    CPanel leftButtons = (CPanel) confirmPanel.getComponent(1);
    // Add the check box on the very left before the refresh icon
    leftButtons.add(checkAutoQuery, 0);
    //
    popup.add(zoomMenu);
    zoomMenu.setText(Msg.getMsg(Env.getCtx(), "Zoom"));
    zoomMenu.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Zoom16.gif")));
    zoomMenu.addActionListener(this);
    //
    popup.add(calcMenu);
    calcMenu.setText(Msg.getMsg(Env.getCtx(), "Calculator"));
    calcMenu.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Calculator16.gif")));
    calcMenu.addActionListener(this);
    //
    //  Table Selection (Invoked before setting column class so that row selection is enabled)
    p_table.setKeyColumnIndex(-1);
    p_table.setCellSelectionEnabled(false);
    p_table.setColumnSelectionAllowed(false);
    p_table.setRowSelectionAllowed(true);
    //  Override the Enter key input and action map
    if (p_saveResults) {
        p_table.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doDispose");
    } else {
        p_table.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doNothing");
    }
    p_table.getActionMap().put("doDispose", doDispose);
    // To enable buttons
    ((ListSelectionModel) p_table.getSelectionModel()).addListSelectionListener(this);
    p_table.addMouseListener(this);
    // Listen to changes in the table
    p_table.addPropertyChangeListener("p_table_update", this);
    ((ListSelectionModel) p_table.getSelectionModel()).addListSelectionListener(this);
    //
    //  Set default location where focus will go. See property change listener.
    m_parentPanel = p_criteriaGrid;
    //
    enableButtons();
}
Also used : AdempiereTaskPaneUI(org.adempiere.plaf.AdempiereTaskPaneUI) ImageIcon(javax.swing.ImageIcon) AppsAction(org.compiere.apps.AppsAction) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) CPanel(org.compiere.swing.CPanel) JButton(javax.swing.JButton) ListSelectionModel(javax.swing.ListSelectionModel) Dimension(java.awt.Dimension) ColorUIResource(javax.swing.plaf.ColorUIResource) ALayout(org.compiere.apps.ALayout)

Aggregations

BorderLayout (java.awt.BorderLayout)3 AdempiereTaskPaneUI (org.adempiere.plaf.AdempiereTaskPaneUI)3 JToolBar (javax.swing.JToolBar)2 MTreeNode (org.compiere.model.MTreeNode)2 JXTaskPane (org.jdesktop.swingx.JXTaskPane)2 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 HashMap (java.util.HashMap)1 ImageIcon (javax.swing.ImageIcon)1 JButton (javax.swing.JButton)1 ListSelectionModel (javax.swing.ListSelectionModel)1 ColorUIResource (javax.swing.plaf.ColorUIResource)1 ALayout (org.compiere.apps.ALayout)1 AppsAction (org.compiere.apps.AppsAction)1 MTree (org.compiere.model.MTree)1 CPanel (org.compiere.swing.CPanel)1