1 11 package org.eclipse.team.internal.ccvs.ui.tags; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.core.runtime.IAdaptable; 17 import org.eclipse.jface.resource.ImageDescriptor; 18 import org.eclipse.team.internal.ccvs.core.*; 19 import org.eclipse.ui.model.IWorkbenchAdapter; 20 21 25 public class TagSourceResourceAdapter implements IAdaptable, IWorkbenchAdapter { 26 27 public static Object getViewerInput(TagSource tagSource) { 28 return new TagSourceResourceAdapter(tagSource); 29 } 30 31 TagSource tagSource; 32 33 private TagSourceResourceAdapter(TagSource tagSource) { 34 this.tagSource = tagSource; 35 } 36 37 40 public Object [] getChildren(Object o) { 41 ICVSResource[] children = tagSource.getCVSResources(); 42 if (children.length == 0) return new Object [0]; 43 List result = new ArrayList (); 44 for (int i = 0; i < children.length; i++) { 45 ICVSResource resource = children[i]; 46 if (resource.isFolder()) { 47 result.add(new CVSFolderElement((ICVSFolder)resource, false)); 48 } else { 49 result.add(new CVSFileElement((ICVSFile)resource)); 50 } 51 } 52 return result.toArray(new Object [result.size()]); 53 } 54 55 58 public ImageDescriptor getImageDescriptor(Object object) { 59 return null; 61 } 62 63 66 public String getLabel(Object o) { 67 return tagSource.getShortDescription(); 68 } 69 70 73 public Object getParent(Object o) { 74 return null; 76 } 77 78 81 public Object getAdapter(Class adapter) { 82 if (adapter == IWorkbenchAdapter.class) { 83 return this; 84 } 85 return null; 86 } 87 88 } 89 | Popular Tags |