Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The annotation <code>@Execute</code> doesn't determine the type to be injected, the method declaration does.</p> <p>As a behavior annotation, <code>@Execute</code> marks the method that should be called when the handler is executed. The type of the object to be injected is determined by the method's arguments. To inject another object type, change the method's argument, e.g.</p> <pre><code>@Execute public void execute(MWindow window) { // method body } </code></pre> <p>to inject an <code>MWindow</code> from the active context.</p> <p>The <code>@Execute</code> annotation contains the <code>@Inject</code> annotation, so when an event is triggered and the handler is going to be executed the following happens:</p> <ol> <li>the framework looks for the method marked by the <code>@Execute</code> annotation </li> <li>the E4 context is searched for an object of the method's argument type (e.g. <code>IWorkbench</code>) </li> <li>the object gets injected and the method is executed</li> </ol> <p>Unless the <code>@Optional</code> annotation is set, an exception is thrown if no object is found in the context.</p> <p>For further reading and more thorough explanations see <a href="http://eclipsesource.com/blogs/tutorials/eclipse-4-e4-tutorial-part-4-dependency-injection-basics/" rel="nofollow"> Eclipse 4 (e4) Tutorial Part 4- Dependency Injection Basics </a> and <a href="http://eclipsesource.com/blogs/tutorials/eclipse-4-e4-tutorial-part-6-behavior-annotations/" rel="nofollow">Eclipse 4 (e4) Tutorial Part 6: Behavior Annotations</a>.</p> <p>An overview of Eclipse 4 annotations can be found at the <a href="http://wiki.eclipse.org/Eclipse4/RCP/Dependency_Injection" rel="nofollow">Eclipse 4 Wiki</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload