OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @constructor | |
7 * @extends {WebInspector.SidebarPane} | |
8 * @implements {WebInspector.TargetManager.Observer} | |
9 */ | |
10 WebInspector.ThreadsSidebarPane = function() | |
11 { | |
12 WebInspector.SidebarPane.call(this, WebInspector.UIString("Threads")); | |
13 /** @type {!Map.<!WebInspector.Target, !WebInspector.Placard>} */ | |
14 this._targetsToPlacards = new Map(); | |
15 /** @type {?WebInspector.Placard} */ | |
16 this._selectedPlacard = null; | |
17 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerPaused, this._onDebuggerStateChanged, this ); | |
18 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerResumed, this._onDebuggerStateChanged, thi s); | |
19 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targ etChanged, this); | |
20 WebInspector.targetManager.observeTargets(this); | |
21 } | |
22 | |
23 WebInspector.ThreadsSidebarPane.prototype = { | |
24 | |
25 /** | |
26 * @param {!WebInspector.Target} target | |
27 */ | |
28 targetAdded: function(target) | |
29 { | |
30 var placard = new WebInspector.Placard(target.name(), ""); | |
vsevik
2014/08/08 08:32:03
Let's use a URL that is trimmed relative to docume
sergeyv
2014/08/08 09:01:50
Done.
| |
31 placard.__target = target; | |
vsevik
2014/08/08 08:32:03
Please use a Map instead.
sergeyv
2014/08/08 09:01:50
Done.
| |
32 placard.element.addEventListener("click", this._onPlacardClick.bind(this , placard), false); | |
33 var currentTarget = WebInspector.context.flavor(WebInspector.Target); | |
34 if (currentTarget === target) | |
35 this._selectPlacard(placard); | |
36 | |
37 this._targetsToPlacards.put(target, placard); | |
38 this.bodyElement.appendChild(placard.element); | |
39 this._updateDebuggerState(target); | |
40 }, | |
41 | |
42 /** | |
43 * @param {!WebInspector.Target} target | |
44 */ | |
45 targetRemoved: function(target) | |
46 { | |
47 var placard = this._targetsToPlacards.remove(target); | |
48 this.bodyElement.removeChild(placard.element); | |
49 }, | |
50 | |
51 /** | |
52 * @param {!WebInspector.Event} event | |
53 */ | |
54 _targetChanged: function(event) | |
55 { | |
56 var newTarget = /** @type {?WebInspector.Target} */(event.data); | |
57 var placard = /** @type {!WebInspector.Placard} */ (this._targetsToPlac ards.get(newTarget)); | |
58 this._selectPlacard(placard); | |
59 }, | |
60 | |
61 /** | |
62 * @param {!WebInspector.Event} event | |
63 */ | |
64 _onDebuggerStateChanged: function(event) | |
65 { | |
66 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta rget); | |
67 this._updateDebuggerState(debuggerModel.target()); | |
68 }, | |
69 | |
70 /** | |
71 * @param {!WebInspector.Target} target | |
72 */ | |
73 _updateDebuggerState: function(target) | |
74 { | |
75 var placard = this._targetsToPlacards.get(target); | |
76 placard.subtitle = target.debuggerModel.isPaused() ? WebInspector.UIStri ng("Paused") : WebInspector.UIString("Running"); | |
77 }, | |
78 | |
79 /** | |
80 * @param {!WebInspector.Placard} placard | |
81 */ | |
82 _selectPlacard: function(placard) | |
83 { | |
84 if (this._selectedPlacard) | |
vsevik
2014/08/08 08:32:03
Let's add an early bailout in case the same placar
sergeyv
2014/08/08 09:01:50
Done.
| |
85 this._selectedPlacard.selected = false; | |
86 | |
87 this._selectedPlacard = placard; | |
88 placard.selected = true; | |
89 }, | |
90 | |
91 /** | |
92 * @param {!WebInspector.Placard} placard | |
93 */ | |
94 _onPlacardClick: function(placard) | |
95 { | |
96 WebInspector.context.setFlavor(WebInspector.Target, placard.__target); | |
97 placard.element.scrollIntoViewIfNeeded(); | |
98 }, | |
99 | |
100 | |
101 __proto__: WebInspector.SidebarPane.prototype | |
102 } | |
OLD | NEW |