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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/elements/class_tree.dart

Issue 308673012: Redo LocationManager to use HTML5 History API (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library class_tree_element;
6
7 import 'observatory_element.dart';
8 import 'dart:html';
9 import 'package:logging/logging.dart';
10 import 'package:observatory/app.dart';
11 import 'package:observatory/service.dart';
12 import 'package:polymer/polymer.dart';
13
14 class ClassTreeRow extends TableTreeRow {
15 @reflectable final Isolate isolate;
16 @reflectable final Class cls;
17 ClassTreeRow(this.isolate, this.cls, ClassTreeRow parent) : super(parent) {
18 assert(isolate != null);
19 assert(cls != null);
20 }
21
22 void onShow() {
23 if (children.length > 0) {
24 // Child rows already created.
25 return;
26 }
27 for (var subClass in cls.children) {
28 if (subClass.isPatch) {
29 continue;
30 }
31 var row = new ClassTreeRow(isolate, subClass, this);
32 children.add(row);
33 }
34 }
35
36 void onHide() {
37 }
38
39 bool hasChildren() {
40 return cls.children.length > 0;
41 }
42 }
43
44
45 @CustomTag('class-tree')
46 class ClassTreeElement extends ObservatoryElement {
47 @observable Isolate isolate;
48
49 TableTree tree;
50
51 ClassTreeElement.created() : super.created();
52
53 void enteredView() {
54 tree = new TableTree();
55 if (isolate != null) {
56 _update(isolate.objectClass);
57 }
58 }
59
60 isolateChanged(oldValue) {
61 isolate.getClassHierarchy().then((objectClass) {
62 _update(objectClass);
63 });
64 }
65
66 void _update(Class root) {
67 try {
68 var rootRow = new ClassTreeRow(isolate, root, null);
69 rootRow.children.add(new ClassTreeRow(isolate, root, rootRow));
70 tree.initialize(rootRow);
71 } catch (e, stackTrace) {
72 Logger.root.warning('_update', e, stackTrace);
73 }
74 // Check if we only have one node at the root and expand it.
75 if (tree.rows.length == 1) {
76 tree.toggle(0);
77 }
78 notifyPropertyChange(#tree, null, tree);
79 }
80
81 @observable String padding(TableTreeRow row) {
82 return 'padding-left: ${row.depth * 16}px;';
83 }
84
85 @observable String coloring(TableTreeRow row) {
86 const colors = const ['rowColor0', 'rowColor1', 'rowColor2', 'rowColor3',
87 'rowColor4', 'rowColor5', 'rowColor6', 'rowColor7',
88 'rowColor8'];
89 var index = (row.depth - 1) % colors.length;
90 return colors[index];
91 }
92
93 @observable void toggleExpanded(Event e, var detail, Element target) {
94 // We only want to expand a tree row if the target of the click is
95 // the table cell (passed in as target) or the span containing the
96 // expander symbol (#expand).
97 var eventTarget = e.target;
98 if ((eventTarget.id != 'expand') && (e.target != target)) {
99 // Target of click was not the expander span or the table cell.
100 return;
101 }
102 var row = target.parent;
103 if (row is TableRowElement) {
104 // Subtract 1 to get 0 based indexing.
turnidge 2014/06/04 18:02:24 Move the above comment inside the "try"
Cutch 2014/06/04 20:28:57 Done.
105 try {
106 tree.toggle(row.rowIndex - 1);
107 } catch (e, stackTrace) {
108 Logger.root.warning('toggleExpanded', e, stackTrace);
109 }
110 }
111 }
112
113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698