KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > AdaptableResourceList


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.team.internal.ccvs.ui;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.core.runtime.IAdaptable;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.ui.model.IWorkbenchAdapter;
17
18 /**
19  * This class acts as a resource list that can be used in table widgets.
20  */

21 public class AdaptableResourceList implements IAdaptable, IWorkbenchAdapter {
22
23     IResource[] resources;
24     
25     public AdaptableResourceList(IResource[] resources) {
26         this.resources = resources;
27     }
28     
29     /**
30      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
31      */

32     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
33         if (adapter == IWorkbenchAdapter.class) return this;
34         return null;
35     }
36
37     /**
38      * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(Object)
39      */

40     public Object JavaDoc[] getChildren(Object JavaDoc o) {
41         return resources;
42     }
43     /**
44      * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
45      */

46     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
47         return null;
48     }
49     /**
50      * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
51      */

52     public String JavaDoc getLabel(Object JavaDoc o) {
53         return o == null ? "" : o.toString();//$NON-NLS-1$
54
}
55     /**
56      * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
57      */

58     public Object JavaDoc getParent(Object JavaDoc o) {
59         return null;
60     }
61     
62 }
63
Popular Tags