« Return to Thread: Compile Single programmatically

Compile Single programmatically

by buhman :: Rate this Message:

Reply to Author | View in Thread


Hi,

I'm developing on an application that is based on a Netbeans Module Suite (v6.0) and I'd need to know one thing:

I'm using the NB Java Editor in my application, and I need to compile this file. A project folder with the build.xml and the property files exists. The compiling itself is yet done by a  workaround that uses a Robot and invokes VK_F9...(COMPILE_SINGLE) which is very, very poor - I know - but it works..

Now I wanted to change this and I was looking for the appropriate Action or Action Handler class that invokes this compiling process in the NB sources with the additionaly features such as the output to the output window, the markups in the code a. s. o. ... but I could not find it. What I found was the following:

        org.openide.nodes.Node[] activatedNodes = WindowManager.getDefault().getRegistry().getActivatedNodes();

        for (int i = 0; i < activatedNodes.length; i++) {
             org.openide.nodes.Node n = activatedNodes[i];
             Project project = (Project)n.getValue("Project"); // NOI18N
             Item item = (Item)n.getValue("Item"); // NOI18N
       
             ActionProvider ap = (ActionProvider)project.getLookup().lookup(ActionProvider.class);
       
              if (ap != null)
                    ap.invokeAction(ActionProvider.COMMAND_COMPILE_SINGLE,
                                             Lookups.fixed(new Object[] {project, n}));
    }

But this code causes a NullPointerException as the Project object is null and now I don't know further...

I'm sure that there's an easy way to realize this, has anyone an idea?

Thanks in Advance!!

Daniel




 « Return to Thread: Compile Single programmatically

LightInTheBox - Buy quality products at wholesale price