KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > filesystem > CVSFileSystem


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.core.filesystem;
12 import java.net.URI JavaDoc;
13 import java.util.HashMap JavaDoc;
14
15 import org.eclipse.core.filesystem.IFileStore;
16 import org.eclipse.core.filesystem.provider.FileSystem;
17 import org.eclipse.core.runtime.*;
18 import org.eclipse.team.internal.ccvs.core.CVSMessages;
19 import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
20 import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
21 import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
22
23 public class CVSFileSystem extends FileSystem {
24
25
26     private CVSFileTree cvsTree;
27
28     public CVSFileSystem() {
29         super();
30     }
31
32     public IFileStore getStore(URI JavaDoc uri) {
33         return new CVSFileStore(CVSURI.fromUri(uri), null);
34     }
35
36     public boolean canReturnFullTree(){
37         return true;
38     }
39     
40     public CVSFileTree getFullTree(URI JavaDoc uri, IProgressMonitor monitor){
41         try{
42         monitor.beginTask(CVSMessages.CVSFileSystem_FetchTree, 100);
43         //always return new tree
44
//monitor.subTask(NLS.bind(message, binding));
45
if (cvsTree != null)
46         return cvsTree;
47
48         return this.refreshTree(uri, monitor);
49         }
50         finally{
51             monitor.done();
52         }
53     }
54     
55
56     public CVSFileTree refreshTree(URI JavaDoc uri, IProgressMonitor monitor){
57         CVSURI cvsURI = CVSURI.fromUri(uri);
58         
59         //Make sure that we're building the tree from the topmost level - keep cycling until you hit null
60
ICVSRemoteFolder folder = cvsURI.getProjectURI().toFolder();
61         
62         try {
63             RemoteLogger logger = new RemoteLogger(folder);
64
65             RemoteFolderTree remoteTree = logger.fetchTree(new SubProgressMonitor(monitor,80));
66             HashMap JavaDoc folderMap = logger.getFolderMap();
67             HashMap JavaDoc logMap = logger.getLogMap();
68             folderMap.put(folder.getName(), remoteTree);
69             //Save tree
70
cvsTree = new CVSFileTree(new CVSFileStore(cvsURI, null), cvsURI, remoteTree, folderMap, logMap);
71
72             return cvsTree;
73         } catch (CoreException e) {
74             CVSProviderPlugin.log(e);
75             return null;
76         }
77         
78     
79     }
80 }
81
Popular Tags