1 11 package org.eclipse.team.internal.ccvs.core.client; 12 13 14 import java.util.StringTokenizer ; 15 16 import org.eclipse.core.resources.IFile; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.osgi.util.NLS; 19 import org.eclipse.team.core.Team; 20 import org.eclipse.team.internal.ccvs.core.*; 21 import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; 22 import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher; 23 24 32 class ImportStructureVisitor implements ICVSResourceVisitor { 33 34 private static final String KEYWORD_OPTION = "-k"; private static final String QUOTE = "'"; 37 protected Session session; 38 protected IProgressMonitor monitor; 39 40 private FileNameMatcher ignoreMatcher; 41 private FileNameMatcher wrapMatcher; 42 43 49 public ImportStructureVisitor(Session session, 50 String [] wrappers, IProgressMonitor monitor) { 51 52 this.session = session; 53 this.monitor = Policy.infiniteSubMonitorFor(monitor, 512); 54 wrapMatcher = initWrapMatcher(wrappers); 55 } 56 57 58 71 private FileNameMatcher initWrapMatcher(String [] wrappers) { 72 73 FileNameMatcher wrapMatcher; 74 75 if (wrappers == null) { 76 return null; 77 } 78 79 wrapMatcher = new FileNameMatcher(); 80 81 for (int i = 0; i < wrappers.length; i++) { 82 83 if (wrappers[i].indexOf(KEYWORD_OPTION) == -1) { 84 continue; 85 } 86 87 StringTokenizer st = new StringTokenizer (wrappers[i]); 88 String pattern = st.nextToken(); 89 String option = st.nextToken(); 90 StringTokenizer quoteSt = 92 new StringTokenizer (st.nextToken(),QUOTE); 93 option += quoteSt.nextToken(); 94 95 wrapMatcher.register(pattern,option); 96 } 97 98 return wrapMatcher; 99 } 100 101 104 public void visitFile(ICVSFile mFile) throws CVSException { 105 if (ignoreMatcher != null && ignoreMatcher.match(mFile.getName())) { 106 return; 107 } 108 109 boolean binary = Team.getFileContentManager().getType((IFile)mFile.getIResource()) == Team.BINARY; 110 if (wrapMatcher != null) { 111 String mode = wrapMatcher.getMatch(mFile.getName()); 112 if (mode != null) binary = KSubstOption.fromMode(mode).isBinary(); 113 } 114 session.sendModified(mFile, binary, monitor); 115 } 116 117 120 public void visitFolder(ICVSFolder mFolder) throws CVSException { 121 122 if (ignoreMatcher != null && ignoreMatcher.match(mFolder.getName())) { 123 return; 124 } 125 126 String localPath = mFolder.getRelativePath(session.getLocalRoot()); 127 monitor.subTask(NLS.bind(CVSMessages.AbstractStructureVisitor_sendingFolder, new String [] { localPath })); 128 129 session.sendConstructedDirectory(localPath); 130 mFolder.acceptChildren(this); 131 } 132 133 } 134 | Popular Tags |