KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > wizards > SuiteClassesContentProvider


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 package org.eclipse.jdt.internal.junit.wizards;
12
13 import java.util.HashSet JavaDoc;
14
15 import org.eclipse.core.runtime.CoreException;
16
17 import org.eclipse.jface.viewers.IStructuredContentProvider;
18 import org.eclipse.jface.viewers.Viewer;
19
20 import org.eclipse.jdt.core.IPackageFragment;
21
22 import org.eclipse.jdt.internal.junit.launcher.JUnit3TestFinder;
23 import org.eclipse.jdt.internal.junit.ui.JUnitPlugin;
24
25 public class SuiteClassesContentProvider implements IStructuredContentProvider {
26         
27     public Object JavaDoc[] getElements(Object JavaDoc parent) {
28         if (! (parent instanceof IPackageFragment))
29             return new Object JavaDoc[0];
30         IPackageFragment pack= (IPackageFragment) parent;
31         if (! pack.exists())
32             return new Object JavaDoc[0];
33         try {
34             HashSet JavaDoc result= new HashSet JavaDoc();
35             new JUnit3TestFinder().findTestsInContainer(pack, result, null);
36             return result.toArray();
37         } catch (CoreException e) {
38             JUnitPlugin.log(e);
39             return new Object JavaDoc[0];
40         }
41     }
42     
43     public void dispose() {
44     }
45     
46     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
47     }
48 }
49
Popular Tags