Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Nokia Inc. All rights reserved. | 2 * Copyright (C) 2008 Nokia Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 var filteredItems = item => `${item[0]} ${item[1]}`; | 157 var filteredItems = item => `${item[0]} ${item[1]}`; |
| 158 for (var item of this.filter(items, filteredItems)) { | 158 for (var item of this.filter(items, filteredItems)) { |
| 159 var key = item[0]; | 159 var key = item[0]; |
| 160 var value = item[1]; | 160 var value = item[1]; |
| 161 var node = new DataGrid.DataGridNode({key: key, value: value}, false); | 161 var node = new DataGrid.DataGridNode({key: key, value: value}, false); |
| 162 node.selectable = true; | 162 node.selectable = true; |
| 163 rootNode.appendChild(node); | 163 rootNode.appendChild(node); |
| 164 if (!selectedNode || key === selectedKey) | 164 if (!selectedNode || key === selectedKey) |
| 165 selectedNode = node; | 165 selectedNode = node; |
| 166 } | 166 } |
| 167 if (selectedNode) | 167 if (selectedNode) { |
| 168 selectedNode.selected = true; | 168 selectedNode.select(); |
| 169 selectedNode.reveal(); | |
| 170 } | |
| 169 this._dataGrid.addCreationNode(false); | 171 this._dataGrid.addCreationNode(false); |
| 170 this.setCanDeleteSelected(!!selectedNode); | 172 this.setCanDeleteSelected(!!selectedNode); |
| 171 } | 173 } |
| 172 | 174 |
| 173 /** | 175 /** |
| 174 * @override | 176 * @override |
| 175 */ | 177 */ |
| 176 deleteSelectedItem() { | 178 deleteSelectedItem() { |
| 177 if (!this._dataGrid || !this._dataGrid.selectedNode) | 179 if (!this._dataGrid || !this._dataGrid.selectedNode) |
| 178 return; | 180 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 } | 221 } |
| 220 } | 222 } |
| 221 | 223 |
| 222 _deleteCallback(node) { | 224 _deleteCallback(node) { |
| 223 if (!node || node.isCreationNode) | 225 if (!node || node.isCreationNode) |
| 224 return; | 226 return; |
| 225 | 227 |
| 226 if (this._domStorage) | 228 if (this._domStorage) |
| 227 this._domStorage.removeItem(node.data.key); | 229 this._domStorage.removeItem(node.data.key); |
| 228 } | 230 } |
| 231 | |
| 232 /** | |
| 233 * @override | |
| 234 */ | |
| 235 focusGrid() { | |
| 236 if (!this._dataGrid) | |
| 237 return; | |
| 238 var root = this._dataGrid.rootNode(); | |
| 239 if (!root || root.children.length === 0) | |
|
dgozman
2017/02/01 00:28:35
There is always a rootNode.
eostroukhov
2017/02/03 01:17:40
Done.
| |
| 240 return; | |
| 241 root.children[0].select(); | |
| 242 this._dataGrid.element.focus(); | |
| 243 } | |
| 229 }; | 244 }; |
| OLD | NEW |