1 19 24 25 package org.netbeans.modules.retouche.navigation.actions; 26 27 import java.awt.Container ; 28 import java.awt.Point ; 29 import java.beans.PropertyChangeEvent ; 30 import java.beans.PropertyChangeListener ; 31 import java.util.List ; 32 import javax.swing.JEditorPane ; 33 import org.openide.awt.*; 34 import org.openide.awt.StatusDisplayer; 35 import org.openide.cookies.*; 36 import org.openide.cookies.EditorCookie; 37 import org.openide.filesystems.FileObject; 38 import org.openide.loaders.DataObject; 39 import org.openide.nodes.*; 40 import org.openide.text.PositionBounds; 41 import org.openide.util.*; 42 import javax.swing.*; 43 import java.awt.event.*; 44 import org.netbeans.api.gsf.Element; 45 import org.netbeans.api.gsf.ElementHandle; 46 import org.netbeans.api.retouche.source.Source; 47 import org.netbeans.api.retouche.source.UiUtils; 48 import org.openide.loaders.DataObjectNotFoundException; 49 import org.openide.windows.TopComponent; 50 51 63 public final class OpenAction extends AbstractAction { 64 65 private ElementHandle<? extends Element> elementHandle; 66 private FileObject fileObject; 67 68 public OpenAction( ElementHandle<? extends Element> elementHandle, FileObject fileObject ) { 69 this.elementHandle = elementHandle; 70 this.fileObject = fileObject; 71 putValue ( Action.NAME, NbBundle.getMessage ( OpenAction.class, "LBL_Goto" ) ); } 73 74 public void actionPerformed (ActionEvent ev) { 75 ElementHandle handle = elementHandle; 76 try { 77 DataObject activeFile = DataObject.find(fileObject); 78 79 if ((activeFile != null) && (handle != null)) { 80 Source js = 81 Source.forFileObject(activeFile.getPrimaryFile()); 82 83 if (js != null) { 84 UiUtils.open(js, handle); 85 } 86 } 87 } catch (DataObjectNotFoundException dnfe) { 88 Exceptions.printStackTrace(dnfe); 89 } 90 } 91 92 public boolean isEnabled () { 93 return true; 94 } 95 96 97 } 98 | Popular Tags |