Added DESC_INC and IMG_INC for the image of include/require in outline (maybe we...
[phpeclipse.git] / net.sourceforge.phpeclipse.launching / src / net / sourceforge / phpdt / internal / launching / InterpreterRunnerConfiguration.java
1 package net.sourceforge.phpdt.internal.launching;
2
3 import java.io.File;
4
5 import net.sourceforge.phpeclipse.resourcesview.PHPProject;
6 import org.eclipse.core.resources.IProject;
7 import org.eclipse.core.runtime.CoreException;
8 import org.eclipse.core.runtime.IPath;
9 import org.eclipse.core.runtime.Path;
10 import org.eclipse.debug.core.ILaunchConfiguration;
11
12 public class InterpreterRunnerConfiguration {
13         protected ILaunchConfiguration configuration;
14
15         public InterpreterRunnerConfiguration(ILaunchConfiguration aConfiguration) {
16                 configuration = aConfiguration;
17         }
18         
19         public String getAbsoluteFileName() {
20                 IPath path = new Path(getFileName());
21                 IProject project = getProject().getProject();
22
23                 return project.getLocation().toOSString() + "/" + getFileName();
24         }
25         
26         public String getFileName() {
27                 String fileName = "";
28
29                 try {
30                         fileName = configuration.getAttribute(PHPLaunchConfigurationAttribute.FILE_NAME, "No file specified in configuration");
31                 } catch(CoreException e) {}
32                 
33                 return fileName.replace('\\', '/');
34         }
35         
36         public PHPProject getProject() {
37                 String projectName = "";
38                 
39                 try {
40                         projectName = configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
41                 } catch(CoreException e) {
42                         PHPLaunchingPlugin.getDefault().log(e);
43                 }
44
45                 IProject project = PHPLaunchingPlugin.getWorkspace().getRoot().getProject(projectName);
46
47                 PHPProject phpProject = new PHPProject();
48                 phpProject.setProject(project);
49                 return phpProject;
50         }
51         
52         public File getAbsoluteWorkingDirectory() {
53                 String file = null;
54                 try {
55                         file = configuration.getAttribute(PHPLaunchConfigurationAttribute.WORKING_DIRECTORY, "");
56                 } catch(CoreException e) {
57                         PHPLaunchingPlugin.log(e);
58                 }
59                 return new File(file);
60         }
61         
62         public String getInterpreterArguments() {
63                 try {
64                         return configuration.getAttribute(PHPLaunchConfigurationAttribute.INTERPRETER_ARGUMENTS, "");
65                 } catch(CoreException e) {}
66                 
67                 return "";
68         }
69         
70         public String getProgramArguments() {
71                 try {
72                         return configuration.getAttribute(PHPLaunchConfigurationAttribute.PROGRAM_ARGUMENTS, "");
73                 } catch (CoreException e) {}
74                 
75                 return "";
76         }
77
78         public PHPInterpreter getInterpreter() {
79                 String selectedInterpreter = null;
80                 try {
81                         selectedInterpreter = configuration.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
82                 } catch(CoreException e) {}
83                 
84                 return PHPRuntime.getDefault().getInterpreter(selectedInterpreter);
85         }
86 }