Search in sources :

Example 1 with VariableValuePair

use of org.absmodels.abs.plugin.debug.model.VariableValuePair in project abstools by abstools.

the class VariableContentProvider method getChildren.

@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement != null) {
        if (parentElement instanceof TaskStackFrameView) {
            TaskStackFrameView stackFrame = (TaskStackFrameView) parentElement;
            ArrayList<VariableValuePair> children = new ArrayList<VariableValuePair>();
            for (String variableName : stackFrame.getVariableNames()) {
                children.add(new VariableValuePair(variableName, stackFrame.getValue(variableName)));
            }
            return children.toArray();
        } else if (parentElement instanceof ObjectView) {
            ObjectView obj = (ObjectView) parentElement;
            ArrayList<VariableValuePair> children = new ArrayList<VariableValuePair>();
            for (String fieldName : obj.getFieldNames()) {
                try {
                    children.add(new VariableValuePair(fieldName, obj.getFieldValue(fieldName)));
                } catch (NoSuchFieldException e) {
                // can never happen. Since we iterate over the field names, the field is guaranteed
                // to exist as long as the objectView is implemented correctly.
                }
            }
            return children.toArray();
        } else if (parentElement instanceof VariableValuePair) {
            return getChildren(((VariableValuePair) parentElement).getValue());
        } else if (parentElement instanceof ABSObject) {
            return getChildren(((ABSObject) parentElement).getView());
        }
    }
    // single (or unknown) value - no children
    return new Object[0];
}
Also used : VariableValuePair(org.absmodels.abs.plugin.debug.model.VariableValuePair) ArrayList(java.util.ArrayList) ABSObject(abs.backend.java.lib.runtime.ABSObject) ABSObject(abs.backend.java.lib.runtime.ABSObject) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView) ObjectView(abs.backend.java.observing.ObjectView)

Aggregations

ABSObject (abs.backend.java.lib.runtime.ABSObject)1 ObjectView (abs.backend.java.observing.ObjectView)1 TaskStackFrameView (abs.backend.java.observing.TaskStackFrameView)1 ArrayList (java.util.ArrayList)1 VariableValuePair (org.absmodels.abs.plugin.debug.model.VariableValuePair)1