]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added generics to ComponentContainer.getComponentIterator (#3717).
authorArtur Signell <artur.signell@itmill.com>
Mon, 14 Dec 2009 12:32:15 +0000 (12:32 +0000)
committerArtur Signell <artur.signell@itmill.com>
Mon, 14 Dec 2009 12:32:15 +0000 (12:32 +0000)
svn changeset:10281/svn branch:6.2

src/com/vaadin/ui/AbstractComponentContainer.java
src/com/vaadin/ui/AbstractOrderedLayout.java
src/com/vaadin/ui/ComponentContainer.java
src/com/vaadin/ui/CssLayout.java
src/com/vaadin/ui/CustomComponent.java
src/com/vaadin/ui/CustomLayout.java
src/com/vaadin/ui/GridLayout.java
src/com/vaadin/ui/Panel.java
src/com/vaadin/ui/SplitPanel.java

index 517dff14ac957f76830b9953e6d7b534dc3ea032..f3e332961a335e9df3e4aaa5e2eac85fea5f6224 100644 (file)
@@ -35,16 +35,16 @@ public abstract class AbstractComponentContainer extends AbstractComponent
      * re-implemented in extending classes for a more powerful implementation.
      */
     public void removeAllComponents() {
-        final LinkedList l = new LinkedList();
+        final LinkedList<Component> l = new LinkedList<Component>();
 
         // Adds all components
-        for (final Iterator i = getComponentIterator(); i.hasNext();) {
+        for (final Iterator<Component> i = getComponentIterator(); i.hasNext();) {
             l.add(i.next());
         }
 
         // Removes all component
-        for (final Iterator i = l.iterator(); i.hasNext();) {
-            removeComponent((Component) i.next());
+        for (final Iterator<Component> i = l.iterator(); i.hasNext();) {
+            removeComponent(i.next());
         }
     }
 
@@ -54,13 +54,14 @@ public abstract class AbstractComponentContainer extends AbstractComponent
      * implemented interface.
      */
     public void moveComponentsFrom(ComponentContainer source) {
-        final LinkedList components = new LinkedList();
-        for (final Iterator i = source.getComponentIterator(); i.hasNext();) {
+        final LinkedList<Component> components = new LinkedList<Component>();
+        for (final Iterator<Component> i = source.getComponentIterator(); i
+                .hasNext();) {
             components.add(i.next());
         }
 
-        for (final Iterator i = components.iterator(); i.hasNext();) {
-            final Component c = (Component) i.next();
+        for (final Iterator<Component> i = components.iterator(); i.hasNext();) {
+            final Component c = i.next();
             source.removeComponent(c);
             addComponent(c);
         }
@@ -76,8 +77,8 @@ public abstract class AbstractComponentContainer extends AbstractComponent
     public void attach() {
         super.attach();
 
-        for (final Iterator i = getComponentIterator(); i.hasNext();) {
-            ((Component) i.next()).attach();
+        for (final Iterator<Component> i = getComponentIterator(); i.hasNext();) {
+            (i.next()).attach();
         }
     }
 
@@ -91,8 +92,8 @@ public abstract class AbstractComponentContainer extends AbstractComponent
     public void detach() {
         super.detach();
 
-        for (final Iterator i = getComponentIterator(); i.hasNext();) {
-            ((Component) i.next()).detach();
+        for (final Iterator<Component> i = getComponentIterator(); i.hasNext();) {
+            (i.next()).detach();
         }
     }
 
@@ -254,9 +255,9 @@ public abstract class AbstractComponentContainer extends AbstractComponent
 
     public void requestRepaintAll() {
         requestRepaint();
-        for (Iterator childIterator = getComponentIterator(); childIterator
+        for (Iterator<Component> childIterator = getComponentIterator(); childIterator
                 .hasNext();) {
-            Component c = (Component) childIterator.next();
+            Component c = childIterator.next();
             if (c instanceof Form) {
                 // Form has children in layout, but is not ComponentContainer
                 c.requestRepaint();
index 04449bd7b8d958d73b9b50a3644b425d2c6ae63e..123c5a8dc0c4ae4cbbaca0d15b2fb700c723dd5b 100644 (file)
@@ -107,7 +107,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
      * 
      * @return the Iterator of the components inside the container.
      */
-    public Iterator getComponentIterator() {
+    public Iterator<Component> getComponentIterator() {
         return components.iterator();
     }
 
index aa591c9742999c3c1757a29b58d21bb2b1182f4f..fd938e584b02df7bcaa36ec1a05da45be264b63b 100644 (file)
@@ -67,7 +67,7 @@ public interface ComponentContainer extends Component {
      * 
      * @return the component iterator.
      */
-    public Iterator getComponentIterator();
+    public Iterator<Component> getComponentIterator();
 
     /**
      * Causes a repaint of this component, and all components below it.
index e0276369566004b1517c712d6f93270f79227a09..1093579cf328433adfa19fbf64eda57ccc5d5dc7 100644 (file)
@@ -127,7 +127,7 @@ public class CssLayout extends AbstractLayout {
      * 
      * @return the Iterator of the components inside the container.
      */
-    public Iterator getComponentIterator() {
+    public Iterator<Component> getComponentIterator() {
         return components.iterator();
     }
 
index 5d086ddaf9f4285915d797210ca33968ee2240d4..976775b8f3874844c0e6fb7fe37dc685fc22b0db 100644 (file)
@@ -145,14 +145,15 @@ public class CustomComponent extends AbstractComponentContainer {
         this.componentType = componentType;
     }
 
-    private class ComponentIterator implements Iterator, Serializable {
+    private class ComponentIterator implements Iterator<Component>,
+            Serializable {
         boolean first = getCompositionRoot() != null;
 
         public boolean hasNext() {
             return first;
         }
 
-        public Object next() {
+        public Component next() {
             first = false;
             return root;
         }
@@ -162,8 +163,7 @@ public class CustomComponent extends AbstractComponentContainer {
         }
     }
 
-    @SuppressWarnings("unchecked")
-    public Iterator getComponentIterator() {
+    public Iterator<Component> getComponentIterator() {
         return new ComponentIterator();
     }
 
index f0ad7514eae134b92d3884b2d122bd69e32e4be5..0baa0dd4682816e9192ae77f897750e2331e3523 100644 (file)
@@ -50,7 +50,7 @@ public class CustomLayout extends AbstractLayout {
     /**
      * Custom layout slots containing the components.
      */
-    private final HashMap slots = new HashMap();
+    private final HashMap<String, Component> slots = new HashMap<String, Component>();
 
     private String templateContents = null;
 
@@ -107,7 +107,7 @@ public class CustomLayout extends AbstractLayout {
      *            the location of the component.
      */
     public void addComponent(Component c, String location) {
-        final Component old = (Component) slots.get(location);
+        final Component old = slots.get(location);
         if (old != null) {
             removeComponent(old);
         }
@@ -155,7 +155,7 @@ public class CustomLayout extends AbstractLayout {
      *            the Location identifier of the component.
      */
     public void removeComponent(String location) {
-        this.removeComponent((Component) slots.get(location));
+        this.removeComponent(slots.get(location));
     }
 
     /**
@@ -164,7 +164,7 @@ public class CustomLayout extends AbstractLayout {
      * 
      * @return the Iterator of the components inside the container.
      */
-    public Iterator getComponentIterator() {
+    public Iterator<Component> getComponentIterator() {
         return slots.values().iterator();
     }
 
@@ -177,7 +177,7 @@ public class CustomLayout extends AbstractLayout {
      * @return the Component in the given location or null if not found.
      */
     public Component getComponent(String location) {
-        return (Component) slots.get(location);
+        return slots.get(location);
     }
 
     /**
@@ -197,10 +197,10 @@ public class CustomLayout extends AbstractLayout {
             target.addAttribute("templateContents", templateContents);
         }
         // Adds all items in all the locations
-        for (final Iterator i = slots.keySet().iterator(); i.hasNext();) {
+        for (final Iterator<String> i = slots.keySet().iterator(); i.hasNext();) {
             // Gets the (location,component)
-            final String location = (String) i.next();
-            final Component c = (Component) slots.get(location);
+            final String location = i.next();
+            final Component c = slots.get(location);
             if (c != null) {
                 // Writes the item
                 target.startTag("location");
@@ -217,9 +217,9 @@ public class CustomLayout extends AbstractLayout {
         // Gets the locations
         String oldLocation = null;
         String newLocation = null;
-        for (final Iterator i = slots.keySet().iterator(); i.hasNext();) {
-            final String location = (String) i.next();
-            final Component component = (Component) slots.get(location);
+        for (final Iterator<String> i = slots.keySet().iterator(); i.hasNext();) {
+            final String location = i.next();
+            final Component component = slots.get(location);
             if (component == oldComponent) {
                 oldLocation = location;
             }
index 778b9b42cab0048e8785856c5c4a6e29ee69a9c6..f1195e9ef40df6b830011437c39d372b877b4fb0 100644 (file)
@@ -386,7 +386,7 @@ public class GridLayout extends AbstractLayout implements
      * 
      * @return the Iterator of the components inside the container.
      */
-    public Iterator getComponentIterator() {
+    public Iterator<Component> getComponentIterator() {
         return Collections.unmodifiableCollection(components).iterator();
     }
 
index d21de3d31322eda527b029563e3ecd50f54eb8c4..1fdbd21237994fe945ba49eefdd4e26da906ea46 100644 (file)
@@ -316,7 +316,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
      * @return the Iterator of the components inside the container.
      * @see com.vaadin.ui.ComponentContainer#getComponentIterator()
      */
-    public Iterator getComponentIterator() {
+    public Iterator<Component> getComponentIterator() {
         return content.getComponentIterator();
     }
 
index 17bc0b64c108c788e361d5727785e536c030c7a1..916c8bb5cc3a674816578807029762c43e857cb4 100644 (file)
@@ -159,8 +159,8 @@ public class SplitPanel extends AbstractLayout {
      * 
      * @return the Iterator of the components inside the container.
      */
-    public Iterator getComponentIterator() {
-        return new Iterator() {
+    public Iterator<Component> getComponentIterator() {
+        return new Iterator<Component>() {
             int i = 0;
 
             public boolean hasNext() {
@@ -171,7 +171,7 @@ public class SplitPanel extends AbstractLayout {
                 return false;
             }
 
-            public Object next() {
+            public Component next() {
                 if (!hasNext()) {
                     return null;
                 }