# HG changeset patch # User Eugene Ostroukhov # Date 1279213731 25200 # Node ID ed815e0eef9a4e53c948fafb64c1ab93b70268e7 # Parent fb993a790bc41a2d4b51a1e5a0e8cc453249f2ba Bug 3268 - Debugger does not start on Windows XP diff -r fb993a790bc4 -r ed815e0eef9a org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/ChromeDebugUtils.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/ChromeDebugUtils.java Wed Jul 14 16:31:49 2010 -0700 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/ChromeDebugUtils.java Thu Jul 15 10:08:51 2010 -0700 @@ -29,7 +29,13 @@ File chromeExecutable = new File(file, getExecutable()); if (chromeExecutable.isFile()) { return chromeExecutable.getAbsolutePath(); + } else if (CoreUtil.isMac() && file.getName().equals("Google Chrome.app")) { + return getExecutablePath(file.getParent()); } + } else if (file.isFile()) { + if (file.getName().equalsIgnoreCase(getExecutable())) { + return file.getAbsolutePath(); + } } return null; } diff -r fb993a790bc4 -r ed815e0eef9a org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/PreferenceInitializer.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/PreferenceInitializer.java Wed Jul 14 16:31:49 2010 -0700 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/PreferenceInitializer.java Thu Jul 15 10:08:51 2010 -0700 @@ -45,6 +45,9 @@ } String property = System.getProperty("user.home"); File folder = new File(property, DEFAULT_CHROME_LOCATION); + if (!folder.exists()) { + folder = new File("C:/Program Files/Google/Chrome/Application/"); + } return folder; } diff -r fb993a790bc4 -r ed815e0eef9a org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/ui/DebugPreferencePage.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/ui/DebugPreferencePage.java Wed Jul 14 16:31:49 2010 -0700 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/ui/DebugPreferencePage.java Thu Jul 15 10:08:51 2010 -0700 @@ -18,15 +18,19 @@ *******************************************************************************/ package org.symbian.tools.wrttools.debug.ui; +import java.io.File; + import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.symbian.tools.wrttools.debug.internal.Activator; +import org.symbian.tools.wrttools.debug.internal.ChromeDebugUtils; import org.symbian.tools.wrttools.debug.internal.IConstants; public class DebugPreferencePage extends FieldEditorPreferencePage implements @@ -42,8 +46,22 @@ @Override protected void createFieldEditors() { - DirectoryFieldEditor editor = new DirectoryFieldEditor("chrome", "Chrome Install Location:", getFieldEditorParent()); - editor.setPreferenceName(IConstants.PREF_NAME_CHROME_LOCATION); + DirectoryFieldEditor editor = new DirectoryFieldEditor(IConstants.PREF_NAME_CHROME_LOCATION, + "Chrome Install Location:", + getFieldEditorParent()) { + @Override + protected boolean doCheckState() { + if (super.doCheckState()) { + String message = validate(getStringValue()); + setErrorMessage(message); + return message == null; + } else { + return false; + } + } + }; + editor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); + editor.setEmptyStringAllowed(false); addField(editor); check = new Button(getFieldEditorParent(), SWT.CHECK); @@ -54,6 +72,19 @@ IConstants.PREF_SHOW_RESOURCE_CHANGE_ERROR))); } + + protected String validate(String newValue) { + String error = null; + if (newValue == null || newValue.trim().length() == 0) { + error = "Chrome install location is not specified"; + } else if (!new File(newValue).exists()) { + error = String.format("%s does not exist", newValue); + } else if (ChromeDebugUtils.getExecutablePath(newValue) == null) { + error = String.format("%s does not contain Chrome executable", newValue); + } + return error; + } + @Override protected void performDefaults() { super.performDefaults();