diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2012-11-27 11:39:32 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-11-28 08:38:54 +0000 |
commit | c78e03fa5907845f745203da925f0264b1b3befc (patch) | |
tree | fab320adf75b046cc17b4f6faef881314546e0c8 | |
parent | fd815c6981fe609a05262388041d1e5793c84692 (diff) | |
download | vaadin-framework-c78e03fa5907845f745203da925f0264b1b3befc.tar.gz vaadin-framework-c78e03fa5907845f745203da925f0264b1b3befc.zip |
Properly support setWidgetEnabled for OptionGroupBased Selects #8985, #8986, #8987 and #8989.
Also fixes #7617 for OptionGroup, #9010 for TwinColSelect.
Change-Id: Ia4c2a5e6ee93847970092fcb1cd685a0173897d7
12 files changed, 659 insertions, 28 deletions
diff --git a/client/src/com/vaadin/client/ui/VListSelect.java b/client/src/com/vaadin/client/ui/VListSelect.java index e88e188f64..2215906af6 100644 --- a/client/src/com/vaadin/client/ui/VListSelect.java +++ b/client/src/com/vaadin/client/ui/VListSelect.java @@ -40,6 +40,8 @@ public class VListSelect extends VOptionGroupBase { select.addClickHandler(this); select.setVisibleItemCount(VISIBLE_COUNT); setStyleName(CLASSNAME); + + updateEnabledState(); } @Override @@ -66,7 +68,6 @@ public class VListSelect extends VOptionGroupBase { @Override public void buildOptions(UIDL uidl) { select.setMultipleSelect(isMultiselect()); - select.setEnabled(!isDisabled() && !isReadonly()); select.clear(); if (!isMultiselect() && isNullSelectionAllowed() && !isNullSelectionItemAvailable()) { @@ -134,6 +135,11 @@ public class VListSelect extends VOptionGroupBase { } @Override + protected void updateEnabledState() { + select.setEnabled(isEnabled() && !isReadonly()); + } + + @Override public void focus() { select.setFocus(true); } diff --git a/client/src/com/vaadin/client/ui/VNativeSelect.java b/client/src/com/vaadin/client/ui/VNativeSelect.java index 5a64c39f01..76fd66815a 100644 --- a/client/src/com/vaadin/client/ui/VNativeSelect.java +++ b/client/src/com/vaadin/client/ui/VNativeSelect.java @@ -38,6 +38,7 @@ public class VNativeSelect extends VOptionGroupBase implements Field { select.addChangeHandler(this); select.setStyleName(CLASSNAME + "-select"); + updateEnabledState(); } protected ListBox getOptionsContainer() { @@ -46,7 +47,6 @@ public class VNativeSelect extends VOptionGroupBase implements Field { @Override public void buildOptions(UIDL uidl) { - select.setEnabled(!isDisabled() && !isReadonly()); select.clear(); firstValueIsTemporaryNullItem = false; @@ -119,6 +119,11 @@ public class VNativeSelect extends VOptionGroupBase implements Field { } @Override + protected void updateEnabledState() { + select.setEnabled(isEnabled() && !isReadonly()); + } + + @Override public void focus() { select.setFocus(true); } diff --git a/client/src/com/vaadin/client/ui/VOptionGroup.java b/client/src/com/vaadin/client/ui/VOptionGroup.java index b928956214..1466c72ab1 100644 --- a/client/src/com/vaadin/client/ui/VOptionGroup.java +++ b/client/src/com/vaadin/client/ui/VOptionGroup.java @@ -16,6 +16,7 @@ package com.vaadin.client.ui; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -34,6 +35,7 @@ import com.google.gwt.user.client.Command; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.FocusWidget; import com.google.gwt.user.client.ui.Focusable; +import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.Widget; @@ -53,6 +55,8 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, private final Map<CheckBox, String> optionsToKeys; + private final List<Boolean> optionsEnabled; + /** For internal use only. May be removed or replaced in the future. */ public boolean sendFocusEvents = false; /** For internal use only. May be removed or replaced in the future. */ @@ -85,6 +89,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, super(CLASSNAME); panel = (Panel) optionsContainer; optionsToKeys = new HashMap<CheckBox, String>(); + optionsEnabled = new ArrayList<Boolean>(); } /* @@ -93,6 +98,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, @Override public void buildOptions(UIDL uidl) { panel.clear(); + optionsEnabled.clear(); for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) { final UIDL opUidl = (UIDL) it.next(); CheckBox op; @@ -124,12 +130,14 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, op.addStyleName(CLASSNAME_OPTION); op.setValue(opUidl.getBooleanAttribute("selected")); - boolean enabled = !opUidl - .getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED) - && !isReadonly() && !isDisabled(); + boolean optionEnabled = !opUidl + .getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED); + boolean enabled = optionEnabled && !isReadonly() && isEnabled(); op.setEnabled(enabled); + optionsEnabled.add(optionEnabled); setStyleName(op.getElement(), - ApplicationConnection.DISABLED_CLASSNAME, !enabled); + ApplicationConnection.DISABLED_CLASSNAME, + !(optionEnabled && isEnabled())); op.addClickHandler(this); optionsToKeys.put(op, opUidl.getStringAttribute("key")); panel.add(op); @@ -169,6 +177,24 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, } @Override + protected void updateEnabledState() { + int i = 0; + boolean optionGroupEnabled = isEnabled() && !isReadonly(); + // sets options enabled according to the widget's enabled, + // readonly and each options own enabled + for (Widget w : panel) { + if (w instanceof HasEnabled) { + ((HasEnabled) w).setEnabled(optionsEnabled.get(i) + && optionGroupEnabled); + setStyleName(w.getElement(), + ApplicationConnection.DISABLED_CLASSNAME, + !(optionsEnabled.get(i) && isEnabled())); + } + i++; + } + } + + @Override public void focus() { Iterator<Widget> iterator = panel.iterator(); if (iterator.hasNext()) { diff --git a/client/src/com/vaadin/client/ui/VOptionGroupBase.java b/client/src/com/vaadin/client/ui/VOptionGroupBase.java index d372f4caf8..c1bb84e886 100644 --- a/client/src/com/vaadin/client/ui/VOptionGroupBase.java +++ b/client/src/com/vaadin/client/ui/VOptionGroupBase.java @@ -27,6 +27,7 @@ import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; @@ -34,7 +35,7 @@ import com.vaadin.client.Focusable; import com.vaadin.client.UIDL; public abstract class VOptionGroupBase extends Composite implements Field, - ClickHandler, ChangeHandler, KeyPressHandler, Focusable { + ClickHandler, ChangeHandler, KeyPressHandler, Focusable, HasEnabled { public static final String CLASSNAME_OPTION = "v-select-option"; @@ -53,11 +54,9 @@ public abstract class VOptionGroupBase extends Composite implements Field, /** For internal use only. May be removed or replaced in the future. */ public boolean multiselect; - /** For internal use only. May be removed or replaced in the future. */ - public boolean disabled; + private boolean enabled; - /** For internal use only. May be removed or replaced in the future. */ - public boolean readonly; + private boolean readonly; /** For internal use only. May be removed or replaced in the future. */ public int cols = 0; @@ -119,11 +118,11 @@ public abstract class VOptionGroupBase extends Composite implements Field, return multiselect; } - protected boolean isDisabled() { - return disabled; + public boolean isEnabled() { + return enabled; } - protected boolean isReadonly() { + public boolean isReadonly() { return readonly; } @@ -184,11 +183,27 @@ public abstract class VOptionGroupBase extends Composite implements Field, } } + public void setReadonly(boolean readonly) { + if (this.readonly != readonly) { + this.readonly = readonly; + updateEnabledState(); + } + } + + public void setEnabled(boolean enabled) { + if (this.enabled != enabled) { + this.enabled = enabled; + updateEnabledState(); + } + } + /** For internal use only. May be removed or replaced in the future. */ public abstract void buildOptions(UIDL uidl); protected abstract String[] getSelectedItems(); + protected abstract void updateEnabledState(); + protected String getSelectedItem() { final String[] sel = getSelectedItems(); if (sel.length > 0) { diff --git a/client/src/com/vaadin/client/ui/VTwinColSelect.java b/client/src/com/vaadin/client/ui/VTwinColSelect.java index 22aa74526c..e98fbaf75d 100644 --- a/client/src/com/vaadin/client/ui/VTwinColSelect.java +++ b/client/src/com/vaadin/client/ui/VTwinColSelect.java @@ -38,6 +38,7 @@ import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.Panel; +import com.vaadin.client.ApplicationConnection; import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.shared.ui.twincolselect.TwinColSelectConstants; @@ -139,6 +140,8 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, selections.addMouseDownHandler(this); selections.addKeyDownHandler(this); + + updateEnabledState(); } public HTML getOptionsCaption() { @@ -220,13 +223,8 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, @Override public void buildOptions(UIDL uidl) { - final boolean enabled = !isDisabled() && !isReadonly(); options.setMultipleSelect(isMultiselect()); selections.setMultipleSelect(isMultiselect()); - options.setEnabled(enabled); - selections.setEnabled(enabled); - add.setEnabled(enabled && !readonly); - remove.setEnabled(enabled && !readonly); options.clear(); selections.clear(); for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) { @@ -245,9 +243,6 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, selections.setVisibleItemCount(getRows()); } - - add.setStyleName("v-disabled", readonly); - remove.setStyleName("v-disabled", readonly); } @Override @@ -429,6 +424,17 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, } @Override + public void updateEnabledState() { + boolean enabled = isEnabled() && !isReadonly(); + options.setEnabled(enabled); + selections.setEnabled(enabled); + add.setEnabled(enabled); + remove.setEnabled(enabled); + add.setStyleName(ApplicationConnection.DISABLED_CLASSNAME, !enabled); + remove.setStyleName(ApplicationConnection.DISABLED_CLASSNAME, !enabled); + } + + @Override public void focus() { options.setFocus(true); } diff --git a/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java b/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java index 36b69922fc..814b179e4a 100644 --- a/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java +++ b/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java @@ -40,8 +40,7 @@ public abstract class OptionGroupBaseConnector extends AbstractFieldConnector getWidget().selectedKeys = uidl.getStringArrayVariableAsSet("selected"); - getWidget().readonly = isReadOnly(); - getWidget().disabled = !isEnabled(); + getWidget().setReadonly(isReadOnly()); getWidget().multiselect = "multi".equals(uidl .getStringAttribute("selectmode")); getWidget().immediate = getState().immediate; @@ -76,10 +75,10 @@ public abstract class OptionGroupBaseConnector extends AbstractFieldConnector getWidget().newItemField = new VTextField(); getWidget().newItemField.addKeyPressHandler(getWidget()); } - getWidget().newItemField.setEnabled(!getWidget().disabled - && !getWidget().readonly); - getWidget().newItemButton.setEnabled(!getWidget().disabled - && !getWidget().readonly); + getWidget().newItemField.setEnabled(getWidget().isEnabled() + && !getWidget().isReadonly()); + getWidget().newItemButton.setEnabled(getWidget().isEnabled() + && !getWidget().isReadonly()); if (getWidget().newItemField == null || getWidget().newItemField.getParent() != getWidget().container) { diff --git a/uitest/src/com/vaadin/tests/components/listselect/ListSelectParentDisabled.html b/uitest/src/com/vaadin/tests/components/listselect/ListSelectParentDisabled.html new file mode 100644 index 0000000000..886f454dcb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/listselect/ListSelectParentDisabled.html @@ -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="" /> +<title>ListSelectParentDisabled</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">ListSelectParentDisabled</td></tr> +</thead><tbody> +<!--Tests that the ListSelect is disabled / enabled correctly when the parent is disabled / enabled. Test the updating of the css class name v-disabled too.--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.select.OptionGroupBaseSelects?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[1]</td> + <td>v-disabled</td> +</tr> +<!--disable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[1]</td> + <td>v-disabled</td> +</tr> +<!--enable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VListSelect[1]</td> + <td>v-disabled</td> +</tr> +</tbody></table> +</body> +</html>
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectParentDisabled.html b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectParentDisabled.html new file mode 100644 index 0000000000..a8d3577eba --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectParentDisabled.html @@ -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="" /> +<title>NativeSelectParentDisabledTest</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">NativeSelectParentDisabledTest</td></tr> +</thead><tbody> +<!--Tests that the NativeSelect is disabled / enabled correctly when the parent is disabled / enabled. Test the updating of the css class name v-disabled too.--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.select.OptionGroupBaseSelects?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[1]</td> + <td>v-disabled</td> +</tr> +<!--disable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>8,6</td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[1]</td> + <td>v-disabled</td> +</tr> +<!--enable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>8,6</td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VNativeSelect[1]</td> + <td>v-disabled</td> +</tr> +</tbody></table> +</body> +</html>
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupParentDisabled.html b/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupParentDisabled.html new file mode 100644 index 0000000000..80d10a05ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupParentDisabled.html @@ -0,0 +1,109 @@ +?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="" /> +<title>OptionGroupParentDisabled</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">OptionGroupParentDisabled</td></tr> +</thead><tbody> +<!--Tests that the OptionGroup is disabled / enabled correctly when the parent is disabled / enabled. Test the updating of the css class name v-disabled too.--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.select.OptionGroupBaseSelects?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]/domChild[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[1]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[1]</td> + <td>v-disabled</td> +</tr> +<!--disable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]/domChild[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[1]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[1]</td> + <td>v-disabled</td> +</tr> +<!--enable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]/domChild[1]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[1]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VOptionGroup[1]</td> + <td>v-disabled</td> +</tr> +</tbody></table> +</body> +</html>
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java b/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java new file mode 100644 index 0000000000..f2dee69cbf --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java @@ -0,0 +1,104 @@ +package com.vaadin.tests.components.select; + +import java.util.Iterator; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.ui.AbstractSelect; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.ListSelect; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.OptionGroup; +import com.vaadin.ui.TwinColSelect; + +public class OptionGroupBaseSelects extends ComponentTestCase<HorizontalLayout> { + + private HorizontalLayout layout; + + @Override + protected Class<HorizontalLayout> getTestClass() { + return HorizontalLayout.class; + } + + @Override + protected void initializeComponents() { + + CheckBox cb = new CheckBox("Switch Selects ReadOnly", false); + cb.addListener(new ValueChangeListener() { + + public void valueChange(ValueChangeEvent event) { + for (Iterator<Component> it = layout.getComponentIterator(); it + .hasNext();) { + Component c = it.next(); + if (c instanceof AbstractSelect) { + c.setReadOnly(!c.isReadOnly()); + } + } + } + }); + CheckBox cb2 = new CheckBox("Switch Selects Enabled", true); + cb2.addListener(new ValueChangeListener() { + + public void valueChange(ValueChangeEvent event) { + for (Iterator<Component> it = layout.getComponentIterator(); it + .hasNext();) { + Component c = it.next(); + if (c instanceof AbstractSelect) { + boolean enabled = !c.isEnabled(); + c.setEnabled(enabled); + c.setCaption(c.getCaption().replace( + (enabled ? "disabled" : "enabled"), + (enabled ? "enabled" : "disabled"))); + } + } + } + }); + HorizontalLayout cbs = new HorizontalLayout(); + cbs.setSpacing(true); + cbs.addComponent(cb); + cbs.addComponent(cb2); + addComponent(cbs); + + layout = new HorizontalLayout(); + layout.setSpacing(true); + layout.addComponent(createSelect( + new ListSelect("List Select, enabled"), true)); + layout.addComponent(createSelect( + new ListSelect("List Select, disabled"), false)); + + layout.addComponent(createSelect(new NativeSelect( + "Native Select, enabled"), true)); + layout.addComponent(createSelect(new NativeSelect( + "Native Select, disabled"), false)); + + layout.addComponent(createSelect(new OptionGroup( + "Option Group, enabled"), true)); + layout.addComponent(createSelect(new OptionGroup( + "Option Group, disabled"), false)); + + layout.addComponent(createSelect(new TwinColSelect( + "Twin Column Select, enabled"), true)); + layout.addComponent(createSelect(new TwinColSelect( + "Twin Column Select, disabled"), false)); + + addTestComponent(layout); + + } + + private AbstractSelect createSelect(AbstractSelect select, boolean enabled) { + select.addContainerProperty(CAPTION, String.class, null); + for (int i = 0; i < 10; i++) { + select.addItem("" + i).getItemProperty(CAPTION) + .setValue("Item " + i); + if (select instanceof OptionGroup && i % 2 == 1) { + ((OptionGroup) select).setItemEnabled("" + i, false); + } + } + select.setEnabled(enabled); + select.setImmediate(true); + return select; + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/select/OptionGroupBasedSelectsParentDisabledScreenshots.html b/uitest/src/com/vaadin/tests/components/select/OptionGroupBasedSelectsParentDisabledScreenshots.html new file mode 100644 index 0000000000..4259da836d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/select/OptionGroupBasedSelectsParentDisabledScreenshots.html @@ -0,0 +1,49 @@ +<?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="" /> +<title>TwinColSelectParentDisabled</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TwinColSelectParentDisabled</td></tr> +</thead><tbody> +<!--Tests with screen shots that OptionGroupBased Selects are disabled / enabled correctly when the parent is disabled / enabled.--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.select.OptionGroupBaseSelects?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>initial_state_parent_enabled</td> +</tr> +<!--disable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>parent_disabled</td> +</tr> +<!--enable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>parent_enabled</td> +</tr> +</tbody></table> +</body> +</html>
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/twincolselect/TwinColSelectParentDisabled.html b/uitest/src/com/vaadin/tests/components/twincolselect/TwinColSelectParentDisabled.html new file mode 100644 index 0000000000..266fef421d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/twincolselect/TwinColSelectParentDisabled.html @@ -0,0 +1,124 @@ +<?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="" /> +<title>TwinColSelectParentDisabled</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TwinColSelectParentDisabled</td></tr> +</thead><tbody> +<!--Tests that the TwinColSelect is disabled / enabled correctly when the parent is disabled / enabled. Test the updating of the css class name v-disabled too.--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.select.OptionGroupBaseSelects?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]#leftSelect</td> + <td></td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]#rightSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]#leftSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]#rightSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]</td> + <td>v-disabled</td> +</tr> +<!--disable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]#leftSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]#rightSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]#leftSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]#rightSelect</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]</td> + <td>v-disabled</td> +</tr> +<!--enable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]#leftSelect</td> + <td></td> +</tr> +<tr> + <td>assertEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]#rightSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]#leftSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotEditable</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]#rightSelect</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[0]</td> + <td>v-disabled</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[2]/VTwinColSelect[1]</td> + <td>v-disabled</td> +</tr> +</tbody></table> +</body> +</html>
\ No newline at end of file |