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

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

Issue 839543002: Revert "Build Observatory with runtime" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
(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 service_ref_element;
6
7 import 'dart:html';
8 import 'package:logging/logging.dart';
9 import 'package:polymer/polymer.dart';
10 import 'observatory_element.dart';
11 import 'package:observatory/service.dart';
12
13 @CustomTag('service-ref')
14 class ServiceRefElement extends ObservatoryElement {
15 @published ServiceObject ref;
16 @published bool internal = false;
17 ServiceRefElement.created() : super.created();
18
19 void refChanged(oldValue) {
20 notifyPropertyChange(#url, "", url);
21 notifyPropertyChange(#name, [], name);
22 notifyPropertyChange(#nameIsEmpty, 0, 1);
23 notifyPropertyChange(#hoverText, "", hoverText);
24 }
25
26 String get url {
27 if (ref == null) {
28 return 'NULL REF';
29 }
30 return gotoLink(ref.link);
31 }
32
33 String get serviceId {
34 if (ref == null) {
35 return 'NULL REF';
36 }
37 return ref.id;
38 }
39
40 String get hoverText {
41 if (ref == null) {
42 return 'NULL REF';
43 }
44 return ref.vmName;
45 }
46
47 String get name {
48 if (ref == null) {
49 return 'NULL REF';
50 }
51 return ref.name;
52 }
53
54 // Workaround isEmpty not being useable due to missing @MirrorsUsed.
55 bool get nameIsEmpty {
56 return (name == null) || name.isEmpty;
57 }
58 }
59
60
61 @CustomTag('any-service-ref')
62 class AnyServiceRefElement extends ObservatoryElement {
63 @published ServiceObject ref;
64 AnyServiceRefElement.created() : super.created();
65
66 Element _constructElementForRef() {
67 var type = ref.type;
68 switch (type) {
69 case 'Class':
70 ServiceRefElement element = new Element.tag('class-ref');
71 element.ref = ref;
72 return element;
73 case 'Code':
74 ServiceRefElement element = new Element.tag('code-ref');
75 element.ref = ref;
76 return element;
77 case 'Context':
78 ServiceRefElement element = new Element.tag('context-ref');
79 element.ref = ref;
80 return element;
81 case 'Error':
82 ServiceRefElement element = new Element.tag('error-ref');
83 element.ref = ref;
84 return element;
85 case 'Field':
86 ServiceRefElement element = new Element.tag('field-ref');
87 element.ref = ref;
88 return element;
89 case 'Function':
90 ServiceRefElement element = new Element.tag('function-ref');
91 element.ref = ref;
92 return element;
93 case 'Library':
94 ServiceRefElement element = new Element.tag('library-ref');
95 element.ref = ref;
96 return element;
97 case 'Object':
98 ServiceRefElement element = new Element.tag('object-ref');
99 element.ref = ref;
100 return element;
101 case 'Script':
102 ServiceRefElement element = new Element.tag('script-ref');
103 element.ref = ref;
104 return element;
105 default:
106 if (ref.isInstance ||
107 ref.isSentinel) { // TODO(rmacnak): Separate this out.
108 ServiceRefElement element = new Element.tag('instance-ref');
109 element.ref = ref;
110 return element;
111 } else {
112 SpanElement element = new Element.tag('span');
113 element.text = "<<Unknown service ref: $ref>>";
114 return element;
115 }
116 }
117 }
118
119 refChanged(oldValue) {
120 // Remove the current view.
121 children.clear();
122 if (ref == null) {
123 Logger.root.info('Viewing null object.');
124 return;
125 }
126 var type = ref.vmType;
127 var element = _constructElementForRef();
128 if (element == null) {
129 Logger.root.info('Unable to find a ref element for \'${type}\'');
130 return;
131 }
132 children.add(element);
133 Logger.root.info('Viewing object of \'${type}\'');
134 }
135 }
136
137 @CustomTag('object-ref')
138 class ObjectRefElement extends ServiceRefElement {
139 ObjectRefElement.created() : super.created();
140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698