List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder SafeHtmlBuilder
public SafeHtmlBuilder()
From source file:org.jboss.ballroom.client.widgets.forms.FieldsetRenderer.java
License:Open Source License
private HTMLPanel createFieldsetPanel(String groupName) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant("<fieldset id='" + id + "' class='default-fieldset'>"); builder.appendHtmlConstant("<legend class='default-legend'>").appendEscaped(groupName) .appendHtmlConstant("</legend>"); builder.appendHtmlConstant("</fieldset>"); return new HTMLPanel(builder.toSafeHtml()); }
From source file:org.jboss.ballroom.client.widgets.tables.HyperlinkCell.java
License:Open Source License
public HyperlinkCell(SafeHtml message, ActionCell.Delegate<String> delegate) { super("click", "keydown"); this.delegate = delegate; this.html = new SafeHtmlBuilder().appendHtmlConstant("<div tabindex=\"-1\" class='gwt-Hyperlink'>") .append(message).appendHtmlConstant("</div>").toSafeHtml(); }
From source file:org.jboss.ballroom.client.widgets.tables.OptionCell.java
License:Open Source License
public OptionCell(SafeHtml message, ActionCell.Delegate<String> delegate) { super("click", "keydown"); this.delegate = delegate; this.html = new SafeHtmlBuilder().appendHtmlConstant("<div tabindex=\"-1\" class='row-tools'>") .append(message).appendHtmlConstant("</div>").toSafeHtml(); }
From source file:org.jboss.ballroom.client.widgets.tables.PopupCell.java
License:Open Source License
public PopupCell(String title, PopupCellDelegate delegate) { super("click", "keydown"); this.delegate = delegate; this.popup = new PopupPanel(); this.popup.setStyleName("default-popup"); this.popup.setWidget(delegate.asWidget()); this.html = new SafeHtmlBuilder() .appendHtmlConstant("<div tabindex=\"-1\" class='cell-popup'>" + title + "</div>").toSafeHtml(); }
From source file:org.jboss.ballroom.client.widgets.window.Feedback.java
License:Open Source License
@Deprecated public static void alert(String title, String message) { alert(title, new SafeHtmlBuilder().appendEscaped(message).toSafeHtml()); }
From source file:org.jboss.gwt.circuit.sample.todo.client.views.TodoView.java
License:Open Source License
public TodoView() { VerticalPanel layout = new VerticalPanel(); layout.getElement().setAttribute("style", "padding:20px;width:100%"); users = new ListBox(); users.addChangeHandler(new ChangeHandler() { @Override/*from w ww . ja v a 2 s . c om*/ public void onChange(com.google.gwt.event.dom.client.ChangeEvent changeEvent) { dispatcher.dispatch(new SelectUser(users.getValue(users.getSelectedIndex()))); } }); layout.add(users); table = new CellTable<Todo>(); table.getElement().setAttribute("style", "width:90%"); table.setEmptyTableWidget(new HTML("No Todo items found!")); final SingleSelectionModel<Todo> selectionModel = new SingleSelectionModel<Todo>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent selectionChangeEvent) { dispatcher.dispatch(new SelectTodo(selectionModel.getSelectedObject())); } }); table.setSelectionModel(selectionModel); dataProvider = new ListDataProvider<Todo>(); dataProvider.addDataDisplay(table); Column<Todo, SafeHtml> nameColumn = new Column<Todo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Todo object) { String css = object.isDone() ? "todo-done" : "none"; SafeHtmlBuilder html = new SafeHtmlBuilder(); html.appendHtmlConstant("<div class=" + css + ">"); html.appendEscaped(object.getName()); html.appendHtmlConstant("</div>"); return html.toSafeHtml(); } }; table.addColumn(nameColumn, "Todo"); TextColumn<Todo> userColumn = new TextColumn<Todo>() { @Override public String getValue(Todo object) { return object.getUser(); } }; table.addColumn(userColumn, "Assignment"); layout.add(table); Button addButton = new Button("Add", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { Dialog.askFor("Please provide a description:", new AsyncCallback<String>() { @Override public void onFailure(Throwable throwable) { } @Override public void onSuccess(String s) { dispatcher.dispatch(new SaveTodo(new Todo(s))); } }); } }); removeButton = new Button("Remove", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { dispatcher.dispatch(new RemoveTodo(selectionModel.getSelectedObject())); } }); removeButton.setEnabled(false); // enabled by selection doneButton = new Button("Done", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { Todo todo = selectionModel.getSelectedObject(); todo.setDone(true); dispatcher.dispatch(new ResolveTodo(todo)); } }); doneButton.setEnabled(false); // enabled by selection HorizontalPanel tools = new HorizontalPanel(); tools.add(addButton); tools.add(removeButton); tools.add(doneButton); layout.add(tools); initWidget(layout); }
From source file:org.jboss.hal.ballroom.autocomplete.ReadChildrenRenderer.java
License:Apache License
@Override public String render(JsonObject item, String query) { String name = item.get(NAME).asString(); @NonNls/*from w ww. j a va 2 s . c o m*/ SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant("<div class=\"" + autocompleteSuggestion + "\" data-val=\"" + name + "\">"); JsonArray addresses = item.getArray(ADDRESSES); if (addresses.length() != 0) { for (int i = 0; i < addresses.length(); i++) { JsonObject keyValue = addresses.getObject(i); builder.appendHtmlConstant( "<span title=\"" + keyValue.getString(KEY) + "\" class=\"" + address + "\">"); builder.appendEscaped(keyValue.getString(VALUE)); builder.appendEscaped(" / "); builder.appendHtmlConstant("</span>"); } } builder.appendHtmlConstant(highlight(query).replace(name, "<b>$1</b>")) //NON-NLS .appendHtmlConstant("</div>"); return builder.toSafeHtml().asString(); }
From source file:org.jboss.hal.ballroom.autocomplete.StringRenderer.java
License:Apache License
@Override public String render(T item, String query) { String itm = toString.apply(item); @NonNls//from w ww. j a v a 2 s. c om SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant("<div class=\"" + autocompleteSuggestion + "\" data-val=\"" + itm + "\">") .appendHtmlConstant(highlight(query).replace(itm, "<b>$1</b>")) //NON-NLS .appendHtmlConstant("</div>"); return builder.toSafeHtml().asString(); }
From source file:org.jboss.hal.ballroom.chart.Utilization.java
License:Apache License
public void update(long current, long total) { if (current <= total) { this.total = total; double currentPercent = Math.round(((double) current) / ((double) total) * 100.0); long remaining = total - current; double remainingPercent = 100.0 - currentPercent; valueBar.setAttribute(aria(VALUE_NOW), String.valueOf(current)); valueBar.setAttribute(aria(VALUE_MAX), String.valueOf(total)); valueBar.style.width = width(currentPercent + "%"); Tooltip.element(valueBar).setTitle(MESSAGES.used(currentPercent)); //noinspection HardCodedStringLiteral valueElement.innerHTML = new SafeHtmlBuilder().appendHtmlConstant("<strong>") .appendEscaped(MESSAGES.currentOfTotal(current, total)).appendHtmlConstant("</strong>") .appendEscaped(" " + unit).toSafeHtml().asString(); remainingBar.setAttribute(aria(VALUE_NOW), String.valueOf(remaining)); remainingBar.setAttribute(aria(VALUE_MAX), String.valueOf(total)); remainingBar.style.width = width(remainingPercent + "%"); Tooltip.element(remainingBar).setTitle(MESSAGES.available(remainingPercent)); remainingElement.textContent = MESSAGES.available(remainingPercent); if (thresholds) { valueBar.classList.remove(progressBarDanger); valueBar.classList.remove(progressBarWarning); valueBar.classList.remove(progressBarSuccess); if (currentPercent > 90) { valueBar.classList.add(progressBarDanger); } else if (currentPercent > 75) { valueBar.classList.add(progressBarWarning); } else { valueBar.classList.add(progressBarSuccess); }/* w ww.jav a2s . c o m*/ } } else { logger.error("Invalid values for utilization bar chart: current > total ({} > {})", current, total); } }
From source file:org.jboss.hal.ballroom.HelpTextBuilder.java
License:Apache License
public SafeHtml helpText(Property property) { SafeHtmlBuilder help = new SafeHtmlBuilder(); ModelNode attribute = property.getValue(); boolean supportsExpression = attribute.hasDefined(EXPRESSIONS_ALLOWED) && attribute.get(EXPRESSIONS_ALLOWED).asBoolean(false); boolean required = attribute.hasDefined(NILLABLE) && !attribute.get(NILLABLE).asBoolean(false); List<String> requires = attribute.hasDefined(REQUIRES) ? attribute.get(REQUIRES).asList().stream().map(ModelNode::asString).collect(toList()) : Collections.emptyList(); List<String> alternatives = attribute.hasDefined(ALTERNATIVES) ? attribute.get(ALTERNATIVES).asList().stream().map(ModelNode::asString).collect(toList()) : Collections.emptyList(); RestartMode restartMode = restartRequired(attribute); if (restartMode == UNKNOWN) { logger.warn("Unknown restart mode in attribute description for '{}': '{}'", property.getName(), attribute.get(RESTART_REQUIRED).asString()); }/* w w w . j a v a2 s .c om*/ boolean showRestartHelp = (restartMode == ALL_SERVICES || restartMode == RestartMode.JVM || restartMode == RESOURCE_SERVICES); SafeHtml desc = SafeHtmlUtils.fromSafeConstant(attribute.get(DESCRIPTION).asString()); help.append(desc); LabelBuilder labelBuilder = new LabelBuilder(); List<SafeHtml> textModules = new ArrayList<>(); if (required) { textModules.add(SafeHtmlUtils.fromString(CONSTANTS.requiredField())); } if (attribute.hasDefined(CAPABILITY_REFERENCE)) { textModules.add(MESSAGES.capabilityReference(attribute.get(CAPABILITY_REFERENCE).asString())); } if (supportsExpression) { textModules.add(SafeHtmlUtils.fromString(CONSTANTS.supportsExpressions())); } if (attribute.hasDefined(UNIT)) { textModules.add(MESSAGES.unit(attribute.get(UNIT).asString().toLowerCase())); } if (!requires.isEmpty()) { textModules.add(MESSAGES.requires(labelBuilder.enumeration(requires, CONSTANTS.and()))); } if (!alternatives.isEmpty()) { textModules.add(MESSAGES.alternativesHelp(labelBuilder.enumeration(alternatives, CONSTANTS.and()))); } if (showRestartHelp) { textModules.add(SafeHtmlUtils.fromString(restartMode.description())); } if (!textModules.isEmpty()) { help.appendHtmlConstant("<br/>"); for (SafeHtml html : textModules) { help.append(html); help.append(SafeHtmlUtils.fromString(". ")); } } return help.toSafeHtml(); }