Allow ViewSite subclasses to be notified of view swaps
This way an extension of a ViewSite can do magic, like update the
window's title upon the change of the view within the view site.
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gwtexpui/user/client/ViewSite.java b/src/main/java/com/google/gwtexpui/user/client/ViewSite.java
index d8c6b60..c80e22f 100644
--- a/src/main/java/com/google/gwtexpui/user/client/ViewSite.java
+++ b/src/main/java/com/google/gwtexpui/user/client/ViewSite.java
@@ -64,6 +64,15 @@
next.add(view);
}
+ /**
+ * Invoked after the view becomes the current view and has been made visible.
+ *
+ * @param view the view being displayed.
+ */
+ protected void onShowView(final V view) {
+ }
+
+ @SuppressWarnings("unchecked")
final void swap(final View v) {
if (next != null && next.getWidget() == v) {
if (current != null) {
@@ -72,6 +81,7 @@
current = next;
next = null;
current.setVisible(true);
+ onShowView((V) v);
}
}
}