Example usage for com.vaadin.client ConnectorHierarchyChangeEvent getOldChildren

List of usage examples for com.vaadin.client ConnectorHierarchyChangeEvent getOldChildren

Introduction

In this page you can find the example usage for com.vaadin.client ConnectorHierarchyChangeEvent getOldChildren.

Prototype

public List<ComponentConnector> getOldChildren() 

Source Link

Document

Returns a collection of the old children for the connector.

Usage

From source file:org.vaadin.addon.leaflet.client.vaadin.LeafletLayerGroupConnector.java

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
    orphaned = new ArrayList<ComponentConnector>(connectorHierarchyChangeEvent.getOldChildren());
    for (ServerConnector componentConnector : getChildren()) {
        orphaned.remove(componentConnector);
    }//  www.  j  a  va2  s  .c om
    deferUpdate();
}

From source file:org.vaadin.addon.leaflet.client.vaadin.LeafletMapConnector.java

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
    List<ComponentConnector> oldChildren = connectorHierarchyChangeEvent.getOldChildren();
    updateChildren = new ArrayList<ServerConnector>();
    for (ServerConnector componentConnector : getChildren()) {
        if (!oldChildren.contains(componentConnector)) {
            updateChildren.add(componentConnector);
        }//from   w  w w  .j  ava2  s  . c om
        oldChildren.remove(componentConnector);
    }
    for (ComponentConnector componentConnector : oldChildren) {
        AbstractLeafletLayerConnector<?> c = (AbstractLeafletLayerConnector<?>) componentConnector;
        map.removeLayer(c.getLayer());
        // TODO: This does not work atm.
        if (c instanceof LeafletLayerGroupConnector) {
            String name = connectorIdToNameMap.remove(c.getConnectorId());
            if (name == null) {
                continue;
            }
            Layers removed = lControl.removeLayer(name);
            map.removeControl(lControl);
            map.addControl(removed);
            lControl = removed;
        }
    }

    updateChildrens();
}

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

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
    final List<ComponentConnector> children = getChildComponents();
    final List<ComponentConnector> oldChildren = event.getOldChildren();
    oldChildren.removeAll(children);//www.j  a  va 2  s .c  o m
    headerConnectors.clear();
    for (final ComponentConnector cc : oldChildren) {
        final PortletConnector pc = PortalLayoutUtil.getPortletConnectorForContent(cc);
        if (pc != null) {
            view.removePortlet(pc.getPortletChrome());
        }
    }

    final Iterator<ComponentConnector> it = children.iterator();
    while (it.hasNext()) {
        final ComponentConnector cc = it.next();
        if (getState().contentToPortlet.get(cc) != null) {
            final PortletConnector pc = (PortletConnector) getState().contentToPortlet.get(cc);
            final PortletChrome portletWidget = pc.getPortletChrome();
            cc.getLayoutManager().addElementResizeListener(portletWidget.getAssociatedSlot().getElement(),
                    slotResizeListener);
            getView().addPortlet(pc.getPortletChrome());
        } else {
            headerConnectors.add(cc);
        }
    }
}

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

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
    // super.onConnectorHierarchyChange(event);

    // Remove old children
    for (ComponentConnector child : event.getOldChildren()) {
        if (child.getParent() != this) {
            Widget widget = child.getWidget();
            if (widget.isAttached()) {
                getWidget().remove(widget);
            }//from ww w.  ja v a2 s.  c o  m
        }
    }

    // Add or move children
    int index = 0;
    for (ComponentConnector child : getChildComponents()) {
        getWidget().addOrMove(child.getWidget(), index);
        ++index;
    }
}

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

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {

    // Remove old children
    for (ComponentConnector child : event.getOldChildren()) {
        if (child.getParent() != this) {
            logger.fine("Remove old child widget");
            Widget widget = child.getWidget();
            if (widget != null && widget.isAttached()) {
                getWidget().remove(widget);
            }/*from w  w w  . j a va  2 s  .co  m*/
        }
    }

    for (ComponentConnector child : getChildComponents()) {
        try {
            getWidget().add(child.getWidget());
        } catch (Exception e) {
            logger.severe("Failed to add! " + e.getMessage());
        }
    }

    ComponentConnector currentConnector = (ComponentConnector) getState().currentComponent;
    if (currentConnector != null) {
        getWidget().setContent(currentConnector.getWidget());
    }

}

From source file:org.vaadin.alump.gridstack.client.GridStackLayoutConnector.java

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
    Duration duration = new Duration();
    getWidget().batchUpdate();// w  w  w .  jav a2s  .c om

    for (ComponentConnector child : event.getOldChildren()) {
        if (child.getParent() != this) {
            Widget widget = child.getWidget();
            if (widget.isAttached()) {
                getWidget().remove(widget);
            }
        }
    }

    for (ComponentConnector child : getChildComponents()) {
        if (child.getWidget().getParent() != getWidget()) {
            getWidget().add(child.getWidget(), getState().childOptions.get(child));
        }
    }

    getWidget().commit();
    LOGGER.info("onConnectorHierarchyChange took " + duration.elapsedMillis() + "ms");
}

From source file:org.vaadin.alump.masonry.client.MasonryLayoutConnector.java

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {

    getWidget().initialize(getState().columnWidth);

    for (ComponentConnector child : event.getOldChildren()) {
        if (child.getParent() != this) {
            Widget widget = child.getWidget();
            if (widget.isAttached()) {
                getWidget().removeItem(widget);
            }/* w  w  w .  jav a2s.  c  o  m*/
        }
    }

    int reconstructFrom = findFirstMismatchInChildren(getChildComponents());

    // Clean reordered widgets
    if (reconstructFrom < getWidget().getWidgetCount()) {
        Set<Widget> removeWidgets = new HashSet<Widget>();
        for (int i = reconstructFrom; i < getWidget().getWidgetCount(); ++i) {
            removeWidgets.add(getWidget().getWidget(i));
        }
        for (Widget remove : removeWidgets) {
            getWidget().removeItem(remove);
        }
    }

    // Add new or reordered children
    for (int i = reconstructFrom; i < getChildComponents().size(); ++i) {
        ComponentConnector cc = getChildComponents().get(i);
        getWidget().addItem(cc.getWidget(), getState().itemStyleNames.get(cc));
    }

    scheduleLayout();
}