KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > tags > CVSFileElement


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.ui.tags;
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.ICVSResource;
19 import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
20 import org.eclipse.team.internal.ccvs.ui.model.CVSResourceElement;
21 import org.eclipse.ui.PlatformUI;
22
23 public class CVSFileElement extends CVSResourceElement {
24     
25     private ICVSFile file;
26     
27     public CVSFileElement(ICVSFile file) {
28         this.file = file;
29     }
30     
31     /**
32      * Initial implementation: return null;
33      */

34     public Object JavaDoc[] fetchChildren(Object JavaDoc o, IProgressMonitor monitor) {
35         return new Object JavaDoc[0];
36     }
37     /**
38      * Initial implementation: return null.
39      */

40     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
41         return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(file.getName());
42     }
43     /**
44      * Initial implementation: return the file's name and version
45      */

46     public String JavaDoc getLabel(Object JavaDoc o) {
47         try {
48             ResourceSyncInfo info = file.getSyncInfo();
49             if(info!=null) {
50                 return file.getName() + " " + info.getRevision(); //$NON-NLS-1$
51
} else {
52                 return file.getName();
53             }
54         } catch (TeamException e) {
55             handle(null, null, e);
56             return null;
57         }
58     }
59     /**
60      * @see IWorkbenchAdapter#getParent(Object)
61      */

62     public Object JavaDoc getParent(Object JavaDoc o) {
63         return null;
64     }
65     
66     public ICVSFile getCVSFile() {
67         return file;
68     }
69     /**
70      * @see CVSResourceElement#getCVSResource()
71      */

72     public ICVSResource getCVSResource() {
73         return file;
74     }
75 }
76
Popular Tags