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

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

Issue 237683004: Disable applyAuthorStyles (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 _collapse(row.children[i]); 92 _collapse(row.children[i]);
93 } 93 }
94 } 94 }
95 // Collapse this row. 95 // Collapse this row.
96 row.expanded = false; 96 row.expanded = false;
97 // Remove all children. 97 // Remove all children.
98 int index = _index(row); 98 int index = _index(row);
99 rows.removeRange(index + 1, index + 1 + childCount); 99 rows.removeRange(index + 1, index + 1 + childCount);
100 } 100 }
101 } 101 }
102
103 typedef String ValueFormatter(dynamic value);
104
105 class SortedTableColumn {
106 static String toStringFormatter(dynamic v) {
107 return v != null ? v.toString() : '<null>';
108 }
109 final String label;
110 final ValueFormatter formatter;
111 SortedTableColumn.withFormatter(this.label, this.formatter);
112 SortedTableColumn(this.label)
113 : formatter = toStringFormatter;
114 }
115
116 class SortedTableRow {
117 final List values;
118 SortedTableRow(this.values);
119 }
120
121 class SortedTable extends Observable {
122 final List<SortedTableColumn> columns;
123 final List<SortedTableRow> rows = new List<SortedTableRow>();
124 final List<int> _sortedRows = [];
125
126 SortedTable(this.columns);
127
128 int _sortColumnIndex = 0;
129 set sortColumnIndex(var index) {
130 assert(index >= 0);
131 assert(index < columns.length);
132 _sortColumnIndex = index;
133 notifyPropertyChange(#getColumnLabel, 0, 1);
134 }
135 int get sortColumnIndex => _sortColumnIndex;
136 bool _sortDescending = true;
137
138 void sort() {
139 assert(_sortColumnIndex >= 0);
140 assert(_sortColumnIndex < columns.length);
141 _sortedRows.sort((i, j) {
142 var a = rows[i].values[_sortColumnIndex];
143 var b = rows[j].values[_sortColumnIndex];
144 if (_sortDescending) {
145 return b.compareTo(a);
146 } else {
147 return a.compareTo(b);
148 }
149 });
150 notifyPropertyChange(#sortedRows, 0, 1);
151 }
152
153 @observable List<int> get sortedRows => _sortedRows;
154
155 void clearRows() {
156 rows.clear();
157 _sortedRows.clear();
158 }
159
160 void addRow(SortedTableRow row) {
161 _sortedRows.add(rows.length);
162 rows.add(row);
163 notifyPropertyChange(#sortedRows, 0, 1);
164 }
165
166 @reflectable String getFormattedValue(int row, int column) {
167 var value = getValue(row, column);
168 var formatter = columns[column].formatter;
169 return formatter(value);
170 }
171
172 @reflectable String getColumnLabel(int column) {
173 assert(column >= 0);
174 assert(column < columns.length);
175 // TODO(johnmccutchan): Move expander display decisions into html once
176 // tables and templates are better supported.
177 const arrowUp = '\u25BC';
178 const arrowDown = '\u25B2';
179 if (column != _sortColumnIndex) {
180 return columns[column].label + '\u2003';
181 }
182 return columns[column].label + (_sortDescending ? arrowUp : arrowDown);
183 }
184
185 @reflectable dynamic getValue(int row, int column) {
186 return rows[row].values[column];
187 }
188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698