use of org.adempiere.webui.component.ListHead in project adempiere by adempiere.
the class WBrowserTable method setData.
/**
* Set the data model and column header names for the Listbox.
*
* @param model The data model to assign to the table
* @param columnNames The names of the table columns
*/
public void setData(ListModelTable model, List<? extends String> columnNames) {
WBrowserListItemRenderer rowRenderer = null;
int size = 0;
if (columnNames != null)
size = columnNames.size();
//
if (size > 0) {
// instantiate our custom row renderer
rowRenderer = new WBrowserListItemRenderer(this);
// add listener for listening to component changes
rowRenderer.addTableValueChangeListener(this);
}
// assign the model and renderer
this.setModel(model);
if (rowRenderer != null) {
getModel().setNoColumns(size);
this.setItemRenderer(rowRenderer);
//recreate listhead if needed
ListHead head = super.getListHead();
if (head != null) {
head.getChildren().clear();
rowRenderer.renderListHead(head);
}
}
autoSize();
if (isShowTotals())
addTotals();
// re-render
this.repaint();
return;
}
use of org.adempiere.webui.component.ListHead in project adempiere by adempiere.
the class WListItemRendererTest method testClearColumns.
/**
* Test method for {@link org.adempiere.webui.component.WListItemRenderer#clearColumns()}.
*/
@Test
public final void testClearColumns() {
ListHead head = new ListHead();
m_renderer.clearColumns();
assertEquals(0, m_renderer.getNoColumns());
m_renderer.renderListHead(head);
assertEquals(0, head.getChildren().size());
}
use of org.adempiere.webui.component.ListHead in project adempiere by adempiere.
the class WListItemRendererTest method testUpdateColumn.
/**
* Test method for {@link org.adempiere.webui.component.WListItemRenderer#updateColumn(int, java.lang.String)}.
*/
@Test
public final void testUpdateColumn() {
ListHead head = new ListHead();
ListHeader header;
m_renderer.updateColumn(1, "Address");
assertEquals(2, m_renderer.getNoColumns());
m_renderer.renderListHead(head);
header = (ListHeader) head.getChildren().get(1);
assertEquals("Address", header.getLabel());
}
use of org.adempiere.webui.component.ListHead in project adempiere by adempiere.
the class WListItemRendererTest method testRenderListHead.
/**
* Test method for {@link org.adempiere.webui.component.WListItemRenderer#renderListHead(org.adempiere.webui.component.ListHead)}.
*/
@Test
public final void testRenderListHead() {
ListHead head = new ListHead();
Object header;
m_renderer.renderListHead(head);
assertEquals(2, head.getChildren().size());
header = head.getChildren().get(1);
assertTrue(header instanceof ListHeader);
assertEquals("Age", ((ListHeader) header).getLabel());
}
use of org.adempiere.webui.component.ListHead in project adempiere by adempiere.
the class WBrowserTable method initialiseHeader.
/**
* Create the listbox header by fetching it from the renderer and adding
* it to the Listbox.
*
*/
private void initialiseHeader() {
ListHead head = null;
head = super.getListHead();
//init only once
if (head != null) {
return;
}
head = new ListHead();
// render list head
if (this.getItemRenderer() instanceof WBrowserListItemRenderer) {
((WBrowserListItemRenderer) this.getItemRenderer()).renderListHead(head);
} else {
throw new ApplicationException("Rendering of the ListHead is unsupported for " + this.getItemRenderer().getClass().getSimpleName());
}
//attach the listhead
head.setParent(this);
return;
}
Aggregations