KickJava   Java API By Example, From Geeks To Geeks.

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


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.jface.action.IAction;
18 import org.eclipse.jface.operation.IRunnableWithProgress;
19 import org.eclipse.team.internal.ccvs.core.CVSException;
20 import org.eclipse.team.internal.ccvs.core.ICVSResource;
21 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
22 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
23 import org.eclipse.team.internal.ui.TeamUIPlugin;
24 import org.eclipse.team.ui.TeamUI;
25
26 public class ShowResourceInHistoryAction extends WorkspaceAction {
27     /*
28      * @see IActionDelegate#run(IAction)
29      */

30     public void execute(IAction action) throws InterruptedException JavaDoc, InvocationTargetException JavaDoc {
31         run(new IRunnableWithProgress() {
32             public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc {
33                 IResource[] resources = getSelectedResources();
34                 if (resources.length != 1) return;
35                 TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), resources[0], null);
36             }
37         }, false /* cancelable */, PROGRESS_BUSYCURSOR);
38     }
39
40     /**
41      * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle()
42      */

43     protected String JavaDoc getErrorTitle() {
44         return CVSUIMessages.ShowHistoryAction_showHistory;
45     }
46
47     /**
48      * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources()
49      */

50     protected boolean isEnabledForMultipleResources() {
51         return false;
52     }
53
54     /**
55      * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources()
56      */

57     protected boolean isEnabledForAddedResources() {
58         return true;
59     }
60
61     /* (non-Javadoc)
62      * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources()
63      */

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

71     protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException {
72         return (!cvsResource.isFolder() && super.isEnabledForCVSResource(cvsResource));
73     }
74
75     /* (non-Javadoc)
76      * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId()
77      */

78     public String JavaDoc getId() {
79         return ICVSUIConstants.CMD_HISTORY;
80     }
81     
82     protected boolean isEnabledForUnmanagedResources() {
83         return true;
84     }
85     
86     protected boolean isEnabledForIgnoredResources() {
87         return true;
88     }
89 }
90
Popular Tags