KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > tags > TagSourceResourceAdapter


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.tags;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 import org.eclipse.core.runtime.IAdaptable;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.team.internal.ccvs.core.*;
19 import org.eclipse.ui.model.IWorkbenchAdapter;
20
21 /**
22  * A workbench adapter that can be used to view the resources that make up
23  * a tag source. It is used by the TagConfigurationDialog.
24  */

25 public class TagSourceResourceAdapter implements IAdaptable, IWorkbenchAdapter {
26
27     public static Object JavaDoc getViewerInput(TagSource tagSource) {
28         return new TagSourceResourceAdapter(tagSource);
29     }
30     
31     TagSource tagSource;
32
33     private TagSourceResourceAdapter(TagSource tagSource) {
34         this.tagSource = tagSource;
35     }
36   
37     /* (non-Javadoc)
38      * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
39      */

40     public Object JavaDoc[] getChildren(Object JavaDoc o) {
41         ICVSResource[] children = tagSource.getCVSResources();
42         if (children.length == 0) return new Object JavaDoc[0];
43         List JavaDoc result = new ArrayList JavaDoc();
44         for (int i = 0; i < children.length; i++) {
45             ICVSResource resource = children[i];
46             if (resource.isFolder()) {
47                 result.add(new CVSFolderElement((ICVSFolder)resource, false));
48             } else {
49                 result.add(new CVSFileElement((ICVSFile)resource));
50             }
51         }
52         return result.toArray(new Object JavaDoc[result.size()]);
53     }
54
55     /* (non-Javadoc)
56      * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
57      */

58     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
59         // No imgae descriptor
60
return null;
61     }
62
63     /* (non-Javadoc)
64      * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
65      */

66     public String JavaDoc getLabel(Object JavaDoc o) {
67         return tagSource.getShortDescription();
68     }
69
70     /* (non-Javadoc)
71      * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
72      */

73     public Object JavaDoc getParent(Object JavaDoc o) {
74         // No parent
75
return null;
76     }
77
78     /* (non-Javadoc)
79      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
80      */

81     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
82         if (adapter == IWorkbenchAdapter.class) {
83             return this;
84         }
85         return null;
86     }
87
88 }
89
Popular Tags