1 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")); setDescription(AntEditorActionMessages.getString("OpenDeclarationAction.1")); setToolTipText(AntEditorActionMessages.getString("OpenDeclarationAction.1")); } 36 37 40 public void run() { 41 if (fEditor == null) { 42 return; 43 } 44 45 fEditor.openReferenceElement(); 46 } 47 48 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 |