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.

VAbstractDateFieldCalendar.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2000-2018 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.client.ui;
  17. import com.vaadin.client.ui.VAbstractCalendarPanel.SubmitListener;
  18. /**
  19. * A client side implementation for inline date field.
  20. */
  21. public abstract class VAbstractDateFieldCalendar<PANEL extends VAbstractCalendarPanel<R>, R extends Enum<R>>
  22. extends VDateField<R> {
  23. /** For internal use only. May be removed or replaced in the future. */
  24. public final PANEL calendarPanel;
  25. public VAbstractDateFieldCalendar(PANEL panel, R resolution) {
  26. super(resolution);
  27. calendarPanel = panel;
  28. calendarPanel.setParentField(this);
  29. add(calendarPanel);
  30. calendarPanel.setSubmitListener(new SubmitListener() {
  31. @Override
  32. public void onSubmit() {
  33. updateValueFromPanel();
  34. }
  35. @Override
  36. public void onCancel() {
  37. // TODO Auto-generated method stub
  38. }
  39. });
  40. calendarPanel.setFocusOutListener(event -> {
  41. updateValueFromPanel();
  42. return false;
  43. });
  44. }
  45. @SuppressWarnings("deprecation")
  46. public abstract void updateValueFromPanel();
  47. public void setTabIndex(int tabIndex) {
  48. calendarPanel.getElement().setTabIndex(tabIndex);
  49. }
  50. public int getTabIndex() {
  51. return calendarPanel.getElement().getTabIndex();
  52. }
  53. }