improved syntax highligthing
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / PHPEclipseShowAction.java
index a6b8466..7cd25dc 100644 (file)
@@ -48,16 +48,16 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
        public void setActivePart(IAction action, IWorkbenchPart targetPart) {
                workbenchPart = targetPart;
        }
-  
-//  public static void open(final URL url, final Shell shell, final String dialogTitle) {
-//    IHelp help= WorkbenchHelp.getHelpSupport();
-//    if (help != null) {
-//      WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
-//    } else {
-//      showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
-//    }
-//  }
-  
+
+       //  public static void open(final URL url, final Shell shell, final String dialogTitle) {
+       //    IHelp help= WorkbenchHelp.getHelpSupport();
+       //    if (help != null) {
+       //      WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
+       //    } else {
+       //      showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
+       //    }
+       //  }
+
        public void run(IAction action) {
                ISelectionProvider selectionProvider = null;
                selectionProvider = workbenchPart.getSite().getSelectionProvider();
@@ -91,8 +91,21 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
                                                //            }
 
                                                String fileName = file.getLocation().toString();
+            String lowerCaseFileName = fileName.toLowerCase();
                                                //       fileName = "http://localhost"+fileName.replaceAll("c:", "");
-                                               fileName = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + 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());
+            } else {
+              MessageDialog.openInformation(shell, "Wrong DocumentRoot", "Adjust DocumentRoot: " + documentRoot);
+              return;
+            }
+            
+                                               fileName = store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + fileName.replaceAll(documentRoot, "");
 
                                                try {
                                                        if (store.getBoolean(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF)) {
@@ -125,8 +138,8 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
                        }
                }
        } /**
-                                        * @see IActionDelegate#selectionChanged(IAction, ISelection)
-                                        */
+                                                * @see IActionDelegate#selectionChanged(IAction, ISelection)
+                                                */
        public void selectionChanged(IAction action, ISelection selection) {
        }