OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:html'; | 6 import 'dart:html'; |
7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
8 import 'package:observatory/src/elements/context_ref.dart'; | 8 import 'package:observatory/src/elements/context_ref.dart'; |
9 import 'package:observatory/src/elements/curly_block.dart'; | 9 import 'package:observatory/src/elements/curly_block.dart'; |
10 import 'package:observatory/src/elements/helpers/any_ref.dart'; | 10 import 'package:observatory/src/elements/helpers/any_ref.dart'; |
11 import 'package:observatory/src/elements/helpers/nav_bar.dart'; | 11 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
12 import 'package:observatory/src/elements/helpers/nav_menu.dart'; | 12 import 'package:observatory/src/elements/helpers/nav_menu.dart'; |
13 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 13 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
14 import 'package:observatory/src/elements/helpers/tag.dart'; | 14 import 'package:observatory/src/elements/helpers/tag.dart'; |
15 import 'package:observatory/src/elements/nav/class_menu.dart'; | 15 import 'package:observatory/src/elements/nav/class_menu.dart'; |
16 import 'package:observatory/src/elements/nav/isolate_menu.dart'; | 16 import 'package:observatory/src/elements/nav/isolate_menu.dart'; |
17 import 'package:observatory/src/elements/nav/notify.dart'; | 17 import 'package:observatory/src/elements/nav/notify.dart'; |
18 import 'package:observatory/src/elements/nav/refresh.dart'; | 18 import 'package:observatory/src/elements/nav/refresh.dart'; |
19 import 'package:observatory/src/elements/nav/top_menu.dart'; | 19 import 'package:observatory/src/elements/nav/top_menu.dart'; |
20 import 'package:observatory/src/elements/nav/vm_menu.dart'; | 20 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
21 import 'package:observatory/src/elements/object_common.dart'; | 21 import 'package:observatory/src/elements/object_common.dart'; |
22 import 'package:observatory/src/elements/view_footer.dart'; | 22 import 'package:observatory/src/elements/view_footer.dart'; |
23 | 23 |
24 class ContextViewElement extends HtmlElement implements Renderable { | 24 class ContextViewElement extends HtmlElement implements Renderable { |
25 static const tag = const Tag<ContextViewElement>('context-view', | 25 static const tag = |
26 dependencies: const [ | 26 const Tag<ContextViewElement>('context-view', dependencies: const [ |
27 ContextRefElement.tag, | 27 ContextRefElement.tag, |
28 CurlyBlockElement.tag, | 28 CurlyBlockElement.tag, |
29 NavClassMenuElement.tag, | 29 NavClassMenuElement.tag, |
30 NavTopMenuElement.tag, | 30 NavTopMenuElement.tag, |
31 NavVMMenuElement.tag, | 31 NavVMMenuElement.tag, |
32 NavIsolateMenuElement.tag, | 32 NavIsolateMenuElement.tag, |
33 NavRefreshElement.tag, | 33 NavRefreshElement.tag, |
34 NavNotifyElement.tag, | 34 NavNotifyElement.tag, |
35 ObjectCommonElement.tag, | 35 ObjectCommonElement.tag, |
36 ViewFooterElement.tag | 36 ViewFooterElement.tag |
37 ]); | 37 ]); |
38 | 38 |
39 RenderingScheduler<ContextViewElement> _r; | 39 RenderingScheduler<ContextViewElement> _r; |
40 | 40 |
41 Stream<RenderedEvent<ContextViewElement>> get onRendered => _r.onRendered; | 41 Stream<RenderedEvent<ContextViewElement>> get onRendered => _r.onRendered; |
42 | 42 |
43 M.VM _vm; | 43 M.VM _vm; |
44 M.IsolateRef _isolate; | 44 M.IsolateRef _isolate; |
45 M.EventRepository _events; | 45 M.EventRepository _events; |
46 M.NotificationRepository _notifications; | 46 M.NotificationRepository _notifications; |
47 M.Context _context; | 47 M.Context _context; |
48 M.ContextRepository _contexts; | 48 M.ContextRepository _contexts; |
49 M.RetainedSizeRepository _retainedSizes; | 49 M.RetainedSizeRepository _retainedSizes; |
50 M.ReachableSizeRepository _reachableSizes; | 50 M.ReachableSizeRepository _reachableSizes; |
51 M.InboundReferencesRepository _references; | 51 M.InboundReferencesRepository _references; |
52 M.RetainingPathRepository _retainingPaths; | 52 M.RetainingPathRepository _retainingPaths; |
53 M.InstanceRepository _instances; | 53 M.InstanceRepository _instances; |
54 | 54 |
55 | |
56 M.VMRef get vm => _vm; | 55 M.VMRef get vm => _vm; |
57 M.IsolateRef get isolate => _isolate; | 56 M.IsolateRef get isolate => _isolate; |
58 M.NotificationRepository get notifications => _notifications; | 57 M.NotificationRepository get notifications => _notifications; |
59 M.Context get context => _context; | 58 M.Context get context => _context; |
60 | 59 |
61 factory ContextViewElement(M.VM vm, M.IsolateRef isolate, M.Context context, | 60 factory ContextViewElement( |
62 M.EventRepository events, | 61 M.VM vm, |
63 M.NotificationRepository notifications, | 62 M.IsolateRef isolate, |
64 M.ContextRepository contexts, | 63 M.Context context, |
65 M.RetainedSizeRepository retainedSizes, | 64 M.EventRepository events, |
66 M.ReachableSizeRepository reachableSizes, | 65 M.NotificationRepository notifications, |
67 M.InboundReferencesRepository references, | 66 M.ContextRepository contexts, |
68 M.RetainingPathRepository retainingPaths, | 67 M.RetainedSizeRepository retainedSizes, |
69 M.InstanceRepository instances, | 68 M.ReachableSizeRepository reachableSizes, |
70 {RenderingQueue queue}) { | 69 M.InboundReferencesRepository references, |
| 70 M.RetainingPathRepository retainingPaths, |
| 71 M.InstanceRepository instances, |
| 72 {RenderingQueue queue}) { |
71 assert(vm != null); | 73 assert(vm != null); |
72 assert(isolate != null); | 74 assert(isolate != null); |
73 assert(events != null); | 75 assert(events != null); |
74 assert(notifications != null); | 76 assert(notifications != null); |
75 assert(context != null); | 77 assert(context != null); |
76 assert(contexts != null); | 78 assert(contexts != null); |
77 assert(retainedSizes != null); | 79 assert(retainedSizes != null); |
78 assert(reachableSizes != null); | 80 assert(reachableSizes != null); |
79 assert(references != null); | 81 assert(references != null); |
80 assert(retainingPaths != null); | 82 assert(retainingPaths != null); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 114 |
113 void render() { | 115 void render() { |
114 var content = [ | 116 var content = [ |
115 navBar([ | 117 navBar([ |
116 new NavTopMenuElement(queue: _r.queue), | 118 new NavTopMenuElement(queue: _r.queue), |
117 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 119 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
118 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), | 120 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
119 new NavClassMenuElement(_isolate, _context.clazz, queue: _r.queue), | 121 new NavClassMenuElement(_isolate, _context.clazz, queue: _r.queue), |
120 navMenu('instance'), | 122 navMenu('instance'), |
121 new NavRefreshElement(queue: _r.queue) | 123 new NavRefreshElement(queue: _r.queue) |
122 ..onRefresh.listen((e) async { | 124 ..onRefresh.listen((e) async { |
123 e.element.disabled = true; | 125 e.element.disabled = true; |
124 _context = await _contexts.get(_isolate, _context.id); | 126 _context = await _contexts.get(_isolate, _context.id); |
125 _r.dirty(); | 127 _r.dirty(); |
126 }), | 128 }), |
127 new NavNotifyElement(_notifications, queue: _r.queue) | 129 new NavNotifyElement(_notifications, queue: _r.queue) |
128 ]), | 130 ]), |
129 new DivElement()..classes = ['content-centered-big'] | 131 new DivElement() |
| 132 ..classes = ['content-centered-big'] |
130 ..children = [ | 133 ..children = [ |
131 new HeadingElement.h2()..text = 'Context', | 134 new HeadingElement.h2()..text = 'Context', |
132 new HRElement(), | 135 new HRElement(), |
133 new ObjectCommonElement(_isolate, _context, _retainedSizes, | 136 new ObjectCommonElement(_isolate, _context, _retainedSizes, |
134 _reachableSizes, _references, _retainingPaths, | 137 _reachableSizes, _references, _retainingPaths, _instances, |
135 _instances, queue: _r.queue) | 138 queue: _r.queue) |
136 ] | 139 ] |
137 ]; | 140 ]; |
138 if (_context.parentContext != null) { | 141 if (_context.parentContext != null) { |
139 content.addAll([ | 142 content.addAll([ |
140 new BRElement(), | 143 new BRElement(), |
141 new DivElement()..classes = ['content-centered-big'] | 144 new DivElement() |
| 145 ..classes = ['content-centered-big'] |
142 ..children = [ | 146 ..children = [ |
143 new DivElement()..classes = ['memberList'] | 147 new DivElement() |
| 148 ..classes = ['memberList'] |
144 ..children = [ | 149 ..children = [ |
145 new DivElement()..classes = ['memberItem'] | 150 new DivElement() |
| 151 ..classes = ['memberItem'] |
146 ..children = [ | 152 ..children = [ |
147 new DivElement()..classes = ['memberName'] | 153 new DivElement() |
| 154 ..classes = ['memberName'] |
148 ..text = 'parent context', | 155 ..text = 'parent context', |
149 new DivElement()..classes = ['memberName'] | 156 new DivElement() |
| 157 ..classes = ['memberName'] |
150 ..children = [ | 158 ..children = [ |
151 new ContextRefElement(_isolate, _context.parentContext, | 159 new ContextRefElement(_isolate, _context.parentContext, |
152 queue: _r.queue) | 160 queue: _r.queue) |
153 ] | 161 ] |
154 ] | 162 ] |
155 ] | 163 ] |
156 ] | 164 ] |
157 ]); | 165 ]); |
158 } | 166 } |
159 content.add(new HRElement()); | 167 content.add(new HRElement()); |
160 if (_context.variables.isNotEmpty) { | 168 if (_context.variables.isNotEmpty) { |
161 int index = 0; | 169 int index = 0; |
162 content.addAll([ | 170 content.addAll([ |
163 new DivElement()..classes = ['content-centered-big'] | 171 new DivElement() |
| 172 ..classes = ['content-centered-big'] |
164 ..children = [ | 173 ..children = [ |
165 new SpanElement()..text = 'Variables ', | 174 new SpanElement()..text = 'Variables ', |
166 new CurlyBlockElement(expanded: _context.variables.length > 8, | 175 new CurlyBlockElement( |
| 176 expanded: _context.variables.length > 8, queue: _r.queue) |
| 177 ..content = [ |
| 178 new DivElement() |
| 179 ..classes = ['memberList'] |
| 180 ..children = _context.variables |
| 181 .map((variable) => new DivElement() |
| 182 ..classes = ['memberItem'] |
| 183 ..children = [ |
| 184 new DivElement() |
| 185 ..classes = ['memberName'] |
| 186 ..text = '[ ${++index} ]', |
| 187 new DivElement() |
| 188 ..classes = ['memberName'] |
| 189 ..children = [ |
| 190 anyRef(_isolate, variable.value, _instances, |
167 queue: _r.queue) | 191 queue: _r.queue) |
168 ..content = [ | 192 ] |
169 new DivElement()..classes = ['memberList'] | 193 ]) |
170 ..children = _context.variables.map((variable) | 194 .toList() |
171 => new DivElement()..classes = ['memberItem'] | |
172 ..children = [ | |
173 new DivElement()..classes = ['memberName'] | |
174 ..text = '[ ${++index} ]', | |
175 new DivElement()..classes = ['memberName'] | |
176 ..children = [ | |
177 anyRef(_isolate, variable.value, _instances, | |
178 queue: _r.queue) | |
179 ] | |
180 ]).toList() | |
181 ] | 195 ] |
182 ] | 196 ] |
183 ]); | 197 ]); |
184 } | 198 } |
185 content.add(new DivElement()..classes = ['content-centered-big'] | 199 content.add(new DivElement() |
| 200 ..classes = ['content-centered-big'] |
186 ..children = [new ViewFooterElement(queue: _r.queue)]); | 201 ..children = [new ViewFooterElement(queue: _r.queue)]); |
187 children = content; | 202 children = content; |
188 } | 203 } |
189 } | 204 } |
OLD | NEW |