/*******************************************************************************
* Copyright (c) 2009 the CHISEL group and contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Del Myers - initial API and implementation
*******************************************************************************/
package ca.uvic.chisel.javasketch.ui.internal.presentation;
import java.util.LinkedList;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
import ca.uvic.chisel.javasketch.data.model.ICall;
/**
* @author Del Myers
*
*/
public class BreadCrumbContentProvider implements IStructuredContentProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
@Override
public Object[] getElements(Object inputElement) {
LinkedList<Object> activations = new LinkedList<Object>();
if (inputElement instanceof ICall) {
ICall current = (ICall) inputElement;
while (current != null) {
activations.addFirst(current);
try {
current = (ICall) current.getActivation().getArrival().getOrigin();
} catch (NullPointerException e) {
current = null;
} catch (ClassCastException e) {
current = null;
}
}
}
activations.addFirst("USER.start()");
return activations.toArray();
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
@Override
public void dispose() {}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}