Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2001-12-07 20:28:56 +0000
committerjames2001-12-07 20:28:56 +0000
commitb0fca8a5842c0223228d2f9f78488f224b06f20e (patch)
tree624c65f78a11a70aa2410bcc697e927e5e48f6ec /bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
parent308927f275d43ec5c9f2e7e26f8777feb47d28f0 (diff)
downloadeclipse.platform.team-b0fca8a5842c0223228d2f9f78488f224b06f20e.tar.gz
eclipse.platform.team-b0fca8a5842c0223228d2f9f78488f224b06f20e.tar.xz
eclipse.platform.team-b0fca8a5842c0223228d2f9f78488f224b06f20e.zip
Separate Show in History action for IFiles
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java90
1 files changed, 90 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
new file mode 100644
index 000000000..c6e3e69a6
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
@@ -0,0 +1,90 @@
+package org.eclipse.team.internal.ccvs.ui.actions;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSRemoteFile;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.HistoryView;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.ui.actions.TeamAction;
+
+public class ShowResourceInHistoryAction extends TeamAction {
+ /**
+ * Returns the selected remote file
+ */
+ protected ICVSRemoteFile getSelectedRemoteFile() {
+ IResource[] resources = getSelectedResources();
+ if (resources.length != 1) return null;
+ if (!(resources[0] instanceof IFile)) return null;
+ IFile file = (IFile)resources[0];
+ CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(file.getProject());
+ try {
+ return (ICVSRemoteFile)provider.getRemoteResource(file);
+ } catch (TeamException e) {
+ CVSUIPlugin.log(e.getStatus());
+ return null;
+ }
+ }
+ /*
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ run(new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ ICVSRemoteFile file = getSelectedRemoteFile();
+ if (file == null) {
+ // No history for selected file
+ MessageDialog.openWarning(getShell(), Policy.bind("ShowHistoryAction.noHistory"), Policy.bind("ShowHistoryAction.noHistoryLong"));
+ return;
+ }
+ HistoryView view = HistoryView.openInActivePerspective();
+ if (view != null) {
+ view.showHistory(file);
+ }
+ }
+ }, Policy.bind("ShowHistoryAction.showHistory"), this.PROGRESS_BUSYCURSOR);
+ }
+ /*
+ * @see TeamAction#isEnabled()
+ */
+ protected boolean isEnabled() throws TeamException {
+ IResource[] resources = getSelectedResources();
+ return resources.length == 1;
+ }
+ /** (Non-javadoc)
+ * Method declared on IActionDelegate.
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ this.selection = (IStructuredSelection) selection;
+ //this action can be invoked by double-click, in which case
+ //there is no target action
+ if (action != null) {
+ try {
+ action.setEnabled(isEnabled());
+ } catch (TeamException e) {
+ action.setEnabled(false);
+ }
+ }
+ }
+ }
+} \ No newline at end of file

Back to the top