1<!DOCTYPE html>
2<!--
3Copyright (c) 2013 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/model/event_set.html">
9<link rel="import" href="/tracing/ui/analysis/analysis_link.html">
10<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html">
11<link rel="import" href="/tracing/ui/base/dom_helpers.html">
12<link rel="import" href="/tracing/ui/base/table.html">
13<link rel="import" href="/tracing/value/ui/scalar_span.html">
14<link rel="import" href="/tracing/value/unit.html">
15
16<polymer-element name="tr-ui-a-multi-object-sub-view"
17    extends="tr-ui-a-sub-view">
18  <template>
19    <style>
20    :host {
21      display: flex;
22    }
23    </style>
24    <tr-ui-b-table id="content"></tr-ui-b-table>
25  </template>
26  <script>
27  'use strict';
28
29  Polymer({
30    created: function() {
31      this.currentSelection_ = undefined;
32    },
33
34    ready: function() {
35      this.$.content.showHeader = false;
36    },
37
38    get selection() {
39      return this.currentSelection_;
40    },
41
42    set selection(selection) {
43      this.currentSelection_ = selection;
44
45      var objectEvents = tr.b.asArray(selection).sort(
46          tr.b.Range.compareByMinTimes);
47
48      var timeSpanConfig = {
49        unit: tr.v.Unit.byName.timeStampInMs,
50        ownerDocument: this.ownerDocument
51      };
52      var table = this.$.content;
53      table.tableColumns = [
54        {
55          title: 'First',
56          value: function(event) {
57            if (event instanceof tr.model.ObjectSnapshot)
58              return tr.v.ui.createScalarSpan(event.ts, timeSpanConfig);
59
60            var spanEl = document.createElement('span');
61            spanEl.appendChild(tr.v.ui.createScalarSpan(
62                event.creationTs, timeSpanConfig));
63            spanEl.appendChild(tr.ui.b.createSpan({
64                textContent: '-',
65                marginLeft: '4px',
66                marginRight: '4px'
67            }));
68            if (event.deletionTs != Number.MAX_VALUE) {
69              spanEl.appendChild(tr.v.ui.createScalarSpan(
70                  event.deletionTs, timeSpanConfig));
71            }
72            return spanEl;
73          },
74          width: '200px'
75        },
76        {
77          title: 'Second',
78          value: function(event) {
79            var linkEl = document.createElement('tr-ui-a-analysis-link');
80            linkEl.setSelectionAndContent(function() {
81                return new tr.model.EventSet(event);
82            }, event.userFriendlyName);
83            return linkEl;
84          },
85          width: '100%'
86        }
87      ];
88      table.tableRows = objectEvents;
89      table.rebuild();
90    }
91  });
92  </script>
93</polymer-element>
94