From 78b1284c2d063f17be07ff0a4239e91519fd07b3 Mon Sep 17 00:00:00 2001 From: "n.hoffmann" Date: Wed, 26 Jan 2011 14:44:18 +0000 Subject: [PATCH] Fixes #2209 --- .../wizard/VocabularyTermWizard.java | 38 +++++++++---------- .../wizard/VocabularyTermWizardPage.java | 7 ++-- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizard.java index e143939e0..da7711b6a 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizard.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizard.java @@ -110,25 +110,10 @@ public class VocabularyTermWizard 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 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()); } /** diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizardPage.java index ffb37c011..fbacb97c6 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizardPage.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizardPage.java @@ -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 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); -- 2.34.1