| Index: dart/editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/mobile/MobileMainTab.java
|
| ===================================================================
|
| --- dart/editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/mobile/MobileMainTab.java (revision 37106)
|
| +++ dart/editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/mobile/MobileMainTab.java (working copy)
|
| @@ -14,6 +14,7 @@
|
| package com.google.dart.tools.debug.ui.internal.mobile;
|
|
|
| import com.google.dart.tools.core.mobile.AndroidDebugBridge;
|
| +import com.google.dart.tools.core.mobile.AndroidDevice;
|
| import com.google.dart.tools.core.model.DartSdkManager;
|
| import com.google.dart.tools.debug.core.DartLaunchConfigWrapper;
|
| import com.google.dart.tools.debug.ui.internal.DartDebugUIPlugin;
|
| @@ -49,15 +50,16 @@
|
|
|
| private static final String MOBILE_STATUS_PREFIX = "Mobile status: ";
|
| private static final String DEVICE_CONNECTED = "Connected";
|
| + private static final String DEVICE_NOT_AUTHORIZED = "Connected mobile is not authorized";
|
| private static final String DEVICE_NOT_FOUND = "No mobile found or USB development not enabled on mobile";
|
|
|
| private LaunchTargetComposite launchTargetGroup;
|
| - private Button dartBrowserButton;
|
| private Button installDartBrowserButton;
|
| private Label statusLabel;
|
|
|
| - private boolean deviceConnected = false;
|
| + private AndroidDevice connectedDevice = null;
|
| private final AtomicBoolean monitorDeviceConnection = new AtomicBoolean(false);
|
| + private Button usePubServeButton;
|
|
|
| @Override
|
| public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
|
| @@ -86,23 +88,29 @@
|
| GridLayoutFactory.swtDefaults().numColumns(3).applyTo(group);
|
| ((GridLayout) group.getLayout()).marginBottom = 4;
|
|
|
| - dartBrowserButton = new Button(group, SWT.CHECK);
|
| - dartBrowserButton.setText("Launch in a Dart Content Shell Browser");
|
| - dartBrowserButton.addSelectionListener(new SelectionAdapter() {
|
| + installDartBrowserButton = new Button(group, SWT.CHECK);
|
| + installDartBrowserButton.setText("Automatically install Dart Content Shell Browser on first launch");
|
| + GridDataFactory.swtDefaults().span(2, 1).grab(true, false).applyTo(installDartBrowserButton);
|
| +
|
| + // pub serve setting
|
| + group = new Group(composite, SWT.NONE);
|
| + group.setText("Pub settings");
|
| + GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
|
| + GridLayoutFactory.swtDefaults().numColumns(3).applyTo(group);
|
| + ((GridLayout) group.getLayout()).marginBottom = 5;
|
| + usePubServeButton = new Button(group, SWT.CHECK);
|
| + usePubServeButton.setText("Use pub to serve the application");
|
| + GridDataFactory.swtDefaults().span(3, 1).applyTo(usePubServeButton);
|
| + usePubServeButton.addSelectionListener(new SelectionAdapter() {
|
| @Override
|
| public void widgetSelected(SelectionEvent e) {
|
| notifyPanelChanged();
|
| - installDartBrowserButton.setEnabled(dartBrowserButton.getSelection());
|
| - installDartBrowserButton.setSelection(dartBrowserButton.getSelection());
|
| }
|
| });
|
| - GridDataFactory.swtDefaults().span(2, 1).grab(true, false).applyTo(dartBrowserButton);
|
| + Label label = new Label(group, SWT.NONE);
|
| + label.setText("(requires port forwarding setup using Chrome > Tools > Inspect Devices)");
|
| + GridDataFactory.swtDefaults().span(3, 1).indent(18, 0).applyTo(label);
|
|
|
| - installDartBrowserButton = new Button(group, SWT.CHECK);
|
| - installDartBrowserButton.setText("Automatically install Dart Content Shell Browser on first mobile launch");
|
| - GridDataFactory.swtDefaults().span(2, 1).grab(true, false).indent(20, 0).applyTo(
|
| - installDartBrowserButton);
|
| -
|
| // Status and setup group
|
| group = new Group(composite, SWT.NONE);
|
| group.setText("Status and first time setup");
|
| @@ -139,9 +147,12 @@
|
| if (performSdkCheck() != null) {
|
| return performSdkCheck();
|
| }
|
| - if (!deviceConnected) {
|
| + if (connectedDevice == null) {
|
| return DEVICE_NOT_FOUND;
|
| }
|
| + if (!connectedDevice.isAuthorized()) {
|
| + return DEVICE_NOT_AUTHORIZED;
|
| + }
|
| return launchTargetGroup.getErrorMessage();
|
| }
|
|
|
| @@ -185,8 +196,8 @@
|
| launchTargetGroup.setHtmlButtonSelection(false);
|
| }
|
|
|
| - dartBrowserButton.setSelection(wrapper.getLaunchContentShell());
|
| installDartBrowserButton.setSelection(wrapper.getInstallContentShell());
|
| + usePubServeButton.setSelection(wrapper.getUsePubServe());
|
| }
|
|
|
| /**
|
| @@ -212,8 +223,8 @@
|
|
|
| wrapper.setUrl(launchTargetGroup.getUrlString());
|
| wrapper.setSourceDirectoryName(launchTargetGroup.getSourceDirectory());
|
| - wrapper.setLaunchContentShell(dartBrowserButton.getSelection());
|
| wrapper.setInstallContentShell(installDartBrowserButton.getSelection());
|
| + wrapper.setUsePubServe(usePubServeButton.getSelection());
|
| }
|
|
|
| @Override
|
| @@ -222,6 +233,7 @@
|
| wrapper.setShouldLaunchFile(true);
|
| wrapper.setApplicationName(""); //$NON-NLS-1$
|
| wrapper.setLaunchContentShell(true);
|
| + wrapper.setUsePubServe(false);
|
| }
|
|
|
| private void notifyPanelChanged() {
|
| @@ -249,14 +261,14 @@
|
| public void run() {
|
|
|
| AndroidDebugBridge devBridge = AndroidDebugBridge.getAndroidDebugBridge();
|
| - boolean wasDeviceConnected = devBridge.getConnectedDevice() != null;
|
| - update(wasDeviceConnected);
|
| + AndroidDevice oldDevice = devBridge.getConnectedDevice();
|
| + update(oldDevice);
|
|
|
| while (monitorDeviceConnection.get()) {
|
| - final boolean isDeviceConnected = devBridge.getConnectedDevice() != null;
|
| - if (wasDeviceConnected != isDeviceConnected) {
|
| - wasDeviceConnected = isDeviceConnected;
|
| - update(isDeviceConnected);
|
| + AndroidDevice newDevice = devBridge.getConnectedDevice();
|
| + if (!AndroidDevice.isEqual(oldDevice, newDevice)) {
|
| + oldDevice = newDevice;
|
| + update(oldDevice);
|
| }
|
| try {
|
| Thread.sleep(1000);
|
| @@ -266,11 +278,11 @@
|
| }
|
| }
|
|
|
| - private void update(final boolean isDeviceConnected) {
|
| + private void update(final AndroidDevice device) {
|
| display.asyncExec(new Runnable() {
|
| @Override
|
| public void run() {
|
| - updateMobileStatus(isDeviceConnected);
|
| + updateMobileStatus(device);
|
| }
|
| });
|
| }
|
| @@ -292,11 +304,18 @@
|
| *
|
| * @param isDeviceConnected {@code true} if a mobile device is currently connected
|
| */
|
| - private void updateMobileStatus(boolean isDeviceConnected) {
|
| - deviceConnected = isDeviceConnected;
|
| + private void updateMobileStatus(AndroidDevice device) {
|
| + connectedDevice = device;
|
| if (statusLabel != null && !statusLabel.isDisposed()) {
|
| - statusLabel.setText(MOBILE_STATUS_PREFIX
|
| - + (deviceConnected ? DEVICE_CONNECTED : DEVICE_NOT_FOUND));
|
| + String status;
|
| + if (device == null) {
|
| + status = DEVICE_NOT_FOUND;
|
| + } else if (!device.isAuthorized()) {
|
| + status = DEVICE_NOT_AUTHORIZED;
|
| + } else {
|
| + status = DEVICE_CONNECTED;
|
| + }
|
| + statusLabel.setText(MOBILE_STATUS_PREFIX + status);
|
| updateLaunchConfigurationDialog();
|
| }
|
| }
|
|
|