Search in sources :

Example 11 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class GridTabRowRenderer method render.

/**
	 * @param row
	 * @param data
	 * @see RowRenderer#render(Row, Object)
	 */
public void render(Row row, Object[] data, int index) throws Exception {
    //don't render if not visible
    if (gridPanel != null && !gridPanel.isVisible()) {
        return;
    }
    if (grid == null)
        grid = (Grid) row.getParent().getParent();
    if (rowListener == null)
        rowListener = new RowListener((Grid) row.getParent().getParent());
    currentValues = data;
    int columnCount = gridTab.getTableModel().getColumnCount();
    GridField[] gridField = gridTab.getFields();
    Grid grid = (Grid) row.getParent().getParent();
    org.zkoss.zul.Columns columns = grid.getColumns();
    int rowIndex = row.getParent().getChildren().indexOf(row);
    if (paging != null && paging.getPageSize() > 0) {
        rowIndex = (paging.getActivePage() * paging.getPageSize()) + rowIndex;
    }
    int colIndex = -1;
    for (int i = 0; i < columnCount; i++) {
        if (!(gridField[i].isDisplayed())) {
            continue;
        }
        colIndex++;
        Div div = new Div();
        ThemeUtils.addSclass("ad-gridtabrowrenderer", div);
        org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
        if (column.isVisible()) {
            Component component = getDisplayComponent(currentValues[i], gridField[i]);
            div.appendChild(component);
            //				if (compCount == 1) {
            //add hidden input component to help focusing to row
            div.appendChild(createAnchorInput());
            if (DisplayType.YesNo == gridField[i].getDisplayType() || DisplayType.Image == gridField[i].getDisplayType()) {
                ThemeUtils.addSclass("yes-no", div);
            //divStyle += "text-align:center; ";
            } else if (DisplayType.isNumeric(gridField[i].getDisplayType())) {
                ThemeUtils.addSclass("numeric", div);
            //divStyle += "text-align:right; ";
            }
        }
        div.setAttribute("columnName", gridField[i].getColumnName());
        div.addEventListener(Events.ON_CLICK, rowListener);
        div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener);
        row.appendChild(div);
    }
    if (rowIndex == gridTab.getCurrentRow()) {
        setCurrentRow(row);
    }
    row.addEventListener(Events.ON_OK, rowListener);
}
Also used : Grid(org.zkoss.zul.Grid) GridField(org.compiere.model.GridField) Div(org.zkoss.zul.Div) Component(org.zkoss.zk.ui.Component) HtmlBasedComponent(org.zkoss.zk.ui.HtmlBasedComponent)

Example 12 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class Group method autoFirstCell.

private GroupHeader autoFirstCell() {
    Component cell = getFirstChild();
    if (cell == null || cell instanceof GroupHeader) {
        if (cell == null)
            cell = new GroupHeader();
        cell.applyProperties();
        cell.setParent(this);
        return (GroupHeader) cell;
    }
    throw new UiException("Unsupported child for setLabel: " + cell);
}
Also used : UiException(org.zkoss.zk.ui.UiException) Component(org.zkoss.zk.ui.Component)

Example 13 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class DrillCommand method service.

public boolean service(AuRequest request, boolean everError) {
    if (!DrillEvent.ON_DRILL_ACROSS.equals(request.getCommand()) && !DrillEvent.ON_DRILL_DOWN.equals(request.getCommand()))
        return false;
    final Map<?, ?> map = request.getData();
    JSONArray data = (JSONArray) map.get("data");
    final Component comp = request.getComponent();
    if (comp == null)
        throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this);
    if (data == null || data.size() < 2)
        throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] { Objects.toString(data), this });
    String columnName = (String) data.get(0);
    String tableName = MQuery.getZoomTableName(columnName);
    String code = (String) data.get(1);
    //
    MQuery query = new MQuery(tableName);
    query.addRestriction(columnName, MQuery.EQUAL, code);
    Events.postEvent(new DrillEvent(request.getCommand(), comp, query));
    return true;
}
Also used : JSONArray(org.zkoss.json.JSONArray) DrillEvent(org.adempiere.webui.event.DrillEvent) MQuery(org.compiere.model.MQuery) UiException(org.zkoss.zk.ui.UiException) Component(org.zkoss.zk.ui.Component)

Example 14 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class GridTabRowRenderer method getDisplayComponent.

private Component getDisplayComponent(Object value, GridField gridField) {
    Component component;
    if (gridField.getDisplayType() == DisplayType.YesNo) {
        component = createReadonlyCheckbox(value);
    } else {
        String text = getDisplayText(value, gridField);
        Label label = new Label();
        setLabelText(text, label);
        component = label;
    }
    return component;
}
Also used : Label(org.zkoss.zhtml.Label) Component(org.zkoss.zk.ui.Component) HtmlBasedComponent(org.zkoss.zk.ui.HtmlBasedComponent)

Example 15 with Component

use of org.zkoss.zk.ui.Component in project adempiere by adempiere.

the class GridPanel method focusToRow.

private void focusToRow(org.zkoss.zul.Row row) {
    if (renderer.isEditing()) {
        if (columnOnClick != null && columnOnClick.trim().length() > 0) {
            setFocusToField(columnOnClick);
            columnOnClick = null;
        } else {
            renderer.setFocusToEditor();
        }
    } else {
        Component cmp = null;
        List<?> childs = row.getChildren();
        for (Object o : childs) {
            Component c = (Component) o;
            if (!c.isVisible())
                continue;
            c = c.getFirstChild();
            if (c == null)
                continue;
            if (c.getNextSibling() != null) {
                cmp = c.getNextSibling();
                break;
            }
        }
        if (cmp != null)
            Clients.response(new AuScript(null, "scrollToRow('" + cmp.getUuid() + "');"));
        if (columnOnClick != null && columnOnClick.trim().length() > 0) {
            List<?> list = row.getChildren();
            for (Object element : list) {
                if (element instanceof Div) {
                    Div div = (Div) element;
                    if (columnOnClick.equals(div.getAttribute("columnName"))) {
                        cmp = div.getFirstChild().getNextSibling();
                        Clients.response(new AuScript(null, "scrollToRow('" + cmp.getUuid() + "');"));
                        break;
                    }
                }
            }
            columnOnClick = null;
        }
    }
}
Also used : Div(org.zkoss.zul.Div) AbstractComponent(org.zkoss.zk.ui.AbstractComponent) Component(org.zkoss.zk.ui.Component) HtmlBasedComponent(org.zkoss.zk.ui.HtmlBasedComponent) AuScript(org.zkoss.zk.au.out.AuScript)

Aggregations

Component (org.zkoss.zk.ui.Component)70 IOException (java.io.IOException)8 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)8 Checkbox (org.adempiere.webui.component.Checkbox)7 ToolBarButton (org.adempiere.webui.component.ToolBarButton)7 Div (org.zkoss.zul.Div)7 Listitem (org.zkoss.zul.Listitem)7 MapLayer (au.org.emii.portal.menu.MapLayer)6 Button (org.adempiere.webui.component.Button)6 Tabpanel (org.adempiere.webui.component.Tabpanel)6 WEditor (org.adempiere.webui.editor.WEditor)6 ParseException (org.json.simple.parser.ParseException)6 Event (org.zkoss.zk.ui.event.Event)6 MapComposer (au.org.emii.portal.composer.MapComposer)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 DashboardPanel (org.adempiere.webui.dashboard.DashboardPanel)5 HeaderPanel (org.adempiere.webui.panel.HeaderPanel)5 SidePanel (org.adempiere.webui.panel.SidePanel)5 UiException (org.zkoss.zk.ui.UiException)5