All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.v7.client.connectors.ClickableRendererConnector Maven / Gradle / Ivy

There is a newer version: 8.27.3
Show newest version
/*
 * Copyright (C) 2000-2023 Vaadin Ltd
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See  for the full
 * license.
 */
package com.vaadin.v7.client.connectors;

import com.google.web.bindery.event.shared.HandlerRegistration;
import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.v7.client.renderers.ClickableRenderer;
import com.vaadin.v7.client.renderers.ClickableRenderer.RendererClickEvent;
import com.vaadin.v7.client.renderers.ClickableRenderer.RendererClickHandler;
import com.vaadin.v7.shared.ui.grid.renderers.RendererClickRpc;

import elemental.json.JsonObject;

/**
 * An abstract base class for {@link ClickableRenderer} connectors.
 *
 * @param 
 *            the presentation type of the renderer
 *
 * @since 7.4
 * @author Vaadin Ltd
 */
public abstract class ClickableRendererConnector
        extends AbstractGridRendererConnector {

    HandlerRegistration clickRegistration;

    @Override
    protected void init() {
        clickRegistration = addClickHandler(
                new RendererClickHandler() {
                    @Override
                    public void onClick(RendererClickEvent event) {
                        getRpcProxy(RendererClickRpc.class).click(
                                getRowKey(event.getCell().getRow()),
                                getColumnId(event.getCell().getColumn()),
                                MouseEventDetailsBuilder.buildMouseEventDetails(
                                        event.getNativeEvent()));
                    }
                });
    }

    @Override
    public void onUnregister() {
        clickRegistration.removeHandler();
    }

    protected abstract HandlerRegistration addClickHandler(
            RendererClickHandler handler);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy