Example usage for com.google.gwt.coreext.client IterableFastStringMap put

List of usage examples for com.google.gwt.coreext.client IterableFastStringMap put

Introduction

In this page you can find the example usage for com.google.gwt.coreext.client IterableFastStringMap put.

Prototype

@Override
    public native T put(String key, T widget) ;

Source Link

Usage

From source file:com.google.speedtracer.client.visualizations.view.EventWaterfallRowDetails.java

License:Apache License

/**
 * Goes to concrete implementation to construct details map for an event.
 * /* w  ww  .  ja  va2s .  com*/
 * @param e the {@link UiEvent}
 * @return the details Map for the UiEvent
 */
private IterableFastStringMap<CellRenderer> getDetailsMapForEvent(UiEvent e) {
    final IterableFastStringMap<CellRenderer> details = new IterableFastStringMap<CellRenderer>();

    details.put("Description", new StringCellRenderer(e.getHelpString()));
    details.put("@", new StringCellRenderer(TimeStampFormatter.formatMilliseconds(e.getTime())));
    if (e.getDuration() > 0) {
        details.put("Duration",
                new StringCellRenderer(TimeStampFormatter.formatMilliseconds(e.getDuration(), 3)));
    }

    String currentAppUrl = eventWaterfall.getVisualization().getModel().getDataDispatcher().getTabDescription()
            .getUrl();

    // This is the stackTrace output by newer versions of WebKit.
    JSOArray<StackFrame> stackTrace = e.getStackTrace();
    if (stackTrace != null) {
        details.put("Stack Trace", new StackTraceRenderer(stackTrace, symbolClickListener, this, currentAppUrl,
                this, true, resources));
    }
    // This is the caller location output by older versions of WebKit.
    // TODO(jaimeyap): remove this once stack trace API reaches Chromium beta.
    if (e.hasCallLocation()) {
        stackTrace = JSOArray.create();
        stackTrace.push(StackFrame.create(e.getCallerScriptName(), e.getCallerFunctionName(),
                e.getCallerScriptLine(), 0));
        details.put("Caused by", new StackTraceRenderer(stackTrace, symbolClickListener, this, currentAppUrl,
                this, true, resources));
    }

    switch (e.getType()) {
    case TimerFiredEvent.TYPE:
        TimerInstalled timerData = eventWaterfall.getSourceDispatcher()
                .getTimerMetaData(e.<TimerInstalled>cast().getTimerId());
        populateDetailsForTimerInstall(timerData, details);
        break;
    case TimerInstalled.TYPE:
        populateDetailsForTimerInstall(e.<TimerInstalled>cast(), details);
        break;
    case TimerCleared.TYPE:
        details.put("Cleared Timer Id", new StringCellRenderer(e.<TimerCleared>cast().getTimerId() + ""));
        break;
    case PaintEvent.TYPE:
        PaintEvent paintEvent = e.cast();
        details.put("Origin", new StringCellRenderer(paintEvent.getX() + ", " + paintEvent.getY()));
        details.put("Size", new StringCellRenderer(paintEvent.getWidth() + " x " + paintEvent.getHeight()));
        break;
    case ParseHtmlEvent.TYPE:
        ParseHtmlEvent parseHtmlEvent = e.cast();
        details.put("Line Number", new StringCellRenderer(parseHtmlEvent.getStartLine() + ""));
        details.put("Length", new StringCellRenderer(parseHtmlEvent.getLength() + " characters"));
        break;
    case EvalScript.TYPE:
        EvalScript scriptTagEvent = e.cast();
        details.put("Url", new StringCellRenderer(scriptTagEvent.getURL()));
        details.put("Line Number", new StringCellRenderer(scriptTagEvent.getLineNumber() + ""));
        break;
    case XhrReadyStateChangeEvent.TYPE:
        XhrReadyStateChangeEvent xhrEvent = e.cast();
        details.put("Ready State", new StringCellRenderer(xhrEvent.getReadyState() + ""));
        details.put("Url", new StringCellRenderer(xhrEvent.getUrl()));
        break;
    case XhrLoadEvent.TYPE:
        details.put("Url", new StringCellRenderer(e.<XhrLoadEvent>cast().getUrl()));
        break;
    case LogEvent.TYPE:
        LogEvent logEvent = e.cast();
        details.put("Message", new StringCellRenderer(logEvent.getMessage()));
        break;
    case JavaScriptExecutionEvent.TYPE:
        JavaScriptExecutionEvent jsExecEvent = e.cast();
        JSOArray<StackFrame> function = JSOArray.create();
        function.push(
                StackFrame.create(jsExecEvent.getScriptName(), "[unknown]", jsExecEvent.getScriptLine(), 0));
        details.put("Function Call", new StackTraceRenderer(function, symbolClickListener, this, currentAppUrl,
                this, true, resources));
        break;
    case ResourceDataReceivedEvent.TYPE:
        ResourceDataReceivedEvent dataRecEvent = e.cast();
        DataDispatcher dataDispatcher = eventWaterfall.getVisualization().getModel().getDataDispatcher();
        NetworkEventDispatcher networkDispatcher = dataDispatcher.getNetworkEventDispatcher();
        NetworkResource resource = networkDispatcher.getResource(dataRecEvent.getRequestId());
        if (resource != null) {
            String resourceUrlStr = resource.getLastPathComponent();
            resourceUrlStr = "".equals(resourceUrlStr) ? resource.getUrl() : resourceUrlStr;
            details.put("Processing Resource", new StringCellRenderer(resourceUrlStr));
        }
        break;
    default:
        break;
    }

    if (e.getOverhead() > 0) {
        details.put("Overhead",
                new StringCellRenderer(TimeStampFormatter.formatMilliseconds(e.getOverhead(), 2)));
    }

    if (CustomEvent.isCustomEvent(e.getType())) {
        // Render key-value pairs for the custom event.
        // Simply iterate over the custom data on the CustomEvent.
        CustomEvent customEvent = e.cast();
        DataBag customData = customEvent.getCustomData();
        customData.iterate(new IterationCallback() {
            public void onIteration(String key, String value) {
                details.put(key, new StringCellRenderer(value));
            }
        });
    }

    return details;
}

From source file:com.google.speedtracer.client.visualizations.view.EventWaterfallRowDetails.java

License:Apache License

private void populateDetailsForTimerInstall(TimerInstalled timerData,
        IterableFastStringMap<CellRenderer> details) {
    if (timerData != null) {
        details.put("Timer Id", new StringCellRenderer(timerData.getTimerId() + ""));
        details.put("Timer Type",
                new StringCellRenderer(timerData.isSingleShot() ? "setTimeout" : "setInterval"));
        details.put("Interval", new StringCellRenderer(timerData.getInterval() + "ms"));
    }// w  w w  .  j a  va  2 s .  c  om
}

From source file:com.google.speedtracer.client.visualizations.view.ServerEventColors.java

License:Apache License

public static Color getColorFor(ServerEvent event) {
    assert event.getType() == EventRecordType.SERVER_EVENT : "event is not a ServerEvent";
    if (colorByTypeString == null) {
        final IterableFastStringMap<Color> map = new IterableFastStringMap<Color>();

        map.put("HTTP", Color.ORANGE);

        // Spring Insight only.
        map.put("WEB_REQUEST", Color.BLUEVIOLET);
        map.put("VIEW_RENDER", Color.MIDNIGHT_BLUE);
        map.put("JDBC", Color.INDIAN_RED);
        map.put("VIEW_RESOLVER", Color.CYAN);
        map.put("TRANSACTION", Color.LIGHT_BLUE);
        map.put("CONTROLLER_METHOD", Color.LIGHTGREEN);
        map.put("MODEL_ATTRIBUTE", Color.DARKGREEN);
        map.put("ANNOTATED_METHOD", Color.PEACH);
        map.put("GRAILS_CONTROLLER_METHOD", Color.YELLOW);
        map.put("LIFECYCLE", Color.DARKBLUE);
        map.put("INIT_BINDER", Color.BROWN);
        map.put("SIMPLE", Color.LIMEGREEN);

        // AppStats only.
        map.put("API", Color.LIGHT_BLUE);
        colorByTypeString = map;//from   w w w  .j  a  va2  s.co m
    }

    final Color color = colorByTypeString.get(event.getServerEventData().getType());
    return (color == null) ? Color.LIGHTGREY : color;
}