OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 10 matching lines...) Expand all Loading... |
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 /** | 29 /** |
30 * @implements {UI.Searchable} | 30 * @implements {UI.Searchable} |
31 * @implements {SDK.TargetManager.Observer} | |
32 * @implements {Console.ConsoleViewportProvider} | 31 * @implements {Console.ConsoleViewportProvider} |
33 * @unrestricted | 32 * @unrestricted |
34 */ | 33 */ |
35 Console.ConsoleView = class extends UI.VBox { | 34 Console.ConsoleView = class extends UI.VBox { |
36 constructor() { | 35 constructor() { |
37 super(); | 36 super(); |
38 this.setMinimumSize(0, 35); | 37 this.setMinimumSize(0, 35); |
39 this.registerRequiredCSS('console/consoleView.css'); | 38 this.registerRequiredCSS('console/consoleView.css'); |
40 | 39 |
41 this._searchableView = new UI.SearchableView(this); | 40 this._searchableView = new UI.SearchableView(this); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto
ryAutocompleteChanged, this); | 154 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto
ryAutocompleteChanged, this); |
156 | 155 |
157 var historyData = this._consoleHistorySetting.get(); | 156 var historyData = this._consoleHistorySetting.get(); |
158 this._prompt.history().setHistoryData(historyData); | 157 this._prompt.history().setHistoryData(historyData); |
159 this._consoleHistoryAutocompleteChanged(); | 158 this._consoleHistoryAutocompleteChanged(); |
160 | 159 |
161 this._updateFilterStatus(); | 160 this._updateFilterStatus(); |
162 this._timestampsSetting.addChangeListener(this._consoleTimestampsSettingChan
ged, this); | 161 this._timestampsSetting.addChangeListener(this._consoleTimestampsSettingChan
ged, this); |
163 | 162 |
164 this._registerWithMessageSink(); | 163 this._registerWithMessageSink(); |
165 SDK.targetManager.observeTargets(this); | |
166 | 164 |
167 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont
extChanged, this); | 165 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont
extChanged, this); |
168 | 166 |
169 this._messagesElement.addEventListener('mousedown', this._updateStickToBotto
mOnMouseDown.bind(this), false); | 167 this._messagesElement.addEventListener('mousedown', this._updateStickToBotto
mOnMouseDown.bind(this), false); |
170 this._messagesElement.addEventListener('mouseup', this._updateStickToBottomO
nMouseUp.bind(this), false); | 168 this._messagesElement.addEventListener('mouseup', this._updateStickToBottomO
nMouseUp.bind(this), false); |
171 this._messagesElement.addEventListener('mouseleave', this._updateStickToBott
omOnMouseUp.bind(this), false); | 169 this._messagesElement.addEventListener('mouseleave', this._updateStickToBott
omOnMouseUp.bind(this), false); |
172 this._messagesElement.addEventListener('wheel', this._updateStickToBottomOnW
heel.bind(this), false); | 170 this._messagesElement.addEventListener('wheel', this._updateStickToBottomOnW
heel.bind(this), false); |
| 171 |
| 172 ConsoleModel.consoleModel.addEventListener( |
| 173 ConsoleModel.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, t
his); |
| 174 ConsoleModel.consoleModel.addEventListener( |
| 175 ConsoleModel.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdd
ed, this); |
| 176 ConsoleModel.consoleModel.addEventListener( |
| 177 ConsoleModel.ConsoleModel.Events.MessageUpdated, this._onConsoleMessageU
pdated, this); |
| 178 ConsoleModel.consoleModel.addEventListener( |
| 179 ConsoleModel.ConsoleModel.Events.CommandEvaluated, this._commandEvaluate
d, this); |
| 180 ConsoleModel.consoleModel.messages().forEach(this._addConsoleMessage, this); |
| 181 if (this._consoleMessages.length) |
| 182 this._viewport.invalidate(); |
173 } | 183 } |
174 | 184 |
175 /** | 185 /** |
176 * @return {!Console.ConsoleView} | 186 * @return {!Console.ConsoleView} |
177 */ | 187 */ |
178 static instance() { | 188 static instance() { |
179 if (!Console.ConsoleView._instance) | 189 if (!Console.ConsoleView._instance) |
180 Console.ConsoleView._instance = new Console.ConsoleView(); | 190 Console.ConsoleView._instance = new Console.ConsoleView(); |
181 return Console.ConsoleView._instance; | 191 return Console.ConsoleView._instance; |
182 } | 192 } |
(...skipping 12 matching lines...) Expand all Loading... |
195 _clearHistory() { | 205 _clearHistory() { |
196 this._consoleHistorySetting.set([]); | 206 this._consoleHistorySetting.set([]); |
197 this._prompt.history().setHistoryData([]); | 207 this._prompt.history().setHistoryData([]); |
198 } | 208 } |
199 | 209 |
200 _consoleHistoryAutocompleteChanged() { | 210 _consoleHistoryAutocompleteChanged() { |
201 this._prompt.setAddCompletionsFromHistory(this._consoleHistoryAutocompleteSe
tting.get()); | 211 this._prompt.setAddCompletionsFromHistory(this._consoleHistoryAutocompleteSe
tting.get()); |
202 } | 212 } |
203 | 213 |
204 /** | 214 /** |
205 * @param {!SDK.Target} target | |
206 */ | |
207 _initConsoleMessages(target) { | |
208 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); | |
209 if (resourceTreeModel && !resourceTreeModel.cachedResourcesLoaded()) { | |
210 resourceTreeModel.addEventListener( | |
211 SDK.ResourceTreeModel.Events.CachedResourcesLoaded, this._onResourceTr
eeModelLoaded, this); | |
212 return; | |
213 } | |
214 this._fetchMultitargetMessages(); | |
215 } | |
216 | |
217 /** | |
218 * @param {!Common.Event} event | |
219 */ | |
220 _onResourceTreeModelLoaded(event) { | |
221 var resourceTreeModel = /** @type {!SDK.ResourceTreeModel} */ (event.data); | |
222 resourceTreeModel.removeEventListener( | |
223 SDK.ResourceTreeModel.Events.CachedResourcesLoaded, this._onResourceTree
ModelLoaded, this); | |
224 this._fetchMultitargetMessages(); | |
225 } | |
226 | |
227 _fetchMultitargetMessages() { | |
228 ConsoleModel.consoleModel.addEventListener( | |
229 ConsoleModel.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, t
his); | |
230 ConsoleModel.consoleModel.addEventListener( | |
231 ConsoleModel.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdd
ed, this); | |
232 ConsoleModel.consoleModel.addEventListener( | |
233 ConsoleModel.ConsoleModel.Events.MessageUpdated, this._onConsoleMessageU
pdated, this); | |
234 ConsoleModel.consoleModel.addEventListener( | |
235 ConsoleModel.ConsoleModel.Events.CommandEvaluated, this._commandEvaluate
d, this); | |
236 ConsoleModel.consoleModel.messages().forEach(this._addConsoleMessage, this); | |
237 this._viewport.invalidate(); | |
238 } | |
239 | |
240 /** | |
241 * @override | 215 * @override |
242 * @return {number} | 216 * @return {number} |
243 */ | 217 */ |
244 itemCount() { | 218 itemCount() { |
245 return this._visibleViewMessages.length; | 219 return this._visibleViewMessages.length; |
246 } | 220 } |
247 | 221 |
248 /** | 222 /** |
249 * @override | 223 * @override |
250 * @param {number} index | 224 * @param {number} index |
(...skipping 13 matching lines...) Expand all Loading... |
264 } | 238 } |
265 | 239 |
266 /** | 240 /** |
267 * @override | 241 * @override |
268 * @return {number} | 242 * @return {number} |
269 */ | 243 */ |
270 minimumRowHeight() { | 244 minimumRowHeight() { |
271 return 16; | 245 return 16; |
272 } | 246 } |
273 | 247 |
274 /** | |
275 * @override | |
276 * @param {!SDK.Target} target | |
277 */ | |
278 targetAdded(target) { | |
279 if (target === SDK.targetManager.mainTarget()) | |
280 this._initConsoleMessages(target); | |
281 this._viewport.invalidate(); | |
282 } | |
283 | |
284 /** | |
285 * @override | |
286 * @param {!SDK.Target} target | |
287 */ | |
288 targetRemoved(target) { | |
289 } | |
290 | |
291 _registerWithMessageSink() { | 248 _registerWithMessageSink() { |
292 Common.console.messages().forEach(this._addSinkMessage, this); | 249 Common.console.messages().forEach(this._addSinkMessage, this); |
293 Common.console.addEventListener(Common.Console.Events.MessageAdded, messageA
dded, this); | 250 Common.console.addEventListener(Common.Console.Events.MessageAdded, messageA
dded, this); |
294 | 251 |
295 /** | 252 /** |
296 * @param {!Common.Event} event | 253 * @param {!Common.Event} event |
297 * @this {Console.ConsoleView} | 254 * @this {Console.ConsoleView} |
298 */ | 255 */ |
299 function messageAdded(event) { | 256 function messageAdded(event) { |
300 this._addSinkMessage(/** @type {!Common.Console.Message} */ (event.data)); | 257 this._addSinkMessage(/** @type {!Common.Console.Message} */ (event.data)); |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 return true; | 1278 return true; |
1322 } | 1279 } |
1323 return false; | 1280 return false; |
1324 } | 1281 } |
1325 }; | 1282 }; |
1326 | 1283 |
1327 /** | 1284 /** |
1328 * @typedef {{messageIndex: number, matchIndex: number}} | 1285 * @typedef {{messageIndex: number, matchIndex: number}} |
1329 */ | 1286 */ |
1330 Console.ConsoleView.RegexMatchRange; | 1287 Console.ConsoleView.RegexMatchRange; |
OLD | NEW |