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:html'; | 5 import 'dart:html'; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
9 import 'package:observatory/src/elements/helpers/tag.dart'; | 9 import 'package:observatory/src/elements/helpers/tag.dart'; |
10 import 'package:observatory/src/elements/helpers/uris.dart'; | 10 import 'package:observatory/src/elements/helpers/uris.dart'; |
11 | 11 |
12 class ClassRefElement extends HtmlElement implements Renderable { | 12 class ClassRefElement extends HtmlElement implements Renderable { |
13 static const tag = const Tag<ClassRefElement>('class-ref'); | 13 static const tag = const Tag<ClassRefElement>('class-ref'); |
14 | 14 |
15 RenderingScheduler<ClassRefElement> _r; | 15 RenderingScheduler<ClassRefElement> _r; |
16 | 16 |
17 Stream<RenderedEvent<ClassRefElement>> get onRendered => _r.onRendered; | 17 Stream<RenderedEvent<ClassRefElement>> get onRendered => _r.onRendered; |
18 | 18 |
19 M.IsolateRef _isolate; | 19 M.IsolateRef _isolate; |
20 M.ClassRef _class; | 20 M.ClassRef _class; |
21 | 21 |
22 M.IsolateRef get isolate => _isolate; | 22 M.IsolateRef get isolate => _isolate; |
23 M.ClassRef get cls => _class; | 23 M.ClassRef get cls => _class; |
24 | 24 |
25 factory ClassRefElement(M.IsolateRef isolate, M.ClassRef cls, | 25 factory ClassRefElement(M.IsolateRef isolate, M.ClassRef cls, |
26 {RenderingQueue queue}) { | 26 {RenderingQueue queue}) { |
| 27 assert(isolate != null); |
27 assert(cls != null); | 28 assert(cls != null); |
28 ClassRefElement e = document.createElement(tag.name); | 29 ClassRefElement e = document.createElement(tag.name); |
29 e._r = new RenderingScheduler(e, queue: queue); | 30 e._r = new RenderingScheduler(e, queue: queue); |
30 e._isolate = isolate; | 31 e._isolate = isolate; |
31 e._class = cls; | 32 e._class = cls; |
32 return e; | 33 return e; |
33 } | 34 } |
34 | 35 |
35 ClassRefElement.created() : super.created(); | 36 ClassRefElement.created() : super.created(); |
36 | 37 |
37 @override | 38 @override |
38 void attached() { | 39 void attached() { |
39 super.attached(); | 40 super.attached(); |
40 _r.enable(); | 41 _r.enable(); |
41 } | 42 } |
42 | 43 |
43 @override | 44 @override |
44 void detached() { | 45 void detached() { |
45 super.detached(); | 46 super.detached(); |
46 _r.disable(notify: true); | 47 _r.disable(notify: true); |
47 children = []; | 48 children = []; |
48 } | 49 } |
49 | 50 |
50 void render() { | 51 void render() { |
51 children = [ | 52 children = [ |
52 new AnchorElement( | 53 new AnchorElement(href: Uris.inspect(_isolate, object: _class)) |
53 href: (_isolate == null) | 54 ..text = _class.name |
54 ? null | |
55 : Uris.inspect(_isolate, object: _class))..text = _class.name | |
56 ]; | 55 ]; |
57 } | 56 } |
58 } | 57 } |
OLD | NEW |