1 11 package org.eclipse.team.internal.ccvs.ui.actions; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.compare.CompareUI; 16 import org.eclipse.jface.action.IAction; 17 import org.eclipse.team.internal.ccvs.core.CVSException; 18 import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; 19 import org.eclipse.team.internal.ccvs.ui.CVSCompareEditorInput; 20 import org.eclipse.team.internal.ccvs.ui.ResourceEditionNode; 21 import org.eclipse.team.internal.ccvs.ui.operations.RemoteCompareOperation; 22 23 27 public class CompareRemoteResourcesAction extends CVSAction { 28 29 public void execute(IAction action) throws InvocationTargetException , InterruptedException { 30 ICVSRemoteResource[] editions = getSelectedRemoteResources(); 31 if (editions == null || editions.length != 2) { 32 return; 33 } 34 try { 35 if (isSameFolder(editions)) { 36 RemoteCompareOperation.create(null, editions[0], RemoteCompareOperation.getTag(editions[1])).run(); 37 } else { 38 ResourceEditionNode left = new ResourceEditionNode(editions[0]); 39 ResourceEditionNode right = new ResourceEditionNode(editions[1]); 40 CompareUI.openCompareEditorOnPage(new CVSCompareEditorInput(left, right), getTargetPage()); 41 } 42 } catch (CVSException e) { 43 throw new InvocationTargetException (e); 44 } 45 } 46 47 protected boolean isSameFolder(ICVSRemoteResource[] editions) { 48 return editions[0].isContainer() && editions[0].getRepository().equals(editions[1].getRepository()) 49 && editions[0].getRepositoryRelativePath().equals(editions[1].getRepositoryRelativePath()); 50 } 51 52 55 public boolean isEnabled() { 56 ICVSRemoteResource[] resources = getSelectedRemoteResources(); 57 if (resources.length != 2) return false; 58 if (resources[0].isContainer() != resources[1].isContainer()) return false; 59 return !resources[0].isContainer() || isSameFolder(resources); 61 } 62 63 } 64 | Popular Tags |