1 /******************************************************************************* 2 * Copyright (c) 2000, 2006 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.team.internal.ccvs.ui.actions; 15 16 import java.lang.reflect.InvocationTargetException; 17 18 import org.eclipse.jface.action.IAction; 19 import org.eclipse.team.core.Team; 20 import org.eclipse.team.internal.ccvs.core.*; 21 import org.eclipse.team.internal.ccvs.ui.Policy; 22 import org.eclipse.ui.PlatformUI; 23 24 public class EditAction extends WorkspaceAction { 25 26 @Override execute(IAction action)27 protected void execute(IAction action) throws InvocationTargetException, InterruptedException { 28 // Get the editors 29 final EditorsAction editors = new EditorsAction(); 30 PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { 31 executeProviderAction(editors, Policy.subMonitorFor(monitor, 25)); 32 33 // If there are editors show them and prompt the user to execute the edit 34 // command 35 if (!editors.promptToEdit(getShell())) { 36 return; 37 } 38 39 executeProviderAction((provider, resources, monitor1) -> { 40 provider.edit(resources, false /* recurse */, true /* notify server */, false /* notifyForWritable */, 41 ICVSFile.NO_NOTIFICATION, monitor1); 42 return Team.OK_STATUS; 43 }, Policy.subMonitorFor(monitor, 75)); 44 }); 45 } 46 47 @Override isEnabledForAddedResources()48 protected boolean isEnabledForAddedResources() { 49 return false; 50 } 51 52 @Override isEnabledForCVSResource(ICVSResource cvsResource)53 protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { 54 if (cvsResource.isFolder()) return false; 55 if (super.isEnabledForCVSResource(cvsResource)) { 56 return ((ICVSFile)cvsResource).isReadOnly(); 57 } else { 58 return false; 59 } 60 } 61 62 } 63