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

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

Issue 2281903003: Added quicks support to Observatory eval-box element (Closed)
Patch Set: Renamed quicks in quickExpressions Created 4 years, 3 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 eval_box_element; 5 library eval_box_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/any_ref.dart'; 10 import 'package:observatory/src/elements/helpers/any_ref.dart';
(...skipping 11 matching lines...) Expand all
22 22
23 Stream<RenderedEvent<EvalBoxElement>> get onRendered => _r.onRendered; 23 Stream<RenderedEvent<EvalBoxElement>> get onRendered => _r.onRendered;
24 24
25 M.IsolateRef _isolate; 25 M.IsolateRef _isolate;
26 M.ObjectRef _context; 26 M.ObjectRef _context;
27 M.InstanceRepository _instances; 27 M.InstanceRepository _instances;
28 M.EvalRepository _eval; 28 M.EvalRepository _eval;
29 final _results = <_ExpressionDescription>[]; 29 final _results = <_ExpressionDescription>[];
30 String _expression = ''; 30 String _expression = '';
31 bool _multiline; 31 bool _multiline;
32 Iterable<String> _quickExpressions;
32 33
33 M.IsolateRef get isolate => _isolate; 34 M.IsolateRef get isolate => _isolate;
34 M.ObjectRef get context => _context; 35 M.ObjectRef get context => _context;
35 36
36 factory EvalBoxElement(M.IsolateRef isolate, M.ObjectRef context, 37 factory EvalBoxElement(M.IsolateRef isolate, M.ObjectRef context,
37 M.InstanceRepository instances, 38 M.InstanceRepository instances,
38 M.EvalRepository eval, 39 M.EvalRepository eval,
39 {bool multiline: false, RenderingQueue queue}) { 40 {bool multiline: false,
41 Iterable<String> quickExpressions: const [],
42 RenderingQueue queue}) {
40 assert(isolate != null); 43 assert(isolate != null);
41 assert(context != null); 44 assert(context != null);
42 assert(instances != null); 45 assert(instances != null);
43 assert(eval != null); 46 assert(eval != null);
44 assert(multiline != null); 47 assert(multiline != null);
48 assert(quickExpressions != null);
45 EvalBoxElement e = document.createElement(tag.name); 49 EvalBoxElement e = document.createElement(tag.name);
46 e._r = new RenderingScheduler(e, queue: queue); 50 e._r = new RenderingScheduler(e, queue: queue);
47 e._isolate = isolate; 51 e._isolate = isolate;
48 e._context = context; 52 e._context = context;
49 e._instances = instances; 53 e._instances = instances;
50 e._eval = eval; 54 e._eval = eval;
51 e._multiline = multiline; 55 e._multiline = multiline;
56 e._quickExpressions = new List.unmodifiable(quickExpressions);
52 return e; 57 return e;
53 } 58 }
54 59
55 EvalBoxElement.created() : super.created(); 60 EvalBoxElement.created() : super.created();
56 61
57 @override 62 @override
58 void attached() { 63 void attached() {
59 super.attached(); 64 super.attached();
60 _r.enable(); 65 _r.enable();
61 } 66 }
62 67
63 @override 68 @override
64 void detached() { 69 void detached() {
65 super.detached(); 70 super.detached();
66 _r.disable(notify: true); 71 _r.disable(notify: true);
67 children = []; 72 children = [];
68 _results.clear(); 73 _results.clear();
69 } 74 }
70 75
71 void render() { 76 void render() {
72 children = [ 77 children = [
78 new DivElement()..classes = const ['quicks']
79 ..children = _quickExpressions.map((q) =>
80 new ButtonElement()
81 ..text = q
82 ..onClick.listen((_) {
83 _expression = q;
84 _run();
85 })
86 ),
73 new DivElement()..classes = const ['heading'] 87 new DivElement()..classes = const ['heading']
74 ..children = [ 88 ..children = [
75 new FormElement() 89 new FormElement()
76 ..autocomplete = 'on' 90 ..autocomplete = 'on'
77 ..children = [ 91 ..children = [
78 _multiline ? _createEvalTextArea() : _createEvalTextBox(), 92 _multiline ? _createEvalTextArea() : _createEvalTextBox(),
79 new SpanElement()..classes = const ['buttons'] 93 new SpanElement()..classes = const ['buttons']
80 ..children = [ 94 ..children = [
81 _createEvalButton(), 95 _createEvalButton(),
82 _createMultilineCheckbox(), 96 _createMultilineCheckbox(),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 201
188 class _ExpressionDescription { 202 class _ExpressionDescription {
189 final String expression; 203 final String expression;
190 final M.ObjectRef value; 204 final M.ObjectRef value;
191 bool get isPending => value == null; 205 bool get isPending => value == null;
192 206
193 _ExpressionDescription(this.expression, this.value); 207 _ExpressionDescription(this.expression, this.value);
194 _ExpressionDescription.pending(this.expression) 208 _ExpressionDescription.pending(this.expression)
195 : value = null; 209 : value = null;
196 } 210 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/css/shared.css ('k') | runtime/observatory/lib/src/elements/eval_box_wrapper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698