package org.ntlab.traceanalyzer;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class CallTreeContentProvider implements ITreeContentProvider {

	public Object[] getChildren(Object parentElement) {
		Object[] children = null;
		if (parentElement instanceof MarkedThread) {
			children = ((MarkedThread)parentElement).getChildren().toArray();
		} else {
			children = ((MarkedMethodExecution)parentElement).getChildren().toArray();
		}
		return children==null ? new Object[0] : children;
	}   

	public Object getParent(Object element) {
		return ((MarkedMethodExecution)element).getParent();
	}   

	public boolean hasChildren(Object element) {
	    return getChildren(element).length == 0 ? false : true;
	}   

	public Object[] getElements(Object inputElement) {
	    return ((MarkedTrace)inputElement).getMarkedThreads().toArray();
	}   

	public void dispose() {
	}

	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
	}
}
