Example usage for com.vaadin.server PaintTarget addAttribute

List of usage examples for com.vaadin.server PaintTarget addAttribute

Introduction

In this page you can find the example usage for com.vaadin.server PaintTarget addAttribute.

Prototype

public void addAttribute(String string, Object[] keys);

Source Link

Usage

From source file:org.vaadin.tltv.multiscrolltable.ui.CustomScrollTable.java

License:Apache License

private void paintColumn(PaintTarget target, Column c, int index) throws PaintException {
    target.startTag(TAG_COLUMN);//w w  w .  jav  a 2s  .  c om
    target.addAttribute(ATTR_PID, columnIdMap.key(c.getColumnId()));
    target.addAttribute(ATTR_INDEX, index);
    target.addAttribute(ATTR_CAPTION, defaultString(c.getCaption()));
    target.addAttribute(ATTR_READONLY, c.isReadonly() || isReadOnly());
    // TODO

    target.endTag(TAG_COLUMN);
}

From source file:org.vaadin.tltv.multiscrolltable.ui.CustomScrollTable.java

License:Apache License

private void paintRows(PaintTarget target, Object[][] cells, int cols) throws PaintException {
    int index = 0;
    // Add rows and cell values to the UIDL
    if (cells != null && cols > 0) {
        target.startTag(TAG_ROWS);//from  www  . j a  va 2 s  .  c o m
        if (rowStructureChanged) {
            target.addAttribute(ATTR_ROW_STRUCTURE_CHANGED, true);
        } else if (rowsChanged) {
            target.addAttribute(ATTR_ROWS_CHANGED, true);
        }

        int size = size();
        int end = cells[0].length;
        if (end > size) {
            end = size;
        }
        String v;
        for (int i = 0; i < end; i++) {
            index = (Integer) cells[0][i];

            target.startTag(TAG_TR);
            target.addAttribute(ATTR_INDEX, index);
            Object itemId = ((Indexed) datasource).getIdByIndex(index);

            String rowHeader = getRowHeaderByIndex(index);
            if (rowHeader != null) {
                target.addAttribute(ATTR_CAPTION, rowHeader);
            }
            String rowDescription = getRowDescriptionByIndex(index);
            if (rowDescription != null && rowDescription.length() > 0) {
                target.addAttribute(ATTR_DESCRIPTION, rowDescription);
            }

            target.addAttribute(ATTR_DEPTH,
                    getContainerStrategy().getDepth(((Indexed) datasource).getIdByIndex(index)));

            if (getContainerDataSource().areChildrenAllowed(itemId)) {
                target.addAttribute(ATTR_CHILDRENS_ALLOWED, true);
                target.addAttribute(ATTR_OPEN, getContainerStrategy().isNodeOpen(itemId));
            }

            for (int j = 1; j < (cols + 1); j++) {
                v = (String) cells[j][i];
                if (v == null) {
                    v = "";
                }
                target.startTag(TAG_VALUE);
                target.addText(v);
                target.endTag(TAG_VALUE);
            }

            target.endTag(TAG_TR);
        }
        target.endTag(TAG_ROWS);
    }
    rowStructureChanged = false;
    rowsChanged = false;
}