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.Status; 18 import org.eclipse.jface.action.IAction; 19 import org.eclipse.jface.operation.IRunnableWithProgress; 20 import org.eclipse.jface.window.Window; 21 import org.eclipse.osgi.util.NLS; 22 import org.eclipse.team.core.TeamException; 23 import org.eclipse.team.core.synchronize.SyncInfo; 24 import org.eclipse.team.internal.ccvs.core.*; 25 import org.eclipse.team.internal.ccvs.ui.*; 26 import org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation; 27 import org.eclipse.ui.IWorkbenchPart; 28 29 public class IgnoreAction extends WorkspaceTraversalAction { 30 31 36 class IgnoreOperation extends RepositoryProviderOperation { 37 38 private final IgnoreResourcesDialog dialog; 39 40 public IgnoreOperation(IWorkbenchPart part, IResource[] resources, IgnoreResourcesDialog dialog) { 41 super(part, resources); 42 this.dialog = dialog; 43 } 44 45 48 protected String getTaskName(CVSTeamProvider provider) { 49 return NLS.bind(CVSUIMessages.IgnoreAction_0, new String [] { provider.getProject().getName() }); 50 } 51 52 55 protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { 56 try { 57 monitor.beginTask(null, resources.length); 58 for (int i = 0; i < resources.length; i++) { 59 IResource resource = resources[i]; 60 String pattern = dialog.getIgnorePatternFor(resource); 61 ICVSResource cvsResource = getCVSResourceFor(resource); 62 cvsResource.setIgnoredAs(pattern); 63 monitor.worked(1); 64 } 65 } catch (TeamException e) { 66 collectStatus(e.getStatus()); 67 return; 68 } finally { 69 monitor.done(); 70 } 71 collectStatus(Status.OK_STATUS); 72 } 73 74 77 protected String getTaskName() { 78 return CVSUIMessages.IgnoreAction_1; 79 } 80 81 84 public boolean consultModelsForMappings() { 85 return false; 86 } 87 88 } 89 90 protected void execute(final IAction action) throws InvocationTargetException , InterruptedException { 91 run(new IRunnableWithProgress() { 92 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 93 IResource[] resources = getSelectedResources(); 94 IgnoreResourcesDialog dialog = new IgnoreResourcesDialog(getShell(), resources); 95 if (dialog.open() != Window.OK) return; 96 new IgnoreOperation(getTargetPart(), resources, dialog).run(); 97 98 } 100 }, false , PROGRESS_BUSYCURSOR); 101 } 102 105 protected String getErrorTitle() { 106 return CVSUIMessages.IgnoreAction_ignore; 107 } 108 109 112 protected boolean isEnabledForManagedResources() { 113 return false; 114 } 115 116 119 protected boolean isEnabledForUnmanagedResources() { 120 return true; 121 } 122 123 126 protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { 127 if (super.isEnabledForCVSResource(cvsResource)) { 128 CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); 130 IResource resource = cvsResource.getIResource(); 131 if (resource == null) return false; 132 try { 133 SyncInfo info = subscriber.getSyncInfo(resource); 134 return ((info.getKind() & SyncInfo.DIRECTION_MASK) == SyncInfo.OUTGOING); 135 } catch (TeamException e) { 136 return true; 138 } 139 } 140 return false; 141 } 142 143 146 public String getId() { 147 return ICVSUIConstants.CMD_IGNORE; 148 } 149 } 150 | Popular Tags |