KickJava   Java API By Example, From Geeks To Geeks.

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


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.runtime.IProgressMonitor;
16 import org.eclipse.jface.action.IAction;
17 import org.eclipse.jface.operation.IRunnableWithProgress;
18 import org.eclipse.team.internal.ccvs.core.*;
19 import org.eclipse.team.internal.ccvs.ui.operations.RemoteCompareOperation;
20 import org.eclipse.team.internal.ccvs.ui.tags.TagSelectionDialog;
21 import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
22
23 /**
24  * Compare to versions of a remote resource.
25  */

26 public class CompareRemoteWithTagAction extends CVSAction {
27
28     /**
29      * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
30      */

31     protected void execute(IAction action) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
32         
33         final ICVSRemoteResource[] resources = getSelectedRemoteResources();
34         if (resources.length == 0) return;
35         
36         // Obtain the tag to compare against
37
final ICVSRemoteResource resource = resources[0];
38         final CVSTag[] tag = new CVSTag[] { null};
39         run(new IRunnableWithProgress() {
40             public void run(IProgressMonitor monitor) {
41                 tag[0] = TagSelectionDialog.getTagToCompareWith(getShell(), TagSource.create(resources),
42                         TagSelectionDialog.INCLUDE_BRANCHES |
43                         TagSelectionDialog.INCLUDE_VERSIONS |
44                         TagSelectionDialog.INCLUDE_DATES |
45                         TagSelectionDialog.INCLUDE_HEAD_TAG);
46             }
47         }, false /* cancelable */, PROGRESS_BUSYCURSOR);
48         if (tag[0] == null) return;
49         
50         // Run the compare operation in the background
51
try {
52             RemoteCompareOperation.create(getTargetPart(), resource, tag[0])
53                 .run();
54         } catch (CVSException e) {
55             throw new InvocationTargetException JavaDoc(e);
56         }
57     }
58
59     /**
60      * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
61      */

62     public boolean isEnabled() {
63         ICVSRemoteResource[] resources = getSelectedRemoteResources();
64         // Only support single select for now.
65
// Need to avoid overlap if multi-select is supported
66
return resources.length == 1;
67     }
68
69 }
70
Popular Tags