Bug 448068 - Adjust e4 tools to new local handling

Change-Id: I3ae73df26c0461ad6a1b9abbf35f16d87fd36e89
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
index ea1d5ec..601f235 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
@@ -350,7 +350,15 @@
 		this.context.set(ModelEditor.class, this);
 		this.obsManager = new ObservablesManager();
 		if (project != null) {
-			ProjectOSGiTranslationProvider translationProvider = new ProjectOSGiTranslationProvider(project, (String) this.context.get(TranslationService.LOCALE)) {
+			String localeString = ""; //$NON-NLS-1$
+			Object object = this.context.get(TranslationService.LOCALE);
+			// TODO simplify once we break e4 tools
+			// compatibility with Luna, in Luna we representation has changed to
+			// be Locale instead of String
+			if (object != null) {
+				localeString = object.toString();
+			}
+			ProjectOSGiTranslationProvider translationProvider = new ProjectOSGiTranslationProvider(project, localeString) {
 				@Override
 				protected void updateResourceBundle() {
 					super.updateResourceBundle();
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/properties/ProjectOSGiTranslationProvider.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/properties/ProjectOSGiTranslationProvider.java
index 6cefaa9..74c7f6f 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/properties/ProjectOSGiTranslationProvider.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/properties/ProjectOSGiTranslationProvider.java
@@ -55,6 +55,8 @@
 	 *            The initial {@link Locale} for which this translation provider
 	 *            should be created.
 	 */
+	// TODO change parameter to Locale instead of String once we break e4 tools
+	// compatibility with Luna
 	public ProjectOSGiTranslationProvider(IProject project, String locale) {
 		// create the translation provider with no initial ResourceBundle as we
 		// need to calculate it first
@@ -91,6 +93,8 @@
 		}
 	}
 
+	// TODO remove once we break e4 tools
+	// compatibility with Luna
 	@Inject
 	void setLocale(@Named(TranslationService.LOCALE) String locale, @Optional Boolean performUpdate) {
 		try {
@@ -103,8 +107,16 @@
 			updateResourceBundle();
 	}
 
+	@Inject
+	void setLocale(@Named(TranslationService.LOCALE) Locale locale, @Optional Boolean performUpdate) {
+		this.locale = locale == null ? Locale.getDefault() : locale;
+
+		if (performUpdate == null || performUpdate)
+			updateResourceBundle();
+	}
+
 	/**
-	 * 
+	 *
 	 * @param delta
 	 *            The resource delta that represents the changes in the state of
 	 *            a resource tree between two discrete points in time.
@@ -154,7 +166,7 @@
 	 * Will check if the manifest header identifying the base name of the
 	 * bundle's localization entries has changed and if so it will update the
 	 * underlying {@link ResourceBundle} and clear the caches.
-	 * 
+	 *
 	 * @param file
 	 *            The reference to the manifest file of the current project.
 	 */
@@ -181,7 +193,7 @@
 	/**
 	 * Extracts the manifest header identifying the base name of the bundle's
 	 * localization entries.
-	 * 
+	 *
 	 * @param file
 	 *            The reference to the manifest file of the current project.
 	 * @return The manifest header identifying the base name of the bundle's
@@ -190,7 +202,7 @@
 	 *             If loading the contents of the given {@link IFile} fails
 	 * @throws IOException
 	 *             If reading out of the given file fails.
-	 * 
+	 *
 	 * @see IFile#getContents()
 	 */
 	public static String extractBasenameFromManifest(IFile file) throws CoreException, IOException {
@@ -219,7 +231,7 @@
 	/**
 	 * Specialization of {@link Control} which loads the {@link ResourceBundle}
 	 * by using file structures of a project instead of using a classloader.
-	 * 
+	 *
 	 * @author Dirk Fauth
 	 */
 	class ProjectResourceBundleControl extends ResourceBundle.Control {
@@ -275,7 +287,7 @@
 		/**
 		 * Loads the properties file by using the {@link IProject} of the
 		 * {@link ProjectOSGiTranslationProvider}.
-		 * 
+		 *
 		 * @param name
 		 * @return The {@link InputStream} to the properties file to load
 		 */