user72749
user72749

Reputation: 19

How to listen for File>New>Project event in Eclipse

I am creating an Eclipse plugin which should listen for and handle the event generated, when the user selects File > New > Project.

How can I do it?

Upvotes: 0

Views: 1222

Answers (2)

jamesh
jamesh

Reputation: 20091

File New Project is a well established action/command. If you are looking to replace it with your own, then I would guess you're in an RCP context, where you are free to do what you will. I would probably start with my own command, and then add it to the menu, toolbar, keybinding etc, as needed. There is an excellent set of tutorials/tips at eclipse-tips.

If you are writing plugins for Eclipse, the IDE, then you are almost certainly approaching the task from too low a level. In this case, I would guess you're wanting to contribute your own wizard, and things to come up when you right click in the package navigator view, under the New menu.

If this is the case, then I would go straight to the newWizards extension point,

Upvotes: 1

VonC
VonC

Reputation: 1323313

One good way to listen and react to a menu item selection is to add an handler.

A handler is the behavior of a command at a particular point in time.
A command can have zero or more handlers associated with it.
At any one point in time, however, a command will either have no active handler or one active handler.
The active handler is the one which is currently responsible for carrying out the behavior of the command. This is very similar to the concept of an action handler and a retargettable action.

So you have to find the Command id corresponding to File New Project, and make sure your extension is the default active handler, redirecting to the new project function by default, after doing your custom process.

More details on the Menu Contribution article.

Upvotes: 1

Related Questions