deckard cain
deckard cain

Reputation: 497

Multiple handlers for one command in eclipse e4

I am writing a new command for my eclipse RCP that should perform one task if one part is active, and other task if other task is active (eg. copy command that copies files if project explorer is active or copies text if text editor is active). I was thinking of having 2 handlers for one command (one defined in fragment.e4xmi of one plugin and other handler in fragment.e4xmi of another plugin). Is this doable?

On this page http://www.vogella.com/tutorials/EclipseRCP/article.html#importantmodelelement_examples it says that:

Each command can have only one valid handler for a given scope. The Eclipse framework selects the handler most specific to the model element.

For example, if you have two handlers for the "Copy" command, one for the window and another one for the part then the runtime selects the handlers closest to model element which is currently selected by the user.

Is it possible to have 2 handlers for one command in e4?

Upvotes: 1

Views: 943

Answers (1)

greg-449
greg-449

Reputation: 111142

If you mean two handlers being called for one invocation of the command the answer is No.

As the reference you quote says the handler closest to the current model element is chosen.

For multiple handlers applying to different parts put each handler in the Handlers list for the part you want it to apply to. This can be in a fragment or the main e4xmi file.

Upvotes: 1

Related Questions