List of usage examples for com.vaadin.server PaintTarget addAttribute
public void addAttribute(String string, Object[] keys);
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 ww w.j a va 2 s . 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.JITWrapper.java
License:Apache License
@Override public void paintContent(PaintTarget target) throws PaintException { target.addAttribute("visData", visData); if (mappings.size() > 0) { target.addAttribute("mappings", mappings); }//from w w w .j a v a 2 s. com }
From source file:annis.gui.widgets.MediaPlayerBase.java
License:Apache License
@Override public void paintContent(PaintTarget target) throws PaintException { if (target.isFullRepaint()) { sourcesAdded = false;// ww w . j ava 2s . c o m wasLoaded = false; } boolean sourcesNeeded = true; if (action == PlayerAction.play) { String[] args; if (endTime == null) { args = new String[] { "" + startTime }; } else { args = new String[] { "" + startTime, "" + endTime }; } target.addAttribute(VMediaPlayerBase.PLAY, args); action = PlayerAction.idle; } else if (action == PlayerAction.pause) { target.addAttribute(VMediaPlayerBase.PAUSE, true); action = PlayerAction.idle; } else if (action == PlayerAction.stop) { target.addAttribute(VMediaPlayerBase.STOP, true); action = PlayerAction.idle; // re-add source the next time someone wants to play something sourcesAdded = false; sourcesNeeded = false; } if (sourcesNeeded && !sourcesAdded) { target.addAttribute(VMediaPlayerBase.SOURCE_URL, resourceURL); target.addAttribute(VMediaPlayerBase.MIME_TYPE, mimeType); sourcesAdded = true; } }
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"); }// w w w .j a v a2 s. c o m }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaGroupTable.java
License:Apache License
@Override protected void paintRowAttributes(PaintTarget target, Object itemId) throws PaintException { super.paintRowAttributes(target, itemId); boolean hasAggregation = items instanceof AggregationContainer && isAggregatable() && !((AggregationContainer) items).getAggregationPropertyIds().isEmpty(); boolean hasGroups = hasGroups(); if (hasGroups) { if (isGroup(itemId)) { target.addAttribute("colKey", columnIdMap.key(getGroupProperty(itemId))); target.addAttribute("groupKey", groupIdMap.key(itemId)); if (isExpanded(itemId)) target.addAttribute("expanded", true); final Object propertyValue = getGroupPropertyValue(itemId); target.addAttribute("groupCaption", formatGroupPropertyValue(itemId, propertyValue)); if (hasAggregation) { paintGroupAggregation(target, itemId, ((AggregationContainer) items).aggregate(new GroupAggregationContext(this, itemId))); }//from w ww . jav a 2s. c o m } } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaGroupTable.java
License:Apache License
protected void paintGroupAggregation(PaintTarget target, Object groupId, Map<Object, Object> aggregations) throws PaintException { boolean paintGroupProperty = false; final Collection groupProperties = getGroupProperties(); final Object groupProperty = getGroupProperty(groupId); for (final Object columnId : visibleColumns) { if (columnId == null || isColumnCollapsed(columnId)) { continue; }/*from ww w . j av a 2s . c o m*/ if (groupProperties.contains(columnId) && !paintGroupProperty) { if (columnId.equals(groupProperty)) { paintGroupProperty = true; } continue; } 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); if (value != null) { target.addText(value); } else { target.addText(""); } } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaMenuBar.java
License:Apache License
@Override protected void paintAdditionalItemParams(PaintTarget target, MenuItem item) throws PaintException { if (shortcuts != null && shortcuts.containsKey(item)) { String shortcut = shortcuts.get(item); if (shortcut != null) { target.addAttribute("shortcut", shortcut); }/* w w w .j ava 2s .c o m*/ } if (testIds != null && testIds.containsKey(item)) { String testIdValue = testIds.get(item); if (testIdValue != null) { target.addAttribute("tid", testIdValue); } } if (cubaIds != null && cubaIds.containsKey(item)) { String idValue = cubaIds.get(item); if (idValue != null) { target.addAttribute("cid", idValue); } } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaTable.java
License:Apache License
@Override protected void paintAdditionalData(PaintTarget target) throws PaintException { if (reqFirstRowToPaint == -1) { boolean hasAggregation = items instanceof AggregationContainer && isAggregatable() && !((AggregationContainer) items).getAggregationPropertyIds().isEmpty(); if (hasAggregation && isShowTotalAggregation() && Table.AggregationStyle.TOP.equals(getAggregationStyle())) { Context context = new Context(getAggregationItemIds()); paintAggregationRow(target, ((AggregationContainer) items).aggregate(context)); }/*from w w w.j a va 2 s . c o m*/ } // paint cuba-ids AppUI current = AppUI.getCurrent(); if (current != null && current.isTestMode()) { ArrayList<String> visibleColOrder = new ArrayList<>(); for (Object columnId : visibleColumns) { if (!isColumnCollapsed(columnId)) { visibleColOrder.add(columnId.toString()); } } target.addAttribute("colcubaids", visibleColOrder.toArray()); } }
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; }/*w w w . j av a 2s . c o 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.toolkit.ui.CubaTree.java
License:Apache License
@Override public void paintContent(PaintTarget target) throws PaintException { if (beforePaintListener != null) { beforePaintListener.run();// w w w . j a v a 2 s . c o m } if (isNodeCaptionsAsHtml()) { target.addAttribute("nodeCaptionsAsHtml", true); } super.paintContent(target); }