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.

ClickableRendererConnector.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.connectors;
  17. import com.google.gwt.json.client.JSONObject;
  18. import com.google.web.bindery.event.shared.HandlerRegistration;
  19. import com.vaadin.client.MouseEventDetailsBuilder;
  20. import com.vaadin.client.ui.grid.renderers.ClickableRenderer.RendererClickEvent;
  21. import com.vaadin.client.ui.grid.renderers.ClickableRenderer.RendererClickHandler;
  22. import com.vaadin.shared.ui.grid.renderers.RendererClickRpc;
  23. /**
  24. * An abstract base class for {@link ClickableRenderer} connectors.
  25. *
  26. * @param <T>
  27. * the presentation type of the renderer
  28. *
  29. * @since
  30. * @author Vaadin Ltd
  31. */
  32. public abstract class ClickableRendererConnector<T> extends
  33. AbstractRendererConnector<T> {
  34. HandlerRegistration clickRegistration;
  35. @Override
  36. protected void init() {
  37. clickRegistration = addClickHandler(new RendererClickHandler<JSONObject>() {
  38. @Override
  39. public void onClick(RendererClickEvent<JSONObject> event) {
  40. getRpcProxy(RendererClickRpc.class).click(
  41. event.getCell().getRow(),
  42. event.getCell().getColumn(),
  43. MouseEventDetailsBuilder.buildMouseEventDetails(event
  44. .getNativeEvent()));
  45. }
  46. });
  47. }
  48. @Override
  49. public void onUnregister() {
  50. clickRegistration.removeHandler();
  51. }
  52. protected abstract HandlerRegistration addClickHandler(
  53. RendererClickHandler<JSONObject> handler);
  54. }