Search in sources :

Example 6 with TaskStackFrameView

use of abs.backend.java.observing.TaskStackFrameView in project abstools by abstools.

the class DebugView method createViewer.

@Override
protected Viewer createViewer(Composite parent) {
    final TreeViewer viewer = new TreeViewer(parent);
    viewer.setContentProvider(new DebugTreeContentProvider());
    viewer.setLabelProvider(new DebugTreeStyledLabelProvider());
    viewer.setInput(debugger.getModel());
    viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            refreshButtonEnablement();
            Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (selection instanceof TaskView || selection instanceof ObjectView || selection instanceof TaskStackFrameView) {
                refreshVariableView();
                if (selection instanceof TaskView) {
                    TaskView tv = (TaskView) selection;
                    TaskInfo taskInfo = getDebugger().getModel().getTaskInfo(tv);
                    highlightLine(taskInfo);
                }
            }
            getSchedulerRef().taskSelectionChanged(selection);
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (selection instanceof ObjectView || selection instanceof TaskStackFrameView) {
                openVariableView();
                refreshVariableView();
            } else {
                viewer.setExpandedState(selection, !viewer.getExpandedState(selection));
            }
        }
    });
    viewer.expandAll();
    return viewer;
}
Also used : TaskView(abs.backend.java.observing.TaskView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ObjectView(abs.backend.java.observing.ObjectView) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView) TaskInfo(abs.backend.java.debugging.TaskInfo) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener)

Example 7 with TaskStackFrameView

use of abs.backend.java.observing.TaskStackFrameView 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

TaskStackFrameView (abs.backend.java.observing.TaskStackFrameView)7 TaskView (abs.backend.java.observing.TaskView)5 ObjectView (abs.backend.java.observing.ObjectView)3 ArrayList (java.util.ArrayList)3 DebugModel (abs.backend.java.debugging.DebugModel)2 COGView (abs.backend.java.observing.COGView)2 TaskStackView (abs.backend.java.observing.TaskStackView)2 Objects (org.absmodels.abs.plugin.debug.model.Objects)2 Tasks (org.absmodels.abs.plugin.debug.model.Tasks)2 TaskInfo (abs.backend.java.debugging.TaskInfo)1 ABSObject (abs.backend.java.lib.runtime.ABSObject)1 ABSValue (abs.backend.java.lib.types.ABSValue)1 MethodView (abs.backend.java.observing.MethodView)1 ScheduleAction (abs.backend.java.scheduling.ScheduleAction)1 ScheduleOptions (abs.backend.java.scheduling.ScheduleOptions)1 TaskInfo (abs.backend.java.scheduling.SimpleTaskScheduler.TaskInfo)1 TaskScheduler (abs.backend.java.scheduling.TaskScheduler)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 VariableValuePair (org.absmodels.abs.plugin.debug.model.VariableValuePair)1