1 package net.sourceforge.phpdt.internal.debug.ui;
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
4 import org.eclipse.core.resources.IFile;
5 import org.eclipse.core.runtime.CoreException;
6 import org.eclipse.core.runtime.IStatus;
7 import org.eclipse.core.runtime.Path;
8 import org.eclipse.debug.core.ILaunchConfiguration;
9 import org.eclipse.debug.core.model.IPersistableSourceLocator;
10 import org.eclipse.debug.core.model.IStackFrame;
11 import org.eclipse.debug.ui.ISourcePresentation;
12 import org.eclipse.ui.IEditorInput;
13 import org.eclipse.ui.PlatformUI;
14 import org.eclipse.ui.part.FileEditorInput;
15 import net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationAttribute;
17 public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePresentation {
18 private String absoluteWorkingDirectory;
20 public PHPSourceLocator() {
24 public String getAbsoluteWorkingDirectory() {
25 return absoluteWorkingDirectory;
28 * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
30 public String getMemento() throws CoreException {
35 * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(String)
37 public void initializeFromMemento(String memento) throws CoreException {
41 * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(ILaunchConfiguration)
43 public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException {
44 this.absoluteWorkingDirectory = configuration.getAttribute(PHPLaunchConfigurationAttribute.WORKING_DIRECTORY, "");
48 * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame)
50 public Object getSourceElement(IStackFrame stackFrame) {
52 //return ((PHPStackFrame) stackFrame).getFileName();
56 * @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(IEditorInput, Object)
58 public String getEditorId(IEditorInput input, Object element) {
59 return PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor((String) element).getId();
63 * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(Object)
65 public IEditorInput getEditorInput(Object element) {
67 String filename = (String) element;
68 IFile eclipseFile = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation(new Path(filename));
69 if (eclipseFile == null) {
70 filename = this.getAbsoluteWorkingDirectory() + "/" + filename;
71 eclipseFile = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation(new Path(filename));
72 if (eclipseFile == null) {
73 PHPeclipsePlugin.log(IStatus.INFO, "Could not find file \"" + element + "\".");
77 return new FileEditorInput(eclipseFile);