#5908: add a default representation to a term with no representation
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / element / RepresentationElement.java
index b17f8e903cc3c1a6e299eed1666c2e498137da7b..e784d8df59ccd29fa611c8d856be56e5c0ac66b9 100644 (file)
@@ -44,6 +44,7 @@ SelectionListener{
         protected TextWithLabelElement element_text;
 
         protected Button button;
+        //protected Button deleteButton;
 
         protected Representation selectedRepresentation;
         protected TermBase term;
@@ -139,9 +140,7 @@ SelectionListener{
             combo_language.addSelectionListener(this);
 
             addControl(formFactory.createLabel(getLayoutComposite(), ""));
-
-
-        }
+       }
 
         public List<Language> getLanguages() {
 
@@ -203,6 +202,11 @@ SelectionListener{
         public void setTerm(
                 TermBase term, boolean update) {
             this.term = term;
+            if (term.getRepresentations().isEmpty()){
+               //if the term has no representation at all, create a default one.
+               Representation rep = Representation.NewInstance("", "", "", PreferencesUtil.getGlobalLanguage());
+               term.addRepresentation(rep);
+            }
 
             if (selectedRepresentation != null) {
                combo_language.setTerms(getLanguages());