diff options
author | Artur Signell <artur@vaadin.com> | 2012-03-14 14:36:19 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-03-14 16:01:19 +0200 |
commit | 3256e0421d03e548f124a22cfabfe50406a11ac1 (patch) | |
tree | 18d1ba8887486be25ccee62d55f936d6fcf302ff /src/com | |
parent | d9fffe6ac9aba3474ffe1e5f89957180ae2d472b (diff) | |
download | vaadin-framework-3256e0421d03e548f124a22cfabfe50406a11ac1.tar.gz vaadin-framework-3256e0421d03e548f124a22cfabfe50406a11ac1.zip |
Made TabSheet work again and removed TabSheet tab caching for now
(part 2)
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/vaadin/ui/TabSheet.java | 42 |
1 files changed, 27 insertions, 15 deletions
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,23 +569,35 @@ 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 * visible and enabled tab is selected if the current selection is empty or @@ -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); |