Java Code Examples for com.google.gwt.core.client.JsArray#get()

The following examples show how to use com.google.gwt.core.client.JsArray#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TurboOverlaySerdes.java    From requestor with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <C extends Collection<JavaScriptObject>> C deserialize(Class<C> collectionType, String response,
                                                              DeserializationContext context) {
    JsArray<JavaScriptObject> jsArray = eval(response);
    if (collectionType.equals(List.class) || collectionType.equals(Collection.class)
            || collectionType.equals(JsArrayList.class)) {
        return (C) new JsArrayList(jsArray);
    } else {
        C col = context.getInstance(collectionType);
        for (int i = 0; i < jsArray.length(); i++) {
            JavaScriptObject t = jsArray.get(i);
            col.add(t);
        }
        return col;
    }
}
 
Example 2
Source File: Index.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public List<Document> search(final String text) {
    List<Document> results = new ArrayList<Document>();
    JsArray jsonResult = searchInternal(text);
    if (jsonResult != null) {
        for (int i = 0; i < jsonResult.length(); i++) {
            JSONObject json = new JSONObject(jsonResult.get(i));
            JSONString jsonId = json.get("ref").isString();
            if (jsonId != null) {
                long id = Long.parseLong(jsonId.stringValue());
                String documentJson = localStorage.getItem(key(id));
                if (documentJson != null) {
                    AutoBean<Document> autoBean = AutoBeanCodex.decode(beanFactory, Document.class, documentJson);
                    results.add(autoBean.as());
                }
            }
        }
    }
    return results;
}
 
Example 3
Source File: PanListener.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onTouchEnd(TouchEndEvent event) {
	if (touchId == null)
		return;
	JsArray<Touch> touches = event.getTouches();
	for (int i = 0; i < touches.length(); i++) {
		Touch touch = touches.get(i);
		if (touch.getIdentifier() == touchId)
			return;
	}
	touchId = null;
	event.preventDefault();
}
 
Example 4
Source File: PanListener.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onTouchMove(TouchMoveEvent event) {
	if (touchId == null)
		return;
	JsArray<Touch> touches = event.getTouches();
	for (int i = 0; i < touches.length(); i++) {
		Touch touch = touches.get(i);
		if (touch.getIdentifier() != touchId)
			continue;
		pan(touch.getClientX() - x, touch.getClientY() - y);
		x = touch.getClientX();
		y = touch.getClientY();
		event.preventDefault();
	}
}
 
Example 5
Source File: GoogleCategoriesDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
protected SelectHandler createSelectHandler(final CoreChartWidget selectable) {
    return new SelectHandler() {
        public void onSelect(SelectEvent event) {
            JsArray<Selection> selections = selectable.getSelection();
            for (int i = 0; i < selections.length(); i++) {
                Selection selection = selections.get(i);
                int row = selection.getRow();
                getPresenter().onCategorySelected(getDataTable().getColumnId(0), row);
            }
        }
    };
}
 
Example 6
Source File: GoogleCategoriesDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
protected SelectHandler createSelectHandler(final GeoChart selectable) {
    return new SelectHandler() {
        public void onSelect(SelectEvent event) {
            JsArray<Selection> selections = selectable.getSelection();
            for (int i = 0; i < selections.length(); i++) {
                Selection selection = selections.get(i);
                int row = selection.getRow();
                getPresenter().onCategorySelected(getDataTable().getColumnId(0), row);
            }
        }
    };
}
 
Example 7
Source File: JsonObjectSerdes.java    From requestor with Apache License 2.0 5 votes vote down vote up
@Override
public <C extends Collection<T>> C deserialize(Class<C> collectionType, String response,
                                               DeserializationContext context) {
    if (!isArray(response))
        throw new UnableToDeserializeException("Response content is not an array.");

    C col = context.getInstance(collectionType);
    @SuppressWarnings("unchecked")
    JsArray<JavaScriptObject> jsArray = (JsArray<JavaScriptObject>) eval(response);
    for (int i = 0; i < jsArray.length(); i++) {
        JavaScriptObject jso = jsArray.get(i);
        col.add(readJson((JsonRecordReader) jso, context));
    }
    return col;
}
 
Example 8
Source File: OverlaySerdes.java    From requestor with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <C extends Collection<JavaScriptObject>> C deserialize(Class<C> collectionType, String response,
                                                              DeserializationContext context) {
    JsArray<JavaScriptObject> jsArray = eval(response);
    C col = context.getInstance(collectionType);
    for (int i = 0; i < jsArray.length(); i++) {
        JavaScriptObject t = jsArray.get(i);
        col.add(t);
    }
    return col;
}
 
Example 9
Source File: TagsInputBase.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
/**
 * Returns list of items contained in the
 *  
 * @return List of items
 */
public List<T> getItems() {
    JsArray<JavaScriptObject> js_items = getItems(getElement());
    List<T> items = new ArrayList<T>();
    
    for(int i=0; i<js_items.length(); i++) {
        @SuppressWarnings("unchecked")
        T item = (T) js_items.get(i);
        items.add(item);
    }
    
    return items;
}