* 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());
}
}
* 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);
}
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();
}
}
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();
}
}
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();
*
* @return the Iterator of the components inside the container.
*/
- public Iterator getComponentIterator() {
+ public Iterator<Component> getComponentIterator() {
return components.iterator();
}
*
* @return the component iterator.
*/
- public Iterator getComponentIterator();
+ public Iterator<Component> getComponentIterator();
/**
* Causes a repaint of this component, and all components below it.
*
* @return the Iterator of the components inside the container.
*/
- public Iterator getComponentIterator() {
+ public Iterator<Component> getComponentIterator() {
return components.iterator();
}
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;
}
}
}
- @SuppressWarnings("unchecked")
- public Iterator getComponentIterator() {
+ public Iterator<Component> getComponentIterator() {
return new ComponentIterator();
}
/**
* 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;
* 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);
}
* the Location identifier of the component.
*/
public void removeComponent(String location) {
- this.removeComponent((Component) slots.get(location));
+ this.removeComponent(slots.get(location));
}
/**
*
* @return the Iterator of the components inside the container.
*/
- public Iterator getComponentIterator() {
+ public Iterator<Component> getComponentIterator() {
return slots.values().iterator();
}
* @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);
}
/**
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");
// 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;
}
*
* @return the Iterator of the components inside the container.
*/
- public Iterator getComponentIterator() {
+ public Iterator<Component> getComponentIterator() {
return Collections.unmodifiableCollection(components).iterator();
}
* @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();
}
*
* @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() {
return false;
}
- public Object next() {
+ public Component next() {
if (!hasNext()) {
return null;
}