1 11 12 package org.eclipse.team.internal.ccvs.ui.model; 13 import java.lang.reflect.InvocationTargetException ; 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.osgi.util.NLS; 18 import org.eclipse.team.core.TeamException; 19 import org.eclipse.team.internal.ccvs.core.*; 20 import org.eclipse.team.internal.ccvs.ui.*; 21 import org.eclipse.team.internal.ccvs.ui.Policy; 22 import org.eclipse.team.internal.ccvs.ui.operations.FetchMembersOperation; 23 import org.eclipse.ui.ISharedImages; 24 import org.eclipse.ui.PlatformUI; 25 import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; 26 import org.eclipse.ui.progress.IElementCollector; 27 28 public class RemoteFolderElement extends RemoteResourceElement implements IDeferredWorkbenchAdapter { 29 30 34 public String getLabel(Object o) { 35 if (!(o instanceof ICVSRemoteFolder)) 36 return null; 37 ICVSRemoteFolder folder = (ICVSRemoteFolder) o; 38 CVSTag tag = folder.getTag(); 39 if (tag != null && tag.getType() != CVSTag.HEAD) { 40 if (folder.getRemoteParent() == null) { 41 return NLS.bind(CVSUIMessages.RemoteFolderElement_nameAndTag, new String [] { folder.getName(), tag.getName() }); 42 } 43 } 44 return folder.getName(); 45 } 46 47 public ImageDescriptor getImageDescriptor(Object object) { 48 if (!(object instanceof ICVSRemoteFolder)) 49 return null; 50 ICVSRemoteFolder folder = (ICVSRemoteFolder) object; 51 if (folder.isDefinedModule()) { 52 return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_MODULE); 53 } 54 return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER); 55 } 56 57 public Object [] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { 58 if (!(o instanceof ICVSRemoteFolder)) 59 return new Object [0]; 60 return ((ICVSRemoteFolder) o).members(monitor); 61 } 62 63 public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) { 64 if (!(o instanceof ICVSRemoteFolder)) { 66 collector.add(new Object [0], monitor); 67 } 68 try { 69 monitor = Policy.monitorFor(monitor); 70 monitor.beginTask(NLS.bind(CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String [] { getLabel(o) }), 100); 71 FetchMembersOperation operation = new FetchMembersOperation(null, (ICVSRemoteFolder)o, collector); 72 operation.run(Policy.subMonitorFor(monitor, 100)); 73 } catch (InvocationTargetException e) { 74 handle(collector, e); 75 } catch (InterruptedException e) { 76 } finally { 78 monitor.done(); 79 } 80 } 81 82 public ISchedulingRule getRule(Object element) { 83 ICVSRepositoryLocation location = getRepositoryLocation(element); 84 return new RepositoryLocationSchedulingRule(location); 85 } 86 87 private ICVSRepositoryLocation getRepositoryLocation(Object o) { 88 if (!(o instanceof ICVSRemoteFolder)) 89 return null; 90 return ((ICVSRemoteFolder)o).getRepository(); 91 } 92 93 public boolean isContainer() { 94 return true; 95 } 96 } 97 | Popular Tags |