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

Unified Diff: runtime/observatory/lib/src/elements/vm_connect_target_wrapper.dart

Issue 2169313002: Converted Observatory vm-connect-target element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Added Uris helper function Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/elements/vm_connect_target_wrapper.dart
diff --git a/runtime/observatory/lib/src/elements/vm_connect_target_wrapper.dart b/runtime/observatory/lib/src/elements/vm_connect_target_wrapper.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1034061535c83ac9306d3287243e89968f31391b
--- /dev/null
+++ b/runtime/observatory/lib/src/elements/vm_connect_target_wrapper.dart
@@ -0,0 +1,77 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:html';
+import 'package:observatory/app.dart';
+import 'package:observatory/service_html.dart';
+import 'package:observatory/src/elements/helpers/tag.dart';
+import 'package:observatory/src/elements/shims/binding.dart';
+import 'package:observatory/src/elements/vm_connect_target.dart';
+
+class VMConnectTargetElementWrapper extends HtmlElement {
+ static final binder = new Binder<VMConnectTargetElementWrapper>(
+ const [const Binding('target')]);
+
+ static const tag =
+ const Tag<VMConnectTargetElementWrapper>('vm-connect-target');
+
+ WebSocketVMTarget _target;
+ WebSocketVMTarget get target => _target;
+ void set target(WebSocketVMTarget target) { _target = target; render(); }
+
+ VMConnectTargetElementWrapper.created() : super.created() {
+ binder.registerCallback(this);
+ createShadowRoot();
+ render();
+ }
+
+ @override
+ void attached() {
+ super.attached();
+ render();
+ }
+
+ void render() {
+ if (target == null) return;
+
+ shadowRoot.children = [
+ new StyleElement()
+ ..text = '''
+ vm-connect-target-wrapped > button.delete-button {
+ margin-left: 0.28em;
+ padding: 4px;
+ background: transparent;
+ border: none !important;
+ }
+
+ vm-connect-target-wrapped > button.delete-button:hover {
+ background: #ff0000;
+ }''',
+ new VMConnectTargetElement(target, current: current,
+ queue: application.queue)
+ ..onConnect.listen(connectToVm)
+ ..onDelete.listen(deleteVm)
+ ];
+ }
+
+ static ObservatoryApplication get application => ObservatoryApplication.app;
+
+ bool get current {
+ if (application.vm == null) { return false; }
+ return (application.vm as WebSocketVM).target == target;
+ }
+
+ static void connectToVm(TargetEvent event) {
+ WebSocketVM currentVM = application.vm;
+ if ((currentVM == null) ||
+ currentVM.isDisconnected ||
+ (currentVM.target != event.target)) {
+ application.vm = new WebSocketVM(event.target);
+ }
+ }
+
+ static void deleteVm(TargetEvent event) {
+ application.targets.remove(event.target);
+ }
+}
« no previous file with comments | « runtime/observatory/lib/src/elements/vm_connect_target.dart ('k') | runtime/observatory/observatory_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698