From 91029a1012310fb3caa6f79d392542111268239c Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Tue, 15 Apr 2014 11:10:18 +0300 Subject: Update the tab caption widths when necessary (#13402) Change-Id: I9c319625da3e4cfc5b49c339f54393f7e12effed --- client/src/com/vaadin/client/ui/VTabsheet.java | 42 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index f2e4003e7f..a523287101 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -92,7 +92,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Representation of a single "tab" shown in the TabBar - * + * */ public static class Tab extends SimplePanel implements HasFocusHandlers, HasBlurHandlers, HasKeyDownHandlers { @@ -194,7 +194,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Toggles the style names for the Tab - * + * * @param selected * true if the Tab is selected * @param first @@ -581,7 +581,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Returns the index of the first visible tab - * + * * @return */ private int getFirstVisibleTab() { @@ -590,7 +590,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Find the next visible tab. Returns -1 if none is found. - * + * * @param i * @return */ @@ -609,7 +609,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Find the previous visible tab. Returns -1 if none is found. - * + * * @param i * @return */ @@ -721,7 +721,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Load the content of a tab of the provided index. - * + * * @param index * of the tab to load */ @@ -747,7 +747,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Returns the currently displayed widget in the tab panel. - * + * * @since 7.2 * @return currently displayed content widget */ @@ -757,7 +757,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Returns the client to server RPC proxy for the tabsheet. - * + * * @since 7.2 * @return RPC proxy */ @@ -767,10 +767,10 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * For internal use only. - * + * * Avoid using this method directly and use appropriate superclass methods * where applicable. - * + * * @deprecated since 7.2 - use more specific methods instead (getRpcProxy(), * getConnectorForWidget(Widget) etc.) * @return ApplicationConnection @@ -885,7 +885,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Checks if the tab with the selected index has been scrolled out of the * view (on the left side). - * + * * @param index * @return */ @@ -1018,7 +1018,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Renders the widget content for a tab sheet. - * + * * @param newWidget */ public void renderContent(Widget newWidget) { @@ -1045,6 +1045,16 @@ public class VTabsheet extends VTabsheetBase implements Focusable, VTabsheet.this.removeStyleDependentName("loading"); } + /** + * Recalculates the sizes of tab captions, causing the tabs to be + * rendered the correct size. + */ + private void updateTabCaptionSizes() { + for (int tabIx = 0; tabIx < tb.getTabCount(); tabIx++) { + tb.getTab(tabIx).recalculateCaptionWidth(); + } + } + /** For internal use only. May be removed or replaced in the future. */ public void updateContentNodeHeight() { if (!isDynamicHeight()) { @@ -1062,8 +1072,12 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } } + /** + * Run internal layouting. + */ public void iLayout() { updateTabScroller(); + updateTabCaptionSizes(); } /** @@ -1379,7 +1393,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Makes tab bar visible. - * + * * @since 7.2 */ public void showTabs() { @@ -1390,7 +1404,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Makes tab bar invisible. - * + * * @since 7.2 */ public void hideTabs() { -- cgit v1.2.3