blob: b81125a8d9c86c5cad62bbd00da1ac45056e88dc [file] [log] [blame]
/*******************************************************************************
* 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.actions;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.ui.CVSLocalCompareEditorInput;
import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
public class CompareWithTagAction extends WorkspaceAction {
public void execute(IAction action) throws InvocationTargetException, InterruptedException {
final ICVSRemoteResource[] remoteResource = new ICVSRemoteResource[] { null };
final IResource[] resources = getSelectedResources();
IProject[] projects = new IProject[resources.length];
for (int i = 0; i < resources.length; i++) {
projects[i] = resources[i].getProject();
}
final CVSTag tag = TagSelectionDialog.getTagToCompareWith(getShell(), projects);
if (tag == null) return;
// Show the compare viewer
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
CompareUI.openCompareEditorOnPage(
new CVSLocalCompareEditorInput(resources, tag),
getTargetPage());
}
}, false /* cancelable */, PROGRESS_BUSYCURSOR);
}
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources()
*/
protected boolean isEnabledForNonExistantResources() {
return true;
}
}