Example usage for com.vaadin.client Util findConnectorFor

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

Introduction

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

Prototype

public static ComponentConnector findConnectorFor(Widget widget) 

Source Link

Usage

From source file:info.magnolia.ui.vaadin.gwt.client.richtext.TextAreaStretcherConnector.java

License:Open Source License

private void unregisterSizeChangeListeners() {
    final LayoutManager lm = getParent().getLayoutManager();
    final UIConnector ui = getConnection().getUIConnector();
    if (ui != null) {
        getParent().removeStateChangeHandler(textAreaSizeHandler);
        lm.removeElementResizeListener(ui.getWidget().getElement(), windowResizeListener);
    }/*from  www.  j  av  a  2 s  .co m*/

    final ComponentConnector formConnector = Util.findConnectorFor(this.form);
    if (formConnector != null) {
        formConnector.getLayoutManager().removeElementResizeListener(this.form.getElement(),
                formResizeListener);
    }
}

From source file:info.magnolia.ui.vaadin.gwt.client.tabsheet.connector.MagnoliaTabSheetConnector.java

License:Open Source License

@Override
protected void init() {
    super.init();

    addStateChangeHandler("activeTab", new StateChangeHandler() {
        @Override/*from   ww  w.j  a  v a 2s  .c o  m*/
        public void onStateChanged(StateChangeEvent event) {
            final MagnoliaTabConnector tabConnector = (MagnoliaTabConnector) getState().activeTab;
            if (tabConnector != null) {
                view.setActiveTab(tabConnector.getWidget());
                eventBus.fireEvent(new ActiveTabChangedEvent(tabConnector.getWidget(), false));
            }
        }
    });

    addStateChangeHandler(new StateChangeHandler() {
        @Override
        public void onStateChanged(StateChangeEvent event) {
            if (event.hasPropertyChanged("showAllEnabled")) {
                view.getTabContainer().addShowAllTab(getState().showAllEnabled, getState().showAllLabel);
            }

            if (getState().logo != null && getState().logoBgColor != null) {
                view.setLogo(getState().logo, getState().logoBgColor);
            }
        }
    });

    registerRpc(MagnoliaTabSheetClientRpc.class, new MagnoliaTabSheetClientRpc() {

        @Override
        public void closeTab(Connector tabConnector) {
            eventBus.fireEvent(new TabCloseEvent(((MagnoliaTabConnector) tabConnector).getWidget()));
        }
    });

    eventBus.addHandler(TabCloseEvent.TYPE, new TabCloseEventHandler() {
        @Override
        public void onTabClosed(TabCloseEvent event) {
            MagnoliaTabWidget tab = event.getTab();
            if (tab == view.getActiveTab()) {
                view.showPreloader();
                tab.getWidget().getElement().getStyle().setDisplay(Style.Display.NONE);
            }
            rpc.closeTab(Util.findConnectorFor(tab));
        }
    });

    eventBus.addHandler(ActiveTabChangedEvent.TYPE, new ActiveTabChangedEvent.Handler() {
        @Override
        public void onActiveTabChanged(final ActiveTabChangedEvent event) {
            MagnoliaTabWidget tab = event.getTab();
            if (view.isShowingAllTabs()) {
                view.setActiveTab(tab);
                tab = null; // force preloader and animation when returning to same tab for consistency reasons
            }
            if (tab != view.getActiveTab() && event.isNotifyServer()) {
                view.showPreloader();
                view.clearTabs();
                rpc.setActiveTab(Util.findConnectorFor(event.getTab()));
            }
        }
    });

    eventBus.addHandler(ShowAllTabsEvent.TYPE, new ShowAllTabsHandler() {
        @Override
        public void onShowAllTabs(ShowAllTabsEvent event) {
            rpc.setShowAll();
            view.showAllTabContents(true);
            view.getTabContainer().showAll(true);
            fireEvent(new ActiveTabChangedEvent(true, false));
        }

    });

    getLayoutManager().addElementResizeListener(view.getTabContainer().getElement(), listener);
}

From source file:org.vaadin.addons.portallayout.gwt.client.dnd.StackPortalDropController.java

License:Apache License

@Override
public void onEnter(DragContext context) {
    super.onEnter(context);
    PortletChrome portletWidget = (PortletChrome) context.selectedWidgets.get(0);
    PortletSlot slot = portletWidget.getAssociatedSlot();
    if (panel != slot.getParent()) {
        PortalLayoutConnector originalConnector = ((PortalLayoutConnector) Util
                .findConnectorFor(slot.getParent()));
        originalConnector.setOutcomingPortletCandidate(portletWidget);
        portalConnector.setIncomingPortletCandidate(portletWidget);
    }//from  w ww . j  av a 2 s  .c  o m
    configurePostionerSlot(context, slot);
}

From source file:org.vaadin.addons.portallayout.gwt.client.dnd.StackPortalDropController.java

License:Apache License

@Override
public void onDrop(DragContext context) {
    super.onDrop(context);
    PortletChrome portletWidget = (PortletChrome) context.selectedWidgets.get(0);
    if (positionerSlot != null) {
        positionerSlot.setWidget(portletWidget);
    }/*from www .ja  v a  2s.c o  m*/
    Widget contentWidget = portletWidget.getContentWidget();
    ComponentConnector contentConnector = Util.findConnectorFor(contentWidget);
    PortalLayoutConnector originalConnector = (PortalLayoutConnector) contentConnector.getParent();
    if (originalConnector != portalConnector) {
        portalConnector.propagateHierarchyChangesToServer();
        originalConnector.propagateHierarchyChangesToServer();
    } else {
        portalConnector.updatePortletPositionOnServer(contentConnector);
    }
}

From source file:org.vaadin.addons.portallayout.gwt.client.portal.connection.PortalLayoutConnector.java

License:Apache License

public void setIncomingPortletCandidate(PortletChrome portletWidget) {
    assert portletWidget != null;
    ComponentConnector pc = Util.findConnectorFor(portletWidget.getContentWidget());
    if (this.outcomingPortletCandidate == pc) {
        this.outcomingPortletCandidate = null;
    } else if (!getChildComponents().contains(pc)) {
        this.incomingPortletCandidate = pc;
    }//from   ww w .ja  v a  2 s .  co m
}

From source file:org.vaadin.addons.portallayout.gwt.client.portal.connection.PortalLayoutConnector.java

License:Apache License

public void setOutcomingPortletCandidate(PortletChrome portletWidget) {
    assert portletWidget != null;
    ComponentConnector pc = Util.findConnectorFor(portletWidget.getContentWidget());
    if (this.incomingPortletCandidate == pc) {
        this.incomingPortletCandidate = null;
    } else if (getChildComponents().contains(pc)) {
        this.outcomingPortletCandidate = pc;
    }//w w  w.  jav a2s  . c o  m
}

From source file:org.vaadin.addons.portallayout.gwt.client.portal.PortalLayoutUtil.java

License:Apache License

public static PortalLayoutConnector getPortalLayoutConnectorForPortlet(PortletConnector pc) {
    ComponentConnector cc = Util.findConnectorFor(pc.getPortletChrome().getContentWidget());
    return cc.getParent() instanceof PortalLayoutConnector ? (PortalLayoutConnector) cc.getParent() : null;
}