OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** @constructor */ | 5 /** @constructor */ |
6 function TaskManager() { } | 6 function TaskManager() { } |
7 | 7 |
8 cr.addSingletonGetter(TaskManager); | 8 cr.addSingletonGetter(TaskManager); |
9 | 9 |
10 /* | 10 /* |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 | 313 |
314 this.table_ = this.dialogDom_.querySelector('.detail-table'); | 314 this.table_ = this.dialogDom_.querySelector('.detail-table'); |
315 cr.ui.Table.decorate(this.table_); | 315 cr.ui.Table.decorate(this.table_); |
316 | 316 |
317 this.table_.dataModel = this.dataModel_; | 317 this.table_.dataModel = this.dataModel_; |
318 this.table_.selectionModel = this.selectionModel_; | 318 this.table_.selectionModel = this.selectionModel_; |
319 this.table_.columnModel = this.columnModel_; | 319 this.table_.columnModel = this.columnModel_; |
320 | 320 |
321 // Expands height of row when a process has some tasks. | 321 // Expands height of row when a process has some tasks. |
322 this.table_.autoExpands = true; | 322 this.table_.fixedHeight = false; |
323 | 323 |
324 this.table_.list.addEventListener('contextmenu', | 324 this.table_.list.addEventListener('contextmenu', |
325 this.onTableContextMenuOpened_.bind(this), | 325 this.onTableContextMenuOpened_.bind(this), |
326 true); | 326 true); |
327 | 327 |
328 // Sets custom row render function. | 328 // Sets custom row render function. |
329 this.table_.setRenderFunction(this.renderRow_.bind(this)); | 329 this.table_.setRenderFunction(this.renderRow_.bind(this)); |
330 }, | 330 }, |
331 | 331 |
332 renderRow_: function(dataItem, table) { | 332 renderRow_: function(dataItem, table) { |
(...skipping 13 matching lines...) Expand all Loading... |
346 | 346 |
347 listItem.appendChild(cell); | 347 listItem.appendChild(cell); |
348 } | 348 } |
349 listItem.data = dataItem; | 349 listItem.data = dataItem; |
350 | 350 |
351 return listItem; | 351 return listItem; |
352 }, | 352 }, |
353 | 353 |
354 renderColumn_: function(entry, columnId, table) { | 354 renderColumn_: function(entry, columnId, table) { |
355 var container = this.document_.createElement('div'); | 355 var container = this.document_.createElement('div'); |
356 container.id = 'detail-container-' + columnId + '-pid' + entry.processId; | |
357 container.className = 'detail-container-' + columnId; | 356 container.className = 'detail-container-' + columnId; |
358 | 357 |
359 if (entry[columnId]) { | 358 if (entry && entry[columnId]) { |
| 359 container.id = 'detail-container-' + columnId + '-pid' + entry.processId; |
| 360 |
360 for (var i = 0; i < entry[columnId].length; i++) { | 361 for (var i = 0; i < entry[columnId].length; i++) { |
361 var label = document.createElement('div'); | 362 var label = document.createElement('div'); |
362 if (columnId == 'title') { | 363 if (columnId == 'title') { |
363 var image = this.document_.createElement('img'); | 364 var image = this.document_.createElement('img'); |
364 image.className = 'detail-title-image'; | 365 image.className = 'detail-title-image'; |
365 image.src = entry['icon'][i]; | 366 image.src = entry['icon'][i]; |
366 label.appendChild(image); | 367 label.appendChild(image); |
367 var text = this.document_.createElement('div'); | 368 var text = this.document_.createElement('div'); |
368 text.className = 'detail-title-text'; | 369 text.className = 'detail-title-text'; |
369 text.textContent = entry['title'][i]; | 370 text.textContent = entry['title'][i]; |
(...skipping 18 matching lines...) Expand all Loading... |
388 } | 389 } |
389 return container; | 390 return container; |
390 }, | 391 }, |
391 | 392 |
392 onTaskChange: function (start, length, tasks) { | 393 onTaskChange: function (start, length, tasks) { |
393 var dm = this.dataModel_; | 394 var dm = this.dataModel_; |
394 var sm = this.selectionModel_; | 395 var sm = this.selectionModel_; |
395 if (!dm || !sm) | 396 if (!dm || !sm) |
396 return; | 397 return; |
397 | 398 |
| 399 this.table_.list.startBatchUpdates(); |
398 // Splice takes the to-be-spliced-in array as individual parameters, | 400 // Splice takes the to-be-spliced-in array as individual parameters, |
399 // rather than as an array, so we need to perform some acrobatics... | 401 // rather than as an array, so we need to perform some acrobatics... |
400 var args = [].slice.call(tasks); | 402 var args = [].slice.call(tasks); |
401 args.unshift(start, length); | 403 args.unshift(start, dm.length); |
402 | 404 |
| 405 sm.beginChange(); |
403 var oldSelectedIndexes = sm.selectedIndexes; | 406 var oldSelectedIndexes = sm.selectedIndexes; |
| 407 |
404 dm.splice.apply(dm, args); | 408 dm.splice.apply(dm, args); |
| 409 |
405 sm.selectedIndexes = oldSelectedIndexes; | 410 sm.selectedIndexes = oldSelectedIndexes; |
| 411 sm.endChange(); |
| 412 this.table_.list.endBatchUpdates(); |
406 }, | 413 }, |
407 | 414 |
408 onTaskAdd: function (start, length, tasks) { | 415 onTaskAdd: function (start, length, tasks) { |
409 var dm = this.dataModel_; | 416 var dm = this.dataModel_; |
410 if (!dm) | 417 if (!dm) |
411 return; | 418 return; |
412 | 419 |
413 // Splice takes the to-be-spliced-in array as individual parameters, | 420 // Splice takes the to-be-spliced-in array as individual parameters, |
414 // rather than as an array, so we need to perform some acrobatics... | 421 // rather than as an array, so we need to perform some acrobatics... |
415 var args = [].slice.call(tasks); | 422 var args = [].slice.call(tasks); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 taskmanager.onTaskChange(start, length, tasks); | 569 taskmanager.onTaskChange(start, length, tasks); |
563 } | 570 } |
564 | 571 |
565 function taskRemoved(start, length) { | 572 function taskRemoved(start, length) { |
566 // Sometimes this can get called too early. | 573 // Sometimes this can get called too early. |
567 if (!taskmanager) | 574 if (!taskmanager) |
568 return; | 575 return; |
569 taskmanager.onTaskRemove(start, length); | 576 taskmanager.onTaskRemove(start, length); |
570 } | 577 } |
571 | 578 |
OLD | NEW |