Added context help menu for php function names. The description of the fundtion opens...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / PHPEclipseShowAction.java
index 5018ac6..f375331 100644 (file)
@@ -21,18 +21,18 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.help.IHelp;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.program.Program;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IObjectActionDelegate;
 import org.eclipse.ui.IWorkbenchPart;
-
 import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.help.IHelp;
 //import org.eclipse.jdt.internal.ui.actions.OpenBrowserUtil;
 // import org.eclipse.help.ui.browser.LaunchURL;
 
@@ -88,31 +88,26 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
             // single file:
             IFile file = (IFile) resource;
             IPath path = file.getFullPath();
-            //            if (j2h==null) {
-            //              shell = new Shell();
-            //              j2h = new Java2HTML(shell); 
-            //            }
 
-            String fileName = file.getLocation().toString();
-            String lowerCaseFileName = fileName.toLowerCase();
+            String localhostURL = file.getLocation().toString();
+            String lowerCaseFileName = localhostURL.toLowerCase();
             //       fileName = "http://localhost"+fileName.replaceAll("c:", "");
             String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
             documentRoot = documentRoot.replace('\\', '/');
             documentRoot = documentRoot.toLowerCase();
-            MessageDialog.openInformation(shell, "lowerCaseFileName", "lowerCaseFileName: " + lowerCaseFileName);
-
+            
             if (lowerCaseFileName.startsWith(documentRoot)) {
-              fileName = fileName.substring(documentRoot.length());
+              localhostURL = localhostURL.substring(documentRoot.length());
             } else {
               MessageDialog.openInformation(shell, "Wrong DocumentRoot", "Adjust DocumentRoot: " + documentRoot);
               return;
             }
 
-            fileName = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + fileName.replaceAll(documentRoot, "");
+            localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, "");
 
             try {
               if (store.getBoolean(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF)) {
-                String[] arguments = { fileName };
+                String[] arguments = { localhostURL };
                 MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF));
 
                 Runtime runtime = Runtime.getRuntime();
@@ -120,23 +115,17 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
                 //                     runtime.exec(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF) + " " + fileName);
                 //                                                             runtime.exec("command.com /c start iexplore " + fileName);
               } else {
-                open(new URL(fileName), shell, fileName);
+            //    MessageDialog.openInformation(shell, "localhostURL", "localhostURL: " + localhostURL);
+            //  this doesn't work under win98 ?
+            //     Program.launch(localhostURL);
+                open(new URL(localhostURL), shell, localhostURL);
               }
             } catch (MalformedURLException e) {
               MessageDialog.openInformation(shell, "MalformedURLException: ", e.toString());
             } catch (IOException e) {
-              MessageDialog.openInformation(shell, "IOException", "Cannot show: " + fileName);
+              MessageDialog.openInformation(shell, "IOException", "Cannot show: " + localhostURL);
 
             }
-
-            //            MessageDialog.openInformation(shell, "PHPEclipse", "FileName - " + fileName);
-            //
-            //            Runtime runtime = Runtime.getRuntime();
-            //            try {
-            //                                                 runtime.exec("command.com /c start iexplore "+fileName);
-
-            //            MessageDialog.openInformation(shell, "J2h Plug-in", "FileName - " + fileName);
-            //            j2h.convert( fileName );
         }
       }
     }