List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder toSafeHtml
public SafeHtml toSafeHtml()
From source file:org.openelis.ui.widget.table.DropdownCell.java
License:Open Source License
public SafeHtml bulkRender(Object value) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); query = false;/*from w w w .j a v a2 s. co m*/ editor.setQueryMode(false); builder.appendEscaped(display(value)); return builder.toSafeHtml(); }
From source file:org.openelis.ui.widget.table.ImageCell.java
License:Open Source License
public SafeHtml bulkRender(Object value) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant("<span class='" + DataBaseUtil.toString(value) + "'/>"); return builder.toSafeHtml(); }
From source file:org.openelis.ui.widget.table.StaticView.java
License:Open Source License
protected void bulkRender() { CellRenderer renderer;/*from ww w . j a va 2 s.co m*/ String style; SafeHtmlBuilder tb = new SafeHtmlBuilder(); for (int i = 0; i < table.getRowCount(); i++) { style = table.getRowAt(i).getStyle(i); tb.appendHtmlConstant("<tr height='" + (table.getRowHeight() + 3) + "px' index='" + i + "'" + (style != null ? " class='" + style + "'>" : ">")); for (int j = 0; j < table.getColumnCount(); j++) { renderer = table.getColumnAt(j).getCellRenderer(); if (table.getColumnAt(j).display) tb.appendHtmlConstant("<td>"); else tb.appendHtmlConstant("<td style=\"display : none;\">)"); tb.append(renderer.bulkRender(table.getValueAt(i, j))); tb.appendHtmlConstant("</td>"); } tb.appendHtmlConstant("</tr>"); } // this is in a try catch only to get by for unit testing try { flexTable.getElement().getElementsByTagName("tbody").getItem(0).setInnerSafeHtml(tb.toSafeHtml()); } catch (Exception e) { } Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { adjustForScroll(0); } }); }
From source file:org.openelis.ui.widget.tree.StaticView.java
License:Open Source License
protected void bulkRender() { CellRenderer renderer;/*from w w w .j a v a 2 s . c om*/ String style; Node node; SafeHtmlBuilder tb = new SafeHtmlBuilder(); for (int r = 0; r < tree.getRowCount(); r++) { node = tree.getNodeAt(r); style = node.getStyle(r); tb.appendHtmlConstant("<tr height='" + tree.getRowHeight() + "px' index='" + r + "'" + (style != null ? " class='" + style + "'>" : ">")); for (int c = 0; c < tree.getColumnCount(); c++) { if (c < tree.getNodeDefinition(node.getType()).size()) { renderer = tree.getCellRenderer(r, c); if (c == 0) { Grid treeGrid = getTreeCell(node, r, c); renderer.render(treeGrid, 0, treeGrid.getCellCount(0) - 1, tree.getValueAt(r, c)); tb.appendHtmlConstant("<td>"); tb.appendHtmlConstant(treeGrid.getElement().getString()); tb.appendHtmlConstant("</td>"); } else { tb.appendHtmlConstant("<td>"); tb.append(renderer.bulkRender(tree.getValueAt(r, c))); tb.appendHtmlConstant("</td>"); } } else { tb.appendHtmlConstant("<td/>"); } } tb.appendHtmlConstant("</tr>"); } flexTable.getElement().getElementsByTagName("tbody").getItem(0).setInnerSafeHtml(tb.toSafeHtml()); Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { adjustForScroll(0); } }); }
From source file:org.opennms.features.vaadin.nodemaps.internal.gwt.client.ui.controls.search.SearchControl.java
License:Open Source License
private void initializeCellAutocompleteWidget() { final AbstractSafeHtmlRenderer<NodeMarker> renderer = new AbstractSafeHtmlRenderer<NodeMarker>() { @Override//from w ww .jav a 2 s. c o m public SafeHtml render(final NodeMarker marker) { final SafeHtmlBuilder builder = new SafeHtmlBuilder(); final String search = m_inputBox.getValue(); builder.appendHtmlConstant("<div class=\"autocomplete-label\">"); builder.appendHtmlConstant(marker.getNodeLabel()); builder.appendHtmlConstant("</div>"); String additionalSearchInfo = null; if (search != null && (search.contains(":") || search.contains("="))) { final String searchKey = search.replaceAll("[\\:\\=].*$", "").toLowerCase(); LOG.info("searchKey = " + searchKey); final Map<String, String> props = marker.getProperties(); if ("category".equals(searchKey) || "categories".equals(searchKey)) { final String catString = props.get("categories"); if (catString != null) { additionalSearchInfo = catString; } } for (final Map.Entry<String, String> entry : props.entrySet()) { final String key = entry.getKey().toLowerCase(); final Object value = entry.getValue(); if (key.equals(searchKey) && m_labels.containsKey(key)) { additionalSearchInfo = m_labels.get(key) + ": " + value; break; } } } if (additionalSearchInfo != null) { builder.appendHtmlConstant("<div class=\"autocomplete-additional-info\">") .appendHtmlConstant(additionalSearchInfo).appendHtmlConstant("</div>"); } return builder.toSafeHtml(); } }; final AbstractSafeHtmlCell<NodeMarker> cell = new AbstractSafeHtmlCell<NodeMarker>(renderer, "keydown", "click", "dblclick", "touchstart") { @Override public void onBrowserEvent(final Context context, final com.google.gwt.dom.client.Element parent, final NodeMarker value, final NativeEvent event, final ValueUpdater<NodeMarker> valueUpdater) { LOG.info("SearchControl.AutocompleteCell.onBrowserEvent(): context = " + context + ", parent = " + parent + ", value = " + value + ", event = " + event); if (m_stateManager.handleAutocompleteEvent(event)) { super.onBrowserEvent(context, parent, value, event, valueUpdater); } } @Override protected void render(final Context context, final SafeHtml data, final SafeHtmlBuilder builder) { builder.appendHtmlConstant("<div class=\"autocomplete-entry\">"); if (data != null) { builder.append(data); } builder.appendHtmlConstant("</div>"); } }; m_autoComplete = new CellList<NodeMarker>(cell); m_autoComplete.setSelectionModel(m_selectionModel); m_autoComplete.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); m_autoComplete.setVisible(false); m_autoComplete.addStyleName("search-autocomplete"); setIdIfMissing(m_autoComplete, "searchControl.autoComplete"); }
From source file:org.otalo.ao.client.widget.chlist.client.ChosenImpl.java
License:Apache License
private void resultsBuild() { selectItems = new SelectParser().parse(selectElement); if (isMultiple && choices > 0) { searchChoices.find("li." + css.searchChoice()).remove(); choices = 0;//w w w . j a v a 2s .c om } else if (!isMultiple) { selectedItem.addClass(css.chznDefault()).find("span").text(defaultText); if (selectElement.getOptions().getLength() <= options.getDisableSearchThreshold()) { container.addClass(css.chznContainerSingleNoSearch()); } else { container.removeClass(css.chznContainerSingleNoSearch()); } } SafeHtmlBuilder content = new SafeHtmlBuilder(); for (int i = 0; i < selectItems.length(); i++) { SelectItem item = selectItems.get(i); if (item.isGroup()) { SafeHtml result = resultAddGroup((GroupItem) item); if (result != null) { content.append(result); } } else { OptionItem optionItem = (OptionItem) item; if (optionItem.isEmpty()) { continue; } SafeHtml optionHtml = resultAddOption(optionItem); if (optionHtml != null) { content.append(optionHtml); } if (optionItem.isSelected() && isMultiple) { choiceBuild(optionItem); } else if (optionItem.isSelected() && !isMultiple) { selectedItem.removeClass(css.chznDefault()).find("span").text(optionItem.getText()); if (allowSingleDeselect) { singleDeselectControlBuild(); } } } } searchFieldDisabled(); showSearchFieldDefault(); searchFieldScale(); searchResults.html(content.toSafeHtml().asString()); }
From source file:org.pepstock.jem.gwt.client.editor.AbstractSyntaxHighlighter.java
License:Open Source License
private MenuItem createMenuItem(final FontSize fontsize, String preference) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant(/*from w w w. j av a 2 s.c o m*/ "<div style='font-size: " + fontsize.getCssValue() + ";'>" + fontsize.getName() + "</div>"); final MenuItem item = new MenuItem(builder.toSafeHtml()); item.setScheduledCommand(new Command() { @Override public void execute() { // sets preferences CurrentUser.getInstance().setStringPreference(PreferencesKeys.JOB_EDIT_FONTSIZE, fontsize.getCssValue()); // fires new event FontSizeEvent event = new FontSizeEvent(fontsize); EventBus.INSTANCE.fireEvent(event); } }); if (preference.equalsIgnoreCase(fontsize.getCssValue())) { selectedFontItem = item; item.setEnabled(false); item.addStyleName(Styles.INSTANCE.common().editMenuItemDisabled()); editor.setFontSize(fontsize.getCssValue()); currentFontSize = fontsize; } return item; }
From source file:org.pepstock.jem.gwt.client.panels.swarm.NodesActions.java
License:Open Source License
private void setStatus(String statusString) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); NodeStatusImages statusObject;/* ww w.j a v a 2s. c om*/ if (statusString.equals(NodeStatusImages.UNKNOWN.toString())) { statusObject = NodeStatusImages.UNKNOWN; } else if (statusString.equals(NodeStatusImages.STARTING.toString())) { statusObject = NodeStatusImages.STARTING; } else if (statusString.equals(NodeStatusImages.INACTIVE.toString())) { statusObject = NodeStatusImages.INACTIVE; } else if (statusString.equals(NodeStatusImages.ACTIVE.toString())) { statusObject = NodeStatusImages.ACTIVE; } else if (statusString.equals(NodeStatusImages.DRAINED.toString())) { statusObject = NodeStatusImages.DRAINED; } else if (statusString.equals(NodeStatusImages.DRAINING.toString())) { statusObject = NodeStatusImages.DRAINING; } else if (statusString.equals(NodeStatusImages.SHUTTING_DOWN.toString())) { statusObject = NodeStatusImages.SHUTTING_DOWN; } else { statusObject = NodeStatusImages.INACTIVE; } sb.appendHtmlConstant("<table>"); // adds a label for imgae sb.appendHtmlConstant("<tr><td align='left' valign='middle'>Swarm is</td><td width='5px'/><td>"); // Add the contact image. String imageHtml = AbstractImagePrototype.create(statusObject.getImage()).getHTML(); sb.appendHtmlConstant(imageHtml); sb.appendHtmlConstant("</td>"); // Add the name and address. sb.appendHtmlConstant("<td align='left' valign='middle'>"); sb.appendEscaped(statusString); // adds a empty space like a margin sb.appendHtmlConstant("</td><td width='15px'/></tr></table>"); statusLabel.setHTML(sb.toSafeHtml()); }
From source file:org.roda.wui.client.browse.BitstreamPreview.java
private void audioPreview() { Audio audioPlayer = Audio.createIfSupported(); if (audioPlayer != null) { HTML html = new HTML(); SafeHtmlBuilder b = new SafeHtmlBuilder(); b.append(SafeHtmlUtils.fromSafeConstant("<i class='fa fa-headphones fa-5'></i>")); html.setHTML(b.toSafeHtml()); // TODO check if audio source type needs to be transformed // TODO check if audio player supports provided file format audioPlayer.addSource(bitstreamDownloadUri.asString(), getAudioSourceType()); audioPlayer.setControls(true);/* ww w . java2s .c o m*/ panel.add(html); panel.add(audioPlayer); audioPlayer.addStyleName("viewRepresentationAudioFilePreview"); html.addStyleName("viewRepresentationAudioFilePreviewHTML"); } else { notSupportedPreview(); } }
From source file:org.roda.wui.client.browse.BitstreamPreview.java
private void errorPreview(String errorPreview) { HTML html = new HTML(); SafeHtmlBuilder b = new SafeHtmlBuilder(); b.append(SafeHtmlUtils.fromSafeConstant("<i class='fa fa-download fa-5'></i>")); b.append(SafeHtmlUtils.fromSafeConstant("<h4 class='errormessage'>")); b.append(SafeHtmlUtils.fromString(errorPreview)); b.append(SafeHtmlUtils.fromSafeConstant("</h4>")); Button downloadButton = new Button(messages.viewRepresentationDownloadFileButton()); downloadButton.addClickHandler(new ClickHandler() { @Override// www. ja va2 s. c om public void onClick(ClickEvent event) { downloadFile(); } }); html.setHTML(b.toSafeHtml()); panel.add(html); panel.add(downloadButton); html.setStyleName("viewRepresentationErrorPreview"); downloadButton.setStyleName("btn btn-donwload viewRepresentationNotSupportedDownloadButton"); onPreviewFailure.execute(); }