From: <ed...@ed...> - 2009-01-28 15:36:09
|
Author: incastrix Date: 2009-01-28 09:35:43 -0600 (Wed, 28 Jan 2009) New Revision: 1637 Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugBooleanValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugFloatValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugIntValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugResourceValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStringValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugValue.java trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java Log: Fix variable view value modification and refactored XDebugAbstractValue and derived classes. Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -5,15 +5,12 @@ */ 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; import org.w3c.dom.Node; -import org.w3c.dom.NodeList; /** * @author Axel @@ -22,52 +19,26 @@ * Window - Preferences - Java - Code Style - Code Templates */ -public abstract class XDebugAbstractValue extends XDebugElement implements IValue { +public /*abstract*/ class XDebugAbstractValue extends XDebugElement implements IValue { private IVariable[] fVariables; private String fValueString; private String fTypeName; private boolean fhasChanged; + protected String rowValue; + + public XDebugAbstractValue(XDebugStackFrame frame, Node value) throws DebugException { + super(frame == null ? null : (XDebugTarget)frame.getDebugTarget()); - public XDebugAbstractValue(XDebugStackFrame frame, Node varNode) throws DebugException { - super(frame == null ? null : (XDebugTarget) frame.getDebugTarget()); + fTypeName = PHPDebugUtils.getAttributeValue(value, "type"); + + fVariables = new IVariable[0]; - fTypeName = PHPDebugUtils.getAttributeValue(varNode,"type"); - - 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++) { - Node propertyNode = property.item(i); - fVariables[i] = new XDebugVariable(frame, propertyNode); - } - }else { - fVariables = new IVariable[0]; - String str=""; - try { - str=varNode.getFirstChild().getNodeValue(); - } catch (NullPointerException e) { - str=""; - } - - String Encoding = PHPDebugUtils.getAttributeValue(varNode,"encoding"); - - if (Encoding.equals("base64")) { - if (str.length()!=0) - str=new String(Base64.decode(str)); - else - str=""; - } - renderValueString(str); + rowValue = ""; + try { + rowValue = value.getFirstChild().getNodeValue(); + } catch (NullPointerException e) { + rowValue = ""; } - String className=PHPDebugUtils.getAttributeValue(varNode,"classname"); - if(!"".equals(className)) - renderValueString(className); } public boolean hasChanged() { @@ -109,26 +80,23 @@ return (fVariables.length > 0); } - public abstract void renderValueString(String data) throws DebugException; - - public abstract boolean verifyValue(String expression); - public boolean setValue(String expression) throws DebugException { - if (!verifyValue(expression)) { - return false; - } - - renderValueString(expression); - fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT)); - return true; + }; + + protected boolean verifyValue(String expression) { + return true; } - public boolean supportsValueModification() { + protected boolean supportsValueModification() { return false; } - public void setValueString(String valueString) { + protected void setValueString(String valueString) { fValueString = valueString; } + + protected void setChildren(IVariable[] newChildren) { + fVariables = newChildren; + } } \ No newline at end of file Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -1,26 +1,46 @@ package net.sourceforge.phpeclipse.xdebug.php.model; +import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils; + import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IVariable; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; public class XDebugArrayValue extends XDebugAbstractValue { + private int NumChildren; + public XDebugArrayValue(XDebugStackFrame variable, Node value) throws DebugException { super(variable, value); + + NumChildren = 0; + if (!PHPDebugUtils.getAttributeValue(value, "numchildren").equals("")) { + NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(value, "numchildren")); + } + + if (NumChildren > 0) { + NodeList property = value.getChildNodes(); + renderValueString(""+property.getLength()); + IVariable[] Variables = new IVariable[property.getLength()]; + + for (int i = 0; i<property.getLength(); i++) { + Node propertyNode = property.item(i); + Variables[i] = new XDebugVariable(variable, propertyNode); + } + + setChildren(Variables); + } } - public void renderValueString(String data) throws DebugException { + private void renderValueString(String data) throws DebugException { if (data.equals("")) { - setValueString("empty")/*fValueString = "empty"*/; + setValueString("empty"); } else { if ("array".equals(getReferenceTypeName())) { - setValueString("array")/*fValueString = "array"*/; + setValueString("array(" + NumChildren + ")"); } else { - setValueString(data)/*fValueString = data*/; + setValueString(data); } } } - - public boolean verifyValue(String expression) { - return false; - } } \ No newline at end of file Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugBooleanValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugBooleanValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugBooleanValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -1,49 +1,54 @@ package net.sourceforge.phpeclipse.xdebug.php.model; +import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.w3c.dom.Node; public class XDebugBooleanValue extends XDebugAbstractValue { public XDebugBooleanValue(XDebugStackFrame variable, Node value) throws DebugException { super(variable, value); + + renderValueString(rowValue); } public boolean supportsValueModification() { return true; } - public void renderValueString(String data) { - int value=-1; - try { - value=Integer.parseInt(data); - } catch (NumberFormatException e) { - data=data.toLowerCase(); - if (data.equals("true") || data.equals("false")) - setValueString(data)/*fValueString=data*/; - else - setValueString("not defined")/*fValueString="not defined"*/; + public boolean setValue(String expression) throws DebugException { + if (isValid(expression)) { + renderValueString(expression); + fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT)); + return true; } - if (value==0) - setValueString("false")/*fValueString="false"*/; - else if (value==1) - setValueString("false")/*fValueString="true"*/; - else - setValueString("not defined")/*fValueString="not defined"*/; + return false; } - public boolean verifyValue(String expression) { - int value=-1; + private void renderValueString(String data) { + if (data.equals("0") || data.toLowerCase().equals("false")) { + setValueString("false"); + } else if (data.equals("1") || data.toLowerCase().equals("true")) { + setValueString("true"); + } + } + + private boolean isValid(String expression) { + int value = -1; try { - value=Integer.parseInt(expression); + value = Integer.parseInt(expression); } catch (NumberFormatException e) { - expression=expression.toLowerCase(); + expression = expression.toLowerCase(); if (expression.equals("true") || expression.equals("false")) return true; else return false; } - if ((value>=0)&& (value <=1)) + if ((value >= 0)&& (value <= 1)) return true; return false; } + + public boolean verifyValue(String expression) { + return isValid(expression); + } } \ No newline at end of file Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugFloatValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugFloatValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugFloatValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -1,22 +1,37 @@ package net.sourceforge.phpeclipse.xdebug.php.model; +import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.w3c.dom.Node; public class XDebugFloatValue extends XDebugAbstractValue { - public XDebugFloatValue(XDebugStackFrame variable, Node value) throws DebugException { - super(variable, value); + public XDebugFloatValue(XDebugStackFrame stackFrame, Node value) throws DebugException { + super(stackFrame, value); + + if (isValid(rowValue)) { + setValueString(rowValue); + } } public boolean supportsValueModification() { return true; } - public void renderValueString(String data) { - setValueString(data)/*fValueString = data*/; + public boolean setValue(String expression) throws DebugException { + if (isValid(expression)) { + setValueString(expression); + fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT)); + return true; + } + + return false; } public boolean verifyValue(String expression) { + return isValid(expression); + } + + private boolean isValid(String expression) { try { Float.parseFloat(expression); } catch (NumberFormatException e) { Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugIntValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugIntValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugIntValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -1,22 +1,33 @@ package net.sourceforge.phpeclipse.xdebug.php.model; +import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.w3c.dom.Node; public class XDebugIntValue extends XDebugAbstractValue { - public XDebugIntValue(XDebugStackFrame frame, Node value) throws DebugException { - super(frame, value); + public XDebugIntValue(XDebugStackFrame stackFrame, Node value) throws DebugException { + super(stackFrame, value); + + if (isValid(rowValue)) { + setValueString(rowValue); + } } public boolean supportsValueModification() { return true; } - public void renderValueString(String dataString) { - setValueString(dataString)/*fValueString = dataString*/; + public boolean setValue(String expression) throws DebugException { + if (isValid(expression)) { + setValueString(expression); + fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT)); + return true; + } + + return false; } - - public boolean verifyValue(String expression) { + + private boolean isValid(String expression) { try { Integer.parseInt(expression); } catch (NumberFormatException e) { @@ -24,4 +35,8 @@ } return true; } + + public boolean verifyValue(String expression) { + return isValid(expression); + } } \ No newline at end of file Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -1,18 +1,38 @@ package net.sourceforge.phpeclipse.xdebug.php.model; +import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils; + import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IVariable; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; public class XDebugObjectValue extends XDebugAbstractValue { + private int NumChildren; + public XDebugObjectValue(XDebugStackFrame variable, Node value) throws DebugException { super(variable, value); - } - public void renderValueString(String data) { - setValueString(data)/*fValueString = data*/; - } + NumChildren = 0; + if (!PHPDebugUtils.getAttributeValue(value, "numchildren").equals("")) { + NumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(value, "numchildren")); + } - public boolean verifyValue(String expression) { - return false; + if (NumChildren > 0) { + NodeList property = value.getChildNodes(); + IVariable[] Variables = new IVariable[property.getLength()]; + + for (int i = 0; i<property.getLength(); i++) { + Node propertyNode = property.item(i); + Variables[i] = new XDebugVariable(variable, propertyNode); + } + + setChildren(Variables); + } + + String className = PHPDebugUtils.getAttributeValue(value,"classname"); + if(!"".equals(className)) { + setValueString(className); + } } } \ No newline at end of file Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugResourceValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugResourceValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugResourceValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -9,14 +9,6 @@ } public void renderValueString(String data) { - setValueString("\"" + data + "\"")/*fValueString = "\"" + data + "\""*/; + setValueString("\"" + data + "\""); } - - public boolean supportsValueModification() { - return true; - } - - public boolean verifyValue(String expression) { - return true; - } } \ No newline at end of file Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStringValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStringValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStringValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -1,22 +1,27 @@ package net.sourceforge.phpeclipse.xdebug.php.model; +import net.sourceforge.phpeclipse.xdebug.core.Base64; + +import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.w3c.dom.Node; public class XDebugStringValue extends XDebugAbstractValue { public XDebugStringValue(XDebugStackFrame variable, Node value) throws DebugException { super(variable, value); - } - public void renderValueString(String data) { - setValueString("\"" + data + "\"")/*fValueString = "\"" + data + "\""*/; + rowValue = new String(Base64.decode(rowValue)); + + setValueString(rowValue); } - public boolean supportsValueModification() { + public boolean setValue(String expression) throws DebugException { + setValueString(expression); + fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT)); return true; } - public boolean verifyValue(String expression) { + public boolean supportsValueModification() { return true; } } \ No newline at end of file Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugValue.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugValue.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugValue.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -6,13 +6,7 @@ public class XDebugValue extends XDebugAbstractValue { public XDebugValue(XDebugStackFrame variable, Node value) throws DebugException { super(variable, value); - } - - public void renderValueString(String data) { - setValueString("uninitialized")/*fValueString = "uninitialized"*/; - } - public boolean verifyValue(String expression) { - return false; + setValueString("uninitialized"); } } \ No newline at end of file Modified: trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java =================================================================== --- trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java 2008-12-25 04:10:56 UTC (rev 1636) +++ trunk/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java 2009-01-28 15:35:43 UTC (rev 1637) @@ -57,10 +57,8 @@ fValue = new XDebugStringValue(frame, property); else if (typeName.equals("array") ) fValue = new XDebugArrayValue(frame, property); - else if (typeName.equals("hash") ) - fValue = new XDebugArrayValue(frame, property); else if (typeName.equals("object") ) - fValue = new XDebugArrayValue(frame, property); + fValue = new XDebugObjectValue(frame, property); else if (typeName.equals("resource") ) fValue = new XDebugResourceValue(frame, property); else @@ -121,7 +119,7 @@ * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String) */ public boolean verifyValue(String expression) throws DebugException { - return fValue.verifyValue(expression); + /*return true; */return fValue.verifyValue(expression); } /* (non-Javadoc) |