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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations