From 27fcaf2699ee4359c2e0cdefb53f17bead2165db Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 8 Jan 2013 11:33:47 +0200 Subject: [PATCH] Fix for fixing both styling and broken behavior with ListSelect with newItemsAllowed enabled. #10537 Change-Id: I82682ffbc2bc1f2801a6826d7e0f78a82990ae9a --- .../vaadin/client/ApplicationConnection.java | 9 ++++ .../optiongroup/OptionGroupBaseConnector.java | 7 +++ .../listselect/ListSelectAllowNewItem.html | 52 +++++++++++++++++++ .../listselect/ListSelectAllowNewItem.java | 29 +++++++++++ 4 files changed, 97 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/listselect/ListSelectAllowNewItem.html create mode 100644 uitest/src/com/vaadin/tests/components/listselect/ListSelectAllowNewItem.java diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index fa3b945163..4a3215bb21 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -3110,6 +3110,15 @@ public class ApplicationConnection { */ @Deprecated public boolean hasEventListeners(Widget widget, String eventIdentifier) { + ComponentConnector connector = getConnectorMap().getConnector(widget); + if (connector == null) { + /* + * No connector will exist in cases where Vaadin widgets have been + * re-used without implementing server<->client communication. + */ + return false; + } + return hasEventListeners(getConnectorMap().getConnector(widget), eventIdentifier); } diff --git a/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java b/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java index 93df05e347..86e857ac7f 100644 --- a/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java +++ b/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java @@ -18,6 +18,7 @@ package com.vaadin.client.ui.optiongroup; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.Paintable; +import com.vaadin.client.StyleConstants; import com.vaadin.client.UIDL; import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.VNativeButton; @@ -72,8 +73,14 @@ public abstract class OptionGroupBaseConnector extends AbstractFieldConnector getWidget().newItemButton = new VNativeButton(); getWidget().newItemButton.setText("+"); getWidget().newItemButton.addClickHandler(getWidget()); + getWidget().newItemButton + .addStyleName(StyleConstants.UI_WIDGET); getWidget().newItemField = new VTextField(); + getWidget().newItemField.client = getConnection(); + getWidget().newItemField.paintableId = getConnectorId(); getWidget().newItemField.addKeyPressHandler(getWidget()); + getWidget().newItemField.addStyleName(StyleConstants.UI_WIDGET); + } getWidget().newItemField.setEnabled(getWidget().isEnabled() && !getWidget().isReadonly()); diff --git a/uitest/src/com/vaadin/tests/components/listselect/ListSelectAllowNewItem.html b/uitest/src/com/vaadin/tests/components/listselect/ListSelectAllowNewItem.html new file mode 100644 index 0000000000..ad5eda1ace --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/listselect/ListSelectAllowNewItem.html @@ -0,0 +1,52 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.listselect.ListSelectAllowNewItem?restartApplication
mouseClickvaadin=runcomvaadintestscomponentslistselectListSelectAllowNewItem::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VListSelect[0]/domChild[1]125,7
typevaadin=runcomvaadintestscomponentslistselectListSelectAllowNewItem::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VListSelect[0]/domChild[1]aaa
mouseClickvaadin=runcomvaadintestscomponentslistselectListSelectAllowNewItem::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VListSelect[0]/domChild[2]15,8
assertTextvaadin=runcomvaadintestscomponentslistselectListSelectAllowNewItem::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VListSelect[0]/domChild[0]/domChild[3]aaa
assertCSSClassvaadin=runcomvaadintestscomponentslistselectListSelectAllowNewItem::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VListSelect[0]/domChild[1]v-widget
assertCSSClassvaadin=runcomvaadintestscomponentslistselectListSelectAllowNewItem::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VListSelect[0]/domChild[2]v-widget
+ + diff --git a/uitest/src/com/vaadin/tests/components/listselect/ListSelectAllowNewItem.java b/uitest/src/com/vaadin/tests/components/listselect/ListSelectAllowNewItem.java new file mode 100644 index 0000000000..8e74a7a53d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/listselect/ListSelectAllowNewItem.java @@ -0,0 +1,29 @@ +package com.vaadin.tests.components.listselect; + +import java.util.Arrays; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.ListSelect; + +public class ListSelectAllowNewItem extends TestBase { + + @Override + protected void setup() { + ListSelect select = new ListSelect("Select", Arrays.asList("Option 1", + "Option 2")); + select.setImmediate(true); + select.setNewItemsAllowed(true); + addComponent(select); + } + + @Override + protected String getDescription() { + return "ListSelect with allowNewItems turned on"; + } + + @Override + protected Integer getTicketNumber() { + return 10537; + } + +} -- 2.39.5