1596135 - debugger: open browser when debugging starts
authortoshihiro <toshihiro>
Tue, 21 Aug 2007 12:55:01 +0000 (12:55 +0000)
committertoshihiro <toshihiro>
Tue, 21 Aug 2007 12:55:01 +0000 (12:55 +0000)
net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPDebugUiMessages.properties
net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEnvironmentTab.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java

index cee0129..c33420d 100644 (file)
@@ -32,6 +32,7 @@ LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label=Remote
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label=Cross Platform debugging
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label=Remote &Sourcepath:
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label=Open with DBGSession URL in internal Browser
+LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInExternalBrowserCheckBox.label=Use external Web browser
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label=Mapped Path:
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote=remote
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local=local
index d7a6527..50d3212 100644 (file)
@@ -63,6 +63,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
 
        protected Button fOpenDBGSessionInBrowserCheckBox;
 
+       protected Button fOpenDBGSessionInExternalBrowserCheckBox;
+
        protected Button fPathMapRemoveButton;
 
        protected Button fPathMapAddButton;
@@ -111,11 +113,12 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                                setRemoteTabEnableState();
                        } else if (source == fRemoteDebugTranslate) {
                                setRemoteTabEnableState();
+                       } else if (source == fOpenDBGSessionInBrowserCheckBox) {
+                               setRemoteTabEnableState();
                        } else {
                                updateLaunchConfigurationDialog();
                        }
                        makeupTargetFile();
-
                }
 
        }
@@ -130,6 +133,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
 
        private static final boolean DEFAULT_OPEN_DBGSESSION_IN_BROWSER = true;
 
+       private static final boolean DEFAULT_OPEN_DBGSESSION_IN_EXTERNAL_BROWSER = false;
+
        static String[] columnTitles = {
                        PHPDebugUiMessages
                                        .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"),
@@ -189,6 +194,18 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                                GridData.HORIZONTAL_ALIGN_BEGINNING));
                fOpenDBGSessionInBrowserCheckBox.addSelectionListener(fListener);
 
+               // addendum
+               fOpenDBGSessionInExternalBrowserCheckBox = new Button(comp, SWT.CHECK);
+               fOpenDBGSessionInExternalBrowserCheckBox
+                               .setText(PHPDebugUiMessages
+                                               .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInExternalBrowserCheckBox.label"));
+               fOpenDBGSessionInExternalBrowserCheckBox.setLayoutData(new GridData(
+                               SWT.BEGINNING));
+               ((GridData) fOpenDBGSessionInExternalBrowserCheckBox.getLayoutData()).horizontalIndent = 16;
+               fOpenDBGSessionInExternalBrowserCheckBox
+                               .addSelectionListener(fListener);
+               // addendum
+
                label = new Label(comp, SWT.NONE);
                label
                                .setText(PHPDebugUiMessages
@@ -356,6 +373,7 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                        fPathMapRemoveButton.setEnabled(false);
                        fPathMapAddButton.setEnabled(false);
                        fOpenDBGSessionInBrowserCheckBox.setEnabled(false);
+                       fOpenDBGSessionInExternalBrowserCheckBox.setEnabled(false);
                } else {
                        setPathMapButtonsEnableState();
                }
@@ -372,6 +390,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                //
                if (fRemoteDebugCheckBox.getSelection()) {
                        fOpenDBGSessionInBrowserCheckBox.setEnabled(true);
+                       fOpenDBGSessionInExternalBrowserCheckBox
+                                       .setEnabled(fOpenDBGSessionInBrowserCheckBox.getSelection());
                        fRemoteDebugTranslate.setEnabled(true);
                        int selectCount = this.fRemoteDebugPathMapTable
                                        .getSelectionIndices().length;
@@ -586,6 +606,9 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                } catch (CoreException ce) {
                        fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG);
                }
+               if (fRemoteDebugCheckBox.getSelection()) {
+                       tabFolder.setSelection(0);
+               }
                try {
                        fRemoteDebugTranslate.setSelection(configuration.getAttribute(
                                        PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE,
@@ -603,7 +626,19 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                        fOpenDBGSessionInBrowserCheckBox
                                        .setSelection(DEFAULT_OPEN_DBGSESSION_IN_BROWSER);
                }
+               try {
+                       fOpenDBGSessionInExternalBrowserCheckBox
+                                       .setSelection(configuration
+                                                       .getAttribute(
+                                                                       PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_EXTERNAL_BROWSER,
+                                                                       DEFAULT_OPEN_DBGSESSION_IN_EXTERNAL_BROWSER));
+               } catch (CoreException ce) {
+                       fOpenDBGSessionInExternalBrowserCheckBox
+                                       .setSelection(DEFAULT_OPEN_DBGSESSION_IN_EXTERNAL_BROWSER);
+               }
+
                setRemoteTabEnableState();
+
                try {
                        fRemoteSourcePath.setText(configuration.getAttribute(
                                        PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
@@ -755,6 +790,10 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                configuration.setAttribute(
                                PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER,
                                fOpenDBGSessionInBrowserCheckBox.getSelection());
+               configuration
+                               .setAttribute(
+                                               PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_EXTERNAL_BROWSER,
+                                               fOpenDBGSessionInExternalBrowserCheckBox.getSelection());
        }
 
        protected Composite createPageRoot(Composite parent) {
index ffb100b..ab6157c 100644 (file)
@@ -68,8 +68,13 @@ public class DebuggerRunner extends InterpreterRunner {
                                JavaProject jproject = configuration.getProject();
                                IProject project = jproject.getProject();
                                IFile file = project.getFile(fileName);
-                               BrowserUtil.showPreview(file, true, "?DBGSESSID=1@clienthost:"
-                                               + port);
+                               if (configuration.useDBGSessionInExternalBrowser()) {
+                                       BrowserUtil.showBrowserAsExternal(file,
+                                                       "?DBGSESSID=1@clienthost:" + port);
+                               } else {
+                                       BrowserUtil.showPreview(file, true,
+                                                       "?DBGSESSID=1@clienthost:" + port);
+                               }
                        }
                });
        }
index 1675fb7..b7cfe1f 100644 (file)
@@ -207,4 +207,16 @@ public class InterpreterRunnerConfiguration {
                return "";
        }
 
+       public boolean useDBGSessionInExternalBrowser() {
+               try {
+                       return configuration
+                                       .getAttribute(
+                                                       PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_EXTERNAL_BROWSER,
+                                                       false);
+               } catch (CoreException e) {
+                       PHPLaunchingPlugin.log(e);
+               }
+               return false;
+       }
+
 }
index 894a2c9..f447aa1 100644 (file)
@@ -45,5 +45,8 @@ public interface PHPLaunchConfigurationAttribute {
        static final String OPEN_DBGSESSION_IN_BROWSER = PHPLaunchingPlugin.PLUGIN_ID
                        + ".OPEN_DBGSESSION_IN_BROWSER";
 
+       static final String OPEN_DBGSESSION_IN_EXTERNAL_BROWSER = PHPLaunchingPlugin.PLUGIN_ID
+                       + ".OPEN_DBGSESSION_IN_EXTERNAL_BROWSER";
+
        static final String FILE_MAP = PHPLaunchingPlugin.PLUGIN_ID + ".FILE_MAP";
 }
\ No newline at end of file
index d6ce54c..ef3b7a1 100644 (file)
@@ -1,5 +1,8 @@
 package net.sourceforge.phpeclipse.ui.editor;
 
+import java.net.MalformedURLException;
+import java.net.URL;
+
 import net.sourceforge.phpeclipse.ui.IPreferenceConstants;
 import net.sourceforge.phpeclipse.ui.WebUI;
 import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil;
@@ -12,6 +15,9 @@ import org.eclipse.ui.IViewReference;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
 import org.eclipse.ui.internal.Perspective;
 import org.eclipse.ui.internal.WorkbenchPage;
 import org.eclipse.ui.part.IShowInTarget;
@@ -187,4 +193,65 @@ public class BrowserUtil {
                }
        }
 
+       private static final String BROWSER_ID = "net.sourceforge.phpeclipse.browser";
+
+       /**
+        * convenient method to show browser as Editor
+        * 
+        */
+       public static void showBrowserAsEditor(IFile file, String queryString) {
+               showBrowser(IWorkbenchBrowserSupport.AS_EDITOR, file, queryString);
+       }
+
+       /**
+        * convenient method to show browser as External Web Browser
+        * 
+        */
+       public static void showBrowserAsExternal(IFile file, String queryString) {
+               showBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, file, queryString);
+       }
+
+       /**
+        * convenient method to show browser as View
+        * 
+        */
+       public static void showBrowserAsView(IFile file, String queryString) {
+               showBrowser(IWorkbenchBrowserSupport.AS_VIEW, file, queryString);
+       }
+
+       /**
+        * Show browser according to General settings
+        * 
+        * See IWorkbenchBrowserSupport and DefaultWorkbenchBrowserSupport.
+        */
+       public static void showBrowser(int style, IFile file, String queryString) {
+               ShowInContextBrowser context = getShowInContext(file, true, queryString);
+               String url = context.getLocalhostUrl();
+               String id = BROWSER_ID;
+               switch (style) {
+               case IWorkbenchBrowserSupport.AS_EXTERNAL:
+                       id += ".x";
+                       break;
+               case IWorkbenchBrowserSupport.AS_EDITOR:
+                       id += ".e";
+                       break;
+               case IWorkbenchBrowserSupport.AS_VIEW:
+                       id += ".v";
+                       break;
+               }
+               style |= IWorkbenchBrowserSupport.LOCATION_BAR
+                               | IWorkbenchBrowserSupport.NAVIGATION_BAR
+                               | IWorkbenchBrowserSupport.STATUS;
+               try {
+                       IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport()
+                                       .createBrowser(style, id, null, url);
+                       browser.openURL(new URL(url));
+
+               } catch (PartInitException e) {
+                       WebUI.log(e);
+               } catch (MalformedURLException e) {
+                       WebUI.log(e);
+               }
+       }
+
 }