KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

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

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

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