Search in sources :

Example 6 with Listcell

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);
    }
}
Also used : Listcell(org.zkoss.zul.Listcell) GridField(org.compiere.model.GridField) Component(org.zkoss.zk.ui.Component)

Example 7 with Listcell

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);
        }
    }
}
Also used : Listcell(org.zkoss.zul.Listcell) GridField(org.compiere.model.GridField) WEditor(org.adempiere.webui.editor.WEditor)

Example 8 with Listcell

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;
}
Also used : Listcell(org.zkoss.zul.Listcell) List(java.util.List) ArrayList(java.util.ArrayList)

Example 9 with Listcell

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;
}
Also used : Listcell(org.zkoss.zul.Listcell)

Example 10 with Listcell

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);
}
Also used : Listcell(org.zkoss.zul.Listcell)

Aggregations

Listcell (org.zkoss.zul.Listcell)10 ArrayList (java.util.ArrayList)2 List (java.util.List)2 WEditor (org.adempiere.webui.editor.WEditor)2 GridField (org.compiere.model.GridField)2 ListItem (org.adempiere.webui.component.ListItem)1 WButtonEditor (org.adempiere.webui.editor.WButtonEditor)1 WEditorPopupMenu (org.adempiere.webui.editor.WEditorPopupMenu)1 AbstractADWindowPanel (org.adempiere.webui.panel.AbstractADWindowPanel)1 ADWindow (org.adempiere.webui.window.ADWindow)1 Component (org.zkoss.zk.ui.Component)1 Image (org.zkoss.zul.Image)1