1 11 package org.eclipse.team.internal.ccvs.ui.tags; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.team.core.TeamException; 18 import org.eclipse.team.internal.ccvs.core.*; 19 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; 20 import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; 21 22 25 public class SingleFileTagSource extends TagSource { 26 27 public static CVSTag[] fetchTagsFor(ICVSFile file, IProgressMonitor monitor) throws TeamException { 28 Set tagSet = new HashSet (); 29 ILogEntry[] entries = file.getLogEntries(monitor); 30 for (int j = 0; j < entries.length; j++) { 31 CVSTag[] tags = entries[j].getTags(); 32 for (int k = 0; k < tags.length; k++) { 33 tagSet.add(tags[k]); 34 } 35 } 36 return (CVSTag[])tagSet.toArray(new CVSTag[tagSet.size()]); 37 } 38 39 private ICVSFile file; 40 private TagSource parentFolderTagSource; 41 42 45 public SingleFileTagSource(ICVSFile file) { 46 this.file = file; 47 parentFolderTagSource = TagSource.create(new ICVSResource[] { file.getParent() }); 48 } 49 50 53 public CVSTag[] getTags(int type) { 54 return parentFolderTagSource.getTags(type); 55 } 56 57 60 public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { 61 CVSTag[] tags = fetchTagsFor(file, monitor); 62 commit(tags, false, monitor); 63 fireChange(); 64 return tags; 65 } 66 67 70 public ICVSRepositoryLocation getLocation() { 71 RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); 72 ICVSRepositoryLocation location = mgr.getRepositoryLocationFor(file); 73 return location; 74 } 75 76 79 public String getShortDescription() { 80 return file.getName(); 81 } 82 83 86 public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { 87 parentFolderTagSource.commit(tags, replace, monitor); 88 fireChange(); 89 } 90 91 94 public ICVSResource[] getCVSResources() { 95 return new ICVSResource[] { file }; 96 } 97 98 } 99 | Popular Tags |