OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:html'; |
| 6 import 'dart:async'; |
| 7 import 'package:observatory/models.dart' as M; |
| 8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
| 9 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 10 import 'package:observatory/src/elements/nav/bar.dart'; |
| 11 import 'package:observatory/src/elements/nav/isolate_menu.dart'; |
| 12 import 'package:observatory/src/elements/nav/menu.dart'; |
| 13 import 'package:observatory/src/elements/nav/notify.dart'; |
| 14 import 'package:observatory/src/elements/nav/top_menu.dart'; |
| 15 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
| 16 import 'package:observatory/src/elements/view_footer.dart'; |
| 17 |
| 18 |
| 19 class SentinelViewElement extends HtmlElement implements Renderable { |
| 20 static const tag = const Tag<SentinelViewElement>('sentinel-view', |
| 21 dependencies: const [ |
| 22 NavBarElement.tag, |
| 23 NavTopMenuElement.tag, |
| 24 NavVMMenuElement.tag, |
| 25 NavIsolateMenuElement.tag, |
| 26 NavMenuElement.tag, |
| 27 NavNotifyElement.tag, |
| 28 ViewFooterElement.tag |
| 29 ]); |
| 30 |
| 31 RenderingScheduler<SentinelViewElement> _r; |
| 32 |
| 33 Stream<RenderedEvent<SentinelViewElement>> get onRendered => _r.onRendered; |
| 34 |
| 35 M.VM _vm; |
| 36 M.IsolateRef _isolate; |
| 37 M.Sentinel _sentinel; |
| 38 M.EventRepository _events; |
| 39 M.NotificationRepository _notifications; |
| 40 |
| 41 M.Sentinel get sentinel => _sentinel; |
| 42 |
| 43 factory SentinelViewElement(M.VM vm, M.IsolateRef isolate, M.Sentinel sentinel
, |
| 44 M.EventRepository events, |
| 45 M.NotificationRepository notifications, |
| 46 {RenderingQueue queue}) { |
| 47 assert(vm != null); |
| 48 assert(isolate != null); |
| 49 assert(sentinel != null); |
| 50 assert(events != null); |
| 51 assert(notifications != null); |
| 52 SentinelViewElement e = document.createElement(tag.name); |
| 53 e._r = new RenderingScheduler(e, queue: queue); |
| 54 e._vm = vm; |
| 55 e._isolate = isolate; |
| 56 e._sentinel = sentinel; |
| 57 e._events = events; |
| 58 e._notifications = notifications; |
| 59 return e; |
| 60 } |
| 61 |
| 62 SentinelViewElement.created() : super.created(); |
| 63 |
| 64 @override |
| 65 void attached() { |
| 66 super.attached(); |
| 67 _r.enable(); |
| 68 } |
| 69 |
| 70 @override |
| 71 void detached() { |
| 72 super.detached(); |
| 73 _r.disable(notify: true); |
| 74 text = ''; |
| 75 title = ''; |
| 76 } |
| 77 |
| 78 void render() { |
| 79 children = [ |
| 80 new NavBarElement(queue: _r.queue) |
| 81 ..children = [ |
| 82 new NavTopMenuElement(queue: _r.queue), |
| 83 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
| 84 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
| 85 new NavMenuElement('sentinel', last: true, queue: _r.queue), |
| 86 new NavNotifyElement(_notifications, queue: _r.queue) |
| 87 ], |
| 88 new DivElement()..classes = const ['content-centered-big'] |
| 89 ..children = [ |
| 90 new HeadingElement.h2() |
| 91 ..text = 'Sentinel: #{_sentinel.valueAsString}', |
| 92 new HRElement(), |
| 93 new DivElement() |
| 94 ..text = _sentinelKindToDescription(_sentinel.kind), |
| 95 new HRElement(), |
| 96 new ViewFooterElement(queue: _r.queue) |
| 97 ] |
| 98 ]; |
| 99 } |
| 100 |
| 101 static String _sentinelKindToDescription(M.SentinelKind kind) { |
| 102 switch (kind) { |
| 103 case M.SentinelKind.collected: |
| 104 return 'This object has been reclaimed by the garbage collector.'; |
| 105 case M.SentinelKind.expired: |
| 106 return 'The handle to this object has expired. ' |
| 107 'Consider refreshing the page.'; |
| 108 case M.SentinelKind.notInitialized: |
| 109 return 'This object will be initialized once it is accessed by ' |
| 110 'the program.'; |
| 111 case M.SentinelKind.initializing: |
| 112 return 'This object is currently being initialized.'; |
| 113 case M.SentinelKind.optimizedOut: |
| 114 return 'This object is no longer needed and has been removed by the ' |
| 115 'optimizing compiler.'; |
| 116 case M.SentinelKind.free: |
| 117 return ''; |
| 118 } |
| 119 throw new Exception('Unknown SentinelKind: $kind'); |
| 120 } |
| 121 |
| 122 } |
OLD | NEW |