blob: 9a3bd0d1f17d488d9fc3937223e049c63a1708f3 [file] [log] [blame]
package org.eclipse.team.internal.ccvs.ui.actions;
/*
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput;
import org.eclipse.team.internal.ui.sync.SyncView;
import org.eclipse.ui.PartInitException;
/**
* Action for catchup/release in popup menus.
*/
public class SyncOutgoingAction extends CVSAction {
public void execute(IAction action) {
IResource[] resources = getSelectedResources();
SyncView view = (SyncView)CVSUIPlugin.getActivePage().findView(SyncView.VIEW_ID);
if (view == null) {
view = SyncView.findInActivePerspective();
}
if (view != null) {
try {
CVSUIPlugin.getActivePage().showView(SyncView.VIEW_ID);
} catch (PartInitException e) {
CVSUIPlugin.log(e.getStatus());
}
// What happens when resources from the same project are selected?
view.showSync(new CVSSyncCompareInput(resources, true));
}
}
protected boolean isEnabled() throws TeamException {
IResource[] resources = getSelectedResources();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (!resource.isAccessible()) return false;
if( resource.getType() == IResource.PROJECT) continue;
// If the resource is not managed and its parent is not managed, disable.
ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
if (!cvsResource.isManaged()) {
// The resource is not managed. See if its parent is managed.
if (!cvsResource.getParent().isManaged()) return false;
}
}
return true;
}
}