KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > model > ModulesCategory


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.model;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.team.core.TeamException;
17 import org.eclipse.team.internal.ccvs.core.CVSTag;
18 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
19 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
20 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
21 import org.eclipse.team.internal.ccvs.ui.Policy;
22 import org.eclipse.ui.model.IWorkbenchAdapter;
23
24 /**
25  * ModulesCategory is the model element for the mdoules category
26  * for a particular repository. Its children are the array of all
27  * modules defined in the CVSROOT/Modules file
28  */

29 public class ModulesCategory extends CVSModelElement implements IAdaptable {
30     private ICVSRepositoryLocation repository;
31
32     public ModulesCategory(ICVSRepositoryLocation repository) {
33         super();
34         this.repository = repository;
35     }
36
37     /**
38      * Returns an object which is an instance of the given class
39      * associated with this object. Returns <code>null</code> if
40      * no such object can be found.
41      */

42     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
43         if (adapter == IWorkbenchAdapter.class) return this;
44         return null;
45     }
46         
47     /**
48      * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
49      */

50     public Object JavaDoc[] fetchChildren(Object JavaDoc o, IProgressMonitor monitor) throws TeamException {
51         return repository.members(CVSTag.DEFAULT, true /* module definitions */, monitor);
52     }
53
54     /**
55      * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
56      */

57     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
58         return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION);
59     }
60
61     /**
62      * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
63      */

64     public String JavaDoc getLabel(Object JavaDoc o) {
65         return Policy.bind("ModulesCategory.label"); //$NON-NLS-1$
66
}
67
68     /**
69      * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
70      */

71     public Object JavaDoc getParent(Object JavaDoc o) {
72         return repository;
73     }
74
75     /**
76      * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#isRemoteElement()
77      */

78     public boolean isRemoteElement() {
79         return true;
80     }
81
82     /**
83      * Returns the repository.
84      * @return ICVSRepositoryLocation
85      */

86     public ICVSRepositoryLocation getRepository() {
87         return repository;
88     }
89
90     public String JavaDoc toString() {
91         return getRepository().toString() + " (modules)"; //$NON-NLS-1$
92
}
93 }
94
Popular Tags