Search in sources :

Example 1 with WTableColumn

use of org.adempiere.webui.component.WTableColumn 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 WTableColumn

use of org.adempiere.webui.component.WTableColumn in project adempiere by adempiere.

the class WBrowserListItemRenderer method setColumnVisibility.

/**
	 * Hide or show column
	 * @param index of the column
	 * @param visible
	 */
public void setColumnVisibility(int index, boolean visible) {
    WTableColumn column;
    if (index >= 0 && index < m_tableColumns.size()) {
        column = m_tableColumns.get(index);
        setColumnVisibility(column, visible);
    } else
        return;
}
Also used : WTableColumn(org.adempiere.webui.component.WTableColumn)

Example 3 with WTableColumn

use of org.adempiere.webui.component.WTableColumn in project adempiere by adempiere.

the class WBrowserListItemRenderer method addColumn.

//  updateColumn
/**
	 *  Add Table Column.  Assumes it is visible.
	 *  after adding a column, you need to set the column classes again
	 *  (DefaultTableModel fires TableStructureChanged, which calls
	 *  JTable.tableChanged .. createDefaultColumnsFromModel
	 *  @param header The header text for the column
	 */
public void addColumn(String header) {
    WTableColumn tableColumn;
    tableColumn = new WTableColumn();
    tableColumn.setHeaderValue(Util.cleanAmp(header));
    setColumnVisibility(tableColumn, true);
    m_tableColumns.add(tableColumn);
    return;
}
Also used : WTableColumn(org.adempiere.webui.component.WTableColumn)

Example 4 with WTableColumn

use of org.adempiere.webui.component.WTableColumn in project adempiere by adempiere.

the class WBrowserListItemRenderer method renderListHead.

/**
	 * Render the ListHead for the table with headers for the table columns.
	 *
	 * @param head	The ListHead component to render.
	 * @see #addColumn(String)
	 */
public void renderListHead(ListHead head) {
    Component header;
    WTableColumn column;
    for (int columnIndex = 0; columnIndex < m_tableColumns.size(); columnIndex++) {
        column = m_tableColumns.get(columnIndex);
        header = getListHeaderComponent(column.getHeaderValue(), columnIndex, column.getColumnClass());
        head.appendChild(header);
    }
    head.setSizable(true);
    return;
}
Also used : WTableColumn(org.adempiere.webui.component.WTableColumn) Component(org.zkoss.zk.ui.Component)

Example 5 with WTableColumn

use of org.adempiere.webui.component.WTableColumn in project adempiere by adempiere.

the class WBrowserListItemRenderer method updateColumn.

/**
	 *  Update Table Column.
	 *
	 *  @param index	The index of the column to update
	 *  @param header 	The header text for the column
	 */
public void updateColumn(int index, String header) {
    WTableColumn tableColumn;
    tableColumn = getColumn(index);
    tableColumn.setHeaderValue(Util.cleanAmp(header));
    return;
}
Also used : WTableColumn(org.adempiere.webui.component.WTableColumn)

Aggregations

WTableColumn (org.adempiere.webui.component.WTableColumn)5 Component (org.zkoss.zk.ui.Component)2 Checkbox (org.adempiere.webui.component.Checkbox)1 Datebox (org.adempiere.webui.component.Datebox)1 Textbox (org.adempiere.webui.component.Textbox)1 TableValueChangeEvent (org.adempiere.webui.event.TableValueChangeEvent)1 IDColumn (org.compiere.minigrid.IDColumn)1 Decimalbox (org.zkoss.zul.Decimalbox)1 Listitem (org.zkoss.zul.Listitem)1