]> source.dussan.org Git - vaadin-framework.git/commitdiff
Always notify parent of enable state changes (#12062)
authorArtur Signell <artur@vaadin.com>
Thu, 13 Jun 2013 13:10:03 +0000 (16:10 +0300)
committerVaadin Code Review <review@vaadin.com>
Thu, 13 Jun 2013 16:19:08 +0000 (16:19 +0000)
Change-Id: I30ee9a968050301d79c5073a62d85390652f76a9

client/src/com/vaadin/client/ui/AbstractComponentConnector.java
uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.java [new file with mode: 0644]

index ebc80c47288649565ea9c95a1cb5aea0fc74d96e..d384549ee3d4ae99444652e757e94fe6bd611ed0 100644 (file)
@@ -185,19 +185,20 @@ public abstract class AbstractComponentConnector extends AbstractConnector
         if (getWidget() instanceof HasEnabled) {
             // set widget specific enabled state
             ((HasEnabled) getWidget()).setEnabled(widgetEnabled);
+        }
 
-            // make sure the caption has or has not v-disabled style
-            if (delegateCaptionHandling()) {
-                ServerConnector parent = getParent();
-                if (parent instanceof HasComponentsConnector) {
-                    ((HasComponentsConnector) parent).updateCaption(this);
-                } else if (parent == null && !(this instanceof UIConnector)) {
-                    VConsole.error("Parent of connector "
-                            + Util.getConnectorString(this)
-                            + " is null. This is typically an indication of a broken component hierarchy");
-                }
+        // make sure the caption has or has not v-disabled style
+        if (delegateCaptionHandling()) {
+            ServerConnector parent = getParent();
+            if (parent instanceof HasComponentsConnector) {
+                ((HasComponentsConnector) parent).updateCaption(this);
+            } else if (parent == null && !(this instanceof UIConnector)) {
+                VConsole.error("Parent of connector "
+                        + Util.getConnectorString(this)
+                        + " is null. This is typically an indication of a broken component hierarchy");
             }
         }
+
     }
 
     protected void updateComponentSize() {
diff --git a/uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.html b/uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.html
new file mode 100644 (file)
index 0000000..87bf0ed
--- /dev/null
@@ -0,0 +1,94 @@
+<?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://localhost: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.formlayout.CaptionEnableDisable?restartApplication</td>
+    <td></td>
+</tr>
+<tr>
+    <td>assertCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]</td>
+    <td>v-disabled</td>
+</tr>
+<!--Enable-->
+<tr>
+    <td>click</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VButton[0]/domChild[0]/domChild[0]</td>
+    <td></td>
+</tr>
+<tr>
+    <td>assertNotCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertNotCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertNotCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertNotCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]</td>
+    <td>v-disabled</td>
+</tr>
+<!--Disable-->
+<tr>
+    <td>click</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VButton[0]/domChild[0]/domChild[0]</td>
+    <td></td>
+</tr>
+<tr>
+    <td>assertCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]</td>
+    <td>v-disabled</td>
+</tr>
+<tr>
+    <td>assertCSSClass</td>
+    <td>vaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]</td>
+    <td>v-disabled</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.java b/uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.java
new file mode 100644 (file)
index 0000000..ce9067d
--- /dev/null
@@ -0,0 +1,61 @@
+package com.vaadin.tests.components.formlayout;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.TextField;
+
+public class CaptionEnableDisable extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        setContent(createFormLayout());
+
+    }
+
+    public FormLayout createFormLayout() {
+        FormLayout layout = new FormLayout();
+        final TextField textField = new TextField("TextField");
+        textField.setEnabled(false);
+        layout.addComponent(textField);
+
+        final ComboBox combobox = new ComboBox("Combobox");
+        combobox.setEnabled(false);
+        layout.addComponent(combobox);
+
+        final NativeSelect nativeSelect = new NativeSelect("NativeSelect");
+        nativeSelect.setEnabled(false);
+        layout.addComponent(nativeSelect);
+
+        final CheckBox checkBox = new CheckBox("Checkbox");
+        checkBox.setEnabled(false);
+        layout.addComponent(checkBox);
+
+        layout.addComponent(new Button("Toggle components enabled",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(Button.ClickEvent event) {
+                        combobox.setEnabled(!combobox.isEnabled());
+                        textField.setEnabled(!textField.isEnabled());
+                        checkBox.setEnabled(!checkBox.isEnabled());
+                        nativeSelect.setEnabled(!nativeSelect.isEnabled());
+                    }
+                }));
+        return layout;
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 12062;
+    }
+
+}
\ No newline at end of file