Search in sources :

Example 1 with CheckboxTree

use of it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree in project adempiere by adempiere.

the class RadioButtonTreeCellRenderer method getTreeCellRendererComponent.

public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    log.fine("row: " + row);
    DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
    log.fine("treeNode.getLevel: " + treeNode.getLevel());
    nodeUserObject m_nodeUserObject = (nodeUserObject) treeNode.getUserObject();
    log.fine("m_nodeUserObject.toString: " + m_nodeUserObject.toString());
    log.fine("m_nodeUserObject.M_Product.getName: " + m_nodeUserObject.M_Product.getName());
    log.fine("value.toString: " + value.toString());
    label.setText(value.toString());
    TreeCheckingModel checkingModel = ((CheckboxTree) tree).getCheckingModel();
    //printTree(new TreePath(tree.getModel().getRoot()), tree.getModel(), checkingModel);
    TreePath path = tree.getPathForRow(row);
    boolean enabled = checkingModel.isPathEnabled(path);
    boolean checked = checkingModel.isPathChecked(path);
    //	    	boolean checkBoxed = checkingModel.isPathCheckBox(path);
    checked = checkingModel.isPathChecked(path);
    //	    	boolean grayed = checkingModel.isPathGreyed(path);
    button.setEnabled(true);
    button.setSelected(checked);
    m_nodeUserObject.isChosen = checked;
    log.fine("m_nodeUserObject.isChosen" + m_nodeUserObject.isChosen);
    if (m_nodeUserObject.isCheckbox || treeNode.isRoot()) {
        panel.add(checkBox);
        panel.remove(button);
        log.fine("checked: " + checked);
        log.fine("enabled: " + enabled);
        checkBox.setEnabled(enabled);
        checkBox.setSelected(checked);
        if (treeNode.isRoot()) {
            checkBox.setSelected(true);
            checkBox.setEnabled(false);
            m_nodeUserObject.isMandatory = true;
        }
        if (m_nodeUserObject.isMandatory) {
            checkBox.setSelected(true);
            checkBox.setEnabled(false);
        }
    } else {
        panel.remove(checkBox);
        panel.add(button);
    }
    panel.add(label);
    m_nodeUserObject.isChosen = checked;
    log.fine("m_nodeUserObject.isChosen: " + m_nodeUserObject.isChosen);
    if (m_nodeUserObject.bom != null) {
        log.fine("m_nodeUserObject.bom not null");
        log.fine("m_nodeUserObject.bom product_id: " + m_nodeUserObject.bom.getM_Product_ID());
        if (m_nodeUserObject.bomLine == null) {
            log.fine("m_nodeUserObject.bomLine is null");
            DefaultMutableTreeNode m_treeNode = getTreeNodeForNodeUserObject(m_nodeUserObject);
            if (!m_treeNode.isRoot()) {
                DefaultMutableTreeNode m_treeNodeParent = (DefaultMutableTreeNode) m_treeNode.getParent();
                if (m_treeNodeParent.isRoot()) {
                    m_nodeUserObject.isMandatory = true;
                }
                nodeUserObject m_nodeUserObjectParent = (nodeUserObject) m_treeNodeParent.getUserObject();
                if (m_nodeUserObjectParent.bom != null) {
                    log.fine("m_nodeUserObjectParent.bom is not null");
                    log.fine("m_nodeUserObjectParent.bom.pp_product_bom_id: " + m_nodeUserObjectParent.bom.get_ID());
                    log.fine("m_nodeUserObject.M_Product.get_ID: " + m_nodeUserObject.M_Product.get_ID());
                    if (getComponentTypeUsingBOMParent(m_nodeUserObjectParent.bom.get_ID(), m_nodeUserObject.M_Product.get_ID()).equals(MPPProductBOMLine.COMPONENTTYPE_Variant) || getComponentTypeUsingBOMParent(m_nodeUserObjectParent.bom.get_ID(), m_nodeUserObject.M_Product.get_ID()).equals(MPPProductBOMLine.COMPONENTTYPE_Component)) {
                        log.fine("Type is checkbox");
                        if (!m_nodeUserObject.isCheckbox) {
                            m_nodeUserObject.isCheckbox = true;
                            panel.remove(label);
                            panel.add(checkBox);
                            panel.add(label);
                            panel.remove(button);
                            if (!m_nodeUserObject.isChosen) {
                                checkBox.setSelected(false);
                                m_nodeUserObject.isChosen = false;
                            } else {
                                checkBox.setSelected(true);
                                m_nodeUserObject.isMandatory = true;
                                m_nodeUserObject.isChosen = true;
                            }
                        }
                    }
                } else {
                    log.fine("Type is checkbox");
                    if (!m_nodeUserObject.isCheckbox) {
                        panel.remove(label);
                        panel.add(checkBox);
                        panel.add(label);
                        panel.remove(button);
                    }
                }
            }
        } else {
            log.fine("m_nodeUserObject.bomLine is not null");
            log.fine("m_nodeUserObject.M_Product.get_ID: " + m_nodeUserObject.M_Product.get_ID());
            log.fine("m_nodeUserObject.bomLine.getM_Product_ID: " + m_nodeUserObject.bomLine.getM_Product_ID());
            log.fine("m_nodeUserObject.isCheckbox: " + m_nodeUserObject.isCheckbox);
        }
    }
    panel.setBackground(Color.white);
    log.fine("m_nodeUserObject.isChosen: " + m_nodeUserObject.isChosen);
    return panel;
}
Also used : TreeCheckingModel(it.cnr.imaa.essi.lablib.gui.checkboxtree.TreeCheckingModel) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) CheckboxTree(it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree)

Example 2 with CheckboxTree

use of it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree in project adempiere by adempiere.

the class RadioButtonTreeCellRenderer method main.

public static void main(String[] args) {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode one = new DefaultMutableTreeNode("one");
    DefaultMutableTreeNode two = new DefaultMutableTreeNode("two");
    DefaultMutableTreeNode three = new DefaultMutableTreeNode("three");
    root.add(one);
    root.add(two);
    root.add(three);
    RadioButtonTreeCellRenderer m_RadioButtonTreeCellRenderer = new RadioButtonTreeCellRenderer();
    final CheckboxTree tree = new CheckboxTree(m_RadioButtonTreeCellRenderer.action_loadBOM(null, false));
    tree.getCheckingModel().setCheckingMode(it.cnr.imaa.essi.lablib.gui.checkboxtree.TreeCheckingModel.CheckingMode.SIMPLE);
    tree.getCheckingModel().clearChecking();
    tree.setCellRenderer(m_RadioButtonTreeCellRenderer);
    tree.addTreeCheckingListener(new TreeCheckingListener() {

        public void valueChanged(TreeCheckingEvent e) {
            log.fine("Checked paths changed: user clicked on " + (e.getLeadingPath().getLastPathComponent()));
        //       		TreeModel tm = tree.getModel();
        //          	TreePath selected = tree.getSelectionPath();
        //       		TreeCheckingModel checkingModel = ((CheckboxTree)tree).getCheckingModel();
        }
    });
    JFrame frame = new JFrame("RadioButton tree");
    frame.add(tree);
    tree.expandAll();
    frame.pack();
    frame.setVisible(true);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CheckboxTree(it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree) JFrame(javax.swing.JFrame) TreeCheckingEvent(it.cnr.imaa.essi.lablib.gui.checkboxtree.TreeCheckingEvent) TreeCheckingListener(it.cnr.imaa.essi.lablib.gui.checkboxtree.TreeCheckingListener)

Example 3 with CheckboxTree

use of it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree in project adempiere by adempiere.

the class VDeleteEntity method preInit.

/**
	 * 	Pre Init
	 */
private void preInit() {
    refreshButton = ConfirmPanel.createRefreshButton(false);
    refreshButton.addActionListener(this);
    //	
    dryRun = new CCheckBox(Msg.getMsg(Env.getCtx(), "DryRun"), true);
    clientLabel = new CLabel(Msg.getElement(Env.getCtx(), "AD_Client_ID"));
    clientPick = new CComboBox(getClients());
    clientPick.setSelectedItem(null);
    clientPick.setMandatory(true);
    clientPick.setBackground(false);
    tableLabel = new CLabel(Msg.getElement(Env.getCtx(), "AD_Table_ID"));
    tablePick = new CComboBox(getTables());
    tablePick.setSelectedItem(null);
    tablePick.setMandatory(true);
    tablePick.setBackground(false);
    rootNode = new DefaultMutableTreeNode(null);
    tree = new CheckboxTree(rootNode);
    treePane = new JScrollPane(tree);
    JViewport viewPort = treePane.getViewport();
    viewPort.add(tree);
}
Also used : CLabel(org.compiere.swing.CLabel) JScrollPane(javax.swing.JScrollPane) CComboBox(org.compiere.swing.CComboBox) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CheckboxTree(it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree) JViewport(javax.swing.JViewport) CCheckBox(org.compiere.swing.CCheckBox)

Example 4 with CheckboxTree

use of it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree in project adempiere by adempiere.

the class VProductConfigurationBOM method createMainPanel.

//	getInvoices
/**************************************************************************
	 * 	Create Main Panel.
	 * 	Called when changing Product
	 */
private void createMainPanel() {
    log.config(": " + m_product);
    this.removeAll();
    this.setPreferredSize(null);
    this.invalidate();
    this.setBorder(null);
    //
    m_selectionList.clear();
    m_productList.clear();
    m_bomLineIDList.clear();
    m_qtyList.clear();
    m_buttonGroups.clear();
    //
    this.setLayout(new ALayout());
    String title = Msg.getMsg(Env.getCtx(), "SelectProduct");
    if (m_product != null && m_product.get_ID() > 0) {
        title = m_product.getName();
        if (m_product.getDescription() != null && m_product.getDescription().length() > 0)
            this.setToolTipText(m_product.getDescription());
        m_bomLine = 0;
        m_tree = new CheckboxTree(this.m_RadioButtonTreeCellRenderer.action_loadBOM(m_product, true));
        m_tree.getCheckingModel().setCheckingMode(it.cnr.imaa.essi.lablib.gui.checkboxtree.TreeCheckingModel.CheckingMode.SIMPLE);
        m_tree.getCheckingModel().clearChecking();
        m_tree.setCellRenderer(this.m_RadioButtonTreeCellRenderer);
        m_tree.setScrollsOnExpand(true);
        JScrollPane treeView = new JScrollPane(m_tree);
        this.add(treeView);
    } else {
        DefaultMutableTreeNode nodeHolder = new DefaultMutableTreeNode(Msg.translate(Env.getCtx(), "No Product Chosen"));
        m_tree = new CheckboxTree(nodeHolder);
        JScrollPane treeView = new JScrollPane(m_tree);
        this.add(treeView);
    }
    this.setBorder(new TitledBorder(title));
}
Also used : JScrollPane(javax.swing.JScrollPane) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CheckboxTree(it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree) TitledBorder(javax.swing.border.TitledBorder) ALayout(org.compiere.apps.ALayout)

Aggregations

CheckboxTree (it.cnr.imaa.essi.lablib.gui.checkboxtree.CheckboxTree)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 JScrollPane (javax.swing.JScrollPane)2 TreeCheckingEvent (it.cnr.imaa.essi.lablib.gui.checkboxtree.TreeCheckingEvent)1 TreeCheckingListener (it.cnr.imaa.essi.lablib.gui.checkboxtree.TreeCheckingListener)1 TreeCheckingModel (it.cnr.imaa.essi.lablib.gui.checkboxtree.TreeCheckingModel)1 JFrame (javax.swing.JFrame)1 JViewport (javax.swing.JViewport)1 TitledBorder (javax.swing.border.TitledBorder)1 TreePath (javax.swing.tree.TreePath)1 ALayout (org.compiere.apps.ALayout)1 CCheckBox (org.compiere.swing.CCheckBox)1 CComboBox (org.compiere.swing.CComboBox)1 CLabel (org.compiere.swing.CLabel)1