KickJava   Java API By Example, From Geeks To Geeks.

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


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

11
12 package org.eclipse.ant.internal.ui.editor;
13
14 import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
15 import org.eclipse.jdt.ui.actions.OpenAction;
16 import org.eclipse.jface.text.ITextSelection;
17
18 public class OpenDeclarationAction extends OpenAction {
19     
20     private AntEditor fEditor;
21     
22     public OpenDeclarationAction(AntEditor antEditor) {
23         super(antEditor.getSite());
24         fEditor= antEditor;
25         setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR);
26         antEditor.getSite().getKeyBindingService().registerAction(this);
27
28         setText(AntEditorMessages.getString("OpenDeclarationAction.0")); //$NON-NLS-1$
29
setDescription(AntEditorMessages.getString("OpenDeclarationAction.1")); //$NON-NLS-1$
30
setToolTipText(AntEditorMessages.getString("OpenDeclarationAction.1")); //$NON-NLS-1$
31
}
32     
33     /* (non-Javadoc)
34      * @see org.eclipse.jface.action.IAction#run()
35      */

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

47     public void selectionChanged(ITextSelection selection) {
48         setEnabled(fEditor != null);
49     }
50     
51     public void setEditor(AntEditor editor) {
52         fEditor= editor;
53     }
54 }
Popular Tags