KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.team.internal.ccvs.core.CVSTag;
16 import org.eclipse.team.internal.ccvs.ui.*;
17 import org.eclipse.ui.model.IWorkbenchAdapter;
18
19 /**
20  * Workbench model element that contains a list of tags
21  * of the same type (BRANCH, VERSION or DATE).
22  */

23 public class TagRootElement implements IWorkbenchAdapter, IAdaptable {
24     private TagSource tagSource;
25     private int typeOfTagRoot;
26     private final Object JavaDoc parent;
27     
28     public TagRootElement(Object JavaDoc parent, TagSource tagSource, int typeOfTagRoot) {
29         this.parent = parent;
30         this.typeOfTagRoot = typeOfTagRoot;
31         this.tagSource = tagSource;
32     }
33     
34     public Object JavaDoc[] getChildren(Object JavaDoc o) {
35         CVSTag[] childTags = tagSource.getTags(typeOfTagRoot);
36         TagElement[] result = new TagElement[childTags.length];
37         for (int i = 0; i < childTags.length; i++) {
38             result[i] = new TagElement(this, childTags[i]);
39         }
40         return result;
41     }
42     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
43         if (adapter == IWorkbenchAdapter.class) return this;
44         return null;
45     }
46     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
47         if(typeOfTagRoot==CVSTag.BRANCH) {
48             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_BRANCHES_CATEGORY);
49         } else if(typeOfTagRoot==CVSTag.DATE){
50             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATES_CATEGORY);
51         }else {
52             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_VERSIONS_CATEGORY);
53         }
54     }
55     public String JavaDoc getLabel(Object JavaDoc o) {
56         if(typeOfTagRoot==CVSTag.BRANCH) {
57             return CVSUIMessages.MergeWizardEndPage_branches;
58         } else if(typeOfTagRoot==CVSTag.DATE){
59             return CVSUIMessages.TagRootElement_0;
60         }else {
61             return CVSUIMessages.VersionsElement_versions;
62         }
63     }
64     public Object JavaDoc getParent(Object JavaDoc o) {
65         return parent;
66     }
67     /**
68      * Gets the typeOfTagRoot.
69      * @return Returns a int
70      */

71     public int getTypeOfTagRoot() {
72         return typeOfTagRoot;
73     }
74
75 }
76
Popular Tags