aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-28 18:03:47 +0200
committerArtur Signell <artur@vaadin.com>2012-11-28 18:03:47 +0200
commit7b0485a5838a070b971d91f8321d6bf6778c3f86 (patch)
tree22b8448b19da4499aa36ae3876c3406d04292174
parent57e82eff5ba7409b3a36f0a03448ee6e3c755d97 (diff)
downloadvaadin-framework-7b0485a5838a070b971d91f8321d6bf6778c3f86.tar.gz
vaadin-framework-7b0485a5838a070b971d91f8321d6bf6778c3f86.zip
Moved setVisible dirty logic to AbstractComponent where it belongs (#10414)
Change-Id: I05f8b739e862c3dd4a52492f2df41862bacd3ce4
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java9
-rw-r--r--server/src/com/vaadin/ui/AbstractComponentContainer.java13
-rw-r--r--server/src/com/vaadin/ui/AbstractSingleComponentContainer.java13
-rw-r--r--server/src/com/vaadin/ui/Form.java13
-rw-r--r--uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html47
-rw-r--r--uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java60
6 files changed, 115 insertions, 40 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index 876a6c482d..63cf19283f 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -401,7 +401,14 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
this.visible = visible;
- markAsDirty();
+ if (visible) {
+ /*
+ * If the visibility state is toggled from invisible to visible it
+ * affects all children (the whole hierarchy) in addition to this
+ * component.
+ */
+ markAsDirtyRecursive();
+ }
if (getParent() != null) {
// Must always repaint the parent (at least the hierarchy) when
// visibility of a child component changes.
diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java
index 427bb3491c..4dd8a8d24a 100644
--- a/server/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -232,19 +232,6 @@ public abstract class AbstractComponentContainer extends AbstractComponent
}
@Override
- public void setVisible(boolean visible) {
- if (isVisible() == visible) {
- return;
- }
-
- super.setVisible(visible);
- // If the visibility state is toggled it might affect all children
- // as well, e.g. make container visible should make children visible if
- // they were only hidden because the container was hidden.
- markAsDirtyRecursive();
- }
-
- @Override
public void setWidth(float width, Unit unit) {
/*
* child tree repaints may be needed, due to our fall back support for
diff --git a/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java b/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
index 7297318e95..5ff56d46dc 100644
--- a/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
@@ -103,19 +103,6 @@ public abstract class AbstractSingleComponentContainer extends
}
@Override
- public void setVisible(boolean visible) {
- if (isVisible() == visible) {
- return;
- }
-
- 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
- // they were only hidden because the container was hidden.
- markAsDirtyRecursive();
- }
-
- @Override
public Component getContent() {
return content;
}
diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java
index 68ebb079f9..862d98bb3c 100644
--- a/server/src/com/vaadin/ui/Form.java
+++ b/server/src/com/vaadin/ui/Form.java
@@ -1374,17 +1374,4 @@ public class Form extends AbstractField<Object> implements Item.Editor,
return count;
}
- @Override
- public void setVisible(boolean visible) {
- if (isVisible() == visible) {
- return;
- }
-
- 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
- // they were only hidden because the container was hidden.
- markAsDirtyRecursive();
- }
-
}
diff --git a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html
new file mode 100644
index 0000000000..ac2f0452b3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://arturwin.office.itmill.com:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.customcomponent.CustomComponentChildVisibility?debug&amp;restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]</td>
+ <td>In panel</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VCheckBox[0]/domChild[0]</td>
+ <td>7,7</td>
+</tr>
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]</td>
+ <td>In panel</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCheckBox[0]/domChild[0]</td>
+ <td>7,7</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]</td>
+ <td>In panel</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java
new file mode 100644
index 0000000000..a9899b2815
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012 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.tests.components.customcomponent;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+
+public class CustomComponentChildVisibility extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final CustomComponent cc = new CustomComponent(new Panel(
+ "In CustomComponent", new Label("In panel")));
+
+ final CheckBox cb = new CheckBox("CustomComponent visible");
+ cb.setValue(true);
+ cb.setImmediate(true);
+ cb.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ cc.setVisible(cb.getValue());
+ }
+ });
+ addComponent(cc);
+ addComponent(cb);
+
+ }
+
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}