aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/gwt/client/Util.java
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2011-05-02 15:12:40 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2011-05-02 15:12:40 +0000
commit22e8f6cd84772760cda21baf67d68268523d6614 (patch)
tree2f8d5be5e0fbb3fe7daf52dd8521a6d044089453 /src/com/vaadin/terminal/gwt/client/Util.java
parent1f57e05dbf8378216d5c411201877be08d3dc27c (diff)
downloadvaadin-framework-22e8f6cd84772760cda21baf67d68268523d6614.tar.gz
vaadin-framework-22e8f6cd84772760cda21baf67d68268523d6614.zip
maybe fixes #6834 (can't reproduce as described, but this fixes an other related (possibly same) issue with Firefox 4)
svn changeset:18588/svn branch:6.6
Diffstat (limited to 'src/com/vaadin/terminal/gwt/client/Util.java')
-rw-r--r--src/com/vaadin/terminal/gwt/client/Util.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java
index e6819efc44..70af13bd4b 100644
--- a/src/com/vaadin/terminal/gwt/client/Util.java
+++ b/src/com/vaadin/terminal/gwt/client/Util.java
@@ -1202,4 +1202,39 @@ public class Util {
return null;
}-*/
;
+
+ /**
+ * Kind of stronger version of isAttached(). In addition to std isAttached,
+ * this method checks that this widget nor any of its parents is hidden. Can
+ * be e.g used to check whether component should react to some events or
+ * not.
+ *
+ * @param widget
+ * @return true if attached and displayed
+ */
+ public static boolean isAttachedAndDisplayed(Widget widget) {
+ if (widget.isAttached()) {
+ /*
+ * Failfast using offset size, then by iterating the widget tree
+ */
+ boolean notZeroSized = widget.getOffsetHeight() > 0
+ || widget.getOffsetWidth() > 0;
+ return notZeroSized || checkVisibilityRecursively(widget);
+ } else {
+ return false;
+ }
+ }
+
+ private static boolean checkVisibilityRecursively(Widget widget) {
+ if (widget.isVisible()) {
+ Widget parent = widget.getParent();
+ if (parent == null) {
+ return true; // root panel
+ } else {
+ return checkVisibilityRecursively(parent);
+ }
+ } else {
+ return false;
+ }
+ }
}