Example usage for com.vaadin.client Util getConnectorForElement

List of usage examples for com.vaadin.client Util getConnectorForElement

Introduction

In this page you can find the example usage for com.vaadin.client Util getConnectorForElement.

Prototype

public static ComponentConnector getConnectorForElement(ApplicationConnection client, Widget parent,
        Element element) 

Source Link

Document

Locates the nested child component of parent which contains the element element.

Usage

From source file:org.vaadin.alump.fancylayouts.gwt.client.connect.FancyCssLayoutConnector.java

License:Apache License

protected ComponentConnector findConnectorWithElement(Element element) {
    return Util.getConnectorForElement(getConnection(), (Widget) getWidget(),
            (com.google.gwt.user.client.Element) element);
}

From source file:org.vaadin.miki.itemgrid.client.itemgrid.ItemGridConnector.java

License:Apache License

/**
 * Constructs the widget with all the default settings.
 *//*  ww  w  .j  a  v  a2  s .  c  om*/
public ItemGridConnector() {
    this.registerRpc(ItemGridClientRpc.class, new ItemGridClientRpc() {
        private static final long serialVersionUID = 20140501;

        @Override
        public void setSelectable(boolean state) {
            ItemGridConnector.this.selectable = state;
        }

    });

    this.getWidget().addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // only do things when in selectable mode
            if (ItemGridConnector.this.selectable) {
                Element element = ((Element) event.getNativeEvent().getEventTarget().cast());
                ComponentConnector connector = Util.getConnectorForElement(
                        ItemGridConnector.this.getConnection(), ItemGridConnector.this.getWidget(), element);
                while (!ItemGridConnector.this.widgetItemIds.containsKey(connector)
                        && connector.getParent() != null && connector.getParent() instanceof ComponentConnector)
                    connector = (ComponentConnector) connector.getParent();
                Integer index = ItemGridConnector.this.widgetItemIds.get(connector);
                ItemGridConnector.this.rpc.clickItemAtIndex(index == null ? -1 : index.intValue());
            }
        }
    });

}