List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendEscaped
public SafeHtmlBuilder appendEscaped(String text)
From source file:stroom.pipeline.structure.client.presenter.PipelineReferenceListPresenter.java
License:Apache License
private SafeHtml getSafeHtmlWithState(final PipelineReference pipelineReference, final String string) { if (string == null) { return SafeHtmlUtils.EMPTY_SAFE_HTML; }// w w w. j a va 2s . c o m final SafeHtmlBuilder builder = new SafeHtmlBuilder(); final State state = referenceStateMap.get(pipelineReference); switch (state) { case ADDED: builder.append(ADDED); break; case REMOVED: builder.append(REMOVED); break; case INHERITED: builder.append(INHERITED); break; } builder.appendEscaped(string); builder.append(END); return builder.toSafeHtml(); }
From source file:stroom.pipeline.structure.client.presenter.PropertyListPresenter.java
License:Apache License
private SafeHtml getSafeHtmlWithState(final PipelineProperty property, final String string, final boolean showRemovedAsDefault) { if (string == null) { return SafeHtmlUtils.EMPTY_SAFE_HTML; }//from ww w. j a va 2 s . com final SafeHtmlBuilder builder = new SafeHtmlBuilder(); if (pipelineModel.getPipelineData().getAddedProperties().contains(property)) { builder.append(ADDED); } else if (pipelineModel.getPipelineData().getRemovedProperties().contains(property)) { if (showRemovedAsDefault) { builder.append(DEFAULT); } else { builder.append(REMOVED); } } else { final PipelineProperty inheritedProperty = getInheritedProperty(property); if (inheritedProperty != null) { builder.append(INHERITED); } else { builder.append(DEFAULT); } } builder.appendEscaped(string); builder.append(END); return builder.toSafeHtml(); }
From source file:stroom.streamstore.client.presenter.MarkerListPresenter.java
License:Apache License
private void addElementId() { getView().addResizableColumn(new Column<Marker, SafeHtml>(new SafeHtmlCell()) { @Override//from www .j av a 2 s .co m public SafeHtml getValue(final Marker marker) { if (marker instanceof StoredError) { final StoredError storedError = (StoredError) marker; if (storedError.getElementId() != null) { return SafeHtmlUtils.fromString(storedError.getElementId()); } } else if (marker instanceof Summary) { final Summary summary = (Summary) marker; final StringBuilder sb = new StringBuilder(); sb.append(summary.getSeverity().getSummaryValue()); sb.append(" ("); if (summary.getTotal() > summary.getCount()) { sb.append(summary.getCount()); sb.append(" of "); sb.append(summary.getTotal()); if (summary.getTotal() >= FetchMarkerResult.MAX_TOTAL_MARKERS) { sb.append("+"); } if (summary.getTotal() <= 1) { sb.append(" item)"); } else { sb.append(" items)"); } } else { sb.append(summary.getCount()); if (summary.getCount() <= 1) { sb.append(" item)"); } else { sb.append(" items)"); } } // Make summery items bold. final SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant("<div style=\"font-weight:bold;\">"); builder.appendEscaped(sb.toString()); builder.appendHtmlConstant("</div>"); return builder.toSafeHtml(); } return null; } }, "Element", 150); }
From source file:stroom.widget.xsdbrowser.client.view.XSDDisplay.java
License:Apache License
private void addChild(final Grid layout, final SelectionMap map, final XSDNode node, final boolean showOccurance, final int row, final int col) { // Ensure layout size. if (layout.getRowCount() < row + 1) { layout.resizeRows(row + 1);/*from w ww .ja va2 s .c om*/ } final XSDType type = node.getType(); rowMap.put(node, row); // Add the image for the structure element if this is one. if (type.isStructural()) { final String occurrence = node.getOccurance(); if (occurrence != null) { final SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant("<div class=\"occuranceLabel\">"); builder.appendEscaped(occurrence); builder.appendHtmlConstant("</div>"); final HTML html = new HTML(builder.toSafeHtml()); final FlowPanel fp = new FlowPanel(); fp.add(getImage(type)); fp.add(html); fp.getElement().getStyle().setPosition(Position.RELATIVE); layout.setWidget(row, col, fp); } else { layout.setWidget(row, col, getImage(type)); } layout.setWidget(row, col + 1, AbstractImagePrototype.create(resources.xsdTree03()).createImage()); } else { // Otherwise add the element. XSDNode refNode = null; Image image = null; XSDNodeLabel lblName = null; Label lblOccurrence = null; Label lblType = null; String name = node.getName(); String valueType = null; if (type == XSDType.ELEMENT || type == XSDType.ATTRIBUTE) { if (name == null) { refNode = node.getRefNode(); if (refNode != null) { name = refNode.getName(); } } if (refNode != null) { valueType = refNode.getValueType(); if (valueType == null) { valueType = "(" + name + "Type)"; } } else { valueType = node.getValueType(); if (valueType == null) { valueType = "(" + name + "Type)"; } } if (showOccurance) { final String occurance = node.getOccurance(); if (occurance != null) { lblOccurrence = new Label(node.getOccurance(), false); } } } // Get the image to use. if (refNode != null) { image = getImage(XSDType.ELEMENT_REF); } else { image = getImage(type); } if (name != null) { lblName = new XSDNodeLabel(name, map, model, node, refNode); } if (valueType != null) { lblType = new Label(valueType, false); } final int colCount = layout.getColumnCount(); // Add line images to get back to the structure level. if (node.getParent() != null && node.getParent().getType().isStructural()) { for (int i = col; i < colCount - 6; i++) { layout.setWidget(row, i, AbstractImagePrototype.create(resources.xsdTree03()).createImage()); } } // Add other images to create the tree lines. int pos = col - 1; XSDNode parent = node; while (pos >= 0 && parent != null && parent.getType().isStructuralOrElement()) { if (node == parent || rowMap.get(parent) == row) { if (parent.isFirstChild() && parent.isLastChild()) { layout.setWidget(row, pos, AbstractImagePrototype.create(resources.xsdTree03()).createImage()); } else if (parent.isFirstChild()) { layout.setWidget(row, pos, AbstractImagePrototype.create(resources.xsdTree06()).createImage()); } else if (parent.isLastChild()) { layout.setWidget(row, pos, AbstractImagePrototype.create(resources.xsdTree09()).createImage()); } else { layout.setWidget(row, pos, AbstractImagePrototype.create(resources.xsdTree05()).createImage()); } } else if (!parent.isLastChild()) { layout.setWidget(row, pos, AbstractImagePrototype.create(resources.xsdTree02()).createImage()); } parent = parent.getParent(); pos -= 2; } if (image != null) { layout.setWidget(row, colCount - 6, image); image.addStyleName("marginRight"); } if (lblName != null) { layout.setWidget(row, colCount - 5, lblName); } if (lblOccurrence != null) { layout.setWidget(row, colCount - 4, new Label("[", false)); layout.setWidget(row, colCount - 3, lblOccurrence); layout.setWidget(row, colCount - 2, new Label("]", false)); } if (lblType != null) { layout.setWidget(row, colCount - 1, lblType); lblType.addStyleName("marginLeft"); } } }