KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > model > CVSFolderElement


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

11 package org.eclipse.team.internal.ccvs.ui.model;
12
13
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.team.core.TeamException;
17 import org.eclipse.team.internal.ccvs.core.ICVSFile;
18 import org.eclipse.team.internal.ccvs.core.ICVSFolder;
19 import org.eclipse.team.internal.ccvs.core.ICVSResource;
20 import org.eclipse.ui.ISharedImages;
21 import org.eclipse.ui.PlatformUI;
22
23 public class CVSFolderElement extends CVSResourceElement {
24     
25     private ICVSFolder folder;
26     private boolean includeUnmanaged;
27     
28     public CVSFolderElement(ICVSFolder folder, boolean includeUnmanaged) {
29         this.folder = folder;
30         this.includeUnmanaged = includeUnmanaged;
31     }
32     
33     /**
34      * Returns CVSResourceElement instances
35      */

36     public Object JavaDoc[] fetchChildren(Object JavaDoc o, IProgressMonitor monitor) throws TeamException {
37         ICVSResource[] children = folder.fetchChildren(monitor);
38         CVSResourceElement[] elements = new CVSResourceElement[children.length];
39         for (int i = 0; i < children.length; i++) {
40             ICVSResource resource = children[i];
41             if(resource.isFolder()) {
42                 elements[i] = new CVSFolderElement((ICVSFolder)resource, includeUnmanaged);
43             } else {
44                 elements[i] = new CVSFileElement((ICVSFile)resource);
45             }
46         }
47         return elements;
48     }
49     
50     /**
51      * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#isRemoteElement()
52      */

53     public boolean isRemoteElement() {
54         return true;
55     }
56     
57     /**
58      * Overridden to append the version name to remote folders which
59      * have version tags and are top-level folders.
60      */

61     public String JavaDoc getLabel(Object JavaDoc o) {
62         return folder.getName();
63     }
64
65     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
66         return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
67     }
68     
69     /**
70      * @see IWorkbenchAdapter#getParent(Object)
71      */

72     public Object JavaDoc getParent(Object JavaDoc o) {
73         return new CVSFolderElement(folder.getParent(), includeUnmanaged);
74     }
75     
76     /**
77      * @see CVSResourceElement#getCVSResource()
78      */

79     public ICVSResource getCVSResource() {
80         return folder ;
81     }
82 }
83
Popular Tags