]> source.dussan.org Git - vaadin-framework.git/commitdiff
relocated utility method
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 10 Dec 2007 10:32:36 +0000 (10:32 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 10 Dec 2007 10:32:36 +0000 (10:32 +0000)
svn changeset:3200/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
src/com/itmill/toolkit/terminal/gwt/client/Util.java

index e04ddc6ae94905565213b15e626f1955caa1b26d..923dbab3d6282f752f37f0d596e086edbf92e063 100755 (executable)
@@ -425,17 +425,6 @@ public class ApplicationConnection {
                 immediate, 'a');
     }
 
-    public static Container getParentLayout(Widget component) {
-        Widget parent = component.getParent();
-        while (parent != null && !(parent instanceof Container)) {
-            parent = parent.getParent();
-        }
-        if (parent != null && ((Container) parent).hasChildComponent(component)) {
-            return (Container) parent;
-        }
-        return null;
-    }
-
     /**
      * Update generic component features.
      * 
@@ -487,7 +476,7 @@ public class ApplicationConnection {
         component.setVisible(visible);
         // Set captions
         if (manageCaption) {
-            final Container parent = getParentLayout(component);
+            final Container parent = Util.getParentLayout(component);
             if (parent != null) {
                 parent.updateCaption((Paintable) component, uidl);
             }
@@ -499,7 +488,7 @@ public class ApplicationConnection {
 
         // Switch to correct implementation if needed
         if (!widgetSet.isCorrectImplementation(component, uidl)) {
-            final Container parent = getParentLayout(component);
+            final Container parent = Util.getParentLayout(component);
             if (parent != null) {
                 final Widget w = widgetSet.createWidget(uidl);
                 parent.replaceChildComponent(component, w);
index be75d449b6bf4df7e1211d35087b0a3f816c2170..4e1e125a876620fd4002088ebc08764e709b30f0 100644 (file)
@@ -19,9 +19,9 @@ public class Util {
      * 
      */
     public static native void browserDebugger() /*-{
-                               if(window.console)
-                                       debugger;
-                         }-*/;
+                                       if(window.console)
+                                               debugger;
+                               }-*/;
 
     /**
      * Detects if current browser is IE.
@@ -29,12 +29,12 @@ public class Util {
      * @return true if IE
      */
     public static native boolean isIE() /*-{
-                               var browser=$wnd.navigator.appName;
-                               if (browser=="Microsoft Internet Explorer") {
-                                       return true;
-                               }
-                               return false;
-                         }-*/;
+                                       var browser=$wnd.navigator.appName;
+                                       if (browser=="Microsoft Internet Explorer") {
+                                               return true;
+                                       }
+                                       return false;
+                               }-*/;
 
     /**
      * Detects if current browser is IE6.
@@ -42,16 +42,16 @@ public class Util {
      * @return true if IE6
      */
     public static native boolean isIE6() /*-{
-                               var browser=$wnd.navigator.appName;
-                               if (browser=="Microsoft Internet Explorer") {
-                                       var ua = navigator.userAgent;
-                                       var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
-                                       if (re.exec(ua) != null)
-                                       rv = parseFloat(RegExp.$1);
-                                       if(rv == 6) return true;
-                               }
-                               return false;
-                         }-*/;
+                                       var browser=$wnd.navigator.appName;
+                                       if (browser=="Microsoft Internet Explorer") {
+                                               var ua = navigator.userAgent;
+                                               var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+                                               if (re.exec(ua) != null)
+                                               rv = parseFloat(RegExp.$1);
+                                               if(rv == 6) return true;
+                                       }
+                                       return false;
+                               }-*/;
 
     /**
      * Nulls oncontextmenu function on given element. We need to manually clear
@@ -61,8 +61,8 @@ public class Util {
      * @param el
      */
     public native static void removeContextMenuEvent(Element el) /*-{
-                               el.oncontextmenu = null;
-                         }-*/;
+                                       el.oncontextmenu = null;
+                               }-*/;
 
     /**
      * Traverses recursively ancestors until ContainerResizedListener child
@@ -82,4 +82,22 @@ public class Util {
             }
         }
     }
+
+    /**
+     * Returns closest parent Widget in hierarchy that implements Container
+     * interface
+     * 
+     * @param component
+     * @return closest parent Container
+     */
+    public static Container getParentLayout(Widget component) {
+        Widget parent = component.getParent();
+        while (parent != null && !(parent instanceof Container)) {
+            parent = parent.getParent();
+        }
+        if (parent != null && ((Container) parent).hasChildComponent(component)) {
+            return (Container) parent;
+        }
+        return null;
+    }
 }