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

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

Introduction

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

Prototype

@Override
public final String toString() 

Source Link

Document

Makes a best-effort attempt to get a useful debugging string describing the given JavaScriptObject.

Usage

From source file:com.gwtmodel.table.view.ewidget.polymer.IronSelectorPolymerCombo.java

License:Apache License

private String getV(JavaScriptObject o, Object oo) {
    String a = iSel.getAttrForSelected();
    String ss;/*from   w w  w .j  a  v a 2 s  . c  o  m*/
    if (oo == null)
        ss = o.toString();
    else
        ss = oo.toString();
    if (!CUtil.EmptyS(a))
        return ss;
    // index
    if (!CUtil.OkInteger(ss))
        return ss;
    int i = CUtil.getNumb(ss);
    JsArray li = iSel.getItems();
    JavaScriptObject obj = li.get(i);
    Element ele = obj.cast();
    String in = ele.getInnerText();
    String sss = obj.getClass().getName();
    return in;
}

From source file:com.moveit.client.facebook.FacebookApi.java

License:Apache License

private void callMethodRetBoolean(final String method, final JavaScriptObject params,
        final AsyncCallback<Boolean> callback) {

    callMethod(method, params, new Callback<JavaScriptObject>(callback) {

        public void onSuccess(JavaScriptObject response) {

            // Hackarond facebook bug, data.setCookie returns an empty
            // object, should return 0 or 1.
            if (new JSONObject(response).toString().equals("{}")) {
                callback.onSuccess(true);
                return;
            }/*from ww  w .  j a v  a2s  .co  m*/
            callback.onSuccess(("1".equals(response.toString()) || "true".equals(response.toString())));
        }
    });
}

From source file:com.ponysdk.core.terminal.ui.PTAddOn.java

License:Apache License

protected void doUpdate(final String methodName, final JavaScriptObject arguments) {
    try {//from  www  .j  a  va  2s.  c o  m
        if (!destroyed)
            addOn.update(methodName, arguments);
        else
            log.warning("PTAddOn #" + getObjectID() + " destroyed, so updates will be discarded : "
                    + arguments.toString());
    } catch (final JavaScriptException e) {
        log.log(Level.SEVERE, e.getMessage(), e);
    }
}

From source file:com.vizuri.mobile.client.controller.BaseController.java

License:Apache License

protected void get(final String endpoint, String errorMessage) {
    if (Network.getOnline() && Properties.hasProperty(NomadProperties.AUTH_TOKEN)) {
        if (!isDataCacheExpired()) {
            //ClientUtil.showAlertMessage("Cache", "using cached results...");
            return;
        }/*w w  w  .  j av a2s . c om*/

        final HTTPClient getRequest = Network.createHTTPClient();

        getRequest.setValidatesSecureCertificate(false);
        getRequest.setTimeout(10000);

        final String displayMessage = (errorMessage != null && errorMessage.length() > 0) ? errorMessage
                : "An Error Occurred";
        getRequest.setOnerror(new EventCallback<JavaScriptObject>() {
            public void onEvent(JavaScriptObject event) {
                logger.error(displayMessage);
                ClientUtil.showAlertMessage("Error", event.toString());
                App.fireEvent(Events.DONE_WORKING, null);
            }
        });

        if (baseView != null) {
            getRequest.setOnload(new EventCallback<JavaScriptObject>() {
                public void onEvent(JavaScriptObject event) {
                    if (getRequest.getStatus() >= 200 && getRequest.getStatus() < 300) {
                        baseView.updateReceived(
                                XmlObjectWrapper.createObjectWrapper(getRequest.getResponseXML()));
                    } else {
                        ClientUtil.showAlertMessage("Request Error",
                                "Received HTTP status: " + getRequest.getStatus());
                    }
                    lastDataUpdate = new Date();
                    App.fireEvent(Events.DONE_WORKING, null);
                }
            });
        } else {
            getRequest.setOnload(new EventCallback<JavaScriptObject>() {
                public void onEvent(JavaScriptObject event) {
                    ClientUtil.showAlertMessage("Received data!", event.toString());
                    App.fireEvent(Events.DONE_WORKING, null);
                }
            });
        }

        App.fireEvent(Events.WORKING, null);

        String requestUrl = Properties.getString(NomadProperties.RHEV_URL, "") + endpoint;
        logger.info("Requesting: " + requestUrl);
        getRequest.open("GET", requestUrl);
        getRequest.setRequestHeader("Authorization", Properties.getString(NomadProperties.AUTH_TOKEN, ""));
        //getRequest.setRequestHeader("Accept", "application/json");
        getRequest.send();
    } else if (!ClientUtil.isUserAuthenticated()) {
        App.fireEvent(Events.LOGIN_REQUIRED, null);
    } else {
        ClientUtil.showAlertMessage("Network Error",
                "A network connection and configured authentication token is required to login remotely.");
    }
}

From source file:de.catma.ui.client.ui.tagger.impl.SelectionHandlerImplStandard.java

License:Open Source License

public final List<Range> getRangeList() {
    List<Range> result = new ArrayList<Range>();
    int rangeCount = getRangeCount();
    for (int i = 0; i < rangeCount; i++) {
        JavaScriptObject jsRange = getRangeAt(i);
        VConsole.log("jsRange: " + jsRange.toString());
        if (jsRange != null) {
            Range range = new Range(this, jsRange);
            VConsole.log(range.toDetailedString());
            result.add(range);//w  w  w.  j  ava2  s .  co  m
        }
    }
    return result;
}

From source file:opus.gwt.management.console.client.deployer.AppBrowserPanel.java

License:Apache License

public void populateFeaturedList(JavaScriptObject jso) {
    featured = new int[20];

    String[] s = jso.toString().split(",\\s*");
    featured = new int[s.length];
    //Window.alert(String.valueOf(s.length));
    for (int i = 0; i < s.length; i++) {
        featured[i] = Integer.valueOf(s[i]);
    }//from  www  . j  a v  a 2  s  . co m
    populateAppGrid(clientFactory.getApplications());
}

From source file:org.cruxframework.crux.widgets.client.rss.feed.Loader.java

License:Apache License

/**
 * This is called from the sandbox iframe with the top-level google object.
 *///from w w  w. j  a v a 2 s  .c  o m
static void ajaxFeedError(JavaScriptObject ex) {
    closeDocument(getDocument(SANDBOX));
    callback.onError(new RuntimeException("Unable to initialize ajax feed api " + ex.toString()));
}

From source file:org.eurekastreams.web.client.ui.common.form.elements.StreamScopeFormElement.java

License:Apache License

/**
 * Default constructor.//from   w w  w  .  j  a  v a  2 s .  c o  m
 * 
 * @param inKey
 *            the key name for the element.
 * @param inScopes
 *            the scopes.
 * @param inTitle
 *            the form element title.
 * @param inInstructions
 *            the instructions.
 * @param isRequired
 *            is the element required.
 * @param inAllowMultiple
 *            does this element allow multiple scopes to be selected.
 * @param inAutoCompleteUrl
 *            the url used to retrieve search results for the autocomplete box.
 * @param inMaxLength
 *            the maximum characters for the autocomplete textbox.
 * @param inMaxItems
 *            the maximum scopes allowed to be added - ignored if inAllowMultiple is false.
 */
public StreamScopeFormElement(final String inKey, final LinkedList<StreamScope> inScopes, final String inTitle,
        final String inInstructions, final boolean isRequired, final boolean inAllowMultiple,
        final String inAutoCompleteUrl, final int inMaxLength, final int inMaxItems) {
    key = inKey;
    allowMultiple = inAllowMultiple;
    maxItems = inMaxItems;
    this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().scopeFormElement());

    listMembers = new Label(inTitle);
    listMembers.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formLabel());

    final Label instructions = new Label(inInstructions);
    instructions.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formInstructions());

    final Set<String> uniqueKeys = new HashSet<String>();
    for (StreamScope scope : inScopes) {
        uniqueKeys.add(scope.getUniqueKey());
    }

    scopeListPanel = new StreamScopeListPanel(inScopes);

    final AutoCompleteEntityDropDownPanel autoComplete = new AutoCompleteEntityDropDownPanel(inAutoCompleteUrl);
    autoComplete.setMaxLength(inMaxLength);
    autoComplete.setOnItemSelectedCommand(new AutoCompleteEntityDropDownPanel.OnItemSelectedCommand() {
        public void itemSelected(final JavaScriptObject obj) {
            if (!getEntityType(obj.toString()).equals("NOTSET")) {
                EventBus.getInstance()
                        .notifyObservers(new StreamScopeAddedEvent(new StreamScope(
                                getDisplayName(obj.toString()),
                                ScopeType.valueOf(getEntityType(obj.toString())), getUniqueId(obj.toString()),
                                Long.parseLong(getStreamScopeId(obj.toString())))));
            }
        }
    });

    EventBus.getInstance().addObserver(StreamScopeAddedEvent.getEvent(), new Observer<StreamScopeAddedEvent>() {
        public void update(final StreamScopeAddedEvent obj) {
            uniqueKeys.add(obj.getScope().getUniqueKey());
            autoComplete.clearText();

            if (!allowMultiple || uniqueKeys.size() >= maxItems) {
                autoComplete.setVisible(false);
                instructions.setVisible(false);
            }
        }
    });

    EventBus.getInstance().addObserver(StreamScopeDeletedEvent.getEvent(),
            new Observer<StreamScopeDeletedEvent>() {
                public void update(final StreamScopeDeletedEvent obj) {
                    uniqueKeys.remove(obj.getScope().getUniqueKey());
                    if (!allowMultiple || uniqueKeys.size() < maxItems) {
                        autoComplete.setVisible(true);
                        instructions.setVisible(true);
                    }
                }
            });

    if ((!allowMultiple && !inScopes.isEmpty()) || uniqueKeys.size() >= maxItems) {
        autoComplete.setVisible(false);
        instructions.setVisible(false);
    }

    this.add(listMembers);
    this.add(scopeListPanel);
    this.add(autoComplete);
    if (isRequired) {
        Label requiredLabel = new Label("(required)");
        requiredLabel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().requiredFormLabel());
        this.add(requiredLabel);
    }

    this.add(instructions);
}

From source file:org.eurekastreams.web.client.ui.common.stream.PostToPanel.java

License:Apache License

/**
 * Default constructor.//w w  w.j a v  a2  s.  c  om
 * 
 * @param postScope
 *            the scope of the current user.
 * @param alwaysShow
 *            always show no matter where you are.
 */
public PostToPanel(final StreamScope postScope, final boolean alwaysShow) {
    // Make this random so we can support multiple of these.
    String groupName = "postTo-" + String.valueOf(Random.nextInt());
    mine = new RadioButton(groupName, "My activity stream");
    other = new RadioButton(groupName, "");

    myScope = postScope;
    WidgetJSNIFacade jSNIFacade = new WidgetJSNIFacadeImpl();
    mine.setChecked(true);
    this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postTo());

    if ((!jSNIFacade.getSecondToLastUrlToken().equals("people")
            && !jSNIFacade.getSecondToLastUrlToken().equals("groups")) || alwaysShow) {

        final PostToPanel thisBuffered = this;

        Label postTo = new Label("Post to:");
        postTo.addStyleName(StaticResourceBundle.INSTANCE.coreCss().label());
        this.add(postTo);

        this.add(mine);
        this.add(other);

        autoComplete = new AutoCompleteEntityDropDownPanel("/resources/autocomplete/entities/");

        autoComplete.setOnItemSelectedCommand(new AutoCompleteEntityDropDownPanel.OnItemSelectedCommand() {
            public void itemSelected(final JavaScriptObject obj) {
                String[] results = obj.toString().split(",", 4);
                if (!results[0].equals("NOTSET")) {
                    String displayName = results[3];
                    ScopeType entityType = ScopeType.valueOf(results[0]);
                    String uniqueId = results[1];
                    long streamScopeId = Long.parseLong(results[2]);

                    typedInScope = new StreamScope(displayName, entityType, uniqueId, streamScopeId);

                    other.setChecked(true);

                    autoComplete.setVisible(false);
                    autoComplete.setDefaultText(OTHER_TEXT);
                    scopePanel = new StreamScopePanel(typedInScope);
                    thisBuffered.add(scopePanel);
                } else {
                    typedInScope = null;
                }
            }
        });
        autoComplete.setDefaultText(OTHER_TEXT);
        this.add(autoComplete);

        EventBus.getInstance().addObserver(StreamScopeDeletedEvent.getEvent(),
                new Observer<StreamScopeDeletedEvent>() {
                    public void update(final StreamScopeDeletedEvent event) {
                        try {
                            if (typedInScope.equals(event.getScope())) {
                                autoComplete.setVisible(true);
                                autoComplete.setDefaultText(OTHER_TEXT);
                                thisBuffered.remove(scopePanel);
                                typedInScope = null;
                            }
                        } catch (final Exception ex) {
                            int x = 0;
                            // no logging Im client side. This means a scope
                            // closed that doesnt have an ID
                            // Usually by a user who just entered it into
                            // the create list modal.
                            // This is necessary because we use a little
                            // long vs a big Long.
                        }
                    }
                });

        EventBus.getInstance().addObserver(SwitchedToCustomStreamEvent.class,
                new Observer<SwitchedToCustomStreamEvent>() {
                    public void update(final SwitchedToCustomStreamEvent arg1) {
                        if (other.isChecked()) {
                            selectMyActivityStream();
                        }
                    }
                });

        EventBus.getInstance().addObserver(SwitchedToGroupStreamEvent.getEvent(),
                new Observer<SwitchedToGroupStreamEvent>() {
                    public void update(final SwitchedToGroupStreamEvent arg1) {
                        GroupStreamDTO group = arg1.getView();

                        // If the group has disabled posting, make "my activity stream" the default destination. The
                        // one case where this would be the incorrect thing to do is if the user is a group or org
                        // coordinator. But it is better for coordinators to have to explicitly choose the group
                        // than the alternative: a non-postable group pre-selected for regular users and their posts
                        // just going nowhere.
                        if (!group.isPostable()) {
                            selectMyActivityStream();
                        } else {
                            other.setChecked(true);
                            autoComplete.setVisible(false);
                            autoComplete.setDefaultText(OTHER_TEXT);
                            removeScopePanel(thisBuffered);

                            typedInScope = new StreamScope(ScopeType.GROUP, group.getShortName());
                            typedInScope.setDisplayName(group.getName());

                            scopePanel = new StreamScopePanel(typedInScope);
                            thisBuffered.add(scopePanel);
                        }
                    }
                });
    }
}

From source file:org.rstudio.studio.client.workbench.views.environment.dataimport.DataImportOptions.java

License:Open Source License

public final String getImportLocation() {
    JavaScriptObject location = getImportLocationNative();
    return location != null ? new String(location.toString()) : null;
}