1 11 package org.eclipse.team.internal.ccvs.ui.operations; 12 13 import java.util.ArrayList ; 14 import java.util.Arrays ; 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.core.resources.mapping.ResourceMappingContext; 20 import org.eclipse.core.runtime.IProgressMonitor; 21 import org.eclipse.core.runtime.IStatus; 22 import org.eclipse.osgi.util.NLS; 23 import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext; 24 import org.eclipse.team.internal.ccvs.core.*; 25 import org.eclipse.team.internal.ccvs.core.client.Command; 26 import org.eclipse.team.internal.ccvs.core.client.Session; 27 import org.eclipse.team.internal.ccvs.core.client.Update; 28 import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; 29 import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; 30 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; 31 import org.eclipse.team.internal.ccvs.ui.Policy; 32 import org.eclipse.ui.IWorkbenchPart; 33 34 37 public class UpdateOperation extends SingleCommandOperation { 38 39 private CVSTag tag; 40 41 48 public UpdateOperation(IWorkbenchPart part, IResource[] resources, LocalOption[] options, CVSTag tag) { 49 this(part, asResourceMappers(resources), options, tag); 50 } 51 52 59 public UpdateOperation(IWorkbenchPart part, ResourceMapping[] mappings, LocalOption[] options, CVSTag tag) { 60 super(part, mappings, options); 61 this.tag = tag; 62 } 63 64 67 protected IStatus executeCommand( 68 Session session, 69 CVSTeamProvider provider, 70 ICVSResource[] resources, 71 boolean recurse, IProgressMonitor monitor) 72 throws CVSException, InterruptedException { 73 74 LocalOption[] commandOptions = getLocalOptions(recurse); 75 76 monitor.beginTask(null, 100); 77 IStatus execute = getUpdateCommand().execute( 78 session, 79 Command.NO_GLOBAL_OPTIONS, 80 commandOptions, 81 resources, 82 getCommandOutputListener(), 83 Policy.subMonitorFor(monitor, 95)); 84 85 updateWorkspaceSubscriber(provider, resources, recurse, Policy.subMonitorFor(monitor, 5)); 86 monitor.done(); 87 return execute; 88 } 89 90 protected LocalOption[] getLocalOptions(boolean recurse) { 91 List localOptions = new ArrayList (); 93 if (tag != null) { 95 localOptions.add(Update.makeTagOption(tag)); 96 } 97 localOptions.addAll(Arrays.asList(super.getLocalOptions(recurse))); 99 LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]); 100 return commandOptions; 101 } 102 103 protected Update getUpdateCommand() { 104 return Command.UPDATE; 105 } 106 107 110 protected String getTaskName() { 111 return CVSUIMessages.UpdateOperation_taskName; } 113 114 117 protected String getTaskName(CVSTeamProvider provider) { 118 return NLS.bind(CVSUIMessages.UpdateOperation_0, new String [] { provider.getProject().getName() }); 119 } 120 121 126 protected ICommandOutputListener getCommandOutputListener() { 127 return null; 128 } 129 130 protected boolean isReportableError(IStatus status) { 131 return super.isReportableError(status) 132 || status.getCode() == CVSStatus.UNMEGERED_BINARY_CONFLICT 133 || status.getCode() == CVSStatus.INVALID_LOCAL_RESOURCE_PATH 134 || status.getCode() == CVSStatus.RESPONSE_HANDLING_FAILURE; 135 } 136 137 140 protected String getErrorMessage(IStatus[] failures, int totalOperations) { 141 return CVSUIMessages.UpdateAction_update; 142 } 143 144 147 protected ResourceMappingContext getResourceMappingContext() { 148 return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); 149 } 150 151 public CVSTag getTag() { 152 return tag; 153 } 154 155 public void setTag(CVSTag tag) { 156 this.tag = tag; 157 } 158 } 159 | Popular Tags |