KickJava   Java API By Example, From Geeks To Geeks.

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


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.dialogs.MessageDialog;
20 import org.eclipse.team.core.Team;
21 import org.eclipse.team.internal.ccvs.core.CVSException;
22 import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
23 import org.eclipse.team.internal.ccvs.core.ICVSFile;
24 import org.eclipse.team.internal.ccvs.core.ICVSResource;
25 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
26 import org.eclipse.ui.actions.WorkspaceModifyOperation;
27
28 public class UneditAction extends WorkspaceAction {
29
30     /**
31      * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
32      */

33     protected void execute(IAction action) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
34         
35         if(! MessageDialog.openConfirm(getShell(), CVSUIMessages.Uneditaction_confirmTitle, CVSUIMessages.Uneditaction_confirmMessage)) { //
36
return;
37         }
38         
39         run(new WorkspaceModifyOperation(null) {
40             public void execute(IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
41                 executeProviderAction(new IProviderAction() {
42                     public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException {
43                         provider.unedit(resources, false /* recurse */, true /* notify server */, monitor);
44                         return Team.OK_STATUS;
45                     }
46                 }, monitor);
47             }
48         }, true /* cancelable */, PROGRESS_DIALOG);
49     }
50
51     /**
52      * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources()
53      */

54     protected boolean isEnabledForAddedResources() {
55         return false;
56     }
57     
58     /* (non-Javadoc)
59      * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources()
60      */

61     protected boolean isEnabledForNonExistantResources() {
62         return true;
63     }
64     
65     /**
66      * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource)
67      */

68     protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException {
69         if (cvsResource.isFolder()) return false;
70         if (super.isEnabledForCVSResource(cvsResource)) {
71             return !((ICVSFile)cvsResource).isReadOnly() && ((ICVSFile)cvsResource).isEdited();
72         } else {
73             return false;
74         }
75     }
76
77
78 }
79
Popular Tags