1 19 20 package org.netbeans.modules.java.actions; 21 22 import java.awt.event.ActionEvent ; 23 import javax.lang.model.element.Element; 24 import javax.swing.AbstractAction ; 25 import org.netbeans.api.java.source.ClasspathInfo; 26 import org.netbeans.api.java.source.JavaSource; 27 import org.netbeans.api.java.source.UiUtils; 28 import org.openide.loaders.DataObject; 29 import org.openide.util.Lookup; 30 import org.openide.util.NbBundle; 31 import org.openide.windows.WindowManager; 32 33 37 public class OpenDeclAction extends AbstractAction { 38 39 40 41 public OpenDeclAction () { 42 super (NbBundle.getMessage(OpenDeclAction.class,"TXT_OpenDecl")); 43 } 44 45 public void actionPerformed(ActionEvent e) { 46 Lookup lkp = WindowManager.getDefault().getRegistry().getActivated().getLookup(); 47 DataObject activeFile = (DataObject) lkp.lookup(DataObject.class); 48 Element value = (Element) lkp.lookup(Element.class); 49 if (activeFile != null && value != null) { 50 JavaSource js = JavaSource.forFileObject(activeFile.getPrimaryFile()); 51 if (js != null) { 52 ClasspathInfo cpInfo = js.getClasspathInfo(); 53 assert cpInfo != null; 54 UiUtils.open(cpInfo,value); 55 } 56 } 57 } 58 } 59 | Popular Tags |