Refactoring of selection elements. Additional minor refactoring. Fixed a bug with...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / translation / TranslationWizardPage.java
index e45397d0bb615bb27729ae91f67778b69cf21077..b7ffb17910db34320f806ac9ebaabdb5c9974cc7 100644 (file)
@@ -34,6 +34,7 @@ import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
 import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement;
 import eu.etaxonomy.taxeditor.ui.element.RootElement;
 
@@ -54,7 +55,7 @@ public class TranslationWizardPage extends WizardPage{
        
        private CdmFormFactory formFactory;
 
-       private TermComboElement combo_sourceLanguage;
+       private TermComboElement<Language> combo_sourceLanguage;
 
        private LanguageStringWithLabelElement text_source;
 
@@ -83,17 +84,17 @@ public class TranslationWizardPage extends WizardPage{
        public void createControl(Composite parent) {
                Composite control = formFactory.createComposite(parent);
 //             control.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GREEN));
-               control.setLayout(CdmFormFactory.LAYOUT(2, true));
+               control.setLayout(LayoutConstants.LAYOUT(2, true));
                
                Composite leftContainer = formFactory.createComposite(control);
-               leftContainer.setLayoutData(CdmFormFactory.FILL());
-               leftContainer.setLayout(CdmFormFactory.LAYOUT(1, false));
+               leftContainer.setLayoutData(LayoutConstants.FILL());
+               leftContainer.setLayout(LayoutConstants.LAYOUT(1, false));
 //             leftContainer.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
                RootElement leftRoot = new RootElement(formFactory, leftContainer);
                
                Composite rightContainer = formFactory.createComposite(control);
-               rightContainer.setLayoutData(CdmFormFactory.FILL());
-               rightContainer.setLayout(CdmFormFactory.LAYOUT(1, false));
+               rightContainer.setLayoutData(LayoutConstants.FILL());
+               rightContainer.setLayout(LayoutConstants.LAYOUT(1, false));
 //             rightContainer.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
                RootElement rightRoot = new RootElement(formFactory, rightContainer);
                
@@ -193,10 +194,15 @@ public class TranslationWizardPage extends WizardPage{
                                        Language sourceLanguage = text_source.getLanguageString().getLanguage();
                                        Language targetLanguage = combo_targetLanguage.getSelection();
                                        
+                                       if(targetLanguage == null){
+                                               StoreUtil.warningDialog("Please select a target language", TranslationWizardPage.class, "Please select a language from the combo box at the right.");
+                                               return;
+                                       }
+                                       
                                        translatedText = service.translate(text, sourceLanguage, targetLanguage);
                                        text_target.setText(translatedText);
                                } catch (LanguageNotSupportedException e) {
-                                       StoreUtil.warningDialog("Language not supported", TranslationWizardPage.class, e.getMessage());
+                                       StoreUtil.warningDialog("Language not supported", TranslationWizardPage.class, "The chosen language is not supported by the translation service.");
                                } catch (Exception e){
                                        StoreUtil.warningDialog("Error translating text", TranslationWizardPage.class, e.getMessage());
                                }