1 11 package org.eclipse.team.internal.ccvs.ui.model; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.core.runtime.jobs.ISchedulingRule; 16 import org.eclipse.jface.resource.ImageDescriptor; 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.ICVSUIConstants; 21 import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; 22 import org.eclipse.ui.model.IWorkbenchAdapter; 23 import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; 24 import org.eclipse.ui.progress.IElementCollector; 25 26 31 public class RemoteModule extends CVSModelElement implements IAdaptable, 32 IDeferredWorkbenchAdapter { 33 ICVSRemoteFolder folder; 34 35 VersionCategory parent; 36 37 40 public RemoteModule(ICVSRemoteFolder folder, VersionCategory parent) { 41 this.folder = folder; 42 this.parent = parent; 43 } 44 45 49 public Object getAdapter(Class adapter) { 50 if (adapter == IWorkbenchAdapter.class) 51 return this; 52 if (adapter == IDeferredWorkbenchAdapter.class) 53 return this; 54 return null; 55 } 56 57 66 public ImageDescriptor getImageDescriptor(Object object) { 67 return CVSUIPlugin.getPlugin().getImageDescriptor( 68 ICVSUIConstants.IMG_PROJECT_VERSION); 69 } 70 71 75 public String getLabel(Object o) { 76 return folder.getName(); 77 } 78 79 82 public Object getParent(Object o) { 83 return parent; 84 } 85 86 89 public ICVSRepositoryLocation getRepository(Object o) { 90 return folder.getRepository(); 91 } 92 93 96 public String toString() { 97 return "RemoteModule(" + folder.getName() + ")"; } 99 100 public ICVSRemoteResource getCVSResource() { 101 return folder; 102 } 103 104 113 public Object [] fetchChildren(Object o, IProgressMonitor monitor) 114 throws TeamException { 115 RepositoryManager manager = CVSUIPlugin.getPlugin() 116 .getRepositoryManager(); 117 try { 118 manager.refreshDefinedTags(folder, false , false , monitor); 119 } catch (TeamException e) { 120 } 122 CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager() 123 .getKnownTags(folder, CVSTag.VERSION); 124 Object [] versions = new Object [tags.length]; 125 for (int i = 0; i < versions.length; i++) { 126 versions[i] = folder.forTag(tags[i]); 127 } 128 return versions; 129 } 130 131 public void fetchDeferredChildren(Object o, IElementCollector collector, 132 IProgressMonitor monitor) { 133 try { 134 collector.add(fetchChildren(o, monitor), monitor); 135 } catch (TeamException e) { 136 handle(collector, e); 137 } 138 } 139 140 public boolean isContainer() { 141 return true; 142 } 143 144 public ISchedulingRule getRule(Object element) { 145 return new RepositoryLocationSchedulingRule(folder.getRepository()); 146 } 147 } 148 | Popular Tags |