Monthly Archive for: ‘June, 2012’

Eclipse Democamp Munich @ Siemens : Impressions

Yesterday we had the Eclipse Democamp at the Siemens campus in Munich. Since the weather was just too great and there was a European Football Championship quarter-final, “only” 131 of the 200 registered attendees showed up. Regarding the feedback I got so far, they enjoyed the event very much (Anonymous quote “Best Eclipse Demo Camp EVER!” :)). I would like to thank all attendees for coming and of course, all the speakers for their great sessions (list is ordered by speaking time slot): Ralph Müller, Tom Schindl, Sebastian Zarnekow, Frank Gerhardt, Benjamin Muskalla, Maximilian Kögel, Jonas Helming, Markus Tiede, Ralf Sternberg, and Tobias Röhm.

Organizing the event was so much fun that I plan to have another one next year.

CU  tonight at the Democamp in Zurich, Switzerland!

Kai

You find me on Twitter and Google+.
Next Eclipse 4 Application Platform trainings

Eclipse 4 Lifecycle Hooks: Login Dialog with CSS Styling

11

Currently I am adding a section about the e4 application platform life cycle management to my e4 tutorial. One good way for hooking in the application’s life cycle are the life cycle hooks. You just have to add a new property with name “lifeCycleURI” and a value like “bundleclass://<bundle id>/<class>” to your product extension and use some life cycle annotations in the specified class.

You find a good introduction and examples for life cycle hooks from Lars Vogel and Marc Teufel. While the basic mechanism is straight forward, there are a few challenges left. One of them is how to provide a login dialog with css styling. Why is this a challenge? Because all the existing life cycle annotations (like @PostContextCreate) that are invoked before the application is started, are processed before the presentation engine is initialized. But the solution is pretty simple: Initialize a presentation engine with your own data.

First you have to provide the css file and the org.eclipse.e4.ui.css.swt.theme extension in your own login project, e.g.

<plugin>
   <extension
         point="org.eclipse.e4.ui.css.swt.theme">
      <theme
            basestylesheeturi="css/login.css"
            id="org.eclipse.e4.tutorial.contacts.themes.login"
            label="Login Theme">
      </theme>
   </extension>
</plugin>

Then, in your own Java code, you have to initialize the engine and style the shell you use for the login dialog. For doing that, get the IEclipseContext using dependency injection, and manually set the cssTheme and cssURI keys before invoking the static method PartRenderingEngine.initializeStyling(), e.g.

public class Login {
   @PostContextCreate
   public void login(IEclipseContext context) {
      final Shell shell = new Shell(SWT.INHERIT_NONE);

      final LoginDialog dialog = new LoginDialog(shell);
      dialog.create();

      String cssTheme = "org.eclipse.e4.tutorial.contacts.themes.login";
      context.set(E4Application.THEME_ID, cssTheme);
      String cssURI = "css/login.css";
      context.set(E4Workbench.CSS_URI_ARG, cssURI);

      PartRenderingEngine.initializeStyling(shell.getDisplay(), context);

      if (dialog.open() != Window.OK) {
         System.exit(0);
      }
   }
}

With this little trick, you can provide a private styling with your own css file just for the login dialog. Here are 2 screen shots of the login dialog example for my e4 tutorial with different css styling:

CU at Democamp Munich 2012!

Kai

You find me on Twitter and Google+.
Next Eclipse 4 Application Platform trainings