1 11 package org.eclipse.team.internal.ccvs.ui.model; 12 13 14 import java.util.HashMap ; 15 import java.util.HashSet ; 16 import java.util.Iterator ; 17 import java.util.Map ; 18 19 import org.eclipse.core.runtime.IAdaptable; 20 import org.eclipse.core.runtime.IProgressMonitor; 21 import org.eclipse.jface.resource.ImageDescriptor; 22 import org.eclipse.team.internal.ccvs.core.CVSTag; 23 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; 24 import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder; 25 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; 26 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; 27 import org.eclipse.team.internal.ccvs.ui.Policy; 28 import org.eclipse.ui.model.IWorkbenchAdapter; 29 30 public class GroupedByVersionCategory extends CVSModelElement implements IAdaptable { 31 private ICVSRepositoryLocation repository; 32 33 36 public GroupedByVersionCategory(ICVSRepositoryLocation repo) { 37 super(); 38 this.repository = repo; 39 } 40 41 46 public Object getAdapter(Class adapter) { 47 if (adapter == IWorkbenchAdapter.class) return this; 48 return null; 49 } 50 51 59 public Object [] fetchChildren(Object o, IProgressMonitor monitor) { 60 Map mappings = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownProjectsAndVersions(repository); 62 Map remoteVersionModules = new HashMap (); 63 for (Iterator it = mappings.keySet().iterator(); it.hasNext();) { 64 String project = (String ) it.next(); 65 CVSTag[] versions = (CVSTag[])((HashSet )mappings.get(project)).toArray(new CVSTag[0]); 66 for (int i = 0; i < versions.length; i++) { 67 CVSTag tag = versions[i]; 68 RemoteVersionModule module = (RemoteVersionModule)remoteVersionModules.get(tag); 69 if(module==null) { 70 module = new RemoteVersionModule(tag, this); 71 remoteVersionModules.put(tag, module); 72 } 73 module.addProject(new RemoteFolder(null, repository, project, tag)); 74 } 75 } 76 return (RemoteVersionModule[])remoteVersionModules.values().toArray(new RemoteVersionModule[0]); 77 } 78 79 85 public ImageDescriptor getImageDescriptor(Object object) { 86 return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_VERSIONS_CATEGORY); 87 } 88 89 97 public String getLabel(Object o) { 98 return Policy.bind("GroupedByVersionCategory.Versions_1"); } 100 101 108 public Object getParent(Object o) { 109 return repository; 110 } 111 112 115 public ICVSRepositoryLocation getRepository(Object o) { 116 return repository; 117 } 118 } 119 | Popular Tags |