| 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 'dart:html'; | 7 import 'dart:html'; |
| 8 import 'package:logging/logging.dart'; | 8 import 'package:logging/logging.dart'; |
| 9 import 'package:polymer/polymer.dart'; | 9 import 'package:polymer/polymer.dart'; |
| 10 import 'observatory_element.dart'; | 10 import 'observatory_element.dart'; |
| 11 import 'package:observatory/service.dart'; | 11 import 'package:observatory/service.dart'; |
| 12 | 12 |
| 13 @CustomTag('service-ref') | 13 @CustomTag('service-ref') |
| 14 class ServiceRefElement extends ObservatoryElement { | 14 class ServiceRefElement extends ObservatoryElement { |
| 15 @published ServiceObject ref; | 15 @published ServiceObject ref; |
| 16 @published bool internal = false; | 16 @published bool internal = false; |
| 17 @published String expandKey; |
| 17 ServiceRefElement.created() : super.created(); | 18 ServiceRefElement.created() : super.created(); |
| 18 | 19 |
| 19 void refChanged(oldValue) { | 20 void refChanged(oldValue) { |
| 20 notifyPropertyChange(#url, "", url); | 21 notifyPropertyChange(#url, "", url); |
| 21 notifyPropertyChange(#name, [], name); | 22 notifyPropertyChange(#name, [], name); |
| 22 notifyPropertyChange(#nameIsEmpty, 0, 1); | 23 notifyPropertyChange(#nameIsEmpty, 0, 1); |
| 23 notifyPropertyChange(#hoverText, "", hoverText); | 24 notifyPropertyChange(#hoverText, "", hoverText); |
| 24 } | 25 } |
| 25 | 26 |
| 26 String get url { | 27 String get url { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 54 // Workaround isEmpty not being useable due to missing @MirrorsUsed. | 55 // Workaround isEmpty not being useable due to missing @MirrorsUsed. |
| 55 bool get nameIsEmpty { | 56 bool get nameIsEmpty { |
| 56 return (name == null) || name.isEmpty; | 57 return (name == null) || name.isEmpty; |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 | 60 |
| 60 | 61 |
| 61 @CustomTag('any-service-ref') | 62 @CustomTag('any-service-ref') |
| 62 class AnyServiceRefElement extends ObservatoryElement { | 63 class AnyServiceRefElement extends ObservatoryElement { |
| 63 @published ServiceObject ref; | 64 @published ServiceObject ref; |
| 65 @published String expandKey; |
| 64 AnyServiceRefElement.created() : super.created(); | 66 AnyServiceRefElement.created() : super.created(); |
| 65 | 67 |
| 66 Element _constructElementForRef() { | 68 Element _constructElementForRef() { |
| 67 var type = ref.type; | 69 var type = ref.type; |
| 68 switch (type) { | 70 switch (type) { |
| 69 case 'Class': | 71 case 'Class': |
| 70 ServiceRefElement element = new Element.tag('class-ref'); | 72 ServiceRefElement element = new Element.tag('class-ref'); |
| 71 element.ref = ref; | 73 element.ref = ref; |
| 72 return element; | 74 return element; |
| 73 case 'Code': | 75 case 'Code': |
| (...skipping 25 matching lines...) Expand all Loading... |
| 99 element.ref = ref; | 101 element.ref = ref; |
| 100 return element; | 102 return element; |
| 101 case 'Script': | 103 case 'Script': |
| 102 ServiceRefElement element = new Element.tag('script-ref'); | 104 ServiceRefElement element = new Element.tag('script-ref'); |
| 103 element.ref = ref; | 105 element.ref = ref; |
| 104 return element; | 106 return element; |
| 105 case 'Instance': | 107 case 'Instance': |
| 106 case 'Sentinel': | 108 case 'Sentinel': |
| 107 ServiceRefElement element = new Element.tag('instance-ref'); | 109 ServiceRefElement element = new Element.tag('instance-ref'); |
| 108 element.ref = ref; | 110 element.ref = ref; |
| 111 if (expandKey != null) { |
| 112 element.expandKey = expandKey; |
| 113 } |
| 109 return element; | 114 return element; |
| 110 default: | 115 default: |
| 111 SpanElement element = new Element.tag('span'); | 116 SpanElement element = new Element.tag('span'); |
| 112 element.text = "<<Unknown service ref: $ref>>"; | 117 element.text = "<<Unknown service ref: $ref>>"; |
| 113 return element; | 118 return element; |
| 114 } | 119 } |
| 115 } | 120 } |
| 116 | 121 |
| 117 refChanged(oldValue) { | 122 refChanged(oldValue) { |
| 118 // Remove the current view. | 123 // Remove the current view. |
| 119 children.clear(); | 124 children.clear(); |
| 120 if (ref == null) { | 125 if (ref == null) { |
| 121 Logger.root.info('Viewing null object.'); | 126 Logger.root.info('Viewing null object.'); |
| 122 return; | 127 return; |
| 123 } | 128 } |
| 124 var type = ref.type; | 129 var type = ref.type; |
| 125 var element = _constructElementForRef(); | 130 var element = _constructElementForRef(); |
| 126 if (element == null) { | 131 if (element == null) { |
| 127 Logger.root.info('Unable to find a ref element for \'${type}\''); | 132 Logger.root.info('Unable to find a ref element for \'${type}\''); |
| 128 return; | 133 return; |
| 129 } | 134 } |
| 130 children.add(element); | 135 children.add(element); |
| 131 } | 136 } |
| 132 } | 137 } |
| 133 | 138 |
| 134 @CustomTag('object-ref') | 139 @CustomTag('object-ref') |
| 135 class ObjectRefElement extends ServiceRefElement { | 140 class ObjectRefElement extends ServiceRefElement { |
| 136 ObjectRefElement.created() : super.created(); | 141 ObjectRefElement.created() : super.created(); |
| 137 } | 142 } |
| OLD | NEW |