KickJava   Java API By Example, From Geeks To Geeks.

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


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  
14 import java.util.ArrayList JavaDoc;
15 import java.util.List JavaDoc;
16
17 import org.eclipse.core.runtime.IAdaptable;
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.jface.resource.ImageDescriptor;
20 import org.eclipse.team.internal.ccvs.core.CVSTag;
21 import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
22 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
23 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
24 import org.eclipse.ui.model.IWorkbenchAdapter;
25
26 /**
27  * This class represents an IProject resource in a repository. The
28  * children of a RemoteModule are its versions. A RemoteModule is
29  * a child of the VersionsCategory.
30  */

31 public class RemoteVersionModule extends CVSModelElement implements IAdaptable {
32     CVSTag tag;
33     List JavaDoc projects = new ArrayList JavaDoc();
34     GroupedByVersionCategory parent;
35     
36     /**
37      * RemoteProject constructor.
38      */

39     public RemoteVersionModule(CVSTag tag, GroupedByVersionCategory parent) {
40         this.tag = tag;
41         this.parent = parent;
42     }
43     
44     /**
45      * Returns an object which is an instance of the given class
46      * associated with this object. Returns <code>null</code> if
47      * no such object can be found.
48      */

49     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
50         if (adapter == IWorkbenchAdapter.class) return this;
51         return null;
52     }
53     
54     public void addProject(ICVSRemoteFolder project) {
55         projects.add(project);
56     }
57     
58     /**
59      * Returns the children of this object. When this object
60      * is displayed in a tree, the returned objects will be this
61      * element's children. Returns an empty enumeration if this
62      * object has no children. The children of the RemoteModule
63      * are the versions for that module.
64      */

65     public Object JavaDoc[] fetchChildren(Object JavaDoc o, IProgressMonitor monitor) {
66         return (ICVSRemoteFolder[]) projects.toArray(new ICVSRemoteFolder[projects.size()]);
67     }
68     
69     /**
70      * Returns an image to be used for displaying an object in the desktop.
71      * @param object The object to get an image for.
72      * @param owner The viewer that the image will be used in. The image will
73      * be disposed when this viewer is closed. If the owner is null, a new
74      * image is returned, and the caller is responsible for disposing it.
75      */

76     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
77         return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION);
78     }
79     
80     /**
81      * Returns the name of this element. This will typically
82      * be used to assign a label to this object when displayed
83      * in the UI.
84      */

85     public String JavaDoc getLabel(Object JavaDoc o) {
86         return tag.getName();
87     }
88     
89     /**
90      * Returns the logical parent of the given object in its tree.
91      */

92     public Object JavaDoc getParent(Object JavaDoc o) {
93         return parent;
94     }
95
96     
97     /** (Non-javadoc)
98      * For debugging purposes only.
99      */

100     public String JavaDoc toString() {
101         return "RemoteVersionModule(" + tag.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
102
}
103 }
104
Popular Tags