KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.model;
12
13
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.team.internal.ccvs.core.CVSTag;
17 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
18 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
19 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
20 import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
21
22 /**
23  * RemoteRootElement is the model element for a repository that
24  * appears in the repositories view. Its children are:
25  * a) HEAD
26  * b) Branch tags category
27  * c) Version tags category
28  */

29 public class CVSRepositoryRootElement extends CVSModelElement {
30     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
31         if (object instanceof ICVSRepositoryLocation || object instanceof RepositoryRoot) {
32             return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_REPOSITORY);
33         }
34         return null;
35     }
36     public String JavaDoc getLabel(Object JavaDoc o) {
37         if (o instanceof ICVSRepositoryLocation) {
38             ICVSRepositoryLocation root = (ICVSRepositoryLocation)o;
39             o = CVSUIPlugin.getPlugin().getRepositoryManager().getRepositoryRootFor(root);
40             if (o == null) {
41                 return root.getLocation(true);
42             }
43         }
44         if (o instanceof RepositoryRoot) {
45             RepositoryRoot root = (RepositoryRoot)o;
46             String JavaDoc name = root.getName();
47             if (name == null)
48                 return root.getRoot().getLocation(true);
49             else
50                 return name;
51         }
52         return null;
53     }
54     public Object JavaDoc getParent(Object JavaDoc o) {
55         return null;
56     }
57     public Object JavaDoc[] fetchChildren(Object JavaDoc o, IProgressMonitor monitor) {
58         ICVSRepositoryLocation location = null;
59         if (o instanceof ICVSRepositoryLocation) {
60             location = (ICVSRepositoryLocation)o;
61         }
62         if (o instanceof RepositoryRoot) {
63             RepositoryRoot root = (RepositoryRoot)o;
64             location = root.getRoot();
65         }
66         if (location == null) return null;
67         return new Object JavaDoc[] {
68             new CVSTagElement(CVSTag.DEFAULT, location),
69             new BranchCategory(location),
70             new VersionCategory(location),
71             new DateTagCategory(location)
72         };
73     }
74 }
75
Popular Tags