From: walsleben Date: Mon, 6 Dec 2004 18:04:33 +0000 (+0000) Subject: inital X-Git-Url: http://secure.phpeclipse.com inital --- diff --git a/net.sourceforge.phpeclipse.xdebug.ui/.classpath b/net.sourceforge.phpeclipse.xdebug.ui/.classpath new file mode 100644 index 0000000..065ac06 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/net.sourceforge.phpeclipse.xdebug.ui/.project b/net.sourceforge.phpeclipse.xdebug.ui/.project new file mode 100644 index 0000000..4c7f716 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/.project @@ -0,0 +1,28 @@ + + + net.sourceforge.phpeclipse.xdebug.ui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/net.sourceforge.phpeclipse.xdebug.ui/build.properties b/net.sourceforge.phpeclipse.xdebug.ui/build.properties new file mode 100644 index 0000000..f22a911 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/build.properties @@ -0,0 +1,4 @@ +source.xdebugui.jar = src/ +output.xdebugui.jar = bin/ +bin.includes = plugin.xml,\ + xdebugui.jar diff --git a/net.sourceforge.phpeclipse.xdebug.ui/plugin.properties b/net.sourceforge.phpeclipse.xdebug.ui/plugin.properties new file mode 100644 index 0000000..06b8368 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/plugin.properties @@ -0,0 +1,19 @@ + +Plugin.name=PHPEclipse XDebug UI + +LaunchShortcut.PHP.label=PHP Application + +PreferencePage.PHPBase.name=PHP +PreferencePage.PHPInterpreter.name=Installed Interpreters + +DebugActionSet.label=PHP XDebug +RunMenu.label=&Run + +BreakpoingActionSet.label=PHP Breakpoints +# GlobalManageBreakpointAction.label=Toggle Line Breakpoint (PHP) +AddBreakpoint.label=Toggle PHP &Breakpoint + +Context.Debugging.name=xDebugging PHP +Context.Debugging.description=xDebugging PHP-Scripts +DebugHover.description=Shows the value of the selected variable. +DebugHover.label=debug variable hover diff --git a/net.sourceforge.phpeclipse.xdebug.ui/plugin.xml b/net.sourceforge.phpeclipse.xdebug.ui/plugin.xml new file mode 100644 index 0000000..98fb90f --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/plugin.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugBreakpointAdapterFactory.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugBreakpointAdapterFactory.java new file mode 100644 index 0000000..1086ec5 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugBreakpointAdapterFactory.java @@ -0,0 +1,43 @@ +/* + * Created on 25.11.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package net.sourceforge.phpeclipse.xdebug.ui; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; +import org.eclipse.ui.texteditor.ITextEditor; + +/** + * @author Axel + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class XDebugBreakpointAdapterFactory implements IAdapterFactory { + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (adaptableObject instanceof ITextEditor) { + ITextEditor editorPart = (ITextEditor) adaptableObject; + IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class); + if (resource != null) { + String extension = resource.getFileExtension(); + if (extension != null && extension.equals("pda")) { + return new XDebugLineBreakpointAdapter(); + } + } + } + return null; + } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + public Class[] getAdapterList() { + return new Class[]{IToggleBreakpointsTarget.class}; + } +} diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugLineBreakpointAdapter.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugLineBreakpointAdapter.java new file mode 100644 index 0000000..1bdcba0 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugLineBreakpointAdapter.java @@ -0,0 +1,105 @@ +/* + * Created on 25.11.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package net.sourceforge.phpeclipse.xdebug.ui; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.core.model.ILineBreakpoint; +import net.sourceforge.phpeclipse.xdebug.core.IXDebugConstants; +import net.sourceforge.phpeclipse.xdebug.core.XDebugLineBreakpoint; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.texteditor.ITextEditor; + +/** + * @author Axel + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class XDebugLineBreakpointAdapter implements IToggleBreakpointsTarget { + /* (non-Javadoc) + * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + ITextEditor textEditor = getEditor(part); + if (textEditor != null) { + IResource resource = (IResource) textEditor.getEditorInput().getAdapter(IResource.class); + ITextSelection textSelection = (ITextSelection) selection; + int lineNumber = textSelection.getStartLine(); + IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IXDebugConstants.ID_XDEBUG_DEBUG_MODEL); + for (int i = 0; i < breakpoints.length; i++) { + IBreakpoint breakpoint = breakpoints[i]; + if (resource.equals(breakpoint.getMarker().getResource())) { + if (((ILineBreakpoint)breakpoint).getLineNumber() == (lineNumber + 1)) { + // remove + breakpoint.delete(); + return; + } + } + } + // create line breakpoint (doc line numbers start at 0) + XDebugLineBreakpoint lineBreakpoint = new XDebugLineBreakpoint(resource, lineNumber + 1); + DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint); + } + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) { + return getEditor(part) != null; + } + + /** + * Returns the editor being used to edit a PDA file, associated with the + * given part, or null if none. + * + * @param part workbench part + * @return the editor being used to edit a PDA file, associated with the + * given part, or null if none + */ + private ITextEditor getEditor(IWorkbenchPart part) { + if (part instanceof ITextEditor) { + ITextEditor editorPart = (ITextEditor) part; + IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class); + if (resource != null) { + String extension = resource.getFileExtension(); + if (extension != null && extension.equals("pda")) { + return editorPart; + } + } + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) { + return false; + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) { + return false; + } +} diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugMainTab.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugMainTab.java new file mode 100644 index 0000000..66852a3 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugMainTab.java @@ -0,0 +1,150 @@ +/* + * Created on 25.11.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package net.sourceforge.phpeclipse.xdebug.ui; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +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 net.sourceforge.phpeclipse.xdebug.core.IXDebugConstants; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ResourceListSelectionDialog; + +/** + * @author Axel + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class XDebugMainTab extends AbstractLaunchConfigurationTab { + + private Text fProgramText; + private Button fProgramButton; + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + Font font = parent.getFont(); + + Composite comp = new Composite(parent, SWT.NONE); + setControl(comp); + GridLayout topLayout = new GridLayout(); + topLayout.verticalSpacing = 0; + topLayout.numColumns = 3; + comp.setLayout(topLayout); + comp.setFont(font); + + createVerticalSpacer(comp, 3); + + Label programLabel = new Label(comp, SWT.NONE); + programLabel.setText("&Program:"); + GridData gd = new GridData(GridData.BEGINNING); + programLabel.setLayoutData(gd); + programLabel.setFont(font); + + fProgramText = new Text(comp, SWT.SINGLE | SWT.BORDER); + gd = new GridData(GridData.FILL_HORIZONTAL); + fProgramText.setLayoutData(gd); + fProgramText.setFont(font); + fProgramText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + updateLaunchConfigurationDialog(); + } + }); + + fProgramButton = createPushButton(comp, "&Browse...", null); //$NON-NLS-1$ + fProgramButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + browsePDAFiles(); + } + }); + } + + /** + * Open a resource chooser to select a PDA program + */ + protected void browsePDAFiles() { + ResourceListSelectionDialog dialog = new ResourceListSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE); + dialog.setTitle("PDA Program"); + dialog.setMessage("Select PDA Program"); + // TODO: single select + if (dialog.open() == Window.OK) { + Object[] files = dialog.getResult(); + IFile file = (IFile) files[0]; + fProgramText.setText(file.getFullPath().toString()); + } + + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) + */ + public void initializeFrom(ILaunchConfiguration configuration) { + try { + String program = configuration.getAttribute(IXDebugConstants.ATTR_XDEBUG_PROGRAM, (String)null); + if (program != null) { + fProgramText.setText(program); + } + } catch (CoreException e) { + setErrorMessage(e.getMessage()); + } + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + String program = fProgramText.getText().trim(); + if (program.length() == 0) { + program = null; + } + configuration.setAttribute(IXDebugConstants.ATTR_XDEBUG_PROGRAM, program); + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() + */ + public String getName() { + return "Main"; + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) + */ + public boolean isValid(ILaunchConfiguration launchConfig) { + String text = fProgramText.getText(); + if (text.length() > 0) { + IPath path = new Path(text); + if (ResourcesPlugin.getWorkspace().getRoot().findMember(path) == null) { + setErrorMessage("Specified program does not exist"); + return false; + } + } else { + setMessage("Specify a program"); + } + return super.isValid(launchConfig); + } +} diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugModelPresentation.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugModelPresentation.java new file mode 100644 index 0000000..ea5f50f --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugModelPresentation.java @@ -0,0 +1,76 @@ +/* + * Created on 25.11.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package net.sourceforge.phpeclipse.xdebug.ui; + +import org.eclipse.core.resources.IFile; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.ILineBreakpoint; +import org.eclipse.debug.core.model.IValue; +import org.eclipse.debug.ui.IDebugModelPresentation; +import org.eclipse.debug.ui.IValueDetailListener; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.part.FileEditorInput; + +/** + * @author Axel + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class XDebugModelPresentation extends LabelProvider implements IDebugModelPresentation { + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IDebugModelPresentation#setAttribute(java.lang.String, java.lang.Object) + */ + public void setAttribute(String attribute, Object value) { + } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object element) { + return null; + } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + */ + public String getText(Object element) { + return null; + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IDebugModelPresentation#computeDetail(org.eclipse.debug.core.model.IValue, org.eclipse.debug.ui.IValueDetailListener) + */ + public void computeDetail(IValue value, IValueDetailListener listener) { + String detail = ""; + try { + detail = value.getValueString(); + } catch (DebugException e) { + } + listener.detailComputed(value, detail); + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object) + */ + public IEditorInput getEditorInput(Object element) { + if (element instanceof IFile) { + return new FileEditorInput((IFile)element); + } + if (element instanceof ILineBreakpoint) { + return new FileEditorInput((IFile)((ILineBreakpoint)element).getMarker().getResource()); + } + return null; + } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(org.eclipse.ui.IEditorInput, java.lang.Object) + */ + public String getEditorId(IEditorInput input, Object element) { + if (element instanceof IFile || element instanceof ILineBreakpoint) { + return "org.eclipse.ui.DefaultTextEditor"; + } + return null; + } +} diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugTabGroup.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugTabGroup.java new file mode 100644 index 0000000..f3c10b6 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugTabGroup.java @@ -0,0 +1,32 @@ +/* + * Created on 25.11.2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package net.sourceforge.phpeclipse.xdebug.ui; + +import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; +import org.eclipse.debug.ui.CommonTab; +import org.eclipse.debug.ui.ILaunchConfigurationDialog; +import org.eclipse.debug.ui.ILaunchConfigurationTab; +import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; + +/** + * @author Axel + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class XDebugTabGroup extends AbstractLaunchConfigurationTabGroup { + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String) + */ + public void createTabs(ILaunchConfigurationDialog dialog, String mode) { + setTabs(new ILaunchConfigurationTab[] { + new XDebugMainTab(), + new SourceLookupTab(), + new CommonTab() + }); + } +}