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

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/dialogs/RemoteConnectionDialog.java

Issue 753183003: Fix an issue resolving paths when remote debugging. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Dart project authors. 2 * Copyright 2013 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
11 * or implied. See the License for the specific language governing permissions a nd limitations under 11 * or implied. See the License for the specific language governing permissions a nd limitations under
12 * the License. 12 * the License.
13 */ 13 */
14 14
15 package com.google.dart.tools.debug.ui.internal.dialogs; 15 package com.google.dart.tools.debug.ui.internal.dialogs;
16 16
17 import com.google.dart.tools.core.internal.util.ResourceUtil;
18 import com.google.dart.tools.debug.core.configs.DartServerLaunchConfigurationDel egate; 17 import com.google.dart.tools.debug.core.configs.DartServerLaunchConfigurationDel egate;
19 import com.google.dart.tools.debug.core.configs.DartiumLaunchConfigurationDelega te; 18 import com.google.dart.tools.debug.core.configs.DartiumLaunchConfigurationDelega te;
20 import com.google.dart.tools.debug.core.util.IRemoteConnectionDelegate; 19 import com.google.dart.tools.debug.core.util.IRemoteConnectionDelegate;
21 import com.google.dart.tools.debug.core.webkit.ChromiumTabInfo; 20 import com.google.dart.tools.debug.core.webkit.ChromiumTabInfo;
22 import com.google.dart.tools.debug.core.webkit.DefaultChromiumTabChooser; 21 import com.google.dart.tools.debug.core.webkit.DefaultChromiumTabChooser;
23 import com.google.dart.tools.debug.core.webkit.IChromiumTabChooser; 22 import com.google.dart.tools.debug.core.webkit.IChromiumTabChooser;
24 import com.google.dart.tools.debug.ui.internal.DartDebugUIPlugin; 23 import com.google.dart.tools.debug.ui.internal.DartDebugUIPlugin;
25 import com.google.dart.tools.debug.ui.internal.view.DebuggerViewManager; 24 import com.google.dart.tools.debug.ui.internal.view.DebuggerViewManager;
26 import com.google.dart.tools.ui.themes.Fonts; 25 import com.google.dart.tools.ui.themes.Fonts;
27 26
28 import org.eclipse.core.resources.IFile; 27 import org.eclipse.core.resources.IContainer;
28 import org.eclipse.core.resources.IResource;
29 import org.eclipse.core.resources.ResourcesPlugin;
29 import org.eclipse.core.runtime.CoreException; 30 import org.eclipse.core.runtime.CoreException;
31 import org.eclipse.core.runtime.IPath;
30 import org.eclipse.core.runtime.IProgressMonitor; 32 import org.eclipse.core.runtime.IProgressMonitor;
31 import org.eclipse.core.runtime.IStatus; 33 import org.eclipse.core.runtime.IStatus;
32 import org.eclipse.core.runtime.Status; 34 import org.eclipse.core.runtime.Status;
33 import org.eclipse.core.runtime.jobs.Job; 35 import org.eclipse.core.runtime.jobs.Job;
34 import org.eclipse.jface.dialogs.ErrorDialog; 36 import org.eclipse.jface.dialogs.ErrorDialog;
35 import org.eclipse.jface.dialogs.IDialogSettings; 37 import org.eclipse.jface.dialogs.IDialogSettings;
36 import org.eclipse.jface.dialogs.TitleAreaDialog; 38 import org.eclipse.jface.dialogs.TitleAreaDialog;
37 import org.eclipse.jface.layout.GridDataFactory; 39 import org.eclipse.jface.layout.GridDataFactory;
38 import org.eclipse.jface.layout.GridLayoutFactory; 40 import org.eclipse.jface.layout.GridLayoutFactory;
39 import org.eclipse.jface.viewers.ArrayContentProvider; 41 import org.eclipse.jface.viewers.ArrayContentProvider;
40 import org.eclipse.jface.viewers.LabelProvider; 42 import org.eclipse.jface.viewers.LabelProvider;
41 import org.eclipse.jface.window.Window; 43 import org.eclipse.jface.window.Window;
42 import org.eclipse.swt.SWT; 44 import org.eclipse.swt.SWT;
43 import org.eclipse.swt.events.SelectionAdapter; 45 import org.eclipse.swt.events.SelectionAdapter;
44 import org.eclipse.swt.events.SelectionEvent; 46 import org.eclipse.swt.events.SelectionEvent;
45 import org.eclipse.swt.graphics.Image; 47 import org.eclipse.swt.graphics.Image;
46 import org.eclipse.swt.widgets.Button; 48 import org.eclipse.swt.widgets.Button;
47 import org.eclipse.swt.widgets.Combo; 49 import org.eclipse.swt.widgets.Combo;
48 import org.eclipse.swt.widgets.Composite; 50 import org.eclipse.swt.widgets.Composite;
49 import org.eclipse.swt.widgets.Control; 51 import org.eclipse.swt.widgets.Control;
50 import org.eclipse.swt.widgets.Display; 52 import org.eclipse.swt.widgets.Display;
51 import org.eclipse.swt.widgets.Group; 53 import org.eclipse.swt.widgets.Group;
52 import org.eclipse.swt.widgets.Label; 54 import org.eclipse.swt.widgets.Label;
53 import org.eclipse.swt.widgets.Shell; 55 import org.eclipse.swt.widgets.Shell;
54 import org.eclipse.swt.widgets.Text; 56 import org.eclipse.swt.widgets.Text;
55 import org.eclipse.ui.IWorkbench; 57 import org.eclipse.ui.IWorkbench;
56 import org.eclipse.ui.PlatformUI; 58 import org.eclipse.ui.PlatformUI;
59 import org.eclipse.ui.dialogs.ContainerSelectionDialog;
57 import org.eclipse.ui.dialogs.ListDialog; 60 import org.eclipse.ui.dialogs.ListDialog;
58 61
59 import java.util.List; 62 import java.util.List;
60 63
61 /** 64 /**
62 * A dialog to connect to remote debug instances. 65 * A dialog to connect to remote debug instances.
63 */ 66 */
64 public class RemoteConnectionDialog extends TitleAreaDialog { 67 public class RemoteConnectionDialog extends TitleAreaDialog {
65 68
66 /** 69 /**
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 119 }
117 120
118 return new DefaultChromiumTabChooser().chooseTab(tabs); 121 return new DefaultChromiumTabChooser().chooseTab(tabs);
119 } 122 }
120 } 123 }
121 124
122 public static class ConnectionJob extends Job { 125 public static class ConnectionJob extends Job {
123 private IRemoteConnectionDelegate connectionDelegate; 126 private IRemoteConnectionDelegate connectionDelegate;
124 private String host; 127 private String host;
125 private int port; 128 private int port;
126 private IFile file; 129 private IContainer container;
127 private boolean usePubServe; 130 private boolean usePubServe;
128 131
129 public ConnectionJob(IRemoteConnectionDelegate connectionDelegate, String ho st, int port, 132 public ConnectionJob(IRemoteConnectionDelegate connectionDelegate, String ho st, int port,
130 IFile file, boolean usePubServe) { 133 IContainer container, boolean usePubServe) {
131 super("Connecting..."); 134 super("Connecting...");
132 135
133 this.connectionDelegate = connectionDelegate; 136 this.connectionDelegate = connectionDelegate;
134 this.host = host; 137 this.host = host;
135 this.port = port; 138 this.port = port;
136 this.file = file; 139 this.container = container;
137 this.usePubServe = usePubServe; 140 this.usePubServe = usePubServe;
138 } 141 }
139 142
140 @Override 143 @Override
141 protected IStatus run(IProgressMonitor monitor) { 144 protected IStatus run(IProgressMonitor monitor) {
142 try { 145 try {
143 connectionDelegate.performRemoteConnection(host, port, file, monitor, us ePubServe); 146 connectionDelegate.performRemoteConnection(host, port, container, monito r, usePubServe);
144 147
145 // Show the debugger view. 148 // Show the debugger view.
146 Display.getDefault().asyncExec(new Runnable() { 149 Display.getDefault().asyncExec(new Runnable() {
147 @Override 150 @Override
148 public void run() { 151 public void run() {
149 DebuggerViewManager viewManager = DebuggerViewManager.getDefault(); 152 DebuggerViewManager viewManager = DebuggerViewManager.getDefault();
150 153
151 if (viewManager.hasDebuggerView()) { 154 if (viewManager.hasDebuggerView()) {
152 viewManager.openDebuggerView(); 155 viewManager.openDebuggerView();
153 } 156 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 198
196 ConnectionType(String label, String message, String helpMessage, String host Default, 199 ConnectionType(String label, String message, String helpMessage, String host Default,
197 String portDefault) { 200 String portDefault) {
198 this.label = label; 201 this.label = label;
199 this.message = message; 202 this.message = message;
200 this.helpMessage = helpMessage; 203 this.helpMessage = helpMessage;
201 this.hostDefault = hostDefault; 204 this.hostDefault = hostDefault;
202 this.portDefault = portDefault; 205 this.portDefault = portDefault;
203 } 206 }
204 207
205 public void connection(String host, int port, IFile file, boolean usePubServ e) { 208 public void connection(String host, int port, IContainer container, boolean usePubServe) {
206 IRemoteConnectionDelegate connectionDelegate = null; 209 IRemoteConnectionDelegate connectionDelegate = null;
207 210
208 switch (this) { 211 switch (this) {
209 case CHROME: { 212 case CHROME: {
210 connectionDelegate = new DartiumLaunchConfigurationDelegate(new Chrome TabChooser()); 213 connectionDelegate = new DartiumLaunchConfigurationDelegate(new Chrome TabChooser());
211 break; 214 break;
212 } 215 }
213 216
214 case COMMAND_LINE: { 217 case COMMAND_LINE: {
215 connectionDelegate = new DartServerLaunchConfigurationDelegate(); 218 connectionDelegate = new DartServerLaunchConfigurationDelegate();
216 break; 219 break;
217 } 220 }
218 221
219 default: { 222 default: {
220 throw new IllegalArgumentException(); 223 throw new IllegalArgumentException();
221 } 224 }
222 } 225 }
223 226
224 if (connectionDelegate != null) { 227 if (connectionDelegate != null) {
225 Job job = new ConnectionJob(connectionDelegate, host, port, file, usePub Serve); 228 Job job = new ConnectionJob(connectionDelegate, host, port, container, u sePubServe);
226 job.schedule(); 229 job.schedule();
227 } 230 }
228 } 231 }
229 } 232 }
230 233
231 static class TabLabelProvider extends LabelProvider { 234 static class TabLabelProvider extends LabelProvider {
232 235
233 @Override 236 @Override
234 public Image getImage(Object element) { 237 public Image getImage(Object element) {
235 return null; 238 return null;
(...skipping 19 matching lines...) Expand all
255 258
256 dialog.open(); 259 dialog.open();
257 } 260 }
258 261
259 private Combo exceptionsCombo; 262 private Combo exceptionsCombo;
260 263
261 private Text hostText; 264 private Text hostText;
262 265
263 private Text portText; 266 private Text portText;
264 267
265 private Text fileText; 268 private Label resourcePathLabel;
266 269
267 private Text instructionsLabel; 270 private Text instructionsLabel;
268 271
269 private Button usePubServeButton; 272 private Button usePubServeButton;
270 273
271 private Group pubGroup; 274 private Group pubGroup;
272 275
273 /** 276 /**
274 * Create a new RemoteConnectionDialog with the given shell as its parent. 277 * Create a new RemoteConnectionDialog with the given shell as its parent.
275 * 278 *
(...skipping 23 matching lines...) Expand all
299 302
300 return contents; 303 return contents;
301 } 304 }
302 305
303 @Override 306 @Override
304 protected void okPressed() { 307 protected void okPressed() {
305 ConnectionType connection = getConnectionType(); 308 ConnectionType connection = getConnectionType();
306 309
307 String host = hostText.getText().trim(); 310 String host = hostText.getText().trim();
308 String port = portText.getText().trim(); 311 String port = portText.getText().trim();
309 String filePath = fileText.getText().trim(); 312 String resourcePath = resourcePathLabel.getText().trim();
310 boolean usePubServe = usePubServeButton.getSelection(); 313 boolean usePubServe = usePubServeButton.getSelection();
311 314
312 IDialogSettings settings = getDialogSettings(); 315 IDialogSettings settings = getDialogSettings();
313 316
314 settings.put("selected", connection.ordinal()); 317 settings.put("selected", connection.ordinal());
315 settings.put(connection.name() + ".host", host); 318 settings.put(connection.name() + ".host", host);
316 settings.put(connection.name() + ".port", port); 319 settings.put(connection.name() + ".port", port);
317 settings.put(connection.name() + ".file", filePath); 320 settings.put(connection.name() + ".resource", resourcePath);
318 settings.put(connection.name() + ".usePubServe", usePubServe); 321 settings.put(connection.name() + ".usePubServe", usePubServe);
319 322
320 int connectionPort; 323 int connectionPort;
321 324
322 try { 325 try {
323 connectionPort = Integer.parseInt(port); 326 connectionPort = Integer.parseInt(port);
324 } catch (NumberFormatException nfe) { 327 } catch (NumberFormatException nfe) {
325 ErrorDialog.openError(getShell(), "Invalid Port", null, new Status( 328 ErrorDialog.openError(getShell(), "Invalid Port", null, new Status(
326 IStatus.ERROR, 329 IStatus.ERROR,
327 DartDebugUIPlugin.PLUGIN_ID, 330 DartDebugUIPlugin.PLUGIN_ID,
328 "\"" + port + "\" is an invalid port.")); 331 "\"" + port + "\" is an invalid port."));
329 return; 332 return;
330 } 333 }
331 334
332 IFile file = ResourceUtil.getFile(filePath); 335 IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(res ourcePath);
333 if (file == null) { 336
334 ErrorDialog.openError(getShell(), "Invalid Application File", null, new St atus( 337 if (resource == null) {
338 ErrorDialog.openError(getShell(), "Invalid Source Project", null, new Stat us(
335 IStatus.ERROR, 339 IStatus.ERROR,
336 DartDebugUIPlugin.PLUGIN_ID, 340 DartDebugUIPlugin.PLUGIN_ID,
337 "\"" + filePath + "\" is an invalid resource path.")); 341 "\"" + resourcePath + "\" is an invalid resource path."));
338 return; 342 return;
339 } 343 }
340 344
341 connection.connection(host, connectionPort, file, usePubServe); 345 IContainer container = resource instanceof IContainer ? (IContainer) resourc e
346 : resource.getParent();
347 connection.connection(host, connectionPort, container, usePubServe);
342 348
343 super.okPressed(); 349 super.okPressed();
344 } 350 }
345 351
346 private void createDialogUI(Composite parent) { 352 private void createDialogUI(Composite parent) {
347 GridLayoutFactory.fillDefaults().numColumns(2).margins(12, 6).applyTo(parent ); 353 GridLayoutFactory.fillDefaults().numColumns(2).margins(12, 6).applyTo(parent );
348 354
349 Label label = new Label(parent, SWT.NONE); 355 Label label = new Label(parent, SWT.NONE);
350 label.setText("Connect to:"); 356 label.setText("Connect to:");
351 357
352 exceptionsCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); 358 exceptionsCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
353 exceptionsCombo.setItems(getConnectionLabels()); 359 exceptionsCombo.setItems(getConnectionLabels());
354 exceptionsCombo.addSelectionListener(new SelectionAdapter() { 360 exceptionsCombo.addSelectionListener(new SelectionAdapter() {
355 @Override 361 @Override
356 public void widgetSelected(SelectionEvent e) { 362 public void widgetSelected(SelectionEvent e) {
357 handleComboChanged(); 363 handleComboChanged();
358 } 364 }
359 }); 365 });
360 366
361 // spacer 367 // spacer
362 label = new Label(parent, SWT.NONE); 368 label = new Label(parent, SWT.NONE);
363 369
364 Group group = new Group(parent, SWT.NONE); 370 Group group = new Group(parent, SWT.NONE);
365 group.setText("Connection parameters"); 371 group.setText("Connection parameters");
366 GridDataFactory.fillDefaults().grab(true, false).applyTo(group); 372 GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
367 GridLayoutFactory.fillDefaults().numColumns(2).margins(12, 6).applyTo(group) ; 373 GridLayoutFactory.fillDefaults().numColumns(3).margins(12, 6).applyTo(group) ;
368 374
369 label = new Label(group, SWT.NONE); 375 label = new Label(group, SWT.NONE);
370 label.setText("Host:"); 376 label.setText("Host:");
371 377
372 hostText = new Text(group, SWT.SINGLE | SWT.BORDER); 378 hostText = new Text(group, SWT.SINGLE | SWT.BORDER);
373 GridDataFactory.fillDefaults().grab(true, false).applyTo(hostText); 379 GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(hostText );
374 380
375 label = new Label(group, SWT.NONE); 381 label = new Label(group, SWT.NONE);
376 label.setText("Port:"); 382 label.setText("Port:");
377 383
378 portText = new Text(group, SWT.SINGLE | SWT.BORDER); 384 portText = new Text(group, SWT.SINGLE | SWT.BORDER);
379 GridDataFactory.fillDefaults().grab(true, false).applyTo(portText); 385 GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(portText );
380 386
381 label = new Label(group, SWT.NONE); 387 label = new Label(group, SWT.NONE);
382 label.setText("File:"); 388 label.setText("Project source:");
devoncarew 2014/11/25 18:27:35 The user now needs to indicate where the source th
383 389
384 fileText = new Text(group, SWT.SINGLE | SWT.BORDER); 390 resourcePathLabel = new Label(group, SWT.NONE);
385 GridDataFactory.fillDefaults().grab(true, false).applyTo(fileText); 391 GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER) .applyTo(
392 resourcePathLabel);
393
394 Button projectBrowseButton = new Button(group, SWT.PUSH);
395 projectBrowseButton.setText("Select Folder...");
396 GridDataFactory.swtDefaults().applyTo(projectBrowseButton);
397 projectBrowseButton.addSelectionListener(new SelectionAdapter() {
398 @Override
399 public void widgetSelected(SelectionEvent e) {
400 handleSourceDirectoryBrowseButton();
401 }
402 });
386 403
387 label = new Label(parent, SWT.NONE); 404 label = new Label(parent, SWT.NONE);
388 405
389 instructionsLabel = new Text(parent, SWT.WRAP | SWT.READ_ONLY); 406 instructionsLabel = new Text(parent, SWT.WRAP | SWT.READ_ONLY);
390 instructionsLabel.setBackground(parent.getBackground()); 407 instructionsLabel.setBackground(parent.getBackground());
391 GridDataFactory.fillDefaults().grab(true, false).hint(100, -1).applyTo(instr uctionsLabel); 408 GridDataFactory.fillDefaults().grab(true, false).hint(100, -1).applyTo(instr uctionsLabel);
392 409
393 // spacer 410 // spacer
394 label = new Label(parent, SWT.NONE); 411 label = new Label(parent, SWT.NONE);
395 412
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 468
452 private void handleComboChanged() { 469 private void handleComboChanged() {
453 ConnectionType connection = getConnectionType(); 470 ConnectionType connection = getConnectionType();
454 471
455 setMessage(connection.message); 472 setMessage(connection.message);
456 instructionsLabel.setText(connection.helpMessage); 473 instructionsLabel.setText(connection.helpMessage);
457 474
458 IDialogSettings settings = getDialogSettings(); 475 IDialogSettings settings = getDialogSettings();
459 hostText.setText(notNull(settings.get(connection.name() + ".host"))); 476 hostText.setText(notNull(settings.get(connection.name() + ".host")));
460 portText.setText(notNull(settings.get(connection.name() + ".port"))); 477 portText.setText(notNull(settings.get(connection.name() + ".port")));
461 fileText.setText(notNull(settings.get(connection.name() + ".file"))); 478 resourcePathLabel.setText(notNull(settings.get(connection.name() + ".resourc e")));
462 479
463 pubGroup.setVisible(connection == ConnectionType.CHROME); 480 pubGroup.setVisible(connection == ConnectionType.CHROME);
464 } 481 }
465 482
483 private void handleSourceDirectoryBrowseButton() {
484 ContainerSelectionDialog dialog = new ContainerSelectionDialog(
485 getShell(),
486 null,
487 false,
488 "Select source location");
489
490 dialog.open();
491
492 Object[] results = dialog.getResult();
493
494 if ((results != null) && (results.length > 0)) {
495 String pathStr = ((IPath) results[0]).toString();
496 resourcePathLabel.setText(pathStr);
497 }
498 }
499
466 private String notNull(String str) { 500 private String notNull(String str) {
467 return str == null ? "" : str; 501 return str == null ? "" : str;
468 } 502 }
469 503
470 } 504 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698