1 11 package org.eclipse.team.internal.ccvs.ui.tags; 12 13 import java.util.Date ; 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 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 40 public TagElement(CVSTag tag) { 41 this(null, tag); 42 } 43 public TagElement(Object parent, CVSTag tag) { 44 this.parent = parent; 45 this.tag = tag; 46 } 47 public Object [] getChildren(Object o) { 48 return new Object [0]; 49 } 50 public Object getAdapter(Class adapter) { 51 if (adapter == IWorkbenchAdapter.class) return this; 52 return null; 53 } 54 public ImageDescriptor getImageDescriptor(Object object) { 55 return getImageDescriptor(tag); 56 } 57 public String getLabel(Object o) { 58 if(tag.getType() == CVSTag.DATE){ 59 Date date = tag.asDate(); 60 if (date != null){ 61 return CVSTagElement.toDisplayString(date); 62 } 63 } 64 return tag.getName(); 65 } 66 public Object getParent(Object o) { 67 return parent; 68 } 69 public CVSTag getTag() { 70 return tag; 71 } 72 73 76 public int hashCode() { 77 return tag.hashCode(); 78 } 79 80 83 public boolean equals(Object obj) { 84 if (obj instanceof TagElement) { 85 return tag.equals(((TagElement)obj).getTag()); 86 } 87 return super.equals(obj); 88 } 89 } 90 | Popular Tags |