From 8dc8a8ff14d980ad53cda65ef1fc6fedb70e2c56 Mon Sep 17 00:00:00 2001 From: khartlage Date: Sun, 29 Dec 2002 18:58:08 +0000 Subject: [PATCH] use module net.sourceforge.phpeclipse.launching instead --- .../.classpath | 18 -- .../.project | 29 ---- .../.template | 4 - .../plugin.properties | 3 - .../plugin.xml | 47 ------ .../internal/launching/InterpreterRunner.java | 90 ---------- .../launching/InterpreterRunnerConfiguration.java | 86 ---------- .../phpdt/internal/launching/PHPInterpreter.java | 60 ------- .../launching/PHPLaunchConfigurationAttribute.java | 18 -- .../launching/PHPLaunchConfigurationDelegate.java | 34 ---- .../internal/launching/PHPLaunchingMessages.java | 21 --- .../launching/PHPLaunchingMessages.properties | 6 - .../internal/launching/PHPLaunchingPlugin.java | 35 ---- .../phpdt/internal/launching/PHPRuntime.java | 174 -------------------- 14 files changed, 0 insertions(+), 625 deletions(-) delete mode 100644 net.sourceforge.phpeclipse.debug.launching/.classpath delete mode 100644 net.sourceforge.phpeclipse.debug.launching/.project delete mode 100644 net.sourceforge.phpeclipse.debug.launching/.template delete mode 100644 net.sourceforge.phpeclipse.debug.launching/plugin.properties delete mode 100644 net.sourceforge.phpeclipse.debug.launching/plugin.xml delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunner.java delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPInterpreter.java delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingMessages.java delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingMessages.properties delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingPlugin.java delete mode 100644 net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPRuntime.java diff --git a/net.sourceforge.phpeclipse.debug.launching/.classpath b/net.sourceforge.phpeclipse.debug.launching/.classpath deleted file mode 100644 index 40e8710..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/.classpath +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/net.sourceforge.phpeclipse.debug.launching/.project b/net.sourceforge.phpeclipse.debug.launching/.project deleted file mode 100644 index 6472dbe..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/.project +++ /dev/null @@ -1,29 +0,0 @@ - - - net.sourceforge.phpeclipse.launching - - - net.sourceforge.phpeclipse - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/net.sourceforge.phpeclipse.debug.launching/.template b/net.sourceforge.phpeclipse.debug.launching/.template deleted file mode 100644 index d65e0f4..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/.template +++ /dev/null @@ -1,4 +0,0 @@ - -
-

Tips on working with this plug-in project

  • For the view of the new plug-in at a glance, go to the Overview.
  • You can test the contributions of this plug-in by launching another instance of the workbench. On the Run menu, click Run As and choose Run-time Workbench from the available choices.
  • You can add more functionality to this plug-in by adding extensions using the New Extension Wizard.
  • The plug-in project contains Java code that you can debug. Place breakpoints in Java classes. On the Run menu, select Debug As and choose Run-time Workbench from the available choices.
  • -
    diff --git a/net.sourceforge.phpeclipse.debug.launching/plugin.properties b/net.sourceforge.phpeclipse.debug.launching/plugin.properties deleted file mode 100644 index 973f149..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/plugin.properties +++ /dev/null @@ -1,3 +0,0 @@ - -Plugin.name=PHPEclipse Launching Support -LaunchConfigurationTypePHPApplication.name=PHP Application \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.debug.launching/plugin.xml b/net.sourceforge.phpeclipse.debug.launching/plugin.xml deleted file mode 100644 index 170f061..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/plugin.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunner.java b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunner.java deleted file mode 100644 index 5e76ed5..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunner.java +++ /dev/null @@ -1,90 +0,0 @@ -package net.sourceforge.phpdt.internal.launching; - -import java.io.File; -import java.io.IOException; -import java.util.Iterator; - -import net.sourceforge.phpeclipse.resourcesview.PHPProject; -import org.eclipse.core.boot.BootLoader; -import org.eclipse.core.resources.IProject; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IProcess; - -public class InterpreterRunner { - - public InterpreterRunner() { - } - - public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) { - String commandLine = renderCommandLine(configuration); - File workingDirectory = configuration.getAbsoluteWorkingDirectory(); - - Process nativePHPProcess = null; - try { - nativePHPProcess = configuration.getInterpreter().exec(commandLine, workingDirectory); - } catch (IOException e) { - throw new RuntimeException("Unable to execute interpreter: " + commandLine + workingDirectory); - } - - IProcess process = DebugPlugin.getDefault().newProcess(launch, nativePHPProcess, renderLabel(configuration)); - process.setAttribute(PHPLaunchingPlugin.PLUGIN_ID + ".launcher.cmdline", commandLine); - return process ; - } - - protected String renderLabel(InterpreterRunnerConfiguration configuration) { - StringBuffer buffer = new StringBuffer(); - - PHPInterpreter interpreter = configuration.getInterpreter(); - buffer.append("PHP "); - buffer.append(interpreter.getCommand()); - buffer.append(" : "); - buffer.append(configuration.getFileName()); - - return buffer.toString(); - } - - protected String renderCommandLine(InterpreterRunnerConfiguration configuration) { - PHPInterpreter interpreter = configuration.getInterpreter(); - - StringBuffer buffer = new StringBuffer(); - buffer.append(this.getDebugCommandLineArgument()); - // buffer.append(renderLoadPath(configuration)); - buffer.append(" " + configuration.getInterpreterArguments()); - // buffer.append(interpreter.endOfOptionsDelimeter); - buffer.append(" " + osDependentPath(configuration.getAbsoluteFileName())); - buffer.append(" " + configuration.getProgramArguments()); - - return buffer.toString(); - } - -// protected String renderLoadPath(InterpreterRunnerConfiguration configuration) { -// StringBuffer loadPath = new StringBuffer(); -// -// PHPProject project = configuration.getProject(); -// addToLoadPath(loadPath, project.getProject()); -// -// Iterator referencedProjects = project.getReferencedProjects().iterator(); -// while (referencedProjects.hasNext()) -// addToLoadPath(loadPath, (IProject) referencedProjects.next()); -// -// return loadPath.toString(); -// } - -// protected void addToLoadPath(StringBuffer loadPath, IProject project) { -// -// loadPath.append(" -I " + osDependentPath(project.getLocation().toOSString())); -// } - - protected String osDependentPath(String aPath) { - if (BootLoader.getOS().equals(BootLoader.OS_WIN32)) - aPath = "\"" + aPath + "\""; - - return aPath; - } - - protected String getDebugCommandLineArgument() { - return "" ; - } - -} diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java deleted file mode 100644 index 5af6d02..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java +++ /dev/null @@ -1,86 +0,0 @@ -package net.sourceforge.phpdt.internal.launching; - -import java.io.File; - -import net.sourceforge.phpeclipse.resourcesview.PHPProject; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.debug.core.ILaunchConfiguration; - -public class InterpreterRunnerConfiguration { - protected ILaunchConfiguration configuration; - - public InterpreterRunnerConfiguration(ILaunchConfiguration aConfiguration) { - configuration = aConfiguration; - } - - public String getAbsoluteFileName() { - IPath path = new Path(getFileName()); - IProject project = getProject().getProject(); - - return project.getLocation().toOSString() + "/" + getFileName(); - } - - public String getFileName() { - String fileName = ""; - - try { - fileName = configuration.getAttribute(PHPLaunchConfigurationAttribute.FILE_NAME, "No file specified in configuration"); - } catch(CoreException e) {} - - return fileName.replace('\\', '/'); - } - - public PHPProject getProject() { - String projectName = ""; - - try { - projectName = configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, ""); - } catch(CoreException e) { - PHPLaunchingPlugin.getDefault().log(e); - } - - IProject project = PHPLaunchingPlugin.getWorkspace().getRoot().getProject(projectName); - - PHPProject phpProject = new PHPProject(); - phpProject.setProject(project); - return phpProject; - } - - public File getAbsoluteWorkingDirectory() { - String file = null; - try { - file = configuration.getAttribute(PHPLaunchConfigurationAttribute.WORKING_DIRECTORY, ""); - } catch(CoreException e) { - PHPLaunchingPlugin.log(e); - } - return new File(file); - } - - public String getInterpreterArguments() { - try { - return configuration.getAttribute(PHPLaunchConfigurationAttribute.INTERPRETER_ARGUMENTS, ""); - } catch(CoreException e) {} - - return ""; - } - - public String getProgramArguments() { - try { - return configuration.getAttribute(PHPLaunchConfigurationAttribute.PROGRAM_ARGUMENTS, ""); - } catch (CoreException e) {} - - return ""; - } - - public PHPInterpreter getInterpreter() { - String selectedInterpreter = null; - try { - selectedInterpreter = configuration.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, ""); - } catch(CoreException e) {} - - return PHPRuntime.getDefault().getInterpreter(selectedInterpreter); - } -} diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPInterpreter.java b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPInterpreter.java deleted file mode 100644 index 2e342b9..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPInterpreter.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.sourceforge.phpdt.internal.launching; - -import java.io.File; -import java.io.IOException; - -import org.eclipse.core.internal.resources.OS; -import org.eclipse.core.runtime.IPath; - -public class PHPInterpreter { - //public final String endOfOptionsDelimeter = " -- "; - - protected IPath installLocation; - protected String name; - - public PHPInterpreter(String aName, IPath validInstallLocation) { - name = aName; - installLocation = validInstallLocation; - } - - public IPath getInstallLocation() { - return installLocation; - } - - public void setInstallLocation(IPath validInstallLocation) { - installLocation = validInstallLocation; - } - - public String getName() { - return name; - } - - public void setName(String newName) { - name = newName; - } - - public String getCommand() { - String directory = installLocation.toOSString() + File.separator; - if (new File(directory + "php.exe").isFile()) - return directory + "php.exe"; - - if (new File(directory, "php").isFile()) - return directory + "php"; - - return null; - } - - public Process exec(String arguments, File workingDirectory) throws IOException { - return Runtime.getRuntime().exec(this.getCommand() + " " + arguments, null, workingDirectory); - } - - public boolean equals(Object other) { - if (other instanceof PHPInterpreter) { - PHPInterpreter otherInterpreter = (PHPInterpreter) other; - if (name.equals(otherInterpreter.getName())) - return installLocation.equals(otherInterpreter.getInstallLocation()); - } - - return false; - } -} diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java deleted file mode 100644 index d6b853e..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.phpdt.internal.launching; - - - -public interface PHPLaunchConfigurationAttribute { - static final String PHP_LAUNCH_CONFIGURATION_TYPE = "net.sourceforge.phpdt.launching.LaunchConfigurationTypePHPApplication"; - - static final String CUSTOM_LOAD_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".CUSTOM_LOAD_PATH"; - static final String FILE_NAME = PHPLaunchingPlugin.PLUGIN_ID + ".FILE_NAME"; - static final String INTERPRETER_ARGUMENTS = PHPLaunchingPlugin.PLUGIN_ID + ".INTERPRETER_ARGUMENTS"; - static final String MODULE_NAME = PHPLaunchingPlugin.PLUGIN_ID + ".MODULE_NAME"; - static final String PROGRAM_ARGUMENTS = PHPLaunchingPlugin.PLUGIN_ID + ".PROGRAM_ARGUMENTS"; - static final String PROJECT_NAME = PHPLaunchingPlugin.PLUGIN_ID + ".PROJECT_NAME"; - static final String SELECTED_INTERPRETER = PHPLaunchingPlugin.PLUGIN_ID + ".SELECTED_INTERPRETER"; - static final String WORKING_DIRECTORY = PHPLaunchingPlugin.PLUGIN_ID + ".WORKING_DIRECTORY"; - static final String USE_DEFAULT_LOAD_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_LOAD_PATH"; - static final String USE_DEFAULT_WORKING_DIRECTORY = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_WORKING_DIRECTORY"; -} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java deleted file mode 100644 index bbc6a9e..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.sourceforge.phpdt.internal.launching; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; - - -public class PHPLaunchConfigurationDelegate implements ILaunchConfigurationDelegate { - protected static final InterpreterRunner interpreterRunner = new InterpreterRunner(); -// protected static final DebuggerRunner debuggerRunner = new DebuggerRunner(); - - public PHPLaunchConfigurationDelegate() { - super(); - } - - /** - * @see ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String, ILaunch, IProgressMonitor) - */ - public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { - if (PHPRuntime.getDefault().getSelectedInterpreter() == null) - throw new CoreException(new Status(IStatus.ERROR, PHPLaunchingPlugin.PLUGIN_ID, IStatus.OK, "You must define an interpreter before running PHP.", null)); -// if (mode.equals("debug")) { -// debuggerRunner.run(new InterpreterRunnerConfiguration(configuration), launch); -// } else { - interpreterRunner.run(new InterpreterRunnerConfiguration(configuration), launch); -// } - } -} diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingMessages.java b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingMessages.java deleted file mode 100644 index ca7ed89..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingMessages.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.sourceforge.phpdt.internal.launching; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class PHPLaunchingMessages { - - private static final String BUNDLE_NAME = PHPLaunchingMessages.class.getName(); - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private PHPLaunchingMessages() {} - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingMessages.properties b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingMessages.properties deleted file mode 100644 index bc2d362..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingMessages.properties +++ /dev/null @@ -1,6 +0,0 @@ - -######################################### -# PHPLaunchingPlugin -######################################### - -PHPLaunchingPlugin.internalErrorOccurred=Internal error occurred \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingPlugin.java b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingPlugin.java deleted file mode 100644 index dee7aa5..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchingPlugin.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.sourceforge.phpdt.internal.launching; - -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.runtime.IPluginDescriptor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; - -public class PHPLaunchingPlugin extends Plugin { - public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.launching"; //$NON-NLS-1$ - - protected static PHPLaunchingPlugin plugin; - - public PHPLaunchingPlugin(IPluginDescriptor descriptor) { - super(descriptor); - plugin = this; - } - - public static PHPLaunchingPlugin getDefault() { - return plugin; - } - - public static IWorkspace getWorkspace() { - return PHPeclipsePlugin.getWorkspace(); - } - - public static void log(IStatus status) { - getDefault().getLog().log(status); - } - - public static void log(Throwable e) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, PHPLaunchingMessages.getString("PHPLaunchingPlugin.internalErrorOccurred"), e)); //$NON-NLS-1$ - } -} diff --git a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPRuntime.java b/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPRuntime.java deleted file mode 100644 index 03447e1..0000000 --- a/net.sourceforge.phpeclipse.debug.launching/src/net/sourceforge/phpdt/internal/launching/PHPRuntime.java +++ /dev/null @@ -1,174 +0,0 @@ -package net.sourceforge.phpdt.internal.launching; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.StringReader; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -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; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -public class PHPRuntime { - protected static PHPRuntime runtime; - - protected List installedInterpreters; - protected PHPInterpreter selectedInterpreter; - protected PHPRuntime() { - super(); - } - - public static PHPRuntime getDefault() { - if (runtime == null) { - runtime = new PHPRuntime(); - } - return runtime; - } - - public PHPInterpreter getSelectedInterpreter() { - if (selectedInterpreter == null) { - loadRuntimeConfiguration(); - } - return selectedInterpreter; - } - - public PHPInterpreter getInterpreter(String name) { - Iterator interpreters = getInstalledInterpreters().iterator(); - while(interpreters.hasNext()) { - PHPInterpreter each = (PHPInterpreter) interpreters.next(); - if (each.getName().equals(name)) - return each; - } - - return getSelectedInterpreter(); - } - - public void setSelectedInterpreter(PHPInterpreter anInterpreter) { - selectedInterpreter = anInterpreter; - saveRuntimeConfiguration(); - } - - public void addInstalledInterpreter(PHPInterpreter anInterpreter) { - getInstalledInterpreters().add(anInterpreter); - if (getInstalledInterpreters().size() == 1) - setSelectedInterpreter((PHPInterpreter) getInstalledInterpreters().get(0)); - - saveRuntimeConfiguration(); - } - - public List getInstalledInterpreters() { - if (installedInterpreters == null) - loadRuntimeConfiguration(); - return installedInterpreters; - } - - public void setInstalledInterpreters(List newInstalledInterpreters) { - installedInterpreters = newInstalledInterpreters; - if (installedInterpreters.size() > 0) - setSelectedInterpreter((PHPInterpreter)installedInterpreters.get(0)); - else - setSelectedInterpreter(null); - } - - protected void saveRuntimeConfiguration() { - writeXML(getRuntimeConfigurationWriter()); - } - - protected Writer getRuntimeConfigurationWriter() { - try { - OutputStream stream = new BufferedOutputStream(new FileOutputStream(getRuntimeConfigurationFile())); - return new OutputStreamWriter(stream); - } catch (FileNotFoundException e) {} - - return null; - } - - protected void loadRuntimeConfiguration() { - installedInterpreters = new ArrayList(); - try { - XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); - reader.setContentHandler(getRuntimeConfigurationContentHandler()); - reader.parse(new InputSource(getRuntimeConfigurationReader())); - } catch(Exception e) { - PHPLaunchingPlugin.getDefault().log(e); - } - } - - protected Reader getRuntimeConfigurationReader() { - try { - return new FileReader(getRuntimeConfigurationFile()); - } catch(FileNotFoundException e) {} - return new StringReader(""); - } - - protected void writeXML(Writer writer) { - try { - writer.write(""); - Iterator interpretersIterator = installedInterpreters.iterator(); - while (interpretersIterator.hasNext()) { - writer.write(""); - } - writer.write(""); - writer.flush(); - } catch(IOException e) { - PHPLaunchingPlugin.log(e); - } - } - - protected ContentHandler getRuntimeConfigurationContentHandler() { - return new ContentHandler() { - public void setDocumentLocator(Locator locator) {} - public void startDocument() throws SAXException {} - public void endDocument() throws SAXException {} - public void startPrefixMapping(String prefix, String uri) throws SAXException {} - public void endPrefixMapping(String prefix) throws SAXException {} - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { - if ("interpreter".equals(qName)) { - String interpreterName = atts.getValue("name"); - IPath installLocation = new Path(atts.getValue("path")); - PHPInterpreter interpreter = new PHPInterpreter(interpreterName, installLocation); - installedInterpreters.add(interpreter); - if (atts.getValue("selected") != null) - selectedInterpreter = interpreter; - } - } - public void endElement(String namespaceURI, String localName, String qName) throws SAXException {} - public void characters(char[] ch, int start, int length) throws SAXException {} - public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {} - public void processingInstruction(String target, String data) throws SAXException {} - public void skippedEntity(String name) throws SAXException {} - }; - } - - protected File getRuntimeConfigurationFile() { - IPath stateLocation = PHPLaunchingPlugin.getDefault().getStateLocation(); - IPath fileLocation = stateLocation.append("runtimeConfiguration.xml"); - return new File(fileLocation.toOSString()); - } -} -- 1.7.1