1 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 24 public class RemoteProjectsView extends RemoteViewPart { 25 26 public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.RemoteProjectsView"; 28 private RemoteProjectsElement root; 29 30 34 public RemoteProjectsView() { 35 super(VIEW_ID); 36 } 37 38 protected void initializeListeners() { 39 getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RepositoriesView.VIEW_ID, this); 41 getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(RemoteTagsView.VIEW_ID, this); 42 } 43 44 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 56 public void selectionChanged(IWorkbenchPart part, ISelection selection) { 57 Object [] 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 74 protected Object getTreeInput() { 75 root = new RemoteProjectsElement(); 76 return root; 77 } 78 79 } 80 | Popular Tags |