Ensuring that DeckLayoutPanel properly attaches/detaches its layout when it is attached/detached from the DOM. Also changing other layout panels to attach/detach their layout implementation in onAttach/onDetach instead of onLoad/onUnload.
http://gwt-code-reviews.appspot.com/1615804
Author: tbroyer, stephen.haberman, jlabanca
Reviewed by: jlabanca
Issue: 7065
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10895 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/CustomScrollPanel.java b/user/src/com/google/gwt/user/client/ui/CustomScrollPanel.java
index dcb07dc..4f5a9b3 100644
--- a/user/src/com/google/gwt/user/client/ui/CustomScrollPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/CustomScrollPanel.java
@@ -435,17 +435,18 @@
protected void onAttach() {
super.onAttach();
containerResizeImpl.onAttach();
+ layout.onAttach();
}
@Override
protected void onDetach() {
super.onDetach();
containerResizeImpl.onDetach();
+ layout.onDetach();
}
@Override
protected void onLoad() {
- layout.onAttach();
hideNativeScrollbars();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
@@ -455,11 +456,6 @@
});
}
- @Override
- protected void onUnload() {
- layout.onDetach();
- }
-
/**
* Add a widget to the panel in the specified layer. Note that this method
* does not do the logical attach.
diff --git a/user/src/com/google/gwt/user/client/ui/DeckLayoutPanel.java b/user/src/com/google/gwt/user/client/ui/DeckLayoutPanel.java
index ed83651..a1db550 100644
--- a/user/src/com/google/gwt/user/client/ui/DeckLayoutPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/DeckLayoutPanel.java
@@ -54,6 +54,7 @@
@Override
public void schedule(int duration, final AnimationCallback callback) {
super.schedule(duration, new AnimationCallback() {
+ @Override
public void onAnimationComplete() {
DeckLayoutPanel.this.doAfterLayout();
if (callback != null) {
@@ -61,6 +62,7 @@
}
}
+ @Override
public void onLayout(Layer layer, double progress) {
if (callback != null) {
callback.onLayout(layer, progress);
@@ -97,14 +99,17 @@
insert(w, getWidgetCount());
}
+ @Override
public void animate(int duration) {
animate(duration, null);
}
+ @Override
public void animate(int duration, AnimationCallback callback) {
layoutCmd.schedule(duration, callback);
}
+ @Override
public void forceLayout() {
layoutCmd.cancel();
doBeforeLayout();
@@ -140,10 +145,12 @@
return getWidgetIndex(visibleWidget);
}
+ @Override
public void insert(IsWidget w, int beforeIndex) {
insert(asWidgetOrNull(w), beforeIndex);
}
+ @Override
public void insert(Widget widget, int beforeIndex) {
Widget before = (beforeIndex < getWidgetCount()) ? getWidget(beforeIndex)
: null;
@@ -197,6 +204,7 @@
return isAnimationVertical;
}
+ @Override
public void onResize() {
for (Widget child : getChildren()) {
if (child instanceof RequiresResize) {
@@ -251,6 +259,7 @@
*
* @param w the widget to show, and add if not a child
*/
+ @Override
public void setWidget(IsWidget w) {
// Hide the currently visible widget.
if (w == null) {
@@ -294,6 +303,18 @@
animate((widget == null) ? 0 : animationDuration);
}
+ @Override
+ protected void onAttach() {
+ super.onAttach();
+ layout.onAttach();
+ }
+
+ @Override
+ protected void onDetach() {
+ super.onDetach();
+ layout.onDetach();
+ }
+
/**
* Assert that the specified widget is null or a child of this widget.
*
diff --git a/user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java b/user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
index fcf6dab..29ef48e 100644
--- a/user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
@@ -248,14 +248,17 @@
this.addWest(widget.asWidget(), size);
}
+ @Override
public void animate(int duration) {
animate(duration, null);
}
+ @Override
public void animate(int duration, final Layout.AnimationCallback callback) {
layoutCmd.schedule(duration, callback);
}
+ @Override
public void forceLayout() {
layoutCmd.cancel();
doLayout();
@@ -369,6 +372,7 @@
insert(widget, Direction.WEST, size, before);
}
+ @Override
public void onResize() {
for (Widget child : getChildren()) {
if (child instanceof RequiresResize) {
@@ -503,12 +507,14 @@
}
@Override
- protected void onLoad() {
+ protected void onAttach() {
+ super.onAttach();
layout.onAttach();
}
@Override
- protected void onUnload() {
+ protected void onDetach() {
+ super.onDetach();
layout.onDetach();
}
diff --git a/user/src/com/google/gwt/user/client/ui/LayoutPanel.java b/user/src/com/google/gwt/user/client/ui/LayoutPanel.java
index be65129..2c61be3 100644
--- a/user/src/com/google/gwt/user/client/ui/LayoutPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/LayoutPanel.java
@@ -134,14 +134,17 @@
insert(widget, getWidgetCount());
}
+ @Override
public void animate(int duration) {
animate(duration, null);
}
+ @Override
public void animate(final int duration, final AnimationCallback callback) {
layoutCmd.schedule(duration, callback);
}
+ @Override
public void forceLayout() {
layoutCmd.cancel();
layout.layout();
@@ -197,6 +200,7 @@
animate(0);
}
+ @Override
public void onResize() {
for (Widget child : getChildren()) {
if (child instanceof RequiresResize) {
@@ -410,12 +414,14 @@
}
@Override
- protected void onLoad() {
+ protected void onAttach() {
+ super.onAttach();
layout.onAttach();
}
@Override
- protected void onUnload() {
+ protected void onDetach() {
+ super.onDetach();
layout.onDetach();
}
diff --git a/user/src/com/google/gwt/user/client/ui/SimpleLayoutPanel.java b/user/src/com/google/gwt/user/client/ui/SimpleLayoutPanel.java
index 66bd402..62ba9b1 100644
--- a/user/src/com/google/gwt/user/client/ui/SimpleLayoutPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/SimpleLayoutPanel.java
@@ -32,6 +32,7 @@
layout = new Layout(getElement());
}
+ @Override
public void onResize() {
if (widget instanceof RequiresResize) {
((RequiresResize) widget).onResize();
@@ -94,12 +95,14 @@
}
@Override
- protected void onLoad() {
+ protected void onAttach() {
+ super.onAttach();
layout.onAttach();
}
@Override
- protected void onUnload() {
+ protected void onDetach() {
+ super.onDetach();
layout.onDetach();
}
}