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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/app/view_model.dart

Issue 201213004: Use VM tag in profile and add stack trace trie (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of app; 5 part of app;
6 6
7 abstract class TableTreeRow extends Observable { 7 abstract class TableTreeRow extends Observable {
8 final TableTreeRow parent; 8 final TableTreeRow parent;
9 @observable final int depth; 9 @observable final int depth;
10 @observable final List<TableTreeRow> children = new List<TableTreeRow>(); 10 @observable final List<TableTreeRow> children = new List<TableTreeRow>();
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 /// Fired when the tree row is expanded. Add children rows here. 37 /// Fired when the tree row is expanded. Add children rows here.
38 void onShow(); 38 void onShow();
39 39
40 /// Fired when the tree row is collapsed. 40 /// Fired when the tree row is collapsed.
41 void onHide(); 41 void onHide();
42 } 42 }
43 43
44 class TableTree extends Observable { 44 class TableTree extends Observable {
45 final List<String> columnHeaders = [];
46 @observable final List<TableTreeRow> rows = toObservable([]); 45 @observable final List<TableTreeRow> rows = toObservable([]);
47 46
48 /// Create a table tree with column [headers]. 47 /// Create a table tree with column [headers].
49 TableTree(List<String> headers) { 48 TableTree();
50 columnHeaders.addAll(headers);
51 }
52 49
53 /// Initialize the table tree with the list of root children. 50 /// Initialize the table tree with the list of root children.
54 void initialize(List<TableTreeRow> children) { 51 void initialize(TableTreeRow root) {
55 rows.clear(); 52 rows.clear();
56 rows.addAll(children); 53 root.onShow();
54 rows.addAll(root.children);
57 } 55 }
58 56
59 /// Toggle expansion of row at [rowIndex]. 57 /// Toggle expansion of row at [rowIndex].
60 void toggle(int rowIndex) { 58 void toggle(int rowIndex) {
61 assert(rowIndex >= 0); 59 assert(rowIndex >= 0);
62 assert(rowIndex < rows.length); 60 assert(rowIndex < rows.length);
63 var row = rows[rowIndex]; 61 var row = rows[rowIndex];
64 if (row.toggle()) { 62 if (row.toggle()) {
65 _expand(row); 63 _expand(row);
66 } else { 64 } else {
67 _collapse(row); 65 _collapse(row);
68 } 66 }
69 } 67 }
70 68
71 int _index(TableTreeRow row) => rows.indexOf(row); 69 int _index(TableTreeRow row) => rows.indexOf(row);
72 70
73 void _insertRow(int index, TableTreeRow row) {
74 if (index == -1) {
75 rows.add(row);
76 } else {
77 rows.insert(index, row);
78 }
79 }
80
81 void _expand(TableTreeRow row) { 71 void _expand(TableTreeRow row) {
82 int index = _index(row); 72 int index = _index(row);
83 assert(index != -1); 73 assert(index != -1);
84 for (var i = 0; i < row.children.length; i++) { 74 rows.insertAll(index + 1, row.children);
85 _insertRow(index + i + 1, row.children[i]);
86 }
87 } 75 }
88 76
89 void _collapse(TableTreeRow row) { 77 void _collapse(TableTreeRow row) {
90 var childCount = row.children.length; 78 var childCount = row.children.length;
91 if (childCount == 0) { 79 if (childCount == 0) {
92 return; 80 return;
93 } 81 }
94 for (var i = 0; i < childCount; i++) { 82 for (var i = 0; i < childCount; i++) {
95 // Close all inner rows. 83 // Close all inner rows.
96 if (row.children[i].expanded) { 84 if (row.children[i].expanded) {
97 _collapse(row.children[i]); 85 _collapse(row.children[i]);
98 } 86 }
99 } 87 }
100 // Collapse this row. 88 // Collapse this row.
101 row.expanded = false; 89 row.expanded = false;
102 // Remove all children. 90 // Remove all children.
103 int index = _index(row); 91 int index = _index(row);
104 for (var i = 0; i < childCount; i++) { 92 rows.removeRange(index + 1, index + 1 + childCount);
105 rows.removeAt(index + 1);
106 }
107 } 93 }
108 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698