KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.merge;
12
13
14 import java.util.Date JavaDoc;
15 import org.eclipse.core.runtime.IAdaptable;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.team.internal.ccvs.core.CVSTag;
18 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
19 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
20 import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
21 import org.eclipse.ui.model.IWorkbenchAdapter;
22
23 public class TagElement implements IWorkbenchAdapter, IAdaptable {
24     CVSTag tag;
25     public TagElement(CVSTag tag) {
26         this.tag = tag;
27     }
28     public Object JavaDoc[] getChildren(Object JavaDoc o) {
29         return new Object JavaDoc[0];
30     }
31     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
32         if (adapter == IWorkbenchAdapter.class) return this;
33         return null;
34     }
35     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
36         if (tag.getType() == CVSTag.BRANCH || tag == CVSTag.DEFAULT) {
37             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_TAG);
38         } else if (tag.getType() == CVSTag.DATE){
39             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATE);
40         }else {
41             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION);
42         }
43     }
44     public String JavaDoc getLabel(Object JavaDoc o) {
45         if(tag.getType() == CVSTag.DATE){
46             Date JavaDoc date = tag.asDate();
47             if (date != null){
48                 return CVSTagElement.toDisplayString(date);
49             }
50         }
51         return tag.getName();
52     }
53     public Object JavaDoc getParent(Object JavaDoc o) {
54         return null;
55     }
56     public CVSTag getTag() {
57         return tag;
58     }
59     
60     /* (non-Javadoc)
61      * @see java.lang.Object#hashCode()
62      */

63     public int hashCode() {
64         return tag.hashCode();
65     }
66     
67     /* (non-Javadoc)
68      * @see java.lang.Object#equals(java.lang.Object)
69      */

70     public boolean equals(Object JavaDoc obj) {
71         if (obj instanceof TagElement) {
72             return tag.equals(((TagElement)obj).getTag());
73         }
74         return super.equals(obj);
75     }
76 }
77
Popular Tags