From 66c2ac63969a77f4e7393319fcc412be5a82b648 Mon Sep 17 00:00:00 2001 From: incastrix Date: Wed, 28 Jan 2009 15:35:43 +0000 Subject: [PATCH] Fix variable view value modification and refactored XDebugAbstractValue and derived classes. --- .../xdebug/php/model/XDebugAbstractValue.java | 78 ++++++-------------- .../xdebug/php/model/XDebugArrayValue.java | 36 +++++++-- .../xdebug/php/model/XDebugBooleanValue.java | 47 +++++++----- .../xdebug/php/model/XDebugFloatValue.java | 23 +++++- .../xdebug/php/model/XDebugIntValue.java | 27 +++++-- .../xdebug/php/model/XDebugObjectValue.java | 32 +++++++-- .../xdebug/php/model/XDebugResourceValue.java | 10 +-- .../xdebug/php/model/XDebugStringValue.java | 15 +++- .../phpeclipse/xdebug/php/model/XDebugValue.java | 8 +-- .../xdebug/php/model/XDebugVariable.java | 6 +- 10 files changed, 157 insertions(+), 125 deletions(-) diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java index 32ea3fa..eb91e5b 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java @@ -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 @@ import org.w3c.dom.NodeList; * 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(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 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 diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java index 7a1dbad..6174c3e 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java @@ -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=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 diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugFloatValue.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugFloatValue.java index 990e371..fd2e709 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugFloatValue.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugFloatValue.java @@ -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) { diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugIntValue.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugIntValue.java index f45eaa8..010c2a9 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugIntValue.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugIntValue.java @@ -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 @@ public class XDebugIntValue extends XDebugAbstractValue { } return true; } + + public boolean verifyValue(String expression) { + return isValid(expression); + } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java index 01fabba..1af871a 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java @@ -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