From 0552cc59f1ce4df38acd7c2d9512c6e150e8f22b Mon Sep 17 00:00:00 2001
From: buczekp <buczekp>
Date: Thu, 27 May 2010 11:20:28 +0000
Subject: [PATCH] SE-248 don't render vocabulary term code together with label
 in browsers and combo boxes

SVN: 16155
---
 .../client/application/model/VocabularyTermModel.java  | 10 +++-------
 .../model/renderer/VocabularyPropertyColRenderer.java  |  7 +------
 .../generic/shared/basic/dto/VocabularyTerm.java       |  6 ++++++
 3 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/VocabularyTermModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/VocabularyTermModel.java
index ea1492ba766..63a26d85d08 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/VocabularyTermModel.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/VocabularyTermModel.java
@@ -30,7 +30,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm;
  * 
  * @author Izabela Adamczyk
  */
-public class VocabularyTermModel extends NonHierarchicalBaseModel implements Comparable<VocabularyTermModel>
+public class VocabularyTermModel extends NonHierarchicalBaseModel implements
+        Comparable<VocabularyTermModel>
 {
     private static final String ORDINAL = "ordinal";
 
@@ -40,16 +41,11 @@ public class VocabularyTermModel extends NonHierarchicalBaseModel implements Com
     {
         set(ModelDataPropertyNames.CODE, term.getCode());
         set(ORDINAL, term.getOrdinal());
-        set(ModelDataPropertyNames.CODE_WITH_LABEL, getCodeWithLabel(term));
+        set(ModelDataPropertyNames.CODE_WITH_LABEL, term.getCodeOrLabel());
         set(ModelDataPropertyNames.TOOLTIP, VocabularyPropertyColRenderer.renderAsTooltip(term));
         set(ModelDataPropertyNames.OBJECT, term);
     }
 
-    private String getCodeWithLabel(VocabularyTerm term)
-    {
-        return VocabularyPropertyColRenderer.renderCodeWithLabel(term);
-    }
-
     public static final List<VocabularyTermModel> convert(List<VocabularyTerm> terms)
     {
         final ArrayList<VocabularyTermModel> list = new ArrayList<VocabularyTermModel>();
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/renderer/VocabularyPropertyColRenderer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/renderer/VocabularyPropertyColRenderer.java
index 8c6ee1ab249..103f80748f5 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/renderer/VocabularyPropertyColRenderer.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/renderer/VocabularyPropertyColRenderer.java
@@ -60,7 +60,7 @@ public class VocabularyPropertyColRenderer<T extends IEntityPropertiesHolder> ex
         final String description = term.getDescription();
         final String url = term.getUrl();
 
-        String result = renderCodeWithLabel(term);
+        String result = term.getCodeOrLabel();
         if (url != null)
         {
             result = ExternalHyperlink.createAnchorString(result, url);
@@ -70,11 +70,6 @@ public class VocabularyPropertyColRenderer<T extends IEntityPropertiesHolder> ex
         return result;
     }
 
-    public static final String renderCodeWithLabel(VocabularyTerm term)
-    {
-        return term.toString();
-    }
-
     public static final String renderAsTooltip(VocabularyTerm term)
     {
         final String code = term.getCode();
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java
index 993d7ebcea6..77fa0356a33 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java
@@ -94,6 +94,12 @@ public class VocabularyTerm extends CodeWithRegistration<Vocabulary> implements
         return label == null ? code : (code == null ? label : label + " [" + code + "]");
     }
 
+    public String getCodeOrLabel()
+    {
+        String code = getCode();
+        return label == null ? code : label;
+    }
+
     public String getUrl()
     {
         return url;
-- 
GitLab