Eclipse and the Ubuntu team working together – Solving the Eclipse menu issue under Ubuntu

I’m very happy to report that the Eclipse platform team worked together with the Canonical Ubuntu team to solve the broken menu issue of Eclipse under Ubuntu. This fix is available for Ubuntu 14.04.

It just to be the case that the menu of the Eclipse IDE did not work out of the box under Ubuntu and you had to use several tricks to make Eclipse work. This was relatively hard to discover for new users of Eclipse under Ubuntu and increased the barrier in using Eclipse.

We (Eclipse platform team) reached out to the Ubuntu team and William Hua from Canonical did solve this issue. I would like to thank William and the whole team from Ubuntu for that effort, they could also have pushed the issue back to the Eclipse side. But they went through the extra effort to solve it on their Ubuntu side. Kudos to them!

Thanks to William for doing most of the work, and also a big thanks to all involved parties, including Jono Bacon, Jason Warner from Canonical and Aleksandar Kurtakov, Paul Webster, Ian Skerrett and Mike Milinkovich from the Eclipse side. Especially thanks to Aleksandar Kurtakov from Red Hat for answering GTK3 SWT questions.

See Ubuntu Launchpad bug report for details.

Posted in Eclipse, Lars Vogel | Tagged , | 5 Comments

Eclipse platform contributors – please convert any patch you have to a Gerrit review

Yesterday Michael Keppler commented on my latest blog post the following:

Although the general process for contributions has improved, there is still quite a difference between what a single _committer_ can do, and what a single _contributor_ can do. It is frustrating if you create bug reports or patches, and no one looks at them. As a (non committer) contributor, you still very much depend on project committers, and their time is a scarce resource. Therefore, from the outside it does not look that easy to me as described by you.

I assume Michael is referring to patches in Bugzilla. The platform.ui team (and I believe the JDT team also) is IMHO good in reviewing Gerrit contributions. I agree that patches in Bugzilla tend to get ignored, I was no one has the time to find and review them.

So please convert any patch you have to a Gerrit review. See Eclipse platform contributions for a description of the required setup.

Posted in Eclipse, Lars Vogel | 3 Comments

Eclipse contributions – What difference can a single developer make?

I frequently hear that a single developer cannot make a difference for the Eclipse project. I think that is not true. The Eclipse project page show that in a lot of projects a handful of developers make most of the work.

See for example JDT project page and you see that Stephan Herrmann makes 24 % of the changes in JDT.

jdt_contributions

Kudos to Stephan for this. I hope others see this as opportunity to get involved into Eclipse development and to make a difference. See Eclipse platform development guide for starting points.

If you live close to Hamburg, please join our Eclipse Hackathon Friday this week.

Posted in Eclipse, Lars Vogel | Tagged | 5 Comments

Using Eclipse application model persisted state to specify the SWT stylebits

With Eclipse Luna M6 and M7 we introduced the possibility to set the stylebits for user interface controls via persisted state data. Use “styleOverride” as key and the integer value for the SWT stylebits you want to use.

For example to create a SWT shell which cannot be resized you need to supply the integer value for SWT.SHELL_TRIM & (~SWT.RESIZE), which is 1024 on the MWindow application element.

styleOverride

If your MPartStack should render its tab below the parts, use 1024.

This results in the following application (in which the window cannot be resized).

styleOverrideresult

Posted in Eclipse, Java, Lars Vogel | Tagged , | 1 Comment

Eclipse Luna M6 – Localization Update

With Eclipse Luna M6 there are some interesting news about localization.

Locale changes at runtime

The application model is now able to react on Locale changes at runtime. In combination with the Eclipse Translation Pattern that comes with the New Message Extension, an Eclipse based application can be re-localized at runtime. For this the MLocalizable mixin interface was introduced, which is now implemented by every model class that contains localizable information, e.g. MUILabel. In this blog post I would like to show how to change the locale at runtime with the new extension, rather than explaining the internals that enables this.

In a previous blog post I described how to change the Locale directly via setting the value to the context. With Luna M6 you should use the newly introduced ILocaleChangeService. This is because the default implementation of that service is updating the Locale in the application context and notifies the model elements. Additionally the ILocaleChangeService posts an event for the topic org/eclipse/e4/core/NLS/LOCALE_CHANGE to the event broker.

A command handler for changing the Locale would now look like this:

/**
 * Item that can be added as a ToolControl to the TrimBar of a
 * Window. Shows an input field which allows to enter a
 * locale String and a Button to send the action to update
 * the Locale.
 */
public class LocaleChangeItem {

	Button button;

	@Inject
	ILocaleChangeService lcs;

	@Inject
	public LocaleChangeItem(Composite parent) {
		final Text input = new Text(parent, SWT.BORDER);
		input.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if (e.keyCode == SWT.CR
					|| e.keyCode == SWT.KEYPAD_CR) {
					lcs.changeApplicationLocale(
						input.getText());
				}
			}
		});

		button = new Button(parent, SWT.PUSH);
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				lcs.changeApplicationLocale(
					input.getText());
			};
		});
	}

	@Inject
	public void translate(@Translation OsgiMessages messages) {
		//button localization via Eclipse Translation Pattern
		LocalizationHelper.updateButtonText(
			button, messages.button_change_locale);
	}
}

You can react on a Locale change in different ways:

  • by getting TranslationService.LOCALE injected (which is what the new message extension is doing)
    @Inject
    @Optional
    private void getNotified(
    	@Named(TranslationService.LOCALE) String s) {
    	System.out.println("Injected via context: " + s);
    }
  • by listening to the @UIEventTopic ILocaleChangeService.LOCALE_CHANGE via dependency injection
    @Inject
    @Optional
    private void getNotified(
    	@UIEventTopic(ILocaleChangeService.LOCALE_CHANGE) Locale s) {
    	System.out.println("Injected via event broker: " + s);
    }
  • by getting the newly created Message object instance injected
    @Inject
    public void translate(@Translation OsgiMessages messages) {
    	System.out.println("Messages injection");
    	//button localization via Eclipse Translation Pattern
    	LocalizationHelper.updateButtonText(
    		button, messages.button_change_locale);
    }
  • by listening to model updates directly (which is what the renderers need to do for example)

The example for the new message extension was updated to show the application model updates with Luna M6 aswell. You can find it at GitHub.

TranslationService Update

Another enhancement regarding localization is an update to the TranslationService. The TranslationService is responsible for localizing the application model. The default implementation BundleTranslationProvider is doing that job by using OSGi ResourceBundles. That means, it loads the file-based ResourceBundle typically located in OSGI-INF/l10n/bundle.properties. To change that, you could create a custom TranslationService implementation and put it to the context. But most of the time that meant to copy&paste some code. And it was not easily possible to configure a ResourceBundle that is located outside the OSGi context, which was asked at Stack Overflow. Two things were done to make it possible to exchange the ResourceBundle loading more easily:

  1. Modified the API of TranslationService.
  2. Introduced the new ResourceBundleProvider service, that is responsible for loading ResourceBundles.

The API modification of TranslationService is a quite simple one, as only the method getResourceString(String, ResourceBundle) was moved from BundleTranslationProvider to TranslationService with protected visibility. Therefore it is not necessary anymore to copy&paste that code for custom TranslationProvider implementations.

The BundleTranslationProvider was modified to use the newly introduced ResourceBundleProvider instead of having a direct dependency to BundleLocalization, which is loading the OSGi ResourceBundle. Of course the default implementation of ResourceBundleProvider is still using BundleLocalization. But with introducing ResourceBundleProvider, it is now possible to easily exchange the way the ResourceBundle is loaded, e.g. a ResourceBundle located on a different server can be loaded or a class-based ResourceBundle can be used. The following example is using a CustomResourceBundleControl, which simply returns a new class-based ResourceBundle instance.

public class CustomResourceBundleProvider
		implements ResourceBundleProvider {
	@Override
	public ResourceBundle getResourceBundle(
		Bundle bundle, String locale) {
		//we set the base name to be an empty String for
		//this simple example
		return ResourceBundle.getBundle("",
			ResourceBundleHelper.toLocale(locale),
			new CustomResourceBundleControl());
	}
}

class CustomResourceBundleControl extends Control
	@Override
	public ResourceBundle newBundle(String baseName, Locale locale,
		String format, ClassLoader loader, boolean reload)
		throws IllegalAccessException, InstantiationException,
			IOException {
		return new CustomListMockBundle();
	}
}

The CustomResourceBundleProvider needs to be set to the IEclipseContext before the model is passed to the renderer. This can be done either via a lifecycle manager in the @PostContextCreate method, or via model addon. In both cases the code gets executed before the model gets passed to the renderer, which is important as the renderer will request the values for the localized content.

public class LifecycleManager {
	@PostContextCreate
	public void postContextCreate(final IEclipseContext context) {
		//Use this to enable custom resource bundle loading,
		//e.g. using a custom ResourceBundle.Control
		context.set(ResourceBundleProvider.class,
			new CustomResourceBundleProvider());
	}
}

Note that the lifecycle manager needs to be registered via plugin.xml (see this vogella tutorial for more information), while the addon is registered via application model (see the Addons section in the Application Model Editor).

public class ResourceBundleAddon {
	@PostConstruct
	void postConstruct(final IEclipseContext context) {
		context.set(ResourceBundleProvider.class,
			new CustomResourceBundleProvider());
	}
}

Another advantage of the ResourceBundleProvider usage is that both, the application model and the new message extension, are using it in the last instance for searching the ResourceBundle to use for localizing the application. So it is only one step to exchange the ResourceBundle for application model and content.

The complete example can also be found at GitHub.

Posted in Dirk Fauth, Eclipse, OSGi | 4 Comments

How to contribute to the Eclipse Open Source project

As preparation for upcoming Eclipse Hackathons on EclipseCon US and the Eclipse Hackathon in Hamburg I updated my How to contribute to the Eclipse Open Source project guide.

I hope that helps new contributors to contribute to the amazing Eclipse platform project.

Posted in Eclipse, Lars Vogel | Tagged | Leave a comment

Next Eclipse Hackathon in Hamburg on 28.03

Our next Eclipse Hackathon in Hamburg has been schedule for the 28.03. Please join us to help to make the Eclipse platform even greater.

https://wiki.eclipse.org/Hackathon_Hamburg_2014

Posted in Eclipse, Lars Vogel | Tagged | Leave a comment

Dark Eclipse ships with Eclipse Luna

We (the Eclipse platform team) added a dark theme contributed by Andrea Guarinoni to Eclipse Luna M6. Lots of people were asking for a default dark theme. Of course SWT CSS styling has some limitation but were are planning to work on these. Having a default dark theme will help us doing so, as more people will start using it and might contribute to it via bug reports or patches.

Here is the Eclipse IDE using the dark theme under Linux.

contacts

And here is an RCP demo application called contacts which imports and extends the dark theme.

contacts

As you may noticed some of the icons are still looking ugly. We received another contribution from Tony McCrary from l33tlabs.com with a new set of icons for the platform and we are in the process of integrating them. For the platform ui icons, e.g., save and the like, we should be done already and I created Gerrit reviews for other platform components, like JDT, Debug and PDE and hope they pick them up soon.

If you want to test the new theme, go to http://download.eclipse.org/eclipse/downloads/ and download the M6 milestone. We are already working on some improvements for M7.

Posted in Eclipse, Lars Vogel | Tagged , | 17 Comments

Import CSS files in Eclipse Luna M6

Eclipse Luna M6 allows you to include other CSS stylesheets. For example to use the new Eclipse dark theme in your RCP application, do the following:

In your RCP application created a /css/default.css file with only one instruction

@import url(“platform:/plugin/org.eclipse.ui.themes/css/e4-dark.css”);

Add org.eclipse.ui.themes to your RCP product and add the applicationCSS property pointing to platform:/plugin/test/css/default.css in your product extension point. If you start your application is is dark styled.

Posted in Eclipse, Lars Vogel | Tagged | 1 Comment

More and more contributions to the Eclipse platform project

If you look at the Git platform.ui repository log, we are getting more and more people involved in providing patches to the Eclipse platform project. I did not count them, but I think we got contributions from at least 10 new contributors in the last two months. And some of them are starting to solve complex issues already.

From helping new contributors with the setup, I learned that for new contributors the Gerrit setup is relatively complex, therefore I created a detailed description:

Contributing to the Eclipse platform project – Gerrit setup

We have also created two “entry” level bugs, which new contributors can use to provide a simple fix, to learn the whole process:

Bug 425962 – [New Contributors] Remove (non-Javadoc) @see statements if @Override is used
Bug 428355 – [New Contributors] Fix warnings in platform projects

Posted in Eclipse, Lars Vogel | Tagged | Leave a comment