DeckPanel now calls setVisible(true) on the Widget that is currently being displayed so users can implement delayed rendering techniques in their widgets. This supports a legacy use case where users relied on setVisible being called.
Patch by: jlabanca
Review by: ecc (desk review, branch-info.txt not reviewed)
Issue: 2510
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.5@3056 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/branch-info.txt b/branch-info.txt
index 4cd6dd9..39be48d 100644
--- a/branch-info.txt
+++ b/branch-info.txt
@@ -47,3 +47,5 @@
- RPC bugfix related to implementing a parameterized interface (r3044)
- MenuBar animation exception when page refreshed while menus open (r3045)
- Showcase textual tweaks (r3046)
+- Add TabPanel.setAnimationEnabled method (r3054)
+- New Showcase locale icon (r3055)
diff --git a/user/src/com/google/gwt/user/client/ui/DeckPanel.java b/user/src/com/google/gwt/user/client/ui/DeckPanel.java
index 4ee7274..273edb5 100644
--- a/user/src/com/google/gwt/user/client/ui/DeckPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/DeckPanel.java
@@ -33,10 +33,10 @@
*/
public class DeckPanel extends ComplexPanel implements HasAnimation {
/**
- * The duration of the animation.
+ * The duration of the animation.
*/
private static final int ANIMATION_DURATION = 350;
-
+
/**
* An {@link Animation} used to slide in the new content.
*/
@@ -81,6 +81,7 @@
// If we aren't showing anything, don't bother with the animation
if (oldWidget == null) {
UIObject.setVisible(newContainer, true);
+ newWidget.setVisible(true);
return;
}
@@ -106,6 +107,12 @@
} else {
onInstantaneousRun();
}
+
+ // We call newWidget.setVisible(true) immediately after showing the
+ // widget's container so users can delay render their widget. Ultimately,
+ // we should have a better way of handling this, but we need to call
+ // setVisible for legacy support.
+ newWidget.setVisible(true);
}
@Override
diff --git a/user/test/com/google/gwt/user/client/ui/DeckPanelTest.java b/user/test/com/google/gwt/user/client/ui/DeckPanelTest.java
index c3f32e9..f9c1889 100644
--- a/user/test/com/google/gwt/user/client/ui/DeckPanelTest.java
+++ b/user/test/com/google/gwt/user/client/ui/DeckPanelTest.java
@@ -28,6 +28,61 @@
}
/**
+ * Test that the {@link DeckPanel} calls widget.setVisible(true) on the
+ * visible widget, but does NOT call widget.setVisible(false) when a widget is
+ * hidden.
+ */
+ public void testSetWidgetVisible() {
+ // Show a widget with animations disabled
+ {
+ DeckPanel deck = new DeckPanel();
+ deck.setAnimationEnabled(false);
+ Label[] labels = new Label[3];
+ for (int i = 0; i < labels.length; i++) {
+ labels[i] = new Label("content" + i);
+ labels[i].setVisible(false);
+ deck.add(labels[i]);
+ }
+
+ // Show widget at index 1, make sure it becomes visible
+ deck.showWidget(1);
+ assertFalse(labels[0].isVisible());
+ assertTrue(labels[1].isVisible());
+ assertFalse(labels[2].isVisible());
+
+ // Show widget at index 0, make sure widget 1 is still visible
+ deck.showWidget(0);
+ assertTrue(labels[0].isVisible());
+ assertTrue(labels[1].isVisible());
+ assertFalse(labels[2].isVisible());
+ }
+
+ // Show a widget with animations enabled
+ {
+ DeckPanel deck = new DeckPanel();
+ deck.setAnimationEnabled(true);
+ Label[] labels = new Label[3];
+ for (int i = 0; i < labels.length; i++) {
+ labels[i] = new Label("content" + i);
+ labels[i].setVisible(false);
+ deck.add(labels[i]);
+ }
+
+ // Show widget at index 1, make sure it becomes visible
+ deck.showWidget(1);
+ assertFalse(labels[0].isVisible());
+ assertTrue(labels[1].isVisible());
+ assertFalse(labels[2].isVisible());
+
+ // Show widget at index 0, make sure widget 1 is still visible
+ deck.showWidget(0);
+ assertTrue(labels[0].isVisible());
+ assertTrue(labels[1].isVisible());
+ assertFalse(labels[2].isVisible());
+ }
+ }
+
+ /**
* Test that the offsetHeight/Width of a widget are defined when the widget is
* added to the DeckPanel.
*/