maps remote files to local files
authorcperkonig <cperkonig>
Wed, 11 Feb 2004 22:22:40 +0000 (22:22 +0000)
committercperkonig <cperkonig>
Wed, 11 Feb 2004 22:22:40 +0000 (22:22 +0000)
net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPSourceLocator.java

index 07d0841..c61f815 100644 (file)
@@ -1,5 +1,7 @@
 package net.sourceforge.phpdt.internal.debug.ui;
 
+import java.util.Map;
+
 import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame;
 import net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationAttribute;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
@@ -11,13 +13,14 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.boot.BootLoader;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.model.IPersistableSourceLocator;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.ui.ISourcePresentation;
-import org.eclipse.ui.IEditorDescriptor;
+//import org.eclipse.ui.IEditorDescriptor;
 import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorRegistry;
+//import org.eclipse.ui.IEditorRegistry;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
@@ -26,6 +29,10 @@ import org.eclipse.ui.part.FileEditorInput;
 
 public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePresentation {
   private String absoluteWorkingDirectory;
+  private Map fileMap = null;
+       private boolean remoteDebug;
+       private IPath remotePath;
+       private String projectName;
 
   public PHPSourceLocator() {
 
@@ -52,13 +59,47 @@ public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePrese
    */
   public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException {
     this.absoluteWorkingDirectory = configuration.getAttribute(PHPLaunchConfigurationAttribute.WORKING_DIRECTORY, "");
+               this.remoteDebug=configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG,false);
+               this.fileMap = configuration.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map)null);
+               this.projectName =configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
+               
+               if (BootLoader.getOS().equals(BootLoader.OS_WIN32))
+                       this.remotePath= new Path((configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, "")).toLowerCase());
+               else
+                       this.remotePath= new Path(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
+               
+//             system.os.name
+
   }
 
   /**
    * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame)
    */
   public Object getSourceElement(IStackFrame stackFrame) {
-    return ((PHPStackFrame) stackFrame).getFileName();
+  
+               String key=((PHPStackFrame) stackFrame).getFileName();
+
+               
+               String file="";
+                   
+    if (remoteDebug)
+    {
+                       IPath path = new Path(key);
+                       if (remotePath.isPrefixOf(path))
+                       {
+                               IPath projectPath;
+                               path=path.removeFirstSegments(remotePath.matchingFirstSegments(path));
+                               file=path.toString();
+                               projectPath=(PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getLocation());
+                               file=(projectPath.append(path)).toString();                     
+                       }
+//     file=(String)(fileMap.get(key));
+    } else
+    {
+       file=key;
+    }
+    
+    return file;
   }
 
   /**
@@ -78,6 +119,8 @@ public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePrese
     IWorkbenchWindow window = workbench.getWorkbenchWindows()[0];
     IWorkbenchPage page = window.getActivePage();
     IPath path = new Path(filename);
+    
+    
 
     // If the file exists in the workspace, open it
     IFile eclipseFile = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation(path);