KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > resources > RemoteFolderTree


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.resources;
12
13
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.core.runtime.Assert;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.team.internal.ccvs.core.*;
18 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
19 import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
20
21 /**
22  * Whereas the RemoteFolder class provides access to a remote hierarchy using
23  * lazy retrieval via <code>getMembers()</code>, the RemoteFolderTree will force
24  * a recursive retrieval of the remote hierarchy in one round trip.
25  */

26 public class RemoteFolderTree extends RemoteFolder {
27     
28     public static RemoteFolderTree fromBytes(RemoteFolderTree parent, IResource local, byte[] bytes) throws CVSException {
29         Assert.isNotNull(bytes);
30         Assert.isTrue(local.getType() != IResource.FILE);
31         FolderSyncInfo syncInfo = FolderSyncInfo.getFolderSyncInfo(bytes);
32         return new RemoteFolderTree(parent, local.getName(), KnownRepositories.getInstance().getRepository(syncInfo.getRoot()), syncInfo.getRepository(), syncInfo.getTag(), syncInfo.getIsStatic());
33     }
34     
35     public RemoteFolderTree(RemoteFolder parent, ICVSRepositoryLocation repository, String JavaDoc repositoryRelativePath, CVSTag tag) {
36         super(parent, repository, repositoryRelativePath, tag);
37     }
38     
39     public RemoteFolderTree(RemoteFolder parent, String JavaDoc name, ICVSRepositoryLocation repository, String JavaDoc repositoryRelativePath, CVSTag tag) {
40         this(parent, name, repository, repositoryRelativePath, tag, false);
41     }
42
43     public RemoteFolderTree(RemoteFolder parent, String JavaDoc name, ICVSRepositoryLocation repository, String JavaDoc repositoryRelativePath, CVSTag tag, boolean isStatic) {
44         super(parent, name, repository, repositoryRelativePath, tag, isStatic);
45     }
46
47     /*
48      * Override of inherited method which persists the children
49      */

50     public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws CVSException {
51         if (getChildren() == null)
52             setChildren(super.getMembers(tagName, monitor));
53         return getChildren();
54     }
55
56     /*
57      * This method is public to allow access by the RemoteFolderTreeBuilder utility class.
58      * No other external classes should use this method.
59      */

60     public void setChildren(ICVSRemoteResource[] children) {
61         super.setChildren(children);
62     }
63     
64     /*
65      * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
66      */

67     public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
68         ICVSRemoteResource[] children = getChildren();
69         if (children == null) return;
70         for (int i=0; i<children.length; i++) {
71             ((ICVSResource)children[i]).accept(visitor);
72         }
73     }
74 }
75
76
Popular Tags