aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-03-20 14:43:24 +0200
committerArtur Signell <artur@vaadin.com>2012-03-21 15:28:05 +0200
commitbd4f8df793edef2dffdf3365e859979e5a86280d (patch)
tree49d2df4296aaae6bcb365d663b11d57ce2bcb238
parent068c74b31b4120d32267c5380d78d826aff0ca23 (diff)
downloadvaadin-framework-bd4f8df793edef2dffdf3365e859979e5a86280d.tar.gz
vaadin-framework-bd4f8df793edef2dffdf3365e859979e5a86280d.zip
Added requestRepaintall helper to AbstractComponentContainer and use the
same helper and logic in all component containers including Form, Table and CustomField
-rw-r--r--src/com/vaadin/ui/AbstractComponentContainer.java27
-rw-r--r--src/com/vaadin/ui/ComponentContainer.java9
-rw-r--r--src/com/vaadin/ui/CustomField.java20
-rw-r--r--src/com/vaadin/ui/Form.java4
-rw-r--r--src/com/vaadin/ui/HasComponents.java9
-rw-r--r--src/com/vaadin/ui/Table.java21
6 files changed, 33 insertions, 57 deletions
diff --git a/src/com/vaadin/ui/AbstractComponentContainer.java b/src/com/vaadin/ui/AbstractComponentContainer.java
index 66e7c18047..b597451a57 100644
--- a/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -367,18 +367,23 @@ public abstract class AbstractComponentContainer extends AbstractComponent
}
public void requestRepaintAll() {
- requestRepaint();
- for (Iterator<Component> childIterator = getComponentIterator(); childIterator
- .hasNext();) {
+ requestRepaintAll(this);
+ }
+
+ /**
+ * Helper that implements the logic needed by requestRepaintAll. Calls
+ * requestRepaintAll/requestRepaint for the component container and all its
+ * children recursively.
+ *
+ * @param container
+ */
+ public static void requestRepaintAll(HasComponents container) {
+ container.requestRepaint();
+ for (Iterator<Component> childIterator = container
+ .getComponentIterator(); childIterator.hasNext();) {
Component c = childIterator.next();
- if (c instanceof Form) {
- // Form has children in layout, but is not ComponentContainer
- c.requestRepaint();
- ((Form) c).getLayout().requestRepaintAll();
- } else if (c instanceof Table) {
- ((Table) c).requestRepaintAll();
- } else if (c instanceof ComponentContainer) {
- ((ComponentContainer) c).requestRepaintAll();
+ if (c instanceof HasComponents) {
+ requestRepaintAll((HasComponents) c);
} else {
c.requestRepaint();
}
diff --git a/src/com/vaadin/ui/ComponentContainer.java b/src/com/vaadin/ui/ComponentContainer.java
index 9487d23ee0..8182d54b56 100644
--- a/src/com/vaadin/ui/ComponentContainer.java
+++ b/src/com/vaadin/ui/ComponentContainer.java
@@ -69,15 +69,6 @@ public interface ComponentContainer extends HasComponents {
public int getComponentCount();
/**
- * Causes a repaint of this component, and all components below it.
- *
- * This should only be used in special cases, e.g when the state of a
- * descendant depends on the state of a ancestor.
- *
- */
- public void requestRepaintAll();
-
- /**
* Moves all components from an another container into this container. The
* components are removed from <code>source</code>.
*
diff --git a/src/com/vaadin/ui/CustomField.java b/src/com/vaadin/ui/CustomField.java
index a462cccfb4..685092904a 100644
--- a/src/com/vaadin/ui/CustomField.java
+++ b/src/com/vaadin/ui/CustomField.java
@@ -121,18 +121,6 @@ public abstract class CustomField<T> extends AbstractField<T> implements
*/
protected abstract Component initContent();
- private void requestContentRepaint() {
- if (getParent() == null) {
- // skip repaint - not yet attached
- return;
- }
- if (getContent() instanceof ComponentContainer) {
- ((ComponentContainer) getContent()).requestRepaintAll();
- } else {
- getContent().requestRepaint();
- }
- }
-
// Size related methods
// TODO might not be necessary to override but following the pattern from
// AbstractComponentContainer
@@ -140,13 +128,13 @@ public abstract class CustomField<T> extends AbstractField<T> implements
@Override
public void setHeight(float height, Unit unit) {
super.setHeight(height, unit);
- requestContentRepaint();
+ requestRepaintAll();
}
@Override
public void setWidth(float height, Unit unit) {
super.setWidth(height, unit);
- requestContentRepaint();
+ requestRepaintAll();
}
// ComponentContainer methods
@@ -182,9 +170,7 @@ public abstract class CustomField<T> extends AbstractField<T> implements
}
public void requestRepaintAll() {
- requestRepaint();
-
- requestContentRepaint();
+ AbstractComponentContainer.requestRepaintAll(this);
}
/**
diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java
index d66fae76ca..1abfefbc58 100644
--- a/src/com/vaadin/ui/Form.java
+++ b/src/com/vaadin/ui/Form.java
@@ -1417,6 +1417,10 @@ public class Form extends AbstractField<Object> implements Item.Editor,
return new ComponentIterator();
}
+ public void requestRepaintAll() {
+ AbstractComponentContainer.requestRepaintAll(this);
+ }
+
public int getComponentCount() {
int count = 0;
if (layout != null) {
diff --git a/src/com/vaadin/ui/HasComponents.java b/src/com/vaadin/ui/HasComponents.java
index de9e392b0d..eca89ddcd2 100644
--- a/src/com/vaadin/ui/HasComponents.java
+++ b/src/com/vaadin/ui/HasComponents.java
@@ -42,4 +42,13 @@ public interface HasComponents extends Component, Iterable<Component> {
* otherwise
*/
public boolean isComponentVisible(Component childComponent);
+
+ /**
+ * Causes a repaint of this component, and all components below it.
+ *
+ * This should only be used in special cases, e.g when the state of a
+ * descendant depends on the state of a ancestor.
+ */
+ public void requestRepaintAll();
+
}
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 079082cc25..32d67939e3 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -4460,27 +4460,8 @@ public class Table extends AbstractSelect implements Action.Container,
}
}
- // Virtually identical to AbstractCompoenentContainer.setEnabled();
public void requestRepaintAll() {
- requestRepaint();
- if (visibleComponents != null) {
- for (Iterator<Component> childIterator = visibleComponents
- .iterator(); childIterator.hasNext();) {
- Component c = childIterator.next();
- if (c instanceof Form) {
- // Form has children in layout, but is not
- // ComponentContainer
- c.requestRepaint();
- ((Form) c).getLayout().requestRepaintAll();
- } else if (c instanceof Table) {
- ((Table) c).requestRepaintAll();
- } else if (c instanceof ComponentContainer) {
- ((ComponentContainer) c).requestRepaintAll();
- } else {
- c.requestRepaint();
- }
- }
- }
+ AbstractComponentContainer.requestRepaintAll(this);
}
/**