KickJava   Java API By Example, From Geeks To Geeks.

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


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.repo;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Iterator JavaDoc;
15
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
18 import org.eclipse.team.internal.ccvs.ui.actions.CVSAction;
19 import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
20
21 /**
22  * Abstract superclass for actions in the repositories view
23  */

24 public abstract class CVSRepoViewAction extends CVSAction {
25
26     /**
27      * Returns the selected CVS Repository locations
28      */

29     protected ICVSRepositoryLocation[] getSelectedRepositoryLocations() {
30         ArrayList JavaDoc tags = new ArrayList JavaDoc();
31         IStructuredSelection selection = getSelection();
32         if (!selection.isEmpty()) {
33             Iterator JavaDoc elements = selection.iterator();
34             while (elements.hasNext()) {
35                 Object JavaDoc element = elements.next();
36                 Object JavaDoc adapter = getAdapter(element, ICVSRepositoryLocation.class);
37                 if (adapter != null) {
38                     tags.add(adapter);
39                 } else {
40                     adapter = getAdapter(element, BranchCategory.class);
41                     if(adapter != null) {
42                         tags.add(((BranchCategory)adapter).getRepository(adapter));
43                     }
44                 }
45             }
46         }
47         return (ICVSRepositoryLocation[])tags.toArray(new ICVSRepositoryLocation[tags.size()]);
48     }
49
50 }
51
Popular Tags