List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromTrustedString
public static SafeHtml fromTrustedString(String s)
From source file:stroom.cell.expander.client.ExpanderCell.java
License:Apache License
private SafeHtml getImageHtml(final ImageResource res) { // Get the HTML for the image. final AbstractImagePrototype proto = AbstractImagePrototype.create(res); final SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML()); return image; }
From source file:stroom.dashboard.client.table.FieldCell.java
License:Apache License
public static FieldCell create(final FieldsManager fieldsManager) { final List<HasCell<Field, ?>> cells = new ArrayList<HasCell<Field, ?>>(); final Column<Field, String> name = new Column<Field, String>(new FieldEditTextCell(fieldsManager)) { @Override// w w w . j av a 2 s. com public String getValue(final Field field) { return field.getName(); } }; name.setFieldUpdater(new FieldUpdater<Field, String>() { @Override public void update(final int index, final Field object, final String value) { object.setName(value); } }); cells.add(name); final Column<Field, ImageResource> group = new Column<Field, ImageResource>(new ImageResourceCell()) { @Override public ImageResource getValue(final Field field) { if (field.getGroup() == null) { return null; } else { return fieldsManager.getResources().group(); } } }; cells.add(group); final Column<Field, SafeHtml> groupNo = new Column<Field, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(final Field field) { if (field.getGroup() == null) { return SafeHtmlUtils.EMPTY_SAFE_HTML; } else { return SafeHtmlUtils .fromTrustedString("<div class=\"" + fieldsManager.getResources().style().sortOrder() + "\">" + (field.getGroup() + 1) + "</div>"); } } }; cells.add(groupNo); final Column<Field, ImageResource> sort = new Column<Field, ImageResource>(new ImageResourceCell()) { @Override public ImageResource getValue(final Field field) { if (field.getSort() == null) { return null; } else if (Sort.SortDirection.ASCENDING == field.getSort().getDirection()) { return fieldsManager.getResources().sortaz(); } else { return fieldsManager.getResources().sortza(); } } }; cells.add(sort); final Column<Field, SafeHtml> sortOrder = new Column<Field, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(final Field field) { if (field.getSort() == null) { return SafeHtmlUtils.EMPTY_SAFE_HTML; } else { return SafeHtmlUtils .fromTrustedString("<div class=\"" + fieldsManager.getResources().style().sortOrder() + "\">" + (field.getSort().getOrder() + 1) + "</div>"); } } }; cells.add(sortOrder); final Column<Field, ImageResource> filter = new Column<Field, ImageResource>(new ImageResourceCell()) { @Override public ImageResource getValue(final Field field) { final Filter filter = field.getFilter(); if (filter != null) { if ((filter.getIncludes() != null && filter.getIncludes().trim().length() > 0) || (filter.getExcludes() != null && filter.getExcludes().trim().length() > 0)) { return fieldsManager.getResources().filter(); } } return null; } }; cells.add(filter); return new FieldCell(cells); }
From source file:stroom.statistics.client.common.StatisticsPlugin.java
License:Apache License
private void doConfirmSave(final EntityEditPresenter<?, StatisticStoreEntity> presenter, final StatisticStoreEntity entity, final StatisticStoreEntity entityFromDb) { // get the persisted versions of the fields we care about final String prevEngineName = entityFromDb.getEngineName(); final StatisticType prevType = entityFromDb.getStatisticType(); final StatisticRollUpType prevRollUpType = entityFromDb.getRollUpType(); final Long prevInterval = entityFromDb.getPrecision(); final List<StatisticField> prevFieldList = entityFromDb.getStatisticFields(); final Set<CustomRollUpMask> prevMaskSet = entityFromDb.getCustomRollUpMasks(); presenter.write(entity);/*w w w .j av a 2 s . c om*/ // if one of a select list of attributes has changed then warn the user // only need a null check on the engine name as the rest will never be // null if (entityFromDb != null && ((prevEngineName == null && entity.getEngineName() != null) || !prevEngineName.equals(entity.getEngineName()) || !prevType.equals(entity.getStatisticType()) || !prevRollUpType.equals(entity.getRollUpType()) || !prevInterval.equals(entity.getPrecision()) || !prevFieldList.equals(entity.getStatisticFields()) || !prevMaskSet.equals(entity.getCustomRollUpMasks()))) { ConfirmEvent.fireWarn(this, SafeHtmlUtils .fromTrustedString("Changes to the following attributes of a statistic data source:<br/><br/>" + "Engine Name<br/>Statistic Type<br/>Precision<br/>Rollup Type<br/>Field list<br/>Custom roll-ups<br/><br/>" + "can potentially cause corruption of the existing statistics data. Please ensure you " + "understand the full consequences of the change.<br/><br/>" + "Do you wish to continue?"), new ConfirmCallback() { @Override public void onResult(final boolean result) { if (result) { doSave(presenter, entity); } else { // Re-enable popup buttons. } } }); } else { // user has changed some attributes we don't care about so just do // the save doSave(presenter, entity); } }
From source file:stroom.stats.client.StroomStatsStorePlugin.java
License:Apache License
private void doConfirmSave(final EntityEditPresenter<?, StroomStatsStoreEntity> presenter, final StroomStatsStoreEntity entity, final StroomStatsStoreEntity entityFromDb) { // get the persisted versions of the fields we care about final StatisticType prevType = entityFromDb.getStatisticType(); final StatisticRollUpType prevRollUpType = entityFromDb.getRollUpType(); final String prevInterval = entityFromDb.getPrecision(); final List<StatisticField> prevFieldList = entityFromDb.getStatisticFields(); final Set<CustomRollUpMask> prevMaskSet = entityFromDb.getCustomRollUpMasks(); presenter.write(entity);//from w w w . j a v a 2 s. co m // if one of a select list of attributes has changed then warn the user // only need a null check on the engine name as the rest will never be // null if (entityFromDb != null && (!prevType.equals(entity.getStatisticType()) || !prevRollUpType.equals(entity.getRollUpType()) || !prevInterval.equals(entity.getPrecision()) || !prevFieldList.equals(entity.getStatisticFields()) || !prevMaskSet.equals(entity.getCustomRollUpMasks()))) { ConfirmEvent.fireWarn(this, SafeHtmlUtils .fromTrustedString("Changes to the following attributes of a statistic data source:<br/><br/>" + "Engine Name<br/>Statistic Type<br/>Precision<br/>Rollup Type<br/>Field list<br/>Custom roll-ups<br/><br/>" + "can potentially cause corruption of the existing statistics data. Please ensure you " + "understand the full consequences of the change.<br/><br/>" + "Do you wish to continue?"), result -> { if (result) { doSave(presenter, entity); } else { // Re-enable popup buttons. } }); } else { // user has changed some attributes we don't care about so just do // the save doSave(presenter, entity); } }
From source file:stroom.widget.tab.client.view.CurveTab.java
License:Apache License
public CurveTab(final Icon icon, final String text, final boolean allowClose) { this.allowClose = allowClose; if (resources == null) { resources = GWT.create(Resources.class); resources.style().ensureInjected(); }/* w w w .j a va 2s .c o m*/ element = DOM.createDiv(); element.setClassName(resources.style().curveTab()); background = DOM.createDiv(); background.setClassName(resources.style().background()); element.appendChild(background); leftBackground = DOM.createDiv(); leftBackground.setClassName(resources.style().leftBackground()); background.appendChild(leftBackground); midBackground = DOM.createDiv(); midBackground.setClassName(resources.style().midBackground()); background.appendChild(midBackground); rightBackground = DOM.createDiv(); rightBackground.setClassName(resources.style().rightBackground()); background.appendChild(rightBackground); if (icon != null) { if (icon instanceof ImageIcon) { final ImageIcon imageIcon = (ImageIcon) icon; final Image image = imageIcon.getImage(); if (image != null) { image.getElement().addClassName(resources.style().icon()); element.appendChild(image.getElement()); } } else if (icon instanceof GlyphIcon) { final GlyphIcon glyphIcon = (GlyphIcon) icon; final SafeHtml safeHtml = SafeHtmlUtils .fromTrustedString("<div class=\"" + resources.style().icon() + "\"><div class=\"" + resources.style().face() + "\" style=\"color:" + glyphIcon.getColourSet() + "\"><i class=\"" + glyphIcon.getGlyph() + "\"></i></div></div>"); final HTML html = new HTML(safeHtml); final Element elem = html.getElement(); element.appendChild(elem); } } label = DOM.createDiv(); label.setClassName(resources.style().text()); label.setInnerText(text); element.appendChild(label); close = DOM.createDiv(); close.setClassName(resources.style().close()); element.appendChild(close); setElement(element); if (!allowClose) { close.getStyle().setDisplay(Display.NONE); label.getStyle().setPaddingRight(20, Unit.PX); } }
From source file:thothbot.parallax.demo.client.Demo.java
License:Open Source License
/** * Create a hidden site map for crawlability. * //from w w w. jav a2s . co m * @param contentWidgets the {@link ContentWidget}s used in Demo */ private void createSiteMap(Set<ContentWidget> contentWidgets) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); for (ContentWidget cw : contentWidgets) { String token = cw.getContentWidgetToken(); sb.append(SafeHtmlUtils.fromTrustedString("<a href=\"#" + token + "\">" + token + "</a>")); } // Add the site map to the page. HTML siteMap = new HTML(sb.toSafeHtml()); siteMap.setVisible(false); RootPanel.get().add(siteMap, 0, 0); }
From source file:uk.ac.ebi.fg.annotare2.prototype.frontier.client.FrontierDialogBox.java
License:Apache License
/** * Sets the html string inside the caption by calling its * {@link #setHTML(SafeHtml)} method. Only known safe HTML should be inserted * in here./* w w w . j a v a 2s. com*/ * * Use {@link #setWidget(Widget)} to set the contents inside the * {@link DialogBox}. * * @param html the object's new HTML */ public void setHTML(String html) { caption.setHTML(SafeHtmlUtils.fromTrustedString(html)); }
From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.MultiLineSafeHtmlRenderer.java
License:Apache License
public SafeHtml render(String object) { if (null == object) { return SafeHtmlUtils.EMPTY_SAFE_HTML; } else {/*from w w w. j a va 2 s .c o m*/ return SafeHtmlUtils .fromTrustedString(SafeHtmlUtils.htmlEscape(object).replaceAll("\\r\\n|[\\r\\n]", "<br>")); } }