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

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

Introduction

In this page you can find the example usage for com.google.gwt.core.client JavaScriptObject 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:it.appify.view.AppJsPageManager.java

License:Open Source License

private void onPageShowed(String name, JavaScriptObject e) {
    ConsoleLogger.getConsoleLogger().log("AppJsPageManager onPageShowed: " + name);
    Page<Element> currentPage = this.pages.get(name);
    Element el = e.cast();
    if (currentPage == null) {
        currentPage = new WebPage(el);
    } else {/*from   ww  w  . j a v  a2 s .  co m*/
        ((WebPage) currentPage).setPageElement(el);
    }
    this.pages.put("name", currentPage);
    onPageShow(currentPage);
}

From source file:it.appify.view.AppJsPageManager.java

License:Open Source License

private void onPageCreated(String pageName, JavaScriptObject e) {
    Page<Element> currentPage = this.pages.get(pageName);
    Element el = e.cast();
    if (currentPage == null) {
        currentPage = new WebPage(el);
    } else {// w  ww  .java  2  s  .  c  om
        ((WebPage) currentPage).setPageElement(el);
    }
    this.pages.put("name", currentPage);
    onPageCreate(currentPage);
}

From source file:it.appify.view.AppJsPageManager.java

License:Open Source License

private void onPageLoaded(String pageName, JavaScriptObject e) {
    Page<Element> currentPage = this.pages.get(pageName);
    Element el = e.cast();
    if (currentPage == null) {
        currentPage = new WebPage(el);
    } else {/*from ww w  .j a v  a2  s . c  o m*/
        ((WebPage) currentPage).setPageElement(el);
    }
    this.pages.put("name", currentPage);
    // onPageReady(currentPage);
}

From source file:it.appify.view.VueJsViewModel.java

License:Open Source License

protected void onDataReceived(JavaScriptObject view, JavaScriptObject model, JavaScriptObject event) {
    Element e = view.cast();
    JSONObject modelJson = new JSONObject(model);
    Event gwtEvent = event.cast();
    // ConsoleLogger.getConsoleLogger().log("getViewId: " + getViewId());
    // ConsoleLogger.getConsoleLogger().log("onDataReceived View  is: " + e.toString());
    // ConsoleLogger.getConsoleLogger().log("onDataReceived Model is: " + modelJson.toString());
    // ConsoleLogger.getConsoleLogger().log("onDataReceived Event is: " + gwtEvent.getType());
    // ConsoleLogger.getConsoleLogger().log("getCurrentEventTarget: "
    // + gwtEvent.getCurrentEventTarget().toString());
    // ConsoleLogger.getConsoleLogger().log("getParentElement: " + e.getParentElement().getId());
    String viewId = getViewId();/*from  ww  w.  j a va2 s .  com*/
    String parentId = e.getParentElement().getId();
    VMKey key = new VMKey(viewId, parentId);
    JSONArray array = modelJson.isArray();
    if (array != null) {
        modelJson = array.get(0).isObject();
    }
    Set<String> keySet = modelJson.keySet();
    if (keySet.size() == 1) {
        modelJson = modelJson.get(keySet.iterator().next()).isObject();

    }
    // TODO: important!! model event disaptching!!
    ViewModelHandlerHolder<?> holder = handlers.get(key);
    if (holder != null) {
        ConsoleLogger.getConsoleLogger().log("-->" + modelJson.toString());
        Serializable o = (Serializable) holder.getObjectMapper().read(modelJson.toString());
        holder.getHandler().onEvent(gwtEvent.getType(), getViewId(), e.getParentElement().getId(), o);
    } else {
        ConsoleLogger.getConsoleLogger().log("holder is null: " + viewId + " - " + parentId);
    }
    // TODO: important!! model event disaptching!!

}

From source file:mx.org.pescadormvp.examples.jsonp.client.query.GetLatLonActionHelperImpl.java

License:Open Source License

/**
 * Create the {@link Result} from the received {@link JavaScriptObject}.
 *//*from  w w w.j  a v a 2s. c  o  m*/
@Override
public GetLatLonResult insantiateResult(JavaScriptObject jsResult) {

    LatLonInfo latLonInfo = jsResult.cast();
    GetLatLonResult result = new GetLatLonResult();

    result.setHasData(latLonInfo.getCount() > 0);

    if (result.hasData()) {
        result.setDisplayName(latLonInfo.getDisplayName());
        result.setLat(Double.valueOf(latLonInfo.getLat()));
        result.setLon(Double.valueOf(latLonInfo.getLon()));
    }

    return result;
}

From source file:net.depoker.createjs.common.client.Event.java

License:Open Source License

/**
 * Contains properties and methods shared by all events for use with EventDispatcher.
 *
 * <p>Note that Event objects are often reused, so you should never rely on an event object's state outside of the
 * call stack it was received in.</p>
 *
 * @param impl Javascript instance of an {@link Event} type.
 *///from   w  ww.java 2 s . c  o  m
public Event(@NotNull JavaScriptObject impl) {
    this.impl = impl.cast();
}

From source file:net.depoker.createjs.preloadjs.client.AbstractLoader.java

License:Open Source License

AbstractLoader(@NotNull JavaScriptObject impl) {
    super(impl);
    this.impl = impl.cast();
}

From source file:org.eclipse.che.ide.jseditor.client.prefmodel.EditorPreferenceReader.java

License:Open Source License

/**
 * Retrieves the editor preference object as stored in the preference json string.
 * @return the preference object or null
 *//*from w  ww .jav a2  s.  c om*/
private EditorPreferences getPreferencesOrNull() {
    final String prefAsJson = this.preferencesManager.getValue(PREFERENCE_PROPERTY);
    if (prefAsJson == null || prefAsJson.isEmpty()) {
        return null;
    }
    JSONValue propertyObject;
    try {
        final JSONValue parseResult = JSONParser.parseStrict(prefAsJson);
        propertyObject = parseResult.isObject();
    } catch (final RuntimeException e) {
        Log.error(KeymapPrefReader.class, "Error during preference parsing.", e);
        return null;
    }
    if (propertyObject == null) {
        return null;
    }
    JavaScriptObject propertyValue;
    try {
        propertyValue = propertyObject.isObject().getJavaScriptObject();
    } catch (final RuntimeException e) {
        Log.error(KeymapPrefReader.class, "Invalid value for editor preference.", e);
        return null;
    }
    return propertyValue.cast();
}

From source file:org.gwtbootstrap3.extras.tagsinput.client.ui.base.TagsInputBase.java

License:Apache License

protected static List<String> toMultiValue(JavaScriptObject js_multi_value) {
    List<String> retValue = new ArrayList<String>();
    JsArrayString js_string_array = js_multi_value.cast();

    for (int i = 0; i < js_string_array.length(); i++) {
        retValue.add(js_string_array.get(i));
    }/*from   w ww  . j  ava2  s  .co m*/

    return retValue;
}

From source file:org.gwtbootstrap3.extras.tagsinput.client.ui.JSComplexTagsInput.java

License:Apache License

@Override
protected JSComplexTag toJO(JavaScriptObject tag) {
    return tag.cast();
}