Skip to content

Commit

Permalink
- HTMLTableBuilder can now append to existing SafeHtmlBuilders
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbiehl committed Apr 2, 2013
1 parent ab5a213 commit e99017b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
Expand Up @@ -92,12 +92,7 @@ public static HTMLTableBuilder mk(String tableClassName) {
private final List<RowBuilder> rows = Lists.newArrayList();

public RowBuilder row() {

RowBuilder rb = new RowBuilder();

rows.add(rb);

return rb;
return row(null);
}

public RowBuilder row(String className) {
Expand All @@ -109,9 +104,11 @@ public RowBuilder row(String className) {
return rb;
}

public SafeHtml toSafeHtml() {

SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder();
public SafeHtmlBuilder build() {
return build(new SafeHtmlBuilder());
}

public SafeHtmlBuilder build(SafeHtmlBuilder htmlBuilder) {

htmlBuilder.appendHtmlConstant("<table "
+ (Strings.isNullOrEmpty(tableClass) ? "" : "class=\""
Expand All @@ -123,7 +120,15 @@ public SafeHtml toSafeHtml() {

htmlBuilder.appendHtmlConstant("</table>");

return htmlBuilder.toSafeHtml();
return htmlBuilder;
}

public SafeHtml asSafeHtml() {
return build().toSafeHtml();
}

public SafeHtml asSafeHtml(SafeHtmlBuilder safeHtmlBuilder) {
return build(safeHtmlBuilder).toSafeHtml();
}

private static class Tuplelize implements
Expand Down
@@ -1,7 +1,5 @@
package org.fhw.asta.kasse.client.widget.print;

import org.fhw.asta.kasse.client.common.HTMLTableBuilder;

import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.user.client.ui.IsWidget;

Expand All @@ -13,6 +11,4 @@ public interface PrintWidget extends IsWidget {

public void addHtml(SafeHtml safeHtml);

public void addHtml(HTMLTableBuilder htmlTable);

}
Expand Up @@ -34,11 +34,6 @@ public void addHtml(String html) {
htmlWidget.setHTML(htmlWidget.getHTML()+html);
}

@Override
public void addHtml(HTMLTableBuilder htmlTable) {
addHtml(htmlTable.toString());
}

@Override
public void addHtml(SafeHtml safeHtml) {
addHtml(safeHtml.asString());
Expand Down

0 comments on commit e99017b

Please sign in to comment.