package de.ugoe.cs.swe.exercises.exercise;

import java.util.ArrayList;

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

import de.ugoe.cs.swe.exercises.lecture.Lecture;

class ExerciseLecturesContentProvider implements IStructuredContentProvider {

	private Exercise exercise;

	public ExerciseLecturesContentProvider(Exercise exercise) {
		this.exercise = exercise;
	}

	public ExerciseLecturesContentProvider() {
		this.exercise = null;
	}

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

	public void dispose() {
	}

	public Object[] getElements(Object parent) {
		if (this.exercise == null)
			return new ArrayList<Lecture>().toArray();
		return this.exercise.getLectures().toArray();
	}
}
