<commit_before>/* 
@ITMillApache2LicenseForJavaFiles@
 */

package com.itmill.toolkit.terminal.gwt.client;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.HasFocus;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ui.ContextMenu;
import com.itmill.toolkit.terminal.gwt.client.ui.IView;
import com.itmill.toolkit.terminal.gwt.client.ui.Notification;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class ApplicationConnection {

    private final String appUri;

    private final HashMap resourcesMap = new HashMap();

    private static Console console;

    private final Vector pendingVariables = new Vector();

    private final HashMap idToPaintable = new HashMap();

    private final HashMap paintableToId = new HashMap();

    private final WidgetSet widgetSet;

    private ContextMenu contextMenu = null;

    private Timer loadTimer;
    private Timer loadTimer2;
    private Timer loadTimer3;
    private Element loadElement;

    private final IView view;

    /**
     * True if each Paintable objects id is injected to DOM. Used for Testing
     * Tools.
     */
    private boolean usePaintableIdsInDOM = false;

    public ApplicationConnection(WidgetSet widgetSet) {
        this.widgetSet = widgetSet;
        appUri = getAppUri();

        if (isDebugMode()) {
            console = new DebugConsole(this);
        } else {
            console = new NullConsole();
        }

        if (isTestingMode()) {
            usePaintableIdsInDOM = true;
        }

        makeUidlRequest("repaintAll=1");

        // TODO remove hardcoded id name
        view = new IView("itmill-ajax-window");

    }

    private native static boolean isTestingMode()
    /*-{
        return $wnd.itmill.testingToolsUri ? true : false;
    }-*/;

    private native static void initializeTestingTools(String uri)
    /*-{
    }-*/;

    public static Console getConsole() {
        return console;
    }

    private native static boolean isDebugMode()
    /*-{
     var uri = $wnd.location;
     var re = /debug[^\/]*$/;
     return re.test(uri);
     }-*/;
<commit_msg>some steps towards Testing Tools supports<commit_after>/* 
@ITMillApache2LicenseForJavaFiles@
 */

package com.itmill.toolkit.terminal.gwt.client;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.HasFocus;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ui.ContextMenu;
import com.itmill.toolkit.terminal.gwt.client.ui.IView;
import com.itmill.toolkit.terminal.gwt.client.ui.Notification;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class ApplicationConnection {

    private final String appUri;

    private final HashMap resourcesMap = new HashMap();

    private static Console console;

    private final Vector pendingVariables = new Vector();

    private final HashMap idToPaintable = new HashMap();

    private final HashMap paintableToId = new HashMap();

    private final WidgetSet widgetSet;

    private ContextMenu contextMenu = null;

    private Timer loadTimer;
    private Timer loadTimer2;
    private Timer loadTimer3;
    private Element loadElement;

    private final IView view;

    /**
     * True if each Paintable objects id is injected to DOM. Used for Testing
     * Tools.
     */
    private boolean usePaintableIdsInDOM = false;

    public ApplicationConnection(WidgetSet widgetSet) {
        this.widgetSet = widgetSet;
        appUri = getAppUri();

        if (isDebugMode()) {
            console = new DebugConsole(this);
        } else {
            console = new NullConsole();
        }

        if (isTestingMode()) {
            usePaintableIdsInDOM = true;
            initializeTestingTools(getTestServerUri());
        }

        makeUidlRequest("repaintAll=1");

        // TODO remove hardcoded id name
        view = new IView("itmill-ajax-window");

    }

    private native static String getTestServerUri()
    /*-{
        return $wnd.itmill.testingToolsUri;
    }-*/;

    private native static boolean isTestingMode()
    /*-{
        return $wnd.itmill.testingToolsUri ? true : false;
    }-*/;

    private native static void initializeTestingTools(String testServerUri)
    /*-{
        $wnd.itmill.startATF(testServerUri);
    }-*/;

    public static Console getConsole() {
        return console;
    }

    private native static boolean isDebugMode()
    /*-{
     var uri = $wnd.location;
     var re = /debug[^\/]*$/;
     return re.test(uri);
     }-*/;

{'fraction_non_alphanumeric': 0.11018199704869651, 'fraction_numerical': 0.0013116904410559109, 'mean_word_length': 3.155313351498638, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7488601', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1799, 'n_words': 408}