| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library isolate_summary_element; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 import 'observatory_element.dart'; | |
| 9 import 'package:observatory/app.dart'; | |
| 10 import 'package:observatory/service.dart'; | |
| 11 import 'package:polymer/polymer.dart'; | |
| 12 | |
| 13 @CustomTag('isolate-summary') | |
| 14 class IsolateSummaryElement extends ObservatoryElement { | |
| 15 IsolateSummaryElement.created() : super.created(); | |
| 16 | |
| 17 @published Isolate isolate; | |
| 18 } | |
| 19 | |
| 20 @CustomTag('isolate-run-state') | |
| 21 class IsolateRunStateElement extends ObservatoryElement { | |
| 22 IsolateRunStateElement.created() : super.created(); | |
| 23 | |
| 24 @published Isolate isolate; | |
| 25 | |
| 26 Future pause(_) { | |
| 27 return isolate.pause(); | |
| 28 } | |
| 29 Future resume(_) { | |
| 30 app.removePauseEvents(isolate); | |
| 31 return isolate.resume(); | |
| 32 } | |
| 33 Future stepInto(_) { | |
| 34 app.removePauseEvents(isolate); | |
| 35 return isolate.stepInto(); | |
| 36 } | |
| 37 Future stepOver(_) { | |
| 38 app.removePauseEvents(isolate); | |
| 39 return isolate.stepOver(); | |
| 40 } | |
| 41 Future stepOut(_) { | |
| 42 app.removePauseEvents(isolate); | |
| 43 return isolate.stepOut(); | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 @CustomTag('isolate-location') | |
| 48 class IsolateLocationElement extends ObservatoryElement { | |
| 49 IsolateLocationElement.created() : super.created(); | |
| 50 | |
| 51 @published Isolate isolate; | |
| 52 } | |
| 53 | |
| 54 @CustomTag('isolate-shared-summary') | |
| 55 class IsolateSharedSummaryElement extends ObservatoryElement { | |
| 56 IsolateSharedSummaryElement.created() : super.created(); | |
| 57 | |
| 58 @published Isolate isolate; | |
| 59 } | |
| 60 | |
| 61 class CounterChart { | |
| 62 var _table = new DataTable(); | |
| 63 var _chart; | |
| 64 | |
| 65 void update(Map counters) { | |
| 66 if (_table.columns == 0) { | |
| 67 // Initialize. | |
| 68 _table.addColumn('string', 'Name'); | |
| 69 _table.addColumn('number', 'Value'); | |
| 70 } | |
| 71 _table.clearRows(); | |
| 72 for (var key in counters.keys) { | |
| 73 var value = double.parse(counters[key].split('%')[0]); | |
| 74 _table.addRow([key, value]); | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 void draw(var element) { | |
| 79 if (_chart == null) { | |
| 80 assert(element != null); | |
| 81 _chart = new Chart('PieChart', element); | |
| 82 } | |
| 83 _chart.draw(_table); | |
| 84 } | |
| 85 } | |
| 86 | |
| 87 @CustomTag('isolate-counter-chart') | |
| 88 class IsolateCounterChartElement extends ObservatoryElement { | |
| 89 IsolateCounterChartElement.created() : super.created(); | |
| 90 | |
| 91 @published ObservableMap counters; | |
| 92 CounterChart chart; | |
| 93 | |
| 94 void countersChanged(oldValue) { | |
| 95 if (counters == null) { | |
| 96 return; | |
| 97 } | |
| 98 // Lazily create the chart. | |
| 99 if (GoogleChart.ready && chart == null) { | |
| 100 chart = new CounterChart(); | |
| 101 } | |
| 102 if (chart == null) { | |
| 103 return; | |
| 104 } | |
| 105 chart.update(counters); | |
| 106 var element = shadowRoot.querySelector('#counterPieChart'); | |
| 107 if (element != null) { | |
| 108 chart.draw(element); | |
| 109 } | |
| 110 } | |
| 111 } | |
| 112 | |
| 113 | |
| 114 | |
| OLD | NEW |