1 11 package org.eclipse.ui.texteditor; 12 13 import java.util.ResourceBundle ; 14 15 import org.eclipse.jface.text.source.IAnnotationModel; 16 17 28 public class GotoAnnotationAction extends TextEditorAction { 29 30 34 private boolean fForward; 35 36 48 public GotoAnnotationAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean forward) { 49 super(bundle, prefix, editor); 50 fForward= forward; 51 setHelpContextId(fForward ? IAbstractTextEditorHelpContextIds.GOTO_NEXT_ANNOTATION_ACTION : IAbstractTextEditorHelpContextIds.GOTO_PREVIOUS_ANNOTATION_ACTION); 52 } 53 54 62 public GotoAnnotationAction(ITextEditor editor, boolean forward) { 63 this(EditorMessages.getBundleForConstructedKeys(), forward ? "Editor.GotoNextAnnotation." : "Editor.GotoPreviousAnnotation.", editor, forward); } 65 66 70 public void run() { 71 ITextEditor editor= getTextEditor(); 72 if (editor instanceof ITextEditorExtension4) 73 ((ITextEditorExtension4)editor).gotoAnnotation(fForward); 74 } 75 76 80 public void setEditor(ITextEditor editor) { 81 super.setEditor(editor); 82 update(); 83 } 84 85 89 public void update() { 90 ITextEditor editor= getTextEditor(); 91 if (!(editor instanceof AbstractTextEditor)) { 92 setEnabled(false); 93 return; 94 } 95 96 IAnnotationModel model= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); 97 setEnabled(model != null); 98 } 99 } 100 | Popular Tags |