1 11 package org.eclipse.team.internal.ccvs.ui.actions; 12 13 import org.eclipse.compare.*; 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.jface.action.IToolBarManager; 18 import org.eclipse.osgi.util.NLS; 19 import org.eclipse.swt.widgets.Shell; 20 import org.eclipse.team.internal.ccvs.ui.CVSHistoryPage; 21 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; 22 import org.eclipse.team.internal.ui.history.FileRevisionTypedElement; 23 import org.eclipse.team.ui.history.*; 24 import org.eclipse.ui.part.IPage; 25 26 33 public class ReplaceWithRevisionAction extends CompareWithRevisionAction { 34 35 protected void showCompareInDialog(Shell shell, Object object){ 36 IHistoryPageSource pageSource = HistoryPageSource.getHistoryPageSource(object); 37 if (pageSource != null && pageSource.canShowHistoryFor(object)) { 38 CompareConfiguration cc = new CompareConfiguration(); 39 cc.setLeftEditable(false); 40 cc.setRightEditable(false); 41 HistoryPageCompareEditorInput input = new HistoryPageCompareEditorInput(cc, pageSource, object) { 42 public void saveChanges(IProgressMonitor monitor) throws CoreException { 43 super.saveChanges(monitor); 44 ((CVSHistoryPage)getHistoryPage()).saveChanges(monitor); 45 setDirty(false); 46 } 47 protected void performReplace(Object o) throws CoreException { 48 FileRevisionTypedElement right = (FileRevisionTypedElement)o; 49 IFile file = (IFile)getCompareResult(); 50 file.setContents(right.getContents(), false, true, null); 51 } 52 protected IPage createPage(CompareViewerPane parent, 53 IToolBarManager toolBarManager) { 54 IPage page = super.createPage(parent, toolBarManager); 55 setTitle(NLS.bind(CVSUIMessages.ReplaceWithRevisionAction_0, ((IHistoryPage)page).getName())); 56 setPageDescription(((IHistoryPage)page).getName()); 57 return page; 58 } 59 }; 60 input.setReplace(true); 61 CompareUI.openCompareDialog(input); 62 } 63 } 64 67 protected String getActionTitle() { 68 return CVSUIMessages.ReplaceWithRevisionAction_1; 69 } 70 71 protected boolean isShowInDialog() { 72 return true; 74 } 75 } 76 | Popular Tags |