<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-#Thu Jun 26 21:18:27 CDT 2008
+#Fri Jul 11 22:55:41 CDT 2008
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Bundle-ManifestVersion: 2
Bundle-Name: Compatability Fragment
Bundle-SymbolicName: net.sourceforge.phpeclipse.32.compatibility
-Bundle-Version: 1.0.0
+Bundle-Version: 0.0.0
Fragment-Host: net.sourceforge.phpeclipse;bundle-version="0.0.0"
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
-Bundle-ClassPath: compatability.jar,
- .
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ClassPath: compatability.jar
Eclipse-PatchFragment: true
-Require-Bundle: net.sourceforge.phpeclipse.launching,
- net.sourceforge.phpeclipse.core;bundle-version="0.0.0"
+Export-Package: net.sourceforge.phpdt.externaltools.actions,
+ net.sourceforge.phpdt.internal.compiler.lookup;x-internal:=true,
+ net.sourceforge.phpdt.internal.compiler.parser;x-internal:=true,
+ net.sourceforge.phpdt.internal.core;x-internal:=true,
+ net.sourceforge.phpdt.internal.corext.phpdoc;x-internal:=true,
+ net.sourceforge.phpdt.internal.corext.util;x-internal:=true,
+ net.sourceforge.phpdt.internal.ui.text.template;x-internal:=true,
+ net.sourceforge.phpdt.internal.ui.util;x-internal:=true,
+ net.sourceforge.phpdt.ltk.core,
+ net.sourceforge.phpeclipse.actions,
+ net.sourceforge.phpeclipse.obfuscator,
+ net.sourceforge.phpeclipse.obfuscator.export,
+ net.sourceforge.phpeclipse.phpeditor,
+ net.sourceforge.phpeclipse.ui,
+ net.sourceforge.phpeclipse.ui.editor,
+ net.sourceforge.phpeclipse.webbrowser.internal;x-internal:=true,
+ net.sourceforge.phpeclipse.webbrowser.views,
+ net.sourceforge.phpeclipse.wizards
+Bundle-Vendor: PHPEclipse Development Team
+++ /dev/null
-/***********************************************************************************************************************************
- * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors: IBM Corporation - Initial implementation Vicente Fernando - www.alfersoft.com.ar Christian Perkonig - remote debug
- **********************************************************************************************************************************/
-package net.sourceforge.phpdt.internal.debug.core;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-import java.util.Map;
-import java.util.Vector;
-
-import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint;
-import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget;
-import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame;
-import net.sourceforge.phpdt.internal.debug.core.model.PHPThread;
-import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.model.IBreakpoint;
-
-public class PHPDBGProxy {
-
- private ServerSocket server = null;
- private BufferedReader reader = null;
- private PHPDBGInterface DBGInt = null; // The DBG interface which is linked with the proxy
- private PHPDebugTarget debugTarget = null;
- private PHPDBGProxy thisProxy = null;
- private PHPLoop phpLoop;
- private PHPThread PHPMainThread;
- private Socket socket;
- private int port;
- private boolean remote;
- private boolean pathtranslation;
- private Map pathmap;
- private IPath remoteSourcePath;
-
- /**
- */
- public PHPDBGProxy () {
- thisProxy = this;
- }
-
- /**
- * @param remote
- * @param remoteSourcePath
- * @param pathTranslate
- * @param paths
- */
- public PHPDBGProxy (boolean remote, String remoteSourcePath, boolean pathTranslate, Map paths) {
- thisProxy = this;
- this.remote = remote;
- this.remoteSourcePath = new Path (remoteSourcePath);
- this.pathmap = paths;
- this.pathtranslation = pathTranslate;
- }
-
- /**
- *
- */
- public void start () {
- createServerSocket (); // Create a server socket for communicatio with DBG
-
- this.startPHPLoop (); //
- }
-
- /**
- *
- */
- public void stop () {
- phpLoop.setShouldStop (); // Notify the thread's 'run loop' to stop
-
- if (DBGInt != null) { // If we have a DBG interface linked with this proxy
- DBGInt.setShouldStop (); // Notify the DBG interface to stop the waiting for response
- }
-
- if (!remote) { // If it's not a remote proxy session
- try {
- getDebugTarget ().getProcess ().terminate (); //
- } catch (DebugException e) {
- e.printStackTrace ();
- }
- }
-
- phpLoop.notifyWait ();
- }
-
- public void setTerminated () {
- try {
- PHPMainThread.terminate ();
- }
- catch (DebugException e) {
- }
- }
-
- /**
- * TODO Is this method called from anywhere?
- *
- * Returns a already created server socket, or
- * creates a server socket if none exists, and
- * returns the newly created one.
- *
- * @return A server socket
- */
- protected ServerSocket getServerSocket () throws IOException {
- if (server == null) { // Do we have already a server socket
- createServerSocket (); // No, then create one
- }
-
- return server; // Return the server socket
- }
-
- /**
- * Find a free unused port between 10001 and 10101 if the current debug session
- * is for remote debugging, and a unused port 7869 if it is used as non remote debugging.
- *
- * For remote debugging the used port is submitted with the URL.
- * E.g. http://localhost/index.php?DBGSESSID=1@localhost:10001
- * For non remote debugging (if PHPeclipse used e.g. php cli directly) no port
- * can be submitted by parameter, and only the default port (7869) can be used.
- *
- * @note: The free dbg version doesn't allow to set the appropriate port within php.ini!
- *
- *
- */
- protected void createServerSocket () {
- if (this.remote) {
- port = SocketUtil.findUnusedLocalPort ("localhost", 10001, 10101); // Get the first free port in the range from 10001 to 10101
- }
- else {
- port = SocketUtil.findUnusedLocalPort ("localhost", 7869, 7869); // Get the first free port in the range from 7869 to 7869
- }
-
- if (port == -1) { // Did we get a free port?
- PHPDebugCorePlugin.log (5, "Cannot find free port!!!!"); // No, output a error message
-
- return; // And return
- }
- try {
- if (server == null) { // If there is no server socket yet
- server = new ServerSocket (port); // create a server socket for the free port
- //System.out.println("ServerSocket on port: " + port);
- }
- } catch (IOException e) {
- PHPDebugCorePlugin.log (e);
- stop ();
- }
- }
-
- /**
- *
- */
- public Socket getSocket () throws IOException {
- return socket; // Return the socket
- }
-
- /**
- * Set the DBG interface which is linked to this proxy
- *
- * @paran DBGInt The DGB interface which is linked with this proxy
- */
- protected void setDBGInterface (PHPDBGInterface DBGInt) {
- this.DBGInt = DBGInt;
- }
-
- /**
- * Get the DBG interface which is linked to this proxy
- *
- * @paran DBGInt The DGB interface which is linked with this proxy
- */
- public PHPDBGInterface getDBGInterface () {
- return DBGInt;
- }
-
- /**
- * Give back a buffered input stream for the socket which is
- * linked with this proxy
- */
- public BufferedReader getReader () throws IOException {
- if (reader == null) { // Do we already have a buffered input stream
- reader = new BufferedReader (new InputStreamReader (this.getSocket ().getInputStream (),
- "ISO8859_1"));
- }
-
- return reader; // Return the buffered input stream
- }
-
- /**
- *
- */
- public BufferedReader getReader (Socket socket) throws IOException {
- if (socket != null) { // Is a socket provided
- return new BufferedReader (new InputStreamReader (socket.getInputStream (),
- "ISO8859_1")); // Then create a buffered input stream
- }
- else {
- return null; // Without a socket we can't create a input stream
- }
- }
-
- /**
- *
- * @return The output stream for this proxy's socket
- */
- public OutputStream getOutputStream () throws IOException {
- return this.getSocket ().getOutputStream ();
- }
-
- /**
- *
- */
- protected void setBreakPoints () throws IOException, CoreException {
- IBreakpoint[] breakpoints = DebugPlugin.getDefault ().getBreakpointManager ().getBreakpoints ();
-
- for (int i = 0; i < breakpoints.length; i++) {
- if (breakpoints[i].isEnabled ()) {
- addBreakpoint (breakpoints[i]);
- }
- }
- }
-
- /**
- *
- */
- private String MapPath (PHPLineBreakpoint phpLBP) {
- IPath filename;
- IPath remotePath;
- IPath newpath;
- IPath localPath;
- String local;
-
- if (remote) {
- filename = phpLBP.getMarker().getResource().getProjectRelativePath();
- filename = remoteSourcePath.append (filename);
- } else {
- filename = phpLBP.getMarker().getResource().getLocation();
- }
-
- String path = filename.toOSString();
-
- if ((pathmap != null) && remote) {
- java.util.Iterator i = pathmap.keySet().iterator();
-
- while (i.hasNext()) {
- String k = (String) i.next();
- if (path.startsWith(k)) {
- path = pathmap.get(k) + path.substring(k.length());
- break;
- }
- }
- }
-
- if (remoteSourcePath.isEmpty ()) {
- if ((pathmap != null) && remote) {
- java.util.Iterator iterator = pathmap.keySet().iterator();
-
- while (iterator.hasNext ()) {
- local = (String) iterator.next (); // Get the local/client side path of the mapping
- remotePath = new Path ((String) pathmap.get (local)); // Get the remote/server side path of the mapping
- localPath = new Path (local); // Get the remote/server side path of the mapping
-
- if (localPath.isPrefixOf (filename)) { // Starts the remote/server side file path with the remote/server side mapping path
- // dann prefix abhängen und den remote path davorhägen
- newpath = filename.removeFirstSegments (localPath.matchingFirstSegments (filename));
- newpath = remotePath.append (newpath);
- path = newpath.toString ();
-
- if (path.substring (0, 1).equals ("/")) {
- path = path.replace ('\\', '/');
- }
- else {
- path = path.replace ('/', '\\');
- }
-
- return path;
- }
- }
- }
- }
- else {
- if (pathtranslation && remote) {
- if (remoteSourcePath.toString ().substring (0, 1).equals ("/")) {
- path = path.replace ('\\', '/');
- }
- else {
- path = path.replace ('/', '\\');
- }
- }
- }
-
- return path;
- }
-
- /**
- *
- */
- public void addBreakpoint (IBreakpoint breakpoint) {
- if (DBGInt == null) {
- return;
- }
-
- int bpNo = 0;
-
- try {
- PHPLineBreakpoint phpLBP;
-
- if (breakpoint.getModelIdentifier() == PHPDebugCorePlugin.getUniqueIdentifier()) {
- phpLBP = (PHPLineBreakpoint) breakpoint;
-
- // bpNo= DBGInt.addBreakpoint(phpLBP.getMarker().getResource().getLocation().toOSString(), phpLBP.getLineNumber());
- if (phpLBP.isConditionEnabled ()) {
- bpNo = DBGInt.addBreakpoint (MapPath(phpLBP),
- phpLBP.getLineNumber(),
- phpLBP.getHitCount(),
- phpLBP.getCondition ());
- }
- else {
- bpNo = DBGInt.addBreakpoint (MapPath(phpLBP),
- phpLBP.getLineNumber(),
- phpLBP.getHitCount(),
- "");
- }
-
- phpLBP.setDBGBpNo(bpNo);
- }
- } catch (IOException e) {
- PHPDebugCorePlugin.log(e);
- stop();
- } catch (CoreException e) {
- PHPDebugCorePlugin.log(e);
- stop();
- }
- }
-
- /**
- *
- */
- public void removeBreakpoint (IBreakpoint breakpoint) {
- if (DBGInt == null) {
- return;
- }
-
- try {
- PHPLineBreakpoint phpLBP;
-
- if (breakpoint.getModelIdentifier() == PHPDebugCorePlugin.getUniqueIdentifier ()) {
- phpLBP = (PHPLineBreakpoint) breakpoint;
-
- // bpNo= DBGInt.addBreakpoint(filename.toOSString(), phpLBP.getLineNumber());
-
- DBGInt.removeBreakpoint(MapPath(phpLBP), phpLBP.getLineNumber(), phpLBP.getDBGBpNo());
- }
- } catch (IOException e) {
- PHPDebugCorePlugin.log (e);
- stop ();
- } catch (CoreException e) {
- PHPDebugCorePlugin.log (e);
- stop ();
- }
- }
-
- /**
- *
- */
- public void phpLoopNotify () {
- phpLoop.notifyWait ();
- }
-
- /**
- *
- */
- public void startPHPLoop () {
- phpLoop = new PHPLoop (); // Create a DBG communication loop object
-
- phpLoop.start (); // And start the communication loop
- }
-
- /**
- *
- */
- public void resume () {
- try {
- DBGInt.continueExecution();
- phpLoop.notifyWait();
- } catch (IOException e) {
- PHPeclipsePlugin.log("Debugging session ended.", e);
- stop();
- }
- }
-
- /**
- *
- */
- public void pause () {
- try {
- if (null != DBGInt) {
- DBGInt.pauseExecution();
- }
- else {
- // TODO Make sure the Suspend action is grayed out
- // when DBGInt is null
- }
- } catch (IOException e) {
- PHPDebugCorePlugin.log (e);
- stop ();
- }
- }
-
- /**
- *
- */
- protected PHPDebugTarget getDebugTarget() {
- return debugTarget;
- }
-
- /**
- * Is called by the DebuggerRunner
- *
- * @param debugTarget
- */
- public void setDebugTarget (PHPDebugTarget debugTarget) {
- this.debugTarget = debugTarget;
- debugTarget.setPHPDBGProxy(this);
- }
-
- /**
- * This method is called by a stackframe.
- * It reads the variables from PHP via DBG
- *
- * @param frame The stackframe which wants the variables.
- * @return The list of variables for this stackframe.
- */
- public Vector readVariables (PHPStackFrame frame) {
- try {
- return DBGInt.getVariables (frame); // Get the variables from DBG interface
- } catch (IOException ioex) {
- ioex.printStackTrace ();
- throw new RuntimeException (ioex.getMessage ());
- } catch (DebugException ex) {
- ex.printStackTrace ();
- throw new RuntimeException (ex.getMessage ());
- }
- }
-
- /**
- *
- * @param frame
- * @param evalString
- * @return
- */
- public PHPVariable[] eval (PHPStackFrame frame, String evalString) {
- try {
- return DBGInt.evalBlock (frame, evalString);
- //return DBGInt.getVariables(frame);
- } catch (IOException ioex) {
- ioex.printStackTrace();
- throw new RuntimeException(ioex.getMessage());
- } catch (DebugException ex) {
- ex.printStackTrace();
- throw new RuntimeException(ex.getMessage());
- }
- }
-
- public void readStepOverEnd (PHPStackFrame stackFrame) {
- try {
- DBGInt.stepOver();
- phpLoop.notifyWait();
- } catch (Exception e) {
- PHPDebugCorePlugin.log(e);
- }
- }
-
- public void readStepReturnEnd (PHPStackFrame stackFrame) {
- try {
- DBGInt.stepOut();
- phpLoop.notifyWait();
- } catch (Exception e) {
- PHPDebugCorePlugin.log(e);
- }
- }
-
- public void readStepIntoEnd (PHPStackFrame stackFrame) {
- try {
- DBGInt.stepInto();
- phpLoop.notifyWait();
- } catch (Exception e) {
- PHPDebugCorePlugin.log(e);
- }
- }
-
- /*
- * public PHPStackFrame[] readFrames(PHPThread thread) { //try { //this.println("th " + thread.getId() + " ; f "); //return new
- * FramesReader(getMultiReaderStrategy()).readFrames(thread); return null; //} catch (IOException e) { //
- * PHPDebugCorePlugin.log(e); // return null; //}
- * }
- */
-
- public void closeSocket() throws IOException {
- if (socket != null) {
- socket.close();
- }
- }
-
- public void closeServerSocket() throws IOException {
- if (server != null) {
- server.close();
- }
- }
-
- public int getPort() {
- return port;
- }
-
- /**
- *
- *
- */
- class PHPLoop extends Thread {
- private boolean shouldStop;
-
- public PHPLoop () {
- shouldStop = false;
- this.setName ("PHPDebuggerLoop");
- }
-
- /**
- *
- */
- public synchronized void setShouldStop () {
- shouldStop = true; // The run loop should stop
-
- try {
- // If the loop thread is blocked on the server socket,
- // forcibly unblock it to avoid leaking the thread,
- // the socket and the port
- closeServerSocket ();
- } catch (IOException x) {
- // Log this as a warning?
- PHPDebugCorePlugin.log (x);
- }
- }
-
- /**
- *
- */
- public synchronized void notifyWait () {
- notify ();
- }
-
- /**
- *
- *
- */
- public void run () {
- try {
- int i;
- int timeout;
- long interval = 200; // Wait 200 ms maximum for a DBG response
- boolean newconnect = false; //
- Socket newSocket = null;
- PHPStackFrame[] StackList;
- PHPDBGInterface newDBGInt;
-
- // synchronized (this) {
- // wait();
- // }
-
- PHPMainThread = new PHPThread (getDebugTarget (), getPort ());
- PHPMainThread.setName ("Thread [main]");
- timeout = 0;
-
- // while ((getDebugTarget() == null) && (timeout < 100)) {
- // sleep(100);
- // timeout++;
- // }
- // Be sure debug target is set
- // PHPMainThread.setDebugTarget(getDebugTarget());
-
- getDebugTarget ().addThread (PHPMainThread);
-
- //System.out.println("Waiting for breakpoints.");
-
- while (!shouldStop) { // As long as nobody will stop us
- newconnect = true; // The first time
-
- try {
- newSocket = server.accept(); // Waits until DBG want to connect
- //System.out.println("Accepted! : " + socket.toString());
- } catch (SocketTimeoutException e) {
- newconnect = false; // No one wants to connect (connection already done)
- } catch (IOException e) {
- PHPDebugCorePlugin.log(e);
- return;
- }
-
- if (newconnect) { // Is it just after a new connection
- if (DBGInt == null) { // Do we have a DBG interface?
- server.setSoTimeout(1); // ???
- }
-
- newDBGInt = new PHPDBGInterface (getReader (newSocket), // Create a new interface
- newSocket.getOutputStream (),
- thisProxy);
- newDBGInt.waitResponse (1000); // Wait for the initial DBG response
- newDBGInt.flushAllPackets (); // Read and process the DBG response
-
- // Check version and session ID
- if ((DBGInt == null) || // If we have no interface
- (DBGInt.getSID () == newDBGInt.getSID ())) {// or the new session ID is different to the old one
- DBGInt = newDBGInt; // Set the new interface as current one
-
- try {
- closeSocket ();
- }
- catch (IOException e) {
- PHPDebugCorePlugin.log (e);
- shouldStop = true;
- }
-
- socket = newSocket;
- setBreakPoints ();
- DBGInt.continueExecution (); // Notify DBG that PHP should continue
- }
- else {
- newDBGInt.continueExecution (); // Notify DBG that PHP should continue
- newSocket.close ();
- }
- }
-
- if (DBGInt.waitResponse (interval)) { // Wait for a DBG response (200 ms)
- DBGInt.flushAllPackets (); // If we got something, read and process it
-
- if (DBGInt.BPUnderHit != 0) { // ???
- StackList = DBGInt.getStackList (); // Get the stack list from DBGInterface
-
- if (StackList.length > 0) { // If there is something in stack list
- for (i = 0; i < StackList.length; i++) { // For all stack list
- StackList[i].setThread (PHPMainThread); // Set the PHPTread for all PHPStackFrames
-
- if (DBGInt.getModByNo (StackList[i].getModNo ()).equals ("")) {
- DBGInt.getSourceTree ();
- }
-
- StackList[i].setFile (DBGInt.getModByNo (StackList[i].getModNo ()));
- }
-
- PHPMainThread.setStackFrames (StackList);
- }
-
- PHPMainThread.suspend (); // Fire debug event
-
- synchronized (this) {
- wait ();
- }
- }
- }
-
- if (remote) {
- if (PHPMainThread.isTerminated ()) {
- shouldStop = true;
-
- break; // Go for terminating the thread
- }
- } else {
- if (PHPMainThread.isTerminated () ||
- getDebugTarget ().getProcess ().isTerminated ()) {
- shouldStop = true;
-
- break; // Go for terminating the thread
- }
- }
- }
- } catch (Exception ex) {
- PHPDebugCorePlugin.log (ex);
- System.out.println (ex);
- } finally {
- try {
- getDebugTarget ().terminate ();
- closeSocket();
- closeServerSocket ();
- } catch (IOException e) {
- PHPDebugCorePlugin.log (e);
-
- return;
- }
-
- //System.out.println("Socket loop finished.");
- }
- }
- }
-}
+++ /dev/null
-package net.sourceforge.phpdt.internal.debug.ui.launcher;
-
-import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin;
-import net.sourceforge.phpeclipse.LoadPathEntry;
-
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @author xp4
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- */
-public class LoadPathEntryLabelProvider implements ILabelProvider {
-
- /**
- * @see ILabelProvider#getImage(Object)
- */
- public Image getImage(Object element) {
- return null;
- }
-
- /**
- * @see ILabelProvider#getText(Object)
- */
- public String getText(Object element) {
- if (element != null && element.getClass() == LoadPathEntry.class)
- return ((LoadPathEntry) element).getProject().getLocation()
- .toOSString();
-
- PHPDebugUiPlugin
- .log(new RuntimeException("Unable to render load path."));
- return null;
- }
-
- /**
- * @see IBaseLabelProvider#addListener(ILabelProviderListener)
- */
- public void addListener(ILabelProviderListener listener) {
- }
-
- /**
- * @see IBaseLabelProvider#dispose()
- */
- public void dispose() {
- }
-
- /**
- * @see IBaseLabelProvider#isLabelProperty(Object, String)
- */
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /**
- * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
- */
- public void removeListener(ILabelProviderListener listener) {
- }
-
-}
+++ /dev/null
-package net.sourceforge.phpdt.internal.debug.ui.launcher;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiMessages;
-import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin;
-import net.sourceforge.phpdt.internal.debug.ui.preferences.EditPathMapDialog;
-import net.sourceforge.phpdt.internal.debug.ui.preferences.PHPInterpreterPreferencePage;
-import net.sourceforge.phpdt.internal.launching.PHPInterpreter;
-import net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationAttribute;
-import net.sourceforge.phpdt.internal.launching.PHPRuntime;
-import net.sourceforge.phpdt.internal.ui.PHPUiImages;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-
-public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
- protected ListViewer loadPathListViewer;
-
- protected java.util.List installedInterpretersWorkingCopy;
-
- protected Combo interpreterCombo;
-
- // protected Button loadPathDefaultButton;
- protected Button fRemoteDebugCheckBox;
-
- protected Button fRemoteDebugTranslate;
-
- protected Button fOpenDBGSessionInBrowserCheckBox;
-
- protected Button fPathMapRemoveButton;
-
- protected Button fPathMapAddButton;
-
- protected Button fPathMapEditButton;
-
- protected Text fRemoteSourcePath;
-
- protected Table fRemoteDebugPathMapTable;
-
- protected TabFolder tabFolder;
-
- private class RemoteDebugTabListener extends SelectionAdapter implements
- ModifyListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- public void modifyText(ModifyEvent e) {
- updateLaunchConfigurationDialog();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- Object source = e.getSource();
- if (source == fRemoteDebugPathMapTable) {
- setPathMapButtonsEnableState();
- } else if (source == fPathMapAddButton) {
- handlePathMapAddButtonSelected();
- } else if (source == fPathMapEditButton) {
- handlePathMapEditButtonSelected();
- } else if (source == fPathMapRemoveButton) {
- handlePathMapRemoveButtonSelected();
- } else if (source == fRemoteDebugCheckBox) {
- setRemoteTabEnableState();
- } else if (source == fRemoteDebugTranslate) {
- setRemoteTabEnableState();
- } else {
- updateLaunchConfigurationDialog();
- ;
- }
-
- }
-
- }
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- private RemoteDebugTabListener fListener = new RemoteDebugTabListener();
-
- private static final boolean DEFAULT_REMOTE_DEBUG = false;
-
- private static final boolean DEFAULT_REMOTE_DEBUG_TRANSLATE = false;
-
- private static final boolean DEFAULT_OPEN_DBGSESSION_IN_BROWSER = true;
-
- static String[] columnTitles = {
- PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"),
- PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.remote") };
-
- public PHPEnvironmentTab() {
- super();
- }
-
- public void createControl(Composite parent) {
- Composite composite = createPageRoot(parent);
-
- tabFolder = new TabFolder(composite, SWT.NONE);
- GridData gridData = new GridData(GridData.FILL_BOTH);
- tabFolder.setLayoutData(gridData);
-
- // addLoadPathTab(tabFolder);
- addInterpreterTab(tabFolder);
- addRemoteDebugTab(tabFolder);
- }
-
- protected void addRemoteDebugTab(TabFolder tabFolder) {
- Label label;
-
- TabItem remoteDebugTab = new TabItem(tabFolder, SWT.NONE, 0);
- remoteDebugTab
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label"));
-
- Composite comp = new Composite(tabFolder, SWT.NONE);
- comp.setLayout(new GridLayout());
- remoteDebugTab.setControl(comp);
- GridData gd;
-
- fRemoteDebugCheckBox = new Button(comp, SWT.CHECK);
- fRemoteDebugCheckBox
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label"));
- fRemoteDebugCheckBox.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_BEGINNING));
- fRemoteDebugCheckBox.addSelectionListener(fListener);
-
- fRemoteDebugTranslate = new Button(comp, SWT.CHECK);
- fRemoteDebugTranslate
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label"));
- fRemoteDebugTranslate.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_BEGINNING));
- fRemoteDebugTranslate.addSelectionListener(fListener);
-
- fOpenDBGSessionInBrowserCheckBox = new Button(comp, SWT.CHECK);
- fOpenDBGSessionInBrowserCheckBox
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label"));
- fOpenDBGSessionInBrowserCheckBox.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_BEGINNING));
- fOpenDBGSessionInBrowserCheckBox.addSelectionListener(fListener);
-
- label = new Label(comp, SWT.NONE);
- label
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label"));
- fRemoteSourcePath = new Text(comp, SWT.BORDER | SWT.SINGLE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- fRemoteSourcePath.setLayoutData(gd);
- fRemoteSourcePath.addModifyListener(fListener);
-
- createVerticalSpacer(comp, 1);
-
- Composite pathMapComp = new Composite(comp, SWT.NONE);
- gd = new GridData(GridData.FILL_BOTH);
- pathMapComp.setLayoutData(gd);
- GridLayout parametersLayout = new GridLayout();
- parametersLayout.numColumns = 2;
- parametersLayout.marginHeight = 0;
- parametersLayout.marginWidth = 0;
- pathMapComp.setLayout(parametersLayout);
-
- Label pathMapLabel = new Label(pathMapComp, SWT.NONE);
- pathMapLabel
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label"));
- gd = new GridData();
- gd.horizontalSpan = 2;
- pathMapLabel.setLayoutData(gd);
-
- fRemoteDebugPathMapTable = new Table(pathMapComp, SWT.BORDER
- | SWT.MULTI);
- TableLayout tableLayout = new TableLayout();
- fRemoteDebugPathMapTable.setLayout(tableLayout);
-
- gd = new GridData(GridData.FILL_BOTH);
- fRemoteDebugPathMapTable.setLayoutData(gd);
- TableColumn column1 = new TableColumn(this.fRemoteDebugPathMapTable,
- SWT.NONE);
- column1
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local")); //$NON-NLS-1$
- TableColumn column2 = new TableColumn(this.fRemoteDebugPathMapTable,
- SWT.NONE);
- column2
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote")); //$NON-NLS-1$
- tableLayout.addColumnData(new ColumnWeightData(100));
- tableLayout.addColumnData(new ColumnWeightData(100));
- fRemoteDebugPathMapTable.setHeaderVisible(true);
- fRemoteDebugPathMapTable.setLinesVisible(true);
- fRemoteDebugPathMapTable.addSelectionListener(fListener);
- fRemoteDebugPathMapTable.addMouseListener(new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent e) {
- setPathMapButtonsEnableState();
- if (fPathMapEditButton.isEnabled()) {
- handlePathMapEditButtonSelected();
- }
- }
- });
- // fRemoteDebugPathMapTable.setEnabled(false);
-
- Composite envButtonComp = new Composite(pathMapComp, SWT.NONE);
- GridLayout envButtonLayout = new GridLayout();
- envButtonLayout.marginHeight = 0;
- envButtonLayout.marginWidth = 0;
- envButtonComp.setLayout(envButtonLayout);
- gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
- | GridData.HORIZONTAL_ALIGN_FILL);
- envButtonComp.setLayoutData(gd);
-
- fPathMapAddButton = createPushButton(
- envButtonComp,
- PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label"), null); //$NON-NLS-1$
- fPathMapAddButton.addSelectionListener(fListener);
- // fPathMapAddButton.setEnabled(false);
-
- fPathMapEditButton = createPushButton(
- envButtonComp,
- PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label"), null); //$NON-NLS-1$
- fPathMapEditButton.addSelectionListener(fListener);
- // fPathMapEditButton.setEnabled(false);
-
- fPathMapRemoveButton = createPushButton(
- envButtonComp,
- PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label"), null); //$NON-NLS-1$
- fPathMapRemoveButton.addSelectionListener(fListener);
- // fPathMapRemoveButton.setEnabled(false);
-
- }
-
- void handlePathMapAddButtonSelected() {
- EditPathMapDialog dialog = new EditPathMapDialog(getShell(),
- "Edit File Map", new String[] { EMPTY_STRING, EMPTY_STRING });
- openNewPathMapDialog(dialog, null);
- // dialog.create();
- // if (dialog.open()==EditPathMapDialog.OK)
- // {
- // TableItem item = new TableItem (fRemoteDebugPathMapTable, SWT.NONE);
- // item.setText(0,dialog.getLocalPath());
- // item.setText(1,dialog.getRemotePath());
- // updateLaunchConfigurationDialog();
- // }
- // updateLaunchConfigurationDialog();
- setPathMapButtonsEnableState();
- }
-
- void handlePathMapRemoveButtonSelected() {
- int[] selectedIndices = this.fRemoteDebugPathMapTable
- .getSelectionIndices();
- this.fRemoteDebugPathMapTable.remove(selectedIndices);
- setPathMapButtonsEnableState();
- updateLaunchConfigurationDialog();
- }
-
- void handlePathMapEditButtonSelected() {
- TableItem selectedItem = this.fRemoteDebugPathMapTable.getSelection()[0];
- String local = selectedItem.getText(0);
- String remote = selectedItem.getText(1);
- EditPathMapDialog dialog = new EditPathMapDialog(getShell(),
- "Edit File Map", new String[] { local, remote });
- openNewPathMapDialog(dialog, selectedItem);
- }
-
- /**
- * Set the enabled state of whole tab.
- */
- private void setRemoteTabEnableState() {
- boolean state = fRemoteDebugCheckBox.getSelection();
- fRemoteSourcePath.setEnabled(state);
- fRemoteDebugTranslate.setEnabled(state);
-
- fRemoteDebugPathMapTable.setEnabled(state);
- if (!state) {
- fPathMapEditButton.setEnabled(false);
- fPathMapRemoveButton.setEnabled(false);
- fPathMapAddButton.setEnabled(false);
- fOpenDBGSessionInBrowserCheckBox.setEnabled(false);
- } else {
- setPathMapButtonsEnableState();
- }
-
- updateLaunchConfigurationDialog();
- }
-
- /**
- * Set the enabled state of the three environment variable-related buttons
- * based on the selection in the PathMapTable widget.
- */
- private void setPathMapButtonsEnableState() {
- // just do nothing for now
- //
- if (fRemoteDebugCheckBox.getSelection()) {
- fOpenDBGSessionInBrowserCheckBox.setEnabled(true);
- fRemoteDebugTranslate.setEnabled(true);
- int selectCount = this.fRemoteDebugPathMapTable
- .getSelectionIndices().length;
- if (selectCount < 1) {
- fPathMapEditButton.setEnabled(false);
- fPathMapRemoveButton.setEnabled(false);
- } else {
- fPathMapRemoveButton.setEnabled(true);
- if (selectCount == 1) {
- fPathMapEditButton.setEnabled(true);
- } else {
- fPathMapEditButton.setEnabled(false);
- }
- }
- fPathMapAddButton.setEnabled(true);
- }
- }
-
- /**
- * Show the specified dialog and update the pathMapTable table based on its
- * results.
- *
- * @param updateItem
- * the item to update, or <code>null</code> if adding a new
- * item
- */
- private void openNewPathMapDialog(EditPathMapDialog dialog,
- TableItem updateItem) {
- if (dialog.open() != EditPathMapDialog.OK) {
- return;
- }
- String[] pathPair = dialog.getPathPair();
- TableItem tableItem = updateItem;
- if (tableItem == null) {
- tableItem = getTableItemForName(pathPair[0]);
- if (tableItem == null) {
- tableItem = new TableItem(this.fRemoteDebugPathMapTable,
- SWT.NONE);
- }
- }
- tableItem.setText(pathPair);
- this.fRemoteDebugPathMapTable
- .setSelection(new TableItem[] { tableItem });
- updateLaunchConfigurationDialog();
- }
-
- /**
- * Helper method that indicates whether the specified parameter name is
- * already present in the parameters table.
- */
- private TableItem getTableItemForName(String candidateName) {
- TableItem[] items = this.fRemoteDebugPathMapTable.getItems();
- for (int i = 0; i < items.length; i++) {
- String name = items[i].getText(0);
- if (name.equals(candidateName)) {
- return items[i];
- }
- }
- return null;
- }
-
- // protected void addLoadPathTab(TabFolder tabFolder) {
- // Composite loadPathComposite = new Composite(tabFolder, SWT.NONE);
- // loadPathComposite.setLayout(new GridLayout());
- //
- // loadPathListViewer = new ListViewer(loadPathComposite, SWT.BORDER |
- // SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
- // loadPathListViewer.setContentProvider(new ListContentProvider());
- // loadPathListViewer.setLabelProvider(new LoadPathEntryLabelProvider());
- // loadPathListViewer.getList().setLayoutData(new
- // GridData(GridData.FILL_BOTH));
- //
- // TabItem loadPathTab = new TabItem(tabFolder, SWT.NONE, 0);
- // loadPathTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathTab.label"));
- // loadPathTab.setControl(loadPathComposite);
- // loadPathTab.setData(loadPathListViewer);
-
- // loadPathDefaultButton = new Button(loadPathComposite, SWT.CHECK);
- // loadPathDefaultButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathDefaultButton.label"));
- // loadPathDefaultButton.setLayoutData(new
- // GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- // loadPathDefaultButton.addSelectionListener(getLoadPathDefaultButtonSelectionListener());
- //
- // loadPathDefaultButton.setEnabled(false); //for now, until the load path
- // is customizable on the configuration
- // }
-
- protected SelectionListener getLoadPathSelectionListener() {
- return new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- System.out.println("Loadpath list selection occurred: "
- + e.getSource());
- }
- };
- }
-
- protected SelectionListener getLoadPathDefaultButtonSelectionListener() {
- return new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setUseLoadPathDefaults(((Button) e.getSource()).getSelection());
- }
- };
- }
-
- protected void addInterpreterTab(TabFolder tabFolder) {
- Composite interpreterComposite = new Composite(tabFolder, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- interpreterComposite.setLayout(layout);
- interpreterComposite.setLayoutData(new GridData(
- GridData.FILL_HORIZONTAL));
-
- createVerticalSpacer(interpreterComposite, 2);
-
- interpreterCombo = new Combo(interpreterComposite, SWT.READ_ONLY);
- interpreterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- initializeInterpreterCombo(interpreterCombo);
- interpreterCombo.addModifyListener(getInterpreterComboModifyListener());
-
- Button interpreterAddButton = new Button(interpreterComposite, SWT.PUSH);
- interpreterAddButton
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.interpreterAddButton.label"));
- interpreterAddButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent evt) {
- PHPInterpreter newInterpreter = new PHPInterpreter(null);
- File phpRuntime = PHPInterpreterPreferencePage.getFile(
- getShell(), null);
- if (phpRuntime != null) {
- newInterpreter.setInstallLocation(phpRuntime);
- PHPRuntime.getDefault().addInstalledInterpreter(
- newInterpreter);
- interpreterCombo.add(newInterpreter.getInstallLocation()
- .toString());
- interpreterCombo.select(interpreterCombo
- .indexOf(newInterpreter.getInstallLocation()
- .toString()));
- }
- }
- });
-
- TabItem interpreterTab = new TabItem(tabFolder, SWT.NONE);
- interpreterTab
- .setText(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.interpreterTab.label"));
- interpreterTab.setControl(interpreterComposite);
- }
-
- protected ModifyListener getInterpreterComboModifyListener() {
- return new ModifyListener() {
- public void modifyText(ModifyEvent evt) {
- updateLaunchConfigurationDialog();
- }
- };
- }
-
- protected void createVerticalSpacer(Composite comp, int colSpan) {
- Label label = new Label(comp, SWT.NONE);
- GridData gd = new GridData();
- gd.horizontalSpan = colSpan;
- label.setLayoutData(gd);
- }
-
- public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- PHPInterpreter selectedInterpreter = PHPRuntime.getDefault()
- .getSelectedInterpreter();
- if (selectedInterpreter != null) {
- String interpreterLocation = selectedInterpreter
- .getInstallLocation().toString();
- configuration.setAttribute(
- PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER,
- interpreterLocation);
- }
- try {
- String projectName = configuration.getAttribute(
- PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
- if (projectName != "") {
- IProject project = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(projectName);
- if (project != null) {
- IPath remotePath = project.getLocation();
- String fileName = configuration.getAttribute(
- PHPLaunchConfigurationAttribute.FILE_NAME, "");
- if (fileName != "") {
- Path filePath = new Path(fileName);
- remotePath = remotePath.append(filePath
- .removeLastSegments(1));
- }
- configuration.setAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_PATH,
- remotePath.toOSString());
- }
- }
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void initializeFrom(ILaunchConfiguration configuration) {
- // initializeLoadPath(configuration);
- initializeInterpreterSelection(configuration);
- initializeRemoteDebug(configuration);
- }
-
- protected void initializeRemoteDebug(ILaunchConfiguration configuration) {
- try {
- fRemoteDebugCheckBox.setSelection(configuration.getAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_DEBUG,
- DEFAULT_REMOTE_DEBUG));
- } catch (CoreException ce) {
- fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG);
- }
- try {
- fRemoteDebugTranslate.setSelection(configuration.getAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE,
- DEFAULT_REMOTE_DEBUG_TRANSLATE));
- } catch (CoreException ce) {
- fRemoteDebugTranslate.setSelection(DEFAULT_REMOTE_DEBUG_TRANSLATE);
- }
- try {
- fOpenDBGSessionInBrowserCheckBox
- .setSelection(configuration
- .getAttribute(
- PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER,
- DEFAULT_OPEN_DBGSESSION_IN_BROWSER));
- } catch (CoreException ce) {
- fOpenDBGSessionInBrowserCheckBox
- .setSelection(DEFAULT_OPEN_DBGSESSION_IN_BROWSER);
- }
- setRemoteTabEnableState();
- try {
- fRemoteSourcePath.setText(configuration.getAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
- } catch (CoreException ce) {
- fRemoteSourcePath.setText("");
- }
-
- updatePathMapFromConfig(configuration);
-
- }
-
- private void updatePathMapFromConfig(ILaunchConfiguration config) {
- Map envVars = null;
- try {
- if (config != null) {
- envVars = config.getAttribute(
- PHPLaunchConfigurationAttribute.FILE_MAP, (Map) null);
- }
- updatePathMapTable(envVars, this.fRemoteDebugPathMapTable);
- setPathMapButtonsEnableState();
- } catch (CoreException ce) {
- log(ce);
- }
- }
-
- private void updatePathMapTable(Map map, Table tableWidget) {
- tableWidget.removeAll();
- if (map == null) {
- return;
- }
- Iterator iterator = map.keySet().iterator();
- while (iterator.hasNext()) {
- String key = (String) iterator.next();
- String value = (String) map.get(key);
- TableItem tableItem = new TableItem(tableWidget, SWT.NONE);
- tableItem.setText(new String[] { key, value });
- }
- }
-
- // protected void initializeLoadPath(ILaunchConfiguration configuration) {
- // boolean useDefaultLoadPath = true;
- // try {
- // useDefaultLoadPath =
- // configuration.getAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH,
- // true);
- // setUseLoadPathDefaults(useDefaultLoadPath);
- // if (useDefaultLoadPath) {
- // String projectName =
- // configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME,
- // "");
- // if (projectName != "") {
- // IProject aProject =
- // PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName);
- // if ((aProject != null) && JavaCore.isPHPProject(aProject)) {
- // JavaProject thePHPProject = new JavaProject();
- // thePHPProject.setProject(aProject);
- // List loadPathEntries = thePHPProject.getLoadPathEntries();
- // loadPathListViewer.setInput(loadPathEntries);
- // }
- // }
- // }
- // } catch (CoreException e) {
- // log(e);
- // }
- // }
-
- protected void setUseLoadPathDefaults(boolean useDefaults) {
- loadPathListViewer.getList().setEnabled(!useDefaults);
- // loadPathDefaultButton.setSelection(useDefaults);
- }
-
- protected void initializeInterpreterSelection(
- ILaunchConfiguration configuration) {
- String interpreterName = null;
- try {
- interpreterName = configuration.getAttribute(
- PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
- } catch (CoreException e) {
- log(e);
- }
- if (interpreterName != null && !interpreterName.equals(""))
- interpreterCombo.select(interpreterCombo.indexOf(interpreterName));
- }
-
- protected void initializeInterpreterCombo(Combo interpreterCombo) {
- installedInterpretersWorkingCopy = new ArrayList();
- installedInterpretersWorkingCopy.addAll(PHPRuntime.getDefault()
- .getInstalledInterpreters());
-
- String[] interpreterNames = new String[installedInterpretersWorkingCopy
- .size()];
- for (int interpreterIndex = 0; interpreterIndex < installedInterpretersWorkingCopy
- .size(); interpreterIndex++) {
- PHPInterpreter interpreter = (PHPInterpreter) installedInterpretersWorkingCopy
- .get(interpreterIndex);
- interpreterNames[interpreterIndex] = interpreter
- .getInstallLocation().toString();
- }
- interpreterCombo.setItems(interpreterNames);
-
- PHPInterpreter selectedInterpreter = PHPRuntime.getDefault()
- .getSelectedInterpreter();
- if (selectedInterpreter != null)
- interpreterCombo.select(interpreterCombo
- .indexOf(selectedInterpreter.getInstallLocation()
- .toString()));
- }
-
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- int selectionIndex = interpreterCombo.getSelectionIndex();
- if (selectionIndex >= 0)
- configuration.setAttribute(
- PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER,
- interpreterCombo.getItem(selectionIndex));
-
- // configuration.setAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH,
- // loadPathDefaultButton.getSelection());
-
- // if (!loadPathDefaultButton.getSelection()) {
- // List loadPathEntries = (List) loadPathListViewer.getInput();
- // List loadPathStrings = new ArrayList();
- // for (Iterator iterator = loadPathEntries.iterator();
- // iterator.hasNext();) {
- // LoadPathEntry entry = (LoadPathEntry) iterator.next();
- // loadPathStrings.add(entry.getPath().toString());
- // }
- // configuration.setAttribute(PHPLaunchConfigurationAttribute.CUSTOM_LOAD_PATH,
- // loadPathStrings);
- // }
-
- configuration.setAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_DEBUG,
- fRemoteDebugCheckBox.getSelection());
- configuration.setAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE,
- fRemoteDebugTranslate.getSelection());
- configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP,
- getMapFromPathMapTable());
- configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH,
- fRemoteSourcePath.getText());
- configuration.setAttribute(
- PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER,
- fOpenDBGSessionInBrowserCheckBox.getSelection());
- }
-
- protected Composite createPageRoot(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- composite.setLayout(layout);
- createVerticalSpacer(composite, 2);
- setControl(composite);
-
- return composite;
- }
-
- private Map getMapFromPathMapTable() {
- TableItem[] items = fRemoteDebugPathMapTable.getItems();
- if (items.length == 0) {
- return null;
- }
- Map map = new HashMap(items.length);
- for (int i = 0; i < items.length; i++) {
- TableItem item = items[i];
- String key = item.getText(0);
- String value = item.getText(1);
- map.put(key, value);
- }
- return map;
- }
-
- public String getName() {
- return PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.name");
- }
-
- public boolean isValid(ILaunchConfiguration launchConfig) {
- try {
- String selectedInterpreter = launchConfig.getAttribute(
- PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
- if (selectedInterpreter.length() == 0) {
- setErrorMessage(PHPDebugUiMessages
- .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message"));
- return false;
- }
- } catch (CoreException e) {
- log(e);
- }
-
- setErrorMessage(null);
- return true;
- }
-
- protected void log(Throwable t) {
- PHPDebugUiPlugin.log(t);
- }
-
- public Image getImage() {
- return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package net.sourceforge.phpdt.internal.launching;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.sourceforge.phpdt.internal.core.JavaProject;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-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();
-
- setEnvironmentVariables(configuration);
- String[] env = configuration.getEnvironment();
- Process nativePHPProcess = null;
- try {
- nativePHPProcess = configuration.getInterpreter().exec(commandLine,
- workingDirectory, env);
- } catch (IOException e) {
- throw new RuntimeException("Unable to execute interpreter: "
- + commandLine + workingDirectory);
- }
-
- IProcess process = DebugPlugin.newProcess(launch, nativePHPProcess,
- renderLabel(configuration));
- process
- .setAttribute(PHPLaunchingPlugin.PLUGIN_ID
- + ".launcher.cmdline", commandLine);
- process.setAttribute(IProcess.ATTR_PROCESS_TYPE,
- PHPLaunchConfigurationAttribute.PHP_LAUNCH_PROCESS_TYPE);
-
- 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 void setEnvironmentVariables(
- InterpreterRunnerConfiguration configuration) {
- IPath FilePath = new Path(configuration.getAbsoluteFileName());
- String OSFilePath = FilePath.toOSString();
- configuration.addEnvironmentValue("REDIRECT_URL", OSFilePath, true);
- configuration.addEnvironmentValue("REQUEST_URI", OSFilePath, true);
- configuration.addEnvironmentValue("PATH_INFO", OSFilePath, true);
- configuration.addEnvironmentValue("PATH_TRANSLATED", OSFilePath, true);
- configuration.addEnvironmentValue("SCRIPT_FILENAME", configuration
- .getInterpreter().getCommand(), true);
- configuration
- .addEnvironmentValue("SERVER_PROTOCOL", "HTTP / 1.1", true);
-
- configuration.addEnvironmentValue("REDIRECT_QUERY_STRING", "", true);
- configuration.addEnvironmentValue("REDIRECT_STATUS", "200", true);
- configuration.addEnvironmentValue("SERVER_SOFTWARE", "DBG / 2.1", true);
- configuration.addEnvironmentValue("SERVER_NAME", "localhost", true);
- configuration.addEnvironmentValue("SERVER_ADDR", "127.0.0.1", true);
- configuration.addEnvironmentValue("SERVER_PORT", "80", true);
- configuration.addEnvironmentValue("REMOTE_ADDR", "127.0.0.1", true);
-
- configuration.addEnvironmentValue("GATEWAY_INTERFACE", "CGI / 1.1",
- true);
- configuration.addEnvironmentValue("REQUEST_METHOD", "GET", true);
-
- Map stringVars = DebugPlugin.getDefault().getLaunchManager()
- .getNativeEnvironment();
- if (stringVars.containsKey("SYSTEMROOT"))
- configuration.addEnvironmentValue("SYSTEMROOT", (String) stringVars
- .get("SYSTEMROOT"), true);
-
- }
-
- protected String renderLoadPath(InterpreterRunnerConfiguration configuration) {
- StringBuffer loadPath = new StringBuffer();
-
- JavaProject 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 (Platform.getOS().equals(Platform.OS_WIN32))
- aPath = "\"" + aPath + "\"";
-
- return aPath;
- }
-
- protected String getDebugCommandLineArgument() {
- return "";
- }
-}
+++ /dev/null
-package net.sourceforge.phpdt.internal.launching;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import net.sourceforge.phpdt.internal.core.JavaProject;
-
-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;
-import org.eclipse.debug.internal.ui.launchConfigurations.EnvironmentVariable;
-
-public class InterpreterRunnerConfiguration {
- protected ILaunchConfiguration configuration;
-
- private HashMap fEnvironment;
-
- public InterpreterRunnerConfiguration(ILaunchConfiguration aConfiguration) {
- configuration = aConfiguration;
- fEnvironment = new HashMap();
- }
-
- 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 JavaProject getProject() {
- String projectName = "";
-
- try {
- projectName = configuration.getAttribute(
- PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
- } catch (CoreException e) {
- PHPLaunchingPlugin.log(e);
- }
-
- IProject project = PHPLaunchingPlugin.getWorkspace().getRoot()
- .getProject(projectName);
-
- JavaProject phpProject = new JavaProject();
- 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);
- }
-
- public boolean useRemoteDebugger() {
- try {
- return configuration.getAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_DEBUG, false);
- } catch (CoreException e) {
- PHPLaunchingPlugin.log(e);
- }
- return false;
- }
-
- public boolean usePathTranslation() {
- try {
- return configuration.getAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE,
- false);
- } catch (CoreException e) {
- PHPLaunchingPlugin.log(e);
- }
- return false;
- }
-
- public Map getPathMap() {
- try {
- return configuration.getAttribute(
- PHPLaunchConfigurationAttribute.FILE_MAP, (Map) null);
- } catch (CoreException e) {
- PHPLaunchingPlugin.log(e);
- }
- return (Map) null;
- }
-
- public boolean useDBGSessionInBrowser() {
- try {
- return configuration.getAttribute(
- PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER,
- true);
- } catch (CoreException e) {
- PHPLaunchingPlugin.log(e);
- }
- return false;
- }
-
- public void setEnvironment(String[] envp) {
- if (envp == null)
- return;
- for (int i = 0; i < envp.length; i++) {
- addEnvironmentValue(envp[i], true);
- }
- }
-
- public void addEnvironmentValue(String env, boolean replace) {
- String value = env.substring(env.indexOf('=') + 1);
- String key = env.substring(0, env.indexOf('='));
- addEnvironmentValue(key, value, replace);
- }
-
- public void addEnvironmentValue(String key, String value, boolean replace) {
- if (!replace && fEnvironment.containsKey(key)) {
- EnvironmentVariable ev = (EnvironmentVariable) fEnvironment
- .get(key);
- ev.setValue(ev.getValue() + ";" + value);
- fEnvironment.put(key, ev);
- } else
- this.fEnvironment.put(key, new EnvironmentVariable(key, value));
- }
-
- public String[] getEnvironment() {
-
- Iterator iter = fEnvironment.entrySet().iterator();
- List strings = new ArrayList(fEnvironment.size());
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- StringBuffer buffer = new StringBuffer((String) entry.getKey());
- buffer.append('=').append(
- ((EnvironmentVariable) entry.getValue()).getValue());
- strings.add(buffer.toString());
- }
- return (String[]) strings.toArray(new String[strings.size()]);
-
- }
-
- public String getRemoteSourcePath() {
-
- IProject project = getProject().getProject();
- if (!useRemoteDebugger())
- return project.getLocation().toOSString();
- else {
- try {
- return configuration.getAttribute(
- PHPLaunchConfigurationAttribute.REMOTE_PATH, "");
- } catch (CoreException e) {
- PHPLaunchingPlugin.log(e);
- }
- }
-
- return "";
- }
-
-}
+++ /dev/null
-package net.sourceforge.phpdt.internal.launching;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.builder.ExternalEditorInput;
-import net.sourceforge.phpeclipse.builder.FileStorage;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.IPersistableSourceLocator;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.ui.ISourcePresentation;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-
-public class PHPSourceLocator implements IPersistableSourceLocator, ISourcePresentation {
- private String absoluteWorkingDirectory;
- private Map pathMap = null;
- private boolean remoteDebug;
- private IPath remoteSourcePath;
- private String projectName;
-
- public PHPSourceLocator() {
-
- }
-
- public String getAbsoluteWorkingDirectory() {
- return absoluteWorkingDirectory;
- }
-
- /**
- * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
- */
- public String getMemento() throws CoreException {
- return null;
- }
-
- /**
- * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(String)
- */
- public void initializeFromMemento(String memento) throws CoreException {
- }
-
- /**
- * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(ILaunchConfiguration)
- */
- public void initializeDefaults (ILaunchConfiguration configuration) throws CoreException {
- this.absoluteWorkingDirectory = configuration.getAttribute (PHPLaunchConfigurationAttribute.WORKING_DIRECTORY, "");
- this.remoteDebug = configuration.getAttribute (PHPLaunchConfigurationAttribute.REMOTE_DEBUG,false);
- this.pathMap = configuration.getAttribute (PHPLaunchConfigurationAttribute.FILE_MAP, (Map)null);
- this.projectName = configuration.getAttribute (PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
-
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- this.remoteSourcePath = new Path ((configuration.getAttribute (PHPLaunchConfigurationAttribute.REMOTE_PATH, "")).toLowerCase());
- }
- else {
- this.remoteSourcePath = new Path (configuration.getAttribute (PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
- }
-
-// system.os.name
- }
-
- /**
- * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame)
- *
- * Return the client side source filename for the server side source file.
- * E.g. when cross debugging, the server side filename could be /var/www/index.php
- * on the client side it is either a Eclipse_PHP_projectname\index.php (when it is a linked file)
- *
- *
- * @param stackFrame The stackframe for which we want the client side source file name
- * @return The filename as it appears on the client side
- */
- public Object getSourceElement (IStackFrame stackFrame) {
- IPath projectPath;
- IPath remotePath;
- IPath path;
- IPath localPath;
- Iterator iterator;
- String fileName;
- String file;
- String local;
-
- fileName = ((PHPStackFrame) stackFrame).getFileName (); // Get the filename as it is submitted by DBG
- file = "";
-
- if (remoteDebug) { // Is it a remote debugging session
- path = new Path (fileName); // Create a IPath object for the server side filename
-
- if (!remoteSourcePath.isEmpty()) {
- if (remoteSourcePath.isPrefixOf (path)) { // Is the server side filename with the remote source path
- path = path.removeFirstSegments (remoteSourcePath.matchingFirstSegments (path)); // Remove the remote source path
- file = path.toString (); // The filename without the remote source path
- projectPath = (PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path
-
- return (projectPath.append (path)).toOSString (); // Return the filename as absolute client side path
- }
- }
- else {
- if (pathMap == null) { // Do we have path mapping (e.g. for cross platform debugging)
- return fileName; // No, then return the filename as it given by DBG (the full server side path)
- }
-
- iterator = pathMap.keySet().iterator();
-
- while (iterator.hasNext ()) {
- local = (String) iterator.next (); // Get the local/client side path of the mapping
- remotePath = new Path ((String) pathMap.get (local)); // Get the remote/server side path of the mapping
-
- if (remotePath.isPrefixOf (path)) { // Starts the remote/server side file path with the remote/server side mapping path
- path = path.removeFirstSegments (remotePath.matchingFirstSegments (path)); // Remove the absolute path from filename
- localPath = new Path (local); // Create new IPath object for the local/client side path
- path = localPath.append (path); // Prepend the project relative path to filename
-
- projectPath = (PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName).getLocation()); // Get the absolute project path
-
- return (projectPath.append (path)).toOSString (); // Return the filename as absolute client side path
- }
- }
- }
-
- if (pathMap == null) { // Do we have path mapping (e.g. for cross platform debugging)
- return fileName; // No, then return the filename as it given by DBG (the full server side path)
- }
-
- iterator = pathMap.keySet().iterator();
-
- while (iterator.hasNext ()) {
- local = (String) iterator.next (); // Get the local/client side path of the mapping
- remotePath = new Path ((String) pathMap.get (local)); // Get the remote/server side path of the mapping
-
- if (remotePath.isPrefixOf (path)) { // Starts the remote/server side file path with the remote/server side mapping path
- path = path.removeFirstSegments (remotePath.matchingFirstSegments (path)); // Remove the absolute path from filename
- localPath = new Path (local); // Create new IPath object for the local/client side path
-
- return localPath.append (path).toOSString (); // Append the remote filename to the client side path (So we return the absolute path
- // to the source file as the client side sees it.
- }
- }
-
- return fileName;
- } else {
- return fileName;
- }
- }
-
- /**
- * @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(IEditorInput, Object)
- */
- public String getEditorId(IEditorInput input, Object element) {
- return PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor((String) element).getId();
- }
-
- /**
- * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(Object)
- *
- * @param element The absolute local/client side file path
- */
- public IEditorInput getEditorInput (Object element) {
- String filename;
- IWorkbench workbench;
- IWorkbenchWindow window;
- IWorkbenchPage page;
- IPath path;
- IFile eclipseFile;
-
- filename = (String) element;
- workbench = PlatformUI.getWorkbench ();
- window = workbench.getWorkbenchWindows ()[0];
- page = window.getActivePage ();
- path = new Path (filename); // Create an IPath object of the absolute local/client side file name
-
- // If the file exists in the workspace, open it
- eclipseFile = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation (path);
-
- // IFile eclipseFile = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation(new Path(filename));
-// if (eclipseFile == null) {
-// filename = this.getAbsoluteWorkingDirectory() + "/" + filename;
-// eclipseFile = PHPeclipsePlugin.getWorkspace().getRoot().getFileForLocation(new Path(filename));
-// if (eclipseFile == null) {
-// PHPeclipsePlugin.log(IStatus.INFO, "Could not find file \"" + element + "\".");
-// return null;
-// }
-// } else
-
- if (eclipseFile == null || !eclipseFile.exists ()) {
- // Otherwise open the stream directly
- //
- if (page == null) {
- PHPeclipsePlugin.log(IStatus.INFO, "Could not find file \"" + element + "\".");
- return null;
- }
-
- FileStorage storage = new FileStorage (path);
- storage.setReadOnly ();
-
- // IEditorRegistry registry = workbench.getEditorRegistry();
- // IEditorDescriptor desc = registry.getDefaultEditor(filename);
- // if (desc == null) {
- // desc = registry.getDefaultEditor();
- // }
- return new ExternalEditorInput(storage);
- }
-
- return new FileEditorInput (eclipseFile);
- }
-}
+++ /dev/null
-/**********************************************************************
- Copyright (c) 2000, 2002 IBM Corp. and others.
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Common Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/cpl-v10.html
-
- Contributors:
- IBM Corporation - Initial implementation
- Vicente Fernando - www.alfersoft.com.ar
- **********************************************************************/
-package net.sourceforge.phpeclipse.xdebug.php.launching;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import net.sourceforge.phpeclipse.xdebug.core.IXDebugPreferenceConstants;
-import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
-import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
-
-public class PHPLaunchConfigurationDelegate extends LaunchConfigurationDelegate {
-
- /**
- * @see ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String,
- * ILaunch, IProgressMonitor)
- */
- public void launch(ILaunchConfiguration configuration, String mode,
- ILaunch launch, IProgressMonitor monitor) throws CoreException {
- List commandList = new ArrayList();
-
- String phpInterpreter = configuration.getAttribute(
- IXDebugConstants.ATTR_PHP_INTERPRETER, (String) null);
- boolean useDefaultInterpreter = configuration.getAttribute(
- IXDebugConstants.ATTR_PHP_DEFAULT_INTERPRETER, true);
-
- if (useDefaultInterpreter)
- phpInterpreter = XDebugCorePlugin
- .getDefault()
- .getPreferenceStore()
- .getString(
- IXDebugPreferenceConstants.PHP_INTERPRETER_PREFERENCE);
-
- File exe = new File(phpInterpreter);
- // Just to get sure that the interpreter exists
- if (!exe.exists()) {
- abort(
- MessageFormat
- .format(
- "Specified PHP executable {0} does not exist. Check value of PHP-Interpreter.",
- new String[] { phpInterpreter }), null);
- }
- commandList.add(phpInterpreter);
-
- // Project name
- String projectName = configuration.getAttribute(
- IXDebugConstants.ATTR_PHP_PROJECT, (String) null);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- projectName);
- // Just to get sure that the project exists
- if (project == null) {
- abort("Project does not exist.", null);
- }
- String fileName = configuration.getAttribute(
- IXDebugConstants.ATTR_PHP_FILE, (String) null);
-
- IFile file = project.getFile(fileName);
- // Just to get sure that the script exists
- if (!file.exists()) {
- abort(MessageFormat.format("PHP-Script {0} does not exist.",
- new String[] { file.getFullPath().toString() }), null);
- }
-
- commandList.add(file.getLocation().toOSString());
-
- // Get de Debugport form the Launchconfiguration or from the preferences
- int debugPort = configuration.getAttribute(
- IXDebugConstants.ATTR_PHP_DEBUGPORT, -1);
- boolean useDefaultPort = configuration.getAttribute(
- IXDebugConstants.ATTR_PHP_DEFAULT_DEBUGPORT, true);
- if (useDefaultPort)
- debugPort = XDebugCorePlugin.getDefault().getPreferenceStore()
- .getInt(IXDebugPreferenceConstants.DEBUGPORT_PREFERENCE);
- if (debugPort < 1024)
- debugPort = IXDebugPreferenceConstants.DEFAULT_DEBUGPORT;
-
- String[] envp = DebugPlugin.getDefault().getLaunchManager()
- .getEnvironment(configuration);
- // appends the environment to the native environment
- if (envp == null) {
- Map stringVars = DebugPlugin.getDefault().getLaunchManager()
- .getNativeEnvironment();
- int idx = 0;
- envp = new String[stringVars.size()];
- for (Iterator i = stringVars.keySet().iterator(); i.hasNext();) {
- String key = (String) i.next();
- String value = (String) stringVars.get(key);
- envp[idx++] = key + "=" + value;
- }
- }
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- String[] env = new String[envp.length + 1];
- for (int i = 0; i < envp.length; i++)
- env[i + 1] = envp[i];
- env[0] = "XDEBUG_CONFIG=idekey=xdebug_test remote_enable=1";
- envp = env;
- }
-
- String[] commandLine = (String[]) commandList
- .toArray(new String[commandList.size()]);
- Process process = DebugPlugin.exec(commandLine, null, envp);
- IProcess p = DebugPlugin.newProcess(launch, process, phpInterpreter);
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- IDebugTarget target = new XDebugTarget(launch, p, debugPort);
- launch.addDebugTarget(target);
- }
- }
-
- /**
- * Throws an exception with a new status containing the given message and
- * optional exception.
- *
- * @param message
- * error message
- * @param e
- * underlying exception
- * @throws CoreException
- */
- private void abort(String message, Throwable e) throws CoreException {
- // TODO: the plug-in code should be the example plug-in, not Perl debug
- // model id
- throw new CoreException(new Status(IStatus.ERROR,
- IXDebugConstants.ID_PHP_DEBUG_MODEL, 0, message, e));
- }
-
-}
+++ /dev/null
-package net.sourceforge.phpeclipse.xdebug.php.launching;
-
-import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
-
-public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant {
-
- public String getSourceName(Object object) throws CoreException {
- if (object instanceof XDebugStackFrame) {
- return ((XDebugStackFrame) object).getSourceName();
- }
- return null;
- }
-
-}
+++ /dev/null
-/**
- *
- */
-package net.sourceforge.phpeclipse.xdebug.php.model;
-
-import net.sourceforge.phpeclipse.xdebug.core.Base64;
-import net.sourceforge.phpeclipse.xdebug.core.DebugConnection;
-import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
-import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
-import net.sourceforge.phpeclipse.xdebug.core.DebugConnection.DebugResponse;
-import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.ILineBreakpoint;
-import org.eclipse.debug.core.model.IMemoryBlock;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.core.model.IThread;
-import org.eclipse.debug.core.model.IValue;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author Christian
- *
- */
-public class XDebugTarget extends XDebugElement implements IDebugTarget,
- IDebugEventSetListener {
- // associated system process (VM)
- private IProcess fProcess;
-
- // containing launch object
- private ILaunch fLaunch;
-
- // debugPort
- private int fDebugPort;
-
- // program name
- // private String fName;
-
- // suspend state
- private boolean fSuspended = true;
-
- // terminated state
- private boolean fTerminated = false;
-
- // threads
- private XDebugThread fThread;
-
- private IThread[] fThreads;
-
- // event dispatch job
- // private EventDispatchJob fEventDispatch;
-
- private DebugConnection fDebugConnection;
-
- // private DebugResponse lastResponse;
-
- /**
- * Constructs a new debug target in the given launch for the associated PDA
- * VM process.
- *
- * @param launch
- * containing launch
- * @param debugPort
- * port to read events from
- * @exception CoreException
- * if unable to connect to host
- */
- public XDebugTarget(ILaunch launch, IProcess process, int debugPort)
- throws CoreException {
- super(null);
- fLaunch = launch;
- fProcess = process;
- fTarget = this;
- fDebugConnection = new DebugConnection(this, debugPort);
- fThread = new XDebugThread(this);
- fThreads = new IThread[] { fThread };
- DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(
- this);
- DebugPlugin.getDefault().addDebugEventListener(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
- */
- public IProcess getProcess() {
- return fProcess;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
- */
- public IThread[] getThreads() throws DebugException {
- return fThreads;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
- */
- public boolean hasThreads() throws DebugException {
- return (fThreads.length > 0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDebugTarget#getName()
- */
- public String getName() throws DebugException {
- return "PHP XDebug Client at localhost:" + fDebugPort;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint)
- */
- public boolean supportsBreakpoint(IBreakpoint breakpoint) {
- if (breakpoint.getModelIdentifier().equals(
- IXDebugConstants.ID_PHP_DEBUG_MODEL)) {
- return true;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
- */
- public IDebugTarget getDebugTarget() {
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
- */
- public ILaunch getLaunch() {
- return fLaunch;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
- */
- public boolean canTerminate() {
- return getProcess().canTerminate();
- // return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
- */
- public boolean isTerminated() {
- // return getProcess().isTerminated();
- return fTerminated;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.ITerminate#terminate()
- */
- public void terminate() throws DebugException {
- fDebugConnection.sendRequest("stop");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
- */
- public boolean canResume() {
- return !isTerminated() && isSuspended();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
- */
- public boolean canSuspend() {
- return !isTerminated() && !isSuspended();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
- */
- public boolean isSuspended() {
- return fSuspended;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.ISuspendResume#resume()
- */
- public void resume() throws DebugException {
- fDebugConnection.sendRequest("run");
- }
-
- /**
- * Notification the target has resumed for the given reason
- *
- * @param detail
- * reason for the resume
- */
- private void resumed(int detail) {
- fSuspended = false;
- fThread.fireResumeEvent(detail);
- }
-
- /**
- * Notification the target has suspended for the given reason
- *
- * @param detail
- * reason for the suspend
- */
- public void suspended(int detail) {
- fSuspended = true;
- fThread.fireSuspendEvent(detail);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
- */
- public void suspend() throws DebugException {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
- */
- public void breakpointAdded(IBreakpoint breakpoint) {
-
- if (supportsBreakpoint(breakpoint)) {
- try {
- if (breakpoint.isEnabled()) {
- IMarker marker = breakpoint.getMarker();
- if (marker != null) {
- try {
- String fileName = PHPDebugUtils.escapeString(marker
- .getResource().getLocation().toString());
- String arg = "-t line -f file:///"
- + fileName
- + " -n "
- + ((ILineBreakpoint) breakpoint)
- .getLineNumber();
- int id = fDebugConnection.sendRequest(
- "breakpoint_set", arg);
- // set the marker Attribute to make later
- // idetification possible
- // TODO: make sure that attribute is set before
- // response from debugger is beeing prosessed
- marker.setAttribute(
- XDebugLineBreakpoint.BREAKPOINT_ID, id);
-
- } catch (CoreException e) {
- }
- }
- }
- } catch (CoreException e) {
-
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint,
- * org.eclipse.core.resources.IMarkerDelta)
- */
- public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
- if (supportsBreakpoint(breakpoint)) {
- try {
- int id = ((XDebugLineBreakpoint) breakpoint).getID();
- if (id > 0)
- fDebugConnection.sendRequest("breakpoint_remove", "-d "
- + id);
- } catch (CoreException e) {
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint,
- * org.eclipse.core.resources.IMarkerDelta)
- */
- public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
- // if (supportsBreakpoint(breakpoint)) {
- // try {
- // if (breakpoint.isEnabled()) {
- // breakpointAdded(breakpoint);
- // } else {
- // breakpointRemoved(breakpoint, null);
- // }
- // } catch (CoreException e) {
- // }
- // }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDisconnect#canDisconnect()
- */
- public boolean canDisconnect() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDisconnect#disconnect()
- */
- public void disconnect() throws DebugException {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
- */
- public boolean isDisconnected() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
- */
- public boolean supportsStorageRetrieval() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long,
- * long)
- */
- public IMemoryBlock getMemoryBlock(long startAddress, long length)
- throws DebugException {
- return null;
- }
-
- /**
- * Notification we have connected to the PHP debugger and it has started.
- * Resume the the debugger.
- */
- public void started() {
-
- fThread.setBreakpoints(null);
- fThread.setStepping(false);
-
- installDeferredBreakpoints();
- try {
- resume();
- // step();
- } catch (DebugException e) {
- }
- }
-
- /**
- * Install breakpoints that are already registered with the breakpoint
- * manager.
- */
- private void installDeferredBreakpoints() {
- IBreakpoint[] breakpoints = XDebugCorePlugin.getBreakpoints();
- for (int i = 0; i < breakpoints.length; i++) {
- breakpointAdded(breakpoints[i]);
- }
- }
-
- /**
- * Called when this debug target terminates.
- */
- public void terminated() {
- fTerminated = true;
- fSuspended = false;
- XDebugCorePlugin.getBreakpointManager().removeBreakpointListener(this);
- fireTerminateEvent();
- DebugPlugin.getDefault().removeDebugEventListener(this);
- fThread.removeEventListeners();
- }
-
- /**
- * Returns the current stack frames in the target.
- *
- * @return the current stack frames in the target
- * @throws DebugException
- * if unable to perform the request
- */
- protected IStackFrame[] getStackFrames() throws DebugException {
- int id = fDebugConnection.sendRequest("stack_get");
- DebugResponse lastResponse = fDebugConnection.waitforTransID(id);
- if (lastResponse.isError())
- return new IStackFrame[0];
- Node response = lastResponse.getParentNode();
- NodeList frames = response.getChildNodes();
- IStackFrame[] theFrames = new IStackFrame[frames.getLength()];
- for (int i = 0; i < frames.getLength(); i++) {
- Node stackNode = frames.item(i);
- theFrames[i] = new XDebugStackFrame(fThread, stackNode, i);
- }
- return theFrames;
- }
-
- /**
- * Single step the interpreter.
- *
- * @throws DebugException
- * if the request fails
- */
- protected void step_over() throws DebugException {
- fThread.setStepping(true);
- resumed(DebugEvent.STEP_OVER);
- fDebugConnection.sendRequest("step_over");
- }
-
- /**
- * Single step the interpreter.
- *
- * @throws DebugException
- * if the request fails
- */
- protected void step_into() throws DebugException {
- fThread.setStepping(true);
- resumed(DebugEvent.STEP_INTO);
- fDebugConnection.sendRequest("step_into");
- }
-
- /**
- * Single step the interpreter.
- *
- * @throws DebugException
- * if the request fails
- */
- protected void step_out() throws DebugException {
- fThread.setStepping(true);
- resumed(DebugEvent.STEP_RETURN);
- fDebugConnection.sendRequest("step_out");
- }
-
- /**
- * Returns the current value of the given variable.
- *
- * @param variable
- * @return variable value
- * @throws DebugException
- * if the request fails
- */
- protected IValue getVariableValue(XDebugVariable variable)
- throws DebugException {
- // synchronized (fDebugSocket) {
- // fDebugConnection.sendRequest("var","" +
- // variable.getStackFrame().getIdentifier() + " " + variable.getName());
- // try {
- // String value = fDebugReader.readLine();
- // //return new XDebugValue(this, value);
- //
- // } catch (IOException e) {
- // abort(MessageFormat.format("Unable to retrieve value for variable
- // {0}", new String[]{variable.getName()}), e);
- // }
- // }
- return null;
- }
-
- /**
- * Returns the values on the data stack (top down)
- *
- * @return the values on the data stack (top down)
- */
- public IValue[] getDataStack() throws DebugException {
- // synchronized (fDebugSocket) {
- // fDebugConnection.sendRequest ("data");
- // try {
- // String valueString = fDebugReader.readLine();
- // if (valueString != null && valueString.length() > 0) {
- // String[] values = valueString.split("\\|");
- // IValue[] theValues = new IValue[values.length];
- // for (int i = 0; i < values.length; i++) {
- // String value = values[values.length - i - 1];
- // // theValues[i] = new XDebugValue(this, value);
- // }
- // return theValues;
- // }
- // } catch (IOException e) {
- // abort("Unable to retrieve data stack", e);
- // }
- // }
- return new IValue[0];
- }
-
- public boolean setVarValue(String name, String value) {
- int id = -1;
- String str = Base64.encodeBytes(value.getBytes());
- int len = str.length();
-
- try {
- id = fDebugConnection.sendRequest("property_set", "-n " + name
- + " -l " + len + " -- " + str);
- } catch (DebugException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- DebugResponse dr = getResponse(id);
- if ((dr.getAttributeValue("success")).equals("1"))
- return true;
-
- return false;
- }
-
- public DebugResponse getResponse(int id) {
- return fDebugConnection.waitforTransID(id);
- }
-
- /**
- * Sends a request to the Debugengine and waits for an OK.
- *
- * @param command
- * debug command
- * @throws DebugException
- * if the request fails
- */
-
- public int sendRequest(String command) throws DebugException {
- return fDebugConnection.sendRequest(command, "");
- }
-
- /**
- * Sends a request to the Debugengine and waits for an OK.
- *
- * @param command
- * debug command
- * @arguments arguments for the command
- * @throws DebugException
- * if the request fails
- */
-
- public int sendRequest(String command, String arguments)
- throws DebugException {
- return fDebugConnection.sendRequest(command, arguments);
- }
-
- /**
- * Notification a breakpoint was encountered. Determine which breakpoint was
- * hit and fire a suspend event.
- *
- * @param event
- * debug event
- */
- public void breakpointHit(Node node) {
- // determine which breakpoint was hit, and set the thread's breakpoint
- Node child = node.getFirstChild();
- if (child.getNodeName().equals("stack")) {
- int lineNumber = Integer.parseInt(PHPDebugUtils.getAttributeValue(
- child, "lineno"));
- String filename = PHPDebugUtils
- .getAttributeValue(child, "filename").substring(8); // remove
- // file:///
- IBreakpoint[] breakpoints = XDebugCorePlugin.getBreakpoints();
- for (int i = 0; i < breakpoints.length; i++) {
- IBreakpoint breakpoint = breakpoints[i];
- if (supportsBreakpoint(breakpoint)) {
- if (breakpoint instanceof ILineBreakpoint) {
- ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
- try {
- if (breakpoint.isEnabled()) {
- IMarker marker = breakpoint.getMarker();
- if (marker != null) {
-
- String name = marker.getResource()
- .getLocation().toOSString();
- if (name.equals(PHPDebugUtils
- .unescapeString(filename))
- && (lineBreakpoint.getLineNumber() == lineNumber)) {
- fThread
- .setBreakpoints(new IBreakpoint[] { breakpoint });
- break;
- }
- }
-
- }
- } catch (CoreException e) {
- }
- }
- }
- }
- }
- suspended(DebugEvent.BREAKPOINT);
- }
-
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
- if ((event.getKind() == DebugEvent.CREATE)
- && (event.getSource() instanceof XDebugElement)) {
- if (((XDebugElement) event.getSource()).getModelIdentifier() == IXDebugConstants.ID_PHP_DEBUG_MODEL) {
- if (event.getKind() == DebugEvent.CREATE)
- started();
- }
- }
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2004 Christopher Lenz and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Christopher Lenz - initial API
- *
- * $Id: XMLDocument.java,v 1.2 2006-10-21 23:13:43 pombredanne Exp $
- */
-
-package net.sourceforge.phpeclipse.xml.core.internal.model;
-
-import net.sourceforge.phpeclipse.core.model.SourceReference;
-import net.sourceforge.phpeclipse.xml.core.internal.parser.XMLParser;
-import net.sourceforge.phpeclipse.xml.core.model.IXMLDocument;
-import net.sourceforge.phpeclipse.xml.core.model.IXMLElement;
-import net.sourceforge.phpeclipse.xml.core.parser.IProblemCollector;
-import net.sourceforge.phpeclipse.xml.core.parser.IXMLParser;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-
-/**
- *
- */
-public class XMLDocument extends SourceReference implements IXMLDocument,
- IDocumentListener {
- // Instance Variables ------------------------------------------------------
-
- private IXMLElement root;
-
- private String systemId;
-
- private Object dirtyLock = new Object();
-
- private boolean dirty = true;
-
- // Constructors ------------------------------------------------------------
-
- public XMLDocument(IDocument document, String systemId) {
- super(document, 0, document.getLength());
- this.systemId = systemId;
- }
-
- // IXMLDocument Implementation ---------------------------------------------
-
- /*
- * @see IXMLDocument#getRoot()
- */
- public IXMLElement getRoot() {
- return root;
- }
-
- /*
- * @see net.sourceforge.phpeclipse.xml.core.model.IXMLDocument#getSystemId()
- */
- public String getSystemId() {
- return systemId;
- }
-
- /*
- * @see IStyleSheet#reconcile(IProblemCollector)
- */
- public void reconcile(IProblemCollector problemCollector, IFile file) {
- synchronized (dirtyLock) {
- if (!dirty) {
- return;
- }
- dirty = false;
- }
-
- synchronized (this) {
- boolean doParse = false;
- root = null;
- if (file != null) {
- String filename = file.getLocation().toString();
- int len = filename.length();
- if (len >= 4) {
- if ((filename.charAt(len - 1) != 'l' && filename
- .charAt(len - 1) != 'L')
- || (filename.charAt(len - 2) != 'p' && filename
- .charAt(len - 2) != 'P')
- || (filename.charAt(len - 3) != 't' && filename
- .charAt(len - 3) != 'T')
- || (filename.charAt(len - 4) != '.')) {
- if ((filename.charAt(len - 1) != 'm' && filename
- .charAt(len - 1) != 'M')
- || (filename.charAt(len - 2) != 't' && filename
- .charAt(len - 2) != 'T')
- || (filename.charAt(len - 3) != 'h' && filename
- .charAt(len - 3) != 'H')
- || (filename.charAt(len - 4) != '.')) {
- if (len >= 5) {
- if ((filename.charAt(len - 1) != 'l' && filename
- .charAt(len - 1) != 'L')
- || (filename.charAt(len - 2) != 'm' && filename
- .charAt(len - 2) != 'M')
- || (filename.charAt(len - 3) != 't' && filename
- .charAt(len - 3) != 'T')
- || (filename.charAt(len - 4) != 'h' && filename
- .charAt(len - 4) != 'H')
- || (filename.charAt(len - 5) != '.')) {
- doParse = true;
- }
- }
- }
- }
- } else {
- doParse = true;
- }
- }
- if (doParse) {
- IXMLParser parser = new XMLParser();
- parser.setProblemCollector(problemCollector);
- parser.setSource(getDocument());
- parser.setSystemId(systemId);
- IXMLDocument model = parser.parse();
- if (model != null) {
- root = model.getRoot();
- }
- }
- }
- }
-
- // IDocumentListener Implementation ----------------------------------------
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- // do nothing
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- synchronized (dirtyLock) {
- dirty = true;
- }
- }
-
- // Public Methods ----------------------------------------------------------
-
- /**
- * Sets the root element.
- *
- * @param root
- * the root element to set
- */
- public void setRoot(IXMLElement root) {
- this.root = root;
- }
-
-}
\ No newline at end of file