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

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

Issue 2970443002: Disable expansion of VirtualTree and VirtualCollection items (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/field_ref.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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/curly_block.dart'; 8 import 'package:observatory/src/elements/curly_block.dart';
9 import 'package:observatory/src/elements/helpers/any_ref.dart'; 9 import 'package:observatory/src/elements/helpers/any_ref.dart';
10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
11 import 'package:observatory/src/elements/helpers/tag.dart'; 11 import 'package:observatory/src/elements/helpers/tag.dart';
12 import 'package:observatory/src/elements/helpers/uris.dart'; 12 import 'package:observatory/src/elements/helpers/uris.dart';
13 13
14 class ContextRefElement extends HtmlElement implements Renderable { 14 class ContextRefElement extends HtmlElement implements Renderable {
15 static const tag = const Tag<ContextRefElement>('context-ref', 15 static const tag = const Tag<ContextRefElement>('context-ref',
16 dependencies: const [CurlyBlockElement.tag]); 16 dependencies: const [CurlyBlockElement.tag]);
17 17
18 RenderingScheduler<ContextRefElement> _r; 18 RenderingScheduler<ContextRefElement> _r;
19 19
20 Stream<RenderedEvent<ContextRefElement>> get onRendered => _r.onRendered; 20 Stream<RenderedEvent<ContextRefElement>> get onRendered => _r.onRendered;
21 21
22 M.IsolateRef _isolate; 22 M.IsolateRef _isolate;
23 M.ContextRef _context; 23 M.ContextRef _context;
24 M.ObjectRepository _objects; 24 M.ObjectRepository _objects;
25 M.Context _loadedContext; 25 M.Context _loadedContext;
26 bool _expandable;
26 bool _expanded = false; 27 bool _expanded = false;
27 28
28 M.IsolateRef get isolate => _isolate; 29 M.IsolateRef get isolate => _isolate;
29 M.ContextRef get context => _context; 30 M.ContextRef get context => _context;
30 31
31 factory ContextRefElement( 32 factory ContextRefElement(
32 M.IsolateRef isolate, M.ContextRef context, M.ObjectRepository objects, 33 M.IsolateRef isolate, M.ContextRef context, M.ObjectRepository objects,
33 {RenderingQueue queue}) { 34 {RenderingQueue queue, bool expandable: true}) {
34 assert(isolate != null); 35 assert(isolate != null);
35 assert(context != null); 36 assert(context != null);
36 assert(objects != null); 37 assert(objects != null);
37 ContextRefElement e = document.createElement(tag.name); 38 ContextRefElement e = document.createElement(tag.name);
38 e._r = new RenderingScheduler(e, queue: queue); 39 e._r = new RenderingScheduler(e, queue: queue);
39 e._isolate = isolate; 40 e._isolate = isolate;
40 e._context = context; 41 e._context = context;
41 e._objects = objects; 42 e._objects = objects;
43 e._expandable = expandable;
42 return e; 44 return e;
43 } 45 }
44 46
45 ContextRefElement.created() : super.created(); 47 ContextRefElement.created() : super.created();
46 48
47 @override 49 @override
48 void attached() { 50 void attached() {
49 super.attached(); 51 super.attached();
50 _r.enable(); 52 _r.enable();
51 } 53 }
52 54
53 @override 55 @override
54 void detached() { 56 void detached() {
55 super.detached(); 57 super.detached();
56 _r.disable(notify: true); 58 _r.disable(notify: true);
57 children = []; 59 children = [];
58 } 60 }
59 61
60 Future _refresh() async { 62 Future _refresh() async {
61 _loadedContext = await _objects.get(_isolate, _context.id); 63 _loadedContext = await _objects.get(_isolate, _context.id);
62 _r.dirty(); 64 _r.dirty();
63 } 65 }
64 66
65 void render() { 67 void render() {
66 children = [ 68 var children = [
67 new AnchorElement(href: Uris.inspect(_isolate, object: _context)) 69 new AnchorElement(href: Uris.inspect(_isolate, object: _context))
68 ..children = [ 70 ..children = [
69 new SpanElement() 71 new SpanElement()
70 ..classes = ['emphasize'] 72 ..classes = ['emphasize']
71 ..text = 'Context', 73 ..text = 'Context',
72 new SpanElement()..text = ' (${_context.length})', 74 new SpanElement()..text = ' (${_context.length})',
73 ], 75 ],
74 new SpanElement()..text = ' ',
75 new CurlyBlockElement(expanded: _expanded, queue: _r.queue)
76 ..content = [
77 new DivElement()
78 ..classes = ['indent']
79 ..children = _createValue()
80 ]
81 ..onToggle.listen((e) async {
82 _expanded = e.control.expanded;
83 if (_expanded) {
84 e.control.disabled = true;
85 await _refresh();
86 e.control.disabled = false;
87 }
88 })
89 ]; 76 ];
77 if (_expandable) {
78 children.addAll([
79 new SpanElement()..text = ' ',
80 new CurlyBlockElement(expanded: _expanded, queue: _r.queue)
81 ..content = [
82 new DivElement()
83 ..classes = ['indent']
84 ..children = _createValue()
85 ]
86 ..onToggle.listen((e) async {
87 _expanded = e.control.expanded;
88 if (_expanded) {
89 e.control.disabled = true;
90 await _refresh();
91 e.control.disabled = false;
92 }
93 })
94 ]);
95 }
96 this.children = children;
90 } 97 }
91 98
92 List<Element> _createValue() { 99 List<Element> _createValue() {
93 if (_loadedContext == null) { 100 if (_loadedContext == null) {
94 return [new SpanElement()..text = 'Loading...']; 101 return [new SpanElement()..text = 'Loading...'];
95 } 102 }
96 var members = new List<Element>(); 103 var members = new List<Element>();
97 if (_loadedContext.parentContext != null) { 104 if (_loadedContext.parentContext != null) {
98 members.add(new DivElement() 105 members.add(new DivElement()
99 ..classes = ['memberItem'] 106 ..classes = ['memberItem']
(...skipping 28 matching lines...) Expand all
128 ]); 135 ]);
129 } 136 }
130 } 137 }
131 return [ 138 return [
132 new DivElement() 139 new DivElement()
133 ..classes = ['memberList'] 140 ..classes = ['memberList']
134 ..children = members 141 ..children = members
135 ]; 142 ];
136 } 143 }
137 } 144 }
OLDNEW
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/field_ref.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698