com.vaadin.client.ui.Icon Java Examples
The following examples show how to use
com.vaadin.client.ui.Icon.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
/** * Gets the visible row in the popup as a HTML string. The string * contains an image tag with the rows icon (if an icon has been * specified) and the caption of the item */ @Override public String getDisplayString() { final StringBuilder sb = new StringBuilder(); ApplicationConnection client = VComboBoxMultiselect.this.connector.getConnection(); final Icon icon = client.getIcon(client.translateVaadinUri(this.untranslatedIconUri)); if (icon != null) { sb.append(icon.getElement() .getString()); } String content; if ("".equals(this.caption)) { // Ensure that empty options use the same height as other // options and are not collapsed (#7506) content = " "; } else { content = WidgetUtil.escapeHTML(this.caption); } sb.append("<span>" + content + "</span>"); return sb.toString(); }
Example #2
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
/** * Gets the visible row in the popup as a HTML string. The string * contains an image tag with the rows icon (if an icon has been * specified) and the caption of the item */ @Override public String getDisplayString() { final StringBuilder sb = new StringBuilder(); ApplicationConnection client = VComboBoxMultiselect.this.connector.getConnection(); final Icon icon = client.getIcon(client.translateVaadinUri(this.untranslatedIconUri)); if (icon != null) { sb.append(icon.getElement() .getString()); } String content; if ("".equals(this.caption)) { // Ensure that empty options use the same height as other // options and are not collapsed (#7506) content = " "; } else { content = WidgetUtil.escapeHTML(this.caption); } sb.append("<span>" + content + "</span>"); return sb.toString(); }
Example #3
Source File: CubaIconRendererConnector.java From cuba with Apache License 2.0 | 5 votes |
@Override public Icon decode(JsonValue value) { URLReference reference = (URLReference) JsonDecoder.decodeValue( TypeDataStore.getType(URLReference.class), value, null, getConnection()); return reference != null ? getConnection().getIcon(reference.getURL()) : null; }
Example #4
Source File: CubaIconRenderer.java From cuba with Apache License 2.0 | 5 votes |
@Override public void render(RendererCellReference cell, Icon icon) { if (icon instanceof ImageIcon) { // onload will set appropriate size later icon.setWidth("0"); icon.setHeight("0"); } Element iconElement = icon.getElement(); cell.getElement().setInnerHTML(getOuterHtml(iconElement)); }
Example #5
Source File: VDragCaptionProvider.java From cuba with Apache License 2.0 | 5 votes |
public Element getDragCaptionElement(Widget w) { ComponentConnector component = Util.findConnectorFor(w); DDLayoutState state = ((DragAndDropAwareState) root.getState()).getDragAndDropState(); DragCaptionInfo dci = state.dragCaptions.get(component); Document document = Document.get(); Element dragCaptionImage = document.createDivElement(); Element dragCaption = document.createSpanElement(); String dragCaptionText = dci.caption; if (dragCaptionText != null) { if (dci.contentMode == ContentMode.TEXT) { dragCaption.setInnerText(dragCaptionText); } else if (dci.contentMode == ContentMode.HTML) { dragCaption.setInnerHTML(dragCaptionText); } else if (dci.contentMode == ContentMode.PREFORMATTED) { PreElement preElement = document.createPreElement(); preElement.setInnerText(dragCaptionText); dragCaption.appendChild(preElement); } } String dragIconKey = state.dragCaptions.get(component).iconKey; if (dragIconKey != null) { String resourceUrl = root.getResourceUrl(dragIconKey); Icon icon = component.getConnection().getIcon(resourceUrl); dragCaptionImage.appendChild(icon.getElement()); } dragCaptionImage.appendChild(dragCaption); return dragCaptionImage; }
Example #6
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 4 votes |
IconWidget(Icon icon) { setElement(icon.getElement()); }
Example #7
Source File: CubaMenuBarWidget.java From cuba with Apache License 2.0 | 4 votes |
@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 { 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(); }
Example #8
Source File: CubaSideMenuWidget.java From cuba with Apache License 2.0 | 4 votes |
protected void addItems(JsonArray items, HasWidgets container) { for (int i = 0; i < items.length(); i++) { JsonObject itemJson = items.getObject(i); Icon icon = null; String iconId = itemJson.getString("icon"); if (menuItemIconSupplier != null && iconId != null) { icon = menuItemIconSupplier.apply(iconId); } boolean captionAsHtml = false; if (itemJson.hasKey("captionAsHtml")) { captionAsHtml = itemJson.getBoolean("captionAsHtml"); } MenuItemWidget menuItemWidget = new MenuItemWidget(this, itemJson.getString("id"), icon, itemJson.getString("styleName"), itemJson.getString("caption"), captionAsHtml); menuItemWidget.setDescription(itemJson.getString("description")); menuItemWidget.setCubaId(itemJson.getString("cubaId")); menuItemWidget.setBadgeText(itemJson.getString("badgeText")); container.add(menuItemWidget); JsonArray childrenItemsJson = itemJson.getArray("children"); if (childrenItemsJson != null) { MenuContainerWidget menuContainerWidget = new MenuContainerWidget(this, menuItemWidget); addItems(childrenItemsJson, menuContainerWidget); container.add(menuContainerWidget); menuItemWidget.setSubMenu(menuContainerWidget); if (itemJson.hasKey("expanded") && itemJson.getBoolean("expanded")) { menuContainerWidget.setExpanded(true); } } } }
Example #9
Source File: CubaSideMenuWidget.java From cuba with Apache License 2.0 | 4 votes |
public MenuItemWidget(CubaSideMenuWidget menu, String id, Icon icon, String styleName, String caption, boolean captionAsHtml) { this.menu = menu; this.id = id; this.icon = icon; this.caption = caption; setElement(Document.get().createDivElement()); setStylePrimaryName(menu.getStylePrimaryName() + "-item"); addStyleDependentName("action"); if (styleName != null) { for (String style : styleName.split(" ")) { if (!style.isEmpty()) { addStyleName(style); } } } SpanElement wrapElement = Document.get().createSpanElement(); wrapElement.setClassName(getStylePrimaryName() + "-wrap"); if (icon != null) { wrapElement.appendChild(icon.getElement()); } captionElement = createCaptionElement(caption, captionAsHtml); wrapElement.appendChild(captionElement); badgeElement = createBadgeElement(); getElement().appendChild(wrapElement); addDomHandler(this, ClickEvent.getType()); addAttachHandler(event -> { if (isAttached() && isRootItem()) { addThumbnail(); } }); }
Example #10
Source File: CubaLabelConnector.java From cuba with Apache License 2.0 | 4 votes |
protected void updateIcon(VLabel widget) { Icon icon = getIcon(); if (icon != null) { widget.getElement().insertFirst(icon.getElement()); } }
Example #11
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 4 votes |
IconWidget(Icon icon) { setElement(icon.getElement()); }