Search in sources :

Example 1 with Listcell

use of org.zkoss.zul.Listcell in project adempiere by adempiere.

the class WBrowserListItemRenderer method getRowPosition.

/**
	 * Get the row index of the given <code>source</code> component.
	 *
	 * @param source	The component for which the row index is to be found.
	 * @return The row index of the given component.
	 */
protected int getRowPosition(Component source) {
    Listcell cell;
    ListItem item;
    int row = -1;
    cell = findListcell(source);
    item = (ListItem) cell.getParent();
    row = item.getIndex();
    return row;
}
Also used : Listcell(org.zkoss.zul.Listcell) ListItem(org.adempiere.webui.component.ListItem)

Example 2 with Listcell

use of org.zkoss.zul.Listcell in project adempiere by adempiere.

the class GridTabListItemRenderer method getEditorCell.

private Listcell getEditorCell(GridField gridField, Object object, int i) {
    Listcell cell = new Listcell("", null);
    WEditor editor = editors.get(gridField);
    if (editor != null) {
        if (editor instanceof WButtonEditor) {
            Object window = SessionManager.getAppDesktop().findWindow(windowNo);
            if (window != null && window instanceof ADWindow) {
                AbstractADWindowPanel windowPanel = ((ADWindow) window).getADWindowPanel();
                ((WButtonEditor) editor).addActionListener(windowPanel);
            }
        } else {
            editor.addValueChangeListener(dataBinder);
        }
        cell.appendChild(editor.getComponent());
        if (editor.getComponent() instanceof Checkbox || editor.getComponent() instanceof Image) {
            cell.setStyle("text-align:center");
        } else if (DisplayType.isNumeric(gridField.getDisplayType())) {
            cell.setStyle("text-align:right");
        }
        gridField.addPropertyChangeListener(editor);
        editor.setValue(gridField.getValue());
        WEditorPopupMenu popupMenu = editor.getPopupMenu();
        if (popupMenu != null) {
            popupMenu.addMenuListener((ContextMenuListener) editor);
            cell.appendChild(popupMenu);
        }
        //streach component to fill grid cell
        editor.fillHorizontal();
    }
    return cell;
}
Also used : WButtonEditor(org.adempiere.webui.editor.WButtonEditor) Listcell(org.zkoss.zul.Listcell) ADWindow(org.adempiere.webui.window.ADWindow) AbstractADWindowPanel(org.adempiere.webui.panel.AbstractADWindowPanel) WEditor(org.adempiere.webui.editor.WEditor) Image(org.zkoss.zul.Image) WEditorPopupMenu(org.adempiere.webui.editor.WEditorPopupMenu)

Example 3 with Listcell

use of org.zkoss.zul.Listcell in project adempiere by adempiere.

the class WListItemRenderer 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 4 with Listcell

use of org.zkoss.zul.Listcell in project adempiere by adempiere.

the class WListItemRenderer method getRowPosition.

/**
	 * Get the row index of the given <code>source</code> component.
	 *
	 * @param source	The component for which the row index is to be found.
	 * @return The row index of the given component.
	 */
protected int getRowPosition(Component source) {
    Listcell cell;
    ListItem item;
    int row = -1;
    cell = findListcell(source);
    item = (ListItem) cell.getParent();
    row = item.getIndex();
    return row;
}
Also used : Listcell(org.zkoss.zul.Listcell)

Example 5 with Listcell

use of org.zkoss.zul.Listcell in project adempiere by adempiere.

the class WListItemRenderer method render.

/**
	 * Renders the <code>data</code> to the specified <code>Listitem</code>.
	 *
	 * @param item 	the listitem to render the result.
	 * 				Note: when this method is called, the listitem has no child
	 * 				at all.
	 * @param data 	that is returned from {@link ListModel#getElementAt}
	 * @throws Exception
	 * @see {@link #render(Listitem, Object)}
	 */
private void render(ListItem item, Object data) {
    Listcell listcell = null;
    int colIndex = 0;
    int rowIndex = item.getIndex();
    WListbox table = null;
    if (item.getListbox() instanceof WListbox) {
        table = (WListbox) item.getListbox();
    }
    int colorCode = 0;
    if (table != null) {
        colorCode = table.getColorCode(rowIndex);
        if (colorCode < 0) {
            //  Color the row.
            //  TODO: do this with a class and CSS
            item.setStyle("color: #FF0000; " + item.getStyle());
        }
    }
    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);
        listcell.setAttribute("zk_component_ID", "ListItem_R" + rowIndex + "_C" + colIndex);
        colIndex++;
    }
    return;
}
Also used : Listcell(org.zkoss.zul.Listcell) ArrayList(java.util.ArrayList) List(java.util.List)

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