Search in sources :

Example 1 with ComponentConnector

use of com.vaadin.client.ComponentConnector in project v-leaflet by mstahv.

the class LeafletLayerGroupConnector method updateChildren.

private void updateChildren() {
    for (ServerConnector serverConnector : getChildComponents()) {
        AbstractLeafletLayerConnector<?> c = (AbstractLeafletLayerConnector<?>) serverConnector;
        c.updateIfDirty();
    }
    if (orphaned != null) {
        for (ComponentConnector c : orphaned) {
            AbstractLeafletLayerConnector<?> lc = (AbstractLeafletLayerConnector<?>) c;
            lc.removeLayerFromParent();
        }
    }
}
Also used : ServerConnector(com.vaadin.client.ServerConnector) ComponentConnector(com.vaadin.client.ComponentConnector)

Example 2 with ComponentConnector

use of com.vaadin.client.ComponentConnector in project v-leaflet by mstahv.

the class LeafletLayerGroupConnector method setChildComponents.

@Override
public void setChildComponents(List<ComponentConnector> childComponents) {
    // Firing hierarchy changes events seems to be buggy in V7 :-(
    // As a workaround do the things here
    orphaned = new ArrayList<ComponentConnector>(getChildComponents());
    this.childComponents = childComponents;
    for (ServerConnector componentConnector : childComponents) {
        orphaned.remove(componentConnector);
    }
    markDirty();
    deferUpdate();
}
Also used : ServerConnector(com.vaadin.client.ServerConnector) ComponentConnector(com.vaadin.client.ComponentConnector)

Example 3 with ComponentConnector

use of com.vaadin.client.ComponentConnector in project v-leaflet by mstahv.

the class LeafletMapConnector method onConnectorHierarchyChange.

@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);
        }
        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();
}
Also used : ServerConnector(com.vaadin.client.ServerConnector) ComponentConnector(com.vaadin.client.ComponentConnector)

Example 4 with ComponentConnector

use of com.vaadin.client.ComponentConnector in project cuba by cuba-platform.

the class CubaCaptionWidget method updateCaption.

@Override
public boolean updateCaption() {
    ComponentConnector owner = getOwner();
    /* CAUTION copied from super class with small changes */
    boolean wasPlacedAfterComponent = placedAfterComponent;
    // Caption is placed after component unless there is some part which
    // moves it above.
    placedAfterComponent = captionPlacedAfterComponentByDefault;
    String style = CLASSNAME;
    if (ComponentStateUtil.hasStyles(owner.getState())) {
        for (String customStyle : owner.getState().styles) {
            style += " " + CLASSNAME + "-" + customStyle;
        }
    }
    if (!owner.isEnabled()) {
        style += " " + StyleConstants.DISABLED;
    }
    setStyleName(style);
    boolean hasIcon = owner.getState().resources.containsKey(ComponentConstants.ICON_RESOURCE);
    boolean showRequired = false;
    boolean showError = owner.getState().errorMessage != null;
    if (owner.getState() instanceof AbstractFieldState) {
        AbstractFieldState abstractFieldState = (AbstractFieldState) owner.getState();
        showError = showError && !abstractFieldState.hideErrors;
    }
    if (owner instanceof AbstractFieldConnector) {
        showRequired = ((AbstractFieldConnector) owner).isRequired();
    }
    if (icon != null) {
        getElement().removeChild(icon.getElement());
        icon = null;
    }
    if (hasIcon) {
        String uri = owner.getState().resources.get(ComponentConstants.ICON_RESOURCE).getURL();
        icon = getOwner().getConnection().getIcon(uri);
        if (icon instanceof ImageIcon) {
            // onload will set appropriate size later
            icon.setWidth("0");
            icon.setHeight("0");
        }
        DOM.insertChild(getElement(), icon.getElement(), getInsertPosition(InsertPosition.ICON));
        // Icon forces the caption to be above the component
        placedAfterComponent = false;
    }
    if (owner.getState().caption != null) {
        if (captionText == null) {
            captionText = DOM.createDiv();
            captionText.setClassName("v-captiontext");
            DOM.insertChild(getElement(), captionText, getInsertPosition(InsertPosition.CAPTION));
        }
        // Update caption text
        String c = owner.getState().caption;
        // A text forces the caption to be above the component.
        placedAfterComponent = false;
        if (c == null || c.trim().equals("")) {
            // that space is reserved.
            if (!hasIcon && !showRequired && !showError) {
                captionText.setInnerHTML("&nbsp;");
            }
        } else {
            setCaptionText(captionText, owner.getState());
        }
    } else if (captionText != null) {
        // Remove existing
        getElement().removeChild(captionText);
        captionText = null;
    }
    if (ComponentStateUtil.hasDescription(owner.getState()) && captionText != null) {
        addStyleDependentName("hasdescription");
    } else {
        removeStyleDependentName("hasdescription");
    }
    AriaHelper.handleInputRequired(owner.getWidget(), showRequired);
    if (showRequired) {
        if (requiredFieldIndicator == null) {
            requiredFieldIndicator = DOM.createDiv();
            requiredFieldIndicator.setClassName("v-required-field-indicator");
            requiredFieldIndicator.setInnerText("*");
            DOM.insertChild(getElement(), requiredFieldIndicator, getInsertPosition(InsertPosition.REQUIRED));
            // Hide the required indicator from assistive device
            Roles.getTextboxRole().setAriaHiddenState(requiredFieldIndicator, true);
        }
    } else if (requiredFieldIndicator != null) {
        // Remove existing
        requiredFieldIndicator.removeFromParent();
        requiredFieldIndicator = null;
    }
    if (isContextHelpIconEnabled(owner.getState())) {
        if (contextHelpIndicatorElement == null) {
            contextHelpIndicatorElement = DOM.createDiv();
            contextHelpIndicatorElement.setClassName(CONTEXT_HELP_CLASSNAME);
            DOM.insertChild(getElement(), contextHelpIndicatorElement, getContextHelpInsertPosition());
            if (clickHandlerRegistration == null) {
                clickHandlerRegistration = addClickHandler(this);
            }
        }
    } else {
        if (contextHelpIndicatorElement != null) {
            contextHelpIndicatorElement.removeFromParent();
            contextHelpIndicatorElement = null;
        }
        if (clickHandlerRegistration != null) {
            clickHandlerRegistration.removeHandler();
            clickHandlerRegistration = null;
        }
    }
    AriaHelper.handleInputInvalid(owner.getWidget(), showError);
    if (showError) {
        if (errorIndicatorElement == null) {
            errorIndicatorElement = DOM.createDiv();
            errorIndicatorElement.setInnerHTML("&nbsp;");
            errorIndicatorElement.setClassName("v-errorindicator");
            DOM.insertChild(getElement(), errorIndicatorElement, getInsertPosition(InsertPosition.ERROR));
            // Hide error indicator from assistive devices
            Roles.getTextboxRole().setAriaHiddenState(errorIndicatorElement, true);
        }
    } else if (errorIndicatorElement != null) {
        // Remove existing
        errorIndicatorElement.removeFromParent();
        errorIndicatorElement = null;
    }
    addStyleName(CLASSNAME);
    if (captionHolder != null) {
        captionHolder.captionUpdated(this);
    }
    return (wasPlacedAfterComponent != placedAfterComponent);
}
Also used : ImageIcon(com.vaadin.client.ui.ImageIcon) ComponentConnector(com.vaadin.client.ComponentConnector) AbstractFieldState(com.vaadin.shared.AbstractFieldState) AbstractFieldConnector(com.vaadin.client.ui.AbstractFieldConnector)

Example 5 with ComponentConnector

use of com.vaadin.client.ComponentConnector in project cuba by cuba-platform.

the class CubaFieldGroupLayoutComponentSlot method onBrowserEvent.

@Override
public void onBrowserEvent(Event event) {
    if (DOM.eventGetType(event) == Event.ONCLICK) {
        Element target = Element.as(event.getEventTarget());
        ComponentConnector componentConnector = Util.findConnectorFor(getWidget());
        if (target == contextHelpIndicatorElement && componentConnector instanceof HasContextHelpConnector) {
            HasContextHelpConnector connector = (HasContextHelpConnector) componentConnector;
            if (hasContextHelpIconListeners(componentConnector.getState())) {
                connector.contextHelpIconClick(event);
            }
        }
    }
}
Also used : HasContextHelpConnector(com.vaadin.client.ui.HasContextHelpConnector) ComponentConnector(com.vaadin.client.ComponentConnector) Element(com.google.gwt.dom.client.Element)

Aggregations

ComponentConnector (com.vaadin.client.ComponentConnector)9 ServerConnector (com.vaadin.client.ServerConnector)3 Element (com.google.gwt.dom.client.Element)2 HasContextHelpConnector (com.vaadin.client.ui.HasContextHelpConnector)2 Widget (com.google.gwt.user.client.ui.Widget)1 VCaption (com.vaadin.client.VCaption)1 AbstractFieldConnector (com.vaadin.client.ui.AbstractFieldConnector)1 ImageIcon (com.vaadin.client.ui.ImageIcon)1 AbstractFieldState (com.vaadin.shared.AbstractFieldState)1 EditorListener (org.vaadin.patrik.client.EditorStateManager.EditorListener)1 FocusListener (org.vaadin.patrik.client.FocusTracker.FocusListener)1 FastNavigationClientRPC (org.vaadin.patrik.shared.FastNavigationClientRPC)1 FastNavigationServerRPC (org.vaadin.patrik.shared.FastNavigationServerRPC)1