KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search > internal > ui > util > ListContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.search.internal.ui.util;
12
13 import java.util.List JavaDoc;
14
15 import org.eclipse.jface.viewers.IStructuredContentProvider;
16 import org.eclipse.jface.viewers.Viewer;
17
18 /**
19  * A specialized content provider to show a list of editor parts.
20  */

21 public class ListContentProvider implements IStructuredContentProvider {
22     List JavaDoc fContents;
23
24     public ListContentProvider() {
25     }
26     
27     public Object JavaDoc[] getElements(Object JavaDoc input) {
28         if (fContents != null && fContents == input)
29             return fContents.toArray();
30         return new Object JavaDoc[0];
31     }
32
33     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
34         if (newInput instanceof List JavaDoc)
35             fContents= (List JavaDoc)newInput;
36         else
37             fContents= null;
38         // we use a fixed set.
39
}
40
41     public void dispose() {
42     }
43     
44     public boolean isDeleted(Object JavaDoc o) {
45         return fContents != null && !fContents.contains(o);
46     }
47 }
48
Popular Tags