KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > javaeditor > GotoAnnotationAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.ui.javaeditor;
13
14 import org.eclipse.ui.PlatformUI;
15 import org.eclipse.ui.texteditor.ITextEditor;
16 import org.eclipse.ui.texteditor.TextEditorAction;
17
18 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
19
20
21 public class GotoAnnotationAction extends TextEditorAction {
22
23     private boolean fForward;
24
25     public GotoAnnotationAction(String JavaDoc prefix, boolean forward) {
26         super(JavaEditorMessages.getBundleForConstructedKeys(), prefix, null);
27         fForward= forward;
28         if (forward)
29             PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_NEXT_ERROR_ACTION);
30         else
31             PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_PREVIOUS_ERROR_ACTION);
32     }
33
34     public void run() {
35         JavaEditor e= (JavaEditor) getTextEditor();
36         e.gotoAnnotation(fForward);
37     }
38
39     public void setEditor(ITextEditor editor) {
40         if (editor instanceof JavaEditor)
41             super.setEditor(editor);
42         update();
43     }
44
45     public void update() {
46         setEnabled(getTextEditor() instanceof JavaEditor);
47     }
48 }
49
Popular Tags