Permalink
Browse files

- HTMLTableBuilder can now append to existing SafeHtmlBuilders

  • Loading branch information...
alexbiehl committed Apr 2, 2013
1 parent ab5a213 commit e99017b640c2529195b934b9be78997d2f21ed0f
@@ -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) {
@@ -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=\""
@@ -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
@@ -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;
@@ -13,6 +11,4 @@
public void addHtml(SafeHtml safeHtml);
- public void addHtml(HTMLTableBuilder htmlTable);
-
}
@@ -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());

0 comments on commit e99017b

Please sign in to comment.