| 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 ServiceRefElement.created() : super.created(); | 14 ServiceRefElement.created() : super.created(); |
| 15 | 15 |
| 16 void refChanged(oldValue) { | 16 void refChanged(oldValue) { |
| 17 notifyPropertyChange(#url, "", url); | 17 notifyPropertyChange(#url, "", url); |
| 18 notifyPropertyChange(#name, [], name); | 18 notifyPropertyChange(#name, [], name); |
| 19 notifyPropertyChange(#hoverText, "", hoverText); |
| 19 } | 20 } |
| 20 | 21 |
| 21 String get url { | 22 String get url { |
| 22 if ((app != null) && (ref != null)) { | 23 if ((app != null) && (ref != null)) { |
| 23 return app.locationManager.currentIsolateRelativeLink(ref['id']); | 24 return app.locationManager.currentIsolateRelativeLink(ref['id']); |
| 24 } | 25 } |
| 25 return ''; | 26 return ''; |
| 26 } | 27 } |
| 27 | 28 |
| 29 String get hoverText { |
| 30 if (ref == null) { |
| 31 return ''; |
| 32 } |
| 33 // Return the VM name by default. |
| 34 var name = ref['name']; |
| 35 return name != null ? name : ''; |
| 36 } |
| 37 |
| 28 String get name { | 38 String get name { |
| 29 if (ref == null) { | 39 if (ref == null) { |
| 30 return ''; | 40 return ''; |
| 31 } | 41 } |
| 32 String name_key = internal ? 'name' : 'user_name'; | 42 String name_key = internal ? 'name' : 'user_name'; |
| 33 if (ref[name_key] != null) { | 43 if (ref[name_key] != null) { |
| 34 return ref[name_key]; | 44 return ref[name_key]; |
| 45 } else if (ref['name'] != null) { |
| 46 return ref['name']; |
| 35 } | 47 } |
| 36 return ''; | 48 return ''; |
| 37 } | 49 } |
| 38 } | 50 } |
| OLD | NEW |