Search in sources :

Example 1 with Decimalbox

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

the class WBrowserListItemRenderer method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    int col = -1;
    int row = -1;
    Object value = null;
    TableValueChangeEvent vcEvent = null;
    WTableColumn tableColumn;
    Component source = event.getTarget();
    if (isWithinListCell(source)) {
        row = getRowPosition(source);
        col = getColumnPosition(source);
        tableColumn = m_tableColumns.get(col);
        if (source instanceof Checkbox) {
            value = Boolean.valueOf(((Checkbox) source).isChecked());
        } else if (source instanceof Decimalbox) {
            value = ((Decimalbox) source).getValue();
        } else if (source instanceof Datebox) {
            value = ((Datebox) source).getValue();
        } else if (source instanceof Textbox) {
            value = ((Textbox) source).getValue();
        }
        if (value != null) {
            vcEvent = new TableValueChangeEvent(source, tableColumn.getHeaderValue().toString(), row, col, value, value);
            fireTableValueChange(vcEvent);
        }
    } else if (event.getTarget() instanceof WBrowserTable && Events.ON_SELECT.equals(event.getName())) {
        WBrowserTable table = (WBrowserTable) event.getTarget();
        if (table.isCheckmark()) {
            int cnt = table.getRowCount();
            if (cnt == 0 || !(table.getValueAt(0, 0) instanceof IDColumn))
                return;
            //update IDColumn
            tableColumn = m_tableColumns.get(0);
            for (int i = 0; i < cnt; i++) {
                IDColumn idcolumn = (IDColumn) table.getValueAt(i, 0);
                if (idcolumn != null) {
                    Listitem item = table.getItemAtIndex(i);
                    value = item.isSelected();
                    Boolean old = idcolumn.isSelected();
                    if (!old.equals(value)) {
                        vcEvent = new TableValueChangeEvent(source, tableColumn.getHeaderValue().toString(), i, 0, old, value);
                        fireTableValueChange(vcEvent);
                    }
                }
            }
        }
    }
    return;
}
Also used : Datebox(org.adempiere.webui.component.Datebox) WTableColumn(org.adempiere.webui.component.WTableColumn) Textbox(org.adempiere.webui.component.Textbox) Listitem(org.zkoss.zul.Listitem) IDColumn(org.compiere.minigrid.IDColumn) Decimalbox(org.zkoss.zul.Decimalbox) Checkbox(org.adempiere.webui.component.Checkbox) Component(org.zkoss.zk.ui.Component) TableValueChangeEvent(org.adempiere.webui.event.TableValueChangeEvent)

Example 2 with Decimalbox

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

the class WBOMDrop method cmd_selection.

//	actionPerformed
/**
	 * 	Enable/disable qty based on selection
	 *	@param source JCheckBox or JRadioButton
	 */
private void cmd_selection(Object source) {
    for (int i = 0; i < m_selectionList.size(); i++) {
        if (source == m_selectionList.get(i)) {
            boolean selected = isSelectionSelected(source);
            Decimalbox qty = m_qtyList.get(i);
            qty.setReadonly(!selected);
            return;
        }
    }
    log.log(Level.SEVERE, "not found - " + source);
}
Also used : Decimalbox(org.zkoss.zul.Decimalbox)

Example 3 with Decimalbox

use of org.zkoss.zul.Decimalbox 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)

Example 4 with Decimalbox

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

the class WListItemRenderer method onEvent.

/* (non-Javadoc)
	 * @see org.zkoss.zk.ui.event.EventListener#onEvent(org.zkoss.zk.ui.event.Event)
	 */
public void onEvent(Event event) throws Exception {
    int col = -1;
    int row = -1;
    Object value = null;
    TableValueChangeEvent vcEvent = null;
    WTableColumn tableColumn;
    Component source = event.getTarget();
    if (isWithinListCell(source)) {
        row = getRowPosition(source);
        col = getColumnPosition(source);
        tableColumn = m_tableColumns.get(col);
        if (source instanceof Checkbox) {
            value = Boolean.valueOf(((Checkbox) source).isChecked());
        } else if (source instanceof Decimalbox) {
            value = ((Decimalbox) source).getValue();
        } else if (source instanceof Datebox) {
            value = ((Datebox) source).getValue();
        } else if (source instanceof Textbox) {
            value = ((Textbox) source).getValue();
        }
        if (value != null) {
            vcEvent = new TableValueChangeEvent(source, tableColumn.getHeaderValue().toString(), row, col, value, value);
            fireTableValueChange(vcEvent);
        }
    } else if (event.getTarget() instanceof WListbox && Events.ON_SELECT.equals(event.getName())) {
        WListbox table = (WListbox) event.getTarget();
        if (table.isCheckmark()) {
            int cnt = table.getRowCount();
            if (cnt == 0 || !(table.getValueAt(0, 0) instanceof IDColumn))
                return;
            //update IDColumn
            tableColumn = m_tableColumns.get(0);
            for (int i = 0; i < cnt; i++) {
                IDColumn idcolumn = (IDColumn) table.getValueAt(i, 0);
                if (idcolumn != null) {
                    Listitem item = table.getItemAtIndex(i);
                    value = item.isSelected();
                    Boolean old = idcolumn.isSelected();
                    if (!old.equals(value)) {
                        vcEvent = new TableValueChangeEvent(source, tableColumn.getHeaderValue().toString(), i, 0, old, value);
                        fireTableValueChange(vcEvent);
                    }
                }
            }
        }
    }
    return;
}
Also used : Listitem(org.zkoss.zul.Listitem) IDColumn(org.compiere.minigrid.IDColumn) Decimalbox(org.zkoss.zul.Decimalbox) Component(org.zkoss.zk.ui.Component) TableValueChangeEvent(org.adempiere.webui.event.TableValueChangeEvent)

Example 5 with Decimalbox

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

the class NumberBox method init.

private void init() {
    Table grid = new Table();
    appendChild(grid);
    grid.setStyle("border: none; padding: 0px; margin: 0px;");
    grid.setDynamicProperty("border", "0");
    grid.setDynamicProperty("cellpadding", "0");
    grid.setDynamicProperty("cellspacing", "0");
    Tr tr = new Tr();
    grid.appendChild(tr);
    tr.setStyle("border: none; padding: 0px; margin: 0px; white-space:nowrap; ");
    Td td = new Td();
    tr.appendChild(td);
    td.setStyle("border: none; padding: 0px; margin: 0px;");
    decimalBox = new Decimalbox();
    if (integral)
        decimalBox.setScale(0);
    //	FR 547
    decimalBox.setStyle("display: inline; text-align: right; padding-right: 2px");
    td.appendChild(decimalBox);
    Td btnColumn = new Td();
    tr.appendChild(btnColumn);
    btnColumn.setStyle("border: none; padding: 0px; margin: 0px;");
    btnColumn.setSclass("editor-button");
    btn = new Button();
    btn.setImage("/images/Calculator10.png");
    btn.setTabindex(-1);
    LayoutUtils.addSclass("editor-button", btn);
    btnColumn.appendChild(btn);
    popup = getCalculatorPopup();
    LayoutUtils.addSclass("editor-button", btn);
    btn.setPopup(popup);
    btn.setStyle("text-align: center;");
    appendChild(popup);
    String style = AEnv.isFirefox2() ? "display: inline" : "display: inline-block";
    style = style + ";white-space:nowrap";
    this.setStyle(style);
}
Also used : Td(org.zkoss.zhtml.Td) Table(org.zkoss.zhtml.Table) Decimalbox(org.zkoss.zul.Decimalbox) Tr(org.zkoss.zhtml.Tr)

Aggregations

Decimalbox (org.zkoss.zul.Decimalbox)6 Checkbox (org.adempiere.webui.component.Checkbox)2 TableValueChangeEvent (org.adempiere.webui.event.TableValueChangeEvent)2 IDColumn (org.compiere.minigrid.IDColumn)2 Table (org.zkoss.zhtml.Table)2 Td (org.zkoss.zhtml.Td)2 Tr (org.zkoss.zhtml.Tr)2 Component (org.zkoss.zk.ui.Component)2 Listitem (org.zkoss.zul.Listitem)2 Button (org.adempiere.webui.component.Button)1 Datebox (org.adempiere.webui.component.Datebox)1 Label (org.adempiere.webui.component.Label)1 Textbox (org.adempiere.webui.component.Textbox)1 WTableColumn (org.adempiere.webui.component.WTableColumn)1 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)1 Hbox (org.zkoss.zul.Hbox)1 Radio (org.zkoss.zul.Radio)1 Radiogroup (org.zkoss.zul.Radiogroup)1