1 11 package org.eclipse.team.internal.ccvs.ui.tags; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.runtime.IProgressMonitor; 16 import org.eclipse.jface.operation.IRunnableContext; 17 import org.eclipse.jface.operation.IRunnableWithProgress; 18 import org.eclipse.team.core.TeamException; 19 import org.eclipse.team.internal.ccvs.core.*; 20 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; 21 import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; 22 import org.eclipse.ui.PlatformUI; 23 24 27 public class SingleFolderTagSource extends TagSource { 28 29 public static CVSTag[] getTags(ICVSFolder folder, int type) { 30 if (type == CVSTag.HEAD) 31 return new CVSTag[] { CVSTag.DEFAULT } ; 32 return CVSUIPlugin.getPlugin().getRepositoryManager().getKnownTags(folder, type); 33 } 34 35 private ICVSFolder folder; 36 37 SingleFolderTagSource(ICVSFolder folder) { 38 this.folder = folder; 39 } 40 41 44 public CVSTag[] getTags(int type) { 45 if (type == CVSTag.HEAD || type == BASE) { 46 return super.getTags(type); 47 } 48 return getTags(getFolder(), type); 49 } 50 51 55 public ICVSFolder getFolder() { 56 return folder; 57 } 58 59 62 public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { 63 CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().refreshDefinedTags(getFolder(), bestEffort , true , monitor); 64 fireChange(); 65 return tags; 66 } 67 68 71 public ICVSRepositoryLocation getLocation() { 72 RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); 73 ICVSRepositoryLocation location = mgr.getRepositoryLocationFor(getFolder()); 74 return location; 75 } 76 77 80 public String getShortDescription() { 81 return getFolder().getName(); 82 } 83 84 87 public void commit(final CVSTag[] tags, final boolean replace, IProgressMonitor monitor) throws CVSException { 88 try { 89 final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); 90 manager.run(new IRunnableWithProgress() { 91 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 92 try { 93 ICVSFolder folder = getFolder(); 94 if (replace) { 95 CVSTag[] oldTags = manager.getKnownTags(folder); 96 manager.removeTags(folder, oldTags); 97 } 98 manager.addTags(folder, tags); 99 } catch (CVSException e) { 100 throw new InvocationTargetException (e); 101 } 102 } 103 }, monitor); 104 } catch (InvocationTargetException e) { 105 throw CVSException.wrapException(e); 106 } catch (InterruptedException e) { 107 } 109 fireChange(); 110 } 111 112 115 public ICVSResource[] getCVSResources() { 116 final ICVSResource[][] resources = new ICVSResource[][] { null }; 117 try { 118 getRunnableContext().run(true, true, new IRunnableWithProgress() { 119 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 120 try { 121 resources[0] = folder.fetchChildren(monitor); 122 } catch (TeamException e) { 123 throw new InvocationTargetException (e); 124 } finally { 125 monitor.done(); 126 } 127 } 128 }); 129 return resources[0]; 130 } catch (InvocationTargetException e) { 131 CVSUIPlugin.log(CVSException.wrapException(e)); 132 } catch (InterruptedException e) { 133 } 135 return new ICVSResource[] { folder }; 136 } 137 138 private IRunnableContext getRunnableContext() { 139 return PlatformUI.getWorkbench().getProgressService(); 140 } 141 142 } 143 | Popular Tags |