From e3c3944506169d92ba8d41596eee188bdbd0d5e3 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Mon, 13 Dec 2010 13:59:59 +0000 Subject: [PATCH] Refactored fix for #6142 svn changeset:16479/svn branch:6.5 --- .../terminal/gwt/client/ui/VScrollTable.java | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 84612e73c4..fe3b4713f5 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -900,15 +900,13 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, // cell to accomodate for the size of the sort arrow. HeaderCell sortedHeader = tHead.getHeaderCell(sortColumn); if (sortedHeader != null) { - sortedHeader.setWidth(sortedHeader.getWidth(), - sortedHeader.isDefinedWidth()); + sortedHeader.resizeCaptionContainer(); } // Also recalculate the width of the captionContainer element in the // previously sorted header, since this now has more room. HeaderCell oldSortedHeader = tHead.getHeaderCell(oldSortColumn); if (oldSortedHeader != null) { - oldSortedHeader.setWidth(oldSortedHeader.getWidth(), - oldSortedHeader.isDefinedWidth()); + oldSortedHeader.resizeCaptionContainer(); } rendering = false; @@ -1770,6 +1768,33 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, sortable = b; } + /** + * Makes room for the sorting indicator in case the column that the + * header cell belongs to is sorted. This is done by resizing the width + * of the caption container element by the correct amount + */ + public void resizeCaptionContainer() { + if (BrowserInfo.get().isIE6() || td.getClassName().contains("-asc") + || td.getClassName().contains("-desc")) { + /* + * Room for the sort indicator is made by subtracting the styled + * margin and width of the resizer from the width of the caption + * container. + */ + int captionContainerWidth = width + - sortIndicator.getOffsetWidth() + - colResizeWidget.getOffsetWidth(); + captionContainer.getStyle().setPropertyPx("width", + captionContainerWidth); + } else { + /* + * Set the caption container element as wide as possible when + * the sorting indicator is not visible. + */ + captionContainer.getStyle().setPropertyPx("width", width); + } + } + public void setNaturalMinimumColumnWidth(int w) { naturalWidth = w; } @@ -1821,22 +1846,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, DOM.setStyleAttribute(captionContainer, "width", ""); setWidth(""); } else { - /* - * If this column is sorted, we need to make room for the sort - * indicator by subtracting the styled margin and resizer width - * from the width of the caption container. - */ - if (BrowserInfo.get().isIE6() - || td.getClassName().contains("-asc") - || td.getClassName().contains("-desc")) { - int captionContainerWidth = w - - sortIndicator.getOffsetWidth() - - colResizeWidget.getOffsetWidth(); - captionContainer.getStyle().setPropertyPx("width", - captionContainerWidth); - } else { - captionContainer.getStyle().setPropertyPx("width", w); - } + resizeCaptionContainer(); /* * if we already have tBody, set the header width properly, if -- 2.39.5