import javax.xml.parsers.SAXParserFactory;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
public class PHPRuntime {
protected static PHPRuntime runtime;
-
+
protected List installedInterpreters;
protected PHPInterpreter selectedInterpreter;
protected PHPRuntime() {
}
return runtime;
}
-
+
public PHPInterpreter getSelectedInterpreter() {
if (selectedInterpreter == null) {
loadRuntimeConfiguration();
if (each.getInstallLocation().toString().equals(installLocation))
return each;
}
-
+
return getSelectedInterpreter();
}
loadRuntimeConfiguration();
return installedInterpreters;
}
-
+
public void setInstalledInterpreters(List newInstalledInterpreters) {
installedInterpreters = newInstalledInterpreters;
if (installedInterpreters.size() > 0)
else
setSelectedInterpreter(null);
}
-
+
protected void saveRuntimeConfiguration() {
writeXML(getRuntimeConfigurationWriter());
}
return null;
}
-
+
protected void loadRuntimeConfiguration() {
installedInterpreters = new ArrayList();
try {
} catch(FileNotFoundException e) {}
return new StringReader("");
}
-
+
protected void writeXML(Writer writer) {
try {
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><runtimeconfig>");
Iterator interpretersIterator = installedInterpreters.iterator();
while (interpretersIterator.hasNext()) {
writer.write("<interpreter name=\"");
-
+
PHPInterpreter entry = (PHPInterpreter) interpretersIterator.next();
// writer.write(entry.getName());
writer.write("\" path=\"");
writer.write("\"");
if (entry.equals(selectedInterpreter))
writer.write(" selected=\"true\"");
-
+
writer.write("/>");
}
writer.write("</runtimeconfig>");
public void skippedEntity(String name) throws SAXException {}
};
}
-
+
protected File getRuntimeConfigurationFile() {
IPath stateLocation = PHPLaunchingPlugin.getDefault().getStateLocation();
IPath fileLocation = stateLocation.append("runtimeConfiguration.xml");