List of usage examples for com.vaadin.client UIDL getStringAttribute
public String getStringAttribute(String name)
From source file:annis.gui.widgets.gwt.client.ui.VAnnotationGrid.java
License:Apache License
private void addRow(UIDL row, int rowNumber) { String caption = row.getStringAttribute("caption"); boolean showNamespace = row.getBooleanAttribute("show-namespace"); String name;// w ww.j a v a 2 s .c o m if (showNamespace) { name = caption; } else { String[] captionSplit = caption.split("::"); name = captionSplit[captionSplit.length - 1]; } boolean showCaption = row.getBooleanAttribute("show-caption"); int startColumn = 0; if (showCaption) { table.setHTML(rowNumber, 0, Util.escapeHTML(name)); formatter.addStyleName(rowNumber, 0, "header"); startColumn = 1; } int colspanOffset = 0; UIDL events = row.getChildByTagName("events"); for (int j = 0; j < events.getChildCount(); j++) { UIDL event = events.getChildUIDL(j); String id = event.getStringAttribute("id"); int left = event.getIntAttribute("left"); int right = event.getIntAttribute("right"); String value = event.getStringAttribute("value"); if (escapeHTML) { value = Util.escapeHTML(value); } // +1 because we also have a caption column, subtract columns we // jumped over by using colspan int col = left + startColumn - colspanOffset; table.setHTML(rowNumber, col, value); if (event.hasAttribute("tooltip")) { Element tdElement = table.getCellFormatter().getElement(rowNumber, col); tdElement.setTitle(event.getStringAttribute("tooltip")); } position2id.put(new Position(rowNumber, col), id); int colspan = right - left + 1; formatter.setColSpan(rowNumber, col, colspan); if (colspan > 1) { colspanOffset += (colspan - 1); } addStyleForEvent(event, rowNumber, col); } }
From source file:annis.gui.widgets.gwt.client.ui.VAnnotationGrid.java
License:Apache License
private void addStyleForEvent(UIDL event, int rowNumber, int col) { String id = event.getStringAttribute("id"); // style given by the server component if (event.hasAttribute("style")) { String[] styles = event.getStringArrayAttribute("style"); for (String s : styles) { formatter.addStyleName(rowNumber, col, s); }//from w w w .ja v a 2s . c om } else { formatter.addStyleName(rowNumber, col, "single_event"); } // fill highlight map if (event.hasAttribute("highlight")) { highlighted.put(id, event.getStringArrayAttribute("highlight")); } if (event.hasAttribute("startTime")) { formatter.addStyleName(rowNumber, col, "speaker"); startTimes.put(new Position(rowNumber, col), event.getDoubleAttribute("startTime")); if (event.hasAttribute("endTime")) { endTimes.put(new Position(rowNumber, col), event.getDoubleAttribute("endTime")); } } if (event.hasAttribute("openPDF")) { String number = event.getStringAttribute("openPDF"); formatter.addStyleName(rowNumber, col, "pdf"); pdfPageNumbers.put(new Position(rowNumber, col), number); } }
From source file:annis.gui.widgets.gwt.client.ui.VJITWrapper.java
License:Apache License
@Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { // This call should be made first. // It handles sizes, captions, tooltips, etc. automatically. if (client.updateComponent(this, uidl, true)) { // If client.updateComponent returns true there has been no changes and we // do not need to update anything. return;//from ww w. j a v a 2s .c o m } if (uidl.hasAttribute("visData")) { jsonData = parseStringToJSON(uidl.getStringAttribute("visData")); // setup config for visualization if (uidl.hasAttribute("mappings")) { setupConfig(uidl.getMapAttribute("mappings")); } else { setupConfig(); } if (visualization == null) { visualization = visualizationInit(config.getJavaScriptObject()); } if (jsonData != null) { visualization.render(); } else { GWT.log("jsonData are null"); } } }
From source file:annis.gui.widgets.gwt.client.ui.VMediaPlayerBase.java
License:Apache License
@Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { if (client.updateComponent(this, uidl, true)) { return;//from w ww. jav a 2s . c om } // Save reference to server connection object to be able to send // user interaction later this.gClient = client; // Save the client side identifier (paintable id) for the widget paintableId = uidl.getId(); if (media == null) { VConsole.error("media not set!!!"); return; } if (uidl.hasAttribute(SOURCE_URL)) { registerMetadataLoadedEvent(media); if (uidl.hasAttribute(MIME_TYPE)) { String mimeType = uidl.getStringAttribute(MIME_TYPE); VConsole.log( "canPlayType for \"" + mimeType + "\"value is \"" + media.canPlayType(mimeType) + "\""); // check for correct mime type if (media.canPlayType(uidl.getStringAttribute(MIME_TYPE)).equals(MediaElement.CANNOT_PLAY)) { VConsole.log("CANNOT PLAY!!!"); gClient.updateVariable(paintableId, CANNOT_PLAY, true, true); } else if (media.canPlayType(uidl.getStringAttribute(MIME_TYPE)) .equals(MediaElement.CAN_PLAY_MAYBE)) { gClient.updateVariable(paintableId, MIGHT_NOT_PLAY, true, true); } } media.setSrc(uidl.getStringAttribute(SOURCE_URL)); } if (uidl.hasAttribute(PLAY)) { String[] time = uidl.getStringArrayAttribute(PLAY); if (time != null && time.length > 0) { if (time.length == 1) { try { media.setCurrentTime(Double.parseDouble(time[0])); } catch (NumberFormatException ex) { VConsole.error(ex); } } else if (time.length == 2) { try { media.setCurrentTime(Double.parseDouble(time[0])); setEndTimeOnce(media, Double.parseDouble(time[1])); } catch (NumberFormatException ex) { VConsole.error(ex); } } media.play(); } } else if (uidl.hasAttribute(PAUSE)) { media.pause(); } else if (uidl.hasAttribute(STOP)) { media.pause(); media.setSrc(""); } }
From source file:com.eternach.client.RichOptionGroupWidget.java
License:Apache License
@Override public void buildOptions(final UIDL uidl) { panel.clear();/*from w w w.ja va 2 s. c o m*/ optionsEnabled.clear(); for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) { boolean iconDisplayed = false; final UIDL opUidl = (UIDL) it.next(); CheckBox op; String itemHtml = opUidl.getStringAttribute("caption"); if (!htmlContentAllowed) { itemHtml = Util.escapeHTML(itemHtml); } final String icon = opUidl.getStringAttribute("icon"); if (icon != null && icon.length() != 0) { final String iconUrl = client.translateVaadinUri(icon); itemHtml = "<span style=\"white-space: normal;\">" + itemHtml + "</span><br/><img src=\"" + iconUrl + "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />"; iconDisplayed = true; } if (isMultiselect()) { op = new VCheckBox(); } else { op = new RadioButton(paintableId, null, true); op.setStyleName("v-radiobutton"); } op.addStyleName(CLASSNAME_OPTION); op.setValue(opUidl.getBooleanAttribute("selected")); final boolean optionEnabled = !opUidl .getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED); final boolean enabled = optionEnabled && !isReadonly() && isEnabled(); op.setEnabled(enabled); optionsEnabled.add(optionEnabled); setStyleName(op.getElement(), ApplicationConnection.DISABLED_CLASSNAME, !(optionEnabled && isEnabled())); op.addClickHandler(this); optionsToKeys.put(op, opUidl.getStringAttribute("key")); String description = opUidl.getStringAttribute("description-text"); if (description == null) { description = ""; } if (opUidl.getStringAttribute("description-icon") != null) { description += "<br/><img src=\"" + client.translateVaadinUri(opUidl.getStringAttribute("description-icon")) + "\"\\>"; } final FocusableFlexTable table = new FocusableFlexTable(); table.setWidget(0, 0, op); table.setHTML(0, 1, itemHtml); table.setCellPadding(0); table.setCellSpacing(0); panel.add(table); if (description != null && description.length() != 0) { elementsToDescription.put(table.getElement(), description); } if (iconDisplayed) { Util.sinkOnloadForImages(table.getElement()); table.addHandler(iconLoadHandler, LoadEvent.getType()); } } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.aggregation.TableAggregationRow.java
License:Apache License
protected void addCellsFromUIDL(UIDL uidl) { int colIndex = 0; final Iterator cells = uidl.getChildIterator(); while (cells.hasNext() && colIndex < tableWidget.getVisibleColOrder().length) { String columnId = tableWidget.getVisibleColOrder()[colIndex]; if (addSpecificCell(columnId, colIndex)) { colIndex++;//w w w . ja v a 2s . co m continue; } final Object cell = cells.next(); String style = ""; if (uidl.hasAttribute("style-" + columnId)) { style = uidl.getStringAttribute("style-" + columnId); } boolean sorted = tableWidget.getHead().getHeaderCell(colIndex).isSorted(); if (cell instanceof String) { addCell((String) cell, aligns[colIndex], style, sorted); } final String colKey = tableWidget.getColKeyByIndex(colIndex); int colWidth; if ((colWidth = tableWidget.getColWidth(colKey)) > -1) { tableWidget.setColWidth(colIndex, colWidth, false); } colIndex++; } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.menubar.CubaMenuBarConnector.java
License:Apache License
@Override protected String getItemId(UIDL uidl) { if (uidl.hasAttribute("tid")) { return uidl.getStringAttribute("tid"); }/* w w w . ja v a2 s .c o m*/ return null; }
From source file:com.haulmont.cuba.web.toolkit.ui.client.menubar.CubaMenuBarConnector.java
License:Apache License
@Override protected void assignAdditionalAttributes(VMenuBar.CustomMenuItem currentItem, UIDL item) { if (item.hasAttribute("cid")) { currentItem.getElement().setAttribute("cuba-id", item.getStringAttribute("cid")); }/*ww w.j a va 2 s .com*/ }
From source file:com.haulmont.cuba.web.toolkit.ui.client.menubar.CubaMenuBarConnector.java
License:Apache License
@Override protected void assignAdditionalMenuStyles(VMenuBar currentMenu, UIDL item) { String icon = item.getStringAttribute("icon"); if (icon != null) { currentMenu.addStyleDependentName("has-icons"); }/*from w w w . ja v a2s. c o m*/ }
From source file:com.haulmont.cuba.web.toolkit.ui.client.menubar.CubaMenuBarWidget.java
License:Apache License
@Override public String buildItemHTML(UIDL item) { // Construct html from the text and the optional icon // Haulmont API : Added support for shortcuts StringBuilder itemHTML = new StringBuilder(); if (item.hasAttribute("separator")) { itemHTML.append("<span>---</span><span>---</span>"); } else {// w ww. ja v a 2 s .c om itemHTML.append("<span class=\"").append(getStylePrimaryName()).append("-menuitem-caption\">"); Icon icon = client.getIcon(item.getStringAttribute("icon")); if (icon != null) { itemHTML.append(icon.getElement().getString()); } String itemText = item.getStringAttribute("text"); if (!htmlContentAllowed) { itemText = WidgetUtil.escapeHTML(itemText); } itemHTML.append(itemText); itemHTML.append("</span>"); // Add submenu indicator if (item.getChildCount() > 0) { String bgStyle = ""; itemHTML.append("<span class=\"").append(getStylePrimaryName()).append("-submenu-indicator\"") .append(bgStyle).append("><span class=\"").append(getStylePrimaryName()) .append("-submenu-indicator-icon\"") .append("><span class=\"text\">►</span></span></span>"); } else { itemHTML.append("<span class=\""); String shortcut = ""; if (item.hasAttribute("shortcut")) { shortcut = item.getStringAttribute("shortcut"); } else { itemHTML.append(getStylePrimaryName()).append("-menuitem-empty-shortcut "); } itemHTML.append(getStylePrimaryName()).append("-menuitem-shortcut\">").append(shortcut) .append("</span"); } } return itemHTML.toString(); }