1 11 package org.eclipse.team.internal.ccvs.ui.operations; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.runtime.IProgressMonitor; 16 import org.eclipse.team.core.TeamException; 17 import org.eclipse.team.internal.ccvs.core.CVSException; 18 import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; 19 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; 20 import org.eclipse.ui.IWorkbenchPart; 21 22 27 public class HasProjectMetaFileOperation extends CVSOperation { 28 29 private ICVSRemoteFolder remoteFolder; 30 private boolean metaFileExists; 31 32 public static boolean hasMetaFile(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) throws InvocationTargetException , InterruptedException { 33 HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(part, remoteFolder); 34 op.run(); 35 return op.metaFileExists(); 36 } 37 38 public HasProjectMetaFileOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) { 39 super(part); 40 this.remoteFolder = remoteFolder; 41 } 42 43 47 private boolean hasMetaFile(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException { 48 49 folder = (ICVSRemoteFolder)folder.forTag(remoteFolder.getTag()); 52 53 try { 54 folder.members(monitor); 55 } catch (TeamException e) { 56 throw CVSException.wrapException(e); 57 } 58 try { 60 folder.getFile(".project"); return true; 62 } catch (TeamException e) { 63 } 65 return false; 66 } 67 68 71 public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { 72 metaFileExists = hasMetaFile(remoteFolder, monitor); 73 } 74 75 80 public boolean metaFileExists() { 81 return metaFileExists; 82 } 83 84 protected String getTaskName() { 85 return CVSUIMessages.HasProjectMetaFile_taskName; } 87 88 91 public boolean canRunAsJob() { 92 return false; 94 } 95 96 } 97 | Popular Tags |