Index: editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/server/DartServerMainTab.java |
=================================================================== |
--- editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/server/DartServerMainTab.java (revision 15120) |
+++ editor/tools/plugins/com.google.dart.tools.debug.ui/src/com/google/dart/tools/debug/ui/internal/server/DartServerMainTab.java (working copy) |
@@ -18,9 +18,9 @@ |
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.AppSelectionDialog; |
+import com.google.dart.tools.ui.internal.util.ExternalBrowserUtil; |
import org.eclipse.core.resources.IFile; |
-import org.eclipse.core.resources.IProject; |
import org.eclipse.core.resources.IResource; |
import org.eclipse.core.resources.IWorkspace; |
import org.eclipse.core.resources.ResourcesPlugin; |
@@ -39,10 +39,13 @@ |
import org.eclipse.swt.events.SelectionAdapter; |
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.Composite; |
+import org.eclipse.swt.widgets.DirectoryDialog; |
import org.eclipse.swt.widgets.Group; |
import org.eclipse.swt.widgets.Label; |
+import org.eclipse.swt.widgets.Link; |
import org.eclipse.swt.widgets.Text; |
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog; |
@@ -55,7 +58,7 @@ |
private Button checkedModeButton; |
private Button enableDebuggingButton; |
- private Label workingDirText; |
+ private Text workingDirText; |
private IPath scriptPath; |
private ModifyListener textModifyListener = new ModifyListener() { |
@@ -79,15 +82,9 @@ |
group.setText("Application"); |
GridDataFactory.fillDefaults().grab(true, false).applyTo(group); |
GridLayoutFactory.swtDefaults().numColumns(3).applyTo(group); |
+ ((GridLayout) group.getLayout()).marginBottom = 5; |
Label label = new Label(group, SWT.NONE); |
- label.setText("Working directory:"); |
- label.pack(); |
- workingDirText = new Label(group, SWT.NONE); |
- GridDataFactory.swtDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo( |
- workingDirText); |
- |
- label = new Label(group, SWT.NONE); |
label.setText("Dart script:"); |
scriptText = new Text(group, SWT.BORDER | SWT.SINGLE); |
@@ -97,7 +94,7 @@ |
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(scriptText); |
Button button = new Button(group, SWT.PUSH); |
- button.setText("Browse..."); |
+ button.setText("Select..."); |
PixelConverter converter = new PixelConverter(button); |
int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); |
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).hint(widthHint, -1).applyTo(button); |
@@ -109,6 +106,24 @@ |
}); |
label = new Label(group, SWT.NONE); |
+ label.setText("Working directory:"); |
+ |
+ workingDirText = new Text(group, SWT.BORDER | SWT.SINGLE); |
+ workingDirText.addModifyListener(textModifyListener); |
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo( |
+ workingDirText); |
+ |
+ button = new Button(group, SWT.PUSH); |
+ button.setText("Select..."); |
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).hint(widthHint, -1).applyTo(button); |
+ button.addSelectionListener(new SelectionAdapter() { |
+ @Override |
+ public void widgetSelected(SelectionEvent e) { |
+ handleCwdBrowseButton(); |
+ } |
+ }); |
+ |
+ label = new Label(group, SWT.NONE); |
label.setText("Script arguments:"); |
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(label); |
@@ -125,17 +140,28 @@ |
group.setText("VM settings"); |
GridDataFactory.fillDefaults().grab(true, false).applyTo(group); |
GridLayoutFactory.swtDefaults().numColumns(3).applyTo(group); |
+ ((GridLayout) group.getLayout()).marginBottom = 4; |
checkedModeButton = new Button(group, SWT.CHECK); |
checkedModeButton.setText("Run in checked mode"); |
- GridDataFactory.swtDefaults().span(3, 1).applyTo(checkedModeButton); |
checkedModeButton.addSelectionListener(new SelectionAdapter() { |
@Override |
public void widgetSelected(SelectionEvent e) { |
notifyPanelChanged(); |
} |
}); |
+ GridDataFactory.swtDefaults().span(2, 1).grab(true, false).applyTo(checkedModeButton); |
+ Link infoLink = new Link(group, SWT.NONE); |
+ infoLink.setText("<a href=\"" + DartDebugUIPlugin.CHECK_MODE_DESC_URL |
+ + "\">what is checked mode?</a>"); |
+ infoLink.addSelectionListener(new SelectionAdapter() { |
+ @Override |
+ public void widgetSelected(SelectionEvent e) { |
+ ExternalBrowserUtil.openInExternalBrowser(DartDebugUIPlugin.CHECK_MODE_DESC_URL); |
+ } |
+ }); |
+ |
enableDebuggingButton = new Button(group, SWT.CHECK); |
enableDebuggingButton.setText("Enable debugging"); |
GridDataFactory.swtDefaults().span(3, 1).applyTo(enableDebuggingButton); |
@@ -160,7 +186,7 @@ |
public String getErrorMessage() { |
// check that the script name is not empty |
if (scriptText.getText().length() == 0) { |
- return "A Dart script is required."; |
+ return "Please select a Dart script."; |
} |
return null; |
@@ -190,7 +216,7 @@ |
if (resource != null) { |
scriptText.setText(resource.getProjectRelativePath().toPortableString()); |
} |
- workingDirText.setText(getWorkingDir(dartLauncher)); |
+ workingDirText.setText(dartLauncher.getWorkingDirectory()); |
argsText.setText(dartLauncher.getArguments()); |
checkedModeButton.setSelection(dartLauncher.getCheckedMode()); |
@@ -209,6 +235,7 @@ |
DartLaunchConfigWrapper dartLauncher = new DartLaunchConfigWrapper(configuration); |
dartLauncher.setApplicationName(scriptPath.toPortableString()); |
+ dartLauncher.setWorkingDirectory(workingDirText.getText()); |
dartLauncher.setArguments(argsText.getText()); |
dartLauncher.setCheckedMode(checkedModeButton.getSelection()); |
@@ -228,6 +255,17 @@ |
dartLauncher.setCheckedMode(false); |
} |
+ protected void handleCwdBrowseButton() { |
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.APPLICATION_MODAL | SWT.OPEN); |
+ dialog.setText("Select the Working Directory"); |
+ |
+ String path = dialog.open(); |
+ |
+ if (path != null) { |
+ workingDirText.setText(path); |
+ } |
+ } |
+ |
protected void handleScriptBrowseButton() { |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
AppSelectionDialog dialog = new AppSelectionDialog(getShell(), workspace.getRoot()); |
@@ -244,35 +282,14 @@ |
dialog.open(); |
Object[] results = dialog.getResult(); |
+ |
if ((results != null) && (results.length > 0) && (results[0] instanceof IFile)) { |
IFile resource = (IFile) results[0]; |
scriptPath = (resource.getFullPath()); |
scriptText.setText(resource.getProjectRelativePath().toPortableString()); |
- workingDirText.setText(getWorkingDir(resource)); |
} |
} |
- private String getWorkingDir(DartLaunchConfigWrapper dartLauncher) { |
- IResource resource = dartLauncher.getApplicationResource(); |
- if (resource != null) { |
- return getWorkingDir(resource); |
- } else { |
- IProject project = dartLauncher.getProject(); |
- if (project != null) { |
- return dartLauncher.getProject().getLocation().toPortableString(); |
- } |
- } |
- return ""; |
- } |
- |
- private String getWorkingDir(IResource resource) { |
- if (resource.isLinked()) { |
- return resource.getLocation().toFile().getParentFile().toString(); |
- } else { |
- return resource.getProject().getLocation().toFile().toString(); |
- } |
- } |
- |
private void notifyPanelChanged() { |
setDirty(true); |