KickJava   Java API By Example, From Geeks To Geeks.

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


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.model;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.team.internal.ccvs.core.CVSException;
15 import org.eclipse.team.internal.ccvs.core.CVSTag;
16 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
17 import org.eclipse.ui.model.IWorkbenchAdapter;
18
19 /**
20  * This class provides common behavior between the branch and date tag categories
21  */

22 public abstract class TagCategory extends CVSModelElement {
23     protected ICVSRepositoryLocation repository;
24     
25     public TagCategory(ICVSRepositoryLocation repository) {
26         this.repository = repository;
27     }
28     
29     /* (non-Javadoc)
30      * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#fetchChildren(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
31      */

32     public Object JavaDoc[] fetchChildren(Object JavaDoc o, IProgressMonitor monitor) throws CVSException {
33         CVSTag[] tags = getTags(monitor);
34         CVSTagElement[] elements = new CVSTagElement[tags.length];
35         for (int i = 0; i < tags.length; i++) {
36             elements[i] = new CVSTagElement(tags[i], repository);
37         }
38         return elements;
39     }
40
41     /**
42      * Return the tags that are to be displyed as children of this category
43      * @param monitor
44      * @return
45      */

46     protected abstract CVSTag[] getTags(IProgressMonitor monitor) throws CVSException;
47
48     /* (non-Javadoc)
49      * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
50      */

51     public Object JavaDoc getParent(Object JavaDoc o) {
52         return repository;
53     }
54     
55     /**
56      * Return the repository the given element belongs to.
57      */

58     public ICVSRepositoryLocation getRepository(Object JavaDoc o) {
59         return repository;
60     }
61
62     /**
63      * Returns an object which is an instance of the given class
64      * associated with this object. Returns <code>null</code> if
65      * no such object can be found.
66      */

67     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
68         if (adapter == IWorkbenchAdapter.class) return this;
69         return null;
70     }
71
72 }
73
Popular Tags