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 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/nav_bar.dart'; | 10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
11 import 'package:observatory/src/elements/helpers/nav_menu.dart'; | 11 import 'package:observatory/src/elements/helpers/nav_menu.dart'; |
12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
13 import 'package:observatory/src/elements/helpers/tag.dart'; | 13 import 'package:observatory/src/elements/helpers/tag.dart'; |
14 import 'package:observatory/src/elements/nav/notify.dart'; | 14 import 'package:observatory/src/elements/nav/notify.dart'; |
15 import 'package:observatory/src/elements/nav/refresh.dart'; | 15 import 'package:observatory/src/elements/nav/refresh.dart'; |
16 import 'package:observatory/src/elements/nav/top_menu.dart'; | 16 import 'package:observatory/src/elements/nav/top_menu.dart'; |
17 import 'package:observatory/src/elements/nav/vm_menu.dart'; | 17 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
18 import 'package:observatory/src/elements/view_footer.dart'; | 18 import 'package:observatory/src/elements/view_footer.dart'; |
19 | 19 |
20 class FlagListElement extends HtmlElement implements Renderable { | 20 class FlagListElement extends HtmlElement implements Renderable { |
21 static const tag = const Tag<FlagListElement>('flag-list', | 21 static const tag = |
22 dependencies: const [NavNotifyElement.tag, | 22 const Tag<FlagListElement>('flag-list', dependencies: const [ |
23 NavRefreshElement.tag, | 23 NavNotifyElement.tag, |
24 NavTopMenuElement.tag, | 24 NavRefreshElement.tag, |
25 NavVMMenuElement.tag, | 25 NavTopMenuElement.tag, |
26 ViewFooterElement.tag,]); | 26 NavVMMenuElement.tag, |
| 27 ViewFooterElement.tag, |
| 28 ]); |
27 | 29 |
28 RenderingScheduler _r; | 30 RenderingScheduler _r; |
29 | 31 |
30 Stream<RenderedEvent<FlagListElement>> get onRendered => _r.onRendered; | 32 Stream<RenderedEvent<FlagListElement>> get onRendered => _r.onRendered; |
31 | 33 |
32 M.VMRef _vm; | 34 M.VMRef _vm; |
33 M.EventRepository _events; | 35 M.EventRepository _events; |
34 M.FlagsRepository _repository; | 36 M.FlagsRepository _repository; |
35 M.NotificationRepository _notifications; | 37 M.NotificationRepository _notifications; |
36 Iterable<M.Flag> _flags; | 38 Iterable<M.Flag> _flags; |
37 | 39 |
38 M.VMRef get vm => _vm; | 40 M.VMRef get vm => _vm; |
39 | 41 |
40 factory FlagListElement(M.VMRef vm, | 42 factory FlagListElement(M.VMRef vm, M.EventRepository events, |
41 M.EventRepository events, | 43 M.FlagsRepository repository, M.NotificationRepository notifications, |
42 M.FlagsRepository repository, | 44 {RenderingQueue queue}) { |
43 M.NotificationRepository notifications, | |
44 {RenderingQueue queue}) { | |
45 assert(vm != null); | 45 assert(vm != null); |
46 assert(events != null); | 46 assert(events != null); |
47 assert(repository != null); | 47 assert(repository != null); |
48 assert(notifications != null); | 48 assert(notifications != null); |
49 FlagListElement e = document.createElement(tag.name); | 49 FlagListElement e = document.createElement(tag.name); |
50 e._r = new RenderingScheduler(e, queue: queue); | 50 e._r = new RenderingScheduler(e, queue: queue); |
51 e._vm = vm; | 51 e._vm = vm; |
52 e._events = events; | 52 e._events = events; |
53 e._repository = repository; | 53 e._repository = repository; |
54 e._notifications = notifications; | 54 e._notifications = notifications; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 _flags = flags; | 124 _flags = flags; |
125 _r.dirty(); | 125 _r.dirty(); |
126 }); | 126 }); |
127 } | 127 } |
128 | 128 |
129 static bool _isModified(M.Flag flag) => flag.modified; | 129 static bool _isModified(M.Flag flag) => flag.modified; |
130 static bool _isUnmodified(M.Flag flag) => !flag.modified; | 130 static bool _isUnmodified(M.Flag flag) => !flag.modified; |
131 | 131 |
132 static List<Element> _renderFlag(M.Flag flag) { | 132 static List<Element> _renderFlag(M.Flag flag) { |
133 return [ | 133 return [ |
134 new SpanElement()..classes = ['comment'] | 134 new SpanElement() |
| 135 ..classes = ['comment'] |
135 ..text = '// ${flag.comment}', | 136 ..text = '// ${flag.comment}', |
136 new DivElement()..classes = flag.modified ? ['flag', 'modified'] | 137 new DivElement() |
137 : ['flag', 'unmodified'] | 138 ..classes = |
| 139 flag.modified ? ['flag', 'modified'] : ['flag', 'unmodified'] |
138 ..children = [ | 140 ..children = [ |
139 new SpanElement()..classes = ['name'] | 141 new SpanElement() |
| 142 ..classes = ['name'] |
140 ..text = flag.name, | 143 ..text = flag.name, |
141 new SpanElement()..text = '=', | 144 new SpanElement()..text = '=', |
142 new SpanElement()..classes = ['value'] | 145 new SpanElement() |
| 146 ..classes = ['value'] |
143 ..text = flag.valueAsString ?? 'NULL' | 147 ..text = flag.valueAsString ?? 'NULL' |
144 ], | 148 ], |
145 new BRElement(), | 149 new BRElement(), |
146 ]; | 150 ]; |
147 } | 151 } |
148 } | 152 } |
OLD | NEW |