OLD | NEW |
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 observatory; | 5 part of observatory; |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 /// Initialize the table tree with the list of root children. | 53 /// Initialize the table tree with the list of root children. |
54 void initialize(List<TableTreeRow> children) { | 54 void initialize(List<TableTreeRow> children) { |
55 rows.clear(); | 55 rows.clear(); |
56 rows.addAll(children); | 56 rows.addAll(children); |
57 } | 57 } |
58 | 58 |
59 /// Toggle expansion of row at [rowIndex]. | 59 /// Toggle expansion of row at [rowIndex]. |
60 void toggle(int rowIndex) { | 60 void toggle(int rowIndex) { |
61 assert(rowIndex >= 0); | 61 assert(rowIndex >= 0); |
62 assert(rowIndex < rows.length); | 62 assert(rowIndex < rows.length); |
63 print(rowIndex); | |
64 print(rows.length); | |
65 var row = rows[rowIndex]; | 63 var row = rows[rowIndex]; |
66 if (row.toggle()) { | 64 if (row.toggle()) { |
67 _expand(row); | 65 _expand(row); |
68 } else { | 66 } else { |
69 _collapse(row); | 67 _collapse(row); |
70 } | 68 } |
71 print('e'); | |
72 } | 69 } |
73 | 70 |
74 int _index(TableTreeRow row) => rows.indexOf(row); | 71 int _index(TableTreeRow row) => rows.indexOf(row); |
75 | 72 |
76 void _insertRow(int index, TableTreeRow row) { | 73 void _insertRow(int index, TableTreeRow row) { |
77 if (index == -1) { | 74 if (index == -1) { |
78 rows.add(row); | 75 rows.add(row); |
79 } else { | 76 } else { |
80 rows.insert(index, row); | 77 rows.insert(index, row); |
81 } | 78 } |
(...skipping 20 matching lines...) Expand all Loading... |
102 } | 99 } |
103 // Collapse this row. | 100 // Collapse this row. |
104 row.expanded = false; | 101 row.expanded = false; |
105 // Remove all children. | 102 // Remove all children. |
106 int index = _index(row); | 103 int index = _index(row); |
107 for (var i = 0; i < childCount; i++) { | 104 for (var i = 0; i < childCount; i++) { |
108 rows.removeAt(index + 1); | 105 rows.removeAt(index + 1); |
109 } | 106 } |
110 } | 107 } |
111 } | 108 } |
OLD | NEW |