diff options
author | Michael Valenta | 2004-03-09 21:59:42 +0000 |
---|---|---|
committer | Michael Valenta | 2004-03-09 21:59:42 +0000 |
commit | be1ecfd92fd599cfa15d9a1fe127d049852796f5 (patch) | |
tree | a644d319de2479c72d15042159c4cba1c04eb9aa /bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java | |
parent | 70d8db4a04629905c0aefa376adfc27566b12c73 (diff) | |
download | eclipse.platform.team-be1ecfd92fd599cfa15d9a1fe127d049852796f5.tar.gz eclipse.platform.team-be1ecfd92fd599cfa15d9a1fe127d049852796f5.tar.xz eclipse.platform.team-be1ecfd92fd599cfa15d9a1fe127d049852796f5.zip |
Refactoring SubscriberActionRoot_branch_I20040315
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java')
-rw-r--r-- | bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java new file mode 100644 index 000000000..12f54b6d4 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertOperation.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui.subscriber; + +import java.util.*; + +import org.eclipse.compare.structuremergeviewer.IDiffElement; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.SyncInfoSet; +import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.ui.IWorkbenchPart; + + +public class CompareRevertOperation extends CVSSubscriberOperation { + protected CompareRevertOperation(IWorkbenchPart part, IDiffElement[] elements) { + super(part, elements); + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName() + */ + protected String getJobName() { + SyncInfoSet syncSet = getSyncInfoSet(); + return Policy.bind("CompareRevertAction.0", new Integer(syncSet.size()).toString()); //$NON-NLS-1$ + + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#run(org.eclipse.team.core.subscribers.MutableSyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) + */ + protected void run(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { + SyncInfo[] changed = syncSet.getSyncInfos(); + if (changed.length == 0) return; + + // The list of sync resources to be updated using "cvs update" + List updateShallow = new ArrayList(); + // A list of sync resource folders which need to be created locally + // (incoming addition or previously pruned) + Set parentCreationElements = new HashSet(); + + for (int i = 0; i < changed.length; i++) { + SyncInfo changedNode = changed[i]; + + // Make sure that parent folders exist + SyncInfo parent = getParent(changedNode); + if (parent != null && isOutOfSync(parent)) { + // We need to ensure that parents that are either incoming folder additions + // or previously pruned folders are recreated. + parentCreationElements.add(parent); + } + + IResource resource = changedNode.getLocal(); + if (resource.getType() == IResource.FILE) { + if (changedNode.getLocal().exists()) { + updateShallow.add(changedNode); + } else if (changedNode.getRemote() != null) { + updateShallow.add(changedNode); + } + } else { + // Special handling for folders to support shallow operations on files + // (i.e. folder operations are performed using the sync info already + // contained in the sync info. + if (isOutOfSync(changedNode)) { + parentCreationElements.add(changedNode); + } + } + + } + try { + // Calculate the total amount of work needed + int work = updateShallow.size() * 100; + monitor.beginTask(null, work); + + if (parentCreationElements.size() > 0) { + makeInSync((SyncInfo[]) parentCreationElements.toArray(new SyncInfo[parentCreationElements.size()])); + } + if (updateShallow.size() > 0) { + runUpdate((SyncInfo[])updateShallow.toArray(new SyncInfo[updateShallow.size()]), Policy.subMonitorFor(monitor, updateShallow.size() * 100)); + } + } finally { + monitor.done(); + } + return; + } + + private void runUpdate(SyncInfo[] infos, IProgressMonitor monitor) throws TeamException { + monitor.beginTask(null, 100 * infos.length); + for (int i = 0; i < infos.length; i++) { + SyncInfo info = infos[i]; + makeRemoteLocal(info, Policy.subMonitorFor(monitor, 100)); + } + monitor.done(); + } +}
\ No newline at end of file |