Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / translation / TranslationWizardPage.java
index 46ca1194360209baa6e42148fccf9923a2de7198..558ae50a8d6b246e89e4a0d8dba099d8424648af 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy
@@ -28,8 +27,9 @@ import eu.etaxonomy.cdm.model.common.Language;
 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.store.StoreUtil;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -98,10 +98,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 +132,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 +146,13 @@ public class TranslationWizardPage extends WizardPage{
                });
 
                LanguageString preferredLanguageString = MultilanguageTextHelper.getPreferredLanguageString(multilanguageText, getLanguages());
-
-               text_source = formFactory.createLanguageStringWithLabelElement(element, null, preferredLanguageString, TEXT_HEIGHT, SWT.NULL);
+               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());
        }
 
@@ -170,6 +172,7 @@ public class TranslationWizardPage extends WizardPage{
                                Language language = combo_targetLanguage.getSelection();
 
                                if (language == null){
+                                       setPageComplete(false);
                                        return;
                                }
 
@@ -186,7 +189,7 @@ public class TranslationWizardPage extends WizardPage{
                        }
                });
 
-               text_target = formFactory.createLanguageStringWithLabelElement(element, null, null, TEXT_HEIGHT, SWT.NULL);
+               text_target = formFactory.createLanguageStringWithLabelElement(element, null, null, TEXT_HEIGHT, false, SWT.NULL);
 
                //
                // The automated translation did rely on the Google Translate API. Unfortunately this service is not free anymore.
@@ -237,7 +240,7 @@ public class TranslationWizardPage extends WizardPage{
                        if (language != null){
                                languageList.add(language);
                        }else{
-                               StoreUtil.warningDialog("Empty languages", getClass(), "The multilanguage string contains invalid data. Please contact the administrator of you datasource.");
+                               MessagingUtils.warningDialog("Empty languages", getClass(), "The multilanguage string contains invalid data. Please contact the administrator of you datasource.");
                        }
                }