Fixes #2209
authorn.hoffmann <n.hoffmann@localhost>
Wed, 26 Jan 2011 14:44:18 +0000 (14:44 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 26 Jan 2011 14:44:18 +0000 (14:44 +0000)
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizard.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizardPage.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());
        }
 
        /**
index ffb37c01138bb23cfce61a2ecfe6f3835e90769d..fbacb97c6709b74fe3ee65a6bb9ccc50d1478d1c 100644 (file)
@@ -21,6 +21,7 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Text;
 
+import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.Representation;
 
@@ -91,9 +92,9 @@ public class VocabularyTermWizardPage<T extends DefinedTermBase> extends WizardP
                
                if(getWizard().getRepresentation() != null){
                        Representation representation = getWizard().getRepresentation();
-                       text_label.setText(representation.getLabel());
-                       text_labelAbbreviation.setText(representation.getAbbreviatedLabel());
-                       text_description.setText(representation.getDescription());
+                       text_label.setText(CdmUtils.Nz(representation.getLabel()));
+                       text_labelAbbreviation.setText(CdmUtils.Nz(representation.getAbbreviatedLabel()));
+                       text_description.setText(CdmUtils.Nz(representation.getDescription()));
                }
                
                setPageComplete(false);