| /** |
| * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf), Loetz GmbH&Co.KG (Heidelberg) |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Florian Pirchner - Initial implementation |
| */ |
| package org.eclipse.osbp.dsl.entity.xtext.tests.blobtests; |
| |
| import java.beans.PropertyChangeListener; |
| import java.beans.PropertyChangeSupport; |
| import java.util.HashMap; |
| import java.util.Locale; |
| import org.eclipse.osbp.runtime.common.i18n.ITranslator; |
| import org.slf4j.Logger; |
| |
| @SuppressWarnings("all") |
| public class TestsBlobtestsTranslator implements ITranslator { |
| private static Logger log = org.slf4j.LoggerFactory.getLogger("translations by translator"); |
| |
| private static org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.TestsBlobtestsTranslator instance = null; |
| |
| private static Locale lastLocale = null; |
| |
| private PropertyChangeSupport pcs = new java.beans.PropertyChangeSupport(this); |
| |
| private HashMap<String, String> translations = new HashMap<String,String>() {{ |
| put("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.foobar","foobar"); |
| put("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.id","id"); |
| put("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.myblob","myblob"); |
| put("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.name","name"); |
| }}; |
| |
| private static String foobar; |
| |
| private static String id; |
| |
| private static String myblob; |
| |
| private static String name; |
| |
| public static org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.TestsBlobtestsTranslator getInstance(final Locale locale) { |
| if(instance == null) { |
| instance = new org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.TestsBlobtestsTranslator(); |
| if (lastLocale == null) { |
| instance.changeLocale(locale); |
| } |
| } |
| return instance; |
| } |
| |
| public void addPropertyChangeListener(final PropertyChangeListener listener) { |
| this.pcs.addPropertyChangeListener(listener); |
| } |
| |
| public void removePropertyChangeListener(final PropertyChangeListener listener) { |
| this.pcs.removePropertyChangeListener(listener); |
| } |
| |
| public void mergeTranslations() { |
| |
| } |
| |
| public HashMap<String, String> getTranslations() { |
| return translations; |
| } |
| |
| public String getFoobar() { |
| if (log.isDebugEnabled()) log.debug("getFoobar returns:"+this.foobar); |
| return this.foobar; |
| } |
| |
| public String getId() { |
| if (log.isDebugEnabled()) log.debug("getId returns:"+this.id); |
| return this.id; |
| } |
| |
| public String getMyblob() { |
| if (log.isDebugEnabled()) log.debug("getMyblob returns:"+this.myblob); |
| return this.myblob; |
| } |
| |
| public String getName() { |
| if (log.isDebugEnabled()) log.debug("getName returns:"+this.name); |
| return this.name; |
| } |
| |
| public void setFoobar(final String newFoobar) { |
| if (log.isDebugEnabled()) log.debug("setFoobar called:"+newFoobar); |
| String oldFoobar = this.foobar; |
| this.foobar = newFoobar; |
| translations.put("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.foobar", newFoobar); |
| this.pcs.firePropertyChange("foobar", oldFoobar, newFoobar); |
| } |
| |
| public void setId(final String newId) { |
| if (log.isDebugEnabled()) log.debug("setId called:"+newId); |
| String oldId = this.id; |
| this.id = newId; |
| translations.put("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.id", newId); |
| this.pcs.firePropertyChange("id", oldId, newId); |
| } |
| |
| public void setMyblob(final String newMyblob) { |
| if (log.isDebugEnabled()) log.debug("setMyblob called:"+newMyblob); |
| String oldMyblob = this.myblob; |
| this.myblob = newMyblob; |
| translations.put("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.myblob", newMyblob); |
| this.pcs.firePropertyChange("myblob", oldMyblob, newMyblob); |
| } |
| |
| public void setName(final String newName) { |
| if (log.isDebugEnabled()) log.debug("setName called:"+newName); |
| String oldName = this.name; |
| this.name = newName; |
| translations.put("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.name", newName); |
| this.pcs.firePropertyChange("name", oldName, newName); |
| } |
| |
| public void changeLocale(final Locale locale) { |
| // avoid unnecessary settings |
| if (locale == null) { |
| if (log.isDebugEnabled()) log.debug("locale for org.eclipse.osbp.dsl.entity.xtext.tests.blobtests is null."); |
| return; |
| } |
| if (locale.equals(lastLocale)) { |
| if (log.isDebugEnabled()) log.debug("locale for org.eclipse.osbp.dsl.entity.xtext.tests.blobtests already set to "+locale.getDisplayLanguage()); |
| return; |
| } |
| if (log.isDebugEnabled()) log.debug("locale for org.eclipse.osbp.dsl.entity.xtext.tests.blobtests set to "+locale.getDisplayLanguage()); |
| lastLocale = locale; |
| // call the imported translators change locale method |
| try { |
| java.util.ResourceBundle resource = java.util.ResourceBundle.getBundle("i18n.I18N", locale, getClass().getClassLoader()); |
| try { |
| setFoobar(resource.getString("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.foobar")); |
| } catch (Exception e) { |
| log.error(getClass().getCanonicalName()+" - "+e.getLocalizedMessage()); |
| } |
| try { |
| setId(resource.getString("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.id")); |
| } catch (Exception e) { |
| log.error(getClass().getCanonicalName()+" - "+e.getLocalizedMessage()); |
| } |
| try { |
| setMyblob(resource.getString("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.myblob")); |
| } catch (Exception e) { |
| log.error(getClass().getCanonicalName()+" - "+e.getLocalizedMessage()); |
| } |
| try { |
| setName(resource.getString("org.eclipse.osbp.dsl.entity.xtext.tests.blobtests.name")); |
| } catch (Exception e) { |
| log.error(getClass().getCanonicalName()+" - "+e.getLocalizedMessage()); |
| } |
| } catch (java.util.MissingResourceException mre) { |
| System.err.println(getClass().getCanonicalName()+" - "+mre.getLocalizedMessage()); |
| } |
| |
| } |
| } |