You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/02/08 23:45:40 UTC

svn commit: r907834 - in /pivot/trunk: wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java wtk/src/org/apache/pivot/wtk/Component.java

Author: gbrown
Date: Mon Feb  8 22:45:40 2010
New Revision: 907834

URL: http://svn.apache.org/viewvc?rev=907834&view=rev
Log:
Add a getAncestor(Class<? extends Container>):Container method to Component; delegate getWindow() and getDisplay() to this method.

Modified:
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java?rev=907834&r1=907833&r2=907834&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java Mon Feb  8 22:45:40 2010
@@ -332,7 +332,7 @@
             thumb.setLocation((int)((width - thumbWidth) * ratio), (height - thumbHeight) / 2);
         } else {
             thumb.setSize(thumbHeight, thumbWidth);
-            
+
             thumb.setLocation((width - thumbHeight) / 2, (int)((height - thumbWidth) * ratio));
         }
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=907834&r1=907833&r2=907834&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Mon Feb  8 22:45:40 2010
@@ -804,25 +804,22 @@
     }
 
     public Window getWindow() {
-        Component component = this;
-
-        while (component != null
-            && !(component instanceof Window)) {
-            component = component.getParent();
-        }
-
-        return (Window)component;
+        return (Window)getAncestor(Window.class);
     }
 
     public Display getDisplay() {
+        return (Display)getAncestor(Display.class);
+    }
+
+    public Container getAncestor(Class<? extends Container> ancestorType) {
         Component component = this;
 
         while (component != null
-            && !(component instanceof Display)) {
+            && !(ancestorType.isInstance(component))) {
             component = component.getParent();
         }
 
-        return (Display)component;
+        return (Container)component;
     }
 
     @Override