Search in sources :

Example 1 with Radiogroup

use of org.zkoss.zul.Radiogroup in project adempiere by adempiere.

the class WBOMDrop method onEvent.

//	addDisplay
/**************************************************************************
	 *	Action Listener
	 *  @param e event
	 */
public void onEvent(Event e) throws Exception {
    log.config(e.getName());
    Object source = e.getTarget();
    //	Toggle Qty Enabled
    if (source instanceof Checkbox || source instanceof Radio) {
        cmd_selection(source);
        //	need to de-select the others in group	
        if (source instanceof Radio) {
            //	find Button Group
            Iterator<Radiogroup> it = m_buttonGroups.values().iterator();
            while (it.hasNext()) {
                Radiogroup group = it.next();
                Enumeration en = (Enumeration) group.getChildren();
                while (en.hasMoreElements()) {
                    //	We found the group
                    if (source == en.nextElement()) {
                        Enumeration info = (Enumeration) group.getChildren();
                        while (info.hasMoreElements()) {
                            Object infoObj = info.nextElement();
                            if (source != infoObj)
                                cmd_selection(infoObj);
                        }
                    }
                }
            }
        }
    } else //	Product / Qty
    if (source == productField || source == productQty) {
        m_qty = productQty.getValue();
        ListItem listitem = productField.getSelectedItem();
        KeyNamePair pp = null;
        if (listitem != null)
            pp = listitem.toKeyNamePair();
        m_product = MProduct.get(Env.getCtx(), pp.getKey());
        createMainPanel();
    //sizeIt();
    } else //	Order
    if (source == orderField) {
        ListItem listitem = orderField.getSelectedItem();
        KeyNamePair pp = null;
        if (listitem != null)
            pp = listitem.toKeyNamePair();
        boolean valid = (pp != null && pp.getKey() > 0);
        if (invoiceField != null)
            invoiceField.setEnabled(!valid);
        if (projectField != null)
            projectField.setEnabled(!valid);
    } else //	Invoice
    if (source == invoiceField) {
        ListItem listitem = invoiceField.getSelectedItem();
        KeyNamePair pp = null;
        if (listitem != null)
            pp = listitem.toKeyNamePair();
        boolean valid = (pp != null && pp.getKey() > 0);
        if (orderField != null)
            orderField.setEnabled(!valid);
        if (projectField != null)
            projectField.setEnabled(!valid);
    } else //	Project
    if (source == projectField) {
        ListItem listitem = projectField.getSelectedItem();
        KeyNamePair pp = null;
        if (listitem != null)
            pp = listitem.toKeyNamePair();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (orderField != null)
            orderField.setEnabled(!valid);
        if (invoiceField != null)
            invoiceField.setEnabled(!valid);
    } else //	OK
    if (confirmPanel.getButton("Ok").equals(e.getTarget())) {
        if (cmd_save())
            SessionManager.getAppDesktop().closeActiveWindow();
    } else if (confirmPanel.getButton("Cancel").equals(e.getTarget()))
        SessionManager.getAppDesktop().closeActiveWindow();
    //	Enable OK
    boolean OK = m_product != null;
    if (OK) {
        KeyNamePair pp = null;
        if (orderField != null) {
            ListItem listitem = orderField.getSelectedItem();
            if (listitem != null)
                pp = listitem.toKeyNamePair();
        }
        if ((pp == null || pp.getKey() <= 0) && invoiceField != null) {
            ListItem listitem = invoiceField.getSelectedItem();
            if (listitem != null)
                pp = listitem.toKeyNamePair();
        }
        if ((pp == null || pp.getKey() <= 0) && projectField != null) {
            ListItem listitem = projectField.getSelectedItem();
            if (listitem != null)
                pp = listitem.toKeyNamePair();
        }
        OK = (pp != null && pp.getKey() > 0);
    }
    confirmPanel.setEnabled("Ok", OK);
}
Also used : Enumeration(java.util.Enumeration) Checkbox(org.adempiere.webui.component.Checkbox) Radiogroup(org.zkoss.zul.Radiogroup) Radio(org.zkoss.zul.Radio) ListItem(org.adempiere.webui.component.ListItem) KeyNamePair(org.compiere.util.KeyNamePair)

Example 2 with Radiogroup

use of org.zkoss.zul.Radiogroup in project adempiere by adempiere.

the class WBOMDrop method addDisplay.

//	addBOMLine
/**
	 * 	Add Line to Display
	 *	@param parentM_Product_ID parent product
	 *	@param M_Product_ID product
	 *	@param bomType bom type
	 *	@param name name
	 *	@param lineQty qty
	 */
private void addDisplay(int parentM_Product_ID, int M_Product_ID, String bomType, String name, BigDecimal lineQty) {
    log.fine("M_Product_ID=" + M_Product_ID + ",Type=" + bomType + ",Name=" + name + ",Qty=" + lineQty);
    boolean selected = true;
    Hbox boxQty = new Hbox();
    boxQty.setWidth("100%");
    boxQty.setWidths("10%, 40%, 50%");
    if (MProductBOM.BOMTYPE_StandardPart.equals(bomType)) {
        String title = "";
        Checkbox cb = new Checkbox();
        cb.setLabel(title);
        cb.setChecked(true);
        cb.setEnabled(false);
        m_selectionList.add(cb);
        boxQty.appendChild(cb);
    } else if (MProductBOM.BOMTYPE_OptionalPart.equals(bomType)) {
        String title = Msg.getMsg(Env.getCtx(), "Optional");
        Checkbox cb = new Checkbox();
        cb.setLabel(title);
        cb.setChecked(false);
        selected = false;
        cb.addEventListener(Events.ON_CHECK, this);
        m_selectionList.add(cb);
        boxQty.appendChild(cb);
    } else //	Alternative
    {
        String title = Msg.getMsg(Env.getCtx(), "Alternative") + " " + bomType;
        Radio b = new Radio();
        b.setLabel(title);
        String groupName = String.valueOf(parentM_Product_ID) + "_" + bomType;
        Radiogroup group = m_buttonGroups.get(groupName);
        if (group == null) {
            log.fine("ButtonGroup=" + groupName);
            group = new Radiogroup();
            m_buttonGroups.put(groupName, group);
            group.appendChild(b);
            //	select first one
            b.setSelected(true);
        } else {
            group.appendChild(b);
            b.setSelected(false);
            selected = false;
        }
        b.addEventListener(Events.ON_CLICK, this);
        m_selectionList.add(b);
        boxQty.appendChild(b);
    }
    //	Add to List & display
    m_productList.add(new Integer(M_Product_ID));
    Decimalbox qty = new Decimalbox();
    qty.setValue(lineQty);
    qty.setReadonly(!selected);
    m_qtyList.add(qty);
    Label label = new Label(name);
    HtmlBasedComponent c = (HtmlBasedComponent) label.rightAlign();
    c.setStyle(c.getStyle() + ";margin-right: 5px");
    boxQty.appendChild(c);
    boxQty.appendChild(qty);
    grpSelectProd.appendChild(boxQty);
}
Also used : Hbox(org.zkoss.zul.Hbox) Decimalbox(org.zkoss.zul.Decimalbox) Checkbox(org.adempiere.webui.component.Checkbox) Radiogroup(org.zkoss.zul.Radiogroup) Label(org.adempiere.webui.component.Label) Radio(org.zkoss.zul.Radio) HtmlBasedComponent(org.zkoss.zk.ui.HtmlBasedComponent)

Aggregations

Checkbox (org.adempiere.webui.component.Checkbox)2 Radio (org.zkoss.zul.Radio)2 Radiogroup (org.zkoss.zul.Radiogroup)2 Enumeration (java.util.Enumeration)1 Label (org.adempiere.webui.component.Label)1 ListItem (org.adempiere.webui.component.ListItem)1 KeyNamePair (org.compiere.util.KeyNamePair)1 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)1 Decimalbox (org.zkoss.zul.Decimalbox)1 Hbox (org.zkoss.zul.Hbox)1