OLD | NEW |
1 // Copyright (c) 2014, 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 library object_view; | 5 import 'dart:async'; |
| 6 import 'dart:html'; |
| 7 import 'package:observatory/models.dart' as M; |
| 8 import 'package:observatory/src/elements/context_ref.dart'; |
| 9 import 'package:observatory/src/elements/curly_block.dart'; |
| 10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
| 11 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 12 import 'package:observatory/src/elements/nav/bar.dart'; |
| 13 import 'package:observatory/src/elements/nav/isolate_menu.dart'; |
| 14 import 'package:observatory/src/elements/nav/menu.dart'; |
| 15 import 'package:observatory/src/elements/nav/notify.dart'; |
| 16 import 'package:observatory/src/elements/nav/refresh.dart'; |
| 17 import 'package:observatory/src/elements/nav/top_menu.dart'; |
| 18 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
| 19 import 'package:observatory/src/elements/object_common.dart'; |
| 20 import 'package:observatory/src/elements/view_footer.dart'; |
6 | 21 |
7 import 'dart:async'; | 22 class ObjectViewElement extends HtmlElement implements Renderable { |
8 import 'observatory_element.dart'; | 23 static const tag = const Tag<ObjectViewElement>('object-view', |
9 import 'package:observatory/service.dart'; | 24 dependencies: const [ |
10 import 'package:polymer/polymer.dart'; | 25 ContextRefElement.tag, |
| 26 CurlyBlockElement.tag, |
| 27 NavBarElement.tag, |
| 28 NavTopMenuElement.tag, |
| 29 NavVMMenuElement.tag, |
| 30 NavIsolateMenuElement.tag, |
| 31 NavMenuElement.tag, |
| 32 NavRefreshElement.tag, |
| 33 NavNotifyElement.tag, |
| 34 ObjectCommonElement.tag, |
| 35 ViewFooterElement.tag |
| 36 ]); |
11 | 37 |
12 @CustomTag('object-view') | 38 RenderingScheduler<ObjectViewElement> _r; |
13 class ObjectViewElement extends ObservatoryElement { | 39 |
14 @published ServiceObject object; | 40 Stream<RenderedEvent<ObjectViewElement>> get onRendered => _r.onRendered; |
| 41 |
| 42 M.VM _vm; |
| 43 M.IsolateRef _isolate; |
| 44 M.EventRepository _events; |
| 45 M.NotificationRepository _notifications; |
| 46 M.Object _object; |
| 47 M.ObjectRepository _objects; |
| 48 M.RetainedSizeRepository _retainedSizes; |
| 49 M.ReachableSizeRepository _reachableSizes; |
| 50 M.InboundReferencesRepository _references; |
| 51 M.RetainingPathRepository _retainingPaths; |
| 52 M.InstanceRepository _instances; |
| 53 |
| 54 |
| 55 M.VMRef get vm => _vm; |
| 56 M.IsolateRef get isolate => _isolate; |
| 57 M.NotificationRepository get notifications => _notifications; |
| 58 M.Context get object => _object; |
| 59 |
| 60 factory ObjectViewElement(M.VM vm, M.IsolateRef isolate, M.Object object, |
| 61 M.EventRepository events, |
| 62 M.NotificationRepository notifications, |
| 63 M.ObjectRepository objects, |
| 64 M.RetainedSizeRepository retainedSizes, |
| 65 M.ReachableSizeRepository reachableSizes, |
| 66 M.InboundReferencesRepository references, |
| 67 M.RetainingPathRepository retainingPaths, |
| 68 M.InstanceRepository instances, |
| 69 {RenderingQueue queue}) { |
| 70 assert(vm != null); |
| 71 assert(isolate != null); |
| 72 assert(events != null); |
| 73 assert(notifications != null); |
| 74 assert(object != null); |
| 75 assert(objects != null); |
| 76 assert(retainedSizes != null); |
| 77 assert(reachableSizes != null); |
| 78 assert(references != null); |
| 79 assert(retainingPaths != null); |
| 80 assert(instances != null); |
| 81 ObjectViewElement e = document.createElement(tag.name); |
| 82 e._r = new RenderingScheduler(e, queue: queue); |
| 83 e._vm = vm; |
| 84 e._isolate = isolate; |
| 85 e._events = events; |
| 86 e._notifications = notifications; |
| 87 e._object = object; |
| 88 e._objects = objects; |
| 89 e._retainedSizes = retainedSizes; |
| 90 e._reachableSizes = reachableSizes; |
| 91 e._references = references; |
| 92 e._retainingPaths = retainingPaths; |
| 93 e._instances = instances; |
| 94 return e; |
| 95 } |
15 | 96 |
16 ObjectViewElement.created() : super.created(); | 97 ObjectViewElement.created() : super.created(); |
17 | 98 |
18 Future refresh() { | 99 @override |
19 return object.reload(); | 100 attached() { |
| 101 super.attached(); |
| 102 _r.enable(); |
| 103 } |
| 104 |
| 105 @override |
| 106 detached() { |
| 107 super.detached(); |
| 108 _r.disable(notify: true); |
| 109 children = []; |
| 110 } |
| 111 |
| 112 void render() { |
| 113 children = [ |
| 114 new NavBarElement(queue: _r.queue) |
| 115 ..children = [ |
| 116 new NavTopMenuElement(queue: _r.queue), |
| 117 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
| 118 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
| 119 new NavMenuElement('object', last: true, queue: _r.queue), |
| 120 new NavRefreshElement(queue: _r.queue) |
| 121 ..onRefresh.listen((e) async { |
| 122 e.element.disabled = true; |
| 123 _object = await _objects.get(_isolate, _object.id); |
| 124 _r.dirty(); |
| 125 }), |
| 126 new NavNotifyElement(_notifications, queue: _r.queue) |
| 127 ], |
| 128 new DivElement()..classes = const ['content-centered-big'] |
| 129 ..children = [ |
| 130 new HeadingElement.h2()..text = 'Object', |
| 131 new HRElement(), |
| 132 new ObjectCommonElement(_isolate, _object, _retainedSizes, |
| 133 _reachableSizes, _references, _retainingPaths, |
| 134 _instances, queue: _r.queue), |
| 135 new HRElement(), |
| 136 new ViewFooterElement(queue: _r.queue) |
| 137 ] |
| 138 ]; |
20 } | 139 } |
21 } | 140 } |
OLD | NEW |