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

Side by Side Diff: Source/devtools/front_end/console/ConsoleView.js

Issue 1273363002: Devtools UI: Show multiple shortcuts, show more shortcuts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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) 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 /** @type {!Array.<!WebInspector.ConsoleViewMessage>} */ 51 /** @type {!Array.<!WebInspector.ConsoleViewMessage>} */
52 this._visibleViewMessages = []; 52 this._visibleViewMessages = [];
53 this._urlToMessageCount = {}; 53 this._urlToMessageCount = {};
54 this._hiddenByFilterCount = 0; 54 this._hiddenByFilterCount = 0;
55 55
56 /** 56 /**
57 * @type {!Array.<!WebInspector.ConsoleView.RegexMatchRange>} 57 * @type {!Array.<!WebInspector.ConsoleView.RegexMatchRange>}
58 */ 58 */
59 this._regexMatchRanges = []; 59 this._regexMatchRanges = [];
60 60
61 this._clearConsoleButton = new WebInspector.ToolbarButton(WebInspector.UIStr ing("Clear console log"), "clear-toolbar-item"); 61 this._clearConsoleButton = WebInspector.ToolbarButton.createActionButton("co nsole.clear");
62 this._clearConsoleButton.addEventListener("click", this._requestClearMessage s, this);
63 62
64 this._executionContextComboBox = new WebInspector.ToolbarComboBox(null, "con sole-context"); 63 this._executionContextComboBox = new WebInspector.ToolbarComboBox(null, "con sole-context");
65 this._executionContextComboBox.setMaxWidth(200); 64 this._executionContextComboBox.setMaxWidth(200);
66 this._executionContextModel = new WebInspector.ExecutionContextModel(this._e xecutionContextComboBox.selectElement()); 65 this._executionContextModel = new WebInspector.ExecutionContextModel(this._e xecutionContextComboBox.selectElement());
67 66
68 this._filter = new WebInspector.ConsoleViewFilter(this); 67 this._filter = new WebInspector.ConsoleViewFilter(this);
69 this._filter.addEventListener(WebInspector.ConsoleViewFilter.Events.FilterCh anged, this._updateMessageList.bind(this)); 68 this._filter.addEventListener(WebInspector.ConsoleViewFilter.Events.FilterCh anged, this._updateMessageList.bind(this));
70 69
71 this._filterBar = new WebInspector.FilterBar("consoleView"); 70 this._filterBar = new WebInspector.FilterBar("consoleView");
72 71
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 571
573 for (var url in this._filter.messageURLFilters) { 572 for (var url in this._filter.messageURLFilters) {
574 filterSubMenu.appendCheckboxItem(String.sprintf("%s (%d)", new WebIn spector.ParsedURL(url).displayName, this._urlToMessageCount[url]), this._filter. removeMessageURLFilter.bind(this._filter, url), true); 573 filterSubMenu.appendCheckboxItem(String.sprintf("%s (%d)", new WebIn spector.ParsedURL(url).displayName, this._urlToMessageCount[url]), this._filter. removeMessageURLFilter.bind(this._filter, url), true);
575 hasFilters = true; 574 hasFilters = true;
576 } 575 }
577 576
578 filterSubMenu.setEnabled(hasFilters || (consoleMessage && consoleMessage .url)); 577 filterSubMenu.setEnabled(hasFilters || (consoleMessage && consoleMessage .url));
579 unhideAll.setEnabled(hasFilters); 578 unhideAll.setEnabled(hasFilters);
580 579
581 contextMenu.appendSeparator(); 580 contextMenu.appendSeparator();
582 contextMenu.appendItem(WebInspector.UIString.capitalize("Clear ^console" ), this._requestClearMessages.bind(this)); 581 contextMenu.appendAction("console.clear");
583 contextMenu.appendItem(WebInspector.UIString("Save as..."), this._saveCo nsole.bind(this)); 582 contextMenu.appendItem(WebInspector.UIString("Save as..."), this._saveCo nsole.bind(this));
584 583
585 var request = consoleMessage ? consoleMessage.request : null; 584 var request = consoleMessage ? consoleMessage.request : null;
586 if (request && request.resourceType() === WebInspector.resourceTypes.XHR ) { 585 if (request && request.resourceType() === WebInspector.resourceTypes.XHR ) {
587 contextMenu.appendSeparator(); 586 contextMenu.appendSeparator();
588 contextMenu.appendItem(WebInspector.UIString("Replay XHR"), request. replayXHR.bind(request)); 587 contextMenu.appendItem(WebInspector.UIString("Replay XHR"), request. replayXHR.bind(request));
589 } 588 }
590 589
591 contextMenu.show(); 590 contextMenu.show();
592 }, 591 },
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 }, 700 },
702 701
703 _registerShortcuts: function() 702 _registerShortcuts: function()
704 { 703 {
705 this._shortcuts = {}; 704 this._shortcuts = {};
706 705
707 var shortcut = WebInspector.KeyboardShortcut; 706 var shortcut = WebInspector.KeyboardShortcut;
708 var section = WebInspector.shortcutsScreen.section(WebInspector.UIString ("Console")); 707 var section = WebInspector.shortcutsScreen.section(WebInspector.UIString ("Console"));
709 708
710 var shortcutL = shortcut.makeDescriptor("l", WebInspector.KeyboardShortc ut.Modifiers.Ctrl); 709 var shortcutL = shortcut.makeDescriptor("l", WebInspector.KeyboardShortc ut.Modifiers.Ctrl);
711 this._shortcuts[shortcutL.key] = this._requestClearMessages.bind(this);
712 var keys = [shortcutL]; 710 var keys = [shortcutL];
713 if (WebInspector.isMac()) { 711 if (WebInspector.isMac()) {
714 var shortcutK = shortcut.makeDescriptor("k", WebInspector.KeyboardSh ortcut.Modifiers.Meta); 712 var shortcutK = shortcut.makeDescriptor("k", WebInspector.KeyboardSh ortcut.Modifiers.Meta);
715 this._shortcuts[shortcutK.key] = this._requestClearMessages.bind(thi s);
716 keys.unshift(shortcutK); 713 keys.unshift(shortcutK);
717 } 714 }
718 section.addAlternateKeys(keys, WebInspector.UIString("Clear console")); 715 section.addAlternateKeys(keys, WebInspector.UIString("Clear console"));
719 716
720 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Tab), WebInspector. UIString("Autocomplete common prefix")); 717 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Tab), WebInspector. UIString("Autocomplete common prefix"));
721 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Right), WebInspecto r.UIString("Accept suggestion")); 718 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Right), WebInspecto r.UIString("Accept suggestion"));
722 719
723 var shortcutU = shortcut.makeDescriptor("u", WebInspector.KeyboardShortc ut.Modifiers.Ctrl); 720 var shortcutU = shortcut.makeDescriptor("u", WebInspector.KeyboardShortc ut.Modifiers.Ctrl);
724 this._shortcuts[shortcutU.key] = this._clearPromptBackwards.bind(this); 721 this._shortcuts[shortcutU.key] = this._clearPromptBackwards.bind(this);
725 section.addAlternateKeys([shortcutU], WebInspector.UIString("Clear conso le prompt")); 722 section.addAlternateKeys([shortcutU], WebInspector.UIString("Clear conso le prompt"));
(...skipping 13 matching lines...) Expand all
739 } 736 }
740 737
741 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Enter), WebInspecto r.UIString("Execute command")); 738 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Enter), WebInspecto r.UIString("Execute command"));
742 }, 739 },
743 740
744 _clearPromptBackwards: function() 741 _clearPromptBackwards: function()
745 { 742 {
746 this._prompt.setText(""); 743 this._prompt.setText("");
747 }, 744 },
748 745
749 _requestClearMessages: function()
750 {
751 var targets = WebInspector.targetManager.targets();
752 for (var i = 0; i < targets.length; ++i)
753 targets[i].consoleModel.requestClearMessages();
754 },
755
756 _promptKeyDown: function(event) 746 _promptKeyDown: function(event)
757 { 747 {
758 if (isEnterKey(event)) { 748 if (isEnterKey(event)) {
759 this._enterKeyPressed(event); 749 this._enterKeyPressed(event);
760 return; 750 return;
761 } 751 }
762 752
763 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); 753 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
764 var handler = this._shortcuts[shortcut]; 754 var handler = this._shortcuts[shortcut];
765 if (handler) { 755 if (handler) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 parentGroup: function() 1272 parentGroup: function()
1283 { 1273 {
1284 return this._parentGroup || this; 1274 return this._parentGroup || this;
1285 }, 1275 },
1286 } 1276 }
1287 1277
1288 /** 1278 /**
1289 * @constructor 1279 * @constructor
1290 * @implements {WebInspector.ActionDelegate} 1280 * @implements {WebInspector.ActionDelegate}
1291 */ 1281 */
1292 WebInspector.ConsoleView.ShowConsoleActionDelegate = function() 1282 WebInspector.ConsoleView.ActionDelegate = function()
1293 { 1283 {
1294 } 1284 }
1295 1285
1296 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = { 1286 WebInspector.ConsoleView.ActionDelegate.prototype = {
1297 /** 1287 /**
1298 * @override 1288 * @override
1299 * @param {!WebInspector.Context} context 1289 * @param {!WebInspector.Context} context
1300 * @param {string} actionId 1290 * @param {string} actionId
1301 */ 1291 */
1302 handleAction: function(context, actionId) 1292 handleAction: function(context, actionId)
1303 { 1293 {
1304 WebInspector.console.show(); 1294 if (actionId === "console.show")
1295 WebInspector.console.show();
1296 else if (actionId === "console.clear")
1297 WebInspector.ConsoleModel.clearConsole();
1305 } 1298 }
1306 } 1299 }
1307 1300
1308 /** 1301 /**
1309 * @typedef {{messageIndex: number, matchIndex: number}} 1302 * @typedef {{messageIndex: number, matchIndex: number}}
1310 */ 1303 */
1311 WebInspector.ConsoleView.RegexMatchRange; 1304 WebInspector.ConsoleView.RegexMatchRange;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698