1 11 package org.eclipse.team.internal.ccvs.ui.actions; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.resources.IResource; 16 import org.eclipse.jface.action.IAction; 17 import org.eclipse.jface.dialogs.MessageDialog; 18 import org.eclipse.team.internal.ccvs.core.CVSException; 19 import org.eclipse.team.internal.ccvs.core.ICVSResource; 20 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; 21 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; 22 import org.eclipse.team.internal.ccvs.ui.operations.AddOperation; 23 import org.eclipse.team.internal.ccvs.ui.wizards.AddWizard; 24 25 29 public class AddAction extends WorkspaceTraversalAction { 30 31 34 public void execute(IAction action) throws InterruptedException , InvocationTargetException { 35 if (!promptForAddOfIgnored()) return; 36 AddOperation op = new AddOperation(getTargetPart(), getCVSResourceMappings()); 37 AddWizard.run(getShell(), op); 38 } 39 40 43 private boolean promptForAddOfIgnored() { 44 IResource[] resources = getSelectedResourcesWithOverlap(); 47 boolean prompt = false; 48 for (int i = 0; i < resources.length; i++) { 49 ICVSResource resource = getCVSResourceFor(resources[i]); 50 try { 51 if (resource.isIgnored()) { 52 prompt = true; 53 break; 54 } 55 } catch (CVSException e) { 56 handle(e); 57 } 58 } 59 if (prompt) { 60 return MessageDialog.openQuestion(getShell(), CVSUIMessages.AddAction_addIgnoredTitle, CVSUIMessages.AddAction_addIgnoredQuestion); } 62 return true; 63 } 64 65 68 protected boolean isEnabledForManagedResources() { 69 return false; 70 } 71 72 75 protected boolean isEnabledForUnmanagedResources() { 76 return true; 77 } 78 79 82 protected boolean isEnabledForIgnoredResources() { 83 return true; 84 } 85 86 89 protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { 90 IResource resource = cvsResource.getIResource(); 92 if (resource.isLinked()) return false; 93 return super.isEnabledForCVSResource(cvsResource); 94 } 95 96 99 public String getId() { 100 return ICVSUIConstants.CMD_ADD; 101 } 102 } 103 | Popular Tags |