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

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: only using latin1 in css 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 event.consume(true);
115 event.consume(true);
116 this.expand(); 115 this.expand();
117 this._createWatchExpression(null).startEditing(); 116 this._createWatchExpression(null).startEditing();
118 }, 117 },
119 118
120 /** 119 /**
121 * @param {!Event} event 120 * @param {!WebInspector.Event} event
122 */ 121 */
123 _refreshButtonClicked: function(event) 122 _refreshButtonClicked: function(event)
124 { 123 {
125 event.consume(); 124 event.consume();
126 this.refreshExpressions(); 125 this.refreshExpressions();
127 }, 126 },
128 127
129 _rebuildWatchExpressions: function() 128 _rebuildWatchExpressions: function()
130 { 129 {
131 this.bodyElement.removeChildren(); 130 this._bodyElement.removeChildren();
132 this._watchExpressions = []; 131 this._watchExpressions = [];
133 this._emptyElement = this.bodyElement.createChild("div", "info"); 132 this._emptyElement = this._bodyElement.createChild("div", "info");
134 this._emptyElement.textContent = WebInspector.UIString("No Watch Express ions"); 133 this._emptyElement.textContent = WebInspector.UIString("No Watch Express ions");
135 var watchExpressionStrings = this._watchExpressionsSetting.get(); 134 var watchExpressionStrings = this._watchExpressionsSetting.get();
136 for (var i = 0; i < watchExpressionStrings.length; ++i) { 135 for (var i = 0; i < watchExpressionStrings.length; ++i) {
137 var expression = watchExpressionStrings[i]; 136 var expression = watchExpressionStrings[i];
138 if (!expression) 137 if (!expression)
139 continue; 138 continue;
140 139
141 this._createWatchExpression(expression); 140 this._createWatchExpression(expression);
142 } 141 }
143 }, 142 },
144 143
145 /** 144 /**
146 * @param {?string} expression 145 * @param {?string} expression
147 * @return {!WebInspector.WatchExpression} 146 * @return {!WebInspector.WatchExpression}
148 */ 147 */
149 _createWatchExpression: function(expression) 148 _createWatchExpression: function(expression)
150 { 149 {
151 this._emptyElement.classList.add("hidden"); 150 this._emptyElement.classList.add("hidden");
152 var watchExpression = new WebInspector.WatchExpression(expression); 151 var watchExpression = new WebInspector.WatchExpression(expression);
153 watchExpression.addEventListener(WebInspector.WatchExpression.Events.Exp ressionUpdated, this._watchExpressionUpdated.bind(this)); 152 watchExpression.addEventListener(WebInspector.WatchExpression.Events.Exp ressionUpdated, this._watchExpressionUpdated.bind(this));
154 this.bodyElement.appendChild(watchExpression.element()); 153 this._bodyElement.appendChild(watchExpression.element());
155 this._watchExpressions.push(watchExpression); 154 this._watchExpressions.push(watchExpression);
156 return watchExpression; 155 return watchExpression;
157 }, 156 },
158 157
159 /** 158 /**
160 * @param {!WebInspector.Event} event 159 * @param {!WebInspector.Event} event
161 */ 160 */
162 _watchExpressionUpdated: function(event) 161 _watchExpressionUpdated: function(event)
163 { 162 {
164 var watchExpression = /** @type {!WebInspector.WatchExpression} */ (even t.target); 163 var watchExpression = /** @type {!WebInspector.WatchExpression} */ (even t.target);
165 if (!watchExpression.expression()) { 164 if (!watchExpression.expression()) {
166 this._watchExpressions.remove(watchExpression); 165 this._watchExpressions.remove(watchExpression);
167 this.bodyElement.removeChild(watchExpression.element()); 166 this._bodyElement.removeChild(watchExpression.element());
168 this._emptyElement.classList.toggle("hidden", !!this._watchExpressio ns.length); 167 this._emptyElement.classList.toggle("hidden", !!this._watchExpressio ns.length);
169 } 168 }
170 169
171 this._saveExpressions(); 170 this._saveExpressions();
172 }, 171 },
173 172
174 /** 173 /**
175 * @param {!Event} event 174 * @param {!Event} event
176 */ 175 */
177 _contextMenu: function(event) 176 _contextMenu: function(event)
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 contextMenu.appendApplicableItems(this._result); 423 contextMenu.appendApplicableItems(this._result);
425 }, 424 },
426 425
427 _copyValueButtonClicked: function() 426 _copyValueButtonClicked: function()
428 { 427 {
429 InspectorFrontendHost.copyText(this._valueElement.textContent); 428 InspectorFrontendHost.copyText(this._valueElement.textContent);
430 }, 429 },
431 430
432 __proto__: WebInspector.Object.prototype 431 __proto__: WebInspector.Object.prototype
433 } 432 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698