1 11 package org.eclipse.team.internal.ccvs.ui.actions; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.compare.CompareConfiguration; 16 import org.eclipse.compare.CompareUI; 17 import org.eclipse.core.resources.IFile; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 import org.eclipse.jface.action.IAction; 21 import org.eclipse.jface.operation.IRunnableWithProgress; 22 import org.eclipse.swt.widgets.Shell; 23 import org.eclipse.team.internal.ccvs.core.CVSException; 24 import org.eclipse.team.internal.ccvs.core.ICVSResource; 25 import org.eclipse.team.internal.ccvs.ui.*; 26 import org.eclipse.team.internal.ui.TeamUIPlugin; 27 import org.eclipse.team.ui.TeamUI; 28 import org.eclipse.team.ui.history.*; 29 30 34 public class CompareWithRevisionAction extends WorkspaceAction { 35 36 37 40 public void execute(IAction action) throws InvocationTargetException , InterruptedException { 41 42 run(new IRunnableWithProgress() { 44 public void run(IProgressMonitor monitor) throws InterruptedException , InvocationTargetException { 45 if (isShowInDialog()) { 46 IFile file = (IFile) getSelectedResources()[0]; 47 showCompareInDialog(getShell(), file); 48 } else { 49 IHistoryView view = TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), (IFile)getSelectedResources()[0], null); 50 IHistoryPage page = view.getHistoryPage(); 51 if (page instanceof CVSHistoryPage){ 52 CVSHistoryPage cvsHistoryPage = (CVSHistoryPage) page; 53 cvsHistoryPage.setClickAction(true); 54 } 55 } 56 } 57 }, false , PROGRESS_BUSYCURSOR); 58 } 59 60 protected void showCompareInDialog(Shell shell, Object object){ 61 IHistoryPageSource pageSource = HistoryPageSource.getHistoryPageSource(object); 62 if (pageSource != null && pageSource.canShowHistoryFor(object)) { 63 CompareConfiguration cc = new CompareConfiguration(); 64 cc.setLeftEditable(true); 65 cc.setRightEditable(false); 66 HistoryPageCompareEditorInput input = new HistoryPageCompareEditorInput(cc, pageSource, object) { 67 public void saveChanges(IProgressMonitor monitor) throws CoreException { 68 super.saveChanges(monitor); 69 ((CVSHistoryPage)getHistoryPage()).saveChanges(monitor); 70 setDirty(false); 71 } 72 }; 73 CompareUI.openCompareDialog(input); 74 } 75 } 76 77 80 protected String getActionTitle() { 81 return CVSUIMessages.CompareWithRevisionAction_4; 82 } 83 84 87 protected String getErrorTitle() { 88 return CVSUIMessages.CompareWithRevisionAction_compare; 89 } 90 91 94 protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { 95 return (!cvsResource.isFolder() && super.isEnabledForCVSResource(cvsResource)); 96 } 97 98 101 protected boolean isEnabledForMultipleResources() { 102 return false; 103 } 104 105 108 protected boolean isEnabledForAddedResources() { 109 return true; 110 } 111 112 protected boolean isEnabledForUnmanagedResources() { 113 return true; 114 } 115 116 protected boolean isEnabledForIgnoredResources() { 117 return true; 118 } 119 120 protected boolean isShowInDialog() { 121 return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG); 122 } 123 } 124 | Popular Tags |