Jakub K
Jakub K

Reputation: 1711

Running the program from Eclipse plugin

I am developing an Eclipse plugin and I would like it to do some stuff right before the user runs his program.

I figure I either need to hook into the event which runs when the user starts his program or create my own button, which would first do my stuff and run the program afterwards.

Is there a way to listen to the run event in an Eclipse plugin? If not, how can I invoke the event programatically? Also, is this event logged somewhere?

Upvotes: 0

Views: 60

Answers (1)

Brian
Brian

Reputation: 144

I found this while looking for the exact same question.

Once we have the manager, just implement your own listener and add it to the LaunchManager:

class MyLaunchListener implements ILaunchListener {

    @Override
    public void launchAdded(ILaunch launch) {
        System.out.println("Launching!");
        // do stuff here
    }

    ...
}

ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
manager.addLaunchListener(new MyLaunchListener());

Note for this to work, you will need to add the org.eclipse.debug.core to your plugin dependencies.

Upvotes: 1

Related Questions