Fixes #2209
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / preference / wizard / VocabularyTermWizard.java
index e143939e09350fb3925fec5da1271f2c5e1019bd..da7711b6a19a78a24cb13b9dbf3e6cb9fbfd93cb 100644 (file)
@@ -110,25 +110,10 @@ public class VocabularyTermWizard<T extends DefinedTermBase> extends Wizard impl
         * @param abbreviatedLabel a {@link java.lang.String} object.
         */
        public void setTerm(String text, String label, String abbreviatedLabel) {
-               
-               try {
-                       if(getTerm() == null){
-                               term = (T) termClass.newInstance();
-                               
-                               term.addRepresentation(new Representation(text, label, abbreviatedLabel, CdmStore.getDefaultLanguage()));
-                       }else{
-                               Representation representation = term.getPreferredRepresentation(CdmStore.getDefaultLanguage());
-                               representation.setText(text);
-                               representation.setLabel(label);
-                               representation.setAbbreviatedLabel(abbreviatedLabel);
-                       }
-                       
-               } catch (InstantiationException e) {
-                       StoreUtil.error(this.getClass(), "InstantiationException when setting term", e);
-               } catch (IllegalAccessException e) {
-                       StoreUtil.error(this.getClass(), "IllegalAccessException when setting term", e);
-               }
-               
+               Representation representation = getTerm().getRepresentation(CdmStore.getDefaultLanguage());
+               representation.setText(text);
+               representation.setLabel(label);
+               representation.setAbbreviatedLabel(abbreviatedLabel);
        }
        
        /**
@@ -137,11 +122,22 @@ public class VocabularyTermWizard<T extends DefinedTermBase> extends Wizard impl
         * @return the term
         */
        public T getTerm() {
+               if(term == null){
+                       try {
+                               term = (T) termClass.newInstance();
+                               
+                               term.addRepresentation(Representation.NewInstance("", "", "", CdmStore.getDefaultLanguage()));
+                       } catch (InstantiationException e) {
+                               StoreUtil.error(this.getClass(), "InstantiationException when setting term", e);
+                       } catch (IllegalAccessException e) {
+                               StoreUtil.error(this.getClass(), "IllegalAccessException when setting term", e);
+                       }
+               }
                return term;
        }
        
-       public Representation getRepresentation(){
-               return term != null ? term.getRepresentation(CdmStore.getDefaultLanguage()) : null;
+       public Representation getRepresentation(){              
+               return getTerm().getRepresentation(CdmStore.getDefaultLanguage());
        }
 
        /**