Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: Source/devtools/front_end/sources/ThreadsSidebarPane.js

Issue 449893002: DevTools: Introduce ThreadsSidebar (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address vsevik's comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 {!Map.<!WebInspector.Placard, !WebInspector.Target>} */
16 this._placardsToTargets = new Map();
17 /** @type {?WebInspector.Placard} */
18 this._selectedPlacard = null;
19 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerPaused, this._onDebuggerStateChanged, this );
20 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerResumed, this._onDebuggerStateChanged, thi s);
21 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targ etChanged, this);
22 WebInspector.targetManager.observeTargets(this);
23 }
24
25 WebInspector.ThreadsSidebarPane.prototype = {
26
27 /**
28 * @param {!WebInspector.Target} target
29 */
30 targetAdded: function(target)
31 {
32 var placard = new WebInspector.Placard(WebInspector.displayNameForURL(ta rget.name()), "");
vsevik 2014/08/08 11:18:26 Calling WebInspector.displayNameForURL("Main") giv
33 placard.element.addEventListener("click", this._onPlacardClick.bind(this , placard), false);
34 var currentTarget = WebInspector.context.flavor(WebInspector.Target);
35 if (currentTarget === target)
36 this._selectPlacard(placard);
37
38 this._targetsToPlacards.put(target, placard);
39 this._placardsToTargets.put(placard, target);
40 this.bodyElement.appendChild(placard.element);
41 this._updateDebuggerState(target);
42 },
43
44 /**
45 * @param {!WebInspector.Target} target
46 */
47 targetRemoved: function(target)
48 {
49 var placard = this._targetsToPlacards.remove(target);
50 this._placardsToTargets.remove(placard);
51 this.bodyElement.removeChild(placard.element);
52 },
53
54 /**
55 * @param {!WebInspector.Event} event
56 */
57 _targetChanged: function(event)
58 {
59 var newTarget = /** @type {?WebInspector.Target} */(event.data);
60 var placard = /** @type {!WebInspector.Placard} */ (this._targetsToPlac ards.get(newTarget));
61 this._selectPlacard(placard);
62 },
63
64 /**
65 * @param {!WebInspector.Event} event
66 */
67 _onDebuggerStateChanged: function(event)
68 {
69 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta rget);
70 this._updateDebuggerState(debuggerModel.target());
71 },
72
73 /**
74 * @param {!WebInspector.Target} target
75 */
76 _updateDebuggerState: function(target)
77 {
78 var placard = this._targetsToPlacards.get(target);
79 placard.subtitle = target.debuggerModel.isPaused() ? WebInspector.UIStri ng("Paused") : WebInspector.UIString("Running");
80 },
81
82 /**
83 * @param {!WebInspector.Placard} placard
84 */
85 _selectPlacard: function(placard)
86 {
87 if (placard === this._selectedPlacard)
88 return;
89
90 if (this._selectedPlacard)
91 this._selectedPlacard.selected = false;
92
93 this._selectedPlacard = placard;
94 placard.selected = true;
95 },
96
97 /**
98 * @param {!WebInspector.Placard} placard
99 */
100 _onPlacardClick: function(placard)
101 {
102 WebInspector.context.setFlavor(WebInspector.Target, this._placardsToTarg ets.get(placard));
103 placard.element.scrollIntoViewIfNeeded();
104 },
105
106
107 __proto__: WebInspector.SidebarPane.prototype
108 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sources/SourcesPanel.js ('k') | Source/devtools/front_end/ui/SidebarPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698