1 12 package org.eclipse.compare.internal; 13 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.viewers.ISelection; 16 17 import org.eclipse.ui.IObjectActionDelegate; 18 import org.eclipse.ui.IWorkbenchPage; 19 import org.eclipse.ui.IWorkbenchPart; 20 import org.eclipse.compare.CompareConfiguration; 21 import org.eclipse.compare.CompareUI; 22 23 24 27 public class CompareAction extends BaseCompareAction implements IObjectActionDelegate { 28 29 private ResourceCompareInput fInput; 30 private IWorkbenchPage fWorkbenchPage; 31 32 33 public void run(ISelection selection) { 34 if (fInput != null) { 35 boolean ok = fInput.setSelection(selection, 38 fWorkbenchPage.getWorkbenchWindow().getShell()); 39 if (!ok) return; 40 fInput.initializeCompareConfiguration(); 41 CompareUI.openCompareEditorOnPage(fInput, fWorkbenchPage); 42 fInput= null; } 44 } 45 46 protected boolean isEnabled(ISelection selection) { 47 if (fInput == null) { 48 CompareConfiguration cc= new CompareConfiguration(); 49 cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean (false)); 52 53 56 fInput= new ResourceCompareInput(cc); 57 } 58 return fInput.isEnabled(selection); 59 } 60 61 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 62 fWorkbenchPage= targetPart.getSite().getPage(); 63 } 64 } 65 | Popular Tags |