1 11 package org.eclipse.team.internal.ccvs.ui.subscriber; 12 13 import org.eclipse.compare.structuremergeviewer.IDiffElement; 14 import org.eclipse.core.resources.IProject; 15 import org.eclipse.core.runtime.IProgressMonitor; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.osgi.util.NLS; 18 import org.eclipse.team.core.TeamException; 19 import org.eclipse.team.core.synchronize.SyncInfo; 20 import org.eclipse.team.core.synchronize.SyncInfoSet; 21 import org.eclipse.team.internal.ccvs.core.CVSException; 22 import org.eclipse.team.internal.ccvs.core.CVSSyncInfo; 23 import org.eclipse.team.internal.ccvs.core.ICVSFolder; 24 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; 25 import org.eclipse.team.internal.ccvs.ui.*; 26 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 27 28 32 public class ConfirmMergedOperation extends CVSSubscriberOperation { 33 34 public ConfirmMergedOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { 35 super(configuration, elements); 36 } 37 38 41 protected String getJobName() { 42 SyncInfoSet syncSet = getSyncInfoSet(); 43 return NLS.bind(CVSUIMessages.SubscriberConfirmMergedAction_jobName, new String [] { new Integer (syncSet.size()).toString() }); 44 } 45 46 49 protected void runWithProjectRule(IProject project, SyncInfoSet syncSet, IProgressMonitor monitor) throws CVSException { 50 SyncInfo[] syncResources = syncSet.getSyncInfos(); 51 monitor.beginTask(null, 100 * syncResources.length); 52 try { 53 for (int i = 0; i < syncResources.length; i++) { 54 SyncInfo info = syncResources[i]; 55 if (!makeOutgoing(info, Policy.subMonitorFor(monitor, 100))) { 56 } 58 } 59 } catch (TeamException e) { 60 handle(e); 61 } finally { 62 monitor.done(); 63 } 64 } 65 66 private boolean makeOutgoing(SyncInfo info, IProgressMonitor monitor) throws CVSException, TeamException { 67 monitor.beginTask(null, 100); 68 try { 69 CVSSyncInfo cvsInfo = getCVSSyncInfo(info); 70 if (cvsInfo == null) { 71 CVSUIPlugin.log(IStatus.ERROR, NLS.bind(CVSUIMessages.SubscriberConfirmMergedAction_0, new String [] { info.getLocal().getFullPath().toString() }), null); 72 return false; 73 } 74 ICVSFolder parent = CVSWorkspaceRoot.getCVSFolderFor(cvsInfo.getLocal().getParent()); 76 if (!parent.isCVSFolder()) { 77 SyncInfo parentInfo = cvsInfo.getSubscriber().getSyncInfo(parent.getIResource()); 79 if (!makeOutgoing(parentInfo, Policy.subMonitorFor(monitor, 20))) { 80 return false; 81 } 82 } 83 IStatus status = cvsInfo.makeOutgoing(Policy.subMonitorFor(monitor, 80)); 84 if (status.getSeverity() == IStatus.ERROR) { 85 logError(status); 86 return false; 87 } 88 return true; 89 } finally { 90 monitor.done(); 91 } 92 } 93 } 94 | Popular Tags |