From: Artur Signell Date: Wed, 14 Mar 2012 12:36:19 +0000 (+0200) Subject: Made TabSheet work again and removed TabSheet tab caching for now X-Git-Tag: 7.0.0.alpha2~324 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3256e0421d03e548f124a22cfabfe50406a11ac1;p=vaadin-framework.git Made TabSheet work again and removed TabSheet tab caching for now (part 2) --- diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index 59f3386732..d614832cd2 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -152,7 +152,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, tabs.remove(c); if (c.equals(selected)) { if (components.isEmpty()) { - selected = null; + setSelected(null); } else { // select the first enabled and visible tab, if any updateSelection(); @@ -279,7 +279,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, tabs.put(c, tab); if (selected == null) { - selected = c; + setSelected(c); fireSelectedTabChange(); } super.addComponent(c); @@ -569,22 +569,34 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, */ public void setSelectedTab(Component c) { if (c != null && components.contains(c) && !c.equals(selected)) { - selected = c; + setSelected(c); updateSelection(); fireSelectedTabChange(); requestRepaint(); - // Repaint of the selected component is needed as only the selected - // component is communicated to the client. Otherwise this will be a - // "cached" update even though the client knows nothing about the - // connector - if (selected instanceof ComponentContainer) { - ((ComponentContainer) selected).requestRepaintAll(); - } else { - selected.requestRepaint(); - } } } + /** + * Sets the selected tab in the TabSheet. Ensures that the selected tab is + * repainted if needed. + * + * @param c + * The new selection or null for no selection + */ + private void setSelected(Component c) { + selected = c; + // Repaint of the selected component is needed as only the selected + // component is communicated to the client. Otherwise this will be a + // "cached" update even though the client knows nothing about the + // connector + if (selected instanceof ComponentContainer) { + ((ComponentContainer) selected).requestRepaintAll(); + } else if (selected != null) { + selected.requestRepaint(); + } + + } + /** * Checks if the current selection is valid, and updates the selection if * the previously selected component is not visible and enabled. The first @@ -619,14 +631,14 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, // The current selection is not valid so we need to change // it if (tab.isEnabled() && tab.isVisible()) { - selected = component; + setSelected(component); break; } else { /* * The current selection is not valid but this tab cannot be * selected either. */ - selected = null; + setSelected(null); } } } @@ -685,7 +697,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, if (selected == oldComponent) { // keep selection w/o selectedTabChange event - selected = newComponent; + setSelected(newComponent); } Tab newTab = tabs.get(newComponent);