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.

GridKeyPressEvent.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2000-2014 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.widget.grid.events;
  17. import com.google.gwt.dom.client.BrowserEvents;
  18. import com.vaadin.client.widget.grid.CellReference;
  19. import com.vaadin.client.widget.grid.events.AbstractGridKeyEventHandler.GridKeyPressHandler;
  20. import com.vaadin.client.widgets.Grid;
  21. import com.vaadin.client.widgets.Grid.AbstractGridKeyEvent;
  22. import com.vaadin.shared.ui.grid.GridConstants.Section;
  23. /**
  24. * Represents native key press event in Grid.
  25. *
  26. * @since 7.4
  27. * @author Vaadin Ltd
  28. */
  29. public class GridKeyPressEvent extends
  30. AbstractGridKeyEvent<GridKeyPressHandler> {
  31. public GridKeyPressEvent(Grid<?> grid, CellReference<?> targetCell) {
  32. super(grid, targetCell);
  33. }
  34. @Override
  35. protected void doDispatch(GridKeyPressHandler handler, Section section) {
  36. if ((section == Section.BODY && handler instanceof BodyKeyPressHandler)
  37. || (section == Section.HEADER && handler instanceof HeaderKeyPressHandler)
  38. || (section == Section.FOOTER && handler instanceof FooterKeyPressHandler)) {
  39. handler.onKeyPress(this);
  40. }
  41. }
  42. @Override
  43. protected String getBrowserEventType() {
  44. return BrowserEvents.KEYPRESS;
  45. }
  46. /**
  47. * Gets the char code for this event.
  48. *
  49. * @return the char code
  50. */
  51. public char getCharCode() {
  52. return (char) getUnicodeCharCode();
  53. }
  54. /**
  55. * Gets the Unicode char code (code point) for this event.
  56. *
  57. * @return the Unicode char code
  58. */
  59. public int getUnicodeCharCode() {
  60. return getNativeEvent().getCharCode();
  61. }
  62. @Override
  63. public String toDebugString() {
  64. return super.toDebugString() + "[" + getCharCode() + "]";
  65. }
  66. }