Example usage for com.vaadin.server PaintTarget endTag

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

Introduction

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

Prototype

public void endTag(String tagName) throws PaintException;

Source Link

Document

Prints element end tag.

Usage

From source file:annis.gui.widgets.grid.AnnotationGrid.java

License:Apache License

@Override
public void paintContent(PaintTarget target) throws PaintException {

    target.addAttribute("escapeHTML", escapeHTML);

    if (rowsByAnnotation != null) {
        target.startTag("rows");
        for (Map.Entry<String, ArrayList<Row>> anno : rowsByAnnotation.entrySet()) {

            for (Row row : anno.getValue()) {
                target.startTag("row");
                target.addAttribute("caption", anno.getKey());
                target.addAttribute("show-caption", showCaption);
                target.addAttribute("show-namespace", showNamespaceForAnno(anno.getKey()));

                ArrayList<GridEvent> rowEvents = row.getEvents();
                // sort the events by their natural order
                Collections.sort(rowEvents, new Comparator<GridEvent>() {
                    @Override//from   w w w  .j  ava  2s  .  c o  m
                    public int compare(GridEvent o1, GridEvent o2) {
                        return ((Integer) o1.getLeft()).compareTo(o2.getLeft());
                    }
                });

                target.startTag("events");
                for (GridEvent event : rowEvents) {
                    target.startTag("event");
                    target.addAttribute("id", event.getId());
                    target.addAttribute("left", event.getLeft() - tokenIndexOffset);
                    target.addAttribute("right", event.getRight() - tokenIndexOffset);
                    target.addAttribute("value", event.getValue());

                    if (event.getTooltip() != null) {
                        target.addAttribute("tooltip", event.getTooltip());
                    }

                    if (event.getStartTime() != null) {
                        target.addAttribute("startTime", event.getStartTime());
                        if (event.getEndTime() != null) {
                            target.addAttribute("endTime", event.getEndTime());
                        }
                    }

                    if (event.getPageNumber() != null) {
                        target.addAttribute("openPDF", event.getPageNumber());
                    }

                    ArrayList<String> styles = getStyles(event, anno.getKey());
                    if (styles.size() > 0) {
                        target.addAttribute("style", styles.toArray());
                    }

                    // define a list of covered token that are hightlighted whenever this
                    // event is hovered
                    target.addAttribute("highlight", event.getCoveredIDs().toArray());

                    target.endTag("event");
                }
                target.endTag("events");

                target.endTag("row");
            }
        }
        target.endTag("rows");
    }

}

From source file:annis.gui.widgets.SimpleCanvas.java

License:Apache License

@Override
public void paintContent(PaintTarget target) throws PaintException {
    target.startTag("clear");
    target.endTag("clear");

    for (Line2D l : lines) {
        target.startTag("line");
        target.addAttribute("from_x", l.getX1());
        target.addAttribute("from_y", l.getY1());
        target.addAttribute("to_x", l.getX2());
        target.addAttribute("to_y", l.getY2());
        target.endTag("line");
    }//from  w w w . j ava  2  s .c  o  m
}

From source file:com.haulmont.cuba.web.toolkit.ui.CubaTable.java

License:Apache License

protected void paintAggregationRow(PaintTarget target, Map<Object, Object> aggregations) throws PaintException {
    target.startTag("arow");
    for (final Object columnId : visibleColumns) {
        if (columnId == null || isColumnCollapsed(columnId)) {
            continue;
        }/*from w  w w . j av a2s.co  m*/

        if (getCellStyleGenerator() != null) {
            String cellStyle = getCellStyleGenerator().getStyle(this, null, columnId);
            if (cellStyle != null && !cellStyle.equals("")) {
                target.addAttribute("style-" + columnIdMap.key(columnId), cellStyle + "-ag");
            }
        }

        String value = (String) aggregations.get(columnId);
        target.addText(value);
    }
    target.endTag("arow");
}

From source file:com.haulmont.cuba.web.widgets.addons.contextmenu.MenuBar.java

License:Apache License

/** Paint (serialise) the component for the client. */
@Override/*www .  ja v  a 2 s  .c  o m*/
public void paintContent(PaintTarget target) throws PaintException {
    target.addAttribute(MenuBarConstants.OPEN_ROOT_MENU_ON_HOWER, openRootOnHover);

    if (isHtmlContentAllowed()) {
        target.addAttribute(MenuBarConstants.HTML_CONTENT_ALLOWED, true);
    }

    target.startTag("options");

    if (getWidth() > -1) {
        target.startTag("moreItem");
        target.addAttribute("text", moreItem.getText());
        if (moreItem.getIcon() != null) {
            target.addAttribute("icon", moreItem.getIcon());
        }
        target.endTag("moreItem");
    }

    target.endTag("options");
    target.startTag("items");

    // This generates the tree from the contents of the menu
    for (MenuItem item : getItems()) {
        paintItem(target, item);
    }

    target.endTag("items");
}

From source file:com.haulmont.cuba.web.widgets.addons.contextmenu.MenuBar.java

License:Apache License

private void paintItem(PaintTarget target, MenuItem item) throws PaintException {
    if (!item.isVisible()) {
        return;/* w w w  .j  ava 2s .  co  m*/
    }

    target.startTag("item");

    target.addAttribute("id", item.getId());

    if (item.getStyleName() != null) {
        target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_STYLE, item.getStyleName());
    }

    if (item.isSeparator()) {
        target.addAttribute("separator", true);
    } else {
        target.addAttribute("text", item.getText());

        Command command = item.getCommand();
        if (command != null) {
            target.addAttribute("command", true);
        }

        Resource icon = item.getIcon();
        if (icon != null) {
            target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_ICON, icon);
        }

        if (!item.isEnabled()) {
            target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DISABLED, true);
        }

        String description = item.getDescription();
        if (description != null && description.length() > 0) {
            target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION, description);
        }
        if (item.isCheckable()) {
            // if the "checked" attribute is present (either true or false),
            // the item is checkable
            target.addAttribute(MenuBarConstants.ATTRIBUTE_CHECKED, item.isChecked());
        }
        if (item.hasChildren()) {
            for (MenuItem child : item.getChildren()) {
                paintItem(target, child);
            }
        }

    }

    target.endTag("item");
}

From source file:com.haulmont.cuba.web.widgets.CubaTable.java

License:Apache License

protected void paintAggregationRow(PaintTarget target, Map<Object, Object> aggregations) throws PaintException {
    target.startTag("arow");
    for (final Object columnId : _visibleColumns()) {
        if (columnId == null || isColumnCollapsed(columnId)) {
            continue;
        }/*from  ww w  . j  a  v a2  s  .  com*/

        if (getCellStyleGenerator() != null) {
            String cellStyle = getCellStyleGenerator().getStyle(this, null, columnId);
            if (cellStyle != null && !cellStyle.equals("")) {
                target.addAttribute("style-" + _columnIdMap().key(columnId), cellStyle + "-ag");
            }
        }

        String value = (String) aggregations.get(columnId);
        target.addText(value);
    }
    target.endTag("arow");
}

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

License:Apache License

private void paintColumns(PaintTarget target) throws PaintException {
    target.startTag(TAG_COLUMNS);//from   ww  w . j av  a2s  .c  o  m
    if (columnStructureChanged) {
        target.addAttribute(ATTR_COLUMN_STRUCTURE_CHANGED, true);
    }
    int index = 0;

    // Paint all scroll contents
    for (ScrollContent sc : scrollContents) {
        target.startTag(TAG_SCROLLCONTENT);

        // Paint scroll content's column groups
        for (ColumnGroup cg : sc.getColumnGroups()) {
            index = paintColumnGroup(target, cg, index);
        }
        target.endTag(TAG_SCROLLCONTENT);
    }
    target.endTag(TAG_COLUMNS);
    columnStructureChanged = false;
}

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

License:Apache License

private int paintColumnGroup(PaintTarget target, ColumnGroup cg, int index) throws PaintException {
    target.startTag(TAG_COLUMNGROUP);//from  www. j  a  v a 2  s .  c  o m
    target.addAttribute(ATTR_CAPTION, defaultString(cg.getCaption()));

    if (cg instanceof HierarchicalColumnGroup) {
        // Paint column group's hierarchical structure
        for (ColumnGroup subCg : ((HierarchicalColumnGroup) cg).getSubColumnGroups()) {
            index = paintColumnGroup(target, subCg, index);
        }
    } else {
        // Paint column group's columns
        for (Column c : cg.getColumns()) {
            paintColumn(target, c, index++);
        }
    }
    target.endTag(TAG_COLUMNGROUP);

    return index;
}

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.j  a  v a  2  s. com*/
    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 v  a2  s.  com
        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;
}