summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-20 14:49:52 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-20 13:15:35 +0000
commit0308bf8b7b85ead586f21db82cd370c53fac46d6 (patch)
tree0b550ad3b68134b599c7a146723923f67e1d04cb /server/src/com/vaadin/ui
parent40e7287b82df23e9105f51b7ca086e93fb8903c5 (diff)
downloadvaadin-framework-0308bf8b7b85ead586f21db82cd370c53fac46d6.tar.gz
vaadin-framework-0308bf8b7b85ead586f21db82cd370c53fac46d6.zip
Moved isComponentVisible to separate interface (#10303)
HasComponents.isComponentVisible is now SelectiveRenderer.isRendered Change-Id: Ic3b9cd65278ffc2a38ee20c76ec771ee057268bf
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java3
-rw-r--r--server/src/com/vaadin/ui/AbstractComponentContainer.java11
-rw-r--r--server/src/com/vaadin/ui/AbstractSingleComponentContainer.java11
-rw-r--r--server/src/com/vaadin/ui/ConnectorTracker.java3
-rw-r--r--server/src/com/vaadin/ui/CustomField.java5
-rw-r--r--server/src/com/vaadin/ui/Form.java5
-rw-r--r--server/src/com/vaadin/ui/HasComponents.java19
-rw-r--r--server/src/com/vaadin/ui/SelectiveRenderer.java50
-rw-r--r--server/src/com/vaadin/ui/TabSheet.java4
-rw-r--r--server/src/com/vaadin/ui/Table.java5
10 files changed, 56 insertions, 60 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index fc6f176e2a..7e7a595a2e 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -349,7 +349,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
return false;
} else if (!super.isConnectorEnabled()) {
return false;
- } else if (!getParent().isComponentVisible(this)) {
+ } else if ((getParent() instanceof SelectiveRenderer)
+ && !((SelectiveRenderer) getParent()).isRendered(this)) {
return false;
} else {
return true;
diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java
index c60f312293..b5cc3da861 100644
--- a/server/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -343,15 +343,4 @@ public abstract class AbstractComponentContainer extends AbstractComponent
public Iterator<Component> getComponentIterator() {
return iterator();
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.ui.HasComponents#isComponentVisible(com.vaadin.ui.Component)
- */
- @Override
- public boolean isComponentVisible(Component childComponent) {
- return true;
- }
} \ No newline at end of file
diff --git a/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java b/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
index 20660ce955..7297318e95 100644
--- a/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
@@ -102,17 +102,6 @@ public abstract class AbstractSingleComponentContainer extends
fireEvent(new ComponentDetachEvent(this, component));
}
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.ui.HasComponents#isComponentVisible(com.vaadin.ui.Component)
- */
- @Override
- public boolean isComponentVisible(Component childComponent) {
- return true;
- }
-
@Override
public void setVisible(boolean visible) {
if (isVisible() == visible) {
diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java
index ddb02129d4..8b1a940c4b 100644
--- a/server/src/com/vaadin/ui/ConnectorTracker.java
+++ b/server/src/com/vaadin/ui/ConnectorTracker.java
@@ -247,7 +247,8 @@ public class ConnectorTracker implements Serializable {
uninitializedConnectors.remove(connector);
diffStates.remove(connector);
iterator.remove();
- } else if (!AbstractCommunicationManager.isVisible(connector)
+ } else if (!AbstractCommunicationManager
+ .isConnectorVisibleToClient(connector)
&& !uninitializedConnectors.contains(connector)) {
uninitializedConnectors.add(connector);
diffStates.remove(connector);
diff --git a/server/src/com/vaadin/ui/CustomField.java b/server/src/com/vaadin/ui/CustomField.java
index 23460d824e..c3331609a5 100644
--- a/server/src/com/vaadin/ui/CustomField.java
+++ b/server/src/com/vaadin/ui/CustomField.java
@@ -150,9 +150,4 @@ public abstract class CustomField<T> extends AbstractField<T> implements
public Iterator<Component> iterator() {
return new ComponentIterator();
}
-
- @Override
- public boolean isComponentVisible(Component childComponent) {
- return true;
- }
}
diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java
index 94a9f9b73a..62a6de4fe6 100644
--- a/server/src/com/vaadin/ui/Form.java
+++ b/server/src/com/vaadin/ui/Form.java
@@ -1375,11 +1375,6 @@ public class Form extends AbstractField<Object> implements Item.Editor,
}
@Override
- public boolean isComponentVisible(Component childComponent) {
- return true;
- };
-
- @Override
public void setVisible(boolean visible) {
if (isVisible() == visible) {
return;
diff --git a/server/src/com/vaadin/ui/HasComponents.java b/server/src/com/vaadin/ui/HasComponents.java
index 4f6320f6b2..d2ca45fa42 100644
--- a/server/src/com/vaadin/ui/HasComponents.java
+++ b/server/src/com/vaadin/ui/HasComponents.java
@@ -41,25 +41,6 @@ public interface HasComponents extends Component, Iterable<Component> {
public Iterator<Component> iterator();
/**
- * 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);
-
- /**
* Interface for {@link HasComponents} implementations that support sending
* attach and detach events for components.
*
diff --git a/server/src/com/vaadin/ui/SelectiveRenderer.java b/server/src/com/vaadin/ui/SelectiveRenderer.java
new file mode 100644
index 0000000000..47fd9bf0ee
--- /dev/null
+++ b/server/src/com/vaadin/ui/SelectiveRenderer.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.ui;
+
+/**
+ * Interface implemented by {@link HasComponents} implementors that wish to
+ * dynamically be able to prevent given child components from reaching the
+ * client side.
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0
+ *
+ */
+public interface SelectiveRenderer extends HasComponents {
+ /**
+ * Checks if the child component should be rendered (sent to the client
+ * side). This method allows hiding a child component from updates and
+ * communication to and from the client. It is mostly useful for parents
+ * which show only a limited number of their children at any given time and
+ * want to allow updates only for the visible children (e.g. TabSheet has
+ * one tab open at a time).
+ * <p>
+ * This method can only prevent updates from reaching the client, not force
+ * child components to reach the client. If the child is set to visible,
+ * returning false will prevent the child from being sent to the client. If
+ * a child is set to invisible, this method has no effect.
+ * </p>
+ *
+ * @param childComponent
+ * The child component to check
+ * @return true if the child component may be sent to the client, false
+ * otherwise
+ */
+ public boolean isRendered(Component childComponent);
+
+}
diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java
index 227743e9f4..1a76aa88bc 100644
--- a/server/src/com/vaadin/ui/TabSheet.java
+++ b/server/src/com/vaadin/ui/TabSheet.java
@@ -70,7 +70,7 @@ import com.vaadin.ui.themes.Runo;
* @since 3.0
*/
public class TabSheet extends AbstractComponentContainer implements Focusable,
- FocusNotifier, BlurNotifier, LegacyComponent {
+ FocusNotifier, BlurNotifier, LegacyComponent, SelectiveRenderer {
/**
* List of component tabs (tab contents). In addition to being on this list,
@@ -1290,7 +1290,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
}
@Override
- public boolean isComponentVisible(Component childComponent) {
+ public boolean isRendered(Component childComponent) {
return childComponent == getSelectedTab();
}
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 352b9212a7..f224e13dfd 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -5579,11 +5579,6 @@ public class Table extends AbstractSelect implements Action.Container,
return iterator();
}
- @Override
- public boolean isComponentVisible(Component childComponent) {
- return true;
- }
-
private final Logger getLogger() {
if (logger == null) {
logger = Logger.getLogger(Table.class.getName());