com.vaadin.client.Profiler Java Examples

The following examples show how to use com.vaadin.client.Profiler. 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: MessageHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Unwraps and parses the given JSON, originating from the server.
 *
 * @param jsonText
 *            the json from the server
 * @return A parsed ValueMap or null if the input could not be parsed (or
 *         was null)
 */
public static ValueMap parseJson(String jsonText) {
    if (jsonText == null) {
        return null;
    }
    final double start = Profiler.getRelativeTimeMillis();
    try {
        ValueMap json = parseJSONResponse(jsonText);
        Console.log("JSON parsing took "
                + Profiler.getRelativeTimeString(start) + "ms");
        return json;
    } catch (final Exception e) {
        Console.error("Unable to parse JSON: " + jsonText);
        return null;
    }
}
 
Example #2
Source File: XhrConnection.java    From flow with Apache License 2.0 6 votes vote down vote up
@Override
public void onSuccess(XMLHttpRequest xhr) {
    Console.log("Server visit took "
            + Profiler.getRelativeTimeString(requestStartTime) + "ms");

    // for(;;);["+ realJson +"]"
    String responseText = xhr.getResponseText();

    ValueMap json = MessageHandler.parseWrappedJson(responseText);
    if (json == null) {
        // Invalid string (not wrapped as expected or can't parse)
        registry.getConnectionStateHandler().xhrInvalidContent(
                new XhrConnectionError(xhr, payload, null));
        return;
    }

    registry.getConnectionStateHandler().xhrOk();
    Console.log("Received xhr message: " + responseText);
    registry.getMessageHandler().handleMessage(json);
}
 
Example #3
Source File: XhrConnection.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Sends an asynchronous UIDL request to the server using the given URI.
 *
 * @param payload
 *            The URI to use for the request. May includes GET parameters
 */
public void send(JsonObject payload) {
    XhrResponseHandler responseHandler = createResponseHandler();
    responseHandler.setPayload(payload);
    responseHandler.setRequestStartTime(Profiler.getRelativeTimeMillis());

    String payloadJson = WidgetUtil.stringify(payload);
    XMLHttpRequest xhr = Xhr.post(getUri(), payloadJson,
            JsonConstants.JSON_CONTENT_TYPE, responseHandler);

    Console.log("Sending xhr message to server: " + payloadJson);

    if (webkitMaybeIgnoringRequests && BrowserInfo.get().isWebkit()) {
        final int retryTimeout = 250;
        new Timer() {
            @Override
            public void run() {
                // Use native js to access private field in Request
                if (resendRequest(xhr) && webkitMaybeIgnoringRequests) {
                    // Schedule retry if still needed
                    schedule(retryTimeout);
                }
            }
        }.schedule(retryTimeout);
    }
}
 
Example #4
Source File: Bootstrapper.java    From flow with Apache License 2.0 5 votes vote down vote up
private static void initModule() {
    // Don't run twice if the module has been inherited several times,
    // and don't continue if vaadinBootstrap was not executed.
    if (moduleLoaded || !vaadinBootstrapLoaded()) {
        Console.warn(
                "vaadinBootstrap.js was not loaded, skipping vaadin application configuration.");
        return;
    }
    moduleLoaded = true;

    Profiler.initialize();

    registerCallback(GWT.getModuleName());
}
 
Example #5
Source File: Bootstrapper.java    From flow with Apache License 2.0 5 votes vote down vote up
private static void doStartApplication(final String applicationId) {
    Profiler.enter("Bootstrapper.startApplication");
    ApplicationConfiguration appConf = getConfigFromDOM(applicationId);
    ApplicationConnection applicationConnection = new ApplicationConnection(
            appConf);
    runningApplications.push(applicationConnection);
    Profiler.leave("Bootstrapper.startApplication");

    ValueMap initialUidl = getJsoConfiguration(applicationId).getUIDL();
    applicationConnection.start(initialUidl);
}
 
Example #6
Source File: ComboBoxMultiselectConnector.java    From vaadin-combobox-multiselect with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(final StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    Profiler.enter("ComboBoxMultiselectConnector.onStateChanged update content");

    getWidget().readonly = isReadOnly();
    getWidget().updateReadOnly();

    // not a FocusWidget -> needs own tabindex handling
    getWidget().tb.setTabIndex(getState().tabIndex);

    getWidget().suggestionPopup.updateStyleNames(getState());

    // make sure the input prompt is updated
    getWidget().updatePlaceholder();

    getDataReceivedHandler().serverReplyHandled();

    // all updates except options have been done
    getWidget().initDone = true;

    Profiler.leave("ComboBoxMultiselectConnector.onStateChanged update content");
}
 
Example #7
Source File: ComboBoxMultiselectConnector.java    From vaadin-combobox-multiselect with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(final StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    Profiler.enter("ComboBoxMultiselectConnector.onStateChanged update content");

    getWidget().readonly = isReadOnly();
    getWidget().updateReadOnly();

    // not a FocusWidget -> needs own tabindex handling
    getWidget().tb.setTabIndex(getState().tabIndex);

    getWidget().suggestionPopup.updateStyleNames(getState());

    // make sure the input prompt is updated
    getWidget().updatePlaceholder();

    getDataReceivedHandler().serverReplyHandled();

    // all updates except options have been done
    getWidget().initDone = true;

    Profiler.leave("ComboBoxMultiselectConnector.onStateChanged update content");
}