use of org.zkoss.zul.Listcell in project adempiere by adempiere.
the class GridTabListItemRenderer method render.
/**
* @param listitem
* @param data
* @see ListitemRenderer#render(Listitem, Object)
*/
public void render(Listitem listitem, Object data, int arg2) throws Exception {
//don't render if not visible
for (Component c = listitem.getParent(); c != null; c = c.getParent()) {
if (!c.isVisible())
return;
}
Object[] values = (Object[]) data;
int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields();
for (int i = 0; i < columnCount; i++) {
if (!(gridField[i].isDisplayed() && gridField[i].isDisplayedGrid())) {
continue;
}
if (editors.get(gridField[i]) == null)
editors.put(gridField[i], WebEditorFactory.getEditor(gridField[i], true));
int rowIndex = listitem.getIndex();
if (paging != null && paging.getPageSize() > 0) {
rowIndex = (paging.getActivePage() * paging.getPageSize()) + rowIndex;
}
Listcell cell = null;
if (rowIndex == gridTab.getCurrentRow() && gridField[i].isEditable(true)) {
cell = getEditorCell(gridField[i], values[i], i);
cell.setParent(listitem);
} else {
if (gridField[i].getDisplayType() == DisplayType.YesNo) {
cell = new Listcell("", null);
cell.setParent(listitem);
cell.setStyle("text-align:center");
createReadonlyCheckbox(values[i], cell);
} else {
String text = getDisplayText(values[i], i);
String display = text;
if (text != null && text.length() > MAX_TEXT_LENGTH)
display = text.substring(0, MAX_TEXT_LENGTH - 3) + "...";
cell = new Listcell(display, null);
cell.setParent(listitem);
if (text != null && text.length() > MAX_TEXT_LENGTH)
cell.setTooltiptext(text);
if (DisplayType.isNumeric(gridField[i].getDisplayType())) {
cell.setStyle("text-align:right");
} else if (gridField[i].getDisplayType() == DisplayType.Image) {
cell.setStyle("text-align:center");
}
}
}
CellListener listener = new CellListener((Listbox) listitem.getParent());
cell.addEventListener(Events.ON_DOUBLE_CLICK, listener);
}
}
use of org.zkoss.zul.Listcell in project adempiere by adempiere.
the class GridTabListItemRenderer method stopEditing.
/**
* Detach all editor and optionally set the current value of the editor as cell label.
* @param updateCellLabel
*/
public void stopEditing(boolean updateCellLabel) {
for (Entry<GridField, WEditor> entry : editors.entrySet()) {
if (entry.getValue().getComponent().getParent() != null) {
if (updateCellLabel) {
Listcell cell = (Listcell) entry.getValue().getComponent().getParent();
if (entry.getKey().getDisplayType() == DisplayType.YesNo) {
cell.setLabel("");
createReadonlyCheckbox(entry.getValue().getValue(), cell);
} else {
cell.setLabel(getDisplayText(entry.getValue().getValue(), getColumnIndex(entry.getKey())));
}
}
entry.getValue().getComponent().detach();
entry.getKey().removePropertyChangeListener(entry.getValue());
entry.getValue().removeValuechangeListener(dataBinder);
}
}
}
use of org.zkoss.zul.Listcell in project adempiere by adempiere.
the class WBrowserListItemRenderer method render.
/**
* Render Item
* @param item
* @param data
*/
private void render(ListItem item, Object data) {
Listcell listcell = null;
int colIndex = 0;
int rowIndex = item.getIndex();
WBrowserTable table = null;
if (item.getListbox() instanceof WBrowserTable) {
table = (WBrowserTable) item.getListbox();
}
if (!(data instanceof List)) {
throw new IllegalArgumentException("A model element was not a list");
}
if (listBox == null || listBox != item.getListbox()) {
listBox = item.getListbox();
}
if (cellListener == null) {
cellListener = new CellListener();
}
for (Object field : (List<?>) data) {
listcell = getCellComponent(table, field, rowIndex, colIndex);
listcell.setParent(item);
listcell.addEventListener(Events.ON_DOUBLE_CLICK, cellListener);
colIndex++;
}
return;
}
use of org.zkoss.zul.Listcell in project adempiere by adempiere.
the class WBrowserListItemRenderer method getColumnPosition.
/**
* Get the column index of the given <code>source</code> component.
*
* @param source The component for which the column index is to be found.
* @return The column index of the given component.
*/
protected int getColumnPosition(Component source) {
Listcell cell;
int col = -1;
cell = findListcell(source);
col = cell.getColumnIndex();
return col;
}
use of org.zkoss.zul.Listcell in project adempiere by adempiere.
the class ADTabListModel method render.
public void render(Listitem item, Object data) throws Exception {
ADTabLabel tabLabel = (ADTabLabel) data;
Listcell cell = new Listcell(tabLabel.label, null);
if (tabLabel.tabLevel > 0) {
cell.setStyle("padding-left:" + (tabLabel.tabLevel * 15 + 5) + "px");
}
cell.setParent(item);
int i = listItems.indexOf(tabLabel);
int s = tabbox.getSelectedIndex();
if (!tabbox.canNavigateTo(s, i))
cell.setVisible(false);
}
Aggregations