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 37301) |
+++ dart/editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/mobile/MobileMainTab.java (working copy) |
@@ -19,6 +19,7 @@ |
import com.google.dart.tools.debug.core.DartLaunchConfigWrapper; |
import com.google.dart.tools.debug.ui.internal.DartDebugUIPlugin; |
import com.google.dart.tools.debug.ui.internal.util.LaunchTargetComposite; |
+import com.google.dart.tools.ui.internal.util.ExternalBrowserUtil; |
import org.eclipse.debug.core.ILaunchConfiguration; |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
@@ -32,13 +33,14 @@ |
import org.eclipse.swt.events.SelectionEvent; |
import org.eclipse.swt.graphics.Image; |
import org.eclipse.swt.layout.GridLayout; |
-import org.eclipse.swt.widgets.Button; |
+import org.eclipse.swt.widgets.Combo; |
import org.eclipse.swt.widgets.Composite; |
import org.eclipse.swt.widgets.Control; |
import org.eclipse.swt.widgets.Display; |
import org.eclipse.swt.widgets.Event; |
import org.eclipse.swt.widgets.Group; |
import org.eclipse.swt.widgets.Label; |
+import org.eclipse.swt.widgets.Link; |
import org.eclipse.swt.widgets.Listener; |
import java.util.concurrent.atomic.AtomicBoolean; |
@@ -48,22 +50,27 @@ |
*/ |
public class MobileMainTab extends AbstractLaunchConfigurationTab { |
- 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"; |
+ public static final String MOBILE_DOC_URL = "https://www.dartlang.org/tools/editor/mobile.html"; |
+ |
+ private static final String INFO_TEXT = "Serve the application using 'pub serve'. " |
+ + "This requires setting up port forwarding."; |
+ |
+ private String[] servers = {"Embedded server", "Pub serve"}; |
+ |
private LaunchTargetComposite launchTargetGroup; |
- private Button installDartBrowserButton; |
- private Label statusLabel; |
private AndroidDevice connectedDevice = null; |
private final AtomicBoolean monitorDeviceConnection = new AtomicBoolean(false); |
- private Button usePubServeButton; |
+ private Link infoLink; |
+ private Combo serversCombo; |
+ private Label infoLabel; |
@Override |
public void activated(ILaunchConfigurationWorkingCopy workingCopy) { |
- startMonitorDeviceConnectionInBackground(statusLabel.getDisplay()); |
+ startMonitorDeviceConnectionInBackground(launchTargetGroup.getDisplay()); |
super.activated(workingCopy); |
} |
@@ -80,53 +87,46 @@ |
notifyPanelChanged(); |
} |
}); |
+ launchTargetGroup.addDisposeListener(new DisposeListener() { |
+ @Override |
+ public void widgetDisposed(DisposeEvent e) { |
+ stopMonitorDeviceConnectionInBackground(); |
+ } |
+ }); |
- // Browser selection group |
+ // pub serve setting |
Group group = new Group(composite, SWT.NONE); |
- group.setText("Browser settings"); |
- GridDataFactory.fillDefaults().grab(true, false).applyTo(group); |
- GridLayoutFactory.swtDefaults().numColumns(3).applyTo(group); |
- ((GridLayout) group.getLayout()).marginBottom = 4; |
+ group.setText("Server"); |
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(group); |
+ GridLayoutFactory.swtDefaults().numColumns(2).applyTo(group); |
+ ((GridLayout) group.getLayout()).marginBottom = 5; |
+ ((GridLayout) group.getLayout()).verticalSpacing = 10; |
- 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() { |
+ serversCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); |
+ serversCombo.addSelectionListener(new SelectionAdapter() { |
@Override |
public void widgetSelected(SelectionEvent e) { |
- notifyPanelChanged(); |
+ handleComboChanged(serversCombo.getSelectionIndex() == 1); |
} |
}); |
- 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); |
+ serversCombo.setItems(servers); |
- // Status and setup group |
- group = new Group(composite, SWT.NONE); |
- group.setText("Status and first time setup"); |
- GridDataFactory.fillDefaults().grab(true, false).applyTo(group); |
- GridLayoutFactory.swtDefaults().numColumns(1).applyTo(group); |
- ((GridLayout) group.getLayout()).marginBottom = 4; |
+ infoLabel = new Label(group, SWT.WRAP); |
+ infoLabel.setText(INFO_TEXT); |
+ GridDataFactory.swtDefaults().grab(true, false).span(1, 2).applyTo(infoLabel); |
- statusLabel = new Label(group, SWT.NONE); |
- GridDataFactory.fillDefaults().grab(true, false).applyTo(statusLabel); |
- statusLabel.setText(MOBILE_STATUS_PREFIX); |
- statusLabel.addDisposeListener(new DisposeListener() { |
+ infoLink = new Link(group, SWT.NONE); |
+ infoLink.setText("Some configurations may require setting up port forwarding in order for the " |
+ + "mobile device to see the web server running on your development machine. See <a href=\"" |
+ + MOBILE_DOC_URL + "\"> port forwarding setup </a> for more information."); |
+ infoLink.addSelectionListener(new SelectionAdapter() { |
@Override |
- public void widgetDisposed(DisposeEvent e) { |
- stopMonitorDeviceConnectionInBackground(); |
+ public void widgetSelected(SelectionEvent e) { |
+ ExternalBrowserUtil.openInExternalBrowser(MOBILE_DOC_URL); |
} |
}); |
+ GridDataFactory.swtDefaults().span(2, 1).grab(true, false).applyTo(infoLink); |
+ new Label(group, SWT.NONE); |
setControl(composite); |
} |
@@ -196,8 +196,13 @@ |
launchTargetGroup.setHtmlButtonSelection(false); |
} |
- installDartBrowserButton.setSelection(wrapper.getInstallContentShell()); |
- usePubServeButton.setSelection(wrapper.getUsePubServe()); |
+ if (wrapper.getUsePubServe()) { |
+ serversCombo.select(1); |
+ handleComboChanged(true); |
+ } else { |
+ serversCombo.select(0); |
+ handleComboChanged(false); |
+ } |
} |
/** |
@@ -223,8 +228,7 @@ |
wrapper.setUrl(launchTargetGroup.getUrlString()); |
wrapper.setSourceDirectoryName(launchTargetGroup.getSourceDirectory()); |
- wrapper.setInstallContentShell(installDartBrowserButton.getSelection()); |
- wrapper.setUsePubServe(usePubServeButton.getSelection()); |
+ wrapper.setUsePubServe(serversCombo.getSelectionIndex() == 1); |
} |
@Override |
@@ -236,6 +240,14 @@ |
wrapper.setUsePubServe(false); |
} |
+ protected void handleComboChanged(boolean usePubServe) { |
+ if (usePubServe) { |
+ infoLabel.setText(INFO_TEXT); |
+ } else { |
+ infoLabel.setText(""); |
+ } |
+ } |
+ |
private void notifyPanelChanged() { |
setDirty(true); |
updateLaunchConfigurationDialog(); |
@@ -306,17 +318,7 @@ |
*/ |
private void updateMobileStatus(AndroidDevice device) { |
connectedDevice = device; |
- if (statusLabel != null && !statusLabel.isDisposed()) { |
- 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(); |
- } |
+ updateLaunchConfigurationDialog(); |
+ |
} |
} |