KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > ui > TestSessionTableContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.junit.ui;
13
14 import java.util.ArrayList JavaDoc;
15
16 import org.eclipse.jface.viewers.IStructuredContentProvider;
17 import org.eclipse.jface.viewers.Viewer;
18
19 import org.eclipse.jdt.junit.model.ITestElement;
20
21 import org.eclipse.jdt.internal.junit.model.TestCaseElement;
22 import org.eclipse.jdt.internal.junit.model.TestRoot;
23 import org.eclipse.jdt.internal.junit.model.TestSuiteElement;
24
25
26 public class TestSessionTableContentProvider implements IStructuredContentProvider {
27
28     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
29     }
30
31     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
32         ArrayList JavaDoc all= new ArrayList JavaDoc();
33         addAll(all, (TestRoot) inputElement);
34         return all.toArray();
35     }
36
37     private void addAll(ArrayList JavaDoc all, TestSuiteElement suite) {
38         ITestElement[] children= suite.getChildren();
39         for (int i= 0; i < children.length; i++) {
40             ITestElement element= children[i];
41             if (element instanceof TestSuiteElement) {
42                 if (((TestSuiteElement) element).getSuiteStatus().isErrorOrFailure())
43                     all.add(element); // add failed suite to flat list too
44
addAll(all, (TestSuiteElement) element);
45             } else if (element instanceof TestCaseElement) {
46                 all.add(element);
47             }
48         }
49     }
50
51     public void dispose() {
52     }
53 }
54
Popular Tags