Setting up a working e4 Development Environment (2)

Time is moving so fast! In the meantime e4 evolved from M7, RC1 to RC2-Release these days… The description how to install a basic working environment that I have written some days ago is still valid for RC2 except for the fact that the e4 0.11 Repository changed. Eat this…

Name: e4 0.11RC2
Location: http://download.eclipse.org/e4/downloads/drops/S-0.11RC2-201105241000/repository

They e4 Team fixed lots of bugs, for example the problem with the secure_storage file is gone now. Using the Indigo Repositories for installing additional plugins into e4 SDK (for example SVN, Git, …) also works like a charm now! Try it out, it’s definately worth a try!

Advertisements

e4 Book in the pipeline…

After beeing ill for a very long time (since february) i did’nt manage it to continue writing on my upcoming new book:

But now I am back again, back to rumble! I just finished two chapters of the book, the third is in work actually. I also have written a 5 part tutorial on e4 for the german „Eclipse Magazin“, the final part will be released in the next issue. Last but not least I did a reboot of this blog to concentrate on developer things esspecially in the area of Eclipse and e4 programming.

By the way, on Amazon my book is listed on Rank 18 in Eclipse books meanwhile, that’s great news for me and motivation!…

LifeCycleHandler to hook into the startup process of an e4-app

In the past on RCP 3.x we hooked into the Application*-Classes to popup things like login screens just before the main application came up. With e4 we dont have the Application-Classes anymore, instead there is a standard E4Application-Class wich is responsible to create the Workbench Model and startup the GUI. Using LifeCycleHandlers you we are able to hook into the startup process of an e4 application. You can register a handler from within your plugin.xml by adding a new property named „lifeCycleURI“ like this:

<pre><?xml version="1.0" encoding="UTF-8"?>
<plugin>

<extension
id="product"
point="org.eclipse.core.runtime.products">
<product
name="de.hama.ui"
application="org.eclipse.e4.ui.workbench.swt.E4Application">
<property
name="appName"
value="de.hama.ui">
</property>
<property
name="applicationXMI"
value="de.hama.ui/Application.e4xmi">
</property>
<property
name="applicationCSS"
value="platform:/plugin/de.hama.ui/css/default.css">
</property>
<property
name="lifeCycleURI"
value="platform:/plugin/de.hama.ui/de.hama.ui.handlers.StartupLifeCycleHandler">
</property>
</product>
</extension>

</plugin>

So now we have the definition of a LifeCycleHandler and during runtime the class E4Application will look into the plugin „de.hama.ui“ to find a classed named „StartupLifeCycleHandler“ in the package „de.hama.ui.handlers“. Easy stuff so far. Like every handler in e4 a LifeCycleHandler is just a POJO, the difference now is that we do not use the @Execute or @CanExecute-Annotations to define wich method inside the handler has to be executed instead there is a new Eclipse-specific Annotation @PostContextCreate wich we can use to mark the method to be executed.After this method is executed, the e4 main app will show up.

Here is an example of a LifeCycleHandler to open a Login-Dialog right before the startup of the main application:

public class StartupLifeCycleHandler {

@Inject
LoginDaoJdbc loginDao;

@PostContextCreate
public void startup(IEclipseContext context) {

int i = loginDialog.open();
if (i == Window.CANCEL)
System.exit(0);

context.set("lfsDS", loginDao.getInitialDataSource());
context.set("login", loginDialog.getLogin());

}

Hope that helps…. have fun!

Reboot!

In the past I used this blog to post in german. In the future I will try to reboot this thing here to share my experiences with e4 / Rich Client Platform 4.1 and other programming topics in englisch! Let’s see how long I will get it managed…. but i try my best!