Enable first implementation of value change in varialbles view.
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugAbstractValue.java
index a3c7cdd..b52ea6f 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Created on 23.11.2004
+ /* Created on 23.11.2004
  *
  * TODO To change the template for this generated file go to
  * Window - Preferences - Java - Code Style - Code Templates
@@ -9,6 +8,7 @@ package net.sourceforge.phpeclipse.xdebug.php.model;
 import net.sourceforge.phpeclipse.xdebug.core.Base64;
 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
 
+import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.model.IValue;
 import org.eclipse.debug.core.model.IVariable;
@@ -17,158 +17,113 @@ import org.w3c.dom.NodeList;
 
 /**
  * @author Axel
- * 
- * TODO To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Style - Code Templates
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
  */
-public abstract class XDebugAbstractValue extends XDebugElement implements
-               IValue {
-
-       public static final int VALUETYPE_UNKNOWN = -1;
-
-       public static final int VALUETYPE_UNINITIALIZED = 0;
-
-       public static final int VALUETYPE_STRING = 1;
-
-       public static final int VALUETYPE_INT = 4;
-
-       public static final int VALUETYPE_FLOAT = 5;
-
-       public static final int VALUETYPE_BOOLEAN = 6;
-
-       public static final int VALUETYPE_ARRAY = 8;
-
-       public static final int VALUETYPE_HASH = 9;
-
-       public static final int VALUETYPE_OBJECT = 10;
-
-       protected XDebugVariable fVariable;
-
+public abstract class XDebugAbstractValue  extends XDebugElement implements IValue {
        private IVariable[] fVariables;
-
        protected String fValueString;
+       protected String fTypeName;
+       private boolean fhasChanged;
 
-       protected int fType;
+       public XDebugAbstractValue(XDebugStackFrame frame, Node varNode)  {
+               super((XDebugTarget) frame.getDebugTarget());
 
-       protected String fTypeName;
+               fTypeName = PHPDebugUtils.getAttributeValue(varNode,"type");
 
-       public XDebugAbstractValue(XDebugVariable variable, Node varNode,
-                       String typeName) {
-               super((XDebugTarget) variable.getDebugTarget());
-               fVariable = variable;
-               if (varNode == null) {
-                       try {
-                               System.out.println(variable.getName() + "=null");
-                       } catch (DebugException e) {
-                               // TODO Auto-generated catch block
-                               e.printStackTrace();
-                       }
-                       return;
-               }
-               setType(typeName);
-               NodeList property = varNode.getChildNodes();
-               if (variable.hasChildren()) {
-                       renderValueString("" + property.getLength());
+               int NumChildren = 0;
+               if (!PHPDebugUtils.getAttributeValue(varNode,"numchildren").equals("")) {
+                       NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(varNode, "numchildren"));
+               }               
+
+               if (NumChildren > 0) {
+                       NodeList property = varNode.getChildNodes();
+                       renderValueString(""+property.getLength());
                        fVariables = new IVariable[property.getLength()];
-                       for (int i = 0; i < property.getLength(); i++) {
+                       for (int i = 0; i<property.getLength(); i++) {
                                Node propertyNode = property.item(i);
-                               fVariables[i] = new XDebugVariable(variable.getStackFrame(),
-                                               propertyNode);
+                               fVariables[i] = new XDebugVariable(frame, propertyNode);
                        }
-               } else {
-                       // fDataString="";
+               }else {
                        fVariables = new IVariable[0];
-                       // if (variable.getType()== XDebugVariable.VARTYPE_UNINITIALIZED)
-                       // fValueString="uninitialized";
-                       // else {
-                       String str = "";
+                       String str="";
                        try {
-                               str = varNode.getFirstChild().getNodeValue();
+                               str=varNode.getFirstChild().getNodeValue();
                        } catch (NullPointerException e) {
-                               str = "";
+                               str="";
                        }
-                       if (variable.getEncoding().equals("base64")) {
-                               if (str.length() != 0)
-                                       str = new String(Base64.decode(str));
+
+                       String Encoding = PHPDebugUtils.getAttributeValue(varNode,"encoding");
+                       
+                       if (Encoding.equals("base64")) {
+                               if (str.length()!=0)
+                                       str=new String(Base64.decode(str));
                                else
-                                       str = "";
+                                       str="";
                        }
                        renderValueString(str);
-                       // }
                }
-               String className = PHPDebugUtils
-                               .getAttributeValue(varNode, "classname");
-               if (className != "")
+               String className=PHPDebugUtils.getAttributeValue(varNode,"classname");
+               if(!"".equals(className))
                        renderValueString(className);
-
        }
-
-       /*
-        * (non-Javadoc)
-        * 
+       
+       public boolean hasChanged() {
+               return fhasChanged;
+       }
+       
+       /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
         */
        public String getReferenceTypeName() throws DebugException {
                return fTypeName;
        }
-
-       /*
-        * (non-Javadoc)
-        * 
+       
+       /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IValue#getValueString()
         */
        public String getValueString() throws DebugException {
                return fValueString;
        }
-
-       /*
-        * (non-Javadoc)
-        * 
+       
+       /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IValue#isAllocated()
         */
        public boolean isAllocated() throws DebugException {
                return true;
        }
-
-       /*
-        * (non-Javadoc)
-        * 
+       
+       /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IValue#getVariables()
         */
        public IVariable[] getVariables() throws DebugException {
                return fVariables;
        }
-
-       /*
-        * (non-Javadoc)
-        * 
+       
+       /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IValue#hasVariables()
         */
        public boolean hasVariables() throws DebugException {
                return (fVariables.length > 0);
        }
-
-       public boolean isArray() {
-               return ((fType & VALUETYPE_ARRAY) > 0);
-       }
-
-       public abstract void setType(String typeName);
-
+       
        public abstract void renderValueString(String data);
 
        public abstract boolean verifyValue(String expression);
-
+       
        public boolean setValue(String expression) {
-               if (!verifyValue(expression))
+               if (!verifyValue(expression)) {
                        return false;
-               if (fTarget.setVarValue(fVariable.getFullName(), expression)) {
-                       renderValueString(expression);
-                       return true;
                }
-               return false;
+               
+               renderValueString(expression);
+               fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
+        
+               return true;
        }
-
+       
        public boolean supportsValueModification() {
                return false;
        }
-}
+}
\ No newline at end of file