KickJava   Java API By Example, From Geeks To Geeks.

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


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.Date JavaDoc;
14 import org.eclipse.core.runtime.IAdaptable;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.team.internal.ccvs.core.CVSTag;
17 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
18 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
19 import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
20 import org.eclipse.ui.model.IWorkbenchAdapter;
21
22 public class TagElement implements IWorkbenchAdapter, IAdaptable {
23     Object JavaDoc parent;
24     CVSTag tag;
25     
26     public static ImageDescriptor getImageDescriptor(CVSTag tag) {
27         if (tag.getType() == CVSTag.BRANCH || tag.equals(CVSTag.DEFAULT)) {
28             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_TAG);
29         } else if (tag.getType() == CVSTag.DATE){
30             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATE);
31         }else {
32             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION);
33         }
34     }
35     
36     /**
37      * @deprecated
38      * @param tag
39      */

40     public TagElement(CVSTag tag) {
41         this(null, tag);
42     }
43     public TagElement(Object JavaDoc parent, CVSTag tag) {
44         this.parent = parent;
45         this.tag = tag;
46     }
47     public Object JavaDoc[] getChildren(Object JavaDoc o) {
48         return new Object JavaDoc[0];
49     }
50     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
51         if (adapter == IWorkbenchAdapter.class) return this;
52         return null;
53     }
54     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
55         return getImageDescriptor(tag);
56     }
57     public String JavaDoc getLabel(Object JavaDoc o) {
58         if(tag.getType() == CVSTag.DATE){
59             Date JavaDoc date = tag.asDate();
60             if (date != null){
61                 return CVSTagElement.toDisplayString(date);
62             }
63         }
64         return tag.getName();
65     }
66     public Object JavaDoc getParent(Object JavaDoc o) {
67         return parent;
68     }
69     public CVSTag getTag() {
70         return tag;
71     }
72     
73     /* (non-Javadoc)
74      * @see java.lang.Object#hashCode()
75      */

76     public int hashCode() {
77         return tag.hashCode();
78     }
79     
80     /* (non-Javadoc)
81      * @see java.lang.Object#equals(java.lang.Object)
82      */

83     public boolean equals(Object JavaDoc obj) {
84         if (obj instanceof TagElement) {
85             return tag.equals(((TagElement)obj).getTag());
86         }
87         return super.equals(obj);
88     }
89 }
90
Popular Tags