Example usage for com.google.gwt.core.client JsArrayString cast

List of usage examples for com.google.gwt.core.client JsArrayString cast

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsArrayString cast.

Prototype

@Override
@SuppressWarnings("unchecked")
public <T extends JavascriptObjectEquivalent> T cast() 

Source Link

Document

A helper method to enable cross-casting from any JavaScriptObject type to any other JavaScriptObject type.

Usage

From source file:org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker.java

License:Open Source License

public void setCategories(final String[] categories) {
    final JsArrayString array = JsArrayString.createArray().cast();
    for (final String category : categories) {
        array.push(category);/* w  w  w  .  java 2 s.com*/
    }
    final JSObject jsObject = array.cast();
    getJSObject().setProperty(Property.CATEGORIES, jsObject);
}

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

License:Apache License

private void setBaseLayers() {
    // clear old layers
    for (ILayer l : layers.values()) {
        map.removeLayer(l);//from  w  w  w.j  av  a 2  s. c o m
    }
    layers.clear();
    // add layers from state
    BaseLayer[] baseLayers = getState().getBaseLayers();
    if (baseLayers != null) {
        for (BaseLayer baseLayer : baseLayers) {
            // suck big time in V7, can't access the raw json, should use
            // e.g. gson and serialize as string in state
            Options tileOptions = new Options();
            tileOptions.setProperty("attribution", baseLayer.getAttributionString());
            if (baseLayer.getDetectRetina() != null && baseLayer.getDetectRetina()) {
                tileOptions.setProperty("detectRetina", true);
            }
            if (baseLayer.getSubDomains() != null) {
                JsArrayString domain = JsArrayString.createArray().cast();
                for (String a : baseLayer.getSubDomains()) {
                    domain.push(a);
                }
                tileOptions.setProperty("subdomains", (JSObject) domain.cast());
            }
            if (baseLayer.getMaxZoom() != null) {
                tileOptions.setProperty("maxZoom", baseLayer.getMaxZoom());
            }
            if (baseLayer.getTms() != null && baseLayer.getTms()) {
                tileOptions.setProperty("tms", true);
            }
            if (baseLayer.getOpacity() != null) {
                tileOptions.setProperty("opacity", baseLayer.getOpacity());
            }

            if (baseLayer.getWms() != null && baseLayer.getWms() == true) {
                if (baseLayer.getLayers() != null) {
                    tileOptions.setProperty("layers", baseLayer.getLayers());
                }
                if (baseLayer.getStyles() != null) {
                    tileOptions.setProperty("styles", baseLayer.getStyles());
                }
                if (baseLayer.getFormat() != null) {
                    tileOptions.setProperty("format", baseLayer.getFormat());
                }
                if (baseLayer.getTransparent() != null && baseLayer.getTransparent()) {
                    tileOptions.setProperty("transparent", true);
                }
                if (baseLayer.getVersion() != null) {
                    tileOptions.setProperty("version", baseLayer.getVersion());
                }
                WmsLayer layer = new WmsLayer(baseLayer.getUrl(), tileOptions);
                map.addLayer(layer);
                layers.put(baseLayer, layer);
            } else {
                TileLayer layer = new TileLayer(baseLayer.getUrl(), tileOptions);
                map.addLayer(layer);
                layers.put(baseLayer, layer);
            }
        }
    }
}