KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > actions > EditAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.actions;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.core.runtime.IStatus;
18 import org.eclipse.jface.action.IAction;
19 import org.eclipse.jface.operation.IRunnableWithProgress;
20 import org.eclipse.team.core.Team;
21 import org.eclipse.team.internal.ccvs.core.*;
22 import org.eclipse.team.internal.ccvs.ui.Policy;
23 import org.eclipse.ui.PlatformUI;
24
25 public class EditAction extends WorkspaceAction {
26
27     /**
28      * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
29      */

30     protected void execute(IAction action) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
31         // Get the editors
32
final EditorsAction editors = new EditorsAction();
33         PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
34             public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
35                 executeProviderAction(editors, Policy.subMonitorFor(monitor, 25));
36                 
37                 // If there are editors show them and prompt the user to execute the edit command
38
if (!editors.promptToEdit(getShell())) {
39                     return;
40                 }
41                 
42                 executeProviderAction(new IProviderAction() {
43                     public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException {
44                         provider.edit(resources, false /* recurse */, true /* notify server */, false /* notifyForWritable*/, ICVSFile.NO_NOTIFICATION, monitor);
45                         return Team.OK_STATUS;
46                     }
47                 }, Policy.subMonitorFor(monitor, 75));
48             }
49         });
50     }
51
52     /**
53      * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources()
54      */

55     protected boolean isEnabledForAddedResources() {
56         return false;
57     }
58     /**
59      * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource)
60      */

61     protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException {
62         if (cvsResource.isFolder()) return false;
63         if (super.isEnabledForCVSResource(cvsResource)) {
64             return ((ICVSFile)cvsResource).isReadOnly();
65         } else {
66             return false;
67         }
68     }
69
70 }
71
Popular Tags