diff options
author | Michael Valenta | 2004-01-23 15:23:55 +0000 |
---|---|---|
committer | Michael Valenta | 2004-01-23 15:23:55 +0000 |
commit | 51e20210b2edc04b7e24953f81ba16fdb0bae660 (patch) | |
tree | 4ae9b6da1669f0bbba4d476eabe4eb7cf6d46efc /bundles/org.eclipse.team.cvs.ui | |
parent | ab04aa02b58dbaca08037772215730c758b70513 (diff) | |
download | eclipse.platform.team-51e20210b2edc04b7e24953f81ba16fdb0bae660.tar.gz eclipse.platform.team-51e20210b2edc04b7e24953f81ba16fdb0bae660.tar.xz eclipse.platform.team-51e20210b2edc04b7e24953f81ba16fdb0bae660.zip |
*** empty log message ***
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui')
6 files changed, 208 insertions, 65 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties index 2d318bae3..4f87f4f47 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.properties +++ b/bundles/org.eclipse.team.cvs.ui/plugin.properties @@ -190,5 +190,8 @@ CVSWorkspaceSubscriber.confirmMerged.tooltip=Mark the conflict as merged by upgr CVSWorkspaceSubscriber.merge.label=&Update CVSWorkspaceSubscriber.merge.tooltip=Perform an update merge on the visible resources +CVSCompareSubscriber.revert.label=&Revert local to remote +CVSCompareSubscriber.revert.tooltip=Revert the local file contents to match that of their corresponding remotes + WorkInProgress.name=Work In Progress CVSRemoteQuickDiffProvider.label=Latest CVS Revision
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml index 0ea5ad22d..f65ad3cc9 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.xml +++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml @@ -724,7 +724,15 @@ <viewerContribution id="org.eclipse.team.ccvs.ui.CVSCompareSubscriberContributions" - targetID="org.eclipse.team.cvs.ui.compare-participant"> + targetID="org.eclipse.team.cvs.ui.compare-participant"> + <action + label="%CVSCompareSubscriber.revert.label" + menubarPath="SubscriberActionsGroup1" + tooltip="%CVSCompareSubscriber.revert.tooltip" + class="org.eclipse.team.internal.ccvs.ui.subscriber.CompareRevertAction" + helpContextId="org.eclipse.team.cvs.ui.compare_revert_action" + id="org.eclipse.team.ccvs.ui.CVSCompareSubscriber.revert"> + </action> <action label="%ShowHistoryAction.label" tooltip="%ShowHistoryAction.tooltip" diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSLocalCompareConfiguration.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSLocalCompareConfiguration.java index 509293553..d2a45f889 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSLocalCompareConfiguration.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSLocalCompareConfiguration.java @@ -12,12 +12,16 @@ package org.eclipse.team.internal.ccvs.ui.subscriber; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.swt.widgets.Composite; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.subscribers.TeamSubscriberSyncInfoCollector; -import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber; -import org.eclipse.team.internal.ccvs.core.CVSTag; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.ui.synchronize.SyncInfoDiffNode; import org.eclipse.team.ui.synchronize.SyncInfoSetCompareConfiguration; +import org.eclipse.team.ui.synchronize.actions.RefreshAction; /** * Provides compare specific support @@ -26,6 +30,7 @@ public class CVSLocalCompareConfiguration extends SyncInfoSetCompareConfiguratio private CVSCompareSubscriber subscriber; private TeamSubscriberSyncInfoCollector collector; + private RefreshAction refreshAction; /** * Return a <code>SyncInfoSetCompareConfiguration</code> that can be used in a @@ -63,4 +68,26 @@ public class CVSLocalCompareConfiguration extends SyncInfoSetCompareConfiguratio collector.waitForCollector(monitor); return super.prepareInput(monitor); } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.SyncInfoSetCompareConfiguration#fillContextMenu(org.eclipse.jface.viewers.StructuredViewer, org.eclipse.jface.action.IMenuManager) + */ + protected void fillContextMenu(StructuredViewer viewer, IMenuManager manager) { + manager.add(refreshAction); + manager.add(new Separator()); + super.fillContextMenu(viewer, manager); + } + + /* (non-Javadoc) + * @see org.eclipse.team.ui.synchronize.SyncInfoSetCompareConfiguration#initializeViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.viewers.StructuredViewer) + */ + public void initializeViewer(Composite parent, StructuredViewer viewer) { + super.initializeViewer(parent, viewer); + initializeActions(viewer); + } + + private void initializeActions(StructuredViewer viewer) { + refreshAction = new RefreshAction(viewer, ((CVSSyncTreeSubscriber)collector.getTeamSubscriber()).getName(), collector, null /* no listener */, false); + + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java index a52adb18d..300222a4a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java @@ -297,4 +297,67 @@ public abstract class CVSSubscriberAction extends SubscriberAction { }); return (result[0] == UpdateDialog.YES); } + + /** + * Make the contents of the local resource match that of the remote + * without modifying the sync info of the local resource. + * If called on a new folder, the sync info will be copied. + */ + protected void makeRemoteLocal(SyncInfo info, IProgressMonitor monitor) throws TeamException { + ISubscriberResource remote = info.getRemote(); + IResource local = info.getLocal(); + try { + if(remote==null) { + if (local.exists()) { + local.delete(IResource.KEEP_HISTORY, monitor); + } + } else { + if(remote.isContainer()) { + ensureContainerExists(info); + } else { + monitor.beginTask(null, 200); + try { + IFile localFile = (IFile)local; + if(local.exists()) { + localFile.setContents(remote.getStorage(Policy.subMonitorFor(monitor, 100)).getContents(), false /*don't force*/, true /*keep history*/, Policy.subMonitorFor(monitor, 100)); + } else { + ensureContainerExists(getParent(info)); + localFile.create(remote.getStorage(Policy.subMonitorFor(monitor, 100)).getContents(), false /*don't force*/, Policy.subMonitorFor(monitor, 100)); + } + } finally { + monitor.done(); + } + } + } + } catch(CoreException e) { + throw new CVSException(Policy.bind("UpdateMergeActionProblems_merging_remote_resources_into_workspace_1"), e); //$NON-NLS-1$ + } + } + + private boolean ensureContainerExists(SyncInfo info) throws TeamException { + IResource local = info.getLocal(); + // make sure that the parent exists + if (!local.exists()) { + if (!ensureContainerExists(getParent(info))) { + return false; + } + } + // make sure that the folder sync info is set; + if (isOutOfSync(info)) { + if (info instanceof CVSSyncInfo) { + CVSSyncInfo cvsInfo = (CVSSyncInfo)info; + IStatus status = cvsInfo.makeInSync(); + if (status.getSeverity() == IStatus.ERROR) { + logError(status); + return false; + } + } + } + // create the folder if it doesn't exist + ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)local); + if (!cvsFolder.exists()) { + cvsFolder.mkdir(); + } + return true; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertAction.java new file mode 100644 index 000000000..19463caa0 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareRevertAction.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * 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.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.subscribers.*; +import org.eclipse.team.internal.ccvs.ui.Policy; + +/** + * Action in compare editor that reverts the local contents to match the contents on the server. + */ +public class CompareRevertAction extends CVSSubscriberAction { + + /* (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(MutableSyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { + SyncInfo[] changed = syncSet.members(); + 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(); + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName(org.eclipse.team.core.subscribers.SyncInfoSet) + */ + protected String getJobName(SyncInfoSet syncSet) { + return "Reverting {0} resources" + new Integer(syncSet.size()).toString(); + + } +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java index 9fc520e66..b162cfc02 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java @@ -13,8 +13,10 @@ package org.eclipse.team.internal.ccvs.ui.subscriber; import java.util.ArrayList; import java.util.List; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.subscribers.*; import org.eclipse.team.core.subscribers.SyncInfoFilter.OrSyncInfoFilter; @@ -22,7 +24,6 @@ import org.eclipse.team.core.subscribers.SyncInfoFilter.SyncInfoDirectionFilter; import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.client.Command; import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.ui.Policy; /** @@ -150,65 +151,6 @@ public class MergeUpdateAction extends SafeUpdateAction { } } - /* - * If called on a new folder, the folder will become an outgoing addition. - */ - private void makeRemoteLocal(SyncInfo info, IProgressMonitor monitor) throws TeamException { - ISubscriberResource remote = info.getRemote(); - IResource local = info.getLocal(); - try { - if(remote==null) { - local.delete(false, monitor); - } else { - if(remote.isContainer()) { - ensureContainerExists(info); - } else { - monitor.beginTask(null, 200); - try { - IFile localFile = (IFile)local; - if(local.exists()) { - localFile.setContents(remote.getStorage(Policy.subMonitorFor(monitor, 100)).getContents(), false /*don't force*/, true /*keep history*/, Policy.subMonitorFor(monitor, 100)); - } else { - ensureContainerExists(getParent(info)); - localFile.create(remote.getStorage(Policy.subMonitorFor(monitor, 100)).getContents(), false /*don't force*/, Policy.subMonitorFor(monitor, 100)); - } - } finally { - monitor.done(); - } - } - } - } catch(CoreException e) { - throw new CVSException(Policy.bind("UpdateMergeActionProblems_merging_remote_resources_into_workspace_1"), e); //$NON-NLS-1$ - } - } - - private boolean ensureContainerExists(SyncInfo info) throws TeamException { - IResource local = info.getLocal(); - // make sure that the parent exists - if (!local.exists()) { - if (!ensureContainerExists(getParent(info))) { - return false; - } - } - // make sure that the folder sync info is set; - if (isOutOfSync(info)) { - if (info instanceof CVSSyncInfo) { - CVSSyncInfo cvsInfo = (CVSSyncInfo)info; - IStatus status = cvsInfo.makeInSync(); - if (status.getSeverity() == IStatus.ERROR) { - logError(status); - return false; - } - } - } - // create the folder if it doesn't exist - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)local); - if (!cvsFolder.exists()) { - cvsFolder.mkdir(); - } - return true; - } - /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName(org.eclipse.team.ui.sync.SyncInfoSet) */ |