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.core.runtime.IProgressMonitor; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.jface.action.IAction; 19 import org.eclipse.jface.dialogs.MessageDialog; 20 import org.eclipse.team.core.Team; 21 import org.eclipse.team.internal.ccvs.core.CVSException; 22 import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; 23 import org.eclipse.team.internal.ccvs.core.ICVSFile; 24 import org.eclipse.team.internal.ccvs.core.ICVSResource; 25 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; 26 import org.eclipse.ui.actions.WorkspaceModifyOperation; 27 28 public class UneditAction extends WorkspaceAction { 29 30 33 protected void execute(IAction action) throws InvocationTargetException , InterruptedException { 34 35 if(! MessageDialog.openConfirm(getShell(), CVSUIMessages.Uneditaction_confirmTitle, CVSUIMessages.Uneditaction_confirmMessage)) { return; 37 } 38 39 run(new WorkspaceModifyOperation(null) { 40 public void execute(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 41 executeProviderAction(new IProviderAction() { 42 public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException { 43 provider.unedit(resources, false , true , monitor); 44 return Team.OK_STATUS; 45 } 46 }, monitor); 47 } 48 }, true , PROGRESS_DIALOG); 49 } 50 51 54 protected boolean isEnabledForAddedResources() { 55 return false; 56 } 57 58 61 protected boolean isEnabledForNonExistantResources() { 62 return true; 63 } 64 65 68 protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { 69 if (cvsResource.isFolder()) return false; 70 if (super.isEnabledForCVSResource(cvsResource)) { 71 return !((ICVSFile)cvsResource).isReadOnly() && ((ICVSFile)cvsResource).isEdited(); 72 } else { 73 return false; 74 } 75 } 76 77 78 } 79 | Popular Tags |