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

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

Issue 2211603002: Centralized event streams (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with master Created 4 years, 4 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
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 library flag_list_element; 5 library flag_list_element;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'dart:async'; 8 import 'dart:async';
9 import 'package:observatory/models.dart' as M; 9 import 'package:observatory/models.dart' as M;
10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
(...skipping 15 matching lines...) Expand all
26 NavRefreshElement.tag, 26 NavRefreshElement.tag,
27 NavTopMenuElement.tag, 27 NavTopMenuElement.tag,
28 NavVMMenuElement.tag, 28 NavVMMenuElement.tag,
29 ViewFooterElement.tag,]); 29 ViewFooterElement.tag,]);
30 30
31 RenderingScheduler _r; 31 RenderingScheduler _r;
32 32
33 Stream<RenderedEvent<FlagListElement>> get onRendered => _r.onRendered; 33 Stream<RenderedEvent<FlagListElement>> get onRendered => _r.onRendered;
34 34
35 M.VMRef _vm; 35 M.VMRef _vm;
36 Stream<M.VMUpdateEvent> _vmUpdates; 36 M.EventRepository _events;
37 M.FlagsRepository _repository; 37 M.FlagsRepository _repository;
38 M.NotificationRepository _notifications; 38 M.NotificationRepository _notifications;
39 Iterable<M.Flag> _flags; 39 Iterable<M.Flag> _flags;
40 40
41 M.VMRef get vm => _vm; 41 M.VMRef get vm => _vm;
42 42
43 factory FlagListElement(M.VMRef vm, 43 factory FlagListElement(M.VMRef vm,
44 Stream<M.VMUpdateEvent> vmUpdates, 44 M.EventRepository events,
45 M.FlagsRepository repository, 45 M.FlagsRepository repository,
46 M.NotificationRepository notifications, 46 M.NotificationRepository notifications,
47 {RenderingQueue queue}) { 47 {RenderingQueue queue}) {
48 assert(vm != null); 48 assert(vm != null);
49 assert(vmUpdates != null); 49 assert(events != null);
50 assert(repository != null); 50 assert(repository != null);
51 assert(notifications != null); 51 assert(notifications != null);
52 FlagListElement e = document.createElement(tag.name); 52 FlagListElement e = document.createElement(tag.name);
53 e._r = new RenderingScheduler(e, queue: queue); 53 e._r = new RenderingScheduler(e, queue: queue);
54 e._vm = vm; 54 e._vm = vm;
55 e._vmUpdates = vmUpdates; 55 e._events = events;
56 e._repository = repository; 56 e._repository = repository;
57 e._notifications = notifications; 57 e._notifications = notifications;
58 return e; 58 return e;
59 } 59 }
60 60
61 FlagListElement.created() : super.created(); 61 FlagListElement.created() : super.created();
62 62
63 @override 63 @override
64 void attached() { 64 void attached() {
65 super.attached(); 65 super.attached();
66 _refresh();
66 _r.enable(); 67 _r.enable();
67 _refresh();
68 } 68 }
69 69
70 @override 70 @override
71 void detached() { 71 void detached() {
72 super.detached(); 72 super.detached();
73 children = []; 73 children = [];
74 _r.disable(notify: true); 74 _r.disable(notify: true);
75 } 75 }
76 76
77 void render() { 77 void render() {
(...skipping 18 matching lines...) Expand all
96 content.add(new HeadingElement.h2()..text = 'None'); 96 content.add(new HeadingElement.h2()..text = 'None');
97 } else { 97 } else {
98 content.addAll(unmodified.expand(_renderFlag)); 98 content.addAll(unmodified.expand(_renderFlag));
99 } 99 }
100 } 100 }
101 101
102 children = [ 102 children = [
103 new NavBarElement(queue: _r.queue) 103 new NavBarElement(queue: _r.queue)
104 ..children = [ 104 ..children = [
105 new NavTopMenuElement(queue: _r.queue), 105 new NavTopMenuElement(queue: _r.queue),
106 new NavVMMenuElement(_vm, _vmUpdates, queue: _r.queue), 106 new NavVMMenuElement(_vm, _events, queue: _r.queue),
107 new NavMenuElement('flags', link: Uris.flags(), last: true, 107 new NavMenuElement('flags', link: Uris.flags(), last: true,
108 queue: _r.queue), 108 queue: _r.queue),
109 new NavRefreshElement(queue: _r.queue) 109 new NavRefreshElement(queue: _r.queue)
110 ..onRefresh.listen((e) async { 110 ..onRefresh.listen((e) async {
111 e.element.disabled = true; 111 e.element.disabled = true;
112 try { 112 try {
113 await _refresh(); 113 await _refresh();
114 } finally { 114 } finally {
115 e.element.disabled = false; 115 e.element.disabled = false;
116 } 116 }
117 }), 117 }),
118 new NavNotifyElement(_notifications, queue: _r.queue) 118 new NavNotifyElement(_notifications, queue: _r.queue)
119 ], 119 ],
120 new DivElement() 120 new DivElement()
121 ..classes = ['content-centered'] 121 ..classes = ['content-centered']
122 ..children = content, 122 ..children = content,
123 new ViewFooterElement(queue: _r.queue) 123 new ViewFooterElement(queue: _r.queue)
124 ]; 124 ];
125 } 125 }
126 126
127 Future _refresh() async { 127 Future _refresh() {
128 _flags = await _repository.list(_vm); 128 return _repository.list().then((flags) {
129 _r.dirty(); 129 _flags = flags;
130 _r.dirty();
131 });
130 } 132 }
131 133
132 static bool _isModified(M.Flag flag) => flag.modified; 134 static bool _isModified(M.Flag flag) => flag.modified;
133 static bool _isUnmodified(M.Flag flag) => !flag.modified; 135 static bool _isUnmodified(M.Flag flag) => !flag.modified;
134 136
135 static List<Element> _renderFlag(M.Flag flag) { 137 static List<Element> _renderFlag(M.Flag flag) {
136 return [ 138 return [
137 new SpanElement()..classes = const ['comment'] 139 new SpanElement()..classes = const ['comment']
138 ..text = '// ${flag.comment}', 140 ..text = '// ${flag.comment}',
139 new DivElement()..classes = flag.modified ? const ['flag', 'modified'] 141 new DivElement()..classes = flag.modified ? const ['flag', 'modified']
140 : const ['flag', 'unmodified'] 142 : const ['flag', 'unmodified']
141 ..children = [ 143 ..children = [
142 new SpanElement()..classes = const ['name'] 144 new SpanElement()..classes = const ['name']
143 ..text = flag.name, 145 ..text = flag.name,
144 new SpanElement()..text = '=', 146 new SpanElement()..text = '=',
145 new SpanElement()..classes = const ['value'] 147 new SpanElement()..classes = const ['value']
146 ..text = flag.valueAsString ?? 'NULL' 148 ..text = flag.valueAsString ?? 'NULL'
147 ], 149 ],
148 new BRElement(), 150 new BRElement(),
149 ]; 151 ];
150 } 152 }
151 } 153 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/error_ref_wrapper.dart ('k') | runtime/observatory/lib/src/elements/function_ref.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698