60f34555e25d83d894627c1532d4bc9b72a37ab4
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / launching / PHPSourcePathComputerDelegate.java
1 package net.sourceforge.phpeclipse.xdebug.php.launching;
2
3
4 import org.eclipse.core.resources.IProject;
5 import org.eclipse.core.resources.ResourcesPlugin;
6 import org.eclipse.core.runtime.CoreException;
7 import org.eclipse.core.runtime.IProgressMonitor;
8 import org.eclipse.debug.core.ILaunchConfiguration;
9 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
10 import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
11 import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
12 import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
13
14 public class PHPSourcePathComputerDelegate implements ISourcePathComputerDelegate {
15
16         public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
17 //              String path = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROGRAM, (String)null);
18 //              ISourceContainer sourceContainer = null;
19 //              if (path != null) {
20 //                      IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
21 //                      if (resource != null) {
22 //                              IContainer container = resource.getParent();
23 //                              if (container.getType() == IResource.PROJECT) {
24 //                                      sourceContainer = new ProjectSourceContainer((IProject)container, false);
25 //                              } else if (container.getType() == IResource.FOLDER) {
26 //                                      sourceContainer = new FolderSourceContainer(container, false);
27 //                              }
28 //                      }
29 //              }
30 //              if (sourceContainer == null) {
31 //                      sourceContainer = new WorkspaceSourceContainer();
32 //              }
33 //              return new ISourceContainer[]{sourceContainer};
34                 String project = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROJECT, (String)null);
35                 ISourceContainer sourceContainer = null;
36                 if (project != null) {
37                         IProject resource = ResourcesPlugin.getWorkspace().getRoot().getProject(project);
38                         if (resource != null) {
39                                 sourceContainer = new ProjectSourceContainer(resource, false);
40                         }
41                 }
42                 if (sourceContainer == null) {
43                         sourceContainer = new WorkspaceSourceContainer();
44                 }
45                 return new ISourceContainer[]{sourceContainer};
46         
47         }
48
49 }