List of usage examples for com.google.gwt.safehtml.shared UriUtils extractScheme
public static String extractScheme(String uri)
From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.AttributeColumn.java
License:Open Source License
private void appendLabel(AttributeDto attr, StringBuilder labels) { if (attr.hasValue() && attr.getValue().trim().length() > 0) { labels.append("<div class=\"attribute-value\">"); if (AttributeDtos.SCRIPT_ATTRIBUTE.equals(attr.getName())) { labels.append("<pre>"); }// w w w.ja v a2s . c om if (attr.hasLocale() && attr.getLocale().trim().length() > 0) { labels.append("<span class=\"label\">").append(attr.getLocale()).append("</span> "); } String value = attr.getValue(); String safeValue = SafeHtmlUtils.fromString(value).asString().replaceAll("\\n", "<br />"); try { if (UriUtils.extractScheme(value) != null && UriUtils.isSafeUri(value)) { labels.append("<a href=").append(value).append(" target=\"_blank\">").append(safeValue) .append("</a>"); } else { labels.append(safeValue); } } catch (Exception e) { labels.append(safeValue); } if (AttributeDtos.SCRIPT_ATTRIBUTE.equals(attr.getName())) { labels.append("</pre>"); } labels.append("</div>"); } }
From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.LocaleTextColumn.java
License:Open Source License
private void appendLabel(LocaleTextDto attr, StringBuilder labels) { labels.append("<div class=\"attribute-value\">"); if (attr.hasLocale() && attr.getLocale().trim().length() > 0) { labels.append("<span class=\"label\">").append(attr.getLocale()).append("</span> "); }// w w w . java 2 s . c o m String value = attr.getText(); String safeValue = SafeHtmlUtils.fromString(value).asString().replaceAll("\\n", "<br />"); try { if (UriUtils.extractScheme(value) != null && UriUtils.isSafeUri(value)) { labels.append("<a href=").append(value).append(" target=\"_blank\">").append(safeValue) .append("</a>"); } else { labels.append(safeValue); } } catch (Exception e) { labels.append(safeValue); } labels.append("</div>"); }