1) Added missing strings for italic, underline and strike through.
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.ui / src / net / sourceforge / phpeclipse / xdebug / ui / php / launching / PHPDebugModelPresentation.java
index 6a1dfbb..75baa34 100644 (file)
@@ -11,6 +11,7 @@
  **********************************************************************/
 package net.sourceforge.phpeclipse.xdebug.ui.php.launching;
 
+import java.io.File;
 import java.util.HashMap;
 
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugLineBreakpoint;
@@ -20,7 +21,9 @@ import net.sourceforge.phpeclipse.xdebug.php.model.XDebugThread;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugVariable;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugValue;
-import net.sourceforge.phpeclipse.xdebug.ui.XDebugUIPlugin;
+import net.sourceforge.phpeclipse.xdebug.ui.XDebugUIPluginImages;
+//import net.sourceforge.phpeclipse.xdebug.ui.XDebugUIPlugin;
+//import net.sourceforge.phpeclipse.xdebug.ui.php.launching.CopyOfPHPDebugModelPresentation.StorageEditorInput;
 
 //import net.sourceforge.phpdt.internal.debug.core.model.IPHPDebugTarget;
 
@@ -30,19 +33,27 @@ import net.sourceforge.phpeclipse.xdebug.ui.XDebugUIPlugin;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IStorage;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.ILineBreakpoint;
 import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
 import org.eclipse.debug.ui.DebugUITools;
 import org.eclipse.debug.ui.IDebugModelPresentation;
 import org.eclipse.debug.ui.IDebugUIConstants;
 import org.eclipse.debug.ui.IValueDetailListener;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.IEditorDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorRegistry;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IStorageEditorInput;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.FileEditorInput;
 
@@ -85,24 +96,21 @@ public class PHPDebugModelPresentation extends LabelProvider implements
        /**
         * @see IDebugModelPresentation#getEditorInput(Object)
         */
-       public IEditorInput getEditorInput(Object item) {
-
-               if (item instanceof XDebugLineBreakpoint) {
-                       IBreakpoint bp = (IBreakpoint) item;
-                       IMarker ma = bp.getMarker();
-                       //IFile eclipseFile = PHPDebugUiPlugin.getWorkspace().getRoot()
-                       //              .getFileForLocation(ma.getResource().getLocation());
-                       
-                       IFile eclipseFile = null; //XDebugUIPlugin.getWorkspace().getRoot()
-                                       //.getFile(ma.getResource().getFullPath());
-                       if (eclipseFile == null) {
-                               return null;
-                       }
-                       return new FileEditorInput(eclipseFile);
+       public IEditorInput getEditorInput(Object element) {
+
+               if (element instanceof IFile) {
+                       return new FileEditorInput((IFile)element);
+               }
+               if( element instanceof LocalFileStorage) {
+                       LocalFileStorage lfc= (LocalFileStorage)element;
+                       return new StorageEditorInput(lfc,lfc.getFile());
+               }
+               if (element instanceof ILineBreakpoint) {
+                       return new FileEditorInput((IFile)((ILineBreakpoint)element).getMarker().getResource());
                }
                return null;
        }
-
+       
        /**
         * @see IDebugModelPresentation#getImage(Object)
         */
@@ -110,7 +118,11 @@ public class PHPDebugModelPresentation extends LabelProvider implements
                if (element instanceof XDebugLineBreakpoint) {
                        return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
                } else if (element instanceof IMarker) {
-                       return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
+                       if (((IMarker) element).getAttribute(IBreakpoint.ENABLED, false)) {
+                               return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT);
+                       } else {
+                               return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED);                           
+                       }
                } else if (element instanceof XDebugStackFrame
                                || element instanceof XDebugThread
                                || element instanceof XDebugTarget) {
@@ -124,15 +136,14 @@ public class PHPDebugModelPresentation extends LabelProvider implements
        }
 
        private Image getVariableImage(XDebugVariable phpVar) {
-               /*
-                * if (phpVar != null) { if (phpVar.isLocal()) return
-                * DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE); if
-                * (phpVar.isHashValue()) return
-                * DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE); }
-                */
-               return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
-       }
+               if (phpVar.getVisibility().equals("protected")) {
+                       return XDebugUIPluginImages.get(XDebugUIPluginImages.IMG_FIELD_PROTECTED);                      
+               }  else if (phpVar.getVisibility().equals("private")) {
+                       return (XDebugUIPluginImages.get(XDebugUIPluginImages.IMG_FIELD_PRIVATE));                      
+               }
 
+               return XDebugUIPluginImages.get(XDebugUIPluginImages.IMG_FIELD_PUBLIC);                 
+       }
        private Image getValueImage(XDebugValue phpVar) {
                if (phpVar != null) {
                        return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE);
@@ -149,7 +160,7 @@ public class PHPDebugModelPresentation extends LabelProvider implements
                                return getBreakpointText((IBreakpoint) element);
                        } else if (element instanceof XDebugVariable) {
                                XDebugVariable phpVar = (XDebugVariable) element;
-                               return phpVar.toString();
+                               return phpVar.getName() + "= " + phpVar.getValueString();//toString();
                        }
                } catch (CoreException e) {
                        //return PHPDebugUiMessages
@@ -162,7 +173,13 @@ public class PHPDebugModelPresentation extends LabelProvider implements
         * @see IDebugModelPresentation#computeDetail(IValue, IValueDetailListener)
         */
        public void computeDetail(IValue value, IValueDetailListener listener) {
-               return;
+               String detail = "";
+               try {
+                       detail = value.getValueString();
+               } catch (DebugException e) {
+               }
+               listener.detailComputed(value, detail);
+               //return;
        }
 
        protected IBreakpoint getBreakpoint(IMarker marker) {
@@ -236,4 +253,51 @@ public class PHPDebugModelPresentation extends LabelProvider implements
                }
                return image;
        }
+
+    class StorageEditorInput extends PlatformObject implements
+       IStorageEditorInput {
+private File fFile;
+
+private IStorage fStorage;
+
+public StorageEditorInput(IStorage storage, File file) {
+       super();
+       fStorage = storage;
+       fFile = file;
+}
+
+public IStorage getStorage() {
+       return fStorage;
+}
+
+public ImageDescriptor getImageDescriptor() {
+       return null;
+}
+
+public String getName() {
+       return getStorage().getName();
+}
+
+public IPersistableElement getPersistable() {
+       return null;
+}
+
+public String getToolTipText() {
+       return getStorage().getFullPath().toOSString();
+}
+
+public boolean equals(Object object) {
+       return object instanceof StorageEditorInput
+                       && getStorage().equals(
+                                       ((StorageEditorInput) object).getStorage());
+}
+
+public int hashCode() {
+       return getStorage().hashCode();
+}
+
+public boolean exists() {
+       return fFile.exists();
+}
+}
 }
\ No newline at end of file