KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > internal > ListContentProvider


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.compare.internal;
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         // nothing to do
26
}
27     
28     public Object JavaDoc[] getElements(Object JavaDoc input) {
29         if (fContents != null && fContents == input)
30             return fContents.toArray();
31         return new Object JavaDoc[0];
32     }
33
34     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
35         if (newInput instanceof List JavaDoc)
36             fContents= (List JavaDoc)newInput;
37         else
38             fContents= null;
39         // we use a fixed set.
40
}
41
42     public void dispose() {
43         // empty default implementation
44
}
45     
46     public boolean isDeleted(Object JavaDoc o) {
47         return fContents != null && !fContents.contains(o);
48     }
49 }
50
Popular Tags