1 11 package org.eclipse.team.internal.ccvs.ui.actions; 12 13 import java.lang.reflect.InvocationTargetException ; 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 import org.eclipse.core.resources.IResource; 18 import org.eclipse.core.resources.mapping.ResourceMapping; 19 import org.eclipse.jface.action.IAction; 20 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; 21 import org.eclipse.team.internal.ccvs.ui.operations.BranchOperation; 22 23 27 public class BranchAction extends WorkspaceTraversalAction { 28 29 32 public void execute(IAction action) throws InvocationTargetException , InterruptedException { 33 ResourceMapping[] resourceMappings = getCVSResourceMappings(); 34 if (resourceMappings == null || resourceMappings.length == 0) { 35 IResource[] resources = getSelectedResources(); 37 resourceMappings = getResourceMappings(resources); 38 } 39 if (resourceMappings == null || resourceMappings.length == 0) { 40 return; 42 } 43 new BranchOperation(getTargetPart(), resourceMappings).run(); 44 } 45 46 private ResourceMapping[] getResourceMappings(IResource[] resources) { 47 List mappings = new ArrayList (); 48 for (int i = 0; i < resources.length; i++) { 49 IResource resource = resources[i]; 50 Object o = getAdapter(resource, ResourceMapping.class); 51 if (o instanceof ResourceMapping) { 52 ResourceMapping mapping = (ResourceMapping) o; 53 mappings.add(mapping); 54 } 55 } 56 return (ResourceMapping[]) mappings.toArray(new ResourceMapping[mappings.size()]); 57 } 58 59 62 public String getId() { 63 return ICVSUIConstants.CMD_BRANCH; 64 } 65 } 66 67 | Popular Tags |