OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014, the Dart project authors. | 2 * Copyright (c) 2014, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 /** | 48 /** |
49 * Main tab for Mobile launch configurations | 49 * Main tab for Mobile launch configurations |
50 */ | 50 */ |
51 public class MobileMainTab extends AbstractLaunchConfigurationTab { | 51 public class MobileMainTab extends AbstractLaunchConfigurationTab { |
52 | 52 |
53 private static final String DEVICE_NOT_AUTHORIZED = "Connected mobile is not a
uthorized"; | 53 private static final String DEVICE_NOT_AUTHORIZED = "Connected mobile is not a
uthorized"; |
54 private static final String DEVICE_NOT_FOUND = "No mobile found or USB develop
ment not enabled on mobile"; | 54 private static final String DEVICE_NOT_FOUND = "No mobile found or USB develop
ment not enabled on mobile"; |
55 | 55 |
56 public static final String MOBILE_DOC_URL = "https://www.dartlang.org/tools/ed
itor/mobile.html"; | 56 public static final String MOBILE_DOC_URL = "https://www.dartlang.org/tools/ed
itor/mobile.html"; |
| 57 // PORT_FORWARD_DOC_URL should be #set-up-port-forwarding but is #connect-the-
devices |
| 58 // until dartbug.com/19457 is fixed. |
| 59 public static final String PORT_FORWARD_DOC_URL = MOBILE_DOC_URL + "#connect-t
he-devices"; |
57 | 60 |
58 private static final String INFO_TEXT = "Serve the application using 'pub serv
e'. " | 61 private static final String INFO_TEXT = "Serve the application using 'pub serv
e'. " |
59 + "This requires setting up port forwarding."; | 62 + "This requires setting up port forwarding."; |
60 | 63 |
61 // When these change, be sure to change the messaging in MobileUrlConnectionEx
ception | 64 // When these change, be sure to change the messaging in MobileUrlConnectionEx
ception |
62 private String[] servers = {"Embedded server", "Pub serve"}; | 65 private String[] servers = {"Embedded server", "Pub serve"}; |
63 | 66 |
64 private LaunchTargetComposite launchTargetGroup; | 67 private LaunchTargetComposite launchTargetGroup; |
65 | 68 |
66 private AndroidDevice connectedDevice = null; | 69 private AndroidDevice connectedDevice = null; |
67 private final AtomicBoolean monitorDeviceConnection = new AtomicBoolean(false)
; | 70 private final AtomicBoolean monitorDeviceConnection = new AtomicBoolean(false)
; |
68 private Link infoLink; | 71 private Link infoLink; |
69 private Combo serversCombo; | 72 private Combo serversCombo; |
70 private Label infoLabel; | 73 private Label infoLabel; |
71 | 74 |
72 @Override | 75 @Override |
73 public void activated(ILaunchConfigurationWorkingCopy workingCopy) { | |
74 startMonitorDeviceConnectionInBackground(launchTargetGroup.getDisplay()); | |
75 super.activated(workingCopy); | |
76 } | |
77 | |
78 @Override | |
79 public void createControl(Composite parent) { | 76 public void createControl(Composite parent) { |
80 Composite composite = new Composite(parent, SWT.NONE); | 77 Composite composite = new Composite(parent, SWT.NONE); |
81 GridLayoutFactory.swtDefaults().spacing(1, 3).applyTo(composite); | 78 GridLayoutFactory.swtDefaults().spacing(1, 3).applyTo(composite); |
82 | 79 |
83 launchTargetGroup = new LaunchTargetComposite(composite, SWT.NONE); | 80 launchTargetGroup = new LaunchTargetComposite(composite, SWT.NONE); |
84 launchTargetGroup.addListener(SWT.Modify, new Listener() { | 81 launchTargetGroup.addListener(SWT.Modify, new Listener() { |
85 | 82 |
86 @Override | 83 @Override |
87 public void handleEvent(Event event) { | 84 public void handleEvent(Event event) { |
88 notifyPanelChanged(); | 85 notifyPanelChanged(); |
(...skipping 20 matching lines...) Expand all Loading... |
109 public void widgetSelected(SelectionEvent e) { | 106 public void widgetSelected(SelectionEvent e) { |
110 handleComboChanged(serversCombo.getSelectionIndex() == 1); | 107 handleComboChanged(serversCombo.getSelectionIndex() == 1); |
111 } | 108 } |
112 }); | 109 }); |
113 serversCombo.setItems(servers); | 110 serversCombo.setItems(servers); |
114 | 111 |
115 infoLabel = new Label(group, SWT.WRAP); | 112 infoLabel = new Label(group, SWT.WRAP); |
116 infoLabel.setText(INFO_TEXT); | 113 infoLabel.setText(INFO_TEXT); |
117 GridDataFactory.swtDefaults().grab(true, false).span(1, 2).applyTo(infoLabel
); | 114 GridDataFactory.swtDefaults().grab(true, false).span(1, 2).applyTo(infoLabel
); |
118 | 115 |
119 infoLink = new Link(group, SWT.NONE); | 116 infoLink = new Link(group, SWT.WRAP); |
120 infoLink.setText("Some configurations may require setting up port forwarding
in order for the " | 117 infoLink.setText("Some configurations may require setting up port forwarding
in order for the " |
121 + "mobile device to see the web server running on your development machi
ne. See <a href=\"" | 118 + "mobile device to see the web server running on your development machi
ne. See <a href=\"" |
122 + MOBILE_DOC_URL + "\"> port forwarding setup </a> for more information.
"); | 119 + PORT_FORWARD_DOC_URL + "\"> port forwarding setup </a> for more inform
ation."); |
123 infoLink.addSelectionListener(new SelectionAdapter() { | 120 infoLink.addSelectionListener(new SelectionAdapter() { |
124 @Override | 121 @Override |
| 122 public void widgetDefaultSelected(SelectionEvent e) { |
| 123 widgetSelected(e); |
| 124 } |
| 125 |
| 126 @Override |
125 public void widgetSelected(SelectionEvent e) { | 127 public void widgetSelected(SelectionEvent e) { |
126 ExternalBrowserUtil.openInExternalBrowser(MOBILE_DOC_URL); | 128 ExternalBrowserUtil.openInExternalBrowser(e.text.trim()); |
127 } | 129 } |
128 }); | 130 }); |
129 GridDataFactory.swtDefaults().span(2, 1).grab(true, false).applyTo(infoLink)
; | 131 GridDataFactory.swtDefaults().span(2, 1).grab(true, false).hint(415, SWT.DEF
AULT).applyTo( |
| 132 infoLink); |
130 new Label(group, SWT.NONE); | 133 new Label(group, SWT.NONE); |
131 | 134 |
132 setControl(composite); | 135 setControl(composite); |
133 } | 136 } |
134 | 137 |
135 @Override | 138 @Override |
136 public void dispose() { | 139 public void dispose() { |
137 Control control = getControl(); | 140 Control control = getControl(); |
138 | 141 |
139 if (control != null) { | 142 if (control != null) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 launchTargetGroup.setHtmlButtonSelection(false); | 200 launchTargetGroup.setHtmlButtonSelection(false); |
198 } | 201 } |
199 | 202 |
200 if (wrapper.getUsePubServe()) { | 203 if (wrapper.getUsePubServe()) { |
201 serversCombo.select(1); | 204 serversCombo.select(1); |
202 handleComboChanged(true); | 205 handleComboChanged(true); |
203 } else { | 206 } else { |
204 serversCombo.select(0); | 207 serversCombo.select(0); |
205 handleComboChanged(false); | 208 handleComboChanged(false); |
206 } | 209 } |
| 210 |
| 211 startMonitorDeviceConnectionInBackground(launchTargetGroup.getDisplay()); |
207 } | 212 } |
208 | 213 |
209 /** | 214 /** |
210 * Store the value specified in the UI into the launch configuration | 215 * Store the value specified in the UI into the launch configuration |
211 */ | 216 */ |
212 @Override | 217 @Override |
213 public void performApply(ILaunchConfigurationWorkingCopy config) { | 218 public void performApply(ILaunchConfigurationWorkingCopy config) { |
214 | 219 |
215 DartLaunchConfigWrapper wrapper = new DartLaunchConfigWrapper(config); | 220 DartLaunchConfigWrapper wrapper = new DartLaunchConfigWrapper(config); |
216 wrapper.setShouldLaunchFile(launchTargetGroup.getHtmlButtonSelection()); | 221 wrapper.setShouldLaunchFile(launchTargetGroup.getHtmlButtonSelection()); |
(...skipping 23 matching lines...) Expand all Loading... |
240 wrapper.setLaunchContentShell(true); | 245 wrapper.setLaunchContentShell(true); |
241 wrapper.setUsePubServe(false); | 246 wrapper.setUsePubServe(false); |
242 } | 247 } |
243 | 248 |
244 protected void handleComboChanged(boolean usePubServe) { | 249 protected void handleComboChanged(boolean usePubServe) { |
245 if (usePubServe) { | 250 if (usePubServe) { |
246 infoLabel.setText(INFO_TEXT); | 251 infoLabel.setText(INFO_TEXT); |
247 } else { | 252 } else { |
248 infoLabel.setText(""); | 253 infoLabel.setText(""); |
249 } | 254 } |
| 255 notifyPanelChanged(); |
250 } | 256 } |
251 | 257 |
252 private void notifyPanelChanged() { | 258 private void notifyPanelChanged() { |
253 setDirty(true); | 259 setDirty(true); |
254 updateLaunchConfigurationDialog(); | 260 updateLaunchConfigurationDialog(); |
255 } | 261 } |
256 | 262 |
257 private String performSdkCheck() { | 263 private String performSdkCheck() { |
258 if (!DartSdkManager.getManager().hasSdk()) { | 264 if (!DartSdkManager.getManager().hasSdk()) { |
259 return "Dart SDK is not installed (" | 265 return "Dart SDK is not installed (" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 * Update the mobile status. Must be called on the UI thread. | 322 * Update the mobile status. Must be called on the UI thread. |
317 * | 323 * |
318 * @param isDeviceConnected {@code true} if a mobile device is currently conne
cted | 324 * @param isDeviceConnected {@code true} if a mobile device is currently conne
cted |
319 */ | 325 */ |
320 private void updateMobileStatus(AndroidDevice device) { | 326 private void updateMobileStatus(AndroidDevice device) { |
321 connectedDevice = device; | 327 connectedDevice = device; |
322 updateLaunchConfigurationDialog(); | 328 updateLaunchConfigurationDialog(); |
323 | 329 |
324 } | 330 } |
325 } | 331 } |
OLD | NEW |