You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NativeSelect.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.v7.ui;
  17. import java.util.Collection;
  18. import com.vaadin.event.FieldEvents.BlurEvent;
  19. import com.vaadin.event.FieldEvents.BlurListener;
  20. import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcDecorator;
  21. import com.vaadin.event.FieldEvents.FocusEvent;
  22. import com.vaadin.event.FieldEvents.FocusListener;
  23. import com.vaadin.v7.data.Container;
  24. import com.vaadin.v7.event.FieldEvents;
  25. /**
  26. * This is a simple drop-down select without, for instance, support for
  27. * multiselect, new items, lazyloading, and other advanced features. Sometimes
  28. * "native" select without all the bells-and-whistles of the ComboBox is a
  29. * better choice.
  30. */
  31. @SuppressWarnings("serial")
  32. @Deprecated
  33. public class NativeSelect extends AbstractSelect
  34. implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {
  35. public NativeSelect() {
  36. super();
  37. registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));
  38. }
  39. public NativeSelect(String caption, Collection<?> options) {
  40. super(caption, options);
  41. registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));
  42. }
  43. public NativeSelect(String caption, Container dataSource) {
  44. super(caption, dataSource);
  45. registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));
  46. }
  47. public NativeSelect(String caption) {
  48. super(caption);
  49. registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));
  50. }
  51. @Override
  52. public void setMultiSelect(boolean multiSelect)
  53. throws UnsupportedOperationException {
  54. if (multiSelect == true) {
  55. throw new UnsupportedOperationException(
  56. "Multiselect not supported");
  57. }
  58. }
  59. @Override
  60. public void setNewItemsAllowed(boolean allowNewOptions)
  61. throws UnsupportedOperationException {
  62. if (allowNewOptions == true) {
  63. throw new UnsupportedOperationException(
  64. "newItemsAllowed not supported");
  65. }
  66. }
  67. @Override
  68. public void addFocusListener(FocusListener listener) {
  69. addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
  70. FocusListener.focusMethod);
  71. }
  72. @Override
  73. public void removeFocusListener(FocusListener listener) {
  74. removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
  75. }
  76. @Override
  77. public void addBlurListener(BlurListener listener) {
  78. addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
  79. BlurListener.blurMethod);
  80. }
  81. @Override
  82. public void removeBlurListener(BlurListener listener) {
  83. removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
  84. }
  85. }