OLD | NEW |
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 Loading... |
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 * @implements {UI.ActionDelegate} | 31 * @implements {UI.ActionDelegate} |
32 * @implements {UI.ToolbarItem.ItemsProvider} | 32 * @implements {UI.ToolbarItem.ItemsProvider} |
33 * @implements {UI.ContextMenu.Provider} | 33 * @implements {UI.ContextMenu.Provider} |
34 * @unrestricted | 34 * @unrestricted |
35 */ | 35 */ |
36 Sources.WatchExpressionsSidebarPane = class extends UI.ThrottledWidget { | 36 Sources.WatchExpressionsSidebarPane = class extends UI.ThrottledWidget { |
37 constructor() { | 37 constructor() { |
38 super(); | 38 super(true); |
39 this.registerRequiredCSS('object_ui/objectValue.css'); | 39 this.registerRequiredCSS('object_ui/objectValue.css'); |
| 40 this.registerRequiredCSS('sources/watchExpressionsSidebarPane.css'); |
40 | 41 |
41 /** @type {!Array.<!Sources.WatchExpression>} */ | 42 /** @type {!Array.<!Sources.WatchExpression>} */ |
42 this._watchExpressions = []; | 43 this._watchExpressions = []; |
43 this._watchExpressionsSetting = Common.settings.createLocalSetting('watchExp
ressions', []); | 44 this._watchExpressionsSetting = Common.settings.createLocalSetting('watchExp
ressions', []); |
44 | 45 |
45 this._addButton = new UI.ToolbarButton(Common.UIString('Add expression'), 'l
argeicon-add'); | 46 this._addButton = new UI.ToolbarButton(Common.UIString('Add expression'), 'l
argeicon-add'); |
46 this._addButton.addEventListener(UI.ToolbarButton.Events.Click, this._addBut
tonClicked.bind(this)); | 47 this._addButton.addEventListener(UI.ToolbarButton.Events.Click, this._addBut
tonClicked.bind(this)); |
47 this._refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'larg
eicon-refresh'); | 48 this._refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'larg
eicon-refresh'); |
48 this._refreshButton.addEventListener(UI.ToolbarButton.Events.Click, this.upd
ate, this); | 49 this._refreshButton.addEventListener(UI.ToolbarButton.Events.Click, this.upd
ate, this); |
49 | 50 |
50 this._bodyElement = this.element.createChild('div', 'vbox watch-expressions'
); | 51 this.contentElement.classList.add('watch-expressions'); |
51 this._bodyElement.addEventListener('contextmenu', this._contextMenu.bind(thi
s), false); | 52 this.contentElement.addEventListener('contextmenu', this._contextMenu.bind(t
his), false); |
52 this._expandController = new ObjectUI.ObjectPropertiesSectionExpandControlle
r(); | 53 this._expandController = new ObjectUI.ObjectPropertiesSectionExpandControlle
r(); |
53 | 54 |
54 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this.update, this); | 55 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this.update, this); |
55 UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame, this.update,
this); | 56 UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame, this.update,
this); |
56 this._linkifier = new Components.Linkifier(); | 57 this._linkifier = new Components.Linkifier(); |
57 this.update(); | 58 this.update(); |
58 } | 59 } |
59 | 60 |
60 /** | 61 /** |
61 * @override | 62 * @override |
(...skipping 24 matching lines...) Expand all Loading... |
86 UI.viewManager.showView('sources.watch'); | 87 UI.viewManager.showView('sources.watch'); |
87 this._createWatchExpression(null).startEditing(); | 88 this._createWatchExpression(null).startEditing(); |
88 } | 89 } |
89 | 90 |
90 /** | 91 /** |
91 * @override | 92 * @override |
92 * @return {!Promise.<?>} | 93 * @return {!Promise.<?>} |
93 */ | 94 */ |
94 doUpdate() { | 95 doUpdate() { |
95 this._linkifier.reset(); | 96 this._linkifier.reset(); |
96 this._bodyElement.removeChildren(); | 97 this.contentElement.removeChildren(); |
97 this._watchExpressions = []; | 98 this._watchExpressions = []; |
98 this._emptyElement = this._bodyElement.createChild('div', 'gray-info-message
'); | 99 this._emptyElement = this.contentElement.createChild('div', 'gray-info-messa
ge'); |
99 this._emptyElement.textContent = Common.UIString('No Watch Expressions'); | 100 this._emptyElement.textContent = Common.UIString('No Watch Expressions'); |
100 var watchExpressionStrings = this._watchExpressionsSetting.get(); | 101 var watchExpressionStrings = this._watchExpressionsSetting.get(); |
101 for (var i = 0; i < watchExpressionStrings.length; ++i) { | 102 for (var i = 0; i < watchExpressionStrings.length; ++i) { |
102 var expression = watchExpressionStrings[i]; | 103 var expression = watchExpressionStrings[i]; |
103 if (!expression) | 104 if (!expression) |
104 continue; | 105 continue; |
105 | 106 |
106 this._createWatchExpression(expression); | 107 this._createWatchExpression(expression); |
107 } | 108 } |
108 return Promise.resolve(); | 109 return Promise.resolve(); |
109 } | 110 } |
110 | 111 |
111 /** | 112 /** |
112 * @param {?string} expression | 113 * @param {?string} expression |
113 * @return {!Sources.WatchExpression} | 114 * @return {!Sources.WatchExpression} |
114 */ | 115 */ |
115 _createWatchExpression(expression) { | 116 _createWatchExpression(expression) { |
116 this._emptyElement.classList.add('hidden'); | 117 this._emptyElement.classList.add('hidden'); |
117 var watchExpression = new Sources.WatchExpression(expression, this._expandCo
ntroller, this._linkifier); | 118 var watchExpression = new Sources.WatchExpression(expression, this._expandCo
ntroller, this._linkifier); |
118 watchExpression.addEventListener( | 119 watchExpression.addEventListener( |
119 Sources.WatchExpression.Events.ExpressionUpdated, this._watchExpressionU
pdated, this); | 120 Sources.WatchExpression.Events.ExpressionUpdated, this._watchExpressionU
pdated, this); |
120 this._bodyElement.appendChild(watchExpression.element()); | 121 this.contentElement.appendChild(watchExpression.element()); |
121 this._watchExpressions.push(watchExpression); | 122 this._watchExpressions.push(watchExpression); |
122 return watchExpression; | 123 return watchExpression; |
123 } | 124 } |
124 | 125 |
125 /** | 126 /** |
126 * @param {!Common.Event} event | 127 * @param {!Common.Event} event |
127 */ | 128 */ |
128 _watchExpressionUpdated(event) { | 129 _watchExpressionUpdated(event) { |
129 var watchExpression = /** @type {!Sources.WatchExpression} */ (event.data); | 130 var watchExpression = /** @type {!Sources.WatchExpression} */ (event.data); |
130 if (!watchExpression.expression()) { | 131 if (!watchExpression.expression()) { |
131 this._watchExpressions.remove(watchExpression); | 132 this._watchExpressions.remove(watchExpression); |
132 this._bodyElement.removeChild(watchExpression.element()); | 133 this.contentElement.removeChild(watchExpression.element()); |
133 this._emptyElement.classList.toggle('hidden', !!this._watchExpressions.len
gth); | 134 this._emptyElement.classList.toggle('hidden', !!this._watchExpressions.len
gth); |
134 } | 135 } |
135 | 136 |
136 this._saveExpressions(); | 137 this._saveExpressions(); |
137 } | 138 } |
138 | 139 |
139 /** | 140 /** |
140 * @param {!Event} event | 141 * @param {!Event} event |
141 */ | 142 */ |
142 _contextMenu(event) { | 143 _contextMenu(event) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 InspectorFrontendHost.copyText(this._valueElement.textContent); | 422 InspectorFrontendHost.copyText(this._valueElement.textContent); |
422 } | 423 } |
423 }; | 424 }; |
424 | 425 |
425 Sources.WatchExpression._watchObjectGroupId = 'watch-group'; | 426 Sources.WatchExpression._watchObjectGroupId = 'watch-group'; |
426 | 427 |
427 /** @enum {symbol} */ | 428 /** @enum {symbol} */ |
428 Sources.WatchExpression.Events = { | 429 Sources.WatchExpression.Events = { |
429 ExpressionUpdated: Symbol('ExpressionUpdated') | 430 ExpressionUpdated: Symbol('ExpressionUpdated') |
430 }; | 431 }; |
OLD | NEW |