| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of app; | 5 part of app; |
| 6 | 6 |
| 7 /// A [Pane] controls the user interface of Observatory. At any given time | 7 /// A [Pane] controls the user interface of Observatory. At any given time |
| 8 /// one pane will be the current pane. Panes are registered at startup. | 8 /// one pane will be the current pane. Panes are registered at startup. |
| 9 /// When the user navigates within the application, each pane is asked if it | 9 /// When the user navigates within the application, each pane is asked if it |
| 10 /// can handle the current location, the first pane to say yes, wins. | 10 /// can handle the current location, the first pane to say yes, wins. |
| 11 abstract class Pane extends Observable { | 11 abstract class Pane extends Observable { |
| 12 final ObservatoryApplication app; | 12 final ObservatoryApplication app; |
| 13 | 13 |
| 14 @observable ObservatoryElement element; | 14 @observable ObservatoryElement element; |
| 15 | 15 |
| 16 Pane(this.app); | 16 Pane(this.app); |
| 17 | 17 |
| 18 /// Called when the pane is installed, this callback must initialize | 18 /// Called when the pane is installed, this callback must initialize |
| 19 /// [element]. | 19 /// [element]. |
| 20 void onInstall(); | 20 void onInstall(); |
| 21 | 21 |
| 22 /// Called when the pane is uninstalled, this callback must clear | 22 /// Called when the pane is uninstalled, this callback must clear |
| 23 /// [element]. | 23 /// [element]. |
| 24 void onUninstall() { | 24 void onUninstall() { |
| 25 element = null; | 25 element = null; |
| 26 } | 26 } |
| 27 | 27 |
| 28 /// Called when the pane should update its state based on [url]. | 28 /// Called when the pane should update its state based on [url]. |
| 29 /// NOTE: Only called when the pane is installed. | 29 /// NOTE: Only called when the pane is installed. |
| 30 void visit(String url); | 30 void visit(String url, Map args); |
| 31 | 31 |
| 32 /// Called to test whether this pane can visit [url]. | 32 /// Called to test whether this pane can visit [url]. |
| 33 bool canVisit(String url); | 33 bool canVisit(String url); |
| 34 } | 34 } |
| 35 | 35 |
| 36 /// A general service object viewer. | 36 /// A general service object viewer. |
| 37 class ServiceObjectPane extends Pane { | 37 class ServiceObjectPane extends Pane { |
| 38 ServiceObjectPane(app) : super(app); | 38 ServiceObjectPane(app) : super(app); |
| 39 | 39 |
| 40 void onInstall() { | 40 void onInstall() { |
| 41 if (element == null) { | 41 if (element == null) { |
| 42 /// Lazily create pane. | 42 /// Lazily create pane. |
| 43 element = new Element.tag('service-view'); | 43 element = new Element.tag('service-view'); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 void visit(String url) { | 47 void visit(String url, Map args) { |
| 48 assert(element != null); | 48 assert(element != null); |
| 49 assert(canVisit(url)); | 49 assert(canVisit(url)); |
| 50 if (url == '') { | 50 if (url == '') { |
| 51 // Nothing requested. | 51 // Nothing requested. |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 /// Request url from VM and display it. | 54 /// Request url from VM and display it. |
| 55 app.vm.get(url).then((obj) { | 55 app.vm.get(url).then((obj) { |
| 56 ServiceObjectViewElement pane = element; | 56 ServiceObjectViewElement pane = element; |
| 57 pane.object = obj; | 57 pane.object = obj; |
| 58 pane.args = toObservable(args); |
| 58 }).catchError((e) { | 59 }).catchError((e) { |
| 59 Logger.root.severe('ServiceObjectPane visit error: $e'); | 60 Logger.root.severe('ServiceObjectPane visit error: $e'); |
| 60 }); | 61 }); |
| 61 } | 62 } |
| 62 | 63 |
| 63 /// Catch all. | 64 /// Catch all. |
| 64 bool canVisit(String url) => true; | 65 bool canVisit(String url) => true; |
| 65 } | 66 } |
| 66 | 67 |
| 67 /// Class tree pane. | 68 /// Class tree pane. |
| 68 class ClassTreePane extends Pane { | 69 class ClassTreePane extends Pane { |
| 69 static const _urlPrefix = 'class-tree/'; | 70 static const _urlPrefix = 'class-tree/'; |
| 70 | 71 |
| 71 ClassTreePane(app) : super(app); | 72 ClassTreePane(app) : super(app); |
| 72 | 73 |
| 73 void onInstall() { | 74 void onInstall() { |
| 74 if (element == null) { | 75 if (element == null) { |
| 75 element = new Element.tag('class-tree'); | 76 element = new Element.tag('class-tree'); |
| 76 } | 77 } |
| 77 } | 78 } |
| 78 | 79 |
| 79 void visit(String url) { | 80 void visit(String url, Map args) { |
| 80 assert(element != null); | 81 assert(element != null); |
| 81 assert(canVisit(url)); | 82 assert(canVisit(url)); |
| 82 // ClassTree urls are 'class-tree/isolate-id', chop off prefix, leaving | 83 // ClassTree urls are 'class-tree/isolate-id', chop off prefix, leaving |
| 83 // isolate url. | 84 // isolate url. |
| 84 url = url.substring(_urlPrefix.length); | 85 url = url.substring(_urlPrefix.length); |
| 85 /// Request the isolate url. | 86 /// Request the isolate url. |
| 86 app.vm.get(url).then((i) { | 87 app.vm.get(url).then((i) { |
| 87 if (element != null) { | 88 if (element != null) { |
| 88 /// Update the pane. | 89 /// Update the pane. |
| 89 ClassTreeElement pane = element; | 90 ClassTreeElement pane = element; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 101 class ErrorViewPane extends Pane { | 102 class ErrorViewPane extends Pane { |
| 102 ErrorViewPane(app) : super(app); | 103 ErrorViewPane(app) : super(app); |
| 103 | 104 |
| 104 void onInstall() { | 105 void onInstall() { |
| 105 if (element == null) { | 106 if (element == null) { |
| 106 /// Lazily create pane. | 107 /// Lazily create pane. |
| 107 element = new Element.tag('service-view'); | 108 element = new Element.tag('service-view'); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 | 111 |
| 111 void visit(String url) { | 112 void visit(String url, Map args) { |
| 112 assert(element != null); | 113 assert(element != null); |
| 113 assert(canVisit(url)); | 114 assert(canVisit(url)); |
| 114 (element as ServiceObjectViewElement).object = app.lastErrorOrException; | 115 (element as ServiceObjectViewElement).object = app.lastErrorOrException; |
| 115 } | 116 } |
| 116 | 117 |
| 117 bool canVisit(String url) => url.startsWith('error/'); | 118 bool canVisit(String url) => url.startsWith('error/'); |
| 118 } | 119 } |
| 119 | 120 |
| 120 class VMConnectPane extends Pane { | 121 class VMConnectPane extends Pane { |
| 121 VMConnectPane(app) : super(app); | 122 VMConnectPane(app) : super(app); |
| 122 | 123 |
| 123 void onInstall() { | 124 void onInstall() { |
| 124 if (element == null) { | 125 if (element == null) { |
| 125 element = new Element.tag('vm-connect'); | 126 element = new Element.tag('vm-connect'); |
| 126 } | 127 } |
| 127 assert(element != null); | 128 assert(element != null); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void visit(String url) { | 131 void visit(String url, Map args) { |
| 131 assert(element != null); | 132 assert(element != null); |
| 132 assert(canVisit(url)); | 133 assert(canVisit(url)); |
| 133 } | 134 } |
| 134 | 135 |
| 135 bool canVisit(String url) => url.startsWith('vm-connect/'); | 136 bool canVisit(String url) => url.startsWith('vm-connect/'); |
| 136 } | 137 } |
| OLD | NEW |