KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > ArrayContentProvider


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

11
12 package com.bull.eclipse.jonas;
13
14 import java.util.Collection JavaDoc;
15
16 import org.eclipse.jface.viewers.IStructuredContentProvider;
17 import org.eclipse.jface.viewers.Viewer;
18
19 /**
20  * This implementation of <code>IStructuredContentProvider</code> handles
21  * the case where the input is an unchanging array or collection of elements.
22  */

23 public class ArrayContentProvider implements IStructuredContentProvider {
24     
25     /**
26      * Returns the elements in the input, which must be either an array or a
27      * <code>Collection</code>.
28      */

29     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
30         if (inputElement instanceof Object JavaDoc[])
31             return (Object JavaDoc[]) inputElement;
32         if (inputElement instanceof Collection JavaDoc)
33             return ((Collection JavaDoc) inputElement).toArray();
34         return new Object JavaDoc[0];
35     }
36     
37     /**
38      * This implementation does nothing.
39      */

40     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
41     }
42
43     /**
44      * This implementation does nothing.
45      */

46     public void dispose() {
47     }
48 }
Popular Tags