Monthly Archive for: ‘August, 2010’

CSS Theming for Eclipse RCP 3.x

11

Eclipse 4.0 brought a great new feature: Theming RCP applications with CSS. Another good news is, this cool feature can also be used with RCP 3.x based applications. The following screen shot shows the RCP Mail Demo, styled with CSS:

How to run the Demo with CSS styling?

  1. Checkout :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse/e4/releng
  2. Import Project Set /releng/org.eclipse.e4.ui.releng/e4.ui.css.psf
  3. Checkout e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.widgets (see bug 322641)
  4. Cleanup org.eclipse.e4.ui.css.swt (see bug 322644)
    => Organize Imports
    => Delete dependencies to org.eclipse.e4.core.*
  5. Start the CSS RCP Mail demo (project org.eclipse.e4.ui.examples.css.rcp)

The demo also provides dynamic theme switching. Here is is little excerpt from the defaul.css styling:


CTabItem, Label, Tree, Text {
 font-family: "Arial";
}

Shell {
 font-size: 12;
}

CTabItem, ToolBar, Button, CBanner, CoolBar {
 font-size: 9;
 background-color: white;
}

CTabFolder, CTabItem {
 background-color: #F0F1F7;
}

If you would like to play around with the css, just edit the files css/default.css and css/colorful.css in the project org.eclipse.e4.ui.examples.css.rcp. I have submitted a short talk at Eclipse Summit Europe to explain a few more details.

Have Fun!

Kai
Follow me on Twitter

Flattr and the Eclipse Community

Yesterday I discovered Flattr, a new micro payment cloud service that went to open beta recently. I have to admit, I really like the idea of Flattr: Spend a fixed amount of real money every month to honor the efforts of others who provide articles, blogs, software, music, video, etc. Let’s say you would like to spend $5 per month (minimum for Europeans is 2€). If you flattr just one thing, the owner will get a great portion of your 5$ (Flattr itself takes a little fee). If you flattr 50 things, every owner will get 1/50 = 10 cent. This does not seem to be much but all flattrs will add up.

In the past, I was just too lazy to donate something to open source projects or authors of great blogs and tutorials (like Tom Schindl, Lars Vogel and others). But now, I can easily recognize their work with just one click!

If you want to get more information about Flattr, just visit www.flattr.com and take a tour. If you like it, an account is created very quickly and easily.

If you provide something to the community, especially the Eclipse community, that others find helpful, you could get some recognition for your work by other Flattr users easily.

For example, if you are the owner of an open source project where you put effort in your spare time, just put it as “Software Thing” into Flattr, tag it,  and put a Flattr button on the project web page (Shameless plug: I did this today with my Eclipse/OSGi related OSS projects MP3 Manager and Person Manager).

Or, if you blog, you could easily put Flattr buttons in or at the end of your blog. There are many plug-ins available for WordPress and probably other blogging systems.

In summery: I think Flattr is a great way to recognize people who provide helpful/interesting content and I am looking forward to flattring you if I like the content you provide.

BTW, if you like this blog post, you could flattr it: Just click on the Flattr button below in the original post (If you read this post from Planet Eclipse, just click on the post’s title to open the original post from my web site, then you should see a Flattr button at the end of this post).

Have Fun

Kai

Eclipse 4.0 RCP: Selection

5

One of the objectives of Eclipse 4.0 was to make rich client development easier. One good example is the following use case: One view provides a selection (e.g. using a JFace TableViewer) and another view wants to get notified about a new selection of a domain object to get the chance to react on it.

First the selection provider part. The selection services can be easily injected using dependency injection.


@Inject
private ESelectionService selectionService;

When using a JFace viewer, the viewer selection has to be forwarded to the selection service:


tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
  @Override
  public void selectionChanged(SelectionChangedEvent event) {
    IStructuredSelection selection =
       (IStructuredSelection) event.getSelection();
    selectionService.setSelection(selection.getFirstElement());
  }
});

On the consumer side, the domain object is injected using an @Optional and @Named active selection. The following code snipped is part of a details view POJO that uses a WritableValue (Eclipse data binding) as holder for the actual domain object (of type IContact).

@Inject
public void setSelection(
  @Optional @Named(IServiceConstants.ACTIVE_SELECTION) IContact contact) {
    if (contact != null) {
      contactValue.setValue(contact);
    }
}

That’s pretty convenient and concise compared with the code needed in Eclipse 3.x.

Have Fun!

Kai
Follow me on Twitter