| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 QuickOpen.CommandMenu = class { | 7 QuickOpen.CommandMenu = class { |
| 8 constructor() { | 8 constructor() { |
| 9 this._commands = []; | 9 this._commands = []; |
| 10 this._loadCommands(); | 10 this._loadCommands(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 */ | 106 */ |
| 107 commands() { | 107 commands() { |
| 108 return this._commands; | 108 return this._commands; |
| 109 } | 109 } |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 QuickOpen.CommandMenuProvider = class extends QuickOpen.FilteredListWidget.Provi
der { | 112 QuickOpen.CommandMenuProvider = class extends QuickOpen.FilteredListWidget.Provi
der { |
| 113 constructor() { | 113 constructor() { |
| 114 super(); | 114 super(); |
| 115 this._commands = []; | 115 this._commands = []; |
| 116 this._appendAvailableCommands(); | |
| 117 } | 116 } |
| 118 | 117 |
| 119 _appendAvailableCommands() { | 118 /** |
| 119 * @override |
| 120 */ |
| 121 attach() { |
| 120 var allCommands = QuickOpen.commandMenu.commands(); | 122 var allCommands = QuickOpen.commandMenu.commands(); |
| 121 | 123 |
| 122 // Populate whitelisted actions. | 124 // Populate whitelisted actions. |
| 123 var actions = UI.actionRegistry.availableActions(); | 125 var actions = UI.actionRegistry.availableActions(); |
| 124 for (var action of actions) { | 126 for (var action of actions) { |
| 125 if (action.category()) | 127 if (action.category()) |
| 126 this._commands.push(QuickOpen.CommandMenu.createActionCommand(action)); | 128 this._commands.push(QuickOpen.CommandMenu.createActionCommand(action)); |
| 127 } | 129 } |
| 128 | 130 |
| 129 for (var command of allCommands) { | 131 for (var command of allCommands) { |
| 130 if (command.available()) | 132 if (command.available()) |
| 131 this._commands.push(command); | 133 this._commands.push(command); |
| 132 } | 134 } |
| 133 | 135 |
| 134 this._commands = this._commands.sort(commandComparator); | 136 this._commands = this._commands.sort(commandComparator); |
| 135 | 137 |
| 136 /** | 138 /** |
| 137 * @param {!QuickOpen.CommandMenu.Command} left | 139 * @param {!QuickOpen.CommandMenu.Command} left |
| 138 * @param {!QuickOpen.CommandMenu.Command} right | 140 * @param {!QuickOpen.CommandMenu.Command} right |
| 139 * @return {number} | 141 * @return {number} |
| 140 */ | 142 */ |
| 141 function commandComparator(left, right) { | 143 function commandComparator(left, right) { |
| 142 var cats = left.category().compareTo(right.category()); | 144 var cats = left.category().compareTo(right.category()); |
| 143 return cats ? cats : left.title().compareTo(right.title()); | 145 return cats ? cats : left.title().compareTo(right.title()); |
| 144 } | 146 } |
| 145 } | 147 } |
| 146 | 148 |
| 147 /** | 149 /** |
| 148 * @override | 150 * @override |
| 151 */ |
| 152 detach() { |
| 153 this._commands = []; |
| 154 } |
| 155 |
| 156 /** |
| 157 * @override |
| 149 * @return {number} | 158 * @return {number} |
| 150 */ | 159 */ |
| 151 itemCount() { | 160 itemCount() { |
| 152 return this._commands.length; | 161 return this._commands.length; |
| 153 } | 162 } |
| 154 | 163 |
| 155 /** | 164 /** |
| 156 * @override | 165 * @override |
| 157 * @param {number} itemIndex | 166 * @param {number} itemIndex |
| 158 * @return {string} | 167 * @return {string} |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 * @override | 314 * @override |
| 306 * @param {!UI.Context} context | 315 * @param {!UI.Context} context |
| 307 * @param {string} actionId | 316 * @param {string} actionId |
| 308 * @return {boolean} | 317 * @return {boolean} |
| 309 */ | 318 */ |
| 310 handleAction(context, actionId) { | 319 handleAction(context, actionId) { |
| 311 QuickOpen.QuickOpen.show('>'); | 320 QuickOpen.QuickOpen.show('>'); |
| 312 return true; | 321 return true; |
| 313 } | 322 } |
| 314 }; | 323 }; |
| OLD | NEW |