List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromTrustedString
public static SafeHtml fromTrustedString(String s)
From source file:org.drools.guvnor.client.util.Util.java
License:Apache License
/** * Get a string representation of the header that includes an image and some * text./*from www . j a v a2 s . c om*/ * * @param image the {@link com.google.gwt.resources.client.ImageResource} to add next to the header * @param text the header text * @return the header as a string */ public static SafeHtml getHeader(ImageResource image, final String text) { return HEADER_TEMPLATE.message( SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(image).getHTML()), new SafeHtml() { public String asString() { return text; } }); }
From source file:org.drools.guvnor.client.widgets.drools.explorer.ArtifactDependenciesExplorerWidget.java
License:Apache License
private void addItem(final TreeItem root, final MavenArtifact artifact, final Collection<MavenArtifact> unchecked) { final SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(images.modelAsset()).getHTML())); sb.appendEscaped(" ").appendEscaped(artifact.toLabel()); final CheckBox checkBox = new CheckBox(sb.toSafeHtml()); if (!unchecked.contains(artifact)) { checkBox.setValue(true);/*from ww w. j a v a 2 s .c om*/ } final TreeItem newTreeItem = root.addItem(checkBox); newTreeItem.setUserObject(artifact); if (artifact.hasChild()) { for (MavenArtifact chilldren : artifact.getChild()) { addItem(newTreeItem, chilldren, unchecked); } } checkBox.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final CheckBox me = ((CheckBox) event.getSource()); boolean checked = me.getValue(); if (newTreeItem.getChildCount() > 0) { for (int i = 0; i < newTreeItem.getChildCount(); i++) { defineState(newTreeItem.getChild(i), checked); } } } private void defineState(TreeItem currentItem, boolean checked) { ((CheckBox) currentItem.getWidget()).setValue(checked); if (currentItem.getChildCount() > 0) { for (int i = 0; i < currentItem.getChildCount(); i++) { defineState(currentItem.getChild(i), checked); } } } }); }
From source file:org.drools.guvnor.client.widgets.tables.ComparableImageResourceCell.java
License:Apache License
@Override public void render(Context context, ComparableImageResource value, SafeHtmlBuilder sb) { if (value != null) { // The template will sanitize the URI. sb.append(SafeHtmlUtils.fromTrustedString(value.getImageHTML())); }//w w w . ja v a 2 s. com }
From source file:org.drools.guvnor.client.widgets.tables.RuleEnabledStateCell.java
License:Apache License
public RuleEnabledStateCell() { //Do the expensive operations in the constructor AbstractImagePrototype aip = AbstractImagePrototype.create(images.warning()); SafeHtml icon = SafeHtmlUtils.fromTrustedString(aip.getHTML()); shtml = SafeHtmlUtils.fromTrustedString( "<div title='" + constants.AssetTableIsDisabledTip() + "'>" + icon.asString() + "</div>"); }
From source file:org.drools.guvnor.client.widgets.tables.RuleFormatImageResourceCell.java
License:Apache License
@Override public void render(Context context, RuleFormatImageResource value, SafeHtmlBuilder sb) { SafeHtml html = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(value).getHTML()); sb.append(html);/*from w w w . j a va 2 s . c o m*/ }
From source file:org.drools.workbench.screens.guided.dtable.client.widget.auditlog.AuditLogEntryCellHelper.java
License:Apache License
private void buildColumnDetailsInsert(final ActionWorkItemColumnDetails details, final SafeHtmlBuilder sb) { sb.append(TEMPLATE.commentHeader(GuidedDecisionTableConstants.INSTANCE .DecisionTableAuditLogInsertWorkItemExecuteColumn0(details.getColumnHeader()))); if (details.getParameters().size() > 0) { sb.append(SafeHtmlUtils.fromTrustedString("<table>")); sb.append(TEMPLATE.commentRow(nil(GuidedDecisionTableConstants.INSTANCE.WorkItemNameColon()), nil(details.getName()), labelClass, valueClass)); for (Map.Entry<String, PortableParameterDefinition> e : details.getParameters().entrySet()) { sb.append(TEMPLATE.commentRow( new StringBuilder(nil(e.getKey())).append(GuidedDecisionTableConstants.COLON).toString(), nil(e.getValue()), labelClass, valueClass)); }//from w w w .ja v a 2 s . co m sb.append(SafeHtmlUtils.fromTrustedString("</table>")); } }
From source file:org.eclipse.kura.web.client.ui.Status.StatusPanelUi.java
License:Open Source License
public void loadStatusTable(CellTable<GwtGroupedNVPair> grid, ListDataProvider<GwtGroupedNVPair> dataProvider) { TextColumn<GwtGroupedNVPair> col1 = new TextColumn<GwtGroupedNVPair>() { @Override/*from ww w .j a va 2 s .c o m*/ public String getValue(GwtGroupedNVPair object) { return String.valueOf(object.getName()); } }; col1.setCellStyleNames("status-table-row"); grid.addColumn(col1); Column<GwtGroupedNVPair, SafeHtml> col2 = new Column<GwtGroupedNVPair, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(GwtGroupedNVPair object) { return SafeHtmlUtils.fromTrustedString(String.valueOf(object.getValue())); } }; col2.setCellStyleNames("status-table-row"); grid.addColumn(col2); dataProvider.addDataDisplay(grid); }
From source file:org.geowe.client.local.main.tool.map.catalog.dialog.LayerCatalogDialog.java
License:Open Source License
private ColumnModel<LayerDef> createColumnList(LayerDefProperties props, RowExpander<LayerDef> rowExpander) { rowExpander.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); rowExpander.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); ColumnConfig<LayerDef, String> nameColumn = new ColumnConfig<LayerDef, String>(props.name(), 200, SafeHtmlUtils.fromTrustedString("<b>" + UIMessages.INSTANCE.layerManagerToolText() + "</b>")); nameColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); ColumnConfig<LayerDef, String> typeColumn = new ColumnConfig<LayerDef, String>(props.type(), 75, UICatalogMessages.INSTANCE.type()); typeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); typeColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); ColumnConfig<LayerDef, ImageResource> iconColumn = new ColumnConfig<LayerDef, ImageResource>(props.icon(), 32, ""); iconColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); iconColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); iconColumn.setCell(new ImageResourceCell() { @Override//from w ww . ja va2s. c o m public void render(Context context, ImageResource value, SafeHtmlBuilder sb) { super.render(context, value, sb); } }); List<ColumnConfig<LayerDef, ?>> columns = new ArrayList<ColumnConfig<LayerDef, ?>>(); columns.add(rowExpander); columns.add(iconColumn); columns.add(nameColumn); columns.add(typeColumn); return new ColumnModel<LayerDef>(columns); }
From source file:org.hudsonci.maven.plugin.ui.gwt.buildinfo.widget.HyperlinkCell.java
License:Open Source License
@Override public void render(Context context, Hyperlink link, SafeHtmlBuilder sb) { // Note: toString renders properly but getHTML doesn't; go figure. sb.append(SafeHtmlUtils.fromTrustedString(link.toString())); }
From source file:org.jboss.hal.client.configuration.subsystem.undertow.ServerPresenter.java
License:Apache License
void disableSsl(String httpsListener) { AddressTemplate httpsTemplate = SERVER_TEMPLATE.append(HTTPS_LISTENER + EQ_WILDCARD); Metadata metadata = metadataRegistry.lookup(httpsTemplate); SafeHtml description = resources.messages().disableSSLUndertowQuestion(httpsListener); String label = new LabelBuilder().label(SECURITY_REALM); TextBoxItem securityRealmItem = new TextBoxItem(SECURITY_REALM, label); securityRealmItem.setRequired(true); SafeHtml securityRealmDescription = SafeHtmlUtils.fromTrustedString( metadata.getDescription().get(ATTRIBUTES).get(SECURITY_REALM).get(DESCRIPTION).asString()); Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(SECURITY_REALM, Ids.FORM), Metadata.empty()) .unboundFormItem(securityRealmItem, 0, securityRealmDescription).build(); HTMLElement content = div().add(p().innerHtml(description)).add(form.element()).get(); Dialog dialog = new Dialog.Builder(resources.constants().disableSSL()).size(Dialog.Size.MEDIUM) .primary(resources.constants().yes(), () -> { boolean valid = form.save(); // if the form contains validation error, don't close the dialog if (valid) { ResourceAddress httpsAddress = httpsTemplate.resolve(statementContext, serverName, httpsListener); Operation undefineSslCtx = new Operation.Builder(httpsAddress, UNDEFINE_ATTRIBUTE_OPERATION) .param(NAME, SSL_CONTEXT).build(); Operation writeSecurityRealm = new Operation.Builder(httpsAddress, WRITE_ATTRIBUTE_OPERATION).param(NAME, SECURITY_REALM) .param(VALUE, securityRealmItem.getValue()).build(); Composite composite = new Composite(); composite.add(undefineSslCtx); composite.add(writeSecurityRealm); dispatcher.execute(composite, (CompositeResult result) -> { MessageEvent.fire(getEventBus(), Message.success(resources.messages().disableSSLUndertowSuccess(httpsListener))); reload();/*from ww w.jav a2 s . c o m*/ }, (operation, failure) -> { MessageEvent.fire(getEventBus(), Message .error(resources.messages().disableSSLUndertowError(httpsListener, failure))); }, (operation, exception) -> { SafeHtml message = resources.messages().disableSSLUndertowError(httpsListener, exception.getMessage()); MessageEvent.fire(getEventBus(), Message.error(message)); }); } return valid; }).secondary(resources.constants().no(), () -> true).closeIcon(true).closeOnEsc(true).add(content) .build(); dialog.registerAttachable(form); dialog.show(); ModelNode model = new ModelNode().setEmptyObject(); form.edit(model); }