summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/ui
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-12-14 12:32:15 +0000
committerArtur Signell <artur.signell@itmill.com>2009-12-14 12:32:15 +0000
commit23d56baff322c593436cc4db00661f401559e923 (patch)
tree06b38ea100c106cacf210e2d35740c80c85c4dca /src/com/vaadin/ui
parentb8358a67c01f9f7b46fd85ada9700334d12cfd82 (diff)
downloadvaadin-framework-23d56baff322c593436cc4db00661f401559e923.tar.gz
vaadin-framework-23d56baff322c593436cc4db00661f401559e923.zip
Added generics to ComponentContainer.getComponentIterator (#3717).
svn changeset:10281/svn branch:6.2
Diffstat (limited to 'src/com/vaadin/ui')
-rw-r--r--src/com/vaadin/ui/AbstractComponentContainer.java29
-rw-r--r--src/com/vaadin/ui/AbstractOrderedLayout.java2
-rw-r--r--src/com/vaadin/ui/ComponentContainer.java2
-rw-r--r--src/com/vaadin/ui/CssLayout.java2
-rw-r--r--src/com/vaadin/ui/CustomComponent.java8
-rw-r--r--src/com/vaadin/ui/CustomLayout.java22
-rw-r--r--src/com/vaadin/ui/GridLayout.java2
-rw-r--r--src/com/vaadin/ui/Panel.java2
-rw-r--r--src/com/vaadin/ui/SplitPanel.java6
9 files changed, 38 insertions, 37 deletions
diff --git a/src/com/vaadin/ui/AbstractComponentContainer.java b/src/com/vaadin/ui/AbstractComponentContainer.java
index 517dff14ac..f3e332961a 100644
--- a/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -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();
diff --git a/src/com/vaadin/ui/AbstractOrderedLayout.java b/src/com/vaadin/ui/AbstractOrderedLayout.java
index 04449bd7b8..123c5a8dc0 100644
--- a/src/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/src/com/vaadin/ui/AbstractOrderedLayout.java
@@ -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();
}
diff --git a/src/com/vaadin/ui/ComponentContainer.java b/src/com/vaadin/ui/ComponentContainer.java
index aa591c9742..fd938e584b 100644
--- a/src/com/vaadin/ui/ComponentContainer.java
+++ b/src/com/vaadin/ui/ComponentContainer.java
@@ -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.
diff --git a/src/com/vaadin/ui/CssLayout.java b/src/com/vaadin/ui/CssLayout.java
index e027636956..1093579cf3 100644
--- a/src/com/vaadin/ui/CssLayout.java
+++ b/src/com/vaadin/ui/CssLayout.java
@@ -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();
}
diff --git a/src/com/vaadin/ui/CustomComponent.java b/src/com/vaadin/ui/CustomComponent.java
index 5d086ddaf9..976775b8f3 100644
--- a/src/com/vaadin/ui/CustomComponent.java
+++ b/src/com/vaadin/ui/CustomComponent.java
@@ -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();
}
diff --git a/src/com/vaadin/ui/CustomLayout.java b/src/com/vaadin/ui/CustomLayout.java
index f0ad7514ea..0baa0dd468 100644
--- a/src/com/vaadin/ui/CustomLayout.java
+++ b/src/com/vaadin/ui/CustomLayout.java
@@ -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;
}
diff --git a/src/com/vaadin/ui/GridLayout.java b/src/com/vaadin/ui/GridLayout.java
index 778b9b42ca..f1195e9ef4 100644
--- a/src/com/vaadin/ui/GridLayout.java
+++ b/src/com/vaadin/ui/GridLayout.java
@@ -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();
}
diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java
index d21de3d313..1fdbd21237 100644
--- a/src/com/vaadin/ui/Panel.java
+++ b/src/com/vaadin/ui/Panel.java
@@ -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();
}
diff --git a/src/com/vaadin/ui/SplitPanel.java b/src/com/vaadin/ui/SplitPanel.java
index 17bc0b64c1..916c8bb5cc 100644
--- a/src/com/vaadin/ui/SplitPanel.java
+++ b/src/com/vaadin/ui/SplitPanel.java
@@ -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;
}