This simplifies the client side state machine. This change does not modify the CSS class name v-filterselect. Change-Id: I2f4a6e5252045cb7698d582be90693e00961b342tags/8.0.0.alpha2
@@ -0,0 +1,75 @@ | |||
/* | |||
* Copyright 2000-2016 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.client.ui; | |||
import com.google.gwt.core.client.JavaScriptObject; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.client.widgets.Escalator; | |||
/** | |||
* A mousewheel handling class to get around the limits of | |||
* {@link Event#ONMOUSEWHEEL}. | |||
* | |||
* For internal use only. May be removed or replaced in the future. | |||
* | |||
* @see Escalator.JsniWorkaround | |||
*/ | |||
// FIXME remove the copy in v7 package | |||
abstract class JsniMousewheelHandler { | |||
/** | |||
* A JavaScript function that handles the mousewheel DOM event, and passes | |||
* it on to Java code. | |||
* | |||
* @see #createMousewheelListenerFunction(Widget) | |||
*/ | |||
protected final JavaScriptObject mousewheelListenerFunction; | |||
protected JsniMousewheelHandler(final Widget widget) { | |||
mousewheelListenerFunction = createMousewheelListenerFunction(widget); | |||
} | |||
/** | |||
* A method that constructs the JavaScript function that will be stored into | |||
* {@link #mousewheelListenerFunction}. | |||
* | |||
* @param widget | |||
* a reference to the current instance of {@link Widget} | |||
*/ | |||
protected abstract JavaScriptObject createMousewheelListenerFunction( | |||
Widget widget); | |||
public native void attachMousewheelListener(Element element) | |||
/*-{ | |||
if (element.addEventListener) { | |||
// FireFox likes "wheel", while others use "mousewheel" | |||
var eventName = 'onmousewheel' in element ? 'mousewheel' : 'wheel'; | |||
element.addEventListener(eventName, this.@com.vaadin.client.ui.JsniMousewheelHandler::mousewheelListenerFunction); | |||
} | |||
}-*/; | |||
public native void detachMousewheelListener(Element element) | |||
/*-{ | |||
if (element.addEventListener) { | |||
// FireFox likes "wheel", while others use "mousewheel" | |||
var eventName = element.onwheel===undefined?"mousewheel":"wheel"; | |||
element.removeEventListener(eventName, this.@com.vaadin.client.ui.JsniMousewheelHandler::mousewheelListenerFunction); | |||
} | |||
}-*/; | |||
} |
@@ -0,0 +1,339 @@ | |||
/* | |||
* Copyright 2000-2016 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.client.ui.combobox; | |||
import com.vaadin.client.Profiler; | |||
import com.vaadin.client.communication.RpcProxy; | |||
import com.vaadin.client.communication.StateChangeEvent; | |||
import com.vaadin.client.connectors.data.HasDataSource; | |||
import com.vaadin.client.data.DataSource; | |||
import com.vaadin.client.ui.AbstractFieldConnector; | |||
import com.vaadin.client.ui.SimpleManagedLayout; | |||
import com.vaadin.client.ui.VComboBox; | |||
import com.vaadin.client.ui.VComboBox.DataReceivedHandler; | |||
import com.vaadin.shared.EventId; | |||
import com.vaadin.shared.Registration; | |||
import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc; | |||
import com.vaadin.shared.data.DataCommunicatorConstants; | |||
import com.vaadin.shared.ui.Connect; | |||
import com.vaadin.shared.ui.combobox.ComboBoxClientRpc; | |||
import com.vaadin.shared.ui.combobox.ComboBoxConstants; | |||
import com.vaadin.shared.ui.combobox.ComboBoxServerRpc; | |||
import com.vaadin.shared.ui.combobox.ComboBoxState; | |||
import com.vaadin.ui.ComboBox; | |||
import elemental.json.JsonObject; | |||
@Connect(ComboBox.class) | |||
public class ComboBoxConnector extends AbstractFieldConnector | |||
implements HasDataSource, SimpleManagedLayout { | |||
protected ComboBoxServerRpc rpc = RpcProxy.create(ComboBoxServerRpc.class, | |||
this); | |||
protected FocusAndBlurServerRpc focusAndBlurRpc = RpcProxy | |||
.create(FocusAndBlurServerRpc.class, this); | |||
private DataSource<JsonObject> dataSource; | |||
private Registration dataChangeHandlerRegistration; | |||
@Override | |||
protected void init() { | |||
super.init(); | |||
getWidget().connector = this; | |||
registerRpc(ComboBoxClientRpc.class, new ComboBoxClientRpc() { | |||
@Override | |||
public void setSelectedItem(String selectedKey, | |||
String selectedCaption) { | |||
getDataReceivedHandler().updateSelectionFromServer(selectedKey, | |||
selectedCaption); | |||
} | |||
}); | |||
} | |||
@Override | |||
public void onStateChanged(StateChangeEvent stateChangeEvent) { | |||
super.onStateChanged(stateChangeEvent); | |||
Profiler.enter("ComboBoxConnector.onStateChanged update content"); | |||
getWidget().readonly = isReadOnly(); | |||
getWidget().updateReadOnly(); | |||
// not a FocusWidget -> needs own tabindex handling | |||
getWidget().tb.setTabIndex(getState().tabIndex); | |||
getWidget().suggestionPopup.updateStyleNames(getState()); | |||
getWidget().nullSelectionAllowed = getState().emptySelectionAllowed; | |||
// TODO having this true would mean that the empty selection item comes | |||
// from the data source so none needs to be added - currently | |||
// unsupported | |||
getWidget().nullSelectItem = false; | |||
// make sure the input prompt is updated | |||
getWidget().updatePlaceholder(); | |||
getDataReceivedHandler().serverReplyHandled(); | |||
Profiler.leave("ComboBoxConnector.onStateChanged update content"); | |||
} | |||
@Override | |||
public VComboBox getWidget() { | |||
return (VComboBox) super.getWidget(); | |||
} | |||
private DataReceivedHandler getDataReceivedHandler() { | |||
return getWidget().getDataReceivedHandler(); | |||
} | |||
@Override | |||
public ComboBoxState getState() { | |||
return (ComboBoxState) super.getState(); | |||
} | |||
@Override | |||
public void layout() { | |||
VComboBox widget = getWidget(); | |||
if (widget.initDone) { | |||
widget.updateRootWidth(); | |||
} | |||
} | |||
@Override | |||
public void setWidgetEnabled(boolean widgetEnabled) { | |||
super.setWidgetEnabled(widgetEnabled); | |||
getWidget().enabled = widgetEnabled; | |||
getWidget().tb.setEnabled(widgetEnabled); | |||
} | |||
/* | |||
* These methods exist to move communications out of VComboBox, and may be | |||
* refactored/removed in the future | |||
*/ | |||
/** | |||
* Send a message about a newly created item to the server. | |||
* | |||
* This method is for internal use only and may be removed in future | |||
* versions. | |||
* | |||
* @since | |||
* @param itemValue | |||
* user entered string value for the new item | |||
*/ | |||
public void sendNewItem(String itemValue) { | |||
rpc.createNewItem(itemValue); | |||
getDataReceivedHandler().clearPendingNavigation(); | |||
} | |||
/** | |||
* Send a message to the server set the current filter. | |||
* | |||
* This method is for internal use only and may be removed in future | |||
* versions. | |||
* | |||
* @since | |||
* @param filter | |||
* the current filter string | |||
*/ | |||
public void setFilter(String filter) { | |||
if (filter != getWidget().lastFilter) { | |||
getDataReceivedHandler().clearPendingNavigation(); | |||
} | |||
rpc.setFilter(filter); | |||
} | |||
/** | |||
* Send a message to the server to request a page of items with the current | |||
* filter. | |||
* | |||
* This method is for internal use only and may be removed in future | |||
* versions. | |||
* | |||
* @since | |||
* @param page | |||
* the page number to get or -1 to let the server/connector | |||
* decide based on current selection (possibly loading more data | |||
* from the server) | |||
*/ | |||
public void requestPage(int page) { | |||
if (page < 0) { | |||
if (getState().scrollToSelectedItem) { | |||
getDataSource().ensureAvailability(0, 10000); | |||
return; | |||
} else { | |||
page = 0; | |||
} | |||
} | |||
int adjustment = (getWidget().nullSelectionAllowed | |||
&& "".equals(getWidget().lastFilter)) ? 1 : 0; | |||
int startIndex = Math.max(0, | |||
page * getWidget().pageLength - adjustment); | |||
int pageLength = getWidget().pageLength > 0 ? getWidget().pageLength | |||
: 10000; | |||
getDataSource().ensureAvailability(startIndex, pageLength); | |||
} | |||
/** | |||
* Send a message to the server updating the current selection. | |||
* | |||
* This method is for internal use only and may be removed in future | |||
* versions. | |||
* | |||
* @since | |||
* @param selectionKey | |||
* the current selected item key | |||
*/ | |||
public void sendSelection(String selectionKey) { | |||
rpc.setSelectedItem(selectionKey); | |||
getDataReceivedHandler().clearPendingNavigation(); | |||
} | |||
/** | |||
* Notify the server that the combo box received focus. | |||
* | |||
* For timing reasons, ConnectorFocusAndBlurHandler is not used at the | |||
* moment. | |||
* | |||
* This method is for internal use only and may be removed in future | |||
* versions. | |||
* | |||
* @since | |||
*/ | |||
public void sendFocusEvent() { | |||
boolean registeredListeners = hasEventListener(EventId.FOCUS); | |||
if (registeredListeners) { | |||
focusAndBlurRpc.focus(); | |||
getDataReceivedHandler().clearPendingNavigation(); | |||
} | |||
} | |||
/** | |||
* Notify the server that the combo box lost focus. | |||
* | |||
* For timing reasons, ConnectorFocusAndBlurHandler is not used at the | |||
* moment. | |||
* | |||
* This method is for internal use only and may be removed in future | |||
* versions. | |||
* | |||
* @since | |||
*/ | |||
public void sendBlurEvent() { | |||
boolean registeredListeners = hasEventListener(EventId.BLUR); | |||
if (registeredListeners) { | |||
focusAndBlurRpc.blur(); | |||
getDataReceivedHandler().clearPendingNavigation(); | |||
} | |||
} | |||
@Override | |||
public void setDataSource(DataSource<JsonObject> dataSource) { | |||
this.dataSource = dataSource; | |||
dataChangeHandlerRegistration = dataSource | |||
.addDataChangeHandler(range -> { | |||
// try to find selected item if requested | |||
if (getState().scrollToSelectedItem | |||
&& getState().pageLength > 0 | |||
&& getWidget().currentPage < 0 | |||
&& getWidget().selectedOptionKey != null) { | |||
// search for the item with the selected key | |||
getWidget().currentPage = 0; | |||
for (int i = 0; i < getDataSource().size(); ++i) { | |||
JsonObject row = getDataSource().getRow(i); | |||
if (row != null) { | |||
String key = row.getString( | |||
DataCommunicatorConstants.KEY); | |||
if (getWidget().selectedOptionKey.equals(key)) { | |||
if (getWidget().nullSelectionAllowed) { | |||
getWidget().currentPage = (i + 1) | |||
/ getState().pageLength; | |||
} else { | |||
getWidget().currentPage = i | |||
/ getState().pageLength; | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
} else if (getWidget().currentPage < 0) { | |||
getWidget().currentPage = 0; | |||
} | |||
getWidget().currentSuggestions.clear(); | |||
int start = getWidget().currentPage | |||
* getWidget().pageLength; | |||
int end = getWidget().pageLength > 0 | |||
? start + getWidget().pageLength | |||
: getDataSource().size(); | |||
if (getWidget().nullSelectionAllowed | |||
&& "".equals(getWidget().lastFilter)) { | |||
// add special null selection item... | |||
if (getWidget().currentPage == 0) { | |||
getWidget().currentSuggestions | |||
.add(getWidget().new ComboBoxSuggestion("", | |||
"", null, null)); | |||
} else { | |||
// ...or leave space for it | |||
start = start - 1; | |||
} | |||
// in either case, the last item to show is | |||
// shifted by one | |||
end = end - 1; | |||
} | |||
for (int i = start; i < end; ++i) { | |||
JsonObject row = getDataSource().getRow(i); | |||
if (row != null) { | |||
String key = row | |||
.getString(DataCommunicatorConstants.KEY); | |||
String caption = row | |||
.getString(DataCommunicatorConstants.NAME); | |||
String style = row | |||
.getString(ComboBoxConstants.STYLE); | |||
String untranslatedIconUri = row | |||
.getString(ComboBoxConstants.ICON); | |||
getWidget().currentSuggestions | |||
.add(getWidget().new ComboBoxSuggestion(key, | |||
caption, style, | |||
untranslatedIconUri)); | |||
} | |||
} | |||
getWidget().totalMatches = getDataSource().size() | |||
+ (getState().emptySelectionAllowed ? 1 : 0); | |||
getDataReceivedHandler().dataReceived(); | |||
}); | |||
} | |||
@Override | |||
public void onUnregister() { | |||
super.onUnregister(); | |||
dataChangeHandlerRegistration.remove(); | |||
} | |||
@Override | |||
public DataSource<JsonObject> getDataSource() { | |||
return dataSource; | |||
} | |||
} |
@@ -0,0 +1,690 @@ | |||
/* | |||
* Copyright 2000-2016 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.ui; | |||
import java.io.Serializable; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import java.util.Optional; | |||
import java.util.function.BiFunction; | |||
import java.util.function.Consumer; | |||
import java.util.function.Function; | |||
import com.vaadin.data.HasValue; | |||
import com.vaadin.event.FieldEvents; | |||
import com.vaadin.event.FieldEvents.BlurEvent; | |||
import com.vaadin.event.FieldEvents.BlurListener; | |||
import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl; | |||
import com.vaadin.event.FieldEvents.FocusEvent; | |||
import com.vaadin.event.FieldEvents.FocusListener; | |||
import com.vaadin.event.selection.SingleSelectionChange; | |||
import com.vaadin.event.selection.SingleSelectionListener; | |||
import com.vaadin.server.KeyMapper; | |||
import com.vaadin.server.Resource; | |||
import com.vaadin.server.ResourceReference; | |||
import com.vaadin.server.data.DataCommunicator; | |||
import com.vaadin.server.data.DataKeyMapper; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.shared.Registration; | |||
import com.vaadin.shared.data.DataCommunicatorConstants; | |||
import com.vaadin.shared.data.selection.SelectionModel; | |||
import com.vaadin.shared.ui.combobox.ComboBoxClientRpc; | |||
import com.vaadin.shared.ui.combobox.ComboBoxConstants; | |||
import com.vaadin.shared.ui.combobox.ComboBoxServerRpc; | |||
import com.vaadin.shared.ui.combobox.ComboBoxState; | |||
import elemental.json.JsonObject; | |||
/** | |||
* A filtering dropdown single-select. Items are filtered based on user input. | |||
* Supports the creation of new items when a handler is set by the user. | |||
* | |||
* @param <T> | |||
* item (bean) type in ComboBox | |||
* @author Vaadin Ltd | |||
*/ | |||
@SuppressWarnings("serial") | |||
public class ComboBox<T> extends | |||
AbstractListing<T, ComboBox<T>.ComboBoxSelectionModel> implements | |||
HasValue<T>, FieldEvents.BlurNotifier, FieldEvents.FocusNotifier { | |||
/** | |||
* Custom single selection model for ComboBox. | |||
*/ | |||
protected class ComboBoxSelectionModel implements SelectionModel.Single<T> { | |||
private Optional<T> selectedItem = Optional.empty(); | |||
private List<SingleSelectionListener<T>> listeners = new ArrayList<>(2); | |||
@Override | |||
public void deselect(T item) { | |||
selectedItem.ifPresent(selected -> { | |||
if (selected.equals(item)) { | |||
setValue(Optional.empty(), false); | |||
} | |||
}); | |||
} | |||
/** | |||
* Sets the selection. This method is primarily for internal use. | |||
* | |||
* @param value | |||
* optional new value | |||
* @param userOriginated | |||
* true if the value comes from user input, false otherwise | |||
*/ | |||
protected void setValue(Optional<T> value, boolean userOriginated) { | |||
if (selectedItem.equals(value)) { | |||
return; | |||
} | |||
selectedItem = value; | |||
String key = value | |||
.map(v -> getDataCommunicator().getKeyMapper().key(v)) | |||
.orElse(null); | |||
String selectedCaption = value | |||
.map(v -> getItemCaptionProvider().apply(v)).orElse(null); | |||
getRpcProxy(ComboBoxClientRpc.class).setSelectedItem(key, | |||
selectedCaption); | |||
fireEvent(userOriginated); | |||
} | |||
/** | |||
* Adds a selection listener to this select. The listener is called when | |||
* the value of this select is changed either by the user or | |||
* programmatically. | |||
* | |||
* @param listener | |||
* the value change listener, not null | |||
* @return a registration for the listener | |||
*/ | |||
public Registration addSelectionListener( | |||
SingleSelectionListener<T> listener) { | |||
Objects.requireNonNull(listener, "listener cannot be null"); | |||
listeners.add(listener); | |||
return () -> listeners.remove(listener); | |||
} | |||
@Override | |||
public void select(T item) { | |||
Objects.requireNonNull(item); | |||
setValue(Optional.of(item), false); | |||
} | |||
@Override | |||
public Optional<T> getSelectedItem() { | |||
return selectedItem; | |||
} | |||
/** | |||
* Fires a selection change event to all listeners. | |||
* | |||
* @param userOriginated | |||
* true to indicate that the change was caused directly by a | |||
* user action, false for programmatically set values | |||
*/ | |||
protected void fireEvent(boolean userOriginated) { | |||
for (SingleSelectionListener<T> listener : listeners) { | |||
listener.accept(new SingleSelectionChange<T>(ComboBox.this, | |||
getSelectedItem().orElse(null), userOriginated)); | |||
} | |||
} | |||
} | |||
/** | |||
* Handler that adds a new item based on user input when the new items | |||
* allowed mode is active. | |||
*/ | |||
@FunctionalInterface | |||
public interface NewItemHandler extends Consumer<String>, Serializable { | |||
} | |||
/** | |||
* ItemCaptionProvider can be used to customize the string shown to the user | |||
* for an item. | |||
* | |||
* @see ComboBox#setItemCaptionProvider(ItemCaptionProvider) | |||
* @param <T> | |||
* item type in the combo box | |||
*/ | |||
@FunctionalInterface | |||
public interface ItemCaptionProvider<T> | |||
extends Function<T, String>, Serializable { | |||
} | |||
/** | |||
* ItemStyleProvider can be used to add custom styles to combo box items | |||
* shown in the popup. The CSS class name that will be added to the item | |||
* style names is <tt>v-filterselect-item-[style name]</tt>. | |||
* | |||
* @see ComboBox#setItemStyleProvider(ItemStyleProvider) | |||
* @param <T> | |||
* item type in the combo box | |||
*/ | |||
@FunctionalInterface | |||
public interface ItemStyleProvider<T> | |||
extends Function<T, String>, Serializable { | |||
} | |||
/** | |||
* ItemIconProvider can be used to add custom icons to combo box items shown | |||
* in the popup. | |||
* | |||
* @see ComboBox#setItemIconProvider(ItemIconProvider) | |||
* @param <T> | |||
* item type in the combo box | |||
*/ | |||
@FunctionalInterface | |||
public interface ItemIconProvider<T> | |||
extends Function<T, Resource>, Serializable { | |||
} | |||
/** | |||
* Filter can be used to customize the filtering of items based on user | |||
* input. | |||
* | |||
* @see ComboBox#setFilter(ItemFilter) | |||
* @param <T> | |||
* item type in the combo box | |||
*/ | |||
@FunctionalInterface | |||
public interface ItemFilter<T> | |||
extends BiFunction<String, T, Boolean>, Serializable { | |||
} | |||
private ComboBoxServerRpc rpc = new ComboBoxServerRpc() { | |||
@Override | |||
public void createNewItem(String itemValue) { | |||
// New option entered | |||
if (getNewItemHandler() != null && itemValue != null | |||
&& itemValue.length() > 0) { | |||
getNewItemHandler().accept(itemValue); | |||
// rebuild list | |||
filterstring = null; | |||
} | |||
} | |||
@Override | |||
public void setSelectedItem(String key) { | |||
// it seems both of these happen, and mean empty selection... | |||
if (key == null || "".equals(key)) { | |||
getSelectionModel().setValue(Optional.empty(), true); | |||
} else { | |||
T item = getDataCommunicator().getKeyMapper().get(key); | |||
getSelectionModel().setValue(Optional.ofNullable(item), true); | |||
} | |||
} | |||
@Override | |||
public void setFilter(String filterText) { | |||
filterstring = filterText; | |||
if (filterText != null) { | |||
getDataCommunicator().setInMemoryFilter( | |||
item -> filter.apply(filterstring, item)); | |||
} else { | |||
getDataCommunicator().setInMemoryFilter(null); | |||
} | |||
} | |||
}; | |||
private FocusAndBlurServerRpcImpl focusBlurRpc = new FocusAndBlurServerRpcImpl( | |||
this) { | |||
@Override | |||
protected void fireEvent(Component.Event event) { | |||
ComboBox.this.fireEvent(event); | |||
} | |||
}; | |||
private String filterstring; | |||
/** | |||
* Handler for new items entered by the user. | |||
*/ | |||
private NewItemHandler newItemHandler; | |||
private ItemCaptionProvider<T> itemCaptionProvider = String::valueOf; | |||
private ItemStyleProvider<T> itemStyleProvider = item -> null; | |||
private ItemIconProvider<T> itemIconProvider = item -> null; | |||
private ItemFilter<T> filter = (filterText, item) -> { | |||
if (filterText == null) { | |||
return true; | |||
} else { | |||
return getItemCaptionProvider().apply(item).toLowerCase(getLocale()) | |||
.contains(filterText.toLowerCase(getLocale())); | |||
} | |||
}; | |||
/** | |||
* Constructs an empty combo box without a caption. The content of the combo | |||
* box can be set with {@link #setDataSource(DataSource)} or | |||
* {@link #setItems(Collection)} | |||
*/ | |||
public ComboBox() { | |||
super(new DataCommunicator<T>() { | |||
@Override | |||
protected DataKeyMapper<T> createKeyMapper() { | |||
return new KeyMapper<T>() { | |||
@Override | |||
public void remove(T removeobj) { | |||
// never remove keys from ComboBox to support selection | |||
// of items that are not currently visible | |||
} | |||
}; | |||
} | |||
}); | |||
setSelectionModel(new ComboBoxSelectionModel()); | |||
init(); | |||
} | |||
/** | |||
* Constructs an empty combo box, whose content can be set with | |||
* {@link #setDataSource(DataSource)} or {@link #setItems(Collection)}. | |||
* | |||
* @param caption | |||
* the caption to show in the containing layout, null for no | |||
* caption | |||
*/ | |||
public ComboBox(String caption) { | |||
this(); | |||
setCaption(caption); | |||
} | |||
/** | |||
* Constructs a combo box with a static in-memory data source with the given | |||
* options. | |||
* | |||
* @param caption | |||
* the caption to show in the containing layout, null for no | |||
* caption | |||
* @param options | |||
* collection of options, not null | |||
*/ | |||
public ComboBox(String caption, Collection<T> options) { | |||
this(caption, DataSource.create(options)); | |||
} | |||
/** | |||
* Constructs a combo box with the given data source. | |||
* | |||
* @param caption | |||
* the caption to show in the containing layout, null for no | |||
* caption | |||
* @param dataSource | |||
* the data source to use, not null | |||
*/ | |||
public ComboBox(String caption, DataSource<T> dataSource) { | |||
this(caption); | |||
setDataSource(dataSource); | |||
} | |||
/** | |||
* Initialize the ComboBox with default settings and register client to | |||
* server RPC implementation. | |||
*/ | |||
private void init() { | |||
registerRpc(rpc); | |||
registerRpc(focusBlurRpc); | |||
addDataGenerator((T data, JsonObject jsonObject) -> { | |||
jsonObject.put(DataCommunicatorConstants.NAME, | |||
getItemCaptionProvider().apply(data)); | |||
String style = itemStyleProvider.apply(data); | |||
if (style != null) { | |||
jsonObject.put(ComboBoxConstants.STYLE, style); | |||
} | |||
Resource icon = itemIconProvider.apply(data); | |||
if (icon != null) { | |||
String iconUrl = ResourceReference | |||
.create(icon, ComboBox.this, null).getURL(); | |||
jsonObject.put(ComboBoxConstants.ICON, iconUrl); | |||
} | |||
}); | |||
} | |||
/** | |||
* Gets the current placeholder text shown when the combo box would be | |||
* empty. | |||
* | |||
* @see #setPlaceholder(String) | |||
* @return the current placeholder string, or null if not enabled | |||
*/ | |||
public String getPlaceholder() { | |||
return getState(false).placeholder; | |||
} | |||
/** | |||
* Sets the placeholder string - a textual prompt that is displayed when the | |||
* select would otherwise be empty, to prompt the user for input. | |||
* | |||
* @param placeholder | |||
* the desired placeholder, or null to disable | |||
*/ | |||
public void setPlaceholder(String placeholder) { | |||
getState().placeholder = placeholder; | |||
} | |||
/** | |||
* Sets whether it is possible to input text into the field or whether the | |||
* field area of the component is just used to show what is selected. By | |||
* disabling text input, the comboBox will work in the same way as a | |||
* {@link NativeSelect} | |||
* | |||
* @see #isTextInputAllowed() | |||
* | |||
* @param textInputAllowed | |||
* true to allow entering text, false to just show the current | |||
* selection | |||
*/ | |||
public void setTextInputAllowed(boolean textInputAllowed) { | |||
getState().textInputAllowed = textInputAllowed; | |||
} | |||
/** | |||
* Returns true if the user can enter text into the field to either filter | |||
* the selections or enter a new value if {@link #isNewItemsAllowed()} | |||
* returns true. If text input is disabled, the comboBox will work in the | |||
* same way as a {@link NativeSelect} | |||
* | |||
* @return true if text input is allowed | |||
*/ | |||
public boolean isTextInputAllowed() { | |||
return getState(false).textInputAllowed; | |||
} | |||
@Override | |||
public void addBlurListener(BlurListener listener) { | |||
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, | |||
BlurListener.blurMethod); | |||
} | |||
@Override | |||
public void removeBlurListener(BlurListener listener) { | |||
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); | |||
} | |||
@Override | |||
public void addFocusListener(FocusListener listener) { | |||
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, | |||
FocusListener.focusMethod); | |||
} | |||
@Override | |||
public void removeFocusListener(FocusListener listener) { | |||
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); | |||
} | |||
/** | |||
* Returns the page length of the suggestion popup. | |||
* | |||
* @return the pageLength | |||
*/ | |||
public int getPageLength() { | |||
return getState(false).pageLength; | |||
} | |||
/** | |||
* Returns the suggestion pop-up's width as a CSS string. | |||
* | |||
* @see #setPopupWidth | |||
* @since 7.7 | |||
* @return explicitly set popup width as CSS size string or null if not set | |||
*/ | |||
public String getPopupWidth() { | |||
return getState(false).suggestionPopupWidth; | |||
} | |||
/** | |||
* Sets the page length for the suggestion popup. Setting the page length to | |||
* 0 will disable suggestion popup paging (all items visible). | |||
* | |||
* @param pageLength | |||
* the pageLength to set | |||
*/ | |||
public void setPageLength(int pageLength) { | |||
getState().pageLength = pageLength; | |||
} | |||
/** | |||
* Returns whether the user is allowed to select nothing in the combo box. | |||
* | |||
* @return true if empty selection is allowed, false otherwise | |||
*/ | |||
public boolean isEmptySelectionAllowed() { | |||
return getState(false).emptySelectionAllowed; | |||
} | |||
/** | |||
* Sets whether the user is allowed to select nothing in the combo box. When | |||
* true, a special empty item is shown to the user. | |||
* | |||
* @param emptySelectionAllowed | |||
* true to allow not selecting anything, false to require | |||
* selection | |||
*/ | |||
public void setEmptySelectionAllowed(boolean emptySelectionAllowed) { | |||
getState().emptySelectionAllowed = emptySelectionAllowed; | |||
} | |||
/** | |||
* Sets the suggestion pop-up's width as a CSS string. By using relative | |||
* units (e.g. "50%") it's possible to set the popup's width relative to the | |||
* ComboBox itself. | |||
* | |||
* @see #getPopupWidth() | |||
* @since 7.7 | |||
* @param width | |||
* the width | |||
*/ | |||
public void setPopupWidth(String width) { | |||
getState().suggestionPopupWidth = width; | |||
} | |||
/** | |||
* Sets whether to scroll the selected item visible (directly open the page | |||
* on which it is) when opening the combo box popup or not. | |||
* | |||
* This requires finding the index of the item, which can be expensive in | |||
* many large lazy loading containers. | |||
* | |||
* @param scrollToSelectedItem | |||
* true to find the page with the selected item when opening the | |||
* selection popup | |||
*/ | |||
public void setScrollToSelectedItem(boolean scrollToSelectedItem) { | |||
getState().scrollToSelectedItem = scrollToSelectedItem; | |||
} | |||
/** | |||
* Returns true if the select should find the page with the selected item | |||
* when opening the popup. | |||
* | |||
* @see #setScrollToSelectedItem(boolean) | |||
* | |||
* @return true if the page with the selected item will be shown when | |||
* opening the popup | |||
*/ | |||
public boolean isScrollToSelectedItem() { | |||
return getState(false).scrollToSelectedItem; | |||
} | |||
/** | |||
* Gets the item caption provider that is used to produce the strings shown | |||
* in the combo box for each item. | |||
* | |||
* @return the item caption provider used, not null | |||
*/ | |||
public ItemCaptionProvider<T> getItemCaptionProvider() { | |||
return itemCaptionProvider; | |||
} | |||
/** | |||
* Sets the item caption provider that is used to produce the strings shown | |||
* in the combo box for each item. By default, | |||
* {@link String#valueOf(Object)} is used. | |||
* | |||
* @param itemCaptionProvider | |||
* the item caption provider to use, not null | |||
*/ | |||
public void setItemCaptionProvider( | |||
ItemCaptionProvider<T> itemCaptionProvider) { | |||
Objects.requireNonNull(itemCaptionProvider, | |||
"Item caption providers must not be null"); | |||
this.itemCaptionProvider = itemCaptionProvider; | |||
getDataCommunicator().reset(); | |||
} | |||
/** | |||
* Sets the item style provider that is used to produce custom styles for | |||
* showing items in the popup. The CSS class name that will be added to the | |||
* item style names is <tt>v-filterselect-item-[style name]</tt>. Returning | |||
* null from the provider results in no custom style name being set. | |||
* | |||
* @param itemStyleProvider | |||
* the item style provider to set, not null | |||
*/ | |||
public void setItemStyleProvider(ItemStyleProvider<T> itemStyleProvider) { | |||
Objects.requireNonNull(itemStyleProvider, | |||
"Item style providers must not be null"); | |||
this.itemStyleProvider = itemStyleProvider; | |||
getDataCommunicator().reset(); | |||
} | |||
/** | |||
* Gets the currently used item style provider that is used to generate CSS | |||
* class names for items. The default item style provider returns null for | |||
* all items, resulting in no custom item class names being set. | |||
* | |||
* @see #setItemStyleProvider(ItemStyleProvider) | |||
* | |||
* @return the currently used item style provider, not null | |||
*/ | |||
public ItemStyleProvider<T> getItemStyleProvider() { | |||
return itemStyleProvider; | |||
} | |||
/** | |||
* Sets the item icon provider that is used to produce custom icons for | |||
* showing items in the popup. The provider can return null for items with | |||
* no icon. | |||
* | |||
* @param itemIconProvider | |||
* the item icon provider to set, not null | |||
*/ | |||
public void setItemIconProvider(ItemIconProvider<T> itemIconProvider) { | |||
Objects.requireNonNull(itemIconProvider, | |||
"Item icon providers must not be null"); | |||
this.itemIconProvider = itemIconProvider; | |||
getDataCommunicator().reset(); | |||
} | |||
/** | |||
* Gets the currently used item icon provider. The default item icon | |||
* provider returns null for all items, resulting in no icons being used. | |||
* | |||
* @see #setItemIconProvider(ItemIconProvider) | |||
* | |||
* @return the currently used item icon provider, not null | |||
*/ | |||
public ItemIconProvider<T> getItemIconProvider() { | |||
return itemIconProvider; | |||
} | |||
/** | |||
* Sets the handler that is called when user types a new item. The creation | |||
* of new items is allowed when a new item handler has been set. | |||
* | |||
* @param newItemHandler | |||
* handler called for new items, null to only permit the | |||
* selection of existing items | |||
*/ | |||
public void setNewItemHandler(NewItemHandler newItemHandler) { | |||
this.newItemHandler = newItemHandler; | |||
getState().allowNewItems = (newItemHandler != null); | |||
markAsDirty(); | |||
} | |||
/** | |||
* Returns the handler called when the user enters a new item (not present | |||
* in the data source). | |||
* | |||
* @return new item handler or null if none specified | |||
*/ | |||
public NewItemHandler getNewItemHandler() { | |||
return newItemHandler; | |||
} | |||
// HasValue methods delegated to the selection model | |||
/** | |||
* Returns the filter used to customize the list based on user input. | |||
* | |||
* @return the current filter, not null | |||
*/ | |||
public ItemFilter<T> getFilter() { | |||
return filter; | |||
} | |||
/** | |||
* Sets the filter used to customize the list based on user input. The | |||
* default filter checks case-insensitively that the input string is | |||
* contained in the item caption. | |||
* | |||
* @param filter | |||
* the filter function to use, not null | |||
*/ | |||
public void setFilter(ItemFilter<T> filter) { | |||
Objects.requireNonNull(filter, "Item filter must not be null"); | |||
this.filter = filter; | |||
} | |||
@Override | |||
public void setValue(T value) { | |||
getSelectionModel().setValue(Optional.ofNullable(value), false); | |||
} | |||
@Override | |||
public T getValue() { | |||
return getSelectionModel().getSelectedItem().orElse(null); | |||
} | |||
@SuppressWarnings("unchecked") | |||
@Override | |||
public Registration addValueChangeListener( | |||
HasValue.ValueChangeListener<? super T> listener) { | |||
return getSelectionModel().addSelectionListener(event -> { | |||
((ValueChangeListener<T>) listener) | |||
.accept(new ValueChange<T>(event.getConnector(), | |||
event.getValue(), event.isUserOriginated())); | |||
}); | |||
} | |||
@Override | |||
protected ComboBoxState getState() { | |||
return (ComboBoxState) super.getState(); | |||
} | |||
@Override | |||
protected ComboBoxState getState(boolean markAsDirty) { | |||
return (ComboBoxState) super.getState(markAsDirty); | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
/* | |||
* Copyright 2000-2016 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.shared.ui.combobox; | |||
import com.vaadin.shared.communication.ClientRpc; | |||
/** | |||
* Server to client RPC interface for ComboBox. | |||
* | |||
* @since | |||
*/ | |||
public interface ComboBoxClientRpc extends ClientRpc { | |||
/** | |||
* Set the current selection. | |||
* | |||
* @param selectedKey | |||
* the id of a single item or null to deselect the current value | |||
* @param selectedCaption | |||
* the caption of the selected item (used in case selection is | |||
* outside the lazy loaded range) | |||
*/ | |||
public void setSelectedItem(String selectedKey, String selectedCaption); | |||
} |
@@ -0,0 +1,30 @@ | |||
/* | |||
* Copyright 2000-2016 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.shared.ui.combobox; | |||
import java.io.Serializable; | |||
/** | |||
* Constants related to the combo box component and its client-server | |||
* communication. | |||
* | |||
* @since 8.0 | |||
* @author Vaadin Ltd | |||
*/ | |||
public class ComboBoxConstants implements Serializable { | |||
public static final String STYLE = "style"; | |||
public static final String ICON = "icon"; | |||
} |
@@ -0,0 +1,51 @@ | |||
/* | |||
* Copyright 2000-2016 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.shared.ui.combobox; | |||
import com.vaadin.shared.communication.ServerRpc; | |||
/** | |||
* Client to server RPC interface for ComboBox. | |||
* | |||
* @since | |||
*/ | |||
public interface ComboBoxServerRpc extends ServerRpc { | |||
/** | |||
* Create a new item in the combo box. This method can only be used when the | |||
* ComboBox is configured to allow the creation of new items by the user. | |||
* | |||
* @param itemValue | |||
* user entered string value for the new item | |||
*/ | |||
public void createNewItem(String itemValue); | |||
/** | |||
* Set the current selection. | |||
* | |||
* @param item | |||
* the id of a single item or null to deselect the current value | |||
*/ | |||
public void setSelectedItem(String item); | |||
/** | |||
* Sets the filter to use. | |||
* | |||
* @param filter | |||
* filter string interpreted according to the current filtering | |||
* mode | |||
*/ | |||
public void setFilter(String filter); | |||
} |
@@ -0,0 +1,85 @@ | |||
/* | |||
* Copyright 2000-2016 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.shared.ui.combobox; | |||
import com.vaadin.shared.AbstractFieldState; | |||
import com.vaadin.shared.annotations.DelegateToWidget; | |||
import com.vaadin.shared.annotations.NoLayout; | |||
/** | |||
* Shared state for the ComboBox component. | |||
* | |||
* @since 7.0 | |||
*/ | |||
public class ComboBoxState extends AbstractFieldState { | |||
{ | |||
// TODO ideally this would be v-combobox, but that would affect a lot of | |||
// themes | |||
primaryStyleName = "v-filterselect"; | |||
} | |||
/** | |||
* If text input is not allowed, the ComboBox behaves like a pretty | |||
* NativeSelect - the user can not enter any text and clicking the text | |||
* field opens the drop down with options. | |||
* | |||
* @since | |||
*/ | |||
@DelegateToWidget | |||
public boolean textInputAllowed = true; | |||
/** | |||
* The prompt to display in an empty field. Null when disabled. | |||
*/ | |||
@DelegateToWidget | |||
@NoLayout | |||
public String placeholder = null; | |||
/** | |||
* Number of items to show per page or 0 to disable paging. | |||
*/ | |||
@DelegateToWidget | |||
public int pageLength = 10; | |||
/** | |||
* Suggestion pop-up's width as a CSS string. By using relative units (e.g. | |||
* "50%") it's possible to set the popup's width relative to the ComboBox | |||
* itself. | |||
*/ | |||
@DelegateToWidget | |||
public String suggestionPopupWidth = null; | |||
/** | |||
* True to allow the user to send new items to the server, false to only | |||
* select among existing items. | |||
*/ | |||
@DelegateToWidget | |||
public boolean allowNewItems = false; | |||
/** | |||
* True to allow selecting nothing (a special empty selection item is shown | |||
* at the beginning of the list), false not to allow empty selection by the | |||
* user. | |||
*/ | |||
public boolean emptySelectionAllowed = true; | |||
/** | |||
* True to automatically scroll the ComboBox to show the selected item, | |||
* false not to search for it in the results. | |||
*/ | |||
public boolean scrollToSelectedItem = false; | |||
} |
@@ -0,0 +1,61 @@ | |||
package com.vaadin.testbench.customelements; | |||
import org.junit.Assert; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.elementsbase.ServerClass; | |||
@ServerClass("com.vaadin.ui.ComboBox") | |||
public class ComboBoxElement | |||
extends com.vaadin.testbench.elements.ComboBoxElement { | |||
private static org.openqa.selenium.By bySuggestionPopup = By | |||
.vaadin("#popup"); | |||
public WebElement getInputField() { | |||
return findElement(By.vaadin("#textbox")); | |||
} | |||
@Override | |||
public String getText() { | |||
return getInputField().getAttribute("value"); | |||
} | |||
@Override | |||
public void clear() { | |||
getInputField().clear(); | |||
} | |||
public WebElement getSuggestionPopup() { | |||
return findElement(bySuggestionPopup); | |||
} | |||
@Override | |||
public void sendKeys(CharSequence... keysToSend) { | |||
sendKeys(50, keysToSend); | |||
} | |||
/** | |||
* Use this method to simulate typing into an element, which may set its | |||
* value. | |||
* | |||
* @param delay | |||
* delay after sending each individual key (mainly needed for | |||
* PhantomJS) | |||
* @param keysToSend | |||
* keys to type into the element | |||
*/ | |||
public void sendKeys(int delay, CharSequence... keysToSend) { | |||
WebElement input = getInputField(); | |||
for (CharSequence key : keysToSend) { | |||
input.sendKeys(key); | |||
try { | |||
Thread.sleep(delay); | |||
} catch (InterruptedException e) { | |||
Assert.fail(e.getMessage()); | |||
} | |||
} | |||
} | |||
} |
@@ -6,8 +6,8 @@ import java.util.List; | |||
import com.vaadin.server.CompositeErrorMessage; | |||
import com.vaadin.server.UserError; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.TextField; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.TextField; | |||
public class ErrorMessages extends TestBase { | |||
@@ -24,7 +24,8 @@ public class ErrorMessages extends TestBase { | |||
tf.setComponentError(new UserError("This is a failure")); | |||
addComponent(tf); | |||
ComboBox cb = new ComboBox("ComboBox with description and UserError"); | |||
ComboBox<String> cb = new ComboBox<>( | |||
"ComboBox with description and UserError"); | |||
cb.setDescription("This is a combobox"); | |||
cb.setComponentError(new UserError("This is a failure")); | |||
addComponent(cb); |
@@ -10,12 +10,12 @@ import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.DateField; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.Layout; | |||
import com.vaadin.ui.NativeButton; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.OptionGroup; | |||
import com.vaadin.v7.ui.TextField; | |||
@@ -5,13 +5,11 @@ import com.vaadin.shared.ui.label.ContentMode; | |||
import com.vaadin.tests.VaadinClasses; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.ComponentContainer; | |||
import com.vaadin.ui.Embedded; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class IconsInCaption extends TestBase { | |||
@@ -35,38 +33,20 @@ public class IconsInCaption extends TestBase { | |||
private Log log = new Log(5); | |||
private ComboBox containerSelect; | |||
private ComboBox<Class<? extends ComponentContainer>> containerSelect; | |||
private ComboBox iconTypeSelect; | |||
private ComboBox<String> iconTypeSelect; | |||
@Override | |||
protected void setup() { | |||
iconTypeSelect = new ComboBox("Icon container"); | |||
iconTypeSelect.addItem(TYPE_EMBEDDED); | |||
iconTypeSelect.addItem(TYPE_CAPTION); | |||
iconTypeSelect.setImmediate(true); | |||
iconTypeSelect.setNullSelectionAllowed(false); | |||
iconTypeSelect.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
updateContainer(); | |||
} | |||
}); | |||
containerSelect = new ComboBox("Container"); | |||
for (Class<? extends ComponentContainer> cc : VaadinClasses | |||
.getComponentContainersSupportingUnlimitedNumberOfComponents()) { | |||
containerSelect.addItem(cc); | |||
} | |||
containerSelect.setImmediate(true); | |||
containerSelect.addListener(new ValueChangeListener() { | |||
iconTypeSelect = new ComboBox<>("Icon container"); | |||
iconTypeSelect.setItems(TYPE_EMBEDDED, TYPE_CAPTION); | |||
iconTypeSelect.setEmptySelectionAllowed(false); | |||
iconTypeSelect.addValueChangeListener(event -> updateContainer()); | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
updateContainer(); | |||
} | |||
}); | |||
containerSelect = new ComboBox<>("Container", VaadinClasses | |||
.getComponentContainersSupportingUnlimitedNumberOfComponents()); | |||
containerSelect.addValueChangeListener(event -> updateContainer()); | |||
addComponent(log); | |||
addComponent(iconTypeSelect); | |||
@@ -78,7 +58,7 @@ public class IconsInCaption extends TestBase { | |||
} | |||
protected void updateContainer() { | |||
Class<? extends ComponentContainer> containerClass = (Class<? extends ComponentContainer>) containerSelect | |||
Class<? extends ComponentContainer> containerClass = containerSelect | |||
.getValue(); | |||
if (containerClass == null) { | |||
return; |
@@ -4,9 +4,7 @@ import java.util.Arrays; | |||
import com.vaadin.server.UserError; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxBorder extends TestBase { | |||
@@ -14,17 +12,13 @@ public class ComboBoxBorder extends TestBase { | |||
protected void setup() { | |||
setTheme("tests-tickets"); | |||
final ComboBox cb = new ComboBox("All errors", | |||
final ComboBox<String> cb = new ComboBox<>("All errors", | |||
Arrays.asList("Error", "Error 2")); | |||
cb.setStyleName("ComboBoxBorder"); | |||
cb.setImmediate(true); | |||
cb.setWidth("200px"); // must have with to reproduce | |||
cb.addListener(new ValueChangeListener() { | |||
public void valueChange(ValueChangeEvent event) { | |||
cb.setComponentError(new UserError("Error")); | |||
} | |||
}); | |||
cb.addValueChangeListener( | |||
event -> cb.setComponentError(new UserError("Error"))); | |||
addComponent(cb); | |||
@@ -15,13 +15,11 @@ | |||
*/ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.FontAwesome; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
/** | |||
* Test UI to check click on icon in the combobox. | |||
@@ -32,16 +30,9 @@ public class ComboBoxClickIcon extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final List<String> items = new ArrayList<>(); | |||
items.add("A"); | |||
items.add("B"); | |||
items.add("C"); | |||
final ComboBox combo = new ComboBox(); | |||
combo.setImmediate(true); | |||
combo.setItemIcon(items.get(0), FontAwesome.ALIGN_CENTER); | |||
combo.setItemIcon(items.get(1), FontAwesome.ALIGN_CENTER); | |||
combo.setItemIcon(items.get(2), FontAwesome.ALIGN_CENTER); | |||
combo.addItems(items); | |||
final ComboBox<String> combo = new ComboBox<>(null, | |||
DataSource.create("A", "B", "C")); | |||
combo.setItemIconProvider(item -> FontAwesome.ALIGN_CENTER); | |||
combo.setTextInputAllowed(false); | |||
addComponent(combo); | |||
} |
@@ -17,9 +17,9 @@ package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class ComboBoxCursorPositionReset extends AbstractTestUI { | |||
@@ -29,11 +29,10 @@ public class ComboBoxCursorPositionReset extends AbstractTestUI { | |||
root.setSizeFull(); | |||
setContent(root); | |||
ComboBox combo = new ComboBox(); | |||
ComboBox<String> combo = new ComboBox<>(); | |||
combo.setImmediate(true); | |||
root.addComponent(combo); | |||
combo.addItem("Hello World"); | |||
combo.addItem("Please click on the text"); | |||
combo.setItems("Hello World", "Please click on the text"); | |||
combo.setValue("Please click on the text"); | |||
Label gap = new Label(); |
@@ -7,10 +7,7 @@ import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.tests.util.Person; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.data.util.BeanItemContainer; | |||
import com.vaadin.v7.ui.AbstractSelect.ItemCaptionMode; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxDuplicateCaption extends TestBase { | |||
@@ -29,25 +26,14 @@ public class ComboBoxDuplicateCaption extends TestBase { | |||
p2.setLastName("Doe"); | |||
list.add(p2); | |||
BeanItemContainer<Person> container = new BeanItemContainer<>( | |||
Person.class); | |||
container.addAll(list); | |||
ComboBox box = new ComboBox("Duplicate captions test Box"); | |||
ComboBox<Person> box = new ComboBox<>("Duplicate captions test Box"); | |||
box.setId("ComboBox"); | |||
box.setImmediate(true); | |||
box.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange( | |||
com.vaadin.v7.data.Property.ValueChangeEvent event) { | |||
Person p = (Person) event.getProperty().getValue(); | |||
log.log("Person = " + p.getFirstName() + " " + p.getLastName()); | |||
} | |||
box.addValueChangeListener(event -> { | |||
Person p = event.getValue(); | |||
log.log("Person = " + p.getFirstName() + " " + p.getLastName()); | |||
}); | |||
box.setContainerDataSource(container); | |||
box.setItemCaptionMode(ItemCaptionMode.PROPERTY); | |||
box.setItemCaptionPropertyId("lastName"); | |||
box.setItems(list); | |||
box.setItemCaptionProvider(Person::getLastName); | |||
addComponent(log); | |||
@@ -57,7 +43,7 @@ public class ComboBoxDuplicateCaption extends TestBase { | |||
@Override | |||
protected String getDescription() { | |||
return "VFilterSelects with duplicate item captions should not try to do a select (exact match search) for onBlur if not waitingForFilteringResponse"; | |||
return "ComboBoxes with duplicate item captions should not try to do a select (exact match search) for onBlur if not waitingForFilteringResponse"; | |||
} | |||
@Override |
@@ -1,14 +1,15 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxEmptyItemsKeyboardNavigation extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox comboBox = new ComboBox(); | |||
comboBox.addItems("foo", "bar"); | |||
ComboBox<String> comboBox = new ComboBox<>(null, | |||
DataSource.create("foo", "bar")); | |||
addComponent(comboBox); | |||
} |
@@ -1,9 +1,10 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxEnablesComboBox extends TestBase { | |||
@@ -11,19 +12,10 @@ public class ComboBoxEnablesComboBox extends TestBase { | |||
@Override | |||
protected void setup() { | |||
ComboBox cb = new ComboBox("Always enabled"); | |||
cb.setImmediate(true); | |||
ComboBox<String> cb = new ComboBox<>("Always enabled"); | |||
populate(cb); | |||
cb.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
cb2.setEnabled(true); | |||
} | |||
}); | |||
cb2 = new ComboBox("Initially disabled"); | |||
cb2.setImmediate(true); | |||
cb.addValueChangeListener(event -> cb2.setEnabled(true)); | |||
cb2 = new ComboBox<String>("Initially disabled"); | |||
cb2.setEnabled(false); | |||
populate(cb2); | |||
@@ -31,10 +23,12 @@ public class ComboBoxEnablesComboBox extends TestBase { | |||
addComponent(cb2); | |||
} | |||
private void populate(ComboBox cb) { | |||
private void populate(ComboBox<String> cb) { | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 1; i < 10; i++) { | |||
cb.addItem("Item " + i); | |||
items.add("Item " + i); | |||
} | |||
cb.setItems(items); | |||
} | |||
@Override |
@@ -3,36 +3,21 @@ package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.v7.data.Item; | |||
import com.vaadin.v7.data.Property; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxIdenticalItems extends AbstractTestUI { | |||
private Log log = new Log(5); | |||
@SuppressWarnings("unchecked") | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final ComboBox select = new ComboBox("ComboBox"); | |||
select.addContainerProperty("caption", String.class, null); | |||
Item item = select.addItem("one-1"); | |||
item.getItemProperty("caption").setValue("One"); | |||
item = select.addItem("one-2"); | |||
item.getItemProperty("caption").setValue("One"); | |||
item = select.addItem("two"); | |||
item.getItemProperty("caption").setValue("Two"); | |||
select.setItemCaptionPropertyId("caption"); | |||
select.setNullSelectionAllowed(false); | |||
select.setImmediate(true); | |||
select.addValueChangeListener(new Property.ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
log.log("Item " + select.getValue() + " selected"); | |||
} | |||
}); | |||
final ComboBox<String> select = new ComboBox<>("ComboBox"); | |||
select.setItemCaptionProvider( | |||
item -> item.startsWith("one") ? "One" : "Two"); | |||
select.setItems("one-1", "one-2", "two"); | |||
select.setEmptySelectionAllowed(false); | |||
select.addValueChangeListener( | |||
event -> log.log("Item " + select.getValue() + " selected")); | |||
addComponent(log); | |||
addComponent(select); | |||
@@ -41,10 +26,10 @@ public class ComboBoxIdenticalItems extends AbstractTestUI { | |||
@Override | |||
protected String getTestDescription() { | |||
return "Keyboard selecting of a value is broken in combobox if two " | |||
+ "items have the same caption. The first item's id is \"One-1\" " | |||
+ "while the second one is \"One-2\". Selecting with mouse works " | |||
+ "items have the same caption. The first item's id is \"one-1\" " | |||
+ "while the second one is \"one-2\". Selecting with mouse works " | |||
+ "as expected but selecting with keyboard always returns the " | |||
+ "object \"One-1\"."; | |||
+ "object \"one-1\"."; | |||
} | |||
@Override |
@@ -1,13 +1,14 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.event.ShortcutAction.KeyCode; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class ComboBoxInPopup extends TestBase { | |||
@@ -34,12 +35,8 @@ public class ComboBoxInPopup extends TestBase { | |||
} | |||
private Component createComboBox() { | |||
ComboBox cb = new ComboBox("A combo box"); | |||
cb.addItem("Yes"); | |||
cb.addItem("No"); | |||
cb.addItem("Maybe"); | |||
return cb; | |||
return new ComboBox<String>("A combo box", | |||
DataSource.create("Yes", "No", "Maybe")); | |||
} | |||
@Override |
@@ -18,33 +18,27 @@ package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxInputPrompt extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final ComboBox cb1 = new ComboBox("Normal"); | |||
cb1.setInputPrompt("Normal input prompt"); | |||
final ComboBox<String> cb1 = new ComboBox<String>("Normal"); | |||
cb1.setPlaceholder("Normal input prompt"); | |||
final ComboBox cb2 = new ComboBox("Disabled"); | |||
final ComboBox<String> cb2 = new ComboBox<String>("Disabled"); | |||
cb2.setEnabled(false); | |||
cb2.setInputPrompt("Disabled input prompt"); | |||
cb2.setPlaceholder("Disabled input prompt"); | |||
final ComboBox cb3 = new ComboBox("Read-only"); | |||
final ComboBox<String> cb3 = new ComboBox<String>("Read-only"); | |||
cb3.setReadOnly(true); | |||
cb3.setInputPrompt("Read-only input prompt"); | |||
cb3.setPlaceholder("Read-only input prompt"); | |||
Button enableButton = new Button("Toggle enabled", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
cb2.setEnabled(!cb2.isEnabled()); | |||
cb3.setReadOnly(!cb3.isReadOnly()); | |||
} | |||
}); | |||
Button enableButton = new Button("Toggle enabled", event -> { | |||
cb2.setEnabled(!cb2.isEnabled()); | |||
cb3.setReadOnly(!cb3.isReadOnly()); | |||
}); | |||
addComponents(cb1, cb2, cb3, enableButton); | |||
} |
@@ -1,20 +1,17 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.data.util.IndexedContainer; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxInvalidNullSelection extends TestBase { | |||
private static final Object CAPTION = "C"; | |||
private IndexedContainer ds1; | |||
private IndexedContainer ds2; | |||
private ComboBox combo; | |||
private DataSource<String> ds1; | |||
private DataSource<String> ds2; | |||
private ComboBox<String> combo; | |||
private Log log = new Log(5); | |||
@Override | |||
@@ -23,28 +20,19 @@ public class ComboBoxInvalidNullSelection extends TestBase { | |||
createDataSources(); | |||
Button b = new Button("Swap data source"); | |||
b.addListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
if (combo.getContainerDataSource() == ds1) { | |||
combo.setContainerDataSource(ds2); | |||
} else { | |||
combo.setContainerDataSource(ds1); | |||
} | |||
combo.setValue("Item 3"); | |||
b.addClickListener(event -> { | |||
if (combo.getDataSource() == ds1) { | |||
combo.setDataSource(ds2); | |||
} else { | |||
combo.setDataSource(ds1); | |||
} | |||
combo.setValue("Item 3"); | |||
}); | |||
combo = new ComboBox(); | |||
combo.setImmediate(true); | |||
combo.setContainerDataSource(ds1); | |||
combo.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
log.log("Value is now: " + combo.getValue()); | |||
} | |||
}); | |||
combo = new ComboBox<>(); | |||
combo.setDataSource(ds1); | |||
combo.addValueChangeListener( | |||
event -> log.log("Value is now: " + combo.getValue())); | |||
addComponent(log); | |||
addComponent(b); | |||
addComponent(combo); | |||
@@ -52,16 +40,9 @@ public class ComboBoxInvalidNullSelection extends TestBase { | |||
} | |||
private void createDataSources() { | |||
ds1 = new IndexedContainer(); | |||
ds1.addContainerProperty(CAPTION, String.class, ""); | |||
ds1.addItem("Item 1"); | |||
ds1.addItem("Item 2"); | |||
ds1.addItem("Item 3"); | |||
ds1.addItem("Item 4"); | |||
ds1 = DataSource.create("Item 1", "Item 2", "Item 3", "Item 4"); | |||
ds2 = new IndexedContainer(); | |||
ds2.addContainerProperty(CAPTION, String.class, ""); | |||
ds2.addItem("Item 3"); | |||
ds2 = DataSource.create("Item 3"); | |||
} | |||
@@ -1,10 +1,8 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.Resource; | |||
import com.vaadin.server.ThemeResource; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.v7.data.Item; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxItemIcon extends TestBase { | |||
@@ -21,33 +19,19 @@ public class ComboBoxItemIcon extends TestBase { | |||
@Override | |||
protected void setup() { | |||
{ | |||
ComboBox cb = new ComboBox(); | |||
cb.addContainerProperty("icon", Resource.class, null); | |||
cb.setItemIconPropertyId("icon"); | |||
Item item = cb.addItem("FI"); | |||
item.getItemProperty("icon").setValue( | |||
new ThemeResource("../tests-tickets/icons/fi.gif")); | |||
item = cb.addItem("SE"); | |||
item.getItemProperty("icon").setValue( | |||
new ThemeResource("../tests-tickets/icons/se.gif")); | |||
ComboBox<String> cb = new ComboBox<>(); | |||
cb.setItems("FI", "SE"); | |||
cb.setItemIconProvider(item -> new ThemeResource( | |||
"../tests-tickets/icons/" + item.toLowerCase() + ".gif")); | |||
addComponent(cb); | |||
} | |||
{ | |||
ComboBox cb = new ComboBox(); | |||
cb.addContainerProperty("icon", Resource.class, null); | |||
cb.setItemIconPropertyId("icon"); | |||
Item item = cb.addItem("Finland"); | |||
item.getItemProperty("icon").setValue( | |||
new ThemeResource("../tests-tickets/icons/fi.gif")); | |||
item = cb.addItem("Australia"); | |||
item.getItemProperty("icon").setValue( | |||
new ThemeResource("../tests-tickets/icons/au.gif")); | |||
item = cb.addItem("Hungary"); | |||
item.getItemProperty("icon").setValue( | |||
new ThemeResource("../tests-tickets/icons/hu.gif")); | |||
ComboBox<String> cb = new ComboBox<>(); | |||
cb.setItems("Finland", "Australia", "Hungary"); | |||
cb.setItemIconProvider( | |||
item -> new ThemeResource("../tests-tickets/icons/" | |||
+ item.substring(0, 2).toLowerCase() + ".gif")); | |||
cb.setValue("Hungary"); | |||
addComponent(cb); |
@@ -2,11 +2,10 @@ package com.vaadin.tests.components.combobox; | |||
import java.util.Date; | |||
import com.vaadin.server.Resource; | |||
import com.vaadin.server.ThemeResource; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.v7.data.Item; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxLargeIcons extends TestBase { | |||
@@ -22,22 +21,15 @@ public class ComboBoxLargeIcons extends TestBase { | |||
@Override | |||
protected void setup() { | |||
ComboBox cb = new ComboBox(); | |||
cb.addContainerProperty("icon", Resource.class, null); | |||
cb.setItemIconPropertyId("icon"); | |||
ComboBox<String> cb = new ComboBox<String>(null, | |||
DataSource.create("folder-add", "folder-delete", "arrow-down", | |||
"arrow-left", "arrow-right", "arrow-up", "document-add", | |||
"document-delete", "document-doc", "document-edit", | |||
"document-image", "document-pdf", "document-ppt", | |||
"document-txt", "document-web", "document")); | |||
getLayout().addComponent(cb); | |||
cb.setNullSelectionAllowed(false); | |||
String[] icons = new String[] { "folder-add", "folder-delete", | |||
"arrow-down", "arrow-left", "arrow-right", "arrow-up", | |||
"document-add", "document-delete", "document-doc", | |||
"document-edit", "document-image", "document-pdf", | |||
"document-ppt", "document-txt", "document-web", "document" }; | |||
for (String icon : icons) { | |||
Item item = cb.addItem(icon); | |||
item.getItemProperty("icon") | |||
.setValue(new ThemeResource("../runo/icons/32/" + icon | |||
+ ".png?" + new Date().getTime())); | |||
} | |||
// FIXME cb.setNullSelectionAllowed(false); | |||
cb.setItemIconProvider(icon -> new ThemeResource( | |||
"../runo/icons/32/" + icon + ".png?" + new Date().getTime())); | |||
} | |||
} |
@@ -15,40 +15,32 @@ | |||
*/ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.v7.data.Property; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class ComboBoxMouseSelectEnter extends AbstractTestUI { | |||
protected ComboBox comboBox; | |||
protected ComboBox<String> comboBox; | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
comboBox = new ComboBox(); | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 0; i < 10; i++) { | |||
items.add("a" + i); | |||
} | |||
comboBox = new ComboBox<>(null, items); | |||
final Label label = new Label(); | |||
label.setId("value"); | |||
comboBox.setTextInputAllowed(true); | |||
comboBox.setNullSelectionAllowed(true); | |||
comboBox.setNullSelectionItemId(null); | |||
for (int i = 0; i < 10; i++) { | |||
comboBox.addItem("a" + i); | |||
} | |||
comboBox.setEmptySelectionAllowed(true); | |||
comboBox.addValueChangeListener(new Property.ValueChangeListener() { | |||
@Override | |||
public void valueChange(Property.ValueChangeEvent event) { | |||
Object value = event.getProperty().getValue(); | |||
if (value != null) { | |||
label.setValue(value.toString()); | |||
} else { | |||
label.setValue("null"); | |||
} | |||
} | |||
}); | |||
comboBox.addValueChangeListener( | |||
event -> label.setValue(String.valueOf(event.getValue()))); | |||
addComponents(comboBox); | |||
addComponent(label); |
@@ -15,9 +15,12 @@ | |||
*/ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
/** | |||
* Tests mousewheel handling in ComboBox. | |||
@@ -36,12 +39,12 @@ public class ComboBoxMousewheel extends AbstractTestUI { | |||
} | |||
private ComboBox createComboBox(String caption) { | |||
ComboBox cb = new ComboBox(caption); | |||
cb.setId(caption); | |||
cb.setImmediate(true); | |||
List<String> data = new ArrayList<>(); | |||
for (int i = 1; i < 100; i++) { | |||
cb.addItem("Item " + i); | |||
data.add("Item " + i); | |||
} | |||
ComboBox<String> cb = new ComboBox<>(caption, data); | |||
cb.setId(caption); | |||
return cb; | |||
} | |||
@@ -1,8 +1,10 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.v7.shared.ui.combobox.FilteringMode; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxNavigation extends TestBase { | |||
@@ -18,12 +20,12 @@ public class ComboBoxNavigation extends TestBase { | |||
@Override | |||
protected void setup() { | |||
ComboBox cb = new ComboBox(); | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 1; i < 100; i++) { | |||
cb.addItem("Item " + i); | |||
items.add("Item " + i); | |||
} | |||
ComboBox cb = new ComboBox(null, items); | |||
cb.setFilteringMode(FilteringMode.CONTAINS); | |||
addComponent(cb); | |||
} |
@@ -3,11 +3,9 @@ package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.FormLayout; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.data.Property; | |||
import com.vaadin.v7.ui.ComboBox; | |||
/** | |||
* The Application's "main" class | |||
@@ -23,21 +21,14 @@ public class ComboBoxParentDisable extends AbstractTestUIWithLog { | |||
final FormLayout formLayout = new FormLayout(); | |||
final ComboBox combo = new ComboBox("Item:"); | |||
combo.addItem("Item 1"); | |||
combo.addItem("Item 2"); | |||
combo.addItem("Item 3"); | |||
combo.addItem("Item 4"); | |||
combo.addValueChangeListener(new MyValueChangeListener()); | |||
final ComboBox<String> combo = new ComboBox<>("Item:"); | |||
combo.setItems("Item 1", "Item 2", "Item 3", "Item 4"); | |||
combo.addValueChangeListener( | |||
event -> log.log("you made a selection change")); | |||
combo.setImmediate(true); | |||
Button btn1 = new Button("Click me"); | |||
btn1.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log.log("you clicked me"); | |||
} | |||
}); | |||
btn1.addClickListener(event -> log.log("you clicked me")); | |||
formLayout.addComponent(combo); | |||
formLayout.addComponent(btn1); | |||
@@ -45,31 +36,14 @@ public class ComboBoxParentDisable extends AbstractTestUIWithLog { | |||
layout.addComponent(formLayout); | |||
Button btn = new Button("Enable/Disable combobox", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
combo.setEnabled(!combo.isEnabled()); | |||
} | |||
}); | |||
event -> combo.setEnabled(!combo.isEnabled())); | |||
layout.addComponent(btn); | |||
btn = new Button("Enable/Disable parent", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
formLayout.setEnabled(!formLayout.isEnabled()); | |||
} | |||
}); | |||
btn = new Button("Enable/Disable parent", | |||
event -> formLayout.setEnabled(!formLayout.isEnabled())); | |||
layout.addComponent(btn); | |||
} | |||
private class MyValueChangeListener | |||
implements Property.ValueChangeListener { | |||
@Override | |||
public void valueChange(Property.ValueChangeEvent event) { | |||
log.log("you made a selection change"); | |||
} | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Test for ensuring that disabling a parent properly disables the combobox"; |
@@ -15,10 +15,13 @@ | |||
*/ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class ComboBoxPopupWhenBodyScrolls extends AbstractTestUI { | |||
@@ -28,10 +31,11 @@ public class ComboBoxPopupWhenBodyScrolls extends AbstractTestUI { | |||
.add("body.v-generated-body { overflow: auto;height:auto;}"); | |||
getPage().getStyles().add( | |||
"body.v-generated-body .v-ui.v-scrollable{ overflow: visible;height:auto !important;}"); | |||
ComboBox cb = new ComboBox(); | |||
List<String> data = new ArrayList<>(); | |||
for (int i = 0; i < 10; i++) { | |||
cb.addItem("Item " + i); | |||
data.add("Item " + i); | |||
} | |||
ComboBox<String> cb = new ComboBox<>(null, data); | |||
Label spacer = new Label("foo"); | |||
spacer.setHeight("2000px"); |
@@ -1,12 +1,11 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.tests.components.ComponentTestCase; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Notification; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class ComboBoxScrollingToPageDisabled | |||
extends ComponentTestCase<ComboBox> { | |||
@@ -20,42 +19,26 @@ public class ComboBoxScrollingToPageDisabled | |||
@Override | |||
protected void initializeComponents() { | |||
ComboBox s = createSelect(null); | |||
ComboBox<String> s = createSelect(null); | |||
s.setScrollToSelectedItem(false); | |||
populate(s, 100); | |||
Object selection = new ArrayList<Object>(s.getItemIds()).get(50); | |||
s.setValue(selection); | |||
s.setValue("Item 50"); | |||
addTestComponent(s); | |||
} | |||
private void populate(ComboBox s, int nr) { | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 0; i < nr; i++) { | |||
addItem(s, "Item " + i); | |||
items.add("Item " + i); | |||
} | |||
s.setItems(items); | |||
} | |||
@SuppressWarnings("unchecked") | |||
private void addItem(ComboBox s, String string) { | |||
Object id = s.addItem(); | |||
s.getItem(id).getItemProperty(CAPTION).setValue(string); | |||
} | |||
private ComboBox createSelect(String caption) { | |||
final ComboBox cb = new ComboBox(); | |||
cb.setImmediate(true); | |||
cb.addContainerProperty(CAPTION, String.class, ""); | |||
cb.setItemCaptionPropertyId(CAPTION); | |||
private ComboBox<String> createSelect(String caption) { | |||
final ComboBox<String> cb = new ComboBox<>(); | |||
cb.setCaption(caption); | |||
cb.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
Notification.show("Value now:" + cb.getValue() + " " | |||
+ cb.getItemCaption(cb.getValue())); | |||
} | |||
}); | |||
cb.addValueChangeListener(event -> Notification | |||
.show("Value now:" + cb.getValue() + " " + cb.getValue())); | |||
return cb; | |||
} | |||
@@ -15,11 +15,14 @@ | |||
*/ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.AbstractLayout; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.ui.ComboBox; | |||
/** | |||
* Test UI verifying navigating in combobox via arrow keys. | |||
@@ -61,12 +64,14 @@ public class ComboBoxScrollingWithArrows extends AbstractTestUI { | |||
} | |||
private void addComboBox(AbstractLayout layout) { | |||
ComboBox box = new ComboBox(); | |||
ComboBox<String> box = new ComboBox<>(); | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 0; i < 100; i++) { | |||
box.addItem("item " + i); | |||
items.add("item " + i); | |||
} | |||
box.setItems(items); | |||
box.setPageLength(10); | |||
box.setNullSelectionAllowed(false); | |||
box.setEmptySelectionAllowed(false); | |||
layout.addComponent(box); | |||
} | |||
} |
@@ -1,41 +1,38 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.v7.data.Property; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.TextField; | |||
import com.vaadin.ui.TextField; | |||
public class ComboBoxSelecting extends AbstractTestUI { | |||
protected ComboBox comboBox; | |||
protected ComboBox<String> comboBox; | |||
protected List<String> items = new ArrayList<>(); | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
comboBox = new ComboBox(); | |||
final Label label = new Label(); | |||
label.setId("value"); | |||
comboBox.setTextInputAllowed(true); | |||
comboBox.setNullSelectionAllowed(true); | |||
comboBox.setNullSelectionItemId(null); | |||
for (char c = 'a'; c <= 'z'; c++) { | |||
for (int i = 0; i < 100; i++) { | |||
comboBox.addItem("" + c + i); | |||
items.add("" + c + i); | |||
} | |||
} | |||
comboBox = new ComboBox<>(null, items); | |||
final Label label = new Label(); | |||
label.setId("value"); | |||
comboBox.addValueChangeListener(new Property.ValueChangeListener() { | |||
@Override | |||
public void valueChange(Property.ValueChangeEvent event) { | |||
Object value = event.getProperty().getValue(); | |||
if (value != null) { | |||
label.setValue(value.toString()); | |||
} else { | |||
label.setValue("null"); | |||
} | |||
comboBox.setTextInputAllowed(true); | |||
comboBox.setEmptySelectionAllowed(true); | |||
comboBox.addValueChangeListener(event -> { | |||
String value = event.getValue(); | |||
if (value != null) { | |||
label.setValue(value); | |||
} else { | |||
label.setValue("null"); | |||
} | |||
}); | |||
@@ -16,27 +16,27 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.server.data.Query; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.v7.data.Property; | |||
public class ComboBoxSelectingWithNewItemsAllowed extends ComboBoxSelecting { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
super.setup(request); | |||
comboBox.setNewItemsAllowed(true); | |||
final Label label = new Label( | |||
String.valueOf(comboBox.getItemIds().size())); | |||
final Label label = new Label(String.valueOf(items.size())); | |||
label.setCaption("Item count:"); | |||
label.setId("count"); | |||
comboBox.addValueChangeListener(new Property.ValueChangeListener() { | |||
@Override | |||
public void valueChange(Property.ValueChangeEvent event) { | |||
label.setValue(String.valueOf(comboBox.getItemIds().size())); | |||
} | |||
comboBox.setNewItemHandler(text -> { | |||
items.add(text); | |||
comboBox.setItems(items); | |||
comboBox.select(text); | |||
label.setValue(String.valueOf(items.size())); | |||
}); | |||
comboBox.addValueChangeListener(event -> label.setValue( | |||
String.valueOf(comboBox.getDataSource().size(new Query())))); | |||
addComponent(label); | |||
} | |||
@@ -5,9 +5,9 @@ import java.util.Arrays; | |||
import com.vaadin.event.FieldEvents; | |||
import com.vaadin.event.FieldEvents.FocusEvent; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class ComboBoxSuggestionOnDetach extends TestBase { | |||
@@ -20,7 +20,7 @@ public class ComboBoxSuggestionOnDetach extends TestBase { | |||
layout.setSizeUndefined(); | |||
popup.setContent(layout); | |||
ComboBox comboBox = new ComboBox("Combo box", | |||
ComboBox<String> comboBox = new ComboBox<>("Combo box", | |||
Arrays.asList("Option 1", "Option 2", "Option 3")); | |||
comboBox.addFocusListener(new FieldEvents.FocusListener() { | |||
@Override |
@@ -20,8 +20,7 @@ import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.shared.ui.combobox.FilteringMode; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxSuggestionPageLength extends AbstractTestUI { | |||
@@ -30,14 +29,12 @@ public class ComboBoxSuggestionPageLength extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox cb = new ComboBox("Page length 0", items); | |||
ComboBox<String> cb = new ComboBox<>("Page length 0", items); | |||
cb.setPageLength(0); | |||
cb.setFilteringMode(FilteringMode.CONTAINS); | |||
addComponent(cb); | |||
cb = new ComboBox("Page length 2", items); | |||
cb = new ComboBox<>("Page length 2", items); | |||
cb.setPageLength(2); | |||
cb.setFilteringMode(FilteringMode.CONTAINS); | |||
addComponent(cb); | |||
} | |||
@@ -2,16 +2,14 @@ package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxSuggestionPopupClose extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final ComboBox select = new ComboBox("ComboBox"); | |||
select.addItem("one"); | |||
select.addItem("two"); | |||
select.addItem("three"); | |||
final ComboBox<String> select = new ComboBox<>("ComboBox"); | |||
select.setItems("one", "two", "three"); | |||
addComponent(select); | |||
} | |||
@@ -5,7 +5,7 @@ import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxSuggestionPopupWidth extends AbstractTestUI { | |||
@@ -16,7 +16,7 @@ public class ComboBoxSuggestionPopupWidth extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox cb = new ComboBox( | |||
ComboBox<String> cb = new ComboBox<>( | |||
"200px wide ComboBox with 100% wide suggestion popup", items); | |||
cb.setPopupWidth("100%"); | |||
cb.setWidth("200px"); |
@@ -5,7 +5,7 @@ import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxSuggestionPopupWidthLegacy extends AbstractTestUI { | |||
@@ -16,7 +16,7 @@ public class ComboBoxSuggestionPopupWidthLegacy extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox legacy = new ComboBox( | |||
ComboBox<String> legacy = new ComboBox<>( | |||
"200px wide ComboBox with legacy mode suggestion popup setPopupWidth(null)", | |||
items); | |||
legacy.addStyleName("legacy"); |
@@ -5,7 +5,7 @@ import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxSuggestionPopupWidthPercentage extends AbstractTestUI { | |||
@@ -16,7 +16,7 @@ public class ComboBoxSuggestionPopupWidthPercentage extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox percentage = new ComboBox( | |||
ComboBox<String> percentage = new ComboBox<>( | |||
"200px wide ComboBox with 200% wide suggestion popup", items); | |||
percentage.addStyleName("percentage"); | |||
percentage.setWidth("200px"); |
@@ -5,7 +5,7 @@ import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxSuggestionPopupWidthPixels extends AbstractTestUI { | |||
@@ -16,7 +16,7 @@ public class ComboBoxSuggestionPopupWidthPixels extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox pixels = new ComboBox( | |||
ComboBox<String> pixels = new ComboBox<>( | |||
"200px wide ComboBox with 300px wide suggestion popup", items); | |||
pixels.addStyleName("pixels"); | |||
pixels.setWidth("200px"); |
@@ -1,25 +1,22 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.Resource; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.ThemeResource; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.v7.data.Item; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxUndefinedWidthAndIcon extends TestBase { | |||
@Override | |||
protected void setup() { | |||
ComboBox cb = new ComboBox(); | |||
cb.addContainerProperty("caption", String.class, null); | |||
cb.addContainerProperty("icon", Resource.class, null); | |||
List<String> data = new ArrayList<>(); | |||
for (int i = 1; i < 200 + 1; i++) { | |||
Item item = cb.addItem(i); | |||
item.getItemProperty("caption").setValue("Item " + i); | |||
item.getItemProperty("icon") | |||
.setValue(new ThemeResource("../runo/icons/16/users.png")); | |||
data.add("Item " + i); | |||
} | |||
cb.setItemIconPropertyId("icon"); | |||
cb.setItemCaptionPropertyId("caption"); | |||
ComboBox<String> cb = new ComboBox<>(null, data); | |||
cb.setItemIconProvider( | |||
item -> new ThemeResource("../runo/icons/16/users.png")); | |||
addComponent(cb); | |||
} |
@@ -1,12 +1,12 @@ | |||
/* | |||
* Copyright 2000-2014 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 | |||
@@ -15,10 +15,13 @@ | |||
*/ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.annotations.Theme; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
@Theme("valo") | |||
public class ComboBoxValoDoubleClick extends AbstractTestUI { | |||
@@ -28,10 +31,12 @@ public class ComboBoxValoDoubleClick extends AbstractTestUI { | |||
// bug. Manually a double click is just about the right timing. | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox cb = new ComboBox("Double-click Me"); | |||
ComboBox<String> cb = new ComboBox<>("Double-click Me"); | |||
List<String> items = new ArrayList<String>(); | |||
for (int i = 0; i < 100; i++) { | |||
cb.addItem("Item-" + i); | |||
items.add("Item-" + i); | |||
} | |||
cb.setItems(items); | |||
addComponent(cb); | |||
} | |||
@@ -1,9 +1,11 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class ComboBoxValueUpdate extends TestBase { | |||
@@ -19,23 +21,17 @@ public class ComboBoxValueUpdate extends TestBase { | |||
@Override | |||
protected void setup() { | |||
ComboBox select = new ComboBox(""); | |||
select.setImmediate(true); | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 0; i < 100; i++) { | |||
select.addItem("item " + i); | |||
items.add("item " + i); | |||
} | |||
ComboBox<String> select = new ComboBox<>("", items); | |||
final Label value = new Label(); | |||
select.addListener(new ComboBox.ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
System.err | |||
.println("Selected " + event.getProperty().getValue()); | |||
value.setValue("Selected " + event.getProperty().getValue()); | |||
} | |||
select.addValueChangeListener(event -> { | |||
System.err.println("Selected " + event.getValue()); | |||
value.setValue("Selected " + event.getValue()); | |||
}); | |||
getLayout().addComponent(select); |
@@ -3,15 +3,12 @@ package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.event.FieldEvents; | |||
import com.vaadin.event.FieldEvents.BlurEvent; | |||
import com.vaadin.event.FieldEvents.FocusEvent; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.TextField; | |||
import com.vaadin.v7.data.util.ObjectProperty; | |||
import com.vaadin.v7.shared.ui.label.ContentMode; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.Label; | |||
import com.vaadin.v7.ui.TextField; | |||
public class ComboFocusBlurEvents extends TestBase { | |||
@@ -25,34 +22,26 @@ public class ComboFocusBlurEvents extends TestBase { | |||
list.add("Item " + i); | |||
} | |||
ComboBox cb = new ComboBox("Combobox", list); | |||
cb.setImmediate(true); | |||
cb.setInputPrompt("Enter text"); | |||
ComboBox<String> cb = new ComboBox<>("Combobox", list); | |||
cb.setPlaceholder("Enter text"); | |||
cb.setDescription("Some Combobox"); | |||
addComponent(cb); | |||
final ObjectProperty<String> log = new ObjectProperty<>(""); | |||
cb.addFocusListener(new FieldEvents.FocusListener() { | |||
@Override | |||
public void focus(FocusEvent event) { | |||
log.setValue(log.getValue().toString() + "<br>" + counter | |||
+ ": Focus event!"); | |||
counter++; | |||
} | |||
cb.addFocusListener(event -> { | |||
log.setValue(log.getValue().toString() + "<br>" + counter | |||
+ ": Focus event!"); | |||
counter++; | |||
}); | |||
cb.addBlurListener(new FieldEvents.BlurListener() { | |||
@Override | |||
public void blur(BlurEvent event) { | |||
log.setValue(log.getValue().toString() + "<br>" + counter | |||
+ ": Blur event!"); | |||
counter++; | |||
} | |||
cb.addBlurListener(event -> { | |||
log.setValue(log.getValue().toString() + "<br>" + counter | |||
+ ": Blur event!"); | |||
counter++; | |||
}); | |||
TextField field = new TextField("Some textfield"); | |||
field.setImmediate(true); | |||
addComponent(field); | |||
Label output = new Label(log); |
@@ -1,11 +1,12 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
@SuppressWarnings("serial") | |||
public class ComboSelectedValueBeyondTheFirstDropdownPage | |||
@@ -17,7 +18,7 @@ public class ComboSelectedValueBeyondTheFirstDropdownPage | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Label value = getLabel(); | |||
ComboBox combobox = getComboBox(value); | |||
ComboBox<String> combobox = getComboBox(value); | |||
addComponent(combobox); | |||
addComponent(value); | |||
@@ -30,23 +31,19 @@ public class ComboSelectedValueBeyondTheFirstDropdownPage | |||
return value; | |||
} | |||
private ComboBox getComboBox(final Label value) { | |||
final ComboBox combobox = new ComboBox("MyCaption"); | |||
private ComboBox<String> getComboBox(final Label value) { | |||
final ComboBox<String> combobox = new ComboBox<>("MyCaption"); | |||
combobox.setDescription( | |||
"ComboBox with more than 10 elements in it's dropdown list."); | |||
combobox.setImmediate(true); | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 1; i <= ITEM_COUNT; i++) { | |||
combobox.addItem(String.format(ITEM_NAME_TEMPLATE, i)); | |||
items.add(String.format(ITEM_NAME_TEMPLATE, i)); | |||
} | |||
combobox.setItems(items); | |||
combobox.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
value.setValue(String.valueOf(event.getProperty().getValue())); | |||
} | |||
}); | |||
combobox.addValueChangeListener( | |||
event -> value.setValue(String.valueOf(event.getValue()))); | |||
return combobox; | |||
} |
@@ -3,9 +3,9 @@ package com.vaadin.tests.components.combobox; | |||
import java.util.Arrays; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.PopupView; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.TextArea; | |||
public class ComboboxInPopupViewWithItems extends TestBase { | |||
@@ -29,7 +29,7 @@ public class ComboboxInPopupViewWithItems extends TestBase { | |||
class PopupContent implements PopupView.Content { | |||
private final ComboBox cb = new ComboBox(null, | |||
private final ComboBox<String> cb = new ComboBox<>(null, | |||
Arrays.asList("Item 1", "Item 2", "Item 3")); | |||
@Override |
@@ -15,17 +15,16 @@ | |||
*/ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import com.vaadin.server.Page; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.MenuBar; | |||
import com.vaadin.ui.MenuBar.MenuItem; | |||
import com.vaadin.ui.Notification; | |||
import com.vaadin.ui.Notification.Type; | |||
import com.vaadin.v7.ui.ComboBox; | |||
/** | |||
* Test UI for combobox popup which should be closed on any click outside it. | |||
@@ -38,11 +37,8 @@ public class ComboboxMenuBarAutoopen extends AbstractTestUI { | |||
protected void setup(VaadinRequest request) { | |||
HorizontalLayout layout = new HorizontalLayout(); | |||
layout.setSpacing(true); | |||
ArrayList<String> options = new ArrayList<>(); | |||
options.add("1"); | |||
options.add("2"); | |||
options.add("3"); | |||
ComboBox combo = new ComboBox(null, options); | |||
ComboBox<String> combo = new ComboBox<>(null, | |||
DataSource.create("1", "2", "3")); | |||
layout.addComponent(combo); | |||
MenuBar menubar = getMenubar(); |
@@ -1,10 +1,13 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.annotations.Theme; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.v7.ui.ComboBox; | |||
@Theme("valo") | |||
public class ComboboxPopupScrolling extends AbstractTestUIWithLog { | |||
@@ -12,25 +15,24 @@ public class ComboboxPopupScrolling extends AbstractTestUIWithLog { | |||
protected void setup(VaadinRequest request) { | |||
ComboBox combobox = new ComboBox("100px wide combobox"); | |||
combobox.setWidth("100px"); | |||
combobox.addItem("AMERICAN SAMOA"); | |||
combobox.addItem("ANTIGUA AND BARBUDA"); | |||
combobox.setItems("AMERICAN SAMOA", "ANTIGUA AND BARBUDA"); | |||
ComboBox combobox2 = new ComboBox("250px wide combobox"); | |||
combobox2.setWidth("250px"); | |||
combobox2.addItem("AMERICAN SAMOA"); | |||
combobox2.addItem("ANTIGUA AND BARBUDA"); | |||
combobox2.setItems("AMERICAN SAMOA", "ANTIGUA AND BARBUDA"); | |||
ComboBox combobox3 = new ComboBox("Undefined wide combobox"); | |||
combobox3.setWidth(null); | |||
combobox3.addItem("AMERICAN SAMOA"); | |||
combobox3.addItem("ANTIGUA AND BARBUDA"); | |||
combobox3.setItems("AMERICAN SAMOA", "ANTIGUA AND BARBUDA"); | |||
ComboBox combobox4 = new ComboBox("Another 100px wide combobox"); | |||
combobox4.setWidth("100px"); | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 0; i < 10; i++) { | |||
combobox4.addItem("AMERICAN SAMOA " + i); | |||
combobox4.addItem("ANTIGUA AND BARBUDA " + i); | |||
items.add("AMERICAN SAMOA " + i); | |||
items.add("ANTIGUA AND BARBUDA " + i); | |||
} | |||
combobox4.setItems(items); | |||
HorizontalLayout hl = new HorizontalLayout(combobox, combobox2, | |||
combobox3, combobox4); |
@@ -1,33 +1,22 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboboxPrimaryStyleNames extends TestBase { | |||
@Override | |||
protected void setup() { | |||
final ComboBox box = new ComboBox(); | |||
final ComboBox<String> box = new ComboBox(null, | |||
DataSource.create("Value 1", "Value 2", "Value 3", "Value 4")); | |||
box.setImmediate(true); | |||
box.addContainerProperty("caption", String.class, ""); | |||
box.setItemCaptionPropertyId("caption"); | |||
box.setPrimaryStyleName("my-combobox"); | |||
addItem(box, "Value 1"); | |||
addItem(box, "Value 2"); | |||
addItem(box, "Value 3"); | |||
addItem(box, "Value 4"); | |||
addComponent(box); | |||
addComponent( | |||
new Button("Set primary style", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
box.setPrimaryStyleName("my-second-combobox"); | |||
} | |||
})); | |||
addComponent(new Button("Set primary style", | |||
event -> box.setPrimaryStyleName("my-second-combobox"))); | |||
} | |||
@@ -41,9 +30,4 @@ public class ComboboxPrimaryStyleNames extends TestBase { | |||
return 9901; | |||
} | |||
private void addItem(ComboBox s, String string) { | |||
Object id = s.addItem(); | |||
s.getItem(id).getItemProperty("caption").setValue(string); | |||
} | |||
} |
@@ -16,10 +16,10 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.server.data.DataSource; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
/** | |||
* Test UI for adding a stylename to a combobox with an undefined width. | |||
@@ -30,20 +30,12 @@ public class ComboboxStyleChangeWidth extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final ComboBox cbFoo = new ComboBox(); | |||
cbFoo.setImmediate(true); | |||
final ComboBox<String> cbFoo = new ComboBox<>(null, DataSource.create( | |||
"A really long string that causes an inline width to be set")); | |||
cbFoo.setSizeUndefined(); | |||
cbFoo.addItem( | |||
"A really long string that causes an inline width to be set"); | |||
Button btn = new Button("Click to break CB", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
cbFoo.addStyleName("foofoo"); | |||
} | |||
}); | |||
event -> cbFoo.addStyleName("foofoo")); | |||
addComponent(cbFoo); | |||
addComponent(btn); |
@@ -1,17 +1,28 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
import com.vaadin.server.ThemeResource; | |||
import com.vaadin.tests.components.ComponentTestCase; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class Comboboxes extends ComponentTestCase<ComboBox> { | |||
private static final Object CAPTION = "caption"; | |||
private static class StringBean { | |||
private String value; | |||
public StringBean(String value) { | |||
this.value = value; | |||
} | |||
public String getValue() { | |||
return value; | |||
} | |||
} | |||
@Override | |||
protected Class<ComboBox> getTestClass() { | |||
@@ -20,69 +31,67 @@ public class Comboboxes extends ComponentTestCase<ComboBox> { | |||
@Override | |||
protected void initializeComponents() { | |||
ComboBox s; | |||
s = createSelect(null); | |||
s.setWidth(null); | |||
addTestComponent(s); | |||
s = createSelect("Undefined wide, empty select"); | |||
s.setWidth(null); | |||
addTestComponent(s); | |||
s = createSelect("Undefined wide select with 5 items"); | |||
s.setWidth(null); | |||
addItem(s, "The first item"); | |||
addItem(s, "The second item"); | |||
addItem(s, "The third item"); | |||
addItem(s, "The fourth item"); | |||
addItem(s, "The fifth item"); | |||
addTestComponent(s); | |||
s = createSelect("Undefined wide select with 50 items"); | |||
s.setWidth(null); | |||
populate(s, 50); | |||
addTestComponent(s); | |||
s = createSelect(null); | |||
s.setWidth("100px"); | |||
addTestComponent(s); | |||
s = createSelect("100px wide, empty select"); | |||
s.setWidth("100px"); | |||
addTestComponent(s); | |||
s = createSelect("150px wide select with 5 items"); | |||
s.setWidth("150px"); | |||
addItem(s, "The first item"); | |||
addItem(s, "The second item"); | |||
addItem(s, "The third item"); | |||
addItem(s, "The fourth item"); | |||
addItem(s, "The fifth item"); | |||
addTestComponent(s); | |||
s = createSelect("200px wide select with 50 items"); | |||
s.setWidth("200px"); | |||
populate(s, 50); | |||
addTestComponent(s); | |||
s = new PageLength0ComboBox(); | |||
s.setImmediate(true); | |||
s.addContainerProperty(CAPTION, String.class, ""); | |||
s.setItemCaptionPropertyId(CAPTION); | |||
s.setCaption("Pagelength 0"); | |||
populate(s, 15); | |||
addTestComponent(s); | |||
ComboBox<String> s1 = createSelect(null); | |||
s1.setWidth(null); | |||
addTestComponent(s1); | |||
ComboBox<String> s2 = createSelect("Undefined wide, empty select"); | |||
s2.setWidth(null); | |||
addTestComponent(s2); | |||
ComboBox<String> s3 = createSelect( | |||
"Undefined wide select with 5 items"); | |||
s3.setWidth(null); | |||
s3.setItems("The first item", "The second item", "The third item", | |||
"The fourth item", "The fifth item"); | |||
addTestComponent(s3); | |||
ComboBox<StringBean> s4 = new ComboBox<>( | |||
"Undefined wide select with 50 items"); | |||
s4.setWidth(null); | |||
populate(s4, 50); | |||
s4.setItemCaptionProvider(StringBean::getValue); | |||
s4.setScrollToSelectedItem(true); | |||
addTestComponent(s4); | |||
ComboBox<String> s5 = createSelect(null); | |||
s5.setWidth("100px"); | |||
addTestComponent(s5); | |||
ComboBox<String> s6 = createSelect("100px wide, empty select"); | |||
s6.setWidth("100px"); | |||
addTestComponent(s6); | |||
ComboBox<String> s7 = createSelect("150px wide select with 5 items"); | |||
s7.setWidth("150px"); | |||
s7.setItems("The first item", "The second item", "The third item", | |||
"The fourth item", "The fifth item"); | |||
addTestComponent(s7); | |||
ComboBox<StringBean> s8 = new ComboBox<>( | |||
"200px wide select with 50 items"); | |||
s8.setWidth("200px"); | |||
populate(s8, 50); | |||
s8.setItemCaptionProvider(StringBean::getValue); | |||
addTestComponent(s8); | |||
ComboBox<StringBean> s9 = new PageLength0ComboBox(); | |||
s9.setImmediate(true); | |||
s9.setCaption("Pagelength 0"); | |||
populate(s9, 15); | |||
s9.setItemCaptionProvider(StringBean::getValue); | |||
addTestComponent(s9); | |||
} | |||
public class PageLength0ComboBox extends ComboBox { | |||
public class PageLength0ComboBox extends ComboBox<StringBean> { | |||
public PageLength0ComboBox() { | |||
super(); | |||
setPageLength(0); | |||
} | |||
} | |||
private void populate(ComboBox s, int nr) { | |||
private void populate(ComboBox<StringBean> s, int nr) { | |||
List<StringBean> beans = new ArrayList<>(); | |||
String text = " an item "; | |||
String caption = ""; | |||
@@ -93,25 +102,13 @@ public class Comboboxes extends ComponentTestCase<ComboBox> { | |||
caption += i; | |||
} | |||
addItem(s, caption); | |||
beans.add(new StringBean(caption)); | |||
} | |||
s.setItems(beans); | |||
} | |||
private void addItem(ComboBox s, String string) { | |||
Object id = s.addItem(); | |||
s.getItem(id).getItemProperty(CAPTION).setValue(string); | |||
} | |||
private ComboBox createSelect(String caption) { | |||
ComboBox cb = new ComboBox(); | |||
cb.setImmediate(true); | |||
cb.addContainerProperty(CAPTION, String.class, ""); | |||
cb.setItemCaptionPropertyId(CAPTION); | |||
cb.setCaption(caption); | |||
return cb; | |||
private ComboBox<String> createSelect(String caption) { | |||
return new ComboBox<>(caption); | |||
} | |||
@Override | |||
@@ -124,6 +121,7 @@ public class Comboboxes extends ComponentTestCase<ComboBox> { | |||
actions.add(createIconSelect()); | |||
} | |||
@SuppressWarnings("rawtypes") | |||
private Component createIconSelect() { | |||
LinkedHashMap<String, String> options = new LinkedHashMap<>(); | |||
@@ -135,15 +133,14 @@ public class Comboboxes extends ComponentTestCase<ComboBox> { | |||
return createSelectAction("Icon", options, "<None>", | |||
new Command<ComboBox, String>() { | |||
@SuppressWarnings("unchecked") | |||
@Override | |||
public void execute(ComboBox c, String value, Object data) { | |||
for (Object id : c.getItemIds()) { | |||
if (value == null) { | |||
c.setItemIcon(id, null); | |||
} else { | |||
c.setItemIcon(id, new ThemeResource( | |||
value + "?" + new Date().getTime())); | |||
} | |||
if (value == null) { | |||
c.setItemIconProvider(item -> null); | |||
} else { | |||
c.setItemIconProvider(item -> new ThemeResource( | |||
value + "?" + new Date().getTime())); | |||
} | |||
} | |||
}); |
@@ -1,43 +0,0 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.event.ShortcutAction.KeyCode; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.FormLayout; | |||
import com.vaadin.ui.UI; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.v7.ui.ComboBox; | |||
/** | |||
* Ticket #12163: when a combo box popup is open in a subwindow, escape should | |||
* only close it and not the window, also on Safari 6. | |||
*/ | |||
public class EscapeClosesComboboxNotWindow extends UI { | |||
final Window window = new Window("Window"); | |||
@Override | |||
protected void init(VaadinRequest request) { | |||
final VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
setContent(layout); | |||
Button button = new Button("Click Me"); | |||
button.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
final FormLayout content = new FormLayout(); | |||
ComboBox cb = new ComboBox(); | |||
cb.addItem("foo"); | |||
cb.addItem("bar"); | |||
content.addComponent(cb); | |||
window.setContent(content); | |||
window.setCloseShortcut(KeyCode.ESCAPE); | |||
UI.getCurrent().addWindow(window); | |||
} | |||
}); | |||
layout.addComponent(button); | |||
} | |||
} |
@@ -20,9 +20,7 @@ import java.util.Locale; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.v7.ui.NativeSelect; | |||
public class FilteringTurkishLocale extends AbstractTestUI { | |||
@@ -30,18 +28,14 @@ public class FilteringTurkishLocale extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final ComboBox comboBox = new ComboBox("Box", | |||
Arrays.asList("I without dot", "İ with dot")); | |||
comboBox.setNullSelectionAllowed(false); | |||
final ComboBox<String> comboBox = new ComboBox<>("Box", | |||
Arrays.asList("I dotless", "İ dotted")); | |||
comboBox.setEmptySelectionAllowed(false); | |||
NativeSelect localeSelect = new NativeSelect("Locale", | |||
Arrays.asList(Locale.ENGLISH, new Locale("tr"))); | |||
localeSelect.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
comboBox.setLocale((Locale) event.getProperty().getValue()); | |||
} | |||
}); | |||
localeSelect.addValueChangeListener(event -> comboBox | |||
.setLocale((Locale) event.getProperty().getValue())); | |||
localeSelect.setValue(Locale.ENGLISH); | |||
addComponents(localeSelect, comboBox); |
@@ -1,11 +1,11 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.tests.components.AbstractTestCase; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.GridLayout; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.Layout; | |||
import com.vaadin.ui.LegacyWindow; | |||
import com.vaadin.v7.ui.ComboBox; | |||
@SuppressWarnings("serial") | |||
public class GridLayoutComboBoxZoomOut extends AbstractTestCase { | |||
@@ -24,20 +24,15 @@ public class GridLayoutComboBoxZoomOut extends AbstractTestCase { | |||
// formLayout.setWidth("100%"); | |||
formLayout.setWidth("1000px"); | |||
ComboBox countryField = new ComboBox(); | |||
countryField.addItem("Finland"); | |||
countryField.addItem("Sweden"); | |||
countryField.addItem("Canada"); | |||
countryField.addItem("USA"); | |||
ComboBox<String> countryField = new ComboBox<>(); | |||
countryField.setItems("Finland", "Sweden", "Canada", "USA"); | |||
countryField.setCaption("Country"); | |||
countryField.setWidth("100%"); | |||
formLayout.addComponent(countryField); | |||
ComboBox statusField = new ComboBox(); | |||
statusField.addItem("Available"); | |||
statusField.addItem("On vacation"); | |||
statusField.addItem("Busy"); | |||
statusField.addItem("Left the building"); | |||
ComboBox<String> statusField = new ComboBox<>(); | |||
statusField.setItems("Available", "On vacation", "Busy", | |||
"Left the building"); | |||
statusField.setCaption("Status"); | |||
statusField.setWidth("100%"); | |||
formLayout.addComponent(statusField); |
@@ -1,10 +1,11 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.server.Resource; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.ThemeResource; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.v7.data.Item; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class PopUpWidth extends TestBase { | |||
@@ -16,18 +17,16 @@ public class PopUpWidth extends TestBase { | |||
"Browse this (check that width does not change)")); | |||
} | |||
private ComboBox createComboBox(String caption) { | |||
ComboBox cb = new ComboBox(caption); | |||
cb.addContainerProperty("caption", String.class, null); | |||
cb.addContainerProperty("icon", Resource.class, null); | |||
private ComboBox<Integer> createComboBox(String caption) { | |||
ComboBox<Integer> cb = new ComboBox<>(caption); | |||
List<Integer> items = new ArrayList<>(); | |||
for (int i = 1; i < 200 + 1; i++) { | |||
Item item = cb.addItem(i); | |||
item.getItemProperty("caption").setValue("Item " + i); | |||
item.getItemProperty("icon") | |||
.setValue(new ThemeResource("../runo/icons/16/users.png")); | |||
items.add(i); | |||
} | |||
cb.setItemIconPropertyId("icon"); | |||
cb.setItemCaptionPropertyId("caption"); | |||
cb.setItems(items); | |||
cb.setItemIconProvider( | |||
item -> new ThemeResource("../runo/icons/16/users.png")); | |||
cb.setItemCaptionProvider(item -> "Item " + item); | |||
return cb; | |||
} | |||
@@ -2,7 +2,7 @@ package com.vaadin.tests.components.combobox; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
public class WidthToggleReadOnly extends TestBase { | |||
@@ -16,9 +16,9 @@ public class WidthToggleReadOnly extends TestBase { | |||
addComponent(createReadOnlyForComboBox(combo)); | |||
} | |||
private ComboBox createNewComboBoxA(String caption) { | |||
ComboBox combo = new ComboBox(caption); | |||
combo.addItem("first"); | |||
private ComboBox<String> createNewComboBoxA(String caption) { | |||
ComboBox<String> combo = new ComboBox<>(caption); | |||
combo.setItems("first"); | |||
combo.setValue("first"); | |||
addComponent(combo); | |||
@@ -31,7 +31,6 @@ public class WidthToggleReadOnly extends TestBase { | |||
readonly.setValue(combo.isReadOnly()); | |||
readonly.addValueChangeListener( | |||
event -> combo.setReadOnly(event.getValue())); | |||
readonly.setImmediate(true); | |||
addComponent(readonly); | |||
return readonly; | |||
} |
@@ -4,10 +4,10 @@ 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.v7.ui.ComboBox; | |||
import com.vaadin.ui.TextField; | |||
import com.vaadin.v7.ui.NativeSelect; | |||
import com.vaadin.v7.ui.TextField; | |||
public class CaptionEnableDisable extends AbstractTestUI { | |||
@@ -23,7 +23,7 @@ public class CaptionEnableDisable extends AbstractTestUI { | |||
textField.setEnabled(false); | |||
layout.addComponent(textField); | |||
final ComboBox combobox = new ComboBox("Combobox"); | |||
final ComboBox<String> combobox = new ComboBox<>("Combobox"); | |||
combobox.setEnabled(false); | |||
layout.addComponent(combobox); | |||
@@ -35,16 +35,12 @@ public class CaptionEnableDisable extends AbstractTestUI { | |||
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()); | |||
} | |||
})); | |||
layout.addComponent(new Button("Toggle components enabled", event -> { | |||
combobox.setEnabled(!combobox.isEnabled()); | |||
textField.setEnabled(!textField.isEnabled()); | |||
checkBox.setEnabled(!checkBox.isEnabled()); | |||
nativeSelect.setEnabled(!nativeSelect.isEnabled()); | |||
})); | |||
return layout; | |||
} | |||
@@ -1,5 +1,7 @@ | |||
package com.vaadin.tests.components.notification; | |||
import java.util.LinkedHashMap; | |||
import com.vaadin.server.Page; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.shared.ui.ValueChangeMode; | |||
@@ -8,13 +10,12 @@ import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Notification; | |||
import com.vaadin.ui.Notification.Type; | |||
import com.vaadin.ui.NotificationConfiguration; | |||
import com.vaadin.ui.TextField; | |||
import com.vaadin.ui.UI; | |||
import com.vaadin.v7.data.Item; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.NativeSelect; | |||
import com.vaadin.v7.ui.TextArea; | |||
@@ -33,7 +34,7 @@ public class NotificationsWaiAria extends AbstractTestUI { | |||
private NativeSelect role; | |||
private TextArea tf; | |||
private ComboBox type; | |||
private ComboBox<Notification.Type> type; | |||
@SuppressWarnings("unchecked") | |||
@Override | |||
@@ -60,28 +61,18 @@ public class NotificationsWaiAria extends AbstractTestUI { | |||
tf.setImmediate(false); | |||
tf.setRows(10); | |||
addComponent(tf); | |||
type = new ComboBox(); | |||
type.setNullSelectionAllowed(false); | |||
type.addContainerProperty(CAPTION, String.class, ""); | |||
type.setItemCaptionPropertyId(CAPTION); | |||
Item item = type.addItem(Notification.Type.HUMANIZED_MESSAGE); | |||
item.getItemProperty(CAPTION).setValue("Humanized"); | |||
item = type.addItem(Notification.Type.ERROR_MESSAGE); | |||
item.getItemProperty(CAPTION).setValue("Error"); | |||
item = type.addItem(Notification.Type.WARNING_MESSAGE); | |||
item.getItemProperty(CAPTION).setValue("Warning"); | |||
item = type.addItem(Notification.Type.TRAY_NOTIFICATION); | |||
item.getItemProperty(CAPTION).setValue("Tray"); | |||
item = type.addItem(Notification.Type.ASSISTIVE_NOTIFICATION); | |||
item.getItemProperty(CAPTION).setValue("Assistive"); | |||
type.setValue(type.getItemIds().iterator().next()); | |||
type = new ComboBox<>(); | |||
LinkedHashMap<Notification.Type, String> items = new LinkedHashMap<>(); | |||
items.put(Notification.Type.HUMANIZED_MESSAGE, "Humanized"); | |||
items.put(Notification.Type.ERROR_MESSAGE, "Error"); | |||
items.put(Notification.Type.WARNING_MESSAGE, "Warning"); | |||
items.put(Notification.Type.TRAY_NOTIFICATION, "Tray"); | |||
items.put(Notification.Type.ASSISTIVE_NOTIFICATION, "Assistive"); | |||
type.setItemCaptionProvider(item -> items.get(item)); | |||
type.setItems(items.keySet()); | |||
type.setValue(items.keySet().iterator().next()); | |||
addComponent(type); | |||
Button showNotification = new Button("Show notification", | |||
@@ -106,7 +97,7 @@ public class NotificationsWaiAria extends AbstractTestUI { | |||
private class SettingHandler implements ClickListener { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Type typeValue = (Type) type.getValue(); | |||
Type typeValue = type.getValue(); | |||
Notification n = new Notification(tf.getValue(), typeValue); | |||
n.setDelayMsec(-1); | |||
@@ -125,8 +116,7 @@ public class NotificationsWaiAria extends AbstractTestUI { | |||
private class DefaultHandler implements ClickListener { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Notification n = new Notification(tf.getValue(), | |||
(Type) type.getValue()); | |||
Notification n = new Notification(tf.getValue(), type.getValue()); | |||
n.setHtmlContentAllowed(true); | |||
n.show(Page.getCurrent()); | |||
} |
@@ -20,10 +20,10 @@ import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class InsertComponentInHorizontalLayout extends AbstractTestUI { | |||
private VerticalLayout layout; |
@@ -9,6 +9,7 @@ import com.vaadin.shared.ui.slider.SliderOrientation; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Alignment; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Embedded; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.HorizontalSplitPanel; | |||
@@ -16,7 +17,6 @@ import com.vaadin.ui.Label; | |||
import com.vaadin.ui.NativeButton; | |||
import com.vaadin.ui.Slider; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.NativeSelect; | |||
import com.vaadin.v7.ui.Table; | |||
@@ -69,7 +69,7 @@ public class VaadinTunesLayout extends AbstractTestUI { | |||
HorizontalLayout volume = new HorizontalLayout(); | |||
HorizontalLayout status = new HorizontalLayout(); | |||
HorizontalLayout viewmodes = new HorizontalLayout(); | |||
ComboBox search = new ComboBox(); | |||
ComboBox<String> search = new ComboBox<>(); | |||
// Add the components and align them properly | |||
top.addComponent(playback); |
@@ -18,10 +18,10 @@ package com.vaadin.tests.components.panel; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.GridLayout; | |||
import com.vaadin.ui.Panel; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.TextField; | |||
public class UndefinedSizeScrollbars extends AbstractTestUI { | |||
@@ -44,7 +44,7 @@ public class UndefinedSizeScrollbars extends AbstractTestUI { | |||
text2.setCaption("Text2"); | |||
text2.setRequired(true); | |||
ComboBox combo = new ComboBox(); | |||
ComboBox<String> combo = new ComboBox<>(); | |||
combo.setCaption("Combo1"); | |||
CheckBox check = new CheckBox(); |
@@ -15,12 +15,13 @@ | |||
*/ | |||
package com.vaadin.tests.components.select; | |||
import java.util.Arrays; | |||
import java.util.Locale; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.v7.shared.ui.combobox.FilteringMode; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.v7.data.util.converter.StringToEnumConverter; | |||
import com.vaadin.v7.ui.NativeSelect; | |||
import com.vaadin.v7.ui.Tree; | |||
@@ -34,11 +35,10 @@ public class EnumSelect extends AbstractTestUIWithLog { | |||
protected void setup(VaadinRequest request) { | |||
setLocale(new Locale("fi", "FI")); | |||
ComboBox cb = new ComboBox(); | |||
cb.setFilteringMode(FilteringMode.CONTAINS); | |||
for (Constant c : Constant.values()) { | |||
cb.addItem(c); | |||
} | |||
ComboBox<Constant> cb = new ComboBox<>(null, | |||
Arrays.asList(Constant.values())); | |||
cb.setItemCaptionProvider(value -> StringToEnumConverter | |||
.enumToString(value, getLocale())); | |||
addComponent(cb); | |||
NativeSelect ns = new NativeSelect(); |
@@ -1,14 +0,0 @@ | |||
package com.vaadin.tests.components.select; | |||
import com.vaadin.tests.components.combobox.ComboBoxes2; | |||
import com.vaadin.v7.ui.Select; | |||
public class SelectTest extends ComboBoxes2<Select> { | |||
@SuppressWarnings("unchecked") | |||
@Override | |||
protected Class<Select> getTestClass() { | |||
return Select.class; | |||
} | |||
} |
@@ -26,7 +26,7 @@ public class StylingPopupOpener extends TestBase { | |||
@Override | |||
protected String getDescription() { | |||
return "VFilterSelect popup opener width is not updated when the style or theme changes"; | |||
return "ComboBox popup opener width is not updated when the style or theme changes"; | |||
} | |||
@Override |
@@ -2,6 +2,7 @@ package com.vaadin.tests.components.table; | |||
import java.math.BigDecimal; | |||
import java.text.NumberFormat; | |||
import java.util.Arrays; | |||
import java.util.Date; | |||
import java.util.Locale; | |||
@@ -12,12 +13,12 @@ import com.vaadin.tests.data.bean.Person; | |||
import com.vaadin.tests.data.bean.Sex; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.data.util.BeanItemContainer; | |||
import com.vaadin.v7.data.util.converter.Converter; | |||
import com.vaadin.v7.data.util.converter.StringToDoubleConverter; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.Table; | |||
public class DoublesInTable extends TestBase { | |||
@@ -56,20 +57,10 @@ public class DoublesInTable extends TestBase { | |||
} | |||
private ComboBox createLocaleSelect() { | |||
ComboBox cb = new ComboBox(); | |||
cb.setNullSelectionAllowed(false); | |||
for (Locale l : Locale.getAvailableLocales()) { | |||
cb.addItem(l); | |||
} | |||
cb.setImmediate(true); | |||
ComboBox<Locale> cb = new ComboBox<>(null, | |||
Arrays.asList(Locale.getAvailableLocales())); | |||
cb.setValue(Locale.US); | |||
cb.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
recreateTable(); | |||
} | |||
}); | |||
cb.addListener(event -> recreateTable()); | |||
return cb; | |||
} | |||
@@ -2,8 +2,8 @@ package com.vaadin.tests.components.ui; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class ComboboxSelectedItemText extends AbstractTestUIWithLog { | |||
@Override | |||
@@ -11,18 +11,16 @@ public class ComboboxSelectedItemText extends AbstractTestUIWithLog { | |||
getLayout().addComponent(new Label( | |||
"Select first ANTIGUA AND BARBUDA from the first combobox. Then select ANTIGUA AND BARBUDA from the second combobox. Finally, click the popup button on the first combobox. Before fix you would see UA AND BAR in the field.")); | |||
ComboBox combobox = new ComboBox("Text input enabled:"); | |||
ComboBox<String> combobox = new ComboBox<>("Text input enabled:"); | |||
combobox.setWidth("100px"); | |||
combobox.addItem("AMERICAN SAMOA"); | |||
combobox.addItem("ANTIGUA AND BARBUDA"); | |||
combobox.setItems("AMERICAN SAMOA", "ANTIGUA AND BARBUDA"); | |||
ComboBox combobox2 = new ComboBox("Text input disabled:"); | |||
ComboBox<String> combobox2 = new ComboBox<>("Text input disabled:"); | |||
combobox2.setWidth("100px"); | |||
combobox2.setTextInputAllowed(false); | |||
combobox2.addItem("AMERICAN SAMOA"); | |||
combobox2.addItem("ANTIGUA AND BARBUDA"); | |||
combobox2.setItems("AMERICAN SAMOA", "ANTIGUA AND BARBUDA"); | |||
getLayout().addComponent(combobox); | |||
getLayout().addComponent(combobox2); |
@@ -1,6 +1,7 @@ | |||
package com.vaadin.tests.components.upload; | |||
import java.io.OutputStream; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Date; | |||
import java.util.List; | |||
@@ -15,20 +16,22 @@ import com.vaadin.server.StreamVariable; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.DragAndDropWrapper; | |||
import com.vaadin.ui.Html5File; | |||
import com.vaadin.ui.Panel; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class DragAndDropUploadAndInteractions extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox comboBox = new ComboBox(); | |||
ComboBox<String> comboBox = new ComboBox<>(); | |||
List<String> items = new ArrayList<>(); | |||
for (int i = 0; i < 10; i++) { | |||
comboBox.addItem("Test " + i); | |||
items.add("Test " + i); | |||
} | |||
comboBox.setItems(items); | |||
addComponent(comboBox); | |||
Button b = new Button("Dummy"); | |||
addComponent(b); |
@@ -18,9 +18,9 @@ package com.vaadin.tests.components.window; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Alignment; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.v7.ui.ComboBox; | |||
/** | |||
* | |||
@@ -44,7 +44,7 @@ public class ComboboxScrollableWindow extends AbstractTestUI { | |||
VerticalLayout content = new VerticalLayout(); | |||
w.setContent(content); | |||
content.setHeight("1000px"); | |||
ComboBox cb = new ComboBox(); | |||
ComboBox<String> cb = new ComboBox<>(); | |||
cb.setId(COMBOBOX_ID); | |||
content.addComponent(cb); | |||
content.setComponentAlignment(cb, Alignment.BOTTOM_CENTER); |
@@ -1,53 +1,41 @@ | |||
package com.vaadin.tests.components.window; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.shared.ui.window.WindowMode; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.ComponentContainer; | |||
import com.vaadin.ui.NativeButton; | |||
import com.vaadin.ui.UI; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.ui.Window.CloseEvent; | |||
import com.vaadin.ui.Window.CloseListener; | |||
import com.vaadin.ui.Window.WindowModeChangeEvent; | |||
import com.vaadin.ui.Window.WindowModeChangeListener; | |||
import com.vaadin.v7.data.Item; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class WindowMaximizeRestoreTest extends AbstractTestUI { | |||
Button.ClickListener addListener = new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
addWindow(createNewWindow()); | |||
} | |||
}; | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Button addButton = new Button("Add new Window"); | |||
addButton.addListener(addListener); | |||
addButton.addClickListener(event -> { | |||
addWindow(createNewWindow()); | |||
addWindowAgain.setValue(null); | |||
}); | |||
addComponent(addButton); | |||
addWindowAgain = new ComboBox("Add Window Again"); | |||
addWindowAgain.setBuffered(false); | |||
addWindowAgain.setImmediate(true); | |||
addWindowAgain.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
Object value = event.getProperty().getValue(); | |||
if (value != null && value instanceof Window) { | |||
UI.getCurrent().addWindow((Window) value); | |||
addWindowAgain.removeItem(value); | |||
} | |||
addWindowAgain = new ComboBox<>("Add Window Again"); | |||
addWindowAgain | |||
.setItemCaptionProvider(window -> window.getData().toString()); | |||
addWindowAgain.addValueChangeListener(event -> { | |||
Object value = event.getValue(); | |||
if (value != null && value instanceof Window) { | |||
UI.getCurrent().addWindow((Window) value); | |||
windowList.remove(value); | |||
addWindowAgain.setItems(windowList); | |||
} | |||
}); | |||
addComponent(addWindowAgain); | |||
@@ -56,7 +44,8 @@ public class WindowMaximizeRestoreTest extends AbstractTestUI { | |||
} | |||
private int windowCount = 0; | |||
private ComboBox addWindowAgain; | |||
private ComboBox<Window> addWindowAgain; | |||
private List<Window> windowList = new ArrayList<>(); | |||
private Window createNewWindow() { | |||
final Window w = new Window("Window " + (++windowCount)); | |||
@@ -68,21 +57,15 @@ public class WindowMaximizeRestoreTest extends AbstractTestUI { | |||
w.setPositionX(200); | |||
w.setPositionY(200); | |||
final NativeButton maximize = new NativeButton("Maximize"); | |||
Button.ClickListener listener = new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
if (w.getWindowMode() == WindowMode.MAXIMIZED) { | |||
w.setWindowMode(WindowMode.NORMAL); | |||
maximize.setCaption("Maximize"); | |||
} else { | |||
w.setWindowMode(WindowMode.MAXIMIZED); | |||
maximize.setCaption("Restore"); | |||
} | |||
maximize.addClickListener(event -> { | |||
if (w.getWindowMode() == WindowMode.MAXIMIZED) { | |||
w.setWindowMode(WindowMode.NORMAL); | |||
maximize.setCaption("Maximize"); | |||
} else { | |||
w.setWindowMode(WindowMode.MAXIMIZED); | |||
maximize.setCaption("Restore"); | |||
} | |||
}; | |||
maximize.addClickListener(listener); | |||
}); | |||
((ComponentContainer) w.getContent()).addComponent(maximize); | |||
w.addWindowModeChangeListener(new WindowModeChangeListener() { | |||
@@ -110,34 +93,17 @@ public class WindowMaximizeRestoreTest extends AbstractTestUI { | |||
event -> w.setClosable(closeable.getValue())); | |||
((ComponentContainer) w.getContent()).addComponent(closeable); | |||
NativeButton contentFull = new NativeButton("Set Content Size Full", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
w.getContent().setSizeFull(); | |||
} | |||
}); | |||
event -> w.getContent().setSizeFull()); | |||
contentFull.setWidth("100%"); | |||
((ComponentContainer) w.getContent()).addComponent(contentFull); | |||
NativeButton center = new NativeButton("Center"); | |||
center.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
w.center(); | |||
} | |||
}); | |||
center.addClickListener(event -> w.center()); | |||
((ComponentContainer) w.getContent()).addComponent(center); | |||
w.addCloseListener(new CloseListener() { | |||
@Override | |||
public void windowClose(CloseEvent e) { | |||
Item item = addWindowAgain.addItem(w); | |||
addWindowAgain.setItemCaption(w, | |||
"Window " + w.getData().toString()); | |||
} | |||
w.addCloseListener(e -> { | |||
windowList.add(w); | |||
addWindowAgain.setItems(windowList); | |||
}); | |||
return w; |
@@ -12,6 +12,7 @@ import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.CssLayout; | |||
import com.vaadin.ui.DateField; | |||
@@ -23,7 +24,6 @@ import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.data.Item; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.NativeSelect; | |||
import com.vaadin.v7.ui.OptionGroup; | |||
import com.vaadin.v7.ui.PasswordField; | |||
@@ -209,8 +209,8 @@ public class CaptionsInLayoutsWaiAria extends TestBase { | |||
components.add(new CheckBox("Default CheckBox")); | |||
ComboBox comboBox = new ComboBox("Default ComboBox"); | |||
comboBox.addItem("Item1"); | |||
ComboBox<String> comboBox = new ComboBox<>("Default ComboBox"); | |||
comboBox.setItems("Item1"); | |||
components.add(comboBox); | |||
OptionGroup radioGroup = new OptionGroup("Single Items"); |
@@ -4,11 +4,13 @@ import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import com.vaadin.server.data.Query; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.AbsoluteLayout; | |||
import com.vaadin.ui.Accordion; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.ComponentContainer; | |||
import com.vaadin.ui.CssLayout; | |||
import com.vaadin.ui.FormLayout; | |||
@@ -22,9 +24,6 @@ import com.vaadin.ui.SingleComponentContainer; | |||
import com.vaadin.ui.TabSheet; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.VerticalSplitPanel; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.ComboBox; | |||
public class MovingComponentsWhileOldParentInvisible extends TestBase { | |||
@@ -37,37 +36,24 @@ public class MovingComponentsWhileOldParentInvisible extends TestBase { | |||
lab = new Label("Label inside the component container"); | |||
lab.setWidth(null); | |||
ComboBox componentContainerSelect = new ComboBox("Container") { | |||
{ | |||
setPageLength(0); | |||
} | |||
}; | |||
ComboBox<Class<? extends HasComponents>> componentContainerSelect = new ComboBox<>( | |||
"Container"); | |||
componentContainerSelect.setPageLength(0); | |||
componentContainerSelect.setId("componentContainerSelect"); | |||
componentContainerSelect.setWidth("300px"); | |||
componentContainerSelect.setImmediate(true); | |||
componentContainerSelect.setNullSelectionAllowed(false); | |||
// componentContainer.addContainerProperty(CAPTION, String.class, ""); | |||
// componentContainer.addContainerProperty(CLASS, Class.class, ""); | |||
for (Class<? extends HasComponents> cls : getComponentContainers()) { | |||
componentContainerSelect.addItem(cls); | |||
} | |||
componentContainerSelect.addListener(new ValueChangeListener() { | |||
@Override | |||
@SuppressWarnings("unchecked") | |||
public void valueChange(ValueChangeEvent event) { | |||
HasComponents oldCC = cc; | |||
cc = createComponentContainer( | |||
(Class<? extends HasComponents>) event.getProperty() | |||
.getValue()); | |||
addToCC(lab); | |||
replaceComponent(oldCC, cc); | |||
} | |||
componentContainerSelect.setItems(getComponentContainers()); | |||
componentContainerSelect.addValueChangeListener(event -> { | |||
HasComponents oldCC = cc; | |||
cc = createComponentContainer(event.getValue()); | |||
addToCC(lab); | |||
replaceComponent(oldCC, cc); | |||
}); | |||
componentContainerSelect.setValue( | |||
componentContainerSelect.getItemIds().iterator().next()); | |||
componentContainerSelect.setValue(componentContainerSelect | |||
.getDataSource().apply(new Query()).iterator().next()); | |||
Button but1 = new Button("Move in and out of component container", | |||
new Button.ClickListener() { | |||
@@ -21,9 +21,9 @@ import org.junit.Test; | |||
import org.openqa.selenium.Keys; | |||
import org.openqa.selenium.interactions.Actions; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.LabelElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxBorderTest extends MultiBrowserTest { | |||
@Test |
@@ -19,8 +19,8 @@ import org.junit.Assert; | |||
import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* Test to check whether combobox is expanded when icon is clicked. |
@@ -10,8 +10,8 @@ import org.openqa.selenium.Keys; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxEmptyItemsKeyboardNavigationTest | |||
extends SingleBrowserTestPhantomJS2 { |
@@ -21,9 +21,9 @@ import org.openqa.selenium.WebDriver; | |||
import org.openqa.selenium.support.ui.ExpectedCondition; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.parallel.BrowserUtil; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* Test for identical item captions in ComboBox. |
@@ -23,9 +23,9 @@ import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxInputPromptTest extends MultiBrowserTest { | |||
@@ -60,7 +60,7 @@ public class ComboBoxInputPromptTest extends MultiBrowserTest { | |||
private String getInputPromptValue(ComboBoxElement comboBox) { | |||
WebElement input = comboBox.findElement(By.tagName("input")); | |||
return input.getAttribute("value"); | |||
return input.getAttribute("placeholder"); | |||
} | |||
private ComboBoxElement getComboBoxWithCaption(String caption) { |
@@ -2,8 +2,8 @@ package com.vaadin.tests.components.combobox; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxItemIconTest extends MultiBrowserTest { | |||
@Test |
@@ -5,8 +5,8 @@ import org.openqa.selenium.Keys; | |||
import org.openqa.selenium.interactions.Actions; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.v7.testbench.customelements.NativeSelectElement; | |||
public class ComboBoxLargeIconsTest extends MultiBrowserTest { |
@@ -28,10 +28,10 @@ import org.openqa.selenium.interactions.Actions; | |||
import org.openqa.selenium.support.ui.ExpectedCondition; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.LabelElement; | |||
import com.vaadin.testbench.parallel.BrowserUtil; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxMouseSelectEnterTest extends MultiBrowserTest { | |||
@@ -21,9 +21,9 @@ import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.commands.TestBenchElementCommands; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.CheckBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxNoTextInputTest extends MultiBrowserTest { | |||
@@ -38,8 +38,7 @@ public class ComboBoxNoTextInputTest extends MultiBrowserTest { | |||
ComboBoxElement cb = $(ComboBoxElement.class).first(); | |||
click(cb); | |||
// popup is opened lazily | |||
waitForElementPresent( | |||
By.vaadin("//com.vaadin.v7.ui.ComboBox[0]#popup")); | |||
waitForElementPresent(By.vaadin("//com.vaadin.ui.ComboBox[0]#popup")); | |||
} | |||
@Test |
@@ -19,8 +19,8 @@ import org.junit.Assert; | |||
import org.junit.Test; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxPopupWhenBodyScrollsTest extends MultiBrowserTest { | |||
@@ -17,9 +17,9 @@ package com.vaadin.tests.components.combobox; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.LabelElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* When pressed down key, while positioned on the last item - should show next |
@@ -27,8 +27,8 @@ import org.openqa.selenium.WebElement; | |||
import org.openqa.selenium.support.ui.ExpectedCondition; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* When pressed down key, while positioned on the last item - should show next |
@@ -9,10 +9,10 @@ import org.openqa.selenium.WebDriver; | |||
import org.openqa.selenium.support.ui.ExpectedCondition; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.LabelElement; | |||
import com.vaadin.testbench.parallel.BrowserUtil; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxSelectingTest extends MultiBrowserTest { | |||
@@ -111,7 +111,11 @@ public class ComboBoxSelectingTest extends MultiBrowserTest { | |||
assertThatSelectedValueIs("z5"); | |||
// longer delay for this one because otherwise it keeps failing when run | |||
// on local machine | |||
comboBoxElement.sendKeys(200, Keys.BACK_SPACE, Keys.BACK_SPACE, | |||
int delay = 200; | |||
if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { | |||
delay = 500; | |||
} | |||
comboBoxElement.sendKeys(delay, Keys.BACK_SPACE, Keys.BACK_SPACE, | |||
Keys.TAB); | |||
assertThatSelectedValueIs("", "null"); | |||
@@ -24,10 +24,10 @@ import org.openqa.selenium.WebDriver; | |||
import org.openqa.selenium.support.ui.ExpectedCondition; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.LabelElement; | |||
import com.vaadin.testbench.parallel.BrowserUtil; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxSelectingWithNewItemsAllowedTest extends MultiBrowserTest { | |||
private ComboBoxElement comboBoxElement; |
@@ -25,8 +25,8 @@ import org.junit.Test; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboBoxSuggestionPageLengthTest extends MultiBrowserTest { | |||
@@ -24,8 +24,8 @@ import org.openqa.selenium.Keys; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* @author Vaadin Ltd |
@@ -19,8 +19,8 @@ import org.junit.Test; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* @author Vaadin Ltd |
@@ -21,8 +21,8 @@ import org.junit.Test; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* @author Vaadin Ltd |
@@ -21,8 +21,8 @@ import org.junit.Test; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* @author Vaadin Ltd |
@@ -21,8 +21,8 @@ import org.junit.Test; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* @author Vaadin Ltd |
@@ -20,9 +20,9 @@ import static org.hamcrest.Matchers.is; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.LabelElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
@SuppressWarnings("serial") | |||
public class ComboSelectedValueBeyondTheFirstDropdownPageTest |
@@ -21,9 +21,9 @@ import org.openqa.selenium.By; | |||
import org.openqa.selenium.WebElement; | |||
import org.openqa.selenium.interactions.Actions; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.MenuBarElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* Test that checks whether Combobox popup is closed on click to autoopen | |||
@@ -35,6 +35,7 @@ public class ComboboxMenuBarAutoopenTest extends MultiBrowserTest { | |||
@Test | |||
public void closeComboboxPopupOnClickToMenuBar() { | |||
setDebug(true); | |||
openTestURL(); | |||
openPopup(); | |||
@@ -57,9 +58,7 @@ public class ComboboxMenuBarAutoopenTest extends MultiBrowserTest { | |||
private void openPopup() { | |||
ComboBoxElement combobox = $(ComboBoxElement.class).first(); | |||
combobox.click(); | |||
combobox.openPopup(); | |||
combobox.focus(); | |||
Actions actions = new Actions(getDriver()); | |||
actions.moveToElement( |
@@ -19,8 +19,8 @@ import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
public class ComboboxPopupScrollingTest extends MultiBrowserTest { | |||
@@ -19,9 +19,9 @@ import static org.junit.Assert.assertEquals; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* Tests that changing a stylename will not cause the width parameter to be |
@@ -21,8 +21,8 @@ import org.junit.Assert; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.v7.testbench.customelements.NativeSelectElement; | |||
public class FilteringTurkishLocaleTest extends MultiBrowserTest { | |||
@@ -49,7 +49,7 @@ public class FilteringTurkishLocaleTest extends MultiBrowserTest { | |||
Assert.assertEquals("There should be only one suggestion", 1, | |||
suggestions.size()); | |||
Assert.assertEquals("İ with dot", suggestions.get(0)); | |||
Assert.assertEquals("İ dotted", suggestions.get(0)); | |||
} | |||
@Test | |||
@@ -62,7 +62,7 @@ public class FilteringTurkishLocaleTest extends MultiBrowserTest { | |||
Assert.assertEquals("There should be only one suggestion", 1, | |||
suggestions.size()); | |||
Assert.assertEquals("I without dot", suggestions.get(0)); | |||
Assert.assertEquals("I dotless", suggestions.get(0)); | |||
} | |||
private List<String> getFilterSuggestions(String string) { |
@@ -22,8 +22,8 @@ import org.junit.Test; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.TestBenchElement; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.SingleBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.v7.testbench.customelements.NativeSelectElement; | |||
public class EnumSelectTest extends SingleBrowserTest { |
@@ -68,10 +68,10 @@ public class ComboboxSelectedItemTextTest extends MultiBrowserTest { | |||
WebElement comboBox = vaadinElement( | |||
"/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[" | |||
+ indexToTest + "]/VFilterSelect[0]"); | |||
+ indexToTest + "]/VComboBox[0]"); | |||
WebElement comboBoxFocus = vaadinElement( | |||
"/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[" | |||
+ indexToFocus + "]/VFilterSelect[0]"); | |||
+ indexToFocus + "]/VComboBox[0]"); | |||
// Select an element from the first (to test) combobox. | |||
@@ -79,7 +79,7 @@ public class ComboboxSelectedItemTextTest extends MultiBrowserTest { | |||
waitForPopup(comboBox); | |||
WebElement comboBoxPopup = vaadinElement( | |||
"/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[" | |||
+ indexToTest + "]/VFilterSelect[0]#popup"); | |||
+ indexToTest + "]/VComboBox[0]#popup"); | |||
comboBoxPopup.findElements(By.tagName("td")).get(2).click(); | |||
// Select an element from the second (to focus) combobox to remove | |||
@@ -90,7 +90,7 @@ public class ComboboxSelectedItemTextTest extends MultiBrowserTest { | |||
waitForPopup(comboBoxFocus); | |||
comboBoxPopup = vaadinElement( | |||
"/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[" | |||
+ indexToFocus + "]/VFilterSelect[0]#popup"); | |||
+ indexToFocus + "]/VComboBox[0]#popup"); | |||
comboBoxPopup.findElements(By.tagName("td")).get(2).click(); | |||
// click the button of the first combobox. This would reveal the |
@@ -23,9 +23,9 @@ import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.commands.TestBenchElementCommands; | |||
import com.vaadin.testbench.customelements.ComboBoxElement; | |||
import com.vaadin.testbench.customelements.WindowElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import com.vaadin.v7.testbench.customelements.ComboBoxElement; | |||
/** | |||
* Tests that a ComboBox at the bottom of a Window remains visible when clicked. |