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:com.haulmont.cuba.web.widgets.client.tabsheetcsslayout.CubaTabSheetCssLayoutConnector.java

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
    for (ComponentConnector child : event.getOldChildren()) {
        if (child.getParent() == this) {
            // Skip current children
            continue;
        }//from w  ww  .  j a  v  a 2 s .  c  o m
        getWidget().remove(child.getWidget());
        VCaption vCaption = childIdToCaption.get(child.getConnectorId());
        if (vCaption != null) {
            childIdToCaption.remove(child.getConnectorId());
            getWidget().remove(vCaption);
        }
    }

    int index = 0;
    for (ComponentConnector child : getChildComponents()) {
        VCaption childCaption = childIdToCaption.get(child.getConnectorId());
        if (childCaption != null) {
            getWidget().addOrMove(childCaption, index++);
        }
        getWidget().addOrMove(child.getWidget(), index++);
    }
}

From source file:de.bonprix.gridstacklayout.client.GridStackLayoutConnector.java

License:Open Source License

@Override
public void onConnectorHierarchyChange(final ConnectorHierarchyChangeEvent event) {

    // Attach all new children
    for (final ComponentConnector connector : getChildComponents()) {

        if (this.attachedChildren.contains(connector)) {
            continue;
        }/*ww  w .j a  v a 2s.  co m*/

        final GridStackWidget gridstackWidget = getState().getWidgetByConnector(connector);
        getWidget().addWidget(gridstackWidget, connector.getWidget());

        this.attachedChildren.add(connector);
    }

    // Remove no longer attached children
    for (final ComponentConnector oldConnector : event.getOldChildren()) {

        if (oldConnector.getParent() == this) {
            continue;
        }

        final Widget oldChildWidget = oldConnector.getWidget();
        if (oldChildWidget.isAttached()) {
            getWidget().remove(oldChildWidget);
            this.attachedChildren.remove(oldConnector);
        }
    }
}

From source file:info.magnolia.ui.vaadin.gwt.client.form.formsection.connector.FormSectionConnector.java

License:Open Source License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent e) {
    final List<ComponentConnector> oldChildren = e.getOldChildren();
    final List<ComponentConnector> newChildren = getChildComponents();

    oldChildren.removeAll(newChildren);//  w  ww  .  ja  v a2s  . co m
    for (final ComponentConnector cc : oldChildren) {
        getWidget().remove(cc.getWidget());
    }

    int index = 0;
    for (final ComponentConnector cc : newChildren) {
        getWidget().insert(cc.getWidget(), index++);
        cc.addStateChangeHandler("errorMessage", childErrorMessageHandler);
    }
}

From source file:info.magnolia.ui.vaadin.gwt.client.magnoliashell.shell.MagnoliaShellConnector.java

License:Open Source License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
    List<ComponentConnector> children = getChildComponents();
    for (ComponentConnector connector : children) {
        if (connector instanceof ViewportConnector) {
            final ViewportConnector vc = (ViewportConnector) connector;
            view.updateViewport(vc.getWidget(), vc.getType());
            vc.setEventBus(eventBus);/*ww w .  j a  v  a  2  s. co m*/
        } else if (connector instanceof OverlayConnector) {
            if (!view.hasOverlay(connector.getWidget())) {
                final OverlayConnector oc = (OverlayConnector) connector;
                ComponentConnector overlayParent = (ComponentConnector) oc.getState().overlayParent;
                Widget parentWidget = overlayParent.getWidget();
                view.openOverlayOnWidget(oc.getWidget(), parentWidget);
            }
        } else if (connector instanceof NativeButtonConnector) {
            view.setUserMenu(connector.getWidget());
        }
    }

    List<ComponentConnector> oldChildren = event.getOldChildren();
    oldChildren.removeAll(children);
    for (ComponentConnector cc : oldChildren) {
        cc.getWidget().removeFromParent();
    }
}

From source file:info.magnolia.ui.vaadin.gwt.client.magnoliashell.viewport.connector.ViewportConnector.java

License:Open Source License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
    final ViewportWidget viewport = getWidget();
    final List<ComponentConnector> children = getChildComponents();
    final List<ComponentConnector> oldChildren = event.getOldChildren();
    int index = 0;
    for (final ComponentConnector cc : children) {
        final Widget w = cc.getWidget();
        if (w.getParent() != viewport) {
            viewport.insert(w, index);/*from  w  ww.  j  a  v a2 s .co  m*/
            getLayoutManager().addElementResizeListener(w.getElement(), childCenterer);
            w.getElement().getStyle().setOpacity(0d);
            Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                    if (getWidget().getVisibleChild() != cc.getWidget()) {
                        w.getElement().getStyle().setDisplay(Display.NONE);
                    }
                    w.getElement().getStyle().clearOpacity();
                }
            });

        }
        ++index;
    }

    oldChildren.removeAll(children);
    for (final ComponentConnector cc : oldChildren) {
        cc.getLayoutManager().removeElementResizeListener(cc.getWidget().getElement(), childCenterer);
        getWidget().removeChild(cc.getWidget());
    }
}

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

License:Open Source License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
    final List<ComponentConnector> childConnectors = getChildComponents();
    final List<ComponentConnector> oldChildren = event.getOldChildren();

    oldChildren.removeAll(childConnectors);
    for (final ComponentConnector cc : oldChildren) {
        view.removeTab((MagnoliaTabWidget) cc.getWidget());
    }//from w ww .  j a  va2s.c  o  m

    for (final ComponentConnector cc : childConnectors) {
        view.updateTab((MagnoliaTabWidget) cc.getWidget());
    }
}

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

License:Open Source License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent e) {
    if (!e.getOldChildren().isEmpty()) {
        final ComponentConnector oldContent = e.getOldChildren().get(0);
        getWidget().remove(oldContent.getWidget());
    }/*from   w  w w.ja  v a  2 s. c om*/

    if (getContent() != null) {
        getWidget().setWidget(getContent().getWidget());
    }
}

From source file:org.tltv.gantt.client.GanttConnector.java

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {

    // StepConnector handles adding new step.
    // Here we handle removing and other necessary changed related
    // hierarchy.
    Set<StepWidget> predecessorRemoved = new HashSet<StepWidget>();
    // remove old steps
    for (ComponentConnector c : connectorHierarchyChangeEvent.getOldChildren()) {
        if (!getChildComponents().contains(c)) {
            StepWidget stepWidget = ((StepConnector) c).getWidget();
            getWidget().removeStep(stepWidget);
            predecessorRemoved.add(stepWidget);
        }// w  w w .  ja v a 2  s.  c  om
    }

    Map<Step, StepWidget> steps = getStepsMap();

    // update new steps with references to gantt widget and locale data
    // provider.
    for (ComponentConnector c : getChildComponents()) {
        StepWidget stepWidget = ((StepConnector) c).getWidget();
        if (!connectorHierarchyChangeEvent.getOldChildren().contains(c)) {
            stepWidget.setGantt(getWidget(), localeDataProvider);
        }

        Step predecessor = ((StepConnector) c).getState().step.getPredecessor();
        if (predecessor != null && !predecessorRemoved.contains(stepWidget)) {
            stepWidget.setPredecessorStepWidget(steps.get(predecessor));
        } else {
            stepWidget.setPredecessorStepWidget(null);
        }
    }

    deferredUpdateAllStepsPredecessors();
}

From source file:org.tltv.gantt.client.StepConnector.java

License:Apache License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {

    // SubStepConnector handles adding new sub-step.
    // Here we handle removing and other necessary changed related
    // hierarchy.
    Set<SubStepWidget> removed = new HashSet<SubStepWidget>();
    // remove old sub-steps
    for (ComponentConnector c : connectorHierarchyChangeEvent.getOldChildren()) {
        if (!getChildComponents().contains(c)) {
            SubStepWidget stepWidget = ((SubStepConnector) c).getWidget();
            getWidget().remove(stepWidget);
            removed.add(stepWidget);//from  w  w w. ja  v  a  2s.com
        }
    }

    if (gantt == null) {
        return;
    }
    // update new steps with references to gantt widget and locale data
    // provider.
    for (ComponentConnector c : getChildComponents()) {
        SubStepWidget stepWidget = ((SubStepConnector) c).getWidget();
        if (!connectorHierarchyChangeEvent.getOldChildren().contains(c)) {
            stepWidget.setGantt(gantt, gantt.getLocaleDataProvider());
        }
    }
}

From source file:org.vaadin.addon.leaflet.client.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);
        }/*  w ww.j  a  v  a 2  s .  c o m*/
        oldChildren.remove(componentConnector);
    }
    for (ComponentConnector componentConnector : oldChildren) {
        // Instance of check for Popup's that don't extend AbstractLeafletLayerConnector
        if (componentConnector instanceof AbstractLeafletLayerConnector) {
            AbstractLeafletLayerConnector<?> c = (AbstractLeafletLayerConnector<?>) componentConnector;
            Layer layer = c.getLayer();
            try {
                map.removeLayer(layer);
                if (layersControl != null) {
                    layersControl.removeLayer(layer);
                }
            } catch (Exception e) {
                VConsole.log("Removing failed, possibly due to timing issue...");
            }
        }
    }

    updateChildrens();
}