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