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); | |
28 assert(cls != null); | 27 assert(cls != null); |
29 ClassRefElement e = document.createElement(tag.name); | 28 ClassRefElement e = document.createElement(tag.name); |
30 e._r = new RenderingScheduler(e, queue: queue); | 29 e._r = new RenderingScheduler(e, queue: queue); |
31 e._isolate = isolate; | 30 e._isolate = isolate; |
32 e._class = cls; | 31 e._class = cls; |
33 return e; | 32 return e; |
34 } | 33 } |
35 | 34 |
36 ClassRefElement.created() : super.created(); | 35 ClassRefElement.created() : super.created(); |
37 | 36 |
38 @override | 37 @override |
39 void attached() { | 38 void attached() { |
40 super.attached(); | 39 super.attached(); |
41 _r.enable(); | 40 _r.enable(); |
42 } | 41 } |
43 | 42 |
44 @override | 43 @override |
45 void detached() { | 44 void detached() { |
46 super.detached(); | 45 super.detached(); |
47 _r.disable(notify: true); | 46 _r.disable(notify: true); |
48 children = []; | 47 children = []; |
49 } | 48 } |
50 | 49 |
51 void render() { | 50 void render() { |
52 children = [ | 51 children = [ |
53 new AnchorElement(href: Uris.inspect(_isolate, object: _class)) | 52 new AnchorElement( |
54 ..text = _class.name | 53 href: (_isolate == null) |
| 54 ? null |
| 55 : Uris.inspect(_isolate, object: _class))..text = _class.name |
55 ]; | 56 ]; |
56 } | 57 } |
57 } | 58 } |
OLD | NEW |