fix NPE in translation wizard
authorKatja Luther <k.luther@bgbm.org>
Thu, 30 Jun 2016 11:35:02 +0000 (13:35 +0200)
committerKatja Luther <k.luther@bgbm.org>
Thu, 30 Jun 2016 11:35:02 +0000 (13:35 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/translation/TranslationWizardPage.java

index e486e7f5214747645392aaa9eed950261663fa77..b217e7f5febb0dc02511eb2049ad878d5d45607f 100644 (file)
@@ -29,6 +29,7 @@ import eu.etaxonomy.cdm.model.common.LanguageString;
 import eu.etaxonomy.cdm.model.common.MultilanguageTextHelper;
 import eu.etaxonomy.cdm.model.common.TermType;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -98,10 +99,10 @@ public class TranslationWizardPage extends WizardPage{
                rightContainer.setLayout(LayoutConstants.LAYOUT(1, false));
 //             rightContainer.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
                RootElement rightRoot = new RootElement(formFactory, rightContainer);
-
+               
                createLeftControls(leftRoot);
                createRightControls(rightRoot);
-
+               
                // initialize with default language
                setSource(CdmStore.getDefaultLanguage());
 
@@ -132,7 +133,7 @@ public class TranslationWizardPage extends WizardPage{
        private void createLeftControls(ICdmFormElement element){
 
                combo_sourceLanguage = formFactory.createDefinedTermComboElement(TermType.Language, element, null, null, SWT.NULL);
-
+               
                combo_sourceLanguage.setTerms(getLanguages());
 
                combo_sourceLanguage.addSelectionListener(new SelectionAdapter() {
@@ -146,11 +147,13 @@ public class TranslationWizardPage extends WizardPage{
                });
 
                LanguageString preferredLanguageString = MultilanguageTextHelper.getPreferredLanguageString(multilanguageText, getLanguages());
-
+               if (preferredLanguageString == null){
+                       preferredLanguageString = LanguageString.NewInstance("", PreferencesUtil.getGlobalLanguage());
+               }
                text_source = formFactory.createLanguageStringWithLabelElement(element, null, preferredLanguageString, TEXT_HEIGHT, false, SWT.NULL);
 
 //             text_source.setEnabled(false);
-
+               
                text_source.setText(preferredLanguageString.getText());
        }