1 11 package org.eclipse.jdt.internal.ui.compare; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jface.action.Action; 16 import org.eclipse.jface.action.IAction; 17 import org.eclipse.jface.viewers.ISelection; 18 import org.eclipse.ui.IActionDelegate; 19 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; 20 21 24 public abstract class JavaHistoryAction extends Action implements IActionDelegate { 25 26 private JavaHistoryActionImpl fDelegate; 27 private JavaEditor fEditor; 28 private String fTitle; 29 private String fMessage; 30 31 JavaHistoryAction() { 32 } 33 34 private JavaHistoryActionImpl getDelegate() { 35 if (fDelegate == null) { 36 fDelegate= createDelegate(); 37 if (fEditor != null && fTitle != null && fMessage != null) 38 fDelegate.init(fEditor, fTitle, fMessage); 39 } 40 return fDelegate; 41 } 42 43 protected abstract JavaHistoryActionImpl createDelegate(); 44 45 final void init(JavaEditor editor, String text, String title, String message) { 46 Assert.isNotNull(editor); 47 Assert.isNotNull(title); 48 Assert.isNotNull(message); 49 fEditor= editor; 50 fTitle= title; 51 fMessage= message; 52 setText(text); 54 } 56 57 60 public final void run(ISelection selection) { 61 getDelegate().run(selection); 62 } 63 64 public final void run() { 65 getDelegate().runFromEditor(this); 66 } 67 68 final void update() { 69 getDelegate().update(this); 70 } 71 72 74 public final void selectionChanged(IAction uiProxy, ISelection selection) { 75 getDelegate().selectionChanged(uiProxy, selection); 76 } 77 78 public final void run(IAction action) { 79 getDelegate().run(action); 80 } 81 } 82 | Popular Tags |