OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 this._dataGrid.element.classList.remove('hidden'); | 172 this._dataGrid.element.classList.remove('hidden'); |
173 this._emptyWidget.detach(); | 173 this._emptyWidget.detach(); |
174 this._deleteButton.setVisible(true); | 174 this._deleteButton.setVisible(true); |
175 | 175 |
176 // FIXME: For Chrome, put creationTime and updateTime somewhere. | 176 // FIXME: For Chrome, put creationTime and updateTime somewhere. |
177 // NOTE: localizedString has not yet been added. | 177 // NOTE: localizedString has not yet been added. |
178 // Common.UIString("(%s) Created: %s Updated: %s", this._size, this._creatio
nTime, this._updateTime); | 178 // Common.UIString("(%s) Created: %s Updated: %s", this._size, this._creatio
nTime, this._updateTime); |
179 } | 179 } |
180 | 180 |
181 _createDataGrid() { | 181 _createDataGrid() { |
182 var columns = /** @type {!Array<!UI.DataGrid.ColumnDescriptor>} */ ([ | 182 var columns = /** @type {!Array<!DataGrid.DataGrid.ColumnDescriptor>} */ ([ |
183 {id: 'resource', title: Common.UIString('Resource'), sort: UI.DataGrid.Ord
er.Ascending, sortable: true}, | 183 {id: 'resource', title: Common.UIString('Resource'), sort: DataGrid.DataGr
id.Order.Ascending, sortable: true}, |
184 {id: 'type', title: Common.UIString('Type'), sortable: true}, | 184 {id: 'type', title: Common.UIString('Type'), sortable: true}, |
185 {id: 'size', title: Common.UIString('Size'), align: UI.DataGrid.Align.Righ
t, sortable: true} | 185 {id: 'size', title: Common.UIString('Size'), align: DataGrid.DataGrid.Alig
n.Right, sortable: true} |
186 ]); | 186 ]); |
187 this._dataGrid = new UI.DataGrid(columns); | 187 this._dataGrid = new DataGrid.DataGrid(columns); |
188 this._dataGrid.asWidget().show(this.element); | 188 this._dataGrid.asWidget().show(this.element); |
189 this._dataGrid.addEventListener(UI.DataGrid.Events.SortingChanged, this._pop
ulateDataGrid, this); | 189 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, thi
s._populateDataGrid, this); |
190 } | 190 } |
191 | 191 |
192 _populateDataGrid() { | 192 _populateDataGrid() { |
193 var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.selected
Node.resource : null; | 193 var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.selected
Node.resource : null; |
194 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; | 194 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; |
195 | 195 |
196 function numberCompare(field, resource1, resource2) { | 196 function numberCompare(field, resource1, resource2) { |
197 return sortDirection * (resource1[field] - resource2[field]); | 197 return sortDirection * (resource1[field] - resource2[field]); |
198 } | 198 } |
199 function localeCompare(field, resource1, resource2) { | 199 function localeCompare(field, resource1, resource2) { |
(...skipping 18 matching lines...) Expand all Loading... |
218 this._resources.sort(comparator); | 218 this._resources.sort(comparator); |
219 this._dataGrid.rootNode().removeChildren(); | 219 this._dataGrid.rootNode().removeChildren(); |
220 | 220 |
221 var nodeToSelect; | 221 var nodeToSelect; |
222 for (var i = 0; i < this._resources.length; ++i) { | 222 for (var i = 0; i < this._resources.length; ++i) { |
223 var data = {}; | 223 var data = {}; |
224 var resource = this._resources[i]; | 224 var resource = this._resources[i]; |
225 data.resource = resource.url; | 225 data.resource = resource.url; |
226 data.type = resource.type; | 226 data.type = resource.type; |
227 data.size = Number.bytesToString(resource.size); | 227 data.size = Number.bytesToString(resource.size); |
228 var node = new UI.DataGridNode(data); | 228 var node = new DataGrid.DataGridNode(data); |
229 node.resource = resource; | 229 node.resource = resource; |
230 node.selectable = true; | 230 node.selectable = true; |
231 this._dataGrid.rootNode().appendChild(node); | 231 this._dataGrid.rootNode().appendChild(node); |
232 if (resource === selectedResource) { | 232 if (resource === selectedResource) { |
233 nodeToSelect = node; | 233 nodeToSelect = node; |
234 nodeToSelect.selected = true; | 234 nodeToSelect.selected = true; |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 if (!nodeToSelect && this._dataGrid.rootNode().children.length) | 238 if (!nodeToSelect && this._dataGrid.rootNode().children.length) |
(...skipping 10 matching lines...) Expand all Loading... |
249 // FIXME: Delete Button semantics are not yet defined. (Delete a single, or
all?) | 249 // FIXME: Delete Button semantics are not yet defined. (Delete a single, or
all?) |
250 this._deleteCallback(this._dataGrid.selectedNode); | 250 this._deleteCallback(this._dataGrid.selectedNode); |
251 } | 251 } |
252 | 252 |
253 _deleteCallback(node) { | 253 _deleteCallback(node) { |
254 // FIXME: Should we delete a single (selected) resource or all resources? | 254 // FIXME: Should we delete a single (selected) resource or all resources? |
255 // Protocol.inspectorBackend.deleteCachedResource(...) | 255 // Protocol.inspectorBackend.deleteCachedResource(...) |
256 // this._update(); | 256 // this._update(); |
257 } | 257 } |
258 }; | 258 }; |
OLD | NEW |