| 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 service_ref_element; | 5 library service_ref_element; |
| 6 | 6 |
| 7 import 'package:polymer/polymer.dart'; | 7 import 'package:polymer/polymer.dart'; |
| 8 import 'observatory_element.dart'; | 8 import 'observatory_element.dart'; |
| 9 | 9 |
| 10 @CustomTag('service-ref') | 10 @CustomTag('service-ref') |
| 11 class ServiceRefElement extends ObservatoryElement { | 11 class ServiceRefElement extends ObservatoryElement { |
| 12 @published Map ref; | 12 @published Map ref; |
| 13 @published bool internal = false; | 13 @published bool internal = false; |
| 14 @published Isolate isolate = null; |
| 14 ServiceRefElement.created() : super.created(); | 15 ServiceRefElement.created() : super.created(); |
| 15 | 16 |
| 16 void refChanged(oldValue) { | 17 void refChanged(oldValue) { |
| 17 notifyPropertyChange(#url, "", url); | 18 notifyPropertyChange(#url, "", url); |
| 18 notifyPropertyChange(#name, [], name); | 19 notifyPropertyChange(#name, [], name); |
| 19 notifyPropertyChange(#hoverText, "", hoverText); | 20 notifyPropertyChange(#hoverText, "", hoverText); |
| 20 } | 21 } |
| 21 | 22 |
| 22 String get url { | 23 String get url { |
| 23 if ((app != null) && (ref != null)) { | 24 if (ref != null) { |
| 24 return app.locationManager.currentIsolateRelativeLink(ref['id']); | 25 return relativeLink(ref['id']); |
| 25 } | 26 } |
| 26 return ''; | 27 return ''; |
| 27 } | 28 } |
| 28 | 29 |
| 29 String get hoverText { | 30 String get hoverText { |
| 30 if (ref == null) { | 31 if (ref == null) { |
| 31 return ''; | 32 return ''; |
| 32 } | 33 } |
| 33 // Return the VM name by default. | 34 // Return the VM name by default. |
| 34 var name = ref['name']; | 35 var name = ref['name']; |
| 35 return name != null ? name : ''; | 36 return name != null ? name : ''; |
| 36 } | 37 } |
| 37 | 38 |
| 38 String get name { | 39 String get name { |
| 39 if (ref == null) { | 40 if (ref == null) { |
| 40 return ''; | 41 return ''; |
| 41 } | 42 } |
| 42 String name_key = internal ? 'name' : 'user_name'; | 43 String name_key = internal ? 'name' : 'user_name'; |
| 43 if (ref[name_key] != null) { | 44 if (ref[name_key] != null) { |
| 44 return ref[name_key]; | 45 return ref[name_key]; |
| 45 } else if (ref['name'] != null) { | 46 } else if (ref['name'] != null) { |
| 46 return ref['name']; | 47 return ref['name']; |
| 47 } | 48 } |
| 48 return ''; | 49 return ''; |
| 49 } | 50 } |
| 51 |
| 52 void isolateChanged(oldValue) { |
| 53 notifyPropertyChange(#relativeLink, 0, 1); |
| 54 } |
| 55 |
| 56 @observable |
| 57 String relativeLink(String link) { |
| 58 if (app == null) { |
| 59 return ''; |
| 60 } else if (isolate == null) { |
| 61 return app.locationManager.currentIsolateRelativeLink(link); |
| 62 } else { |
| 63 return app.locationManager.relativeLink(isolate.id, link); |
| 64 } |
| 65 } |
| 50 } | 66 } |
| OLD | NEW |