Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: runtime/observatory/lib/src/elements/nav/vm_menu.dart

Issue 2170723002: Converted Observatory vm-nav-menu element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Added missing space Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 import 'dart:async';
7 import 'package:observatory/models.dart' as M
8 show VM, IsolateRef, Target, VMUpdateEvent;
9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
10 import 'package:observatory/src/elements/helpers/tag.dart';
11 import 'package:observatory/src/elements/helpers/uris.dart';
12 import 'package:observatory/src/elements/nav/menu.dart';
13 import 'package:observatory/src/elements/nav/menu_item.dart';
14
15 class NavVMMenuElement extends HtmlElement implements Renderable {
16 static const tag = const Tag<NavVMMenuElement>('nav-vm-menu',
17 dependencies: const [NavMenuElement.tag,
18 NavMenuItemElement.tag]);
19
20 RenderingScheduler _r;
21
22 Stream<RenderedEvent<NavVMMenuElement>> get onRendered => _r.onRendered;
23
24 Stream<M.VMUpdateEvent> _updates;
25 StreamSubscription _updatesSubscription;
26
27 bool _last;
28 M.VM _vm;
29 M.Target _target;
30 bool get last => _last;
31 M.VM get vm => _vm;
32 M.Target get target => _target;
33 set last(bool value) => _last = _r.checkAndReact(_last, value);
34
35 factory NavVMMenuElement(M.VM vm, Stream<M.VMUpdateEvent> updates,
36 {bool last: false, M.Target target, RenderingQueue queue}) {
37 assert(vm != null);
38 assert(updates != null);
39 assert(last != null);
40 NavVMMenuElement e = document.createElement(tag.name);
41 e._r = new RenderingScheduler(e, queue: queue);
42 e._vm = vm;
43 e._updates = updates;
44 e._last = last;
45 e._target = target;
46 return e;
47 }
48
49 NavVMMenuElement.created() : super.created() { createShadowRoot(); }
50
51 @override
52 void attached() {
53 super.attached();
54 _r.enable();
55 _updatesSubscription = _updates
56 .listen((M.VMUpdateEvent e) { _vm = e.vm; _r.dirty(); });
57 }
58
59 @override
60 void detached() {
61 super.detached();
62 _r.disable(notify: true);
63 shadowRoot.children = [];
64 assert(_updatesSubscription != null);
65 _updatesSubscription.cancel();
66 _updatesSubscription = null;
67 }
68
69 void render() {
70 final String name = (target == null) ? vm.name
71 : '${vm.name}@${target.name}';
72 /// TODO(cbernaschina) use the isolate repository.
73 shadowRoot.children = [
74 new NavMenuElement(name, link: Uris.vm(), last: last, queue: _r.queue)
75 ..children = (
76 _vm.isolates.map((M.IsolateRef isolate) {
77 return new NavMenuItemElement(isolate.name, queue: _r.queue,
78 link: Uris.inspect(isolate));
79 }).toList()
80 ..add(new ContentElement())
81 )
82 ];
83 }
84 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/service_common.dart ('k') | runtime/observatory/lib/src/elements/nav/vm_menu_wrapper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698