aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-03-13 17:59:26 +0200
committerArtur Signell <artur@vaadin.com>2012-03-14 16:00:47 +0200
commit79871340bdcfc7eda7e2800966e2e62215154649 (patch)
treec815b76dd46409763899be6d60c45afb9483ed0c /src
parent7ab4e3ecf7ae25417f2b784f8afa5c18e330a428 (diff)
downloadvaadin-framework-79871340bdcfc7eda7e2800966e2e62215154649.tar.gz
vaadin-framework-79871340bdcfc7eda7e2800966e2e62215154649.zip
#8500 Allow component containers to hide their children even though
the children are visible. Allows Tabsheet to disallow updates to all tabs except the selected.
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java13
-rw-r--r--src/com/vaadin/ui/AbstractComponentContainer.java10
-rw-r--r--src/com/vaadin/ui/CustomField.java3
-rw-r--r--src/com/vaadin/ui/Form.java4
-rw-r--r--src/com/vaadin/ui/HasComponents.java18
-rw-r--r--src/com/vaadin/ui/TabSheet.java5
6 files changed, 47 insertions, 6 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 04f64ecaea..615112168b 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -946,22 +946,23 @@ public abstract class AbstractCommunicationManager implements
JSONObject hierarchyInfo = new JSONObject();
for (Paintable p : hierarchyPendingQueue) {
if (p instanceof HasComponents) {
- HasComponents cc = (HasComponents) p;
- String connectorId = paintableIdMap.get(cc);
+ HasComponents parent = (HasComponents) p;
+ String parentConnectorId = paintableIdMap.get(parent);
JSONArray children = new JSONArray();
- for (Component child : getChildComponents(cc)) {
- if (child.getState().isVisible()) {
+ for (Component child : getChildComponents(parent)) {
+ if (child.getState().isVisible()
+ && parent.isComponentVisible(child)) {
String childConnectorId = getPaintableId(child);
children.put(childConnectorId);
}
}
try {
- hierarchyInfo.put(connectorId, children);
+ hierarchyInfo.put(parentConnectorId, children);
} catch (JSONException e) {
throw new PaintException(
"Failed to send hierarchy information about "
- + connectorId + " to the client: "
+ + parentConnectorId + " to the client: "
+ e.getMessage());
}
}
diff --git a/src/com/vaadin/ui/AbstractComponentContainer.java b/src/com/vaadin/ui/AbstractComponentContainer.java
index 20b79e8a06..01b5a7ad4c 100644
--- a/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -382,4 +382,14 @@ public abstract class AbstractComponentContainer extends AbstractComponent
public Iterator<Component> iterator() {
return getComponentIterator();
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.ui.HasComponents#isComponentVisible(com.vaadin.ui.Component)
+ */
+ public boolean isComponentVisible(Component childComponent) {
+ return true;
+ }
} \ No newline at end of file
diff --git a/src/com/vaadin/ui/CustomField.java b/src/com/vaadin/ui/CustomField.java
index 5436cd0480..a462cccfb4 100644
--- a/src/com/vaadin/ui/CustomField.java
+++ b/src/com/vaadin/ui/CustomField.java
@@ -253,4 +253,7 @@ public abstract class CustomField<T> extends AbstractField<T> implements
// content never detached
}
+ public boolean isComponentVisible(Component childComponent) {
+ return true;
+ }
}
diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java
index c4ae0457a9..c39f043b21 100644
--- a/src/com/vaadin/ui/Form.java
+++ b/src/com/vaadin/ui/Form.java
@@ -1420,4 +1420,8 @@ public class Form extends AbstractField<Object> implements Item.Editor,
return count;
}
+
+ public boolean isComponentVisible(Component childComponent) {
+ return true;
+ };
}
diff --git a/src/com/vaadin/ui/HasComponents.java b/src/com/vaadin/ui/HasComponents.java
index e6f71fb3ed..af3d76ba9c 100644
--- a/src/com/vaadin/ui/HasComponents.java
+++ b/src/com/vaadin/ui/HasComponents.java
@@ -21,4 +21,22 @@ public interface HasComponents extends Component, Iterable<Component> {
*/
public Iterator<Component> getComponentIterator();
+ /**
+ * Checks if the child component is visible. This method allows hiding a
+ * child component from updates and communication to and from the client.
+ * This is useful for components that show only a limited number of its
+ * children at any given time and want to allow updates only for the
+ * children that are visible (e.g. TabSheet has one tab open at a time).
+ * <p>
+ * Note that this will prevent updates from reaching the child even though
+ * the child itself is set to visible. Also if a child is set to invisible
+ * this will not force it to be visible.
+ * </p>
+ *
+ * @param childComponent
+ * The child component to check
+ * @return true if the child component is visible to the user, false
+ * otherwise
+ */
+ public boolean isComponentVisible(Component childComponent);
}
diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java
index 89c363e554..96e9feb6d3 100644
--- a/src/com/vaadin/ui/TabSheet.java
+++ b/src/com/vaadin/ui/TabSheet.java
@@ -1286,4 +1286,9 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}
+
+ @Override
+ public boolean isComponentVisible(Component childComponent) {
+ return childComponent == getSelectedTab();
+ }
}