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

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

Issue 1172643002: DevTools: migrate sidebar pane's titleElement to use Toolbar. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaselined Created 5 years, 6 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
1 /* 1 /*
2 * Copyright (C) IBM Corp. 2009 All rights reserved. 2 * Copyright (C) IBM Corp. 2009 All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.SidebarPane} 33 * @extends {WebInspector.SidebarPane}
34 */ 34 */
35 WebInspector.WatchExpressionsSidebarPane = function() 35 WebInspector.WatchExpressionsSidebarPane = function()
36 { 36 {
37 WebInspector.SidebarPane.call(this, WebInspector.UIString("Watch")); 37 WebInspector.SidebarPane.call(this, WebInspector.UIString("Watch"));
38 this.registerRequiredCSS("components/objectValue.css");
38 39
39 this._requiresUpdate = true; 40 this._requiresUpdate = true;
40 /** @type {!Array.<!WebInspector.WatchExpression>} */ 41 /** @type {!Array.<!WebInspector.WatchExpression>} */
41 this._watchExpressions = []; 42 this._watchExpressions = [];
42 this._watchExpressionsSetting = WebInspector.settings.createLocalSetting("wa tchExpressions", []); 43 this._watchExpressionsSetting = WebInspector.settings.createLocalSetting("wa tchExpressions", []);
43 44
44 this.registerRequiredCSS("components/objectValue.css"); 45 var addButton = new WebInspector.ToolbarButton(WebInspector.UIString("Add ex pression"), "add-toolbar-item");
45 this.bodyElement.classList.add("vbox", "watch-expressions"); 46 addButton.addEventListener("click", this._addButtonClicked.bind(this));
46 this.bodyElement.addEventListener("contextmenu", this._contextMenu.bind(this ), false); 47 this.toolbar().appendToolbarItem(addButton);
48 var refreshButton = new WebInspector.ToolbarButton(WebInspector.UIString("Re fresh"), "refresh-toolbar-item");
49 refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this ));
50 this.toolbar().appendToolbarItem(refreshButton);
47 51
48 var refreshButton = this.titleElement.createChild("button", "pane-title-butt on refresh"); 52 this._bodyElement = this.element.createChild("div", "vbox watch-expressions" );
49 refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this ), false); 53 this._bodyElement.addEventListener("contextmenu", this._contextMenu.bind(thi s), false);
50 refreshButton.title = WebInspector.UIString("Refresh");
51 54
52 var addButton = this.titleElement.createChild("button", "pane-title-button a dd");
53 addButton.addEventListener("click", this._addButtonClicked.bind(this), false );
54 addButton.title = WebInspector.UIString("Add watch expression");
55 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this.refreshExpressions, this); 55 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this.refreshExpressions, this);
56 } 56 }
57 57
58 WebInspector.WatchExpressionsSidebarPane.prototype = { 58 WebInspector.WatchExpressionsSidebarPane.prototype = {
59 wasShown: function() 59 wasShown: function()
60 { 60 {
61 this._refreshExpressionsIfNeeded(); 61 this._refreshExpressionsIfNeeded();
62 }, 62 },
63 63
64 refreshExpressions: function() 64 refreshExpressions: function()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 _refreshExpressionsIfNeeded: function() 100 _refreshExpressionsIfNeeded: function()
101 { 101 {
102 if (this._requiresUpdate && this.isShowing()) { 102 if (this._requiresUpdate && this.isShowing()) {
103 this._rebuildWatchExpressions(); 103 this._rebuildWatchExpressions();
104 delete this._requiresUpdate; 104 delete this._requiresUpdate;
105 } else 105 } else
106 this._requiresUpdate = true; 106 this._requiresUpdate = true;
107 }, 107 },
108 108
109 /** 109 /**
110 * @param {?Event} event 110 * @param {!WebInspector.Event} event
111 */ 111 */
112 _addButtonClicked: function(event) 112 _addButtonClicked: function(event)
113 { 113 {
114 if (event) 114 if (event)
dgozman 2015/06/09 13:27:02 Remove |if (event)|.
pfeldman 2015/06/09 13:40:59 Done.
115 event.consume(true); 115 event.consume(true);
116 this.expand(); 116 this.expand();
117 this._createWatchExpression(null).startEditing(); 117 this._createWatchExpression(null).startEditing();
118 }, 118 },
119 119
120 /** 120 /**
121 * @param {!Event} event 121 * @param {!WebInspector.Event} event
122 */ 122 */
123 _refreshButtonClicked: function(event) 123 _refreshButtonClicked: function(event)
124 { 124 {
125 event.consume(); 125 event.consume();
126 this.refreshExpressions(); 126 this.refreshExpressions();
127 }, 127 },
128 128
129 _rebuildWatchExpressions: function() 129 _rebuildWatchExpressions: function()
130 { 130 {
131 this.bodyElement.removeChildren(); 131 this._bodyElement.removeChildren();
132 this._watchExpressions = []; 132 this._watchExpressions = [];
133 this._emptyElement = this.bodyElement.createChild("div", "info"); 133 this._emptyElement = this._bodyElement.createChild("div", "info");
134 this._emptyElement.textContent = WebInspector.UIString("No Watch Express ions"); 134 this._emptyElement.textContent = WebInspector.UIString("No Watch Express ions");
135 var watchExpressionStrings = this._watchExpressionsSetting.get(); 135 var watchExpressionStrings = this._watchExpressionsSetting.get();
136 for (var i = 0; i < watchExpressionStrings.length; ++i) { 136 for (var i = 0; i < watchExpressionStrings.length; ++i) {
137 var expression = watchExpressionStrings[i]; 137 var expression = watchExpressionStrings[i];
138 if (!expression) 138 if (!expression)
139 continue; 139 continue;
140 140
141 this._createWatchExpression(expression); 141 this._createWatchExpression(expression);
142 } 142 }
143 }, 143 },
144 144
145 /** 145 /**
146 * @param {?string} expression 146 * @param {?string} expression
147 * @return {!WebInspector.WatchExpression} 147 * @return {!WebInspector.WatchExpression}
148 */ 148 */
149 _createWatchExpression: function(expression) 149 _createWatchExpression: function(expression)
150 { 150 {
151 this._emptyElement.classList.add("hidden"); 151 this._emptyElement.classList.add("hidden");
152 var watchExpression = new WebInspector.WatchExpression(expression); 152 var watchExpression = new WebInspector.WatchExpression(expression);
153 watchExpression.addEventListener(WebInspector.WatchExpression.Events.Exp ressionUpdated, this._watchExpressionUpdated.bind(this)); 153 watchExpression.addEventListener(WebInspector.WatchExpression.Events.Exp ressionUpdated, this._watchExpressionUpdated.bind(this));
154 this.bodyElement.appendChild(watchExpression.element()); 154 this._bodyElement.appendChild(watchExpression.element());
155 this._watchExpressions.push(watchExpression); 155 this._watchExpressions.push(watchExpression);
156 return watchExpression; 156 return watchExpression;
157 }, 157 },
158 158
159 /** 159 /**
160 * @param {!WebInspector.Event} event 160 * @param {!WebInspector.Event} event
161 */ 161 */
162 _watchExpressionUpdated: function(event) 162 _watchExpressionUpdated: function(event)
163 { 163 {
164 var watchExpression = /** @type {!WebInspector.WatchExpression} */ (even t.target); 164 var watchExpression = /** @type {!WebInspector.WatchExpression} */ (even t.target);
165 if (!watchExpression.expression()) { 165 if (!watchExpression.expression()) {
166 this._watchExpressions.remove(watchExpression); 166 this._watchExpressions.remove(watchExpression);
167 this.bodyElement.removeChild(watchExpression.element()); 167 this._bodyElement.removeChild(watchExpression.element());
168 this._emptyElement.classList.toggle("hidden", !!this._watchExpressio ns.length); 168 this._emptyElement.classList.toggle("hidden", !!this._watchExpressio ns.length);
169 } 169 }
170 170
171 this._saveExpressions(); 171 this._saveExpressions();
172 }, 172 },
173 173
174 /** 174 /**
175 * @param {!Event} event 175 * @param {!Event} event
176 */ 176 */
177 _contextMenu: function(event) 177 _contextMenu: function(event)
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 contextMenu.appendApplicableItems(this._result); 424 contextMenu.appendApplicableItems(this._result);
425 }, 425 },
426 426
427 _copyValueButtonClicked: function() 427 _copyValueButtonClicked: function()
428 { 428 {
429 InspectorFrontendHost.copyText(this._valueElement.textContent); 429 InspectorFrontendHost.copyText(this._valueElement.textContent);
430 }, 430 },
431 431
432 __proto__: WebInspector.Object.prototype 432 __proto__: WebInspector.Object.prototype
433 } 433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698