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

Setting up a working e4 Development Environment (1)

e4 SDK 4.1M7 is out and starting with this series I will try to show you how to setup a Development-Environment with wich you can start working in and with e4. I will also explain how to setup important tools like Window Builder, EGit/JGit- and Subversion-Integration. Finally I will end up showing you how to get Kai Tödters Contacs-Demo and my Geo-Application working within Eclipse 4.1 SDK M7.

So let’s start the fun.

First of all you need to download the latest Eclipse 4.1 SDK M7 from here. You could also install e4 0.11M7 on top of an Eclipse 3.7 but I recommend you to do it directly in Eclipse 4.1  just to get started and a basic understanding of the next generation of the Eclipse IDE itself.

Unzip the downloaded file somewhere to your harddisk. I use Ubuntu 11.04 with a JDK 1.6.0_24 installed. On Linux-Sytems I usually install my software into my home directory, so for Eclipse 4.1 SDK M7 i create a directory „e4-m7“ in my home, move the original Zip-File there and unzip it. In the same directory I also create my workspace-folder. Doing it this way you can handle separate installations of Milestone Builds the same time, just a best practice that i figured out while working with all the different Milestone Builds in the past. After Copying and Unzipping, my Eclipse-Installation-Folder looks like this:

Next step is to start Eclipse, in order to do that just go into the folder $HOME/e4-m7/eclipse and doubleclick the eclipse executeable. Eclipse will start up asking you the workspace which you want to use. We use the workspace folder we have create within the e4-m7 folder so we select:

So far nothing special. Some seconds or minutes or hours later Eclipse 4.1 M7 will finally show up. If you get an error message or a small empty box and Eclipse doesn’t come up, it can be that there is a secure_storage file on you computer created by another Eclipse-Installation. This definitely can cause problems. In such a case just delete this file, which is normally located in the folder $HOME/.eclipse/org.eclipse.equinox.security/secure_storage. In a Unix-Terminal just do a rm to delete the file. On Windows please use Explorer to navigate to the file an delete it. After deleting the secure_storage file Eclipse 4.1M7 will start BUT you will loose all informations you entered in previous Eclipse-Installations that have to do with networking, especially the proxy settings. So you have to reenter them, which will of course result in another secure_storage file. On my Ubuntu-Box Eclipse looks quite pretty:


In order to be more productive in our e4 development, the e4 team provides us with further tools which are not part of the Eclipse 4.1 SDK Build. Included in the e4 tools you will find very helpful things like wizards, a graphical Workbench Model Editor and of course the e4 Sourcecode, which in fact is very interesting to learn e4 and to see what is under the hoods. Yeah, we need all this, so let’s go and install that stuff.
Move your mouse pointer to HELP | INSTALL NEW SOFTWARE… and in the upcoming dialog just press the ADD… button to add a new software repository to Eclipse from which we can install additional software. Please enter:

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

What are we doing here? We point Eclipse to the Software Repository with all the needed tools. The location/repository is different for every Milestone Build. On the Eclipse Website you’ll find this link on the download site of the e4 0.11M7 Build if you scroll down the page to the bottom. Here you’ll see a link „online repo site“… Some things are hard to find on the Eclipse Website, i know…

After adding this new repository, Eclipse will list you the available software, please select like this:

E4 Resources brings us the sourcecode, e4 Tools includes the wizards and the Workbench Model Editor and e4 XWT provides us with an optional package named „XWT“ which is in the e4 incubator at the moment. With XWT you are able to define your UIs in XML and connect it to the code via XAML-Technology. Really hot stuff and definitely worth to try it out! But back to e4…

After installing please do NOT restart Eclipse. We need further software so why not first installing everything we need and doing the restart at the end?

In professional RCP projects where you create a lot of UI it doesn’t make any sense to create the UI with pure coding. To be really productive we need a graphical tool to create the UI visually like we can do it with Netbeans or Visual Studio. The good news is: With Window Builder Pro (formerly a expensive tool from a company called „Instantiation“, then this company was acquired by Google because of the included Designer for GWT. Google brought Window Builder to the Eclipse Foundation) we have one of the best visual designers around – for free! Let’s install this into our Eclipse 4.1M7.

Again please move you mouse pointer to HELP | INSTALL NEW SOFTWARE… and add the following repository:

Name: Window Builder
Location: http://download.eclipse.org/windowbuilder/WB/integration/3.7

Arrived here please install the following:

At this point you have a fully functional and working development environment for e4. That’s why we are at the end of the first part of this series now. In my next post I will show how to create a first project and play around with Window Builder, after this we move our concentration to EGit/JGit and Subversion…

Have fun!

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!