TabPanel now implements HasAnimation and its methods. TabPanel indirectly supports animations because it uses a DeckPanel, so all methods delegate to the DeckPanel. This is consistent with other widgets, such as Tree.
Patch by: jlabanca
Review by: ecc
Issue: 2495
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.5@3054 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/samples/showcase/src/com/google/gwt/sample/showcase/client/content/panels/CwTabPanel.java b/samples/showcase/src/com/google/gwt/sample/showcase/client/content/panels/CwTabPanel.java
index be505a5..356e88b 100644
--- a/samples/showcase/src/com/google/gwt/sample/showcase/client/content/panels/CwTabPanel.java
+++ b/samples/showcase/src/com/google/gwt/sample/showcase/client/content/panels/CwTabPanel.java
@@ -84,9 +84,7 @@
// Create a tab panel
DecoratedTabPanel tabPanel = new DecoratedTabPanel();
tabPanel.setWidth("400px");
-
- // Enable the deck panel animation
- tabPanel.getDeckPanel().setAnimationEnabled(true);
+ tabPanel.setAnimationEnabled(true);
// Add a home tab
String[] tabTitles = constants.cwTabPanelTabs();
diff --git a/user/src/com/google/gwt/user/client/ui/TabPanel.java b/user/src/com/google/gwt/user/client/ui/TabPanel.java
index e58f78a..3083eb2 100644
--- a/user/src/com/google/gwt/user/client/ui/TabPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/TabPanel.java
@@ -47,7 +47,7 @@
* </p>
*/
public class TabPanel extends Composite implements TabListener,
- SourcesTabEvents, HasWidgets, IndexedPanel {
+ SourcesTabEvents, HasWidgets, HasAnimation, IndexedPanel {
/**
* This extension of DeckPanel overrides the public mutator methods to prevent
* external callers from adding to the state of the DeckPanel.
@@ -325,6 +325,10 @@
insert(widget, tabText, false, beforeIndex);
}
+ public boolean isAnimationEnabled() {
+ return deck.isAnimationEnabled();
+ }
+
public Iterator<Widget> iterator() {
// The Iterator returned by DeckPanel supports removal and will invoke
// TabbedDeckPanel.remove(), which is an active function.
@@ -375,6 +379,10 @@
tabBar.selectTab(index);
}
+ public void setAnimationEnabled(boolean enable) {
+ deck.setAnimationEnabled(enable);
+ }
+
/**
* Create a {@link SimplePanel} that will wrap the contents in a tab.
* Subclasses can use this method to wrap tabs in decorator panels.
diff --git a/user/test/com/google/gwt/user/client/ui/TabPanelTest.java b/user/test/com/google/gwt/user/client/ui/TabPanelTest.java
index 5e3e166..a3a8bbd 100644
--- a/user/test/com/google/gwt/user/client/ui/TabPanelTest.java
+++ b/user/test/com/google/gwt/user/client/ui/TabPanelTest.java
@@ -37,6 +37,27 @@
return "com.google.gwt.user.DebugTest";
}
+ /**
+ * Test that methods associated with animations delegate to the
+ * {@link DeckPanel}.
+ */
+ public void testAnimationDelegation() {
+ TabPanel tabPanel = createTabPanel();
+ DeckPanel deck = tabPanel.getDeckPanel();
+
+ tabPanel.setAnimationEnabled(true);
+ assertTrue(tabPanel.isAnimationEnabled());
+ assertTrue(deck.isAnimationEnabled());
+
+ tabPanel.setAnimationEnabled(false);
+ assertFalse(tabPanel.isAnimationEnabled());
+ assertFalse(deck.isAnimationEnabled());
+
+ deck.setAnimationEnabled(true);
+ assertTrue(tabPanel.isAnimationEnabled());
+ assertTrue(deck.isAnimationEnabled());
+ }
+
public void testAttachDetachOrder() {
HasWidgetsTester.testAll(createTabPanel(), new Adder());
}