1 package net.sourceforge.phpeclipse.xdebug.ui.php.launching;
7 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugLineBreakpoint;
8 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame;
9 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
10 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugThread;
11 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugValue;
12 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugVariable;
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.core.resources.IMarker;
16 import org.eclipse.core.resources.IStorage;
17 import org.eclipse.core.runtime.PlatformObject;
18 import org.eclipse.debug.core.model.ILineBreakpoint;
19 import org.eclipse.debug.core.model.IValue;
20 import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
21 import org.eclipse.debug.ui.DebugUITools;
22 import org.eclipse.debug.ui.IDebugModelPresentation;
23 import org.eclipse.debug.ui.IDebugUIConstants;
24 import org.eclipse.debug.ui.IValueDetailListener;
25 import org.eclipse.jface.resource.ImageDescriptor;
26 import org.eclipse.jface.viewers.ILabelProviderListener;
27 import org.eclipse.swt.graphics.Image;
28 import org.eclipse.ui.IEditorDescriptor;
29 import org.eclipse.ui.IEditorInput;
30 import org.eclipse.ui.IEditorRegistry;
31 import org.eclipse.ui.IPersistableElement;
32 import org.eclipse.ui.IStorageEditorInput;
33 import org.eclipse.ui.PlatformUI;
34 import org.eclipse.ui.part.FileEditorInput;
36 public class PHPDebugModelPresentation implements IDebugModelPresentation {
38 class StorageEditorInput extends PlatformObject implements
42 private IStorage fStorage;
44 public StorageEditorInput(IStorage storage, File file) {
50 public IStorage getStorage() {
54 public ImageDescriptor getImageDescriptor() {
58 public String getName() {
59 return getStorage().getName();
62 public IPersistableElement getPersistable() {
66 public String getToolTipText() {
67 return getStorage().getFullPath().toOSString();
70 public boolean equals(Object object) {
71 return object instanceof StorageEditorInput
72 && getStorage().equals(
73 ((StorageEditorInput) object).getStorage());
76 public int hashCode() {
77 return getStorage().hashCode();
80 public boolean exists() {
81 return fFile.exists();
86 public void setAttribute(String attribute, Object value) {
87 // TODO Auto-generated method stub
92 * @see IDebugModelPresentation#getImage(Object)
94 public Image getImage(Object element) {
95 if (element instanceof XDebugLineBreakpoint) {
96 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
97 } else if (element instanceof IMarker) {
98 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
99 } else if (element instanceof XDebugStackFrame || element instanceof XDebugThread || element instanceof XDebugTarget) {
101 } else if (element instanceof XDebugVariable) {
102 return getVariableImage((XDebugVariable)element);
103 } else if (element instanceof XDebugValue) {
104 return getValueImage((XDebugValue)element);
106 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
108 private Image getVariableImage(XDebugVariable phpVar) {
109 /* if (phpVar != null) {
110 if (phpVar.isLocal())
111 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
112 if (phpVar.isHashValue())
113 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
116 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
119 private Image getValueImage(XDebugValue phpVar) {
120 if (phpVar != null) {
121 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
123 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
127 public String getText(Object element) {
128 // TODO Auto-generated method stub
132 public void computeDetail(IValue value, IValueDetailListener listener) {
133 // TODO Auto-generated method stub
137 public void addListener(ILabelProviderListener listener) {
138 // TODO Auto-generated method stub
142 public void dispose() {
143 // TODO Auto-generated method stub
147 public boolean isLabelProperty(Object element, String property) {
148 // TODO Auto-generated method stub
152 public void removeListener(ILabelProviderListener listener) {
153 // TODO Auto-generated method stub
157 public IEditorInput getEditorInput(Object element) {
159 if (element instanceof IFile) {
160 return new FileEditorInput((IFile)element);
162 if( element instanceof LocalFileStorage) {
163 LocalFileStorage lfc= (LocalFileStorage)element;
164 return new StorageEditorInput(lfc,lfc.getFile());
166 if (element instanceof ILineBreakpoint) {
167 return new FileEditorInput((IFile)((ILineBreakpoint)element).getMarker().getResource());
172 public String getEditorId(IEditorInput input, Object element) {
173 IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
174 IEditorDescriptor descriptor= registry.getDefaultEditor(input.getName());
175 if (descriptor != null)
176 return descriptor.getId();