From: toshihiro Date: Thu, 23 Aug 2007 06:42:09 +0000 (+0000) Subject: Modified: 1596135 - debugger: open browser when debugging starts X-Git-Url: http://secure.phpeclipse.com Modified: 1596135 - debugger: open browser when debugging starts Since nothing will happen when DocumentRoot is incorrect. Show error message. --- diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java index ef6360d..adc6a51 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java @@ -8,7 +8,7 @@ * Contributors: * Christopher Lenz - initial implementation * - * $Id: WebUI.java,v 1.9 2007-08-20 02:33:07 toshihiro Exp $ + * $Id: WebUI.java,v 1.10 2007-08-23 06:42:09 toshihiro Exp $ */ package net.sourceforge.phpeclipse.ui; @@ -42,7 +42,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; */ public class WebUI extends AbstractUIPlugin implements IPreferenceConstants { - private static final String PLUGIN_ID = "net.sourceforge.phpeclipse.ui"; + public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.ui"; private static final String CUSTOM_TEMPLATES_KEY = "net.sourceforge.phpeclipse.ui.templates"; //$NON-NLS-1$ @@ -197,7 +197,7 @@ public class WebUI extends AbstractUIPlugin implements IPreferenceConstants { } public static void log(Throwable e) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, e - .getLocalizedMessage(), e)); + log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "" + + e.getLocalizedMessage(), e)); } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java index ef3b7a1..0282fd9 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java @@ -5,11 +5,16 @@ import java.net.URL; import net.sourceforge.phpeclipse.ui.IPreferenceConstants; import net.sourceforge.phpeclipse.ui.WebUI; +import net.sourceforge.phpeclipse.ui.internal.WebUIMessages; import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil; import net.sourceforge.phpeclipse.webbrowser.views.BrowserView; import net.sourceforge.phpeclipse.webbrowser.views.ShowInContextBrowser; import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbenchPage; @@ -227,6 +232,18 @@ public class BrowserUtil { public static void showBrowser(int style, IFile file, String queryString) { ShowInContextBrowser context = getShowInContext(file, true, queryString); String url = context.getLocalhostUrl(); + if (url == null) { + String dialogTitle = WebUIMessages + .getString("BrowserUtil.error.dialog.title"); + String message = WebUIMessages + .getString("BrowserUtil.null.url.message"); + String reason = WebUIMessages + .getString("BrowserUtil.null.url.reason"); + IStatus status = new Status(IStatus.ERROR, WebUI.PLUGIN_ID, 0, + reason, null); + ErrorDialog.openError(new Shell(), dialogTitle, message, status); + return; + } String id = BROWSER_ID; switch (style) { case IWorkbenchBrowserSupport.AS_EXTERNAL: diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/internal/WebUIMessages.properties b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/internal/WebUIMessages.properties index 259e7c6..8448791 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/internal/WebUIMessages.properties +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/internal/WebUIMessages.properties @@ -8,7 +8,7 @@ # Contributors: # Christopher Lenz - initial english resources # -# $Id: WebUIMessages.properties,v 1.1 2004-09-02 18:26:29 jsurfer Exp $ +# $Id: WebUIMessages.properties,v 1.2 2007-08-23 06:42:09 toshihiro Exp $ # # Outline Page ----------------------------------------------------------------- @@ -21,3 +21,7 @@ OutlinePage.linkWithEditor.description = Link with editor # Preview View ----------------------------------------------------------------- BrowserPreview.notAvailable = A preview is not available. + +BrowserUtil.error.dialog.title=Open Browser Error +BrowserUtil.null.url.message=Invalid URL +BrowserUtil.null.url.reason=DocumentRoot may be incorrect. Make sure Project Settings.