KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > repo > RemoteProjectsView


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.repo;
12
13 import org.eclipse.jface.viewers.ISelection;
14 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
15 import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
16 import org.eclipse.team.internal.ccvs.ui.model.RemoteProjectsElement;
17 import org.eclipse.team.internal.ui.actions.TeamAction;
18 import org.eclipse.ui.IWorkbenchPart;
19
20 /**
21  * This view shows a list of projects stored in a repository that share the same
22  * tag
23  */

24 public class RemoteProjectsView extends RemoteViewPart {
25     
26     public static final String JavaDoc VIEW_ID = "org.eclipse.team.ccvs.ui.RemoteProjectsView"; //$NON-NLS-1$
27

28     private RemoteProjectsElement root;
29
30     /**
31      * Constructor for RemoteProjectsView.
32      * @param partName
33      */

34     public RemoteProjectsView() {
35         super(VIEW_ID);
36     }
37
38     protected void initializeListeners() {
39         // listen for selection changes in the repo view
40
getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RepositoriesView.VIEW_ID, this);
41         getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RemoteTagsView.VIEW_ID, this);
42     }
43     
44     /**
45      * @see org.eclipse.ui.IWorkbenchPart#dispose()
46      */

47     public void dispose() {
48         getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(RepositoriesView.VIEW_ID, this);
49         getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(RemoteTagsView.VIEW_ID, this);
50         super.dispose();
51     }
52     
53     /**
54      * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
55      */

56     public void selectionChanged(IWorkbenchPart part, ISelection selection) {
57         Object JavaDoc[] selected = TeamAction.getSelectedAdaptables(selection, ICVSRepositoryLocation.class);
58         if (selected.length != 0) {
59             root.setRoot((ICVSRepositoryLocation)selected[0]);
60         } else {
61             selected = TeamAction.getSelectedAdaptables(selection, CVSTagElement.class);
62             if (selected.length != 0) {
63                 CVSTagElement element = (CVSTagElement)selected[0];
64                 root.setRoot(element.getRoot());
65                 root.setTag(element.getTag());
66             }
67         };
68         refreshViewer();
69     }
70     
71     /**
72      * @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#getTreeInput()
73      */

74     protected Object JavaDoc getTreeInput() {
75         root = new RemoteProjectsElement();
76         return root;
77     }
78
79 }
80
Popular Tags