List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant
public SafeHtmlBuilder appendHtmlConstant(String html)
From source file:stroom.cell.item.client.ItemCell.java
License:Apache License
@Override public void render(final Context context, final V value, final SafeHtmlBuilder sb) { // Get the view data. final Object key = context.getKey(); V viewData = getViewData(key);/*from w ww . j a v a 2s . com*/ if (viewData != null && viewData.equals(value)) { clearViewData(key); viewData = null; } final int selectedIndex = getSelectedIndex(viewData == null ? value : viewData); sb.appendHtmlConstant("<select tabindex=\"-1\">"); int index = 0; for (final V option : options) { if (index++ == selectedIndex) { sb.append(template.selected(option.getDisplayValue())); } else { sb.append(template.deselected(option.getDisplayValue())); } } sb.appendHtmlConstant("</select>"); }
From source file:stroom.dashboard.client.table.FieldEditTextCell.java
License:Apache License
@Override public void render(final Context context, final String value, final SafeHtmlBuilder sb) { // Get the view data. final Object key = context.getKey(); ViewData viewData = getViewData(key); if (viewData != null && !viewData.isEditing() && value != null && value.equals(viewData.getText())) { clearViewData(key);//from w ww. j av a 2s . co m viewData = null; } String toRender = value; if (viewData != null) { final String text = viewData.getText(); if (viewData.isEditing()) { // Do not use the renderer in edit mode because the value of a // text input element is always treated as text. SafeHtml isn't // valid in the context of the value attribute. sb.append(template.input(fieldsManager.getResources().style().fieldText(), text)); return; } else { // The user pressed enter, but view data still exists. toRender = text; } } if (toRender != null && toRender.trim().length() > 0) { sb.append(template.div(fieldsManager.getResources().style().fieldLabel(), toRender)); } else { // Render a blank space to force the rendered element to have a // height. Otherwise it is not clickable. sb.appendHtmlConstant("\u00A0"); } }
From source file:stroom.dashboard.client.table.TablePresenter.java
License:Apache License
private void addColumn(final Field field, final int pos) { final Column<Row, SafeHtml> column = new Column<Row, SafeHtml>(new SafeHtmlCell()) { @Override//from w w w . ja v a 2 s . c o m public SafeHtml getValue(final Row row) { if (row == null) { return null; } final List<String> values = row.getValues(); if (values != null) { final String value = values.get(pos); if (value != null) { if (field.getGroup() != null && field.getGroup() >= row.getDepth()) { final SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<b>"); sb.appendEscaped(value); sb.appendHtmlConstant("</b>"); return sb.toSafeHtml(); } return SafeHtmlUtils.fromString(value); } } return null; } @Override public String getCellStyleNames(Cell.Context context, Row object) { if (field.getFormat() != null && field.getFormat().getWrap() != null && field.getFormat().getWrap()) { return super.getCellStyleNames(context, object) + " " + getView().getResources().dataGridStyle().dataGridCellWrapText(); } return super.getCellStyleNames(context, object); } }; final FieldHeader fieldHeader = new FieldHeader(fieldsManager, field); fieldHeader.setUpdater(value -> getView().redrawHeaders()); getView().addResizableColumn(column, fieldHeader, field.getWidth()); existingColumns.add(column); }
From source file:stroom.jobsystem.client.TaskTypeCell.java
License:Apache License
@Override public void render(Context context, TaskType value, SafeHtmlBuilder sb) { if (value != null) { // Get the view data. Object key = context.getKey(); TaskType viewData = getViewData(key); if (viewData != null && viewData.equals(value)) { clearViewData(key);//from w w w.j a v a2 s . c om viewData = null; } sb.appendHtmlConstant("<span style=\"position:relative;width:120px;height:16px;\">"); if (JobType.CRON.equals(value.getJobType())) { sb.appendHtmlConstant("Cron " + value.getSchedule() + " "); } if (JobType.FREQUENCY.equals(value.getJobType())) { sb.appendHtmlConstant("Frequency " + value.getSchedule() + " "); } if (JobType.DISTRIBUTED.equals(value.getJobType())) { sb.appendHtmlConstant("Distributed "); } if (JobType.CRON.equals(value.getJobType()) || JobType.FREQUENCY.equals(value.getJobType())) { sb.appendHtmlConstant(button); } sb.appendHtmlConstant("</div>"); } }
From source file:stroom.pool.client.presenter.ButtonCell.java
License:Apache License
@Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<a href=\"javascript:void();\">"); if (data != null) { sb.append(data);//from ww w .j a v a 2 s . co m } sb.appendHtmlConstant("</a>"); }
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 a va 2 s .c o 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 w w. j a va2 s . c o m } 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"); } } }
From source file:taxonomy.webui.client.widget.LocalesColumnConfig.java
License:Open Source License
public LocalesColumnConfig(ValueProvider<? super M, Set<VLocale>> valueProvider) { super(valueProvider, 100, "Locales"); setCell(new AbstractCell<Set<VLocale>>() { @Override/*from www. j a v a2 s .c o m*/ public void render(com.google.gwt.cell.client.Cell.Context context, Set<VLocale> value, SafeHtmlBuilder sb) { if (value == null) { return; } String vn = null; String en = null; for (VLocale v : value) { if ("en".equals(v.getName())) { en = v.getValue(); } else if ("vn".equals(v.getName())) { vn = v.getValue(); } } if (vn != null) { sb.appendHtmlConstant( "<div style='float:left; width: 200px;'><span style='color: blue'><img src='images/flags/vn.png'/> : " + vn + "</span></div>"); } if (en != null) { sb.appendHtmlConstant( "<span style='color: green'><img src='images/flags/gb.png'/> : " + en + "</span>"); } } }); }
From source file:taxonomy.webui.client.widget.ModelGridFactory.java
License:Open Source License
public static ModelGridPanel<VFamily> createFamily() { if (family == null) { FamilyProperties properties = GWT.create(FamilyProperties.class); List<ColumnConfig<VFamily, ?>> cf = new ArrayList<ColumnConfig<VFamily, ?>>(); IdentityValueProvider<VFamily> identity = new IdentityValueProvider<VFamily>(); final RowExpander<VFamily> desc = new RowExpander<VFamily>(identity, new AbstractCell<VFamily>() { @Override//from w w w. j a va 2 s .co m public void render(com.google.gwt.cell.client.Cell.Context context, VFamily value, SafeHtmlBuilder sb) { sb.appendHtmlConstant( "<div style='float:left; margin: 5px 5px 10px;'><img style='height:100px' src='" + (value.getAvatar() != null ? value.getAvatar() : "images/photos/all_kids.jpg") + "'/></div>"); sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>Description:</b> " + value.getDescription() + "</p>"); } }); cf.add(desc); cf.add(new ColumnConfig<VFamily, Integer>(properties.id(), 20, "ID")); cf.add(new ColumnConfig<VFamily, String>(properties.name(), 50, "Name")); cf.add(new ColumnConfig<VFamily, VKingdom>(properties.kingdom(), 50, "Kingdom")); cf.add(new LocalesColumnConfig<VFamily>(properties.locales())); family = new ModelGridPanel<VFamily>(Tables.FAMILY.getName(), cf); foo(desc, family); } return family; }
From source file:taxonomy.webui.client.widget.ModelGridFactory.java
License:Open Source License
public static ModelGridPanel<VGenus> createGenus() { if (genus == null) { GenusProperites properties = GWT.create(GenusProperites.class); List<ColumnConfig<VGenus, ?>> cf = new ArrayList<ColumnConfig<VGenus, ?>>(); IdentityValueProvider<VGenus> identity = new IdentityValueProvider<VGenus>(); final RowExpander<VGenus> desc = new RowExpander<VGenus>(identity, new AbstractCell<VGenus>() { @Override/* w w w.j a va 2 s . co m*/ public void render(com.google.gwt.cell.client.Cell.Context context, VGenus value, SafeHtmlBuilder sb) { sb.appendHtmlConstant( "<div style='float:left; margin: 5px 5px 10px;'><img style='height:100px' src='" + (value.getAvatar() != null ? value.getAvatar() : "images/photos/all_kids.jpg") + "'/></div>"); sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>Description:</b> " + value.getDescription() + "</p>"); } }); cf.add(desc); cf.add(new ColumnConfig<VGenus, Integer>(properties.id(), 20, "ID")); cf.add(new ColumnConfig<VGenus, String>(properties.name(), 50, "Name")); cf.add(new SetColumnConfig<VGenus, VVariant>(properties.variants(), "Variant")); cf.add(new ColumnConfig<VGenus, VKingdom>(properties.kingdom(), 50, "Kingdom")); cf.add(new LocalesColumnConfig<VGenus>(properties.locales())); genus = new ModelGridPanel<VGenus>(Tables.GENUS.getName(), cf); foo(desc, genus); } return genus; }