import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Component;
-import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.HasComponents;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Root;
JSONObject hierarchyInfo = new JSONObject();
for (Paintable p : hierarchyPendingQueue) {
- if (p instanceof ComponentContainer) {
- ComponentContainer cc = (ComponentContainer) p;
+ if (p instanceof HasComponents) {
+ HasComponents cc = (HasComponents) p;
String connectorId = paintableIdMap.get(cc);
JSONArray children = new JSONArray();
- Iterator<Component> iterator = getChildComponentIterator(cc);
- while (iterator.hasNext()) {
- Component child = iterator.next();
+ for (Component child : getChildComponents(cc)) {
if (child.getState().isVisible()) {
String childConnectorId = getPaintableId(child);
children.put(childConnectorId);
}
- private Iterator<Component> getChildComponentIterator(ComponentContainer cc) {
+ private Iterable<Component> getChildComponents(HasComponents cc) {
if (cc instanceof Panel) {
// This is so wrong.. (#2924)
if (((Panel) cc).getContent() == null) {
- return new NullIterator<Component>();
+ return Collections.emptyList();
} else {
- return Collections.singleton(
- (Component) ((Panel) cc).getContent()).iterator();
+ return Collections.singleton((Component) ((Panel) cc)
+ .getContent());
}
}
- return cc.getComponentIterator();
+ return cc;
}
/**
package com.vaadin.ui;
import java.io.Serializable;
-import java.util.Iterator;
/**
* Extension to the {@link Component} interface which adds to it the capacity to
* @VERSION@
* @since 3.0
*/
-public interface ComponentContainer extends Component {
+public interface ComponentContainer extends HasComponents {
/**
* Adds the component into this container.
*/
public void replaceComponent(Component oldComponent, Component newComponent);
- /**
- * Gets an iterator to the collection of contained components. Using this
- * iterator it is possible to step through all components contained in this
- * container.
- *
- * @return the component iterator.
- */
- public Iterator<Component> getComponentIterator();
-
/**
* Gets the number of children this {@link ComponentContainer} has. This
* must be symmetric with what {@link #getComponentIterator()} returns.
--- /dev/null
+package com.vaadin.ui;
+
+import java.util.Iterator;
+
+/**
+ * Interface that must be implemented by all {@link Component}s that contain
+ * other {@link Component}s.
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0.0
+ *
+ */
+public interface HasComponents extends Component, Iterable<Component> {
+ /**
+ * Gets an iterator to the collection of contained components. Using this
+ * iterator it is possible to step through all components contained in this
+ * container.
+ *
+ * @return the component iterator.
+ */
+ public Iterator<Component> getComponentIterator();
+
+}