From: Matti Tahvonen Date: Wed, 6 Aug 2008 07:26:52 +0000 (+0000) Subject: fixes #1965 (support for table column icons) X-Git-Tag: 6.7.0.beta1~4398 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=58586cf30a64addc27e56c58d6b775813852ed3f;p=vaadin-framework.git fixes #1965 (support for table column icons) svn changeset:5142/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java index cfb24cfbec..af1623c71d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -1269,9 +1269,11 @@ public class IScrollTable extends Composite implements Table, ScrollListener, final UIDL col = (UIDL) it.next(); final String cid = col.getStringAttribute("cid"); updated.add(cid); + + String caption = buildCaptionHtmlSnippet(col); HeaderCell c = getHeaderCell(cid); if (c == null) { - c = new HeaderCell(cid, col.getStringAttribute("caption")); + c = new HeaderCell(cid, caption); availableCells.put(cid, c); if (initializedAndAttached) { // we will need a column width recalculation @@ -1280,7 +1282,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, isNewBody = true; } } else { - c.setText(col.getStringAttribute("caption")); + c.setText(caption); } if (col.hasAttribute("sortable")) { @@ -1298,7 +1300,6 @@ public class IScrollTable extends Composite implements Table, ScrollListener, final String width = col.getStringAttribute("width"); c.setWidth(Integer.parseInt(width)); } - // TODO icon } // check for orphaned header cells it = availableCells.keySet().iterator(); @@ -1959,14 +1960,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, int col = 0; // row header if (showRowHeaders) { - String caption = uidl.getStringAttribute("caption"); - if (uidl.hasAttribute("icon")) { - caption = "\"icon\"" + caption; - } - addCell(caption, aligns[col++], ""); + addCell(buildCaptionHtmlSnippet(uidl), aligns[col++], ""); } if (uidl.hasAttribute("al")) { @@ -2249,4 +2243,22 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } } + /** + * Helper function to build html snippet for column or row headers + * + * @param uidl + * possibly with values caption and icon + * @return html snippet containing possibly an icon + caption text + */ + private String buildCaptionHtmlSnippet(UIDL uidl) { + String s = uidl.getStringAttribute("caption"); + if (uidl.hasAttribute("icon")) { + s = "\"icon\"" + s; + } + return s; + } + }