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

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

Issue 266043004: Small cleanup to Code and Profiler pages (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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>();
11 @observable final List<String> columns = []; 11 @observable final List<String> columns = [];
12 static const arrowRight = '\u2192'; 12 static const arrowRight = '\u2192';
13 static const arrowDownRight = '\u21b3'; 13 static const arrowDownRight = '\u21b3';
14 static const showExpanderStyle = 'cursor: pointer;';
15 static const hideExpanderStyle = 'visibility:hidden;';
16
14 // TODO(johnmccutchan): Move expander display decisions into html once 17 // TODO(johnmccutchan): Move expander display decisions into html once
15 // tables and templates are better supported. 18 // tables and templates are better supported.
16 @observable String expander = arrowRight; 19 @observable String expander = arrowRight;
20 @observable String expanderStyle = showExpanderStyle;
17 21
18 TableTreeRow(TableTreeRow parent) : 22 TableTreeRow(TableTreeRow parent) :
19 parent = parent, 23 parent = parent,
20 depth = parent != null ? parent.depth+1 : 0; 24 depth = parent != null ? parent.depth+1 : 0 {
25 if (!hasChildren()) {
26 expanderStyle = hideExpanderStyle;
27 }
28 }
21 29
22 bool _expanded = false; 30 bool _expanded = false;
23 bool get expanded => _expanded; 31 bool get expanded => _expanded;
24 set expanded(bool expanded) { 32 set expanded(bool expanded) {
25 var changed = _expanded != expanded; 33 var changed = _expanded != expanded;
26 _expanded = expanded; 34 _expanded = expanded;
27 if (changed) { 35 if (changed) {
28 // If the state has changed, fire callbacks. 36 // If the state has changed, fire callbacks.
29 if (_expanded) { 37 if (_expanded) {
30 expander = arrowDownRight; 38 expander = arrowDownRight;
31 onShow(); 39 onShow();
32 } else { 40 } else {
33 expander = arrowRight; 41 expander = arrowRight;
34 onHide(); 42 onHide();
35 } 43 }
36 } 44 }
37 } 45 }
38 46
39 bool toggle() { 47 bool toggle() {
40 expanded = !expanded; 48 expanded = !expanded;
41 return expanded; 49 return expanded;
42 } 50 }
43 51
52 bool hasChildren();
53
44 /// Fired when the tree row is expanded. Add children rows here. 54 /// Fired when the tree row is expanded. Add children rows here.
45 void onShow(); 55 void onShow();
46 56
47 /// Fired when the tree row is collapsed. 57 /// Fired when the tree row is collapsed.
48 void onHide(); 58 void onHide();
49 } 59 }
50 60
51 class TableTree extends Observable { 61 class TableTree extends Observable {
52 @observable final List<TableTreeRow> rows = toObservable([]); 62 @observable final List<TableTreeRow> rows = toObservable([]);
53 63
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (column != _sortColumnIndex) { 189 if (column != _sortColumnIndex) {
180 return columns[column].label + '\u2003'; 190 return columns[column].label + '\u2003';
181 } 191 }
182 return columns[column].label + (_sortDescending ? arrowUp : arrowDown); 192 return columns[column].label + (_sortDescending ? arrowUp : arrowDown);
183 } 193 }
184 194
185 @reflectable dynamic getValue(int row, int column) { 195 @reflectable dynamic getValue(int row, int column) {
186 return rows[row].values[column]; 196 return rows[row].values[column];
187 } 197 }
188 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698