misc changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / PHPEclipseShowAction.java
index 0366b57..0d3b56f 100644 (file)
@@ -16,11 +16,11 @@ import java.net.URL;
 import java.text.MessageFormat;
 import java.util.Iterator;
 
-import net.sourceforge.phpeclipse.IPreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.overlaypages.Util;
+import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction;
 import net.sourceforge.phpeclipse.views.PHPConsole;
-import net.sourceforge.phpeclipse.views.browser.BrowserView;
+import net.sourceforge.phpeclipse.webbrowser.views.BrowserView;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.jface.action.IAction;
@@ -35,7 +35,6 @@ import org.eclipse.ui.IObjectActionDelegate;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
 //import org.eclipse.update.internal.ui.UpdatePerspective;
 //import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser;
 public class PHPEclipseShowAction implements IObjectActionDelegate {
@@ -74,7 +73,7 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
             // single file:
             IFile file = (IFile) resource;
             String localhostURL;
-            if ((localhostURL = getLocalhostURL(store, (IFile) resource)) == null) {
+            if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(store, (IFile) resource)) == null) {
               MessageDialog.openInformation(shell,
                   "Couldn't create localhost URL",
                   "Please configure your localhost and documentRoot");
@@ -116,28 +115,28 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
    */
   public void selectionChanged(IAction action, ISelection selection) {
   }
-  public static String getLocalhostURL(IPreferenceStore store, IFile file) {
-    if (store == null) {
-      store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-    }
-    // IPath path = file.getFullPath();
-    String localhostURL = file.getLocation().toString();
-    String lowerCaseFileName = localhostURL.toLowerCase();
-  //  String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
-    String documentRoot = Util.getMiscProjectsPreferenceValue(
-               file.getProject(), IPreferenceConstants.PHP_DOCUMENTROOT_PREF);
-    
-    documentRoot = documentRoot.replace('\\', '/');
-    documentRoot = documentRoot.toLowerCase();
-    
-    if (lowerCaseFileName.startsWith(documentRoot)) {
-      localhostURL = localhostURL.substring(documentRoot.length());
-    } else {
-      return null;  
-    }
-//    return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
-    return Util.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + localhostURL;
-  }
+//  public static String getLocalhostURL(IPreferenceStore store, IFile file) {
+//    if (store == null) {
+//      store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+//    }
+//    // IPath path = file.getFullPath();
+//    String localhostURL = file.getLocation().toString();
+//    String lowerCaseFileName = localhostURL.toLowerCase();
+//  //  String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
+//    String documentRoot = Util.getMiscProjectsPreferenceValue(
+//             file.getProject(), IPreferenceConstants.PHP_DOCUMENTROOT_PREF);
+//    
+//    documentRoot = documentRoot.replace('\\', '/');
+//    documentRoot = documentRoot.toLowerCase();
+//    
+//    if (lowerCaseFileName.startsWith(documentRoot)) {
+//      localhostURL = localhostURL.substring(documentRoot.length());
+//    } else {
+//      return null;  
+//    }
+////    return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
+//    return Util.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + localhostURL;
+//  }
   
   public static void open(final URL url, final Shell shell,
       final String dialogTitle) {