From 59103a959544016728f2967a3ce79a06f9bff7fa Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 13 Jun 2013 16:10:03 +0300 Subject: Always notify parent of enable state changes (#12062) Change-Id: I30ee9a968050301d79c5073a62d85390652f76a9 --- .../client/ui/AbstractComponentConnector.java | 21 ++--- .../formlayout/CaptionEnableDisable.html | 94 ++++++++++++++++++++++ .../formlayout/CaptionEnableDisable.java | 61 ++++++++++++++ 3 files changed, 166 insertions(+), 10 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.html create mode 100644 uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.java diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index ebc80c4728..d384549ee3 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -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 index 0000000000..87bf0edb49 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.html @@ -0,0 +1,94 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.formlayout.CaptionEnableDisable?restartApplication
assertCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]v-disabled
assertCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]v-disabled
assertCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]v-disabled
assertCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]v-disabled
clickvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VButton[0]/domChild[0]/domChild[0]
assertNotCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]v-disabled
assertNotCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]v-disabled
assertNotCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]v-disabled
assertNotCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]v-disabled
clickvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VButton[0]/domChild[0]/domChild[0]
assertCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]v-disabled
assertCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]v-disabled
assertCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]v-disabled
assertCSSClassvaadin=runcomvaadintestscomponentsformlayoutCaptionEnableDisable::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]v-disabled
+ + 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 index 0000000000..ce9067df29 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/formlayout/CaptionEnableDisable.java @@ -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 -- cgit v1.2.3