KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > actions > OpenDeclarationAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.ant.internal.ui.editor.actions;
13
14 import org.eclipse.ant.internal.ui.editor.AntEditor;
15 import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
16 import org.eclipse.jdt.ui.actions.OpenAction;
17 import org.eclipse.jface.commands.ActionHandler;
18 import org.eclipse.jface.text.ITextSelection;
19 import org.eclipse.ui.handlers.IHandlerService;
20
21 public class OpenDeclarationAction extends OpenAction {
22     
23     private AntEditor fEditor;
24     
25     public OpenDeclarationAction(AntEditor antEditor) {
26         super(antEditor.getSite());
27         fEditor= antEditor;
28         setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR);
29         IHandlerService handlerServer= (IHandlerService) antEditor.getSite().getService(IHandlerService.class);
30         handlerServer.activateHandler(IJavaEditorActionDefinitionIds.OPEN_EDITOR, new ActionHandler(this));
31
32         setText(AntEditorActionMessages.getString("OpenDeclarationAction.0")); //$NON-NLS-1$
33
setDescription(AntEditorActionMessages.getString("OpenDeclarationAction.1")); //$NON-NLS-1$
34
setToolTipText(AntEditorActionMessages.getString("OpenDeclarationAction.1")); //$NON-NLS-1$
35
}
36     
37     /* (non-Javadoc)
38      * @see org.eclipse.jface.action.IAction#run()
39      */

40     public void run() {
41         if (fEditor == null) {
42             return;
43         }
44         
45         fEditor.openReferenceElement();
46     }
47     
48     /* (non-Javadoc)
49      * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.text.ITextSelection)
50      */

51     public void selectionChanged(ITextSelection selection) {
52         setEnabled(fEditor != null);
53     }
54     
55     public void setEditor(AntEditor editor) {
56         fEditor= editor;
57     }
58 }
59
Popular Tags