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.

ClickEventHandler.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.google.gwt.dom.client.NativeEvent;
  18. import com.vaadin.client.ComponentConnector;
  19. import com.vaadin.client.MouseEventDetailsBuilder;
  20. import com.vaadin.shared.EventId;
  21. import com.vaadin.shared.MouseEventDetails;
  22. public abstract class ClickEventHandler extends AbstractClickEventHandler {
  23. public ClickEventHandler(ComponentConnector connector) {
  24. this(connector, EventId.CLICK_EVENT_IDENTIFIER);
  25. }
  26. public ClickEventHandler(ComponentConnector connector,
  27. String clickEventIdentifier) {
  28. super(connector, clickEventIdentifier);
  29. }
  30. /**
  31. * Sends the click event based on the given native event. Delegates actual
  32. * sending to {@link #fireClick(MouseEventDetails)}.
  33. *
  34. * @param event
  35. * The native event that caused this click event
  36. */
  37. @Override
  38. protected void fireClick(NativeEvent event) {
  39. MouseEventDetails mouseDetails = MouseEventDetailsBuilder
  40. .buildMouseEventDetails(event, getRelativeToElement());
  41. fireClick(event, mouseDetails);
  42. }
  43. /**
  44. * Sends the click event to the server. Must be implemented by sub classes,
  45. * typically by calling an RPC method.
  46. *
  47. * @param event
  48. * The event that caused this click to be fired
  49. *
  50. * @param mouseDetails
  51. * The mouse details for the event
  52. */
  53. protected abstract void fireClick(NativeEvent event,
  54. MouseEventDetails mouseDetails);
  55. }