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

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

Introduction

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

Prototype

public final native int length() ;

Source Link

Document

Gets the length of the array.

Usage

From source file:org.opencms.ade.galleries.client.preview.CmsPreviewUtil.java

License:Open Source License

/**
 * Returns the available image format names for gallery widget mode.<p>
 * /*w w w  .ja  v a2s . c  om*/
 * @return the available image format names
 */
public static String[] getFormatNames() {

    JsArrayString formatNames = nativeGetFormatNames();
    if ((formatNames == null) || (formatNames.length() == 0)) {
        return null;
    }
    String[] result = new String[formatNames.length()];
    for (int i = 0; i < formatNames.length(); i++) {
        result[i] = formatNames.get(i);
    }
    return result;
}

From source file:org.opencms.ade.galleries.client.preview.CmsPreviewUtil.java

License:Open Source License

/**
 * Returns the available image formats for gallery widget mode.<p>
 * //from w w  w.j a  v  a 2  s. co  m
 * @return the available image formats
 */
public static String[] getFormats() {

    JsArrayString tempArr = nativeGetFormats();
    if ((tempArr == null) || (tempArr.length() == 0)) {
        return null;
    }
    String[] result = new String[tempArr.length()];
    for (int i = 0; i < tempArr.length(); i++) {
        result[i] = tempArr.get(i);
    }
    return result;
}

From source file:org.opencms.ui.client.CmsWidgetSetEntryPoint.java

License:Open Source License

/**
 * Loads JavaScript resources into the window context.<p>
 *
 * @param dependencies the dependencies to load
 * @param callback the callback to execute once the resources are loaded
 *//*w w  w . j a  v a 2 s. c  o m*/
public static void loadScriptDependencies(final JsArrayString dependencies, final JavaScriptObject callback) {

    if (dependencies.length() == 0) {
        return;
    }

    // Listener that loads the next when one is completed
    ResourceLoadListener resourceLoadListener = new ResourceLoadListener() {

        @Override
        public void onError(ResourceLoadEvent event) {

            CmsDebugLog.consoleLog(event.getResourceUrl() + " could not be loaded.");
            // The show must go on
            onLoad(event);
        }

        @Override
        public void onLoad(ResourceLoadEvent event) {

            if (dependencies.length() != 0) {
                String url = dependencies.shift();
                // Load next in chain (hopefully already preloaded)
                event.getResourceLoader().loadScript(url, this);
            } else {
                // finished loading dependencies
                callNativeFunction(callback);
            }
        }
    };

    ResourceLoader loader = ResourceLoader.get();

    // Start chain by loading first
    String url = dependencies.shift();
    loader.loadScript(url, resourceLoadListener);
    if (ResourceLoader.supportsInOrderScriptExecution()) {
        for (int i = 0; i < dependencies.length(); i++) {
            String preloadUrl = dependencies.get(i);
            loader.loadScript(preloadUrl, null);
        }
    } else {
        // Preload all remaining
        for (int i = 0; i < dependencies.length(); i++) {
            String preloadUrl = dependencies.get(i);
            loader.preloadResource(preloadUrl, null);
        }
    }
}

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

License:Open Source License

public List<String> getTextPropertyNames() {
    final JsArrayString nativeNames = getNativePropertyNames(getJSObject());
    final List<String> names = new ArrayList<String>();
    for (int i = 0; i < nativeNames.length(); i++) {
        names.add(nativeNames.get(i));//  w  ww.  j  a v  a 2 s  .  co  m
    }
    return names;
}

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

License:Open Source License

public List<String> getCategoryList() {
    final List<String> categories = new ArrayList<String>();
    final JsArrayString jsCategories = getCategories();
    for (int i = 0; i < jsCategories.length(); i++) {
        categories.add(jsCategories.get(i));
    }/*from ww w. j  ava  2  s  .  c om*/
    return categories;
}

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

License:Open Source License

public String getCategoriesAsString() {
    final StringBuilder catBuilder = new StringBuilder();
    final JsArrayString categories = getCategories();
    if (categories.length() > 0) {
        if (categories.length() == 1) {
            catBuilder.append("Category: ");
        } else {//from  www .ja  va  2  s . c om
            catBuilder.append("Categories: ");
        }
        for (int i = 0; i < categories.length(); i++) {
            catBuilder.append(categories.get(i));
            if (i != (categories.length() - 1)) {
                catBuilder.append(", ");
            }
        }
    }
    return catBuilder.toString();
}

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

License:Open Source License

public String[] getTextPropertyNames() {
    final JsArrayString nativeNames = getNativePropertyNames(getJSObject());
    final String[] names = new String[nativeNames.length()];
    for (int i = 0; i < nativeNames.length(); i++) {
        names[i] = nativeNames.get(i);/*from  w  w w . ja v a2  s.  c o  m*/
    }
    return names;
}

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

License:Open Source License

public GWTMapWidget() {
    super();/*from w w w  . ja  v  a  2 s .c  o m*/
    m_div = Document.get().createDivElement();
    m_div.setId("gwt-map");
    m_div.getStyle().setWidth(100, Unit.PCT);
    m_div.getStyle().setHeight(100, Unit.PCT);
    setElement(m_div);

    m_filter = new MarkerFilter() {
        @Override
        public boolean matches(final NodeMarker marker) {
            if (marker.getSeverity() < m_minimumSeverity)
                return false;
            if (m_searchString == null || "".equals(m_searchString))
                return true;

            final String searchString = m_searchString.toLowerCase();
            // VConsole.log("searching: search string = " + searchString);

            // /// handle foo: style search strings for text properties
            // VConsole.log("checking property:search");
            for (final String propertyName : marker.getTextPropertyNames()) {
                final String lowerPropertyName = propertyName.toLowerCase();
                if (searchString.startsWith(lowerPropertyName + ":")) {
                    final String searchStringWithoutPrefix = searchString
                            .replaceFirst(lowerPropertyName + ":\\s*", "");
                    final String propertyValue = marker.getProperty(propertyName);
                    if (propertyValue != null
                            && propertyValue.toLowerCase().contains(searchStringWithoutPrefix)) {
                        return true;
                    } else {
                        return false;
                    }
                } else if (searchString.startsWith(lowerPropertyName + "=")) {
                    final String searchStringWithoutPrefix = searchString
                            .replaceFirst(lowerPropertyName + "=\\s*", "");
                    final String propertyValue = marker.getProperty(propertyName);
                    if (propertyValue != null
                            && propertyValue.toLowerCase().equals(searchStringWithoutPrefix)) {
                        return true;
                    } else {
                        return false;
                    }
                }
            }

            // /// special case: categories: -> category: search
            if (searchString.startsWith("category:") || searchString.startsWith("categories:")) {
                final String searchStringWithoutPrefix = searchString.replaceFirst("categor(ies|y):\\s*", "");
                final MatchType match = matchCategories(marker, searchStringWithoutPrefix);
                return match != MatchType.NONE;
            } else if (searchString.startsWith("category=") || searchString.startsWith("categories=")) {
                final String searchStringWithoutPrefix = searchString.replaceFirst("categor(ies|y)=\\s*", "");
                final MatchType match = matchCategories(marker, searchStringWithoutPrefix);
                return match == MatchType.EXACT;
            }

            // /// if no foo: style search strings, first search all text
            // properties for a match
            for (final String propertyName : marker.getTextPropertyNames()) {
                final String value = marker.getProperty(propertyName);
                if (value != null) {
                    final String propertyValue = value.toLowerCase();
                    if (propertyValue.contains(searchString)) {
                        return true;
                    }
                }
            }

            // /// otherwise, search categories
            return matchCategories(marker, searchString) != MatchType.NONE;
        }

        private MatchType matchCategories(final NodeMarker marker, final String searchString) {
            final JsArrayString categories = marker.getCategories();
            for (int i = 0; i < categories.length(); i++) {
                final String category = categories.get(i).toLowerCase();
                if (category.equals(searchString)) {
                    return MatchType.EXACT;
                } else if (category.contains(searchString)) {
                    return MatchType.SUBSTRING;
                }
            }
            return MatchType.NONE;
        }

    };
    m_markers = new MarkerContainer(m_filter);
    VConsole.log("GWTMapWidget initialized");
}

From source file:org.opennms.features.vaadin.topology.gwt.client.GWTEdge.java

License:Open Source License

public String[] getActionKeys() {
    JsArrayString actionKeys = actionKeys();
    String[] keys = new String[actionKeys.length()];
    for (int i = 0; i < keys.length; i++) {
        keys[i] = actionKeys.get(i);//from w  ww . ja v a2s. c om
    }
    return keys;
}

From source file:org.opennms.features.vaadin.topology.gwt.client.GWTVertex.java

License:Open Source License

public final String[] getActionKeys() {
    JsArrayString actionKeys = actionKeys();
    String[] keys = new String[actionKeys.length()];
    for (int i = 0; i < keys.length; i++) {
        keys[i] = actionKeys.get(i);//w  ww  . j  a va2s  .co m
    }
    return keys;
}