Initial implementation of the new Debug Plugin
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.ui / src / net / sourceforge / phpeclipse / xdebug / ui / php / launching / PHPDebugModelPresentation.java
1 package net.sourceforge.phpeclipse.xdebug.ui.php.launching;
2
3
4
5 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugLineBreakpoint;
6 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame;
7 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
8 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugThread;
9 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugValue;
10 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugVariable;
11
12 import org.eclipse.core.resources.IFile;
13 import org.eclipse.core.resources.IMarker;
14 import org.eclipse.debug.core.model.ILineBreakpoint;
15 import org.eclipse.debug.core.model.IValue;
16 import org.eclipse.debug.ui.DebugUITools;
17 import org.eclipse.debug.ui.IDebugModelPresentation;
18 import org.eclipse.debug.ui.IDebugUIConstants;
19 import org.eclipse.debug.ui.IValueDetailListener;
20 import org.eclipse.jface.viewers.ILabelProviderListener;
21 import org.eclipse.swt.graphics.Image;
22 import org.eclipse.ui.IEditorDescriptor;
23 import org.eclipse.ui.IEditorInput;
24 import org.eclipse.ui.IEditorRegistry;
25 import org.eclipse.ui.PlatformUI;
26 import org.eclipse.ui.part.FileEditorInput;
27
28 public class PHPDebugModelPresentation implements IDebugModelPresentation {
29
30         public void setAttribute(String attribute, Object value) {
31                 // TODO Auto-generated method stub
32
33         }
34
35         /**
36          * @see IDebugModelPresentation#getImage(Object)
37          */
38         public Image getImage(Object element) {
39                 if (element instanceof XDebugLineBreakpoint) {
40                         return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
41                 } else if (element instanceof IMarker) {
42                         return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
43                 } else if (element instanceof XDebugStackFrame || element instanceof XDebugThread || element instanceof XDebugTarget) {
44                         return null;
45                 } else if (element instanceof XDebugVariable) {
46                         return getVariableImage((XDebugVariable)element);
47                 } else if (element instanceof XDebugValue) {
48                         return getValueImage((XDebugValue)element);
49                 }
50                 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
51         }
52         private Image getVariableImage(XDebugVariable phpVar) {
53                 /*              if (phpVar != null) {
54                  if (phpVar.isLocal())
55                  return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
56                  if (phpVar.isHashValue())
57                  return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
58                  }
59                  */
60                 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
61         }
62         
63         private Image getValueImage(XDebugValue phpVar) {
64                 if (phpVar != null) {
65                         return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
66                 }
67                 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
68         }
69
70
71         public String getText(Object element) {
72                 // TODO Auto-generated method stub
73                 return null;
74         }
75
76         public void computeDetail(IValue value, IValueDetailListener listener) {
77                 // TODO Auto-generated method stub
78
79         }
80
81         public void addListener(ILabelProviderListener listener) {
82                 // TODO Auto-generated method stub
83
84         }
85
86         public void dispose() {
87                 // TODO Auto-generated method stub
88
89         }
90
91         public boolean isLabelProperty(Object element, String property) {
92                 // TODO Auto-generated method stub
93                 return false;
94         }
95
96         public void removeListener(ILabelProviderListener listener) {
97                 // TODO Auto-generated method stub
98
99         }
100
101         public IEditorInput getEditorInput(Object element) {
102
103                 if (element instanceof IFile) {
104                         return new FileEditorInput((IFile)element);
105                 }
106                 if (element instanceof ILineBreakpoint) {
107                         return new FileEditorInput((IFile)((ILineBreakpoint)element).getMarker().getResource());
108                 }
109                 return null;
110         }
111
112         public String getEditorId(IEditorInput input, Object element) {
113                 IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
114                 IEditorDescriptor descriptor= registry.getDefaultEditor(input.getName());
115                 if (descriptor != null)
116                         return descriptor.getId();
117                 
118                 return null;
119         }
120
121 }