dedaaad76de3e4e6b6c1b226aed146a91d8ce055
[phpeclipse.git] /
1 package net.sourceforge.phpeclipse.xdebug.ui.php.launching;
2
3
4
5 import java.io.File;
6
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;
13
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;
35
36 public class CopyOfPHPDebugModelPresentation implements IDebugModelPresentation {
37         
38     class StorageEditorInput extends PlatformObject implements
39                         IStorageEditorInput {
40                 private File fFile;
41
42                 private IStorage fStorage;
43
44                 public StorageEditorInput(IStorage storage, File file) {
45                         super();
46                         fStorage = storage;
47                         fFile = file;
48                 }
49
50                 public IStorage getStorage() {
51                         return fStorage;
52                 }
53
54                 public ImageDescriptor getImageDescriptor() {
55                         return null;
56                 }
57
58                 public String getName() {
59                         return getStorage().getName();
60                 }
61
62                 public IPersistableElement getPersistable() {
63                         return null;
64                 }
65
66                 public String getToolTipText() {
67                         return getStorage().getFullPath().toOSString();
68                 }
69
70                 public boolean equals(Object object) {
71                         return object instanceof StorageEditorInput
72                                         && getStorage().equals(
73                                                         ((StorageEditorInput) object).getStorage());
74                 }
75
76                 public int hashCode() {
77                         return getStorage().hashCode();
78                 }
79
80                 public boolean exists() {
81                         return fFile.exists();
82                 }
83         }
84
85
86         public void setAttribute(String attribute, Object value) {
87                 // TODO Auto-generated method stub
88
89         }
90
91         /**
92          * @see IDebugModelPresentation#getImage(Object)
93          */
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) {
100                         return null;
101                 } else if (element instanceof XDebugVariable) {
102                         return getVariableImage((XDebugVariable)element);
103                 } else if (element instanceof XDebugValue) {
104                         return getValueImage((XDebugValue)element);
105                 }
106                 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
107         }
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);
114                  }
115                  */
116                 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
117         }
118         
119         private Image getValueImage(XDebugValue phpVar) {
120                 if (phpVar != null) {
121                         return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
122                 }
123                 return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
124         }
125
126
127         public String getText(Object element) {
128                 // TODO Auto-generated method stub
129                 return null;
130         }
131
132         public void computeDetail(IValue value, IValueDetailListener listener) {
133                 // TODO Auto-generated method stub
134
135         }
136
137         public void addListener(ILabelProviderListener listener) {
138                 // TODO Auto-generated method stub
139
140         }
141
142         public void dispose() {
143                 // TODO Auto-generated method stub
144
145         }
146
147         public boolean isLabelProperty(Object element, String property) {
148                 // TODO Auto-generated method stub
149                 return false;
150         }
151
152         public void removeListener(ILabelProviderListener listener) {
153                 // TODO Auto-generated method stub
154
155         }
156
157         public IEditorInput getEditorInput(Object element) {
158
159                 if (element instanceof IFile) {
160                         return new FileEditorInput((IFile)element);
161                 }
162                 if( element instanceof LocalFileStorage) {
163                         LocalFileStorage lfc= (LocalFileStorage)element;
164                         return new StorageEditorInput(lfc,lfc.getFile());
165                 }
166                 if (element instanceof ILineBreakpoint) {
167                         return new FileEditorInput((IFile)((ILineBreakpoint)element).getMarker().getResource());
168                 }
169                 return null;
170         }
171
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();
177                 
178                 return null;
179         }
180
181 }