OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016, 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 | |
7 import 'package:observatory/app.dart'; | |
8 import 'package:observatory/service.dart'; | |
9 import 'package:observatory/src/elements/helpers/tag.dart'; | |
10 import 'package:observatory/src/elements/shims/binding.dart'; | |
11 import 'package:observatory/src/elements/nav/isolate_menu.dart'; | |
12 | |
13 @bindable | |
14 class NavIsolateMenuElementWrapper extends HtmlElement { | |
15 static const binder = const Binder<NavIsolateMenuElementWrapper>(const { | |
16 'last': #last, 'isolate': #isolate | |
17 }); | |
18 | |
19 static const tag = | |
20 const Tag<NavIsolateMenuElementWrapper>('isolate-nav-menu'); | |
21 | |
22 bool _last = false; | |
23 Isolate _isolate; | |
24 | |
25 bool get last => _last; | |
26 Isolate get isolate => _isolate; | |
27 | |
28 set last(bool value) { | |
29 _last = value; | |
30 render(); | |
31 } | |
32 set isolate(Isolate value) { | |
33 _isolate = value; | |
34 render(); | |
35 } | |
36 | |
37 NavIsolateMenuElementWrapper.created() : super.created() { | |
38 binder.registerCallback(this); | |
39 _last = _getBoolAttribute('last'); | |
40 createShadowRoot(); | |
41 render(); | |
42 } | |
43 | |
44 @override | |
45 void attached() { | |
46 super.attached(); | |
47 render(); | |
48 } | |
49 | |
50 void render() { | |
51 shadowRoot.children = []; | |
52 if (_isolate == null || _last == null) { | |
53 return; | |
54 } | |
55 | |
56 shadowRoot.children = [ | |
57 new NavIsolateMenuElement(_isolate, app.events, last: _last, | |
58 queue: app.queue) | |
59 ..children = [new ContentElement()] | |
60 ]; | |
61 } | |
62 | |
63 ObservatoryApplication get app => ObservatoryApplication.app; | |
64 | |
65 bool _getBoolAttribute(String name) { | |
66 final String value = getAttribute(name); | |
67 return !(value == null || value == 'false'); | |
68 } | |
69 } | |
OLD | NEW |