summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/AbstractComponentContainer.java
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2012-11-13 18:08:29 +0200
committerArtur Signell <artur@vaadin.com>2012-11-13 18:18:40 +0200
commit391884746fda1781c55b13bc200dd75373f69141 (patch)
tree0d5a8dcd9d13c5c39813d81252506e12d72741af /server/src/com/vaadin/ui/AbstractComponentContainer.java
parent4628bcc3062ef19ed9d561f79fe3bfb3696d6e04 (diff)
downloadvaadin-framework-391884746fda1781c55b13bc200dd75373f69141.tar.gz
vaadin-framework-391884746fda1781c55b13bc200dd75373f69141.zip
UI based on AbstractBasicComponentContainer (#2924)
Change-Id: I1614a3464b8e7a0e9ecdd8c3a76335cdb85bdf87
Diffstat (limited to 'server/src/com/vaadin/ui/AbstractComponentContainer.java')
-rw-r--r--server/src/com/vaadin/ui/AbstractComponentContainer.java75
1 files changed, 18 insertions, 57 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java
index fdc753b57c..c60f312293 100644
--- a/server/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -16,7 +16,6 @@
package com.vaadin.ui;
-import java.lang.reflect.Method;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -83,32 +82,11 @@ public abstract class AbstractComponentContainer extends AbstractComponent
}
}
- /* Events */
-
- private static final Method COMPONENT_ATTACHED_METHOD;
-
- private static final Method COMPONENT_DETACHED_METHOD;
-
- static {
- try {
- COMPONENT_ATTACHED_METHOD = ComponentAttachListener.class
- .getDeclaredMethod("componentAttachedToContainer",
- new Class[] { ComponentAttachEvent.class });
- COMPONENT_DETACHED_METHOD = ComponentDetachListener.class
- .getDeclaredMethod("componentDetachedFromContainer",
- new Class[] { ComponentDetachEvent.class });
- } catch (final java.lang.NoSuchMethodException e) {
- // This should never happen
- throw new java.lang.RuntimeException(
- "Internal error finding methods in AbstractComponentContainer");
- }
- }
-
/* documented in interface */
@Override
public void addComponentAttachListener(ComponentAttachListener listener) {
- addListener(ComponentContainer.ComponentAttachEvent.class, listener,
- COMPONENT_ATTACHED_METHOD);
+ addListener(ComponentAttachEvent.class, listener,
+ ComponentAttachListener.attachMethod);
}
/**
@@ -123,9 +101,9 @@ public abstract class AbstractComponentContainer extends AbstractComponent
/* documented in interface */
@Override
- public void addComponentDetachListener(ComponentDetachListener listener) {
- addListener(ComponentContainer.ComponentDetachEvent.class, listener,
- COMPONENT_DETACHED_METHOD);
+ public void removeComponentAttachListener(ComponentAttachListener listener) {
+ removeListener(ComponentAttachEvent.class, listener,
+ ComponentAttachListener.attachMethod);
}
/**
@@ -140,9 +118,9 @@ public abstract class AbstractComponentContainer extends AbstractComponent
/* documented in interface */
@Override
- public void removeComponentAttachListener(ComponentAttachListener listener) {
- removeListener(ComponentContainer.ComponentAttachEvent.class, listener,
- COMPONENT_ATTACHED_METHOD);
+ public void addComponentDetachListener(ComponentDetachListener listener) {
+ addListener(ComponentDetachEvent.class, listener,
+ ComponentDetachListener.detachMethod);
}
/**
@@ -158,8 +136,8 @@ public abstract class AbstractComponentContainer extends AbstractComponent
/* documented in interface */
@Override
public void removeComponentDetachListener(ComponentDetachListener listener) {
- removeListener(ComponentContainer.ComponentDetachEvent.class, listener,
- COMPONENT_DETACHED_METHOD);
+ removeListener(ComponentDetachEvent.class, listener,
+ ComponentDetachListener.detachMethod);
}
/**
@@ -218,9 +196,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
if (c.getParent() != null) {
// If the component already has a parent, try to remove it
- ComponentContainer oldParent = (ComponentContainer) c.getParent();
- oldParent.removeComponent(c);
-
+ AbstractSingleComponentContainer.removeFromParent(c);
}
c.setParent(this);
@@ -250,7 +226,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
super.setVisible(visible);
// If the visibility state is toggled it might affect all children
- // aswell, e.g. make container visible should make children visible if
+ // as well, e.g. make container visible should make children visible if
// they were only hidden because the container was hidden.
markAsDirtyRecursive();
}
@@ -315,30 +291,15 @@ public abstract class AbstractComponentContainer extends AbstractComponent
private Collection<Component> getInvalidSizedChildren(final boolean vertical) {
HashSet<Component> components = null;
- if (this instanceof Panel) {
- Panel p = (Panel) this;
- ComponentContainer content = p.getContent();
+ for (Component component : this) {
boolean valid = vertical ? ComponentSizeValidator
- .checkHeights(content) : ComponentSizeValidator
- .checkWidths(content);
-
+ .checkHeights(component) : ComponentSizeValidator
+ .checkWidths(component);
if (!valid) {
- components = new HashSet<Component>(1);
- components.add(content);
- }
- } else {
- for (Iterator<Component> componentIterator = getComponentIterator(); componentIterator
- .hasNext();) {
- Component component = componentIterator.next();
- boolean valid = vertical ? ComponentSizeValidator
- .checkHeights(component) : ComponentSizeValidator
- .checkWidths(component);
- if (!valid) {
- if (components == null) {
- components = new HashSet<Component>();
- }
- components.add(component);
+ if (components == null) {
+ components = new HashSet<Component>();
}
+ components.add(component);
}
}
return components;