1 11 package org.eclipse.team.internal.ccvs.core.client; 12 13 14 import org.eclipse.team.internal.ccvs.core.CVSException; 15 import org.eclipse.team.internal.ccvs.core.ICVSFile; 16 import org.eclipse.team.internal.ccvs.core.ICVSFolder; 17 import org.eclipse.team.internal.ccvs.core.ICVSResource; 18 import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; 19 20 30 31 class FileStructureVisitor extends AbstractStructureVisitor { 32 33 private boolean sendEmptyFolders; 34 35 public FileStructureVisitor(Session session, LocalOption[] localOptions, boolean sendEmptyFolders, boolean sendModifiedContents) { 36 this(session, localOptions, sendEmptyFolders, sendModifiedContents, true); 37 } 38 39 public FileStructureVisitor(Session session, LocalOption[] localOptions, boolean sendEmptyFolders, boolean sendModifiedContents, boolean sendBinary) { 40 super(session, localOptions, true, sendModifiedContents, sendBinary); 41 this.sendEmptyFolders = sendEmptyFolders; 42 } 43 44 47 public void visitFile(ICVSFile mFile) throws CVSException { 48 sendFile(mFile); 49 } 50 51 54 public void visitFolder(ICVSFolder mFolder) throws CVSException { 55 56 if (sendEmptyFolders) { 57 sendFolder(mFolder); 60 } 61 62 boolean exists = mFolder.exists(); 63 boolean isCVSFolder = mFolder.isCVSFolder(); 64 65 if ( ! isCVSFolder) return; 68 69 if (exists && isOrphanedSubtree(mFolder)) { 70 return; 71 } 72 73 ICVSResource[] children = mFolder.members(ICVSFolder.ALL_UNIGNORED_MEMBERS); 75 sendFiles(children); 76 sendQuestionableFolders(children); 77 if (isRecurse()) { 78 sendManagedFolders(children); 79 } 80 } 81 82 86 private void sendManagedFolders(ICVSResource[] children) throws CVSException { 87 for (int i = 0; i < children.length; i++) { 88 ICVSResource resource = children[i]; 89 if (resource.isFolder() && resource.isManaged()) { 90 resource.accept(this); 91 } 92 } 93 } 94 95 99 private void sendQuestionableFolders(ICVSResource[] children) throws CVSException { 100 for (int i = 0; i < children.length; i++) { 101 ICVSResource resource = children[i]; 102 if (resource.isFolder() && ! resource.isManaged()) { 103 resource.accept(this); 104 } 105 } 106 } 107 108 112 private void sendFiles(ICVSResource[] children) throws CVSException { 113 for (int i = 0; i < children.length; i++) { 114 ICVSResource resource = children[i]; 115 if (!resource.isFolder()) { 116 resource.accept(this); 117 } 118 } 119 } 120 121 } 122 | Popular Tags |