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

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

Introduction

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

Prototype

public final native String get(int index) ;

Source Link

Document

Gets the value at a given index.

Usage

From source file:org.opencms.ade.sitemap.client.hoverbar.CmsCopyPageMenuEntry.java

License:Open Source License

/**
 * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuEntry#execute()
 *//*from   w  w  w.jav  a 2s  .  co m*/
@Override
public void execute() {

    CmsUUID id = getHoverbar().getEntry().getId();
    CmsScriptCallbackHelper callback = new CmsScriptCallbackHelper() {

        @Override
        public void run() {

            JsArrayString args = m_arguments.cast();
            String ids = args.get(0);
            if (ids.length() > 0) {
                List<String> idList = CmsStringUtil.splitAsList(ids, "|");
                CmsSitemapController controller = CmsSitemapView.getInstance().getController();
                for (String idFromList : idList) {

                    if (null != controller.getEntryById(new CmsUUID(idFromList))) {
                        controller.updateEntry(new CmsUUID(idFromList));
                    }
                }
            }
        }
    };
    openPageCopyDialog("" + id, callback.createCallback());
}

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

License:Open Source License

/**
 * @see com.vaadin.client.extensions.AbstractExtensionConnector#extend(com.vaadin.client.ServerConnector)
 *//*from   w  w w .j a  v  a2s.  c  o m*/
@Override
protected void extend(ServerConnector target) {

    installNativeFunctions();
    CmsScriptCallbackHelper callbackHelper = new CmsScriptCallbackHelper() {

        @Override
        @SuppressWarnings("synthetic-access")
        public void run() {

            JsArrayString arguments = m_arguments.cast();
            getRpcProxy(I_CmsSitemapServerRpc.class).showLocaleComparison(arguments.get(0));

        }
    };
    callbackHelper.installCallbackOnWindow(CmsGwtConstants.CALLBACK_REFRESH_LOCALE_COMPARISON);

    CmsScriptCallbackHelper propertySaveHelper = new CmsScriptCallbackHelper() {

        @SuppressWarnings("synthetic-access")
        @Override
        public void run() {

            JsArrayString arguments = m_arguments.cast();
            String id = arguments.get(0);
            getRpcProxy(I_CmsSitemapServerRpc.class).handleChangedProperties(id);
        }

    };
    propertySaveHelper.installCallbackOnWindow(CmsGwtConstants.CALLBACK_HANDLE_CHANGED_PROPERTIES);

}

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
 *//*from ww w .  ja v  a2  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));
    }//from   ww w .  j  a va  2  s. c  o 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   w w w  . j a v a  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 {/* ww w .  ja  v a  2 s .  c o  m*/
            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);
    }/*w  ww.ja va2 s  .  c  om*/
    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  . j  a v a2 s  .  com
    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 w  w . j a  v a  2  s  . c  o m*/
    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 .  ja  va 2  s.  c  o  m*/
    return keys;
}