[openide-dev] Pathname of file in focus

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[openide-dev] Pathname of file in focus

jespersahner
Hi!

I have a module, which reads some text from a file in focus in the editor,
like:

    public void performAction() {
        Node[] node=TopComponent.getRegistry().getActivatedNodes();
        if (node.length==1) {
            EditorCookie ec=(EditorCookie)
node[0].getCookie(EditorCookie.class);
            if (ec!=null) {
                JEditorPane[] panes=ec.getOpenedPanes();
                if (panes.length>0) {
                    String text=panes[0].getSelectedText();
    ....

How do I get the pathname of the file in focus?

Regards,
Jesper


Reply | Threaded
Open this post in threaded view
|

[openide-dev] Re: Pathname of file in focus

Jesse Glick
jesper sahner wrote:
> I have a module, which reads some text from a file in focus in the
> editor, like:
>
>    public void performAction() {
>        Node[] node=TopComponent.getRegistry().getActivatedNodes();
>        if (node.length==1) {
>    ....
>
> How do I get the pathname of the file in focus?

http://wiki.java.net/bin/view/Netbeans/DevFaqFilesFromNodes

-J.

--
[hidden email]  x22801  netbeans.org  ant.apache.org